]> git.karo-electronics.de Git - linux-beck.git/commitdiff
Merge 3.15-rc3 into staging-next
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 28 Apr 2014 04:38:34 +0000 (21:38 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 28 Apr 2014 04:38:34 +0000 (21:38 -0700)
470 files changed:
Documentation/ABI/testing/sysfs-bus-iio
Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 [new file with mode: 0644]
Documentation/devicetree/bindings/iio/proximity/as3935.txt [new file with mode: 0644]
Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt
Documentation/devicetree/bindings/vendor-prefixes.txt
MAINTAINERS
drivers/iio/Kconfig
drivers/iio/Makefile
drivers/iio/accel/st_accel_core.c
drivers/iio/adc/Kconfig
drivers/iio/adc/Makefile
drivers/iio/adc/ad799x.c [moved from drivers/staging/iio/adc/ad799x_core.c with 81% similarity]
drivers/iio/adc/mcp3422.c
drivers/iio/common/st_sensors/st_sensors_core.c
drivers/iio/gyro/itg3200_core.c
drivers/iio/gyro/st_gyro_core.c
drivers/iio/imu/inv_mpu6050/Kconfig
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
drivers/iio/industrialio-core.c
drivers/iio/industrialio-event.c
drivers/iio/inkern.c
drivers/iio/magnetometer/Kconfig
drivers/iio/magnetometer/ak8975.c
drivers/iio/magnetometer/st_magn_core.c
drivers/iio/pressure/st_pressure_core.c
drivers/iio/proximity/Kconfig [new file with mode: 0644]
drivers/iio/proximity/Makefile [new file with mode: 0644]
drivers/iio/proximity/as3935.c [new file with mode: 0644]
drivers/staging/Kconfig
drivers/staging/Makefile
drivers/staging/android/binder.c
drivers/staging/android/ion/ion_carveout_heap.c
drivers/staging/android/ion/ion_chunk_heap.c
drivers/staging/android/ion/ion_system_heap.c
drivers/staging/android/ram_console.h [deleted file]
drivers/staging/android/uapi/ion.h
drivers/staging/bcm/CmHost.c
drivers/staging/bcm/InterfaceMisc.h
drivers/staging/bcm/Qos.c
drivers/staging/bcm/hostmibs.c
drivers/staging/comedi/comedi_fops.c
drivers/staging/comedi/drivers.c
drivers/staging/comedi/drivers/8255.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
drivers/staging/comedi/drivers/addi_apci_1032.c
drivers/staging/comedi/drivers/addi_apci_1500.c
drivers/staging/comedi/drivers/addi_apci_1564.c
drivers/staging/comedi/drivers/addi_apci_2032.c
drivers/staging/comedi/drivers/addi_apci_3120.c
drivers/staging/comedi/drivers/addi_apci_3xxx.c
drivers/staging/comedi/drivers/adl_pci9111.c
drivers/staging/comedi/drivers/adl_pci9118.c
drivers/staging/comedi/drivers/adv_pci1710.c
drivers/staging/comedi/drivers/amplc_dio200_common.c
drivers/staging/comedi/drivers/amplc_pc236.c
drivers/staging/comedi/drivers/amplc_pci224.c
drivers/staging/comedi/drivers/amplc_pci230.c
drivers/staging/comedi/drivers/cb_pcidas.c
drivers/staging/comedi/drivers/cb_pcidas64.c
drivers/staging/comedi/drivers/comedi_parport.c
drivers/staging/comedi/drivers/comedi_test.c
drivers/staging/comedi/drivers/das16.c
drivers/staging/comedi/drivers/das16m1.c
drivers/staging/comedi/drivers/das1800.c
drivers/staging/comedi/drivers/das6402.c
drivers/staging/comedi/drivers/das800.c
drivers/staging/comedi/drivers/dmm32at.c
drivers/staging/comedi/drivers/dt282x.c
drivers/staging/comedi/drivers/gsc_hpdi.c
drivers/staging/comedi/drivers/me4000.c
drivers/staging/comedi/drivers/ni_6527.c
drivers/staging/comedi/drivers/ni_65xx.c
drivers/staging/comedi/drivers/ni_at_a2150.c
drivers/staging/comedi/drivers/ni_labpc.c
drivers/staging/comedi/drivers/ni_mio_common.c
drivers/staging/comedi/drivers/ni_pcidio.c
drivers/staging/comedi/drivers/ni_tiocmd.c
drivers/staging/comedi/drivers/pcl726.c
drivers/staging/comedi/drivers/pcl812.c
drivers/staging/comedi/drivers/pcmmio.c
drivers/staging/comedi/drivers/pcmuio.c
drivers/staging/comedi/drivers/rtd520.c
drivers/staging/comedi/drivers/s626.c
drivers/staging/comedi/drivers/usbdux.c
drivers/staging/comedi/drivers/usbduxfast.c
drivers/staging/comedi/drivers/usbduxsigma.c
drivers/staging/crystalhd/crystalhd_lnx.c
drivers/staging/cxt1e1/hwprobe.c
drivers/staging/cxt1e1/linux.c
drivers/staging/cxt1e1/musycc.c
drivers/staging/cxt1e1/pmc93x6_eeprom.c
drivers/staging/cxt1e1/pmcc4_drv.c
drivers/staging/cxt1e1/pmcc4_private.h
drivers/staging/cxt1e1/sbecom_inline_linux.h
drivers/staging/cxt1e1/sbecrc.c
drivers/staging/cxt1e1/sbeproc.c
drivers/staging/dgap/dgap.c
drivers/staging/dgap/dgap.h
drivers/staging/fwserial/dma_fifo.c
drivers/staging/fwserial/dma_fifo.h
drivers/staging/fwserial/fwserial.c
drivers/staging/goldfish/README
drivers/staging/goldfish/goldfish_audio.c
drivers/staging/goldfish/goldfish_nand.c
drivers/staging/iio/adc/Kconfig
drivers/staging/iio/adc/Makefile
drivers/staging/iio/adc/ad7606.h
drivers/staging/iio/adc/ad7816.c
drivers/staging/iio/adc/ad799x.h [deleted file]
drivers/staging/iio/adc/ad799x_ring.c [deleted file]
drivers/staging/iio/adc/spear_adc.c
drivers/staging/iio/addac/adt7316.c
drivers/staging/iio/cdc/ad7152.c
drivers/staging/iio/cdc/ad7746.c
drivers/staging/iio/light/tsl2583.c
drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
drivers/staging/imx-drm/imx-drm-core.c
drivers/staging/imx-drm/imx-hdmi.c
drivers/staging/imx-drm/ipu-v3/ipu-common.c
drivers/staging/imx-drm/ipu-v3/ipu-dc.c
drivers/staging/imx-drm/parallel-display.c
drivers/staging/keucr/init.c
drivers/staging/keucr/init.h
drivers/staging/keucr/smil.h
drivers/staging/keucr/smilsub.c
drivers/staging/keucr/transport.c
drivers/staging/line6/driver.c
drivers/staging/line6/pcm.c
drivers/staging/line6/playback.c
drivers/staging/line6/toneport.c
drivers/staging/lustre/include/linux/libcfs/libcfs.h
drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
drivers/staging/lustre/include/linux/libcfs/linux/linux-lock.h
drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h
drivers/staging/lustre/include/linux/lnet/lib-lnet.h
drivers/staging/lustre/include/linux/lnet/lib-types.h
drivers/staging/lustre/include/linux/lnet/lnetst.h
drivers/staging/lustre/include/linux/lnet/ptllnd.h
drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h
drivers/staging/lustre/include/linux/lnet/types.h
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
drivers/staging/lustre/lnet/lnet/api-ni.c
drivers/staging/lustre/lustre/fid/lproc_fid.c
drivers/staging/lustre/lustre/include/dt_object.h
drivers/staging/lustre/lustre/include/ioctl.h [deleted file]
drivers/staging/lustre/lustre/include/linux/obd.h
drivers/staging/lustre/lustre/include/lprocfs_status.h
drivers/staging/lustre/lustre/include/lu_object.h
drivers/staging/lustre/lustre/include/lu_ref.h
drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
drivers/staging/lustre/lustre/include/lustre/lustre_user.h
drivers/staging/lustre/lustre/include/lustre_debug.h
drivers/staging/lustre/lustre/include/lustre_dlm.h
drivers/staging/lustre/lustre/include/lustre_lib.h
drivers/staging/lustre/lustre/include/lustre_log.h
drivers/staging/lustre/lustre/include/lustre_mdc.h
drivers/staging/lustre/lustre/include/lustre_net.h
drivers/staging/lustre/lustre/include/obd.h
drivers/staging/lustre/lustre/include/obd_class.h
drivers/staging/lustre/lustre/include/obd_lov.h [deleted file]
drivers/staging/lustre/lustre/include/obd_support.h
drivers/staging/lustre/lustre/lclient/lcommon_cl.c
drivers/staging/lustre/lustre/lclient/lcommon_misc.c
drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c
drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c
drivers/staging/lustre/lustre/libcfs/linux/linux-module.c
drivers/staging/lustre/lustre/libcfs/module.c
drivers/staging/lustre/lustre/libcfs/nidstrings.c
drivers/staging/lustre/lustre/libcfs/tracefile.c
drivers/staging/lustre/lustre/libcfs/tracefile.h
drivers/staging/lustre/lustre/libcfs/workitem.c
drivers/staging/lustre/lustre/llite/dcache.c
drivers/staging/lustre/lustre/llite/dir.c
drivers/staging/lustre/lustre/llite/file.c
drivers/staging/lustre/lustre/llite/llite_capa.c
drivers/staging/lustre/lustre/llite/llite_internal.h
drivers/staging/lustre/lustre/llite/llite_lib.c
drivers/staging/lustre/lustre/llite/llite_mmap.c
drivers/staging/lustre/lustre/llite/llite_nfs.c
drivers/staging/lustre/lustre/llite/lloop.c
drivers/staging/lustre/lustre/llite/lproc_llite.c
drivers/staging/lustre/lustre/llite/namei.c
drivers/staging/lustre/lustre/llite/remote_perm.c
drivers/staging/lustre/lustre/llite/rw.c
drivers/staging/lustre/lustre/llite/rw26.c
drivers/staging/lustre/lustre/llite/statahead.c
drivers/staging/lustre/lustre/llite/super25.c
drivers/staging/lustre/lustre/llite/symlink.c
drivers/staging/lustre/lustre/llite/vvp_dev.c
drivers/staging/lustre/lustre/llite/vvp_internal.h
drivers/staging/lustre/lustre/llite/vvp_io.c
drivers/staging/lustre/lustre/llite/vvp_object.c
drivers/staging/lustre/lustre/llite/xattr.c
drivers/staging/lustre/lustre/llite/xattr_cache.c
drivers/staging/lustre/lustre/lmv/lmv_obd.c
drivers/staging/lustre/lustre/lmv/lproc_lmv.c
drivers/staging/lustre/lustre/lov/Makefile
drivers/staging/lustre/lustre/lov/lov_dev.c
drivers/staging/lustre/lustre/lov/lov_ea.c
drivers/staging/lustre/lustre/lov/lov_internal.h
drivers/staging/lustre/lustre/lov/lov_lock.c
drivers/staging/lustre/lustre/lov/lov_log.c [deleted file]
drivers/staging/lustre/lustre/lov/lov_merge.c
drivers/staging/lustre/lustre/lov/lov_obd.c
drivers/staging/lustre/lustre/lov/lov_object.c
drivers/staging/lustre/lustre/lov/lov_offset.c
drivers/staging/lustre/lustre/lov/lov_pack.c
drivers/staging/lustre/lustre/lov/lov_request.c
drivers/staging/lustre/lustre/lov/lovsub_dev.c
drivers/staging/lustre/lustre/lov/lovsub_lock.c
drivers/staging/lustre/lustre/lov/lovsub_object.c
drivers/staging/lustre/lustre/mdc/mdc_locks.c
drivers/staging/lustre/lustre/mdc/mdc_reint.c
drivers/staging/lustre/lustre/mdc/mdc_request.c
drivers/staging/lustre/lustre/mgc/mgc_request.c
drivers/staging/lustre/lustre/obdclass/cl_lock.c
drivers/staging/lustre/lustre/obdclass/cl_object.c
drivers/staging/lustre/lustre/obdclass/cl_page.c
drivers/staging/lustre/lustre/obdclass/debug.c
drivers/staging/lustre/lustre/obdclass/genops.c
drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
drivers/staging/lustre/lustre/obdclass/llog_obd.c
drivers/staging/lustre/lustre/obdclass/obd_mount.c
drivers/staging/lustre/lustre/obdecho/echo_client.c
drivers/staging/lustre/lustre/osc/lproc_osc.c
drivers/staging/lustre/lustre/osc/osc_cache.c
drivers/staging/lustre/lustre/osc/osc_cl_internal.h
drivers/staging/lustre/lustre/osc/osc_dev.c
drivers/staging/lustre/lustre/osc/osc_io.c
drivers/staging/lustre/lustre/osc/osc_lock.c
drivers/staging/lustre/lustre/osc/osc_object.c
drivers/staging/lustre/lustre/osc/osc_request.c
drivers/staging/lustre/lustre/ptlrpc/client.c
drivers/staging/lustre/lustre/ptlrpc/events.c
drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c
drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c
drivers/staging/lustre/lustre/ptlrpc/import.c
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
drivers/staging/lustre/lustre/ptlrpc/nrs.c
drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
drivers/staging/lustre/lustre/ptlrpc/pinger.c
drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h
drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c
drivers/staging/lustre/lustre/ptlrpc/recover.c
drivers/staging/lustre/lustre/ptlrpc/sec.c
drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
drivers/staging/lustre/lustre/ptlrpc/service.c
drivers/staging/netlogic/xlr_net.c
drivers/staging/panel/panel.c
drivers/staging/rtl8188eu/core/rtw_br_ext.c
drivers/staging/rtl8188eu/core/rtw_cmd.c
drivers/staging/rtl8188eu/core/rtw_led.c
drivers/staging/rtl8188eu/core/rtw_p2p.c
drivers/staging/rtl8188eu/core/rtw_recv.c
drivers/staging/rtl8188eu/core/rtw_wlan_util.c
drivers/staging/rtl8188eu/hal/rtl8188eu_led.c
drivers/staging/rtl8188eu/hal/usb_halinit.c
drivers/staging/rtl8188eu/include/drv_types.h
drivers/staging/rtl8188eu/include/drv_types_linux.h [deleted file]
drivers/staging/rtl8188eu/include/rtw_cmd.h
drivers/staging/rtl8188eu/include/rtw_led.h
drivers/staging/rtl8188eu/include/xmit_osdep.h
drivers/staging/rtl8188eu/os_dep/os_intfs.c
drivers/staging/rtl8188eu/os_dep/usb_intf.c
drivers/staging/rtl8192e/rtl8192e/Kconfig
drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c
drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.h
drivers/staging/rtl8192e/rtl8192e/r8192E_hwimg.c
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
drivers/staging/rtl8192e/rtl8192e/rtl_core.c
drivers/staging/rtl8192e/rtl8192e/rtl_core.h
drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
drivers/staging/rtl8192e/rtl8192e/rtl_wx.h
drivers/staging/rtl8192e/rtl819x_BAProc.c
drivers/staging/rtl8192e/rtl819x_TSProc.c
drivers/staging/rtl8192e/rtllib_rx.c
drivers/staging/rtl8192e/rtllib_softmac.c
drivers/staging/rtl8192u/r8190_rtl8256.c
drivers/staging/rtl8723au/Kconfig
drivers/staging/rtl8723au/Makefile
drivers/staging/rtl8723au/core/rtw_ap.c
drivers/staging/rtl8723au/core/rtw_cmd.c
drivers/staging/rtl8723au/core/rtw_ieee80211.c
drivers/staging/rtl8723au/core/rtw_io.c
drivers/staging/rtl8723au/core/rtw_ioctl_set.c
drivers/staging/rtl8723au/core/rtw_mlme.c
drivers/staging/rtl8723au/core/rtw_mlme_ext.c
drivers/staging/rtl8723au/core/rtw_p2p.c [deleted file]
drivers/staging/rtl8723au/core/rtw_pwrctrl.c
drivers/staging/rtl8723au/core/rtw_recv.c
drivers/staging/rtl8723au/core/rtw_sreset.c
drivers/staging/rtl8723au/core/rtw_sta_mgt.c
drivers/staging/rtl8723au/core/rtw_wlan_util.c
drivers/staging/rtl8723au/core/rtw_xmit.c
drivers/staging/rtl8723au/hal/hal_com.c
drivers/staging/rtl8723au/hal/hal_intf.c
drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c
drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
drivers/staging/rtl8723au/hal/rtl8723a_dm.c
drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
drivers/staging/rtl8723au/hal/rtl8723au_recv.c
drivers/staging/rtl8723au/hal/usb_halinit.c
drivers/staging/rtl8723au/hal/usb_ops_linux.c
drivers/staging/rtl8723au/include/cmd_osdep.h [deleted file]
drivers/staging/rtl8723au/include/drv_types.h
drivers/staging/rtl8723au/include/ethernet.h [deleted file]
drivers/staging/rtl8723au/include/hal_com.h
drivers/staging/rtl8723au/include/hal_intf.h
drivers/staging/rtl8723au/include/ieee80211.h
drivers/staging/rtl8723au/include/mlme_osdep.h
drivers/staging/rtl8723au/include/osdep_intf.h
drivers/staging/rtl8723au/include/osdep_service.h
drivers/staging/rtl8723au/include/recv_osdep.h
drivers/staging/rtl8723au/include/rtl8723a_cmd.h
drivers/staging/rtl8723au/include/rtl8723a_hal.h
drivers/staging/rtl8723au/include/rtw_ap.h
drivers/staging/rtl8723au/include/rtw_cmd.h
drivers/staging/rtl8723au/include/rtw_io.h
drivers/staging/rtl8723au/include/rtw_mlme.h
drivers/staging/rtl8723au/include/rtw_mlme_ext.h
drivers/staging/rtl8723au/include/rtw_p2p.h [deleted file]
drivers/staging/rtl8723au/include/rtw_pwrctrl.h
drivers/staging/rtl8723au/include/rtw_recv.h
drivers/staging/rtl8723au/include/rtw_security.h
drivers/staging/rtl8723au/include/rtw_xmit.h
drivers/staging/rtl8723au/include/sta_info.h
drivers/staging/rtl8723au/include/usb_ops.h
drivers/staging/rtl8723au/include/usb_ops_linux.h
drivers/staging/rtl8723au/include/wifi.h
drivers/staging/rtl8723au/include/xmit_osdep.h
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
drivers/staging/rtl8723au/os_dep/mlme_linux.c
drivers/staging/rtl8723au/os_dep/os_intfs.c
drivers/staging/rtl8723au/os_dep/osdep_service.c
drivers/staging/rtl8723au/os_dep/recv_linux.c
drivers/staging/rtl8723au/os_dep/usb_intf.c
drivers/staging/rtl8723au/os_dep/usb_ops_linux.c
drivers/staging/rtl8723au/os_dep/xmit_linux.c
drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c
drivers/staging/rtl8821ae/pci.c
drivers/staging/rtl8821ae/rtl8821ae/hw.h
drivers/staging/rtl8821ae/wifi.h
drivers/staging/sbe-2t3e3/2t3e3.h [deleted file]
drivers/staging/sbe-2t3e3/Kconfig [deleted file]
drivers/staging/sbe-2t3e3/Makefile [deleted file]
drivers/staging/sbe-2t3e3/TODO [deleted file]
drivers/staging/sbe-2t3e3/cpld.c [deleted file]
drivers/staging/sbe-2t3e3/ctrl.c [deleted file]
drivers/staging/sbe-2t3e3/ctrl.h [deleted file]
drivers/staging/sbe-2t3e3/dc.c [deleted file]
drivers/staging/sbe-2t3e3/exar7250.c [deleted file]
drivers/staging/sbe-2t3e3/exar7300.c [deleted file]
drivers/staging/sbe-2t3e3/intr.c [deleted file]
drivers/staging/sbe-2t3e3/io.c [deleted file]
drivers/staging/sbe-2t3e3/main.c [deleted file]
drivers/staging/sbe-2t3e3/maps.c [deleted file]
drivers/staging/sbe-2t3e3/module.c [deleted file]
drivers/staging/sbe-2t3e3/netdev.c [deleted file]
drivers/staging/silicom/bpctl_mod.c
drivers/staging/silicom/bypasslib/bypass.c
drivers/staging/skein/Kconfig [new file with mode: 0644]
drivers/staging/skein/Makefile [new file with mode: 0644]
drivers/staging/skein/TODO [new file with mode: 0644]
drivers/staging/skein/include/skein.h [new file with mode: 0644]
drivers/staging/skein/include/skeinApi.h [new file with mode: 0644]
drivers/staging/skein/include/skein_block.h [new file with mode: 0644]
drivers/staging/skein/include/skein_iv.h [new file with mode: 0644]
drivers/staging/skein/include/threefishApi.h [new file with mode: 0644]
drivers/staging/skein/skein.c [new file with mode: 0644]
drivers/staging/skein/skeinApi.c [new file with mode: 0644]
drivers/staging/skein/skeinBlockNo3F.c [new file with mode: 0644]
drivers/staging/skein/skein_block.c [new file with mode: 0644]
drivers/staging/skein/threefish1024Block.c [new file with mode: 0644]
drivers/staging/skein/threefish256Block.c [new file with mode: 0644]
drivers/staging/skein/threefish512Block.c [new file with mode: 0644]
drivers/staging/skein/threefishApi.c [new file with mode: 0644]
drivers/staging/slicoss/slicoss.c
drivers/staging/speakup/kobjects.c
drivers/staging/unisys/channels/channel.c
drivers/staging/unisys/channels/chanstub.c
drivers/staging/unisys/channels/chanstub.h
drivers/staging/unisys/common-spar/include/channels/channel.h
drivers/staging/unisys/common-spar/include/channels/channel_guid.h
drivers/staging/unisys/common-spar/include/channels/controlframework.h
drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
drivers/staging/unisys/common-spar/include/channels/diagchannel.h
drivers/staging/unisys/common-spar/include/channels/iochannel.h
drivers/staging/unisys/common-spar/include/channels/vbuschannel.h
drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h
drivers/staging/unisys/common-spar/include/diagnostics/appos_subsystems.h
drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h
drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h
drivers/staging/unisys/common-spar/include/version.h
drivers/staging/unisys/common-spar/include/vmcallinterface.h
drivers/staging/unisys/include/commontypes.h
drivers/staging/unisys/include/guestlinuxdebug.h
drivers/staging/unisys/include/guidutils.h
drivers/staging/unisys/include/periodic_work.h
drivers/staging/unisys/include/procobjecttree.h
drivers/staging/unisys/include/sparstop.h
drivers/staging/unisys/include/timskmod.h
drivers/staging/unisys/include/timskmodutils.h
drivers/staging/unisys/include/uisqueue.h
drivers/staging/unisys/include/uisthread.h
drivers/staging/unisys/include/uisutils.h
drivers/staging/unisys/include/uniklog.h
drivers/staging/unisys/uislib/uislib.c
drivers/staging/unisys/uislib/uisqueue.c
drivers/staging/unisys/uislib/uisthread.c
drivers/staging/unisys/uislib/uisutils.c
drivers/staging/unisys/virthba/virthba.c
drivers/staging/unisys/virthba/virthba.h
drivers/staging/unisys/virtpci/virtpci.c
drivers/staging/unisys/virtpci/virtpci.h
drivers/staging/unisys/visorchannel/globals.h
drivers/staging/unisys/visorchannel/visorchannel.h
drivers/staging/unisys/visorchannel/visorchannel_funcs.c
drivers/staging/unisys/visorchannel/visorchannel_main.c
drivers/staging/unisys/visorchipset/controlvm.h
drivers/staging/unisys/visorchipset/controlvm_direct.c
drivers/staging/unisys/visorchipset/file.c
drivers/staging/unisys/visorchipset/file.h
drivers/staging/unisys/visorchipset/globals.h
drivers/staging/unisys/visorchipset/parser.c
drivers/staging/unisys/visorchipset/parser.h
drivers/staging/unisys/visorchipset/testing.h
drivers/staging/unisys/visorchipset/visorchipset.h
drivers/staging/unisys/visorchipset/visorchipset_main.c
drivers/staging/unisys/visorchipset/visorchipset_umode.h
drivers/staging/unisys/visorutil/charqueue.c
drivers/staging/unisys/visorutil/charqueue.h
drivers/staging/unisys/visorutil/easyproc.c
drivers/staging/unisys/visorutil/easyproc.h
drivers/staging/unisys/visorutil/memregion.h
drivers/staging/unisys/visorutil/memregion_direct.c
drivers/staging/unisys/visorutil/periodic_work.c
drivers/staging/unisys/visorutil/procobjecttree.c
drivers/staging/unisys/visorutil/visorkmodutils.c
drivers/staging/vme/devices/vme_user.c
drivers/staging/vt6655/card.c
drivers/staging/vt6655/datarate.c
drivers/staging/vt6655/device.h
drivers/staging/vt6655/ioctl.c
drivers/staging/vt6655/iwctl.c
drivers/staging/vt6655/wpactl.c
drivers/staging/vt6656/aes_ccmp.c
drivers/staging/vt6656/firmware.c
drivers/staging/vt6656/rxtx.c
drivers/staging/vt6656/rxtx.h
drivers/staging/vt6656/tether.h
drivers/staging/wlan-ng/prism2usb.c
drivers/staging/xgifb/XGI_main_26.c
drivers/staging/xgifb/vb_init.c
drivers/staging/xgifb/vb_setmode.c
include/linux/iio/common/st_sensors.h
include/linux/iio/consumer.h

index 6e02c5029152ea0832fdebdfa9bd9aff14188b2d..58ba3330030576e582843a263fa16fd34aafba64 100644 (file)
@@ -210,6 +210,14 @@ Contact:   linux-iio@vger.kernel.org
 Description:
                Scaled humidity measurement in milli percent.
 
+What:          /sys/bus/iio/devices/iio:deviceX/in_X_mean_raw
+KernelVersion: 3.5
+Contact:       linux-iio@vger.kernel.org
+Description:
+               Averaged raw measurement from channel X. The number of values
+               used for averaging is device specific. The converting rules for
+               normal raw values also applies to the averaged raw values.
+
 What:          /sys/bus/iio/devices/iio:deviceX/in_accel_offset
 What:          /sys/bus/iio/devices/iio:deviceX/in_accel_x_offset
 What:          /sys/bus/iio/devices/iio:deviceX/in_accel_y_offset
diff --git a/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 b/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935
new file mode 100644 (file)
index 0000000..6708c5e
--- /dev/null
@@ -0,0 +1,16 @@
+What           /sys/bus/iio/devices/iio:deviceX/in_proximity_raw
+Date:          March 2014
+KernelVersion: 3.15
+Contact:       Matt Ranostay <mranostay@gmail.com>
+Description:
+               Get the current distance in meters of storm (1km steps)
+               1000-40000 = distance in meters
+
+What           /sys/bus/iio/devices/iio:deviceX/sensor_sensitivity
+Date:          March 2014
+KernelVersion: 3.15
+Contact:       Matt Ranostay <mranostay@gmail.com>
+Description:
+               Show or set the gain boost of the amp, from 0-31 range.
+               18 = indoors (default)
+               14 = outdoors
diff --git a/Documentation/devicetree/bindings/iio/proximity/as3935.txt b/Documentation/devicetree/bindings/iio/proximity/as3935.txt
new file mode 100644 (file)
index 0000000..ae23dd8
--- /dev/null
@@ -0,0 +1,28 @@
+Austrian Microsystems AS3935 Franklin lightning sensor device driver
+
+Required properties:
+       - compatible: must be "ams,as3935"
+       - reg: SPI chip select number for the device
+       - spi-cpha: SPI Mode 1. Refer to spi/spi-bus.txt for generic SPI
+       slave node bindings.
+       - interrupt-parent : should be the phandle for the interrupt controller
+       - interrupts : the sole interrupt generated by the device
+
+       Refer to interrupt-controller/interrupts.txt for generic
+       interrupt client node bindings.
+
+Optional properties:
+       - ams,tuning-capacitor-pf: Calibration tuning capacitor stepping
+         value 0 - 120pF. This will require using the calibration data from
+         the manufacturer.
+
+Example:
+
+as3935@0 {
+       compatible = "ams,as3935";
+       reg = <0>;
+       spi-cpha;
+       interrupt-parent = <&gpio1>;
+       interrupts = <16 1>;
+       ams,tuning-capacitor-pf = <80>;
+};
index 3be5ce7a965447fa4129c0bc82cc6ade0863ace3..e75f0e549fff7cfe767786a83c57da5b5a4fe5b1 100644 (file)
@@ -61,6 +61,7 @@ Required properties:
 Optional properties:
 - interface_pix_fmt: How this display is connected to the
   display interface. Currently supported types: "rgb24", "rgb565", "bgr666"
+  and "lvds666".
 - edid: verbatim EDID data block describing attached display.
 - ddc: phandle describing the i2c bus handling the display data
   channel
index abc308083acb204c7625c5d53ed58d546c65f755..7e88bc6195653ac148c3e93ade52cce9ace87619 100644 (file)
@@ -13,6 +13,7 @@ allwinner     Allwinner Technology Co., Ltd.
 altr   Altera Corp.
 amcc   Applied Micro Circuits Corporation (APM, formally AMCC)
 amd    Advanced Micro Devices (AMD), Inc.
+ams    AMS AG
 amstaos        AMS-Taos Inc.
 apm    Applied Micro Circuits Corporation (APM)
 arm    ARM Ltd.
index e67ea244204163a5d0eb9e43239c5ccd4394bae1..da6867988988ebf640ab3d7f4bae43c02d21e03a 100644 (file)
@@ -8479,6 +8479,13 @@ M:       Florian Schilhabel <florian.c.schilhabel@googlemail.com>.
 S:     Odd Fixes
 F:     drivers/staging/rtl8712/
 
+STAGING - REALTEK RTL8723U WIRELESS DRIVER
+M:     Larry Finger <Larry.Finger@lwfinger.net>
+M:     Jes Sorensen <Jes.Sorensen@redhat.com>
+L:     linux-wireless@vger.kernel.org
+S:     Maintained
+F:     drivers/staging/rtl8723au/
+
 STAGING - SILICON MOTION SM7XX FRAME BUFFER DRIVER
 M:     Teddy Wang <teddy.wang@siliconmotion.com.cn>
 S:     Odd Fixes
index 5dd0e120a504cd68cf096c1304512af112c97862..743485e4d6f83c28de0729509b8951b9f112a4eb 100644 (file)
@@ -74,6 +74,7 @@ if IIO_TRIGGER
    source "drivers/iio/trigger/Kconfig"
 endif #IIO_TRIGGER
 source "drivers/iio/pressure/Kconfig"
+source "drivers/iio/proximity/Kconfig"
 source "drivers/iio/temperature/Kconfig"
 
 endif # IIO
index 887d39090d7568391d059bdf9f30902a6123cd25..698afc2d17ce84c62e8e7fea4473558505d11808 100644 (file)
@@ -24,5 +24,6 @@ obj-y += light/
 obj-y += magnetometer/
 obj-y += orientation/
 obj-y += pressure/
+obj-y += proximity/
 obj-y += temperature/
 obj-y += trigger/
index 38caedc76b98f20520f9be751fabc15e90b03793..a2abf7c2ce3be4cbd0cdcbb8dd2481035651d3bc 100644 (file)
@@ -459,6 +459,8 @@ int st_accel_common_probe(struct iio_dev *indio_dev,
        indio_dev->modes = INDIO_DIRECT_MODE;
        indio_dev->info = &accel_info;
 
+       st_sensors_power_enable(indio_dev);
+
        err = st_sensors_check_device_support(indio_dev,
                                ARRAY_SIZE(st_accel_sensors), st_accel_sensors);
        if (err < 0)
@@ -496,6 +498,9 @@ int st_accel_common_probe(struct iio_dev *indio_dev,
        if (err)
                goto st_accel_device_register_error;
 
+       dev_info(&indio_dev->dev, "registered accelerometer %s\n",
+                indio_dev->name);
+
        return 0;
 
 st_accel_device_register_error:
@@ -512,6 +517,8 @@ void st_accel_common_remove(struct iio_dev *indio_dev)
 {
        struct st_sensor_data *adata = iio_priv(indio_dev);
 
+       st_sensors_power_disable(indio_dev);
+
        iio_device_unregister(indio_dev);
        if (adata->get_irq_data_ready(indio_dev) > 0)
                st_sensors_deallocate_trigger(indio_dev);
index d86196cfe4b47091add5d756da6d3dbf7fded9eb..6cbf34a90c04b21fbb56cae6f711a3db386ef173 100644 (file)
@@ -96,6 +96,17 @@ config AD7923
          To compile this driver as a module, choose M here: the
          module will be called ad7923.
 
+config AD799X
+       tristate "Analog Devices AD799x ADC driver"
+       depends on I2C
+       select IIO_BUFFER
+       select IIO_TRIGGERED_BUFFER
+       help
+         Say yes here to build support for Analog Devices:
+         ad7991, ad7995, ad7999, ad7992, ad7993, ad7994, ad7997, ad7998
+         i2c analog to digital converters (ADC). Provides direct access
+         via sysfs.
+
 config AT91_ADC
        tristate "Atmel AT91 ADC"
        depends on ARCH_AT91
@@ -107,7 +118,7 @@ config AT91_ADC
 
 config EXYNOS_ADC
        bool "Exynos ADC driver support"
-       depends on OF
+       depends on ARCH_EXYNOS || (OF && COMPILE_TEST)
        help
          Core support for the ADC block found in the Samsung EXYNOS series
          of SoCs for drivers such as the touchscreen and hwmon to use to share
@@ -146,11 +157,12 @@ config MCP320X
          called mcp320x.
 
 config MCP3422
-       tristate "Microchip Technology MCP3422/3/4 driver"
+       tristate "Microchip Technology MCP3422/3/4/6/7/8 driver"
        depends on I2C
        help
-         Say yes here to build support for Microchip Technology's MCP3422,
-         MCP3423 or MCP3424 analog to digital converters.
+         Say yes here to build support for Microchip Technology's
+         MCP3422, MCP3423, MCP3424, MCP3426, MCP3427 or MCP3428
+         analog to digital converters.
 
          This driver can also be built as a module. If so, the module will be
          called mcp3422.
index ab346d88c68874e2ac06dc6f2911ef1ec6cf0f25..9d60f2deaaaf276d8b6c0ee5134feb520f3dec9c 100644 (file)
@@ -11,6 +11,7 @@ obj-$(CONFIG_AD7476) += ad7476.o
 obj-$(CONFIG_AD7791) += ad7791.o
 obj-$(CONFIG_AD7793) += ad7793.o
 obj-$(CONFIG_AD7887) += ad7887.o
+obj-$(CONFIG_AD799X) += ad799x.o
 obj-$(CONFIG_AT91_ADC) += at91_adc.o
 obj-$(CONFIG_EXYNOS_ADC) += exynos_adc.o
 obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o
similarity index 81%
rename from drivers/staging/iio/adc/ad799x_core.c
rename to drivers/iio/adc/ad799x.c
index 979ec77d6c2d1b17c9e644f720ad953ec9364e5a..16a8b14b1921746b9449ee0645d231e346655819 100644 (file)
 #include <linux/iio/sysfs.h>
 #include <linux/iio/events.h>
 #include <linux/iio/buffer.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/triggered_buffer.h>
 
-#include "ad799x.h"
+#define AD799X_CHANNEL_SHIFT                   4
+#define AD799X_STORAGEBITS                     16
+/*
+ * AD7991, AD7995 and AD7999 defines
+ */
+
+#define AD7991_REF_SEL                         0x08
+#define AD7991_FLTR                            0x04
+#define AD7991_BIT_TRIAL_DELAY                 0x02
+#define AD7991_SAMPLE_DELAY                    0x01
+
+/*
+ * AD7992, AD7993, AD7994, AD7997 and AD7998 defines
+ */
+
+#define AD7998_FLTR                            0x08
+#define AD7998_ALERT_EN                                0x04
+#define AD7998_BUSY_ALERT                      0x02
+#define AD7998_BUSY_ALERT_POL                  0x01
+
+#define AD7998_CONV_RES_REG                    0x0
+#define AD7998_ALERT_STAT_REG                  0x1
+#define AD7998_CONF_REG                                0x2
+#define AD7998_CYCLE_TMR_REG                   0x3
+
+#define AD7998_DATALOW_REG(x)                  ((x) * 3 + 0x4)
+#define AD7998_DATAHIGH_REG(x)                 ((x) * 3 + 0x5)
+#define AD7998_HYST_REG(x)                     ((x) * 3 + 0x6)
+
+#define AD7998_CYC_MASK                                0x7
+#define AD7998_CYC_DIS                         0x0
+#define AD7998_CYC_TCONF_32                    0x1
+#define AD7998_CYC_TCONF_64                    0x2
+#define AD7998_CYC_TCONF_128                   0x3
+#define AD7998_CYC_TCONF_256                   0x4
+#define AD7998_CYC_TCONF_512                   0x5
+#define AD7998_CYC_TCONF_1024                  0x6
+#define AD7998_CYC_TCONF_2048                  0x7
+
+#define AD7998_ALERT_STAT_CLEAR                        0xFF
+
+/*
+ * AD7997 and AD7997 defines
+ */
+
+#define AD7997_8_READ_SINGLE                   0x80
+#define AD7997_8_READ_SEQUENCE                 0x70
+/* TODO: move this into a common header */
+#define RES_MASK(bits) ((1 << (bits)) - 1)
+
+enum {
+       ad7991,
+       ad7995,
+       ad7999,
+       ad7992,
+       ad7993,
+       ad7994,
+       ad7997,
+       ad7998
+};
+
+/**
+ * struct ad799x_chip_info - chip specific information
+ * @channel:           channel specification
+ * @num_channels:      number of channels
+ * @monitor_mode:      whether the chip supports monitor interrupts
+ * @default_config:    device default configuration
+ * @event_attrs:       pointer to the monitor event attribute group
+ */
+struct ad799x_chip_info {
+       struct iio_chan_spec            channel[9];
+       int                             num_channels;
+       u16                             default_config;
+       const struct iio_info           *info;
+};
+
+struct ad799x_state {
+       struct i2c_client               *client;
+       const struct ad799x_chip_info   *chip_info;
+       struct regulator                *reg;
+       struct regulator                *vref;
+       unsigned                        id;
+       u16                             config;
+
+       u8                              *rx_buf;
+       unsigned int                    transfer_size;
+};
+
+/**
+ * ad799x_trigger_handler() bh of trigger launched polling to ring buffer
+ *
+ * Currently there is no option in this driver to disable the saving of
+ * timestamps within the ring.
+ **/
+static irqreturn_t ad799x_trigger_handler(int irq, void *p)
+{
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->indio_dev;
+       struct ad799x_state *st = iio_priv(indio_dev);
+       int b_sent;
+       u8 cmd;
+
+       switch (st->id) {
+       case ad7991:
+       case ad7995:
+       case ad7999:
+               cmd = st->config |
+                       (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT);
+               break;
+       case ad7992:
+       case ad7993:
+       case ad7994:
+               cmd = (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT) |
+                       AD7998_CONV_RES_REG;
+               break;
+       case ad7997:
+       case ad7998:
+               cmd = AD7997_8_READ_SEQUENCE | AD7998_CONV_RES_REG;
+               break;
+       default:
+               cmd = 0;
+       }
+
+       b_sent = i2c_smbus_read_i2c_block_data(st->client,
+                       cmd, st->transfer_size, st->rx_buf);
+       if (b_sent < 0)
+               goto out;
+
+       iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf,
+                       iio_get_time_ns());
+out:
+       iio_trigger_notify_done(indio_dev->trig);
+
+       return IRQ_HANDLED;
+}
 
 /*
  * ad799x register access by I2C
@@ -578,7 +714,8 @@ static int ad799x_probe(struct i2c_client *client,
        indio_dev->channels = st->chip_info->channel;
        indio_dev->num_channels = st->chip_info->num_channels;
 
-       ret = ad799x_register_ring_funcs_and_init(indio_dev);
+       ret = iio_triggered_buffer_setup(indio_dev, NULL,
+               &ad799x_trigger_handler, NULL);
        if (ret)
                goto error_disable_reg;
 
@@ -601,7 +738,7 @@ static int ad799x_probe(struct i2c_client *client,
        return 0;
 
 error_cleanup_ring:
-       ad799x_ring_cleanup(indio_dev);
+       iio_triggered_buffer_cleanup(indio_dev);
 error_disable_reg:
        if (!IS_ERR(st->vref))
                regulator_disable(st->vref);
@@ -618,7 +755,7 @@ static int ad799x_remove(struct i2c_client *client)
 
        iio_device_unregister(indio_dev);
 
-       ad799x_ring_cleanup(indio_dev);
+       iio_triggered_buffer_cleanup(indio_dev);
        if (!IS_ERR(st->vref))
                regulator_disable(st->vref);
        if (!IS_ERR(st->reg))
index 47dcb34ff44c47f6317a62c99e025df6eb6b27f6..51672256072bc8db2778e6c60982f320c680f3d4 100644 (file)
@@ -1,10 +1,11 @@
 /*
- * mcp3422.c - driver for the Microchip mcp3422/3/4 chip family
+ * mcp3422.c - driver for the Microchip mcp3422/3/4/6/7/8 chip family
  *
  * Copyright (C) 2013, Angelo Compagnucci
  * Author: Angelo Compagnucci <angelo.compagnucci@gmail.com>
  *
  * Datasheet: http://ww1.microchip.com/downloads/en/devicedoc/22088b.pdf
+ *            http://ww1.microchip.com/downloads/en/DeviceDoc/22226a.pdf
  *
  * This driver exports the value of analog input voltage to sysfs, the
  * voltage unit is nV.
@@ -96,6 +97,7 @@ static const int mcp3422_sign_extend[4] = {
 /* Client data (each client gets its own) */
 struct mcp3422 {
        struct i2c_client *i2c;
+       u8 id;
        u8 config;
        u8 pga[4];
        struct mutex lock;
@@ -238,6 +240,8 @@ static int mcp3422_write_raw(struct iio_dev *iio,
                        temp = MCP3422_SRATE_15;
                        break;
                case 3:
+                       if (adc->id > 4)
+                               return -EINVAL;
                        temp = MCP3422_SRATE_3;
                        break;
                default:
@@ -271,6 +275,17 @@ static int mcp3422_write_raw_get_fmt(struct iio_dev *indio_dev,
        }
 }
 
+static ssize_t mcp3422_show_samp_freqs(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       struct mcp3422 *adc = iio_priv(dev_to_iio_dev(dev));
+
+       if (adc->id > 4)
+               return sprintf(buf, "240 60 15\n");
+
+       return sprintf(buf, "240 60 15 3\n");
+}
+
 static ssize_t mcp3422_show_scales(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
@@ -284,12 +299,13 @@ static ssize_t mcp3422_show_scales(struct device *dev,
                mcp3422_scales[sample_rate][3]);
 }
 
-static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("240 60 15 3");
+static IIO_DEVICE_ATTR(sampling_frequency_available, S_IRUGO,
+               mcp3422_show_samp_freqs, NULL, 0);
 static IIO_DEVICE_ATTR(in_voltage_scale_available, S_IRUGO,
                mcp3422_show_scales, NULL, 0);
 
 static struct attribute *mcp3422_attributes[] = {
-       &iio_const_attr_sampling_frequency_available.dev_attr.attr,
+       &iio_dev_attr_sampling_frequency_available.dev_attr.attr,
        &iio_dev_attr_in_voltage_scale_available.dev_attr.attr,
        NULL,
 };
@@ -335,6 +351,7 @@ static int mcp3422_probe(struct i2c_client *client,
 
        adc = iio_priv(indio_dev);
        adc->i2c = client;
+       adc->id = (u8)(id->driver_data);
 
        mutex_init(&adc->lock);
 
@@ -343,13 +360,16 @@ static int mcp3422_probe(struct i2c_client *client,
        indio_dev->modes = INDIO_DIRECT_MODE;
        indio_dev->info = &mcp3422_info;
 
-       switch ((unsigned int)(id->driver_data)) {
+       switch (adc->id) {
        case 2:
        case 3:
+       case 6:
+       case 7:
                indio_dev->channels = mcp3422_channels;
                indio_dev->num_channels = ARRAY_SIZE(mcp3422_channels);
                break;
        case 4:
+       case 8:
                indio_dev->channels = mcp3424_channels;
                indio_dev->num_channels = ARRAY_SIZE(mcp3424_channels);
                break;
@@ -375,6 +395,9 @@ static const struct i2c_device_id mcp3422_id[] = {
        { "mcp3422", 2 },
        { "mcp3423", 3 },
        { "mcp3424", 4 },
+       { "mcp3426", 6 },
+       { "mcp3427", 7 },
+       { "mcp3428", 8 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, mcp3422_id);
@@ -399,5 +422,5 @@ static struct i2c_driver mcp3422_driver = {
 module_i2c_driver(mcp3422_driver);
 
 MODULE_AUTHOR("Angelo Compagnucci <angelo.compagnucci@gmail.com>");
-MODULE_DESCRIPTION("Microchip mcp3422/3/4 driver");
+MODULE_DESCRIPTION("Microchip mcp3422/3/4/6/7/8 driver");
 MODULE_LICENSE("GPL v2");
index 7ba1ef27021323ec82ccb8a2cb3242795bfb0116..e8b932fed70ecb4b97ac5eeb044a6fb0c41cfcdd 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/iio/iio.h>
+#include <linux/regulator/consumer.h>
 #include <asm/unaligned.h>
 
 #include <linux/iio/common/st_sensors.h>
@@ -198,6 +199,42 @@ int st_sensors_set_axis_enable(struct iio_dev *indio_dev, u8 axis_enable)
 }
 EXPORT_SYMBOL(st_sensors_set_axis_enable);
 
+void st_sensors_power_enable(struct iio_dev *indio_dev)
+{
+       struct st_sensor_data *pdata = iio_priv(indio_dev);
+       int err;
+
+       /* Regulators not mandatory, but if requested we should enable them. */
+       pdata->vdd = devm_regulator_get_optional(indio_dev->dev.parent, "vdd");
+       if (!IS_ERR(pdata->vdd)) {
+               err = regulator_enable(pdata->vdd);
+               if (err != 0)
+                       dev_warn(&indio_dev->dev,
+                                "Failed to enable specified Vdd supply\n");
+       }
+
+       pdata->vdd_io = devm_regulator_get_optional(indio_dev->dev.parent, "vddio");
+       if (!IS_ERR(pdata->vdd_io)) {
+               err = regulator_enable(pdata->vdd_io);
+               if (err != 0)
+                       dev_warn(&indio_dev->dev,
+                                "Failed to enable specified Vdd_IO supply\n");
+       }
+}
+EXPORT_SYMBOL(st_sensors_power_enable);
+
+void st_sensors_power_disable(struct iio_dev *indio_dev)
+{
+       struct st_sensor_data *pdata = iio_priv(indio_dev);
+
+       if (!IS_ERR(pdata->vdd))
+               regulator_disable(pdata->vdd);
+
+       if (!IS_ERR(pdata->vdd_io))
+               regulator_disable(pdata->vdd_io);
+}
+EXPORT_SYMBOL(st_sensors_power_disable);
+
 static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,
                                       struct st_sensors_platform_data *pdata)
 {
index 4d3f3b92b361ef06ec57649f664205201b0cfc34..8295e318399f9874ccde4f4429a001141a4004be 100644 (file)
@@ -110,8 +110,6 @@ static int itg3200_read_raw(struct iio_dev *indio_dev,
        default:
                return -EINVAL;
        }
-
-       return ret;
 }
 
 static ssize_t itg3200_read_frequency(struct device *dev,
index a8e174a47bc409cc22ece45c5a971ca3fe14f37d..ed74a906998953de9c97461a7f137323eb30ed5f 100644 (file)
@@ -311,6 +311,8 @@ int st_gyro_common_probe(struct iio_dev *indio_dev,
        indio_dev->modes = INDIO_DIRECT_MODE;
        indio_dev->info = &gyro_info;
 
+       st_sensors_power_enable(indio_dev);
+
        err = st_sensors_check_device_support(indio_dev,
                                ARRAY_SIZE(st_gyro_sensors), st_gyro_sensors);
        if (err < 0)
@@ -344,6 +346,9 @@ int st_gyro_common_probe(struct iio_dev *indio_dev,
        if (err)
                goto st_gyro_device_register_error;
 
+       dev_info(&indio_dev->dev, "registered gyroscope %s\n",
+                indio_dev->name);
+
        return 0;
 
 st_gyro_device_register_error:
@@ -360,6 +365,8 @@ void st_gyro_common_remove(struct iio_dev *indio_dev)
 {
        struct st_sensor_data *gdata = iio_priv(indio_dev);
 
+       st_sensors_power_disable(indio_dev);
+
        iio_device_unregister(indio_dev);
        if (gdata->get_irq_data_ready(indio_dev) > 0)
                st_sensors_deallocate_trigger(indio_dev);
index 361b2328453d478cd5ba945e91b9c242310b6119..2d0608ba88d7d6e375ae3b0f9c94853c4af84015 100644 (file)
@@ -9,6 +9,8 @@ config INV_MPU6050_IIO
        select IIO_TRIGGERED_BUFFER
        help
          This driver supports the Invensense MPU6050 devices.
+         This driver can also support MPU6500 in MPU6050 compatibility mode
+         and also in MPU6500 mode with some limitations.
          It is a gyroscope/accelerometer combo device.
          This driver can be built as a module. The module will be called
          inv-mpu6050.
index cb9f96b446a55cd138f129db3443d44821b32781..af287bf719154c2bbe75c7ae8a7fbc2bd88f4067 100644 (file)
@@ -764,6 +764,7 @@ static SIMPLE_DEV_PM_OPS(inv_mpu_pmops, inv_mpu_suspend, inv_mpu_resume);
  */
 static const struct i2c_device_id inv_mpu_id[] = {
        {"mpu6050", INV_MPU6050},
+       {"mpu6500", INV_MPU6500},
        {}
 };
 
index 0ab382be1e64198fbdce8edba42347c0740ce185..e7799315d4dc1c4167338a922215e3404bb389d8 100644 (file)
@@ -59,6 +59,7 @@ struct inv_mpu6050_reg_map {
 /*device enum */
 enum inv_devices {
        INV_MPU6050,
+       INV_MPU6500,
        INV_NUM_PARTS
 };
 
index ede16aec20fbd68ec01f729aaffa4543e02a8f0c..184444db62acaca683c8ebce22b0870c1ff7ebac 100644 (file)
@@ -340,7 +340,7 @@ ssize_t iio_enum_read(struct iio_dev *indio_dev,
        else if (i >= e->num_items)
                return -EINVAL;
 
-       return sprintf(buf, "%s\n", e->items[i]);
+       return snprintf(buf, PAGE_SIZE, "%s\n", e->items[i]);
 }
 EXPORT_SYMBOL_GPL(iio_enum_read);
 
@@ -716,6 +716,8 @@ static int iio_device_add_info_mask_type(struct iio_dev *indio_dev,
        int i, ret, attrcount = 0;
 
        for_each_set_bit(i, infomask, sizeof(infomask)*8) {
+               if (i >= ARRAY_SIZE(iio_chan_info_postfix))
+                       return -EINVAL;
                ret = __iio_add_chan_devattr(iio_chan_info_postfix[i],
                                             chan,
                                             &iio_read_channel_info,
@@ -820,7 +822,7 @@ static ssize_t iio_show_dev_name(struct device *dev,
                                 char *buf)
 {
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-       return sprintf(buf, "%s\n", indio_dev->name);
+       return snprintf(buf, PAGE_SIZE, "%s\n", indio_dev->name);
 }
 
 static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);
index ea6e06b9c7d42954cf6eb0d5ab86f18734e828b4..dddfb0f90d342e5b324bba657c5d194df6205a2d 100644 (file)
@@ -321,7 +321,9 @@ static int iio_device_add_event(struct iio_dev *indio_dev,
        char *postfix;
        int ret;
 
-       for_each_set_bit(i, mask, sizeof(*mask)) {
+       for_each_set_bit(i, mask, sizeof(*mask)*8) {
+               if (i >= ARRAY_SIZE(iio_ev_info_text))
+                       return -EINVAL;
                postfix = kasprintf(GFP_KERNEL, "%s_%s_%s",
                                iio_ev_type_text[type], iio_ev_dir_text[dir],
                                iio_ev_info_text[i]);
index 0cf5f8e06cfcc6b6bc8c059871e153a391cbd122..adeba5a0ecf70ff79ed4e3ed653ee6e4bf27b0ca 100644 (file)
@@ -443,6 +443,24 @@ err_unlock:
 }
 EXPORT_SYMBOL_GPL(iio_read_channel_raw);
 
+int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
+{
+       int ret;
+
+       mutex_lock(&chan->indio_dev->info_exist_lock);
+       if (chan->indio_dev->info == NULL) {
+               ret = -ENODEV;
+               goto err_unlock;
+       }
+
+       ret = iio_channel_read(chan, val, NULL, IIO_CHAN_INFO_AVERAGE_RAW);
+err_unlock:
+       mutex_unlock(&chan->indio_dev->info_exist_lock);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(iio_read_channel_average_raw);
+
 static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
        int raw, int *processed, unsigned int scale)
 {
index d86d226dcd67e09b585652ef983c9ccb038cdb99..05a364c543f851bae06bd35733676b7491a997fe 100644 (file)
@@ -11,7 +11,8 @@ config AK8975
        depends on GPIOLIB
        help
          Say yes here to build support for Asahi Kasei AK8975 3-Axis
-         Magnetometer.
+         Magnetometer. This driver can also support AK8963, if i2c
+         device name is identified as ak8963.
 
          To compile this driver as a module, choose M here: the module
          will be called ak8975.
index 74866d1efd1b8a646d2add6f5b5000cfbc52b925..f5c1d41bf39f550c7ccbf4464d11bc6a877009dc 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/bitops.h>
 #include <linux/gpio.h>
 #include <linux/of_gpio.h>
+#include <linux/acpi.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #define AK8975_MAX_CONVERSION_TIMEOUT  500
 #define AK8975_CONVERSION_DONE_POLL_TIME 10
 #define AK8975_DATA_READY_TIMEOUT      ((100*HZ)/1000)
-#define RAW_TO_GAUSS(asa) ((((asa) + 128) * 3000) / 256)
+#define RAW_TO_GAUSS_8975(asa) ((((asa) + 128) * 3000) / 256)
+#define RAW_TO_GAUSS_8963(asa) ((((asa) + 128) * 6000) / 256)
+
+/* Compatible Asahi Kasei Compass parts */
+enum asahi_compass_chipset {
+       AK8975,
+       AK8963,
+};
 
 /*
  * Per-instance context data for the device.
@@ -101,6 +109,7 @@ struct ak8975_data {
        int                     eoc_irq;
        wait_queue_head_t       data_ready_queue;
        unsigned long           flags;
+       enum asahi_compass_chipset chipset;
 };
 
 static const int ak8975_index_to_reg[] = {
@@ -272,9 +281,21 @@ static int ak8975_setup(struct i2c_client *client)
  * Since ASA doesn't change, we cache the resultant scale factor into the
  * device context in ak8975_setup().
  */
-       data->raw_to_gauss[0] = RAW_TO_GAUSS(data->asa[0]);
-       data->raw_to_gauss[1] = RAW_TO_GAUSS(data->asa[1]);
-       data->raw_to_gauss[2] = RAW_TO_GAUSS(data->asa[2]);
+       if (data->chipset == AK8963) {
+               /*
+                * H range is +-8190 and magnetometer range is +-4912.
+                * So HuT using the above explanation for 8975,
+                * 4912/8190 = ~ 6/10.
+                * So the Hadj should use 6/10 instead of 3/10.
+                */
+               data->raw_to_gauss[0] = RAW_TO_GAUSS_8963(data->asa[0]);
+               data->raw_to_gauss[1] = RAW_TO_GAUSS_8963(data->asa[1]);
+               data->raw_to_gauss[2] = RAW_TO_GAUSS_8963(data->asa[2]);
+       } else {
+               data->raw_to_gauss[0] = RAW_TO_GAUSS_8975(data->asa[0]);
+               data->raw_to_gauss[1] = RAW_TO_GAUSS_8975(data->asa[1]);
+               data->raw_to_gauss[2] = RAW_TO_GAUSS_8975(data->asa[2]);
+       }
 
        return 0;
 }
@@ -455,6 +476,27 @@ static const struct iio_info ak8975_info = {
        .driver_module = THIS_MODULE,
 };
 
+static const struct acpi_device_id ak_acpi_match[] = {
+       {"AK8975", AK8975},
+       {"AK8963", AK8963},
+       {"INVN6500", AK8963},
+       { },
+};
+MODULE_DEVICE_TABLE(acpi, ak_acpi_match);
+
+static char *ak8975_match_acpi_device(struct device *dev,
+                               enum asahi_compass_chipset *chipset)
+{
+       const struct acpi_device_id *id;
+
+       id = acpi_match_device(dev->driver->acpi_match_table, dev);
+       if (!id)
+               return NULL;
+       *chipset = (int)id->driver_data;
+
+       return (char *)dev_name(dev);
+}
+
 static int ak8975_probe(struct i2c_client *client,
                        const struct i2c_device_id *id)
 {
@@ -462,6 +504,7 @@ static int ak8975_probe(struct i2c_client *client,
        struct iio_dev *indio_dev;
        int eoc_gpio;
        int err;
+       char *name = NULL;
 
        /* Grab and set up the supplied GPIO. */
        if (client->dev.platform_data)
@@ -499,6 +542,19 @@ static int ak8975_probe(struct i2c_client *client,
        data->eoc_gpio = eoc_gpio;
        data->eoc_irq = 0;
 
+       /* id will be NULL when enumerated via ACPI */
+       if (id) {
+               data->chipset =
+                       (enum asahi_compass_chipset)(id->driver_data);
+               name = (char *) id->name;
+       } else if (ACPI_HANDLE(&client->dev))
+               name = ak8975_match_acpi_device(&client->dev, &data->chipset);
+       else {
+               err = -ENOSYS;
+               goto exit_free_iio;
+       }
+       dev_dbg(&client->dev, "Asahi compass chip %s\n", name);
+
        /* Perform some basic start-of-day setup of the device. */
        err = ak8975_setup(client);
        if (err < 0) {
@@ -515,7 +571,7 @@ static int ak8975_probe(struct i2c_client *client,
        indio_dev->info = &ak8975_info;
        indio_dev->name = id->name;
        indio_dev->modes = INDIO_DIRECT_MODE;
-
+       indio_dev->name = name;
        err = iio_device_register(indio_dev);
        if (err < 0)
                goto exit_free_iio;
@@ -552,7 +608,8 @@ static int ak8975_remove(struct i2c_client *client)
 }
 
 static const struct i2c_device_id ak8975_id[] = {
-       {"ak8975", 0},
+       {"ak8975", AK8975},
+       {"ak8963", AK8963},
        {}
 };
 
@@ -569,6 +626,7 @@ static struct i2c_driver ak8975_driver = {
        .driver = {
                .name   = "ak8975",
                .of_match_table = ak8975_of_match,
+               .acpi_match_table = ACPI_PTR(ak_acpi_match),
        },
        .probe          = ak8975_probe,
        .remove         = ak8975_remove,
index 52bbcfa1e07795208b45633ced62de0015772b74..240a21dd0c6111457ce171d37b5d43fa9b5b0316 100644 (file)
@@ -355,6 +355,8 @@ int st_magn_common_probe(struct iio_dev *indio_dev,
        indio_dev->modes = INDIO_DIRECT_MODE;
        indio_dev->info = &magn_info;
 
+       st_sensors_power_enable(indio_dev);
+
        err = st_sensors_check_device_support(indio_dev,
                                ARRAY_SIZE(st_magn_sensors), st_magn_sensors);
        if (err < 0)
@@ -387,6 +389,9 @@ int st_magn_common_probe(struct iio_dev *indio_dev,
        if (err)
                goto st_magn_device_register_error;
 
+       dev_info(&indio_dev->dev, "registered magnetometer %s\n",
+                indio_dev->name);
+
        return 0;
 
 st_magn_device_register_error:
@@ -403,6 +408,8 @@ void st_magn_common_remove(struct iio_dev *indio_dev)
 {
        struct st_sensor_data *mdata = iio_priv(indio_dev);
 
+       st_sensors_power_disable(indio_dev);
+
        iio_device_unregister(indio_dev);
        if (mdata->get_irq_data_ready(indio_dev) > 0)
                st_sensors_deallocate_trigger(indio_dev);
index 7418768ed49c62ef830d071f84f7506729129369..cd7e01f3a93b5fbfd59ade63de23fc8b11f436cc 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/iio/sysfs.h>
 #include <linux/iio/trigger.h>
 #include <linux/iio/buffer.h>
-#include <linux/regulator/consumer.h>
 #include <asm/unaligned.h>
 
 #include <linux/iio/common/st_sensors.h>
@@ -387,40 +386,6 @@ static const struct iio_trigger_ops st_press_trigger_ops = {
 #define ST_PRESS_TRIGGER_OPS NULL
 #endif
 
-static void st_press_power_enable(struct iio_dev *indio_dev)
-{
-       struct st_sensor_data *pdata = iio_priv(indio_dev);
-       int err;
-
-       /* Regulators not mandatory, but if requested we should enable them. */
-       pdata->vdd = devm_regulator_get_optional(&indio_dev->dev, "vdd");
-       if (!IS_ERR(pdata->vdd)) {
-               err = regulator_enable(pdata->vdd);
-               if (err != 0)
-                       dev_warn(&indio_dev->dev,
-                                "Failed to enable specified Vdd supply\n");
-       }
-
-       pdata->vdd_io = devm_regulator_get_optional(&indio_dev->dev, "vddio");
-       if (!IS_ERR(pdata->vdd_io)) {
-               err = regulator_enable(pdata->vdd_io);
-               if (err != 0)
-                       dev_warn(&indio_dev->dev,
-                                "Failed to enable specified Vdd_IO supply\n");
-       }
-}
-
-static void st_press_power_disable(struct iio_dev *indio_dev)
-{
-       struct st_sensor_data *pdata = iio_priv(indio_dev);
-
-       if (!IS_ERR(pdata->vdd))
-               regulator_disable(pdata->vdd);
-
-       if (!IS_ERR(pdata->vdd_io))
-               regulator_disable(pdata->vdd_io);
-}
-
 int st_press_common_probe(struct iio_dev *indio_dev,
                                struct st_sensors_platform_data *plat_data)
 {
@@ -431,7 +396,7 @@ int st_press_common_probe(struct iio_dev *indio_dev,
        indio_dev->modes = INDIO_DIRECT_MODE;
        indio_dev->info = &press_info;
 
-       st_press_power_enable(indio_dev);
+       st_sensors_power_enable(indio_dev);
 
        err = st_sensors_check_device_support(indio_dev,
                                              ARRAY_SIZE(st_press_sensors),
@@ -474,6 +439,9 @@ int st_press_common_probe(struct iio_dev *indio_dev,
        if (err)
                goto st_press_device_register_error;
 
+       dev_info(&indio_dev->dev, "registered pressure sensor %s\n",
+                indio_dev->name);
+
        return err;
 
 st_press_device_register_error:
@@ -490,7 +458,7 @@ void st_press_common_remove(struct iio_dev *indio_dev)
 {
        struct st_sensor_data *pdata = iio_priv(indio_dev);
 
-       st_press_power_disable(indio_dev);
+       st_sensors_power_disable(indio_dev);
 
        iio_device_unregister(indio_dev);
        if (pdata->get_irq_data_ready(indio_dev) > 0)
diff --git a/drivers/iio/proximity/Kconfig b/drivers/iio/proximity/Kconfig
new file mode 100644 (file)
index 0000000..0c8cdf5
--- /dev/null
@@ -0,0 +1,19 @@
+#
+# Proximity sensors
+#
+
+menu "Lightning sensors"
+
+config AS3935
+       tristate "AS3935 Franklin lightning sensor"
+       select IIO_BUFFER
+       select IIO_TRIGGERED_BUFFER
+       depends on SPI
+       help
+         Say Y here to build SPI interface support for the Austrian
+         Microsystems AS3935 lightning detection sensor.
+
+         To compile this driver as a module, choose M here: the
+         module will be called as3935
+
+endmenu
diff --git a/drivers/iio/proximity/Makefile b/drivers/iio/proximity/Makefile
new file mode 100644 (file)
index 0000000..743adee
--- /dev/null
@@ -0,0 +1,6 @@
+#
+# Makefile for IIO proximity sensors
+#
+
+# When adding new entries keep the list in alphabetical order
+obj-$(CONFIG_AS3935)           += as3935.o
diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
new file mode 100644 (file)
index 0000000..bf677bf
--- /dev/null
@@ -0,0 +1,456 @@
+/*
+ * as3935.c - Support for AS3935 Franklin lightning sensor
+ *
+ * Copyright (C) 2014 Matt Ranostay <mranostay@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (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/module.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/workqueue.h>
+#include <linux/mutex.h>
+#include <linux/err.h>
+#include <linux/irq.h>
+#include <linux/gpio.h>
+#include <linux/spi/spi.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/trigger.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/buffer.h>
+#include <linux/iio/triggered_buffer.h>
+#include <linux/of_gpio.h>
+
+
+#define AS3935_AFE_GAIN                0x00
+#define AS3935_AFE_MASK                0x3F
+#define AS3935_AFE_GAIN_MAX    0x1F
+#define AS3935_AFE_PWR_BIT     BIT(0)
+
+#define AS3935_INT             0x03
+#define AS3935_INT_MASK                0x07
+#define AS3935_EVENT_INT       BIT(3)
+#define AS3935_NOISE_INT       BIT(1)
+
+#define AS3935_DATA            0x07
+#define AS3935_DATA_MASK       0x3F
+
+#define AS3935_TUNE_CAP                0x08
+#define AS3935_CALIBRATE       0x3D
+
+#define AS3935_WRITE_DATA      BIT(15)
+#define AS3935_READ_DATA       BIT(14)
+#define AS3935_ADDRESS(x)      ((x) << 8)
+
+#define MAX_PF_CAP             120
+#define TUNE_CAP_DIV           8
+
+struct as3935_state {
+       struct spi_device *spi;
+       struct iio_trigger *trig;
+       struct mutex lock;
+       struct delayed_work work;
+
+       u32 tune_cap;
+       u8 buf[2] ____cacheline_aligned;
+};
+
+static const struct iio_chan_spec as3935_channels[] = {
+       {
+               .type           = IIO_PROXIMITY,
+               .info_mask_separate =
+                       BIT(IIO_CHAN_INFO_RAW) |
+                       BIT(IIO_CHAN_INFO_PROCESSED),
+               .scan_index     = 0,
+               .scan_type = {
+                       .sign           = 'u',
+                       .realbits       = 6,
+                       .storagebits    = 8,
+               },
+       },
+       IIO_CHAN_SOFT_TIMESTAMP(1),
+};
+
+static int as3935_read(struct as3935_state *st, unsigned int reg, int *val)
+{
+       u8 cmd;
+       int ret;
+
+       cmd = (AS3935_READ_DATA | AS3935_ADDRESS(reg)) >> 8;
+       ret = spi_w8r8(st->spi, cmd);
+       if (ret < 0)
+               return ret;
+       *val = ret;
+
+       return 0;
+};
+
+static int as3935_write(struct as3935_state *st,
+                               unsigned int reg,
+                               unsigned int val)
+{
+       u8 *buf = st->buf;
+
+       buf[0] = (AS3935_WRITE_DATA | AS3935_ADDRESS(reg)) >> 8;
+       buf[1] = val;
+
+       return spi_write(st->spi, buf, 2);
+};
+
+static ssize_t as3935_sensor_sensitivity_show(struct device *dev,
+                                       struct device_attribute *attr,
+                                       char *buf)
+{
+       struct as3935_state *st = iio_priv(dev_to_iio_dev(dev));
+       int val, ret;
+
+       ret = as3935_read(st, AS3935_AFE_GAIN, &val);
+       if (ret)
+               return ret;
+       val = (val & AS3935_AFE_MASK) >> 1;
+
+       return sprintf(buf, "%d\n", val);
+};
+
+static ssize_t as3935_sensor_sensitivity_store(struct device *dev,
+                                       struct device_attribute *attr,
+                                       const char *buf, size_t len)
+{
+       struct as3935_state *st = iio_priv(dev_to_iio_dev(dev));
+       unsigned long val;
+       int ret;
+
+       ret = kstrtoul((const char *) buf, 10, &val);
+       if (ret)
+               return -EINVAL;
+
+       if (val > AS3935_AFE_GAIN_MAX)
+               return -EINVAL;
+
+       as3935_write(st, AS3935_AFE_GAIN, val << 1);
+
+       return len;
+};
+
+static IIO_DEVICE_ATTR(sensor_sensitivity, S_IRUGO | S_IWUSR,
+       as3935_sensor_sensitivity_show, as3935_sensor_sensitivity_store, 0);
+
+
+static struct attribute *as3935_attributes[] = {
+       &iio_dev_attr_sensor_sensitivity.dev_attr.attr,
+       NULL,
+};
+
+static struct attribute_group as3935_attribute_group = {
+       .attrs = as3935_attributes,
+};
+
+static int as3935_read_raw(struct iio_dev *indio_dev,
+                          struct iio_chan_spec const *chan,
+                          int *val,
+                          int *val2,
+                          long m)
+{
+       struct as3935_state *st = iio_priv(indio_dev);
+       int ret;
+
+
+       switch (m) {
+       case IIO_CHAN_INFO_PROCESSED:
+       case IIO_CHAN_INFO_RAW:
+               *val2 = 0;
+               ret = as3935_read(st, AS3935_DATA, val);
+               if (ret)
+                       return ret;
+
+               if (m == IIO_CHAN_INFO_RAW)
+                       return IIO_VAL_INT;
+
+               /* storm out of range */
+               if (*val == AS3935_DATA_MASK)
+                       return -EINVAL;
+               *val *= 1000;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return IIO_VAL_INT;
+}
+
+static const struct iio_info as3935_info = {
+       .driver_module = THIS_MODULE,
+       .attrs = &as3935_attribute_group,
+       .read_raw = &as3935_read_raw,
+};
+
+static irqreturn_t as3935_trigger_handler(int irq, void *private)
+{
+       struct iio_poll_func *pf = private;
+       struct iio_dev *indio_dev = pf->indio_dev;
+       struct as3935_state *st = iio_priv(indio_dev);
+       int val, ret;
+
+       ret = as3935_read(st, AS3935_DATA, &val);
+       if (ret)
+               goto err_read;
+       val &= AS3935_DATA_MASK;
+       val *= 1000;
+
+       iio_push_to_buffers_with_timestamp(indio_dev, &val, pf->timestamp);
+err_read:
+       iio_trigger_notify_done(indio_dev->trig);
+
+       return IRQ_HANDLED;
+};
+
+static const struct iio_trigger_ops iio_interrupt_trigger_ops = {
+       .owner = THIS_MODULE,
+};
+
+static void as3935_event_work(struct work_struct *work)
+{
+       struct as3935_state *st;
+       int val;
+
+       st = container_of(work, struct as3935_state, work.work);
+
+       as3935_read(st, AS3935_INT, &val);
+       val &= AS3935_INT_MASK;
+
+       switch (val) {
+       case AS3935_EVENT_INT:
+               iio_trigger_poll(st->trig, iio_get_time_ns());
+               break;
+       case AS3935_NOISE_INT:
+               dev_warn(&st->spi->dev, "noise level is too high");
+               break;
+       }
+};
+
+static irqreturn_t as3935_interrupt_handler(int irq, void *private)
+{
+       struct iio_dev *indio_dev = private;
+       struct as3935_state *st = iio_priv(indio_dev);
+
+       /*
+        * Delay work for >2 milliseconds after an interrupt to allow
+        * estimated distance to recalculated.
+        */
+
+       schedule_delayed_work(&st->work, msecs_to_jiffies(3));
+
+       return IRQ_HANDLED;
+}
+
+static void calibrate_as3935(struct as3935_state *st)
+{
+       mutex_lock(&st->lock);
+
+       /* mask disturber interrupt bit */
+       as3935_write(st, AS3935_INT, BIT(5));
+
+       as3935_write(st, AS3935_CALIBRATE, 0x96);
+       as3935_write(st, AS3935_TUNE_CAP,
+               BIT(5) | (st->tune_cap / TUNE_CAP_DIV));
+
+       mdelay(2);
+       as3935_write(st, AS3935_TUNE_CAP, (st->tune_cap / TUNE_CAP_DIV));
+
+       mutex_unlock(&st->lock);
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int as3935_suspend(struct spi_device *spi, pm_message_t msg)
+{
+       struct iio_dev *indio_dev = spi_get_drvdata(spi);
+       struct as3935_state *st = iio_priv(indio_dev);
+       int val, ret;
+
+       mutex_lock(&st->lock);
+       ret = as3935_read(st, AS3935_AFE_GAIN, &val);
+       if (ret)
+               goto err_suspend;
+       val |= AS3935_AFE_PWR_BIT;
+
+       ret = as3935_write(st, AS3935_AFE_GAIN, val);
+
+err_suspend:
+       mutex_unlock(&st->lock);
+
+       return ret;
+}
+
+static int as3935_resume(struct spi_device *spi)
+{
+       struct iio_dev *indio_dev = spi_get_drvdata(spi);
+       struct as3935_state *st = iio_priv(indio_dev);
+       int val, ret;
+
+       mutex_lock(&st->lock);
+       ret = as3935_read(st, AS3935_AFE_GAIN, &val);
+       if (ret)
+               goto err_resume;
+       val &= ~AS3935_AFE_PWR_BIT;
+       ret = as3935_write(st, AS3935_AFE_GAIN, val);
+
+err_resume:
+       mutex_unlock(&st->lock);
+
+       return ret;
+}
+#else
+#define as3935_suspend NULL
+#define as3935_resume  NULL
+#endif
+
+static int as3935_probe(struct spi_device *spi)
+{
+       struct iio_dev *indio_dev;
+       struct iio_trigger *trig;
+       struct as3935_state *st;
+       struct device_node *np = spi->dev.of_node;
+       int ret;
+
+       /* Be sure lightning event interrupt is specified */
+       if (!spi->irq) {
+               dev_err(&spi->dev, "unable to get event interrupt\n");
+               return -EINVAL;
+       }
+
+       indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(st));
+       if (!indio_dev)
+               return -ENOMEM;
+
+       st = iio_priv(indio_dev);
+       st->spi = spi;
+       st->tune_cap = 0;
+
+       spi_set_drvdata(spi, indio_dev);
+       mutex_init(&st->lock);
+       INIT_DELAYED_WORK(&st->work, as3935_event_work);
+
+       ret = of_property_read_u32(np,
+                       "ams,tuning-capacitor-pf", &st->tune_cap);
+       if (ret) {
+               st->tune_cap = 0;
+               dev_warn(&spi->dev,
+                       "no tuning-capacitor-pf set, defaulting to %d",
+                       st->tune_cap);
+       }
+
+       if (st->tune_cap > MAX_PF_CAP) {
+               dev_err(&spi->dev,
+                       "wrong tuning-capacitor-pf setting of %d\n",
+                       st->tune_cap);
+               return -EINVAL;
+       }
+
+       indio_dev->dev.parent = &spi->dev;
+       indio_dev->name = spi_get_device_id(spi)->name;
+       indio_dev->channels = as3935_channels;
+       indio_dev->num_channels = ARRAY_SIZE(as3935_channels);
+       indio_dev->modes = INDIO_DIRECT_MODE;
+       indio_dev->info = &as3935_info;
+
+       trig = devm_iio_trigger_alloc(&spi->dev, "%s-dev%d",
+                                     indio_dev->name, indio_dev->id);
+
+       if (!trig)
+               return -ENOMEM;
+
+       st->trig = trig;
+       trig->dev.parent = indio_dev->dev.parent;
+       iio_trigger_set_drvdata(trig, indio_dev);
+       trig->ops = &iio_interrupt_trigger_ops;
+
+       ret = iio_trigger_register(trig);
+       if (ret) {
+               dev_err(&spi->dev, "failed to register trigger\n");
+               return ret;
+       }
+
+       ret = iio_triggered_buffer_setup(indio_dev, NULL,
+               &as3935_trigger_handler, NULL);
+
+       if (ret) {
+               dev_err(&spi->dev, "cannot setup iio trigger\n");
+               goto unregister_trigger;
+       }
+
+       calibrate_as3935(st);
+
+       ret = devm_request_irq(&spi->dev, spi->irq,
+                               &as3935_interrupt_handler,
+                               IRQF_TRIGGER_RISING,
+                               dev_name(&spi->dev),
+                               indio_dev);
+
+       if (ret) {
+               dev_err(&spi->dev, "unable to request irq\n");
+               goto unregister_buffer;
+       }
+
+       ret = iio_device_register(indio_dev);
+       if (ret < 0) {
+               dev_err(&spi->dev, "unable to register device\n");
+               goto unregister_buffer;
+       }
+       return 0;
+
+unregister_buffer:
+       iio_triggered_buffer_cleanup(indio_dev);
+
+unregister_trigger:
+       iio_trigger_unregister(st->trig);
+
+       return ret;
+};
+
+static int as3935_remove(struct spi_device *spi)
+{
+       struct iio_dev *indio_dev = spi_get_drvdata(spi);
+       struct as3935_state *st = iio_priv(indio_dev);
+
+       iio_device_unregister(indio_dev);
+       iio_triggered_buffer_cleanup(indio_dev);
+       iio_trigger_unregister(st->trig);
+
+       return 0;
+};
+
+static const struct spi_device_id as3935_id[] = {
+       {"as3935", 0},
+       {},
+};
+MODULE_DEVICE_TABLE(spi, as3935_id);
+
+static struct spi_driver as3935_driver = {
+       .driver = {
+               .name   = "as3935",
+               .owner  = THIS_MODULE,
+       },
+       .probe          = as3935_probe,
+       .remove         = as3935_remove,
+       .id_table       = as3935_id,
+       .suspend        = as3935_suspend,
+       .resume         = as3935_resume,
+};
+module_spi_driver(as3935_driver);
+
+MODULE_AUTHOR("Matt Ranostay <mranostay@gmail.com>");
+MODULE_DESCRIPTION("AS3935 lightning sensor");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("spi:as3935");
index 22365f140bec3d2d009b60d345369bd38aedf41a..0c3887778f38b9330bc7cd0fdc53849e234372f1 100644 (file)
@@ -90,8 +90,6 @@ source "drivers/staging/tidspbridge/Kconfig"
 
 source "drivers/staging/quickstart/Kconfig"
 
-source "drivers/staging/sbe-2t3e3/Kconfig"
-
 source "drivers/staging/keucr/Kconfig"
 
 source "drivers/staging/bcm/Kconfig"
@@ -144,6 +142,8 @@ source "drivers/staging/gs_fpgaboot/Kconfig"
 
 source "drivers/staging/nokia_h4p/Kconfig"
 
+source "drivers/staging/skein/Kconfig"
+
 source "drivers/staging/unisys/Kconfig"
 
 endif # STAGING
index fbe84ed2d048e4b953af51e2b9724945c7021db9..7bf91a6160668c8b6e6dbf841daeb447a0e8c6fc 100644 (file)
@@ -39,7 +39,6 @@ obj-$(CONFIG_CXT1E1)          += cxt1e1/
 obj-$(CONFIG_FB_XGI)           += xgifb/
 obj-$(CONFIG_TIDSPBRIDGE)      += tidspbridge/
 obj-$(CONFIG_ACPI_QUICKSTART)  += quickstart/
-obj-$(CONFIG_SBE_2T3E3)                += sbe-2t3e3/
 obj-$(CONFIG_USB_ENESTORAGE)   += keucr/
 obj-$(CONFIG_BCM_WIMAX)                += bcm/
 obj-$(CONFIG_FT1000)           += ft1000/
@@ -64,4 +63,5 @@ obj-$(CONFIG_DGAP)                    += dgap/
 obj-$(CONFIG_MTD_SPINAND_MT29F)        += mt29f_spinand/
 obj-$(CONFIG_GS_FPGABOOT)      += gs_fpgaboot/
 obj-$(CONFIG_BT_NOKIA_H4P)     += nokia_h4p/
+obj-$(CONFIG_CRYPTO_SKEIN)     += skein/
 obj-$(CONFIG_UNISYSSPAR)       += unisys/
index cfe4bc8f05cb82ec83b4e127ba53f8e72968a85c..1f5e2499ac1b2255caf7e598018f1cd52148767b 100644 (file)
@@ -2683,16 +2683,20 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
                binder_free_thread(proc, thread);
                thread = NULL;
                break;
-       case BINDER_VERSION:
+       case BINDER_VERSION: {
+               struct binder_version __user *ver = ubuf;
+
                if (size != sizeof(struct binder_version)) {
                        ret = -EINVAL;
                        goto err;
                }
-               if (put_user(BINDER_CURRENT_PROTOCOL_VERSION, &((struct binder_version *)ubuf)->protocol_version)) {
+               if (put_user(BINDER_CURRENT_PROTOCOL_VERSION,
+                            &ver->protocol_version)) {
                        ret = -EINVAL;
                        goto err;
                }
                break;
+       }
        default:
                ret = -EINVAL;
                goto err;
index 3cb05b9b0e93dd0183fa08372100e0074aa588e4..dcb6f2196c8742ed08a364ac3f438b0a45260b4e 100644 (file)
@@ -81,7 +81,7 @@ static int ion_carveout_heap_allocate(struct ion_heap *heap,
        if (align > PAGE_SIZE)
                return -EINVAL;
 
-       table = kzalloc(sizeof(struct sg_table), GFP_KERNEL);
+       table = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
        if (!table)
                return -ENOMEM;
        ret = sg_alloc_table(table, 1, GFP_KERNEL);
index d40f5f831808aa38b84d64c23954a504e059df32..3f2c12ba4d149aa9478e40d49ae375792252ec6e 100644 (file)
@@ -55,7 +55,7 @@ static int ion_chunk_heap_allocate(struct ion_heap *heap,
        if (allocated_size > chunk_heap->size - chunk_heap->allocated)
                return -ENOMEM;
 
-       table = kzalloc(sizeof(struct sg_table), GFP_KERNEL);
+       table = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
        if (!table)
                return -ENOMEM;
        ret = sg_alloc_table(table, num_chunks, GFP_KERNEL);
index c92363356ae142292fdcc29f0e1ebd758ff49e8c..0663a7fbfa6045909be58a636f5893cb18b30315 100644 (file)
@@ -166,7 +166,7 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
                max_order = info->order;
                i++;
        }
-       table = kzalloc(sizeof(struct sg_table), GFP_KERNEL);
+       table = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
        if (!table)
                goto err;
 
@@ -356,7 +356,7 @@ static int ion_system_contig_heap_allocate(struct ion_heap *heap,
        for (i = len >> PAGE_SHIFT; i < (1 << order); i++)
                __free_page(page + i);
 
-       table = kzalloc(sizeof(struct sg_table), GFP_KERNEL);
+       table = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
        if (!table) {
                ret = -ENOMEM;
                goto out;
diff --git a/drivers/staging/android/ram_console.h b/drivers/staging/android/ram_console.h
deleted file mode 100644 (file)
index 9f1125c..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2010 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 _INCLUDE_LINUX_PLATFORM_DATA_RAM_CONSOLE_H_
-#define _INCLUDE_LINUX_PLATFORM_DATA_RAM_CONSOLE_H_
-
-struct ram_console_platform_data {
-       const char *bootinfo;
-};
-
-#endif /* _INCLUDE_LINUX_PLATFORM_DATA_RAM_CONSOLE_H_ */
index f09e7c154d691ec4d1e0e5c73901129fbc397d6e..6aa4956733708b025c981197424517ed0d29f6fa 100644 (file)
@@ -27,12 +27,12 @@ typedef int ion_user_handle_t;
  * @ION_HEAP_TYPE_SYSTEM:       memory allocated via vmalloc
  * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc
  * @ION_HEAP_TYPE_CARVEOUT:     memory allocated from a prereserved
- *                              carveout heap, allocations are physically
- *                              contiguous
+ *                              carveout heap, allocations are physically
+ *                              contiguous
  * @ION_HEAP_TYPE_DMA:          memory allocated via DMA API
  * @ION_NUM_HEAPS:              helper for iterating over heaps, a bit mask
- *                              is used to identify the heaps, so only 32
- *                              total heap types are supported
+ *                              is used to identify the heaps, so only 32
+ *                              total heap types are supported
  */
 enum ion_heap_type {
        ION_HEAP_TYPE_SYSTEM,
@@ -50,7 +50,7 @@ enum ion_heap_type {
 #define ION_HEAP_CARVEOUT_MASK         (1 << ION_HEAP_TYPE_CARVEOUT)
 #define ION_HEAP_TYPE_DMA_MASK         (1 << ION_HEAP_TYPE_DMA)
 
-#define ION_NUM_HEAP_IDS               sizeof(unsigned int) * 8
+#define ION_NUM_HEAP_IDS               (sizeof(unsigned int) * 8)
 
 /**
  * allocation flags - the lower 16 bits are used by core ion, the upper 16
@@ -78,7 +78,7 @@ enum ion_heap_type {
  * @align:             required alignment of the allocation
  * @heap_id_mask:      mask of heap ids to allocate from
  * @flags:             flags passed to heap
- * @handle:            pointer that will be populated with a cookie to use to 
+ * @handle:            pointer that will be populated with a cookie to use to
  *                     refer to this allocation
  *
  * Provided by userspace as an argument to the ioctl
index 632f81a7c63fb80ff2e77e94618b946cb48fca99..4564c63f908c953e19321dd5699be157bd08b3c0 100644 (file)
@@ -460,42 +460,30 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer
        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "CopyToAdapter : u8CSSpecification : %X\n", psfLocalSet->u8CSSpecification);
        switch (psfLocalSet->u8CSSpecification) {
        case eCSPacketIPV4:
-       {
                Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS;
                break;
-       }
        case eCSPacketIPV6:
-       {
                Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV6_CS;
                break;
-       }
        case eCS802_3PacketEthernet:
        case eCS802_1QPacketVLAN:
-       {
                Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3;
                break;
-       }
        case eCSPacketIPV4Over802_1QVLAN:
        case eCSPacketIPV4Over802_3Ethernet:
-       {
                Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS;
                Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3;
                break;
-       }
        case eCSPacketIPV6Over802_1QVLAN:
        case eCSPacketIPV6Over802_3Ethernet:
-       {
                Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV6_CS;
                Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3;
                break;
-       }
        default:
-       {
                BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Error in value of CS Classification.. setting default to IP CS\n");
                Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS;
                break;
        }
-       }
 
        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "CopyToAdapter : Queue No : %X ETH CS Support :  %X  , IP CS Support : %X\n",
                        uiSearchRuleIndex,
@@ -542,32 +530,23 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer
                } else if (ucDsxType == DSC_ACK) {
                        switch (psfCSType->u8ClassfierDSCAction) {
                        case 0: /* DSC Add Classifier */
-                       {
                                eClassifierAction = eAddClassifier;
-                       }
-                       break;
+                               break;
                        case 1: /* DSC Replace Classifier */
-                       {
                                eClassifierAction = eReplaceClassifier;
-                       }
-                       break;
+                               break;
                        case 2: /* DSC Delete Classifier */
-                       {
                                eClassifierAction = eDeleteClassifier;
-                       }
-                       break;
+                               break;
                        default:
-                       {
                                eClassifierAction = eInvalidClassifierAction;
                        }
-                       }
                }
 
                u16PacketClassificationRuleIndex = ntohs(psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex);
 
                switch (eClassifierAction) {
                case eAddClassifier:
-               {
                        /* Get a Free Classifier Index From Classifier table for this SF to add the Classifier */
                        /* Contained in this message */
                        nClassifierIndex = SearchClsid(Adapter, ulSFID, u16PacketClassificationRuleIndex);
@@ -587,10 +566,8 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer
                                                "CopyToAdapter: Error The Specified Classifier Already Exists and attempted To Add Classifier with Same PCRI : 0x%x\n",
                                                u16PacketClassificationRuleIndex);
                        }
-               }
-               break;
+                       break;
                case eReplaceClassifier:
-               {
                        /* Get the Classifier Index From Classifier table for this SF and replace existing  Classifier */
                        /* with the new classifier Contained in this message */
                        nClassifierIndex = SearchClsid(Adapter, ulSFID, u16PacketClassificationRuleIndex);
@@ -601,10 +578,8 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer
                        }
                        /* Copy the Classifier Rule for this service flow into our Classifier table maintained per SF. */
                        CopyClassifierRuleToSF(Adapter, psfCSType, uiSearchRuleIndex, nClassifierIndex);
-               }
-               break;
+                       break;
                case eDeleteClassifier:
-               {
                        /* Get the Classifier Index From Classifier table for this SF and replace existing  Classifier */
                        /* with the new classifier Contained in this message */
                        nClassifierIndex = SearchClsid(Adapter, ulSFID, u16PacketClassificationRuleIndex);
@@ -616,14 +591,11 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer
 
                        /* Delete This classifier */
                        DeleteClassifierRuleFromSF(Adapter, uiSearchRuleIndex, nClassifierIndex);
-               }
-               break;
+                       break;
                default:
-               {
                        /* Invalid Action for classifier */
                        break;
                }
-               }
        }
 
        /* Repeat parsing Classification Entries to process PHS Rules */
@@ -633,35 +605,28 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer
 
                switch (psfCSType->u8PhsDSCAction) {
                case eDeleteAllPHSRules:
-               {
                        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Deleting All PHS Rules For VCID: 0x%X\n", uVCID);
 
                        /* Delete All the PHS rules for this Service flow */
                        PhsDeleteSFRules(&Adapter->stBCMPhsContext, uVCID);
                        break;
-               }
                case eDeletePHSRule:
-               {
                        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "PHS DSC Action = Delete PHS Rule\n");
 
                        if (psfCSType->cPhsRule.u8PHSI)
                                PhsDeletePHSRule(&Adapter->stBCMPhsContext, uVCID, psfCSType->cCPacketClassificationRule.u8AssociatedPHSI);
 
                        break;
-               }
                default:
-               {
                        if (ucDsxType == DSC_ACK) {
                                /* BCM_DEBUG_PRINT(CONN_MSG,("Invalid PHS DSC Action For DSC\n",psfCSType->cPhsRule.u8PHSI)); */
                                break; /* FOr DSC ACK Case PHS DSC Action must be in valid set */
                        }
-               }
                /* Proceed To Add PHS rule for DSA_ACK case even if PHS DSC action is unspecified */
                /* No Break Here . Intentionally! */
 
                case eAddPHSRule:
                case eSetPHSRule:
-               {
                        if (psfCSType->cPhsRule.u8PHSI) {
                                /* Apply This PHS Rule to all classifiers whose Associated PHSI Match */
                                unsigned int uiClassifierIndex = 0;
@@ -738,8 +703,7 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer
                                                sPhsRule.u8PHSI);
                                }
                        }
-               }
-               break;
+                       break;
                }
        }
 
index bce6869a747809ae0724f31f538764cf4551d4bc..efb6860461535d571c5162665bf55346f383535d 100644 (file)
@@ -14,13 +14,13 @@ InterfaceWRM(struct bcm_interface_adapter *psIntfAdapter,
                        INT len);
 
 
-int InterfaceFileDownload( PVOID psIntfAdapter,
-                        struct file *flp,
-                        unsigned int on_chip_loc);
+int InterfaceFileDownload(PVOID psIntfAdapter,
+                       struct file *flp,
+                       unsigned int on_chip_loc);
 
-int InterfaceFileReadbackFromChip( PVOID psIntfAdapter,
-                        struct file *flp,
-                        unsigned int on_chip_loc);
+int InterfaceFileReadbackFromChip(PVOID psIntfAdapter,
+                       struct file *flp,
+                       unsigned int on_chip_loc);
 
 
 int BcmRDM(PVOID arg,
index 4f315835ddfcfd0348d6f70c203f0fb0d3b93cb1..64ae92b13160e76a7ee2ce372d67ab80fd2c0fe9 100644 (file)
@@ -4,11 +4,18 @@ This file contains the routines related to Quality of Service.
 */
 #include "headers.h"
 
-static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter, PVOID pvEthPayload, struct bcm_eth_packet_info *pstEthCsPktInfo);
-static bool EThCSClassifyPkt(struct bcm_mini_adapter *Adapter, struct sk_buff* skb, struct bcm_eth_packet_info *pstEthCsPktInfo, struct bcm_classifier_rule *pstClassifierRule, B_UINT8 EthCSCupport);
+static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,
+                           PVOID pvEthPayload,
+                           struct bcm_eth_packet_info *pstEthCsPktInfo);
 
-static USHORT  IpVersion4(struct bcm_mini_adapter *Adapter, struct iphdr *iphd,
-                          struct bcm_classifier_rule *pstClassifierRule);
+static bool EThCSClassifyPkt(struct bcm_mini_adapter *Adapter,
+                            struct sk_buff *skb,
+                            struct bcm_eth_packet_info *pstEthCsPktInfo,
+                            struct bcm_classifier_rule *pstClassifierRule,
+                            B_UINT8 EthCSCupport);
+
+static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, struct iphdr *iphd,
+                        struct bcm_classifier_rule *pstClassifierRule);
 
 static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex);
 
@@ -33,14 +40,11 @@ static bool MatchSrcIpAddress(struct bcm_classifier_rule *pstClassifierRule, ULO
        ulSrcIP = ntohl(ulSrcIP);
        if (0 == pstClassifierRule->ucIPSourceAddressLength)
                return TRUE;
-       for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPSourceAddressLength); ucLoopIndex++)
-       {
+       for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPSourceAddressLength); ucLoopIndex++) {
                BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Ip Address Mask:0x%x PacketIp:0x%x and Classification:0x%x", (UINT)pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex], (UINT)ulSrcIP, (UINT)pstClassifierRule->stSrcIpAddress.ulIpv6Addr[ucLoopIndex]);
                if ((pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex] & ulSrcIP) ==
                                (pstClassifierRule->stSrcIpAddress.ulIpv4Addr[ucLoopIndex] & pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex]))
-               {
                        return TRUE;
-               }
        }
        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Ip Address Not Matched");
        return false;
@@ -68,13 +72,10 @@ static bool MatchDestIpAddress(struct bcm_classifier_rule *pstClassifierRule, UL
                return TRUE;
        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Ip Address 0x%x 0x%x 0x%x  ", (UINT)ulDestIP, (UINT)pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex], (UINT)pstClassifierRule->stDestIpAddress.ulIpv4Addr[ucLoopIndex]);
 
-       for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPDestinationAddressLength); ucLoopIndex++)
-       {
+       for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPDestinationAddressLength); ucLoopIndex++) {
                if ((pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex] & ulDestIP) ==
                                (pstClassifierRule->stDestIpAddress.ulIpv4Addr[ucLoopIndex] & pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex]))
-               {
                        return TRUE;
-               }
        }
        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Ip Address Not Matched");
        return false;
@@ -99,9 +100,8 @@ static bool MatchTos(struct bcm_classifier_rule *pstClassifierRule, UCHAR ucType
                return TRUE;
 
        if (((pstClassifierRule->ucTosMask & ucTypeOfService) <= pstClassifierRule->ucTosHigh) && ((pstClassifierRule->ucTosMask & ucTypeOfService) >= pstClassifierRule->ucTosLow))
-       {
                return TRUE;
-       }
+
        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Type Of Service Not Matched");
        return false;
 }
@@ -123,13 +123,10 @@ bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule, UCHAR ucProtoc
        struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
        if (0 == pstClassifierRule->ucProtocolLength)
                return TRUE;
-       for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucProtocolLength; ucLoopIndex++)
-       {
+       for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucProtocolLength; ucLoopIndex++) {
                BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol:0x%X Classification Protocol:0x%X", ucProtocol, pstClassifierRule->ucProtocol[ucLoopIndex]);
                if (pstClassifierRule->ucProtocol[ucLoopIndex] == ucProtocol)
-               {
                        return TRUE;
-               }
        }
        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol Not Matched");
        return false;
@@ -155,13 +152,10 @@ bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule, USHORT ushSrcPo
 
        if (0 == pstClassifierRule->ucSrcPortRangeLength)
                return TRUE;
-       for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucSrcPortRangeLength; ucLoopIndex++)
-       {
+       for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucSrcPortRangeLength; ucLoopIndex++) {
                if (ushSrcPort <= pstClassifierRule->usSrcPortRangeHi[ucLoopIndex] &&
                        ushSrcPort >= pstClassifierRule->usSrcPortRangeLo[ucLoopIndex])
-               {
                        return TRUE;
-               }
        }
        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Port: %x Not Matched ", ushSrcPort);
        return false;
@@ -186,15 +180,12 @@ bool MatchDestPort(struct bcm_classifier_rule *pstClassifierRule, USHORT ushDest
        if (0 == pstClassifierRule->ucDestPortRangeLength)
                return TRUE;
 
-       for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucDestPortRangeLength; ucLoopIndex++)
-       {
+       for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucDestPortRangeLength; ucLoopIndex++) {
                BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Matching Port:0x%X   0x%X  0x%X", ushDestPort, pstClassifierRule->usDestPortRangeLo[ucLoopIndex], pstClassifierRule->usDestPortRangeHi[ucLoopIndex]);
 
                if (ushDestPort <= pstClassifierRule->usDestPortRangeHi[ucLoopIndex] &&
                        ushDestPort >= pstClassifierRule->usDestPortRangeLo[ucLoopIndex])
-               {
                        return TRUE;
-               }
        }
        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Dest Port: %x Not Matched", ushDestPort);
        return false;
@@ -273,21 +264,13 @@ static USHORT     IpVersion4(struct bcm_mini_adapter *Adapter,
                bClassificationSucceed = TRUE;
        } while (0);
 
-       if (TRUE == bClassificationSucceed)
-       {
+       if (TRUE == bClassificationSucceed) {
                INT iMatchedSFQueueIndex = 0;
                iMatchedSFQueueIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID);
                if (iMatchedSFQueueIndex >= NO_OF_QUEUES)
-               {
                        bClassificationSucceed = false;
-               }
-               else
-               {
-                       if (false == Adapter->PackInfo[iMatchedSFQueueIndex].bActive)
-                       {
-                               bClassificationSucceed = false;
-                       }
-               }
+               else if (false == Adapter->PackInfo[iMatchedSFQueueIndex].bActive)
+                       bClassificationSucceed = false;
        }
 
        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "IpVersion4 <==========");
@@ -299,8 +282,7 @@ VOID PruneQueueAllSF(struct bcm_mini_adapter *Adapter)
 {
        UINT iIndex = 0;
 
-       for (iIndex = 0; iIndex < HiPriority; iIndex++)
-       {
+       for (iIndex = 0; iIndex < HiPriority; iIndex++) {
                if (!Adapter->PackInfo[iIndex].bValid)
                        continue;
 
@@ -334,10 +316,10 @@ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex)
 
        spin_lock_bh(&Adapter->PackInfo[iIndex].SFQueueLock);
 
-       while (1)
+       while (1) {
 //     while((UINT)Adapter->PackInfo[iIndex].uiCurrentPacketsOnHost >
-//             SF_MAX_ALLOWED_PACKETS_TO_BACKUP)
-       {
+//             SF_MAX_ALLOWED_PACKETS_TO_BACKUP) {
+
                BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "uiCurrentBytesOnHost:%x uiMaxBucketSize :%x",
                Adapter->PackInfo[iIndex].uiCurrentBytesOnHost,
                Adapter->PackInfo[iIndex].uiMaxBucketSize);
@@ -350,8 +332,7 @@ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex)
                        ((1000*(jiffies - *((B_UINT32 *)(PacketToDrop->cb)+SKB_CB_LATENCY_OFFSET))/HZ) <= Adapter->PackInfo[iIndex].uiMaxLatency))
                        break;
 
-               if (PacketToDrop)
-               {
+               if (PacketToDrop) {
                        if (netif_msg_tx_err(Adapter))
                                pr_info(PFX "%s: tx queue %d overlimit\n",
                                        Adapter->dev->name, iIndex);
@@ -394,20 +375,16 @@ VOID flush_all_queues(struct bcm_mini_adapter *Adapter)
        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "=====>");
 
 //     down(&Adapter->data_packet_queue_lock);
-       for (iQIndex = LowPriority; iQIndex < HiPriority; iQIndex++)
-       {
+       for (iQIndex = LowPriority; iQIndex < HiPriority; iQIndex++) {
                struct net_device_stats *netstats = &Adapter->dev->stats;
 
                spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock);
-               while (Adapter->PackInfo[iQIndex].FirstTxQueue)
-               {
+               while (Adapter->PackInfo[iQIndex].FirstTxQueue) {
                        PacketToDrop = Adapter->PackInfo[iQIndex].FirstTxQueue;
-                       if (PacketToDrop)
-                       {
+                       if (PacketToDrop) {
                                uiTotalPacketLength = PacketToDrop->len;
                                netstats->tx_dropped++;
-                       }
-                       else
+                       } else
                                uiTotalPacketLength = 0;
 
                        DEQUEUEPACKET(Adapter->PackInfo[iQIndex].FirstTxQueue,
@@ -455,58 +432,42 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb)
        *((UINT32*) (skb->cb) +SKB_CB_TCPACK_OFFSET) = 0;
        EThCSGetPktInfo(Adapter, pvEThPayload, &stEthCsPktInfo);
 
-       switch (stEthCsPktInfo.eNwpktEthFrameType)
-       {
+       switch (stEthCsPktInfo.eNwpktEthFrameType) {
                case eEth802LLCFrame:
-               {
                        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLCFrame\n");
                        pIpHeader = pvEThPayload + sizeof(struct bcm_eth_llc_frame);
                        break;
-               }
-
                case eEth802LLCSNAPFrame:
-               {
                        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLC SNAP Frame\n");
                        pIpHeader = pvEThPayload + sizeof(struct bcm_eth_llc_snap_frame);
                        break;
-               }
                case eEth802QVLANFrame:
-               {
                        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802.1Q VLANFrame\n");
                        pIpHeader = pvEThPayload + sizeof(struct bcm_eth_q_frame);
                        break;
-               }
                case eEthOtherFrame:
-               {
                        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : ETH Other Frame\n");
                        pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame);
                        break;
-               }
                default:
-               {
                        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : Unrecognized ETH Frame\n");
                        pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame);
                        break;
-               }
        }
 
-       if (stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet)
-       {
+       if (stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) {
                usCurrFragment = (ntohs(pIpHeader->frag_off) & IP_OFFSET);
                if ((ntohs(pIpHeader->frag_off) & IP_MF) || usCurrFragment)
                        bFragmentedPkt = TRUE;
 
-               if (bFragmentedPkt)
-               {
+               if (bFragmentedPkt) {
                                //Fragmented  Packet. Get Frag Classifier Entry.
                        pstClassifierRule = GetFragIPClsEntry(Adapter, pIpHeader->id, pIpHeader->saddr);
-                       if (pstClassifierRule)
-                       {
+                       if (pstClassifierRule) {
                                        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "It is next Fragmented pkt");
                                        bClassificationSucceed = TRUE;
                        }
-                       if (!(ntohs(pIpHeader->frag_off) & IP_MF))
-                       {
+                       if (!(ntohs(pIpHeader->frag_off) & IP_MF)) {
                                //Fragmented Last packet . Remove Frag Classifier Entry
                                BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "This is the last fragmented Pkt");
                                DelFragIPClsEntry(Adapter, pIpHeader->id, pIpHeader->saddr);
@@ -514,23 +475,19 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb)
                }
        }
 
-       for (uiLoopIndex = MAX_CLASSIFIERS - 1; uiLoopIndex >= 0; uiLoopIndex--)
-       {
+       for (uiLoopIndex = MAX_CLASSIFIERS - 1; uiLoopIndex >= 0; uiLoopIndex--) {
                if (bClassificationSucceed)
                        break;
                //Iterate through all classifiers which are already in order of priority
                //to classify the packet until match found
-               do
-               {
-                       if (false == Adapter->astClassifierTable[uiLoopIndex].bUsed)
-                       {
+               do {
+                       if (false == Adapter->astClassifierTable[uiLoopIndex].bUsed) {
                                bClassificationSucceed = false;
                                break;
                        }
                        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "Adapter->PackInfo[%d].bvalid=True\n", uiLoopIndex);
 
-                       if (0 == Adapter->astClassifierTable[uiLoopIndex].ucDirection)
-                       {
+                       if (0 == Adapter->astClassifierTable[uiLoopIndex].ucDirection) {
                                bClassificationSucceed = false;//cannot be processed for classification.
                                break;                                          // it is a down link connection
                        }
@@ -543,11 +500,9 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb)
                                break;
                        }
 
-                       if (Adapter->PackInfo[uiSfIndex].bEthCSSupport)
-                       {
+                       if (Adapter->PackInfo[uiSfIndex].bEthCSSupport) {
 
-                               if (eEthUnsupportedFrame == stEthCsPktInfo.eNwpktEthFrameType)
-                               {
+                               if (eEthUnsupportedFrame == stEthCsPktInfo.eNwpktEthFrameType) {
                                        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet Not a Valid Supported Ethernet Frame\n");
                                        bClassificationSucceed = false;
                                        break;
@@ -558,17 +513,12 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb)
                                BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "Performing ETH CS Classification on Classifier Rule ID : %x Service Flow ID : %lx\n", pstClassifierRule->uiClassifierRuleIndex, Adapter->PackInfo[uiSfIndex].ulSFID);
                                bClassificationSucceed = EThCSClassifyPkt(Adapter, skb, &stEthCsPktInfo, pstClassifierRule, Adapter->PackInfo[uiSfIndex].bEthCSSupport);
 
-                               if (!bClassificationSucceed)
-                               {
+                               if (!bClassificationSucceed) {
                                        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "ClassifyPacket : Ethernet CS Classification Failed\n");
                                        break;
                                }
-                       }
-
-                       else // No ETH Supported on this SF
-                       {
-                               if (eEthOtherFrame != stEthCsPktInfo.eNwpktEthFrameType)
-                               {
+                       } else {        // No ETH Supported on this SF
+                               if (eEthOtherFrame != stEthCsPktInfo.eNwpktEthFrameType) {
                                        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet Not a 802.3 Ethernet Frame... hence not allowed over non-ETH CS SF\n");
                                        bClassificationSucceed = false;
                                        break;
@@ -577,11 +527,9 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb)
 
                        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "Proceeding to IP CS Clasification");
 
-                       if (Adapter->PackInfo[uiSfIndex].bIPCSSupport)
-                       {
+                       if (Adapter->PackInfo[uiSfIndex].bIPCSSupport) {
 
-                               if (stEthCsPktInfo.eNwpktIPFrameType == eNonIPPacket)
-                               {
+                               if (stEthCsPktInfo.eNwpktIPFrameType == eNonIPPacket) {
                                        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet is Not an IP Packet\n");
                                        bClassificationSucceed = false;
                                        break;
@@ -598,31 +546,26 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb)
                } while (0);
        }
 
-       if (bClassificationSucceed == TRUE)
-       {
+       if (bClassificationSucceed == TRUE) {
                BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "CF id : %d, SF ID is =%lu", pstClassifierRule->uiClassifierRuleIndex, pstClassifierRule->ulSFID);
 
                //Store The matched Classifier in SKB
                *((UINT32*)(skb->cb)+SKB_CB_CLASSIFICATION_OFFSET) = pstClassifierRule->uiClassifierRuleIndex;
-               if ((TCP == pIpHeader->protocol) && !bFragmentedPkt && (ETH_AND_IP_HEADER_LEN + TCP_HEADER_LEN <= skb->len))
-               {
+               if ((TCP == pIpHeader->protocol) && !bFragmentedPkt && (ETH_AND_IP_HEADER_LEN + TCP_HEADER_LEN <= skb->len)) {
                         IpHeaderLength   = pIpHeader->ihl;
                         pTcpHeader = (struct bcm_tcp_header *)(((PUCHAR)pIpHeader)+(IpHeaderLength*4));
                         TcpHeaderLength  = GET_TCP_HEADER_LEN(pTcpHeader->HeaderLength);
 
                        if ((pTcpHeader->ucFlags & TCP_ACK) &&
                           (ntohs(pIpHeader->tot_len) == (IpHeaderLength*4)+(TcpHeaderLength*4)))
-                       {
                                *((UINT32*) (skb->cb) + SKB_CB_TCPACK_OFFSET) = TCP_ACK;
-                       }
                }
 
                usIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID);
                BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "index is  =%d", usIndex);
 
                //If this is the first fragment of a Fragmented pkt, add this CF. Only This CF should be used for all other fragment of this Pkt.
-               if (bFragmentedPkt && (usCurrFragment == 0))
-               {
+               if (bFragmentedPkt && (usCurrFragment == 0)) {
                        //First Fragment of Fragmented Packet. Create Frag CLS Entry
                        struct bcm_fragmented_packet_info stFragPktInfo;
                        stFragPktInfo.bUsed = TRUE;
@@ -649,8 +592,7 @@ static bool EthCSMatchSrcMACAddress(struct bcm_classifier_rule *pstClassifierRul
        if (pstClassifierRule->ucEthCSSrcMACLen == 0)
                return TRUE;
        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "%s\n", __FUNCTION__);
-       for (i = 0; i < MAC_ADDRESS_SIZE; i++)
-       {
+       for (i = 0; i < MAC_ADDRESS_SIZE; i++) {
                BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "SRC MAC[%x] = %x ClassifierRuleSrcMAC = %x Mask : %x\n", i, Mac[i], pstClassifierRule->au8EThCSSrcMAC[i], pstClassifierRule->au8EThCSSrcMACMask[i]);
                if ((pstClassifierRule->au8EThCSSrcMAC[i] & pstClassifierRule->au8EThCSSrcMACMask[i]) !=
                        (Mac[i] & pstClassifierRule->au8EThCSSrcMACMask[i]))
@@ -666,8 +608,7 @@ static bool EthCSMatchDestMACAddress(struct bcm_classifier_rule *pstClassifierRu
        if (pstClassifierRule->ucEthCSDestMACLen == 0)
                return TRUE;
        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s\n", __FUNCTION__);
-       for (i = 0; i < MAC_ADDRESS_SIZE; i++)
-       {
+       for (i = 0; i < MAC_ADDRESS_SIZE; i++) {
                BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "SRC MAC[%x] = %x ClassifierRuleSrcMAC = %x Mask : %x\n", i, Mac[i], pstClassifierRule->au8EThCSDestMAC[i], pstClassifierRule->au8EThCSDestMACMask[i]);
                if ((pstClassifierRule->au8EThCSDestMAC[i] & pstClassifierRule->au8EThCSDestMACMask[i]) !=
                        (Mac[i] & pstClassifierRule->au8EThCSDestMACMask[i]))
@@ -684,8 +625,7 @@ static bool EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule,
                return TRUE;
 
        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "%s SrcEtherType:%x CLS EtherType[0]:%x\n", __FUNCTION__, pstEthCsPktInfo->usEtherType, pstClassifierRule->au8EthCSEtherType[0]);
-       if (pstClassifierRule->au8EthCSEtherType[0] == 1)
-       {
+       if (pstClassifierRule->au8EthCSEtherType[0] == 1) {
                BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "%s  CLS EtherType[1]:%x EtherType[2]:%x\n", __FUNCTION__, pstClassifierRule->au8EthCSEtherType[1], pstClassifierRule->au8EthCSEtherType[2]);
 
                if (memcmp(&pstEthCsPktInfo->usEtherType, &pstClassifierRule->au8EthCSEtherType[1], 2) == 0)
@@ -694,8 +634,7 @@ static bool EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule,
                        return false;
        }
 
-       if (pstClassifierRule->au8EthCSEtherType[0] == 2)
-       {
+       if (pstClassifierRule->au8EthCSEtherType[0] == 2) {
                if (eEth802LLCFrame != pstEthCsPktInfo->eNwpktEthFrameType)
                        return false;
 
@@ -721,8 +660,7 @@ static bool EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule, s
        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "%s  CLS UserPrio:%x CLS VLANID:%x\n", __FUNCTION__, ntohs(*((USHORT *)pstClassifierRule->usUserPriority)), pstClassifierRule->usVLANID);
 
        /* In case FW didn't receive the TLV, the priority field should be ignored */
-       if (pstClassifierRule->usValidityBitMap & (1<<PKT_CLASSIFICATION_USER_PRIORITY_VALID))
-       {
+       if (pstClassifierRule->usValidityBitMap & (1<<PKT_CLASSIFICATION_USER_PRIORITY_VALID)) {
                if (pstEthCsPktInfo->eNwpktEthFrameType != eEth802QVLANFrame)
                                return false;
 
@@ -739,8 +677,7 @@ static bool EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule, s
 
        bClassificationSucceed = false;
 
-       if (pstClassifierRule->usValidityBitMap & (1<<PKT_CLASSIFICATION_VLANID_VALID))
-       {
+       if (pstClassifierRule->usValidityBitMap & (1<<PKT_CLASSIFICATION_VLANID_VALID)) {
                if (pstEthCsPktInfo->eNwpktEthFrameType != eEth802QVLANFrame)
                                return false;
 
@@ -800,32 +737,24 @@ static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter, PVOID pvEthPayload
        USHORT u16Etype = ntohs(((struct bcm_eth_header *)pvEthPayload)->u16Etype);
 
        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,  "EthCSGetPktInfo : Eth Hdr Type : %X\n", u16Etype);
-       if (u16Etype > 0x5dc)
-       {
+       if (u16Etype > 0x5dc) {
                BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : ETH2 Frame\n");
                //ETH2 Frame
-               if (u16Etype == ETHERNET_FRAMETYPE_802QVLAN)
-               {
+               if (u16Etype == ETHERNET_FRAMETYPE_802QVLAN) {
                        //802.1Q VLAN Header
                        pstEthCsPktInfo->eNwpktEthFrameType = eEth802QVLANFrame;
                        u16Etype = ((struct bcm_eth_q_frame *)pvEthPayload)->EthType;
                        //((ETH_CS_802_Q_FRAME*)pvEthPayload)->UserPriority
-               }
-               else
-               {
+               } else {
                        pstEthCsPktInfo->eNwpktEthFrameType = eEthOtherFrame;
                        u16Etype = ntohs(u16Etype);
                }
-
-       }
-       else
-       {
+       } else {
                //802.2 LLC
                BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "802.2 LLC Frame\n");
                pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCFrame;
                pstEthCsPktInfo->ucDSAP = ((struct bcm_eth_llc_frame *)pvEthPayload)->DSAP;
-               if (pstEthCsPktInfo->ucDSAP == 0xAA && ((struct bcm_eth_llc_frame *)pvEthPayload)->SSAP == 0xAA)
-               {
+               if (pstEthCsPktInfo->ucDSAP == 0xAA && ((struct bcm_eth_llc_frame *)pvEthPayload)->SSAP == 0xAA) {
                        //SNAP Frame
                        pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCSNAPFrame;
                        u16Etype = ((struct bcm_eth_llc_snap_frame *)pvEthPayload)->usEtherType;
index 39ace5510c4360c42cf8a1b59828ed27e9735460..42d9004e357d53a0ce5d33000cfb9df578f18d10 100644 (file)
@@ -9,37 +9,40 @@
 
 #include "headers.h"
 
-INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_mibs *pstHostMibs)
+INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter,
+                      struct bcm_host_stats_mibs *pstHostMibs)
 {
        struct bcm_phs_entry *pstServiceFlowEntry = NULL;
        struct bcm_phs_rule *pstPhsRule = NULL;
        struct bcm_phs_classifier_table *pstClassifierTable = NULL;
        struct bcm_phs_classifier_entry *pstClassifierRule = NULL;
-       struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *) &Adapter->stBCMPhsContext;
-
-       UINT nClassifierIndex = 0, nPhsTableIndex = 0, nSfIndex = 0, uiIndex = 0;
+       struct bcm_phs_extension *pDeviceExtension = &Adapter->stBCMPhsContext;
+       UINT nClassifierIndex = 0;
+       UINT nPhsTableIndex = 0;
+       UINT nSfIndex = 0;
+       UINT uiIndex = 0;
 
        if (pDeviceExtension == NULL) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, HOST_MIBS, DBG_LVL_ALL, "Invalid Device Extension\n");
+               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, HOST_MIBS,
+                               DBG_LVL_ALL, "Invalid Device Extension\n");
                return STATUS_FAILURE;
        }
 
        /* Copy the classifier Table */
-       for (nClassifierIndex = 0; nClassifierIndex < MAX_CLASSIFIERS; nClassifierIndex++) {
+       for (nClassifierIndex = 0; nClassifierIndex < MAX_CLASSIFIERS;
+                                                       nClassifierIndex++) {
                if (Adapter->astClassifierTable[nClassifierIndex].bUsed == TRUE)
-                       memcpy((PVOID) &pstHostMibs->
-                              astClassifierTable[nClassifierIndex],
-                              (PVOID) &Adapter->
-                              astClassifierTable[nClassifierIndex],
+                       memcpy(&pstHostMibs->astClassifierTable[nClassifierIndex],
+                              &Adapter->astClassifierTable[nClassifierIndex],
                               sizeof(struct bcm_mibs_classifier_rule));
        }
 
        /* Copy the SF Table */
        for (nSfIndex = 0; nSfIndex < NO_OF_QUEUES; nSfIndex++) {
                if (Adapter->PackInfo[nSfIndex].bValid) {
-                       memcpy((PVOID) &pstHostMibs->astSFtable[nSfIndex],
-                              (PVOID) &Adapter->PackInfo[nSfIndex],
-                               sizeof(struct bcm_mibs_table));
+                       memcpy(&pstHostMibs->astSFtable[nSfIndex],
+                              &Adapter->PackInfo[nSfIndex],
+                              sizeof(struct bcm_mibs_table));
                } else {
                        /* If index in not valid,
                         * don't process this for the PHS table.
@@ -68,9 +71,9 @@ INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_m
                                pstHostMibs->astPhsRulesTable[nPhsTableIndex].
                                    ulSFID = Adapter->PackInfo[nSfIndex].ulSFID;
 
-                               memcpy(&pstHostMibs->
-                                      astPhsRulesTable[nPhsTableIndex].u8PHSI,
-                                      &pstPhsRule->u8PHSI, sizeof(struct bcm_phs_rule));
+                               memcpy(&pstHostMibs->astPhsRulesTable[nPhsTableIndex].u8PHSI,
+                                      &pstPhsRule->u8PHSI,
+                                      sizeof(struct bcm_phs_rule));
                                nPhsTableIndex++;
 
                        }
@@ -82,26 +85,32 @@ INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_m
        /* Copy other Host Statistics parameters */
        pstHostMibs->stHostInfo.GoodTransmits = Adapter->dev->stats.tx_packets;
        pstHostMibs->stHostInfo.GoodReceives = Adapter->dev->stats.rx_packets;
-       pstHostMibs->stHostInfo.CurrNumFreeDesc = atomic_read(&Adapter->CurrNumFreeTxDesc);
+       pstHostMibs->stHostInfo.CurrNumFreeDesc =
+                               atomic_read(&Adapter->CurrNumFreeTxDesc);
        pstHostMibs->stHostInfo.BEBucketSize = Adapter->BEBucketSize;
        pstHostMibs->stHostInfo.rtPSBucketSize = Adapter->rtPSBucketSize;
        pstHostMibs->stHostInfo.TimerActive = Adapter->TimerActive;
        pstHostMibs->stHostInfo.u32TotalDSD = Adapter->u32TotalDSD;
 
-       memcpy(pstHostMibs->stHostInfo.aTxPktSizeHist, Adapter->aTxPktSizeHist, sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES);
-       memcpy(pstHostMibs->stHostInfo.aRxPktSizeHist, Adapter->aRxPktSizeHist, sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES);
+       memcpy(pstHostMibs->stHostInfo.aTxPktSizeHist, Adapter->aTxPktSizeHist,
+              sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES);
+       memcpy(pstHostMibs->stHostInfo.aRxPktSizeHist, Adapter->aRxPktSizeHist,
+              sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES);
 
        return STATUS_SUCCESS;
 }
 
-VOID GetDroppedAppCntrlPktMibs(struct bcm_host_stats_mibs *pstHostMibs, struct bcm_tarang_data *pTarang)
+VOID GetDroppedAppCntrlPktMibs(struct bcm_host_stats_mibs *pstHostMibs,
+                              struct bcm_tarang_data *pTarang)
 {
        memcpy(&(pstHostMibs->stDroppedAppCntrlMsgs),
               &(pTarang->stDroppedAppCntrlMsgs),
               sizeof(struct bcm_mibs_dropped_cntrl_msg));
 }
 
-VOID CopyMIBSExtendedSFParameters(struct bcm_mini_adapter *Adapter, struct bcm_connect_mgr_params *psfLocalSet, UINT uiSearchRuleIndex)
+VOID CopyMIBSExtendedSFParameters(struct bcm_mini_adapter *Adapter,
+                                 struct bcm_connect_mgr_params *psfLocalSet,
+                                 UINT uiSearchRuleIndex)
 {
        struct bcm_mibs_parameters *t = &Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable;
 
index acc80197e35ed86f0c89eee412f6bba9d0d640b5..70545e670dd0b8ccb3b8aeb54c7f85bc4711db76 100644 (file)
@@ -1435,13 +1435,15 @@ static int __comedi_get_user_cmd(struct comedi_device *dev,
        s = &dev->subdevices[cmd->subdev];
 
        if (s->type == COMEDI_SUBD_UNUSED) {
-               dev_dbg(dev->class_dev, "%d not valid subdevice\n", cmd->subdev);
+               dev_dbg(dev->class_dev, "%d not valid subdevice\n",
+                       cmd->subdev);
                return -EIO;
        }
 
        if (!s->do_cmd || !s->do_cmdtest || !s->async) {
                dev_dbg(dev->class_dev,
-                       "subdevice %d does not support commands\n", cmd->subdev);
+                       "subdevice %d does not support commands\n",
+                       cmd->subdev);
                return -EIO;
        }
 
@@ -1597,7 +1599,6 @@ static int do_cmdtest_ioctl(struct comedi_device *dev,
 {
        struct comedi_cmd cmd;
        struct comedi_subdevice *s;
-       unsigned int *chanlist = NULL;
        unsigned int __user *user_chanlist;
        int ret;
 
@@ -1626,8 +1627,6 @@ static int do_cmdtest_ioctl(struct comedi_device *dev,
                ret = -EFAULT;
        }
 
-       kfree(chanlist);
-
        return ret;
 }
 
index ab0e8ed472910e93fd2268d7b5694ef9b388e291..cb5d21411a0c804ee585778bb68afb77a91ae646 100644 (file)
@@ -258,6 +258,7 @@ static int insn_rw_emulate_bits(struct comedi_device *dev,
        const unsigned base_bitfield_channel =
            (chan < channels_per_bitfield) ? 0 : chan;
        unsigned int new_data[2];
+
        memset(new_data, 0, sizeof(new_data));
        memset(&new_insn, 0, sizeof(new_insn));
        new_insn.insn = INSN_BITS;
index 48817f087d9758a1e0e40aedce29b25b5ce6bab4..1d53e241e84d94bfd873d44c3de10a06ed83ec31 100644 (file)
@@ -231,7 +231,7 @@ static int subdev_8255_cmdtest(struct comedi_device *dev,
        err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
        err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
        err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, 1);
+       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
        err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
@@ -298,6 +298,7 @@ int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice *s,
        if (ret)
                return ret;
 
+       s->len_chanlist = 1;
        s->do_cmdtest   = subdev_8255_cmdtest;
        s->do_cmd       = subdev_8255_cmd;
        s->cancel       = subdev_8255_cancel;
index 9c86b02eb6da4b96f53a6a4693a3c36ba77eb5b9..7976a22ae94dea9586f86234e507e1744a09fdfb 100644 (file)
@@ -21,6 +21,8 @@
  *
  */
 
+#include "../addi_watchdog.h"
+
 #define APCI1564_ADDRESS_RANGE                         128
 
 /* Digital Input IRQ Function Selection */
@@ -76,7 +78,7 @@
 #define APCI1564_TIMER_WARN_TIMEBASE_REG               0x64
 
 /*
- * devpriv->iobase Register Map
+ * dev>iobase Register Map
  */
 #define APCI1564_TCW_REG(x)                            (0x00 + ((x) * 0x20))
 #define APCI1564_TCW_RELOAD_REG(x)                     (0x04 + ((x) * 0x20))
@@ -239,13 +241,13 @@ static int apci1564_timer_config(struct comedi_device *dev,
                        outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DO_IRQ_REG);
                        outl(0x0, devpriv->i_IobaseAmcc + APCI1564_WDOG_IRQ_REG);
                        outl(0x0,
-                               devpriv->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER1));
+                            dev->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER1));
                        outl(0x0,
-                               devpriv->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER2));
+                            dev->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER2));
                        outl(0x0,
-                               devpriv->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER3));
+                            dev->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER3));
                        outl(0x0,
-                               devpriv->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER4));
+                            dev->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER4));
                } else {
                        /* disable Timer interrupt */
                        outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER_CTRL_REG);
@@ -266,13 +268,13 @@ static int apci1564_timer_config(struct comedi_device *dev,
                devpriv->b_ModeSelectRegister = data[5];
 
                /* First Stop The Counter */
-               ul_Command1 = inl(devpriv->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1));
+               ul_Command1 = inl(dev->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1));
                ul_Command1 = ul_Command1 & 0xFFFFF9FEUL;
                /* Stop The Timer */
-               outl(ul_Command1, devpriv->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1));
+               outl(ul_Command1, dev->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1));
 
                /* Set the reload value */
-               outl(data[3], devpriv->iobase + APCI1564_TCW_RELOAD_REG(data[5] - 1));
+               outl(data[3], dev->iobase + APCI1564_TCW_RELOAD_REG(data[5] - 1));
 
                /* Set the mode :             */
                /* - Disable the hardware     */
@@ -285,15 +287,15 @@ static int apci1564_timer_config(struct comedi_device *dev,
                ul_Command1 =
                        (ul_Command1 & 0xFFFC19E2UL) | 0x80000UL |
                        (unsigned int) ((unsigned int) data[4] << 16UL);
-               outl(ul_Command1, devpriv->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1));
+               outl(ul_Command1, dev->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1));
 
                /*  Enable or Disable Interrupt */
                ul_Command1 = (ul_Command1 & 0xFFFFF9FD) | (data[1] << 1);
-               outl(ul_Command1, devpriv->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1));
+               outl(ul_Command1, dev->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1));
 
                /* Set the Up/Down selection */
                ul_Command1 = (ul_Command1 & 0xFFFBF9FFUL) | (data[6] << 18);
-               outl(ul_Command1, devpriv->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1));
+               outl(ul_Command1, dev->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1));
        } else {
                dev_err(dev->class_dev, "Invalid subdevice.\n");
        }
@@ -349,8 +351,8 @@ static int apci1564_timer_write(struct comedi_device *dev,
        }
        if (devpriv->b_TimerSelectMode == ADDIDATA_COUNTER) {
                ul_Command1 =
-                       inl(devpriv->iobase +
-                               APCI1564_TCW_CTRL_REG(devpriv->b_ModeSelectRegister - 1));
+                       inl(dev->iobase +
+                           APCI1564_TCW_CTRL_REG(devpriv->b_ModeSelectRegister - 1));
                if (data[1] == 1) {
                        /* Start the Counter subdevice */
                        ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL;
@@ -362,9 +364,8 @@ static int apci1564_timer_write(struct comedi_device *dev,
                        /*  Clears the Counter subdevice */
                        ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x400;
                }
-               outl(ul_Command1,
-                       devpriv->iobase +
-                       APCI1564_TCW_CTRL_REG(devpriv->b_ModeSelectRegister - 1));
+               outl(ul_Command1, dev->iobase +
+                    APCI1564_TCW_CTRL_REG(devpriv->b_ModeSelectRegister - 1));
        }
        return insn->n;
 }
@@ -393,11 +394,11 @@ static int apci1564_timer_read(struct comedi_device *dev,
        } else if (devpriv->b_TimerSelectMode == ADDIDATA_COUNTER) {
                /*  Read the Counter Actual Value. */
                data[0] =
-                       inl(devpriv->iobase +
-                               APCI1564_TCW_REG(devpriv->b_ModeSelectRegister - 1));
+                       inl(dev->iobase +
+                           APCI1564_TCW_REG(devpriv->b_ModeSelectRegister - 1));
                ul_Command1 =
-                       inl(devpriv->iobase +
-                               APCI1564_TCW_STATUS_REG(devpriv->b_ModeSelectRegister - 1));
+                       inl(dev->iobase +
+                           APCI1564_TCW_STATUS_REG(devpriv->b_ModeSelectRegister - 1));
 
                /* Get the software trigger status */
                data[1] = (unsigned char) ((ul_Command1 >> 1) & 1);
@@ -446,13 +447,13 @@ static void apci1564_interrupt(int irq, void *d)
        ui_DO = inl(devpriv->i_IobaseAmcc + APCI1564_DO_IRQ_REG) & 0x01;
        ui_Timer = inl(devpriv->i_IobaseAmcc + APCI1564_TIMER_IRQ_REG) & 0x01;
        ui_C1 =
-               inl(devpriv->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER1)) & 0x1;
+               inl(dev->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER1)) & 0x1;
        ui_C2 =
-               inl(devpriv->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER2)) & 0x1;
+               inl(dev->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER2)) & 0x1;
        ui_C3 =
-               inl(devpriv->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER3)) & 0x1;
+               inl(dev->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER3)) & 0x1;
        ui_C4 =
-               inl(devpriv->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER4)) & 0x1;
+               inl(dev->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER4)) & 0x1;
        if (ui_DI == 0 && ui_DO == 0 && ui_Timer == 0 && ui_C1 == 0
                && ui_C2 == 0 && ui_C3 == 0 && ui_C4 == 0) {
                dev_err(dev->class_dev, "Interrupt from unknown source.\n");
@@ -506,16 +507,16 @@ static void apci1564_interrupt(int irq, void *d)
 
                        /*  Disable Counter Interrupt */
                        ul_Command2 =
-                               inl(devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1));
+                               inl(dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1));
                        outl(0x0,
-                            devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1));
+                            dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1));
 
                        /* Send a signal to from kernel to user space */
                        send_sig(SIGIO, devpriv->tsk_Current, 0);
 
                        /*  Enable Counter Interrupt */
                        outl(ul_Command2,
-                            devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1));
+                            dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1));
                }
        }
 
@@ -525,16 +526,16 @@ static void apci1564_interrupt(int irq, void *d)
 
                        /*  Disable Counter Interrupt */
                        ul_Command2 =
-                               inl(devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2));
+                               inl(dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2));
                        outl(0x0,
-                            devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2));
+                            dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2));
 
                        /* Send a signal to from kernel to user space */
                        send_sig(SIGIO, devpriv->tsk_Current, 0);
 
                        /*  Enable Counter Interrupt */
                        outl(ul_Command2,
-                            devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2));
+                            dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2));
                }
        }
 
@@ -544,16 +545,16 @@ static void apci1564_interrupt(int irq, void *d)
 
                        /*  Disable Counter Interrupt */
                        ul_Command2 =
-                               inl(devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3));
+                               inl(dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3));
                        outl(0x0,
-                            devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3));
+                            dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3));
 
                        /* Send a signal to from kernel to user space */
                        send_sig(SIGIO, devpriv->tsk_Current, 0);
 
                        /*  Enable Counter Interrupt */
                        outl(ul_Command2,
-                            devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3));
+                            dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3));
                }
        }
 
@@ -563,16 +564,16 @@ static void apci1564_interrupt(int irq, void *d)
 
                        /*  Disable Counter Interrupt */
                        ul_Command2 =
-                               inl(devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4));
+                               inl(dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4));
                        outl(0x0,
-                            devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4));
+                            dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4));
 
                        /* Send a signal to from kernel to user space */
                        send_sig(SIGIO, devpriv->tsk_Current, 0);
 
                        /*  Enable Counter Interrupt */
                        outl(ul_Command2,
-                            devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4));
+                            dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4));
                }
        }
        return;
@@ -582,26 +583,30 @@ static int apci1564_reset(struct comedi_device *dev)
 {
        struct addi_private *devpriv = dev->private;
 
-       /* disable the interrupts */
+       ui_Type = 0;
+
+       /* Disable the input interrupts and reset status register */
        outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG);
-       /* Reset the interrupt status register */
        inl(devpriv->i_IobaseAmcc + APCI1564_DI_INT_STATUS_REG);
-       /* Disable the and/or interrupt */
        outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_INT_MODE1_REG);
        outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_INT_MODE2_REG);
-       devpriv->b_DigitalOutputRegister = 0;
-       ui_Type = 0;
-       /* Resets the output channels */
+
+       /* Reset the output channels and disable interrupts */
        outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DO_REG);
-       /* Disables the interrupt. */
        outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DO_INT_CTRL_REG);
-       outl(0x0, devpriv->i_IobaseAmcc + APCI1564_WDOG_RELOAD_REG);
-       outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER_REG);
+
+       /* Reset the watchdog registers */
+       addi_watchdog_reset(devpriv->i_IobaseAmcc + APCI1564_WDOG_REG);
+
+       /* Reset the timer registers */
        outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER_CTRL_REG);
+       outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER_RELOAD_REG);
+
+       /* Reset the counter registers */
+       outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1));
+       outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2));
+       outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3));
+       outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4));
 
-       outl(0x0, devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1));
-       outl(0x0, devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2));
-       outl(0x0, devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3));
-       outl(0x0, devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4));
        return 0;
 }
index 70e8f426285cd9ea63e992bbed4195c07c6c35ad..7ead23e34e8ebba36e480c527945c0293e8fbfe8 100644 (file)
@@ -734,7 +734,6 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev,
                               struct comedi_subdevice *s,
                               struct comedi_cmd *cmd)
 {
-       const struct addi_board *this_board = comedi_board(dev);
        int err = 0;
 
        /* Step 1 : check if triggers are trivially valid */
@@ -779,8 +778,7 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev,
        }
 
        err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1);
-       err |= cfc_check_trigger_arg_max(&cmd->chanlist_len,
-                                        this_board->i_AiChannelList);
+       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
                err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
index 0536d83738616547fea494e25d959ea59502913c..9b8851c7e07214afe62f7ddb3cf6a4ee895f3a57 100644 (file)
@@ -2221,12 +2221,11 @@ static int apci3200_ai_cmdtest(struct comedi_device *dev,
        unsigned int ui_ConvertTimeBase = 0;
        unsigned int ui_DelayTime = 0;
        unsigned int ui_DelayTimeBase = 0;
-       int i_Triggermode = 0;
-       int i_TriggerEdge = 0;
        int i_NbrOfChannel = 0;
        int i_Cpt = 0;
        double d_ConversionTimeForAllChannels = 0.0;
        double d_SCANTimeNewUnit = 0.0;
+       unsigned int arg;
 
        /* Step 1 : check if triggers are trivially valid */
 
@@ -2253,23 +2252,37 @@ static int apci3200_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 2b : and mutually compatible */
 
-       if (cmd->start_src == TRIG_EXT) {
-               i_TriggerEdge = cmd->start_arg & 0xFFFF;
-               i_Triggermode = cmd->start_arg >> 16;
-               if (i_TriggerEdge < 1 || i_TriggerEdge > 3) {
-                       err++;
-                       printk("\nThe trigger edge selection is in error\n");
-               }
-               if (i_Triggermode != 2) {
-                       err++;
-                       printk("\nThe trigger mode selection is in error\n");
-               }
-       }
-
        if (err) {
                apci3200_reset(dev);
                return 2;
        }
+
+       /* Step 3: check if arguments are trivially valid */
+
+       switch (cmd->start_src) {
+       case TRIG_NOW:
+               err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               break;
+       case TRIG_EXT:
+               /* validate the trigger edge selection */
+               arg = cmd->start_arg & 0xffff;
+               if (arg < 1 || arg > 3) {
+                       cmd->start_arg &= ~0xffff;
+                       cmd->start_arg |= 1;
+                       err |= -EINVAL;
+               }
+               /* validate the trigger mode selection */
+               arg = cmd->start_arg >> 16;
+               if (arg != 2) {
+                       cmd->start_arg &= ~(0xffff << 16);
+                       cmd->start_arg |= (2 << 16);
+                       err |= -EINVAL;
+               }
+               break;
+       }
+
+       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+
        /* i_FirstChannel=cmd->chanlist[0]; */
        s_BoardInfos[dev->minor].i_FirstChannel = cmd->chanlist[0];
        /* i_LastChannel=cmd->chanlist[1]; */
index 0daa0ea63b5ef1fa11decb610a2e24662e8c80be..c242afc9134d6978660ad724c7fdb7b685576d01 100644 (file)
@@ -198,7 +198,7 @@ static int apci1032_cos_cmdtest(struct comedi_device *dev,
        err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
        err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
        err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, 1);
+       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
        err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
@@ -332,6 +332,7 @@ static int apci1032_auto_attach(struct comedi_device *dev,
                s->range_table  = &range_digital;
                s->insn_config  = apci1032_cos_insn_config;
                s->insn_bits    = apci1032_cos_insn_bits;
+               s->len_chanlist = 1;
                s->do_cmdtest   = apci1032_cos_cmdtest;
                s->do_cmd       = apci1032_cos_cmd;
                s->cancel       = apci1032_cos_cancel;
@@ -379,5 +380,5 @@ static struct pci_driver apci1032_pci_driver = {
 module_comedi_pci_driver(apci1032_driver, apci1032_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
-MODULE_DESCRIPTION("Comedi low-level driver");
+MODULE_DESCRIPTION("ADDI-DATA APCI-1032, 32 channel DI boards");
 MODULE_LICENSE("GPL");
index bd8e08ca14c02fe92381f3a3f4c5a24116938f16..eab75eb26478164d718d54817b375ee7883aac6a 100644 (file)
@@ -72,5 +72,5 @@ static struct pci_driver apci1500_pci_driver = {
 module_comedi_pci_driver(apci1500_driver, apci1500_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
-MODULE_DESCRIPTION("Comedi low-level driver");
+MODULE_DESCRIPTION("ADDI-DATA APCI-1500, 16 channel DI / 16 channel DO boards");
 MODULE_LICENSE("GPL");
index 27aa9ae1bdd9e3a9f53413df969ff005aede3a71..5f6d3b56fad2ba63b393ea10fa84b197e2e835ee 100644 (file)
@@ -9,7 +9,6 @@
 
 #include "addi-data/addi_eeprom.c"
 #include "addi-data/hwdrv_apci1564.c"
-#include "addi-data/addi_common.c"
 
 static const struct addi_board apci1564_boardtypes[] = {
        {
@@ -34,19 +33,217 @@ static const struct addi_board apci1564_boardtypes[] = {
        },
 };
 
+static int i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev,
+                                    struct comedi_subdevice *s,
+                                    struct comedi_insn *insn,
+                                    unsigned int *data)
+{
+       const struct addi_board *this_board = comedi_board(dev);
+       struct addi_private *devpriv = dev->private;
+       unsigned short w_Address = CR_CHAN(insn->chanspec);
+       unsigned short w_Data;
+
+       w_Data = addi_eeprom_readw(devpriv->i_IobaseAmcc,
+               this_board->pc_EepromChip, 2 * w_Address);
+       data[0] = w_Data;
+
+       return insn->n;
+}
+
+static irqreturn_t v_ADDI_Interrupt(int irq, void *d)
+{
+       struct comedi_device *dev = d;
+       const struct addi_board *this_board = comedi_board(dev);
+
+       this_board->interrupt(irq, d);
+       return IRQ_RETVAL(1);
+}
+
+static int i_ADDI_Reset(struct comedi_device *dev)
+{
+       const struct addi_board *this_board = comedi_board(dev);
+
+       this_board->reset(dev);
+       return 0;
+}
+
 static int apci1564_auto_attach(struct comedi_device *dev,
-                               unsigned long context)
+                                     unsigned long context_unused)
+{
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+       const struct addi_board *this_board = comedi_board(dev);
+       struct addi_private *devpriv;
+       struct comedi_subdevice *s;
+       int ret, n_subdevices;
+       unsigned int dw_Dummy;
+
+       dev->board_name = this_board->pc_DriverName;
+
+       devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
+       if (!devpriv)
+               return -ENOMEM;
+
+       ret = comedi_pci_enable(dev);
+       if (ret)
+               return ret;
+
+       if (this_board->i_IorangeBase1)
+               dev->iobase = pci_resource_start(pcidev, 1);
+       else
+               dev->iobase = pci_resource_start(pcidev, 0);
+
+       devpriv->iobase = dev->iobase;
+       devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0);
+       devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2);
+       devpriv->i_IobaseReserved = pci_resource_start(pcidev, 3);
+
+       /* Initialize parameters that can be overridden in EEPROM */
+       devpriv->s_EeParameters.i_NbrAiChannel = this_board->i_NbrAiChannel;
+       devpriv->s_EeParameters.i_NbrAoChannel = this_board->i_NbrAoChannel;
+       devpriv->s_EeParameters.i_AiMaxdata = this_board->i_AiMaxdata;
+       devpriv->s_EeParameters.i_AoMaxdata = this_board->i_AoMaxdata;
+       devpriv->s_EeParameters.i_NbrDiChannel = this_board->i_NbrDiChannel;
+       devpriv->s_EeParameters.i_NbrDoChannel = this_board->i_NbrDoChannel;
+       devpriv->s_EeParameters.i_DoMaxdata = this_board->i_DoMaxdata;
+       devpriv->s_EeParameters.i_Timer = this_board->i_Timer;
+       devpriv->s_EeParameters.ui_MinAcquisitiontimeNs =
+               this_board->ui_MinAcquisitiontimeNs;
+       devpriv->s_EeParameters.ui_MinDelaytimeNs =
+               this_board->ui_MinDelaytimeNs;
+
+       /* ## */
+
+       if (pcidev->irq > 0) {
+               ret = request_irq(pcidev->irq, v_ADDI_Interrupt, IRQF_SHARED,
+                                 dev->board_name, dev);
+               if (ret == 0)
+                       dev->irq = pcidev->irq;
+       }
+
+       /*  Read eepeom and fill addi_board Structure */
+
+       if (this_board->i_PCIEeprom) {
+               if (!(strcmp(this_board->pc_EepromChip, "S5920"))) {
+                       /*  Set 3 wait stait */
+                       if (!(strcmp(dev->board_name, "apci035")))
+                               outl(0x80808082, devpriv->i_IobaseAmcc + 0x60);
+                       else
+                               outl(0x83838383, devpriv->i_IobaseAmcc + 0x60);
+
+                       /*  Enable the interrupt for the controller */
+                       dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38);
+                       outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38);
+               }
+               addi_eeprom_read_info(dev, pci_resource_start(pcidev, 0));
+       }
+
+       n_subdevices = 7;
+       ret = comedi_alloc_subdevices(dev, n_subdevices);
+       if (ret)
+               return ret;
+
+       /*  Allocate and Initialise AI Subdevice Structures */
+       s = &dev->subdevices[0];
+       s->type = COMEDI_SUBD_UNUSED;
+
+       /*  Allocate and Initialise AO Subdevice Structures */
+       s = &dev->subdevices[1];
+       s->type = COMEDI_SUBD_UNUSED;
+
+       /*  Allocate and Initialise DI Subdevice Structures */
+       s = &dev->subdevices[2];
+       if (devpriv->s_EeParameters.i_NbrDiChannel) {
+               s->type = COMEDI_SUBD_DI;
+               s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON;
+               s->n_chan = devpriv->s_EeParameters.i_NbrDiChannel;
+               s->maxdata = 1;
+               s->len_chanlist =
+                       devpriv->s_EeParameters.i_NbrDiChannel;
+               s->range_table = &range_digital;
+               s->insn_config = this_board->di_config;
+               s->insn_read = this_board->di_read;
+               s->insn_write = this_board->di_write;
+               s->insn_bits = this_board->di_bits;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+       /*  Allocate and Initialise DO Subdevice Structures */
+       s = &dev->subdevices[3];
+       if (devpriv->s_EeParameters.i_NbrDoChannel) {
+               s->type = COMEDI_SUBD_DO;
+               s->subdev_flags =
+                       SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
+               s->n_chan = devpriv->s_EeParameters.i_NbrDoChannel;
+               s->maxdata = devpriv->s_EeParameters.i_DoMaxdata;
+               s->len_chanlist =
+                       devpriv->s_EeParameters.i_NbrDoChannel;
+               s->range_table = &range_digital;
+
+               /* insn_config - for digital output memory */
+               s->insn_config = this_board->do_config;
+               s->insn_write = this_board->do_write;
+               s->insn_bits = this_board->do_bits;
+               s->insn_read = this_board->do_read;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+
+       /*  Allocate and Initialise Timer Subdevice Structures */
+       s = &dev->subdevices[4];
+       if (devpriv->s_EeParameters.i_Timer) {
+               s->type = COMEDI_SUBD_TIMER;
+               s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
+               s->n_chan = 1;
+               s->maxdata = 0;
+               s->len_chanlist = 1;
+               s->range_table = &range_digital;
+
+               s->insn_write = this_board->timer_write;
+               s->insn_read = this_board->timer_read;
+               s->insn_config = this_board->timer_config;
+               s->insn_bits = this_board->timer_bits;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+
+       /*  Allocate and Initialise TTL */
+       s = &dev->subdevices[5];
+       s->type = COMEDI_SUBD_UNUSED;
+
+       /* EEPROM */
+       s = &dev->subdevices[6];
+       if (this_board->i_PCIEeprom) {
+               s->type = COMEDI_SUBD_MEMORY;
+               s->subdev_flags = SDF_READABLE | SDF_INTERNAL;
+               s->n_chan = 256;
+               s->maxdata = 0xffff;
+               s->insn_read = i_ADDIDATA_InsnReadEeprom;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+
+       i_ADDI_Reset(dev);
+       return 0;
+}
+
+static void apci1564_detach(struct comedi_device *dev)
 {
-       dev->board_ptr = &apci1564_boardtypes[0];
+       struct addi_private *devpriv = dev->private;
 
-       return addi_auto_attach(dev, context);
+       if (devpriv) {
+               if (dev->iobase)
+                       i_ADDI_Reset(dev);
+               if (dev->irq)
+                       free_irq(dev->irq, dev);
+       }
+       comedi_pci_disable(dev);
 }
 
 static struct comedi_driver apci1564_driver = {
        .driver_name    = "addi_apci_1564",
        .module         = THIS_MODULE,
        .auto_attach    = apci1564_auto_attach,
-       .detach         = i_ADDI_Detach,
+       .detach         = apci1564_detach,
 };
 
 static int apci1564_pci_probe(struct pci_dev *dev,
@@ -70,5 +267,5 @@ static struct pci_driver apci1564_pci_driver = {
 module_comedi_pci_driver(apci1564_driver, apci1564_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
-MODULE_DESCRIPTION("Comedi low-level driver");
+MODULE_DESCRIPTION("ADDI-DATA APCI-1564, 32 channel DI / 32 channel DO boards");
 MODULE_LICENSE("GPL");
index c9b933cb5987c069fad52c98f64a8894e94f4f0c..feefc7a5ca9a7fe6b2df196d77e404fee2039d81 100644 (file)
@@ -374,5 +374,5 @@ static struct pci_driver apci2032_pci_driver = {
 module_comedi_pci_driver(apci2032_driver, apci2032_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
-MODULE_DESCRIPTION("Comedi low-level driver");
+MODULE_DESCRIPTION("ADDI-DATA APCI-2032, 32 channel DO boards");
 MODULE_LICENSE("GPL");
index 57ee6e5c76355a8d63ef34e8335e1e3d1ed331f2..0cfb12fa1cbc8d0131cfb8838456f3dc1ba570c1 100644 (file)
@@ -246,5 +246,5 @@ static struct pci_driver apci3120_pci_driver = {
 module_comedi_pci_driver(apci3120_driver, apci3120_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
-MODULE_DESCRIPTION("Comedi low-level driver");
+MODULE_DESCRIPTION("ADDI-DATA APCI-3120, Analog input board");
 MODULE_LICENSE("GPL");
index 6dc11c407f572e966bebf55e8775cb5071eff10b..64c37b65ba27eec889e9654a38ef2d496aed9603 100644 (file)
@@ -573,26 +573,6 @@ static int apci3xxx_ai_cmdtest(struct comedi_device *dev,
 
        /* step 4: fix up any arguments */
 
-       /*
-        * FIXME: The hardware supports multiple scan modes but the original
-        * addi-data driver only supported reading a single channel with
-        * interrupts. Need a proper datasheet to fix this.
-        *
-        * The following scan modes are supported by the hardware:
-        * 1) Single software scan
-        * 2) Single hardware triggered scan
-        * 3) Continuous software scan
-        * 4) Continuous software scan with timer delay
-        * 5) Continuous hardware triggered scan
-        * 6) Continuous hardware triggered scan with timer delay
-        *
-        * For now, limit the chanlist to a single channel.
-        */
-       if (cmd->chanlist_len > 1) {
-               cmd->chanlist_len = 1;
-               err |= -EINVAL;
-       }
-
        tmp = cmd->convert_arg;
        err |= apci3xxx_ai_ns_to_timer(dev, &cmd->convert_arg,
                                       cmd->flags & TRIG_ROUND_MASK);
@@ -842,12 +822,30 @@ static int apci3xxx_auto_attach(struct comedi_device *dev,
                s->subdev_flags = SDF_READABLE | board->ai_subdev_flags;
                s->n_chan       = board->ai_n_chan;
                s->maxdata      = board->ai_maxdata;
-               s->len_chanlist = s->n_chan;
                s->range_table  = &apci3xxx_ai_range;
                s->insn_read    = apci3xxx_ai_insn_read;
                if (dev->irq) {
+                       /*
+                        * FIXME: The hardware supports multiple scan modes
+                        * but the original addi-data driver only supported
+                        * reading a single channel with interrupts. Need a
+                        * proper datasheet to fix this.
+                        *
+                        * The following scan modes are supported by the
+                        * hardware:
+                        *   1) Single software scan
+                        *   2) Single hardware triggered scan
+                        *   3) Continuous software scan
+                        *   4) Continuous software scan with timer delay
+                        *   5) Continuous hardware triggered scan
+                        *   6) Continuous hardware triggered scan with timer
+                        *      delay
+                        *
+                        * For now, limit the chanlist to a single channel.
+                        */
                        dev->read_subdev = s;
                        s->subdev_flags |= SDF_CMD_READ;
+                       s->len_chanlist = 1;
                        s->do_cmdtest   = apci3xxx_ai_cmdtest;
                        s->do_cmd       = apci3xxx_ai_cmd;
                        s->cancel       = apci3xxx_ai_cancel;
index a29ceacb966ddb0796ded16bbf33c607b9c248c0..9225a382a2ae089891cc88343baa0bdb6d1d152c 100644 (file)
@@ -314,75 +314,103 @@ static int pci9111_ai_cancel(struct comedi_device *dev,
        return 0;
 }
 
+static int pci9111_ai_check_chanlist(struct comedi_device *dev,
+                                    struct comedi_subdevice *s,
+                                    struct comedi_cmd *cmd)
+{
+       unsigned int range0 = CR_RANGE(cmd->chanlist[0]);
+       unsigned int aref0 = CR_AREF(cmd->chanlist[0]);
+       int i;
+
+       for (i = 1; i < cmd->chanlist_len; i++) {
+               unsigned int chan = CR_CHAN(cmd->chanlist[i]);
+               unsigned int range = CR_RANGE(cmd->chanlist[i]);
+               unsigned int aref = CR_AREF(cmd->chanlist[i]);
+
+               if (chan != i) {
+                       dev_dbg(dev->class_dev,
+                               "entries in chanlist must be consecutive channels,counting upwards from 0\n");
+                       return -EINVAL;
+               }
+
+               if (range != range0) {
+                       dev_dbg(dev->class_dev,
+                               "entries in chanlist must all have the same gain\n");
+                       return -EINVAL;
+               }
+
+               if (aref != aref0) {
+                       dev_dbg(dev->class_dev,
+                               "entries in chanlist must all have the same reference\n");
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
 static int pci9111_ai_do_cmd_test(struct comedi_device *dev,
                                  struct comedi_subdevice *s,
                                  struct comedi_cmd *cmd)
 {
        struct pci9111_private_data *dev_private = dev->private;
+       int err = 0;
        int tmp;
-       int error = 0;
-       int range, reference;
-       int i;
 
        /* Step 1 : check if triggers are trivially valid */
 
-       error |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       error |= cfc_check_trigger_src(&cmd->scan_begin_src,
+       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
                                        TRIG_TIMER | TRIG_FOLLOW | TRIG_EXT);
-       error |= cfc_check_trigger_src(&cmd->convert_src,
+       err |= cfc_check_trigger_src(&cmd->convert_src,
                                        TRIG_TIMER | TRIG_EXT);
-       error |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       error |= cfc_check_trigger_src(&cmd->stop_src,
+       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= cfc_check_trigger_src(&cmd->stop_src,
                                        TRIG_COUNT | TRIG_NONE);
 
-       if (error)
+       if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       error |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       error |= cfc_check_trigger_is_unique(cmd->convert_src);
-       error |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= cfc_check_trigger_is_unique(cmd->convert_src);
+       err |= cfc_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
-       if ((cmd->convert_src == TRIG_TIMER) &&
-           !((cmd->scan_begin_src == TRIG_TIMER) ||
-             (cmd->scan_begin_src == TRIG_FOLLOW)))
-               error |= -EINVAL;
-       if ((cmd->convert_src == TRIG_EXT) &&
-           !((cmd->scan_begin_src == TRIG_EXT) ||
-             (cmd->scan_begin_src == TRIG_FOLLOW)))
-               error |= -EINVAL;
+       if (cmd->scan_begin_src != TRIG_FOLLOW) {
+               if (cmd->scan_begin_src != cmd->convert_src)
+                       err |= -EINVAL;
+       }
 
-       if (error)
+       if (err)
                return 2;
 
        /* Step 3: check if arguments are trivially valid */
 
-       error |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
 
        if (cmd->convert_src == TRIG_TIMER)
-               error |= cfc_check_trigger_arg_min(&cmd->convert_arg,
+               err |= cfc_check_trigger_arg_min(&cmd->convert_arg,
                                        PCI9111_AI_ACQUISITION_PERIOD_MIN_NS);
        else    /* TRIG_EXT */
-               error |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
+               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
 
        if (cmd->scan_begin_src == TRIG_TIMER)
-               error |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
+               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
                                        PCI9111_AI_ACQUISITION_PERIOD_MIN_NS);
        else    /* TRIG_FOLLOW || TRIG_EXT */
-               error |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
 
-       error |= cfc_check_trigger_arg_is(&cmd->scan_end_arg,
-                                         cmd->chanlist_len);
+       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               error |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               error |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
 
-       if (error)
+       if (err)
                return 3;
 
        /*  Step 4 : fix up any arguments */
@@ -394,7 +422,7 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev,
                                          &dev_private->div2,
                                          &cmd->convert_arg, cmd->flags);
                if (tmp != cmd->convert_arg)
-                       error++;
+                       err |= -EINVAL;
        }
        /*  There's only one timer on this card, so the scan_begin timer must */
        /*  be a multiple of chanlist_len*convert_arg */
@@ -414,48 +442,23 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev,
                                scan_begin_arg = scan_factor * scan_begin_min;
                                if (cmd->scan_begin_arg != scan_begin_arg) {
                                        cmd->scan_begin_arg = scan_begin_arg;
-                                       error++;
+                                       err |= -EINVAL;
                                }
                        } else {
                                cmd->scan_begin_arg = scan_begin_min;
-                               error++;
+                               err |= -EINVAL;
                        }
                }
        }
 
-       if (error)
+       if (err)
                return 4;
 
-       /*  Step 5 : check channel list */
-
-       if (cmd->chanlist) {
-
-               range = CR_RANGE(cmd->chanlist[0]);
-               reference = CR_AREF(cmd->chanlist[0]);
-
-               if (cmd->chanlist_len > 1) {
-                       for (i = 0; i < cmd->chanlist_len; i++) {
-                               if (CR_CHAN(cmd->chanlist[i]) != i) {
-                                       comedi_error(dev,
-                                                    "entries in chanlist must be consecutive "
-                                                    "channels,counting upwards from 0\n");
-                                       error++;
-                               }
-                               if (CR_RANGE(cmd->chanlist[i]) != range) {
-                                       comedi_error(dev,
-                                                    "entries in chanlist must all have the same gain\n");
-                                       error++;
-                               }
-                               if (CR_AREF(cmd->chanlist[i]) != reference) {
-                                       comedi_error(dev,
-                                                    "entries in chanlist must all have the same reference\n");
-                                       error++;
-                               }
-                       }
-               }
-       }
+       /* Step 5: check channel list if it exists */
+       if (cmd->chanlist && cmd->chanlist_len > 0)
+               err |= pci9111_ai_check_chanlist(dev, s, cmd);
 
-       if (error)
+       if (err)
                return 5;
 
        return 0;
index 3cfa1756fa6aa2cf9d4091042de8aff01506805d..4be5f67cf14ad129648251f698bf1037afd02d14 100644 (file)
@@ -96,7 +96,7 @@ Configuration options:
                                 * correct channel number on every 12 bit sample
                                 */
 
-#define IORANGE_9118   64      /* I hope */
+#define IORANGE_9118   64      /* I hope */
 #define PCI9118_CHANLEN        255     /*
                                 * len of chanlist, some source say 256,
                                 * but reality looks like 255 :-(
@@ -383,7 +383,7 @@ struct pci9118_private {
                                                 * users(0-AI, 1-AO, 2-DI, 3-DO)
                                                 */
        unsigned int cnt0_divisor;              /* actual CNT0 divisor */
-       void (*int_ai_func) (struct comedi_device *, struct comedi_subdevice *,
+       void (*int_ai_func)(struct comedi_device *, struct comedi_subdevice *,
                unsigned short,
                unsigned int,
                unsigned short);        /*
@@ -411,7 +411,6 @@ struct pci9118_private {
                                         */
        unsigned int ai_maskerr;        /* which warning was printed */
        unsigned int ai_maskharderr;    /* on which error bits stops */
-       unsigned int ai_inttrig_start;  /* TRIG_INT for start */
 };
 
 static int check_channel_list(struct comedi_device *dev,
@@ -1045,7 +1044,7 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev,
                move_block_from_dma(dev, s,
                                    devpriv->dmabuf_virt[devpriv->dma_actbuf],
                                    samplesinbuf);
-               m = m - sampls;         /* m= how many samples was transferred */
+               m = m - sampls;         /* m=how many samples was transferred */
        }
 
        if (!devpriv->ai_neverending) {
@@ -1135,11 +1134,13 @@ static irqreturn_t interrupt_pci9118(int irq, void *d)
 }
 
 static int pci9118_ai_inttrig(struct comedi_device *dev,
-                             struct comedi_subdevice *s, unsigned int trignum)
+                             struct comedi_subdevice *s,
+                             unsigned int trig_num)
 {
        struct pci9118_private *devpriv = dev->private;
+       struct comedi_cmd *cmd = &s->async->cmd;
 
-       if (trignum != devpriv->ai_inttrig_start)
+       if (trig_num != cmd->start_arg)
                return -EINVAL;
 
        devpriv->ai12_startstop &= ~START_AI_INT;
@@ -1221,8 +1222,15 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       if (cmd->start_src & (TRIG_NOW | TRIG_EXT))
+       switch (cmd->start_src) {
+       case TRIG_NOW:
+       case TRIG_EXT:
                err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               break;
+       case TRIG_INT:
+               /* start_arg is the internal trigger (any value) */
+               break;
+       }
 
        if (cmd->scan_begin_src & (TRIG_FOLLOW | TRIG_EXT))
                err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
@@ -1259,8 +1267,6 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev,
                err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1);
-       err |= cfc_check_trigger_arg_max(&cmd->chanlist_len,
-                                        this_board->n_aichanlist);
 
        err |= cfc_check_trigger_arg_min(&cmd->scan_end_arg,
                                         cmd->chanlist_len);
@@ -1629,7 +1635,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        }
        if (cmd->start_src == TRIG_INT) {
                devpriv->ai12_startstop |= START_AI_INT;
-               devpriv->ai_inttrig_start = cmd->start_arg;
                s->async->inttrig = pci9118_ai_inttrig;
        }
 #if 0
index 28ec48548317ca86cc706e95c4af5e3661add169..765b1f00255bc7b40be90fa85e5a10400bfa0b87 100644 (file)
@@ -301,7 +301,6 @@ struct pci1710_private {
        char neverending_ai;    /*  we do unlimited AI */
        unsigned int CntrlReg;  /*  Control register */
        unsigned int i8254_osc_base;    /*  frequence of onboard oscilator */
-       unsigned int ai_do;     /*  what do AI? 0=nothing, 1 to 4 mode */
        unsigned int ai_act_scan;       /*  how many scans we finished */
        unsigned int ai_act_chan;       /*  actual position in actual scan */
        unsigned int ai_buf_ptr;        /*  data buffer ptr in samples */
@@ -314,13 +313,6 @@ struct pci1710_private {
        unsigned char act_chanlist_len; /*  len of scanlist */
        unsigned char act_chanlist_pos; /*  actual position in MUX list */
        unsigned char da_ranges;        /*  copy of D/A outpit range register */
-       unsigned int ai_scans;  /*  len of scanlist */
-       unsigned int ai_n_chan; /*  how many channels is measured */
-       unsigned int *ai_chanlist;      /*  actaul chanlist */
-       unsigned int ai_flags;  /*  flaglist */
-       unsigned int ai_data_len;       /*  len of data buffer */
-       unsigned int ai_timer1; /*  timers */
-       unsigned int ai_timer2;
        unsigned short ao_data[4];      /*  data output buffer */
        unsigned int cnt0_write_wait;   /* after a write, wait for update of the
                                         * internal state */
@@ -340,12 +332,14 @@ static const unsigned int muxonechan[] = {
  If it's ok, then program scan/gain logic.
  This works for all cards.
 */
-static int check_channel_list(struct comedi_device *dev,
-                             struct comedi_subdevice *s,
-                             unsigned int *chanlist, unsigned int n_chan)
+static int pci171x_ai_check_chanlist(struct comedi_device *dev,
+                                    struct comedi_subdevice *s,
+                                    struct comedi_cmd *cmd)
 {
        unsigned int chansegment[32];
        unsigned int i, nowmustbechan, seglen, segpos;
+       unsigned int *chanlist = cmd->chanlist;
+       unsigned int n_chan = cmd->chanlist_len;
 
        /* correct channel and range number check itself comedi/range.c */
        if (n_chan < 1) {
@@ -733,7 +727,6 @@ static int pci171x_ai_cancel(struct comedi_device *dev,
                break;
        }
 
-       devpriv->ai_do = 0;
        devpriv->ai_act_scan = 0;
        s->async->cur_chan = 0;
        devpriv->ai_buf_ptr = 0;
@@ -750,6 +743,7 @@ static void interrupt_pci1710_every_sample(void *d)
        struct comedi_device *dev = d;
        struct pci1710_private *devpriv = dev->private;
        struct comedi_subdevice *s = dev->read_subdev;
+       struct comedi_cmd *cmd = &s->async->cmd;
        int m;
 #ifdef PCI171x_PARANOIDCHECK
        const struct boardtype *this_board = comedi_board(dev);
@@ -798,14 +792,14 @@ static void interrupt_pci1710_every_sample(void *d)
 #endif
                ++s->async->cur_chan;
 
-               if (s->async->cur_chan >= devpriv->ai_n_chan)
+               if (s->async->cur_chan >= cmd->chanlist_len)
                        s->async->cur_chan = 0;
 
 
                if (s->async->cur_chan == 0) {  /*  one scan done */
                        devpriv->ai_act_scan++;
                        if ((!devpriv->neverending_ai) &&
-                           (devpriv->ai_act_scan >= devpriv->ai_scans)) {
+                           (devpriv->ai_act_scan >= cmd->stop_arg)) {
                                /*  all data sampled */
                                s->async->events |= COMEDI_CB_EOA;
                                cfc_handle_events(dev, s);
@@ -826,6 +820,7 @@ static int move_block_from_fifo(struct comedi_device *dev,
                                struct comedi_subdevice *s, int n, int turn)
 {
        struct pci1710_private *devpriv = dev->private;
+       struct comedi_cmd *cmd = &s->async->cmd;
        int i, j;
 #ifdef PCI171x_PARANOIDCHECK
        const struct boardtype *this_board = comedi_board(dev);
@@ -855,7 +850,7 @@ static int move_block_from_fifo(struct comedi_device *dev,
                               inw(dev->iobase + PCI171x_AD_DATA) & 0x0fff);
 #endif
                j++;
-               if (j >= devpriv->ai_n_chan) {
+               if (j >= cmd->chanlist_len) {
                        j = 0;
                        devpriv->ai_act_scan++;
                }
@@ -873,6 +868,7 @@ static void interrupt_pci1710_half_fifo(void *d)
        const struct boardtype *this_board = comedi_board(dev);
        struct pci1710_private *devpriv = dev->private;
        struct comedi_subdevice *s = dev->read_subdev;
+       struct comedi_cmd *cmd = &s->async->cmd;
        int m, samplesinbuf;
 
        m = inw(dev->iobase + PCI171x_STATUS);
@@ -891,8 +887,8 @@ static void interrupt_pci1710_half_fifo(void *d)
        }
 
        samplesinbuf = this_board->fifo_half_size;
-       if (samplesinbuf * sizeof(short) >= devpriv->ai_data_len) {
-               m = devpriv->ai_data_len / sizeof(short);
+       if (samplesinbuf * sizeof(short) >= s->async->prealloc_bufsz) {
+               m = s->async->prealloc_bufsz / sizeof(short);
                if (move_block_from_fifo(dev, s, m, 0))
                        return;
                samplesinbuf -= m;
@@ -904,8 +900,8 @@ static void interrupt_pci1710_half_fifo(void *d)
        }
 
        if (!devpriv->neverending_ai)
-               if (devpriv->ai_act_scan >= devpriv->ai_scans) { /* all data
-                                                                   sampled */
+               if (devpriv->ai_act_scan >= cmd->stop_arg) {
+                       /* all data sampled */
                        s->async->events |= COMEDI_CB_EOA;
                        cfc_handle_events(dev, s);
                        return;
@@ -951,31 +947,33 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d)
        return IRQ_HANDLED;
 }
 
-/*
-==============================================================================
-*/
-static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
-                                    struct comedi_subdevice *s)
+static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 {
-       const struct boardtype *this_board = comedi_board(dev);
        struct pci1710_private *devpriv = dev->private;
+       struct comedi_cmd *cmd = &s->async->cmd;
        unsigned int divisor1 = 0, divisor2 = 0;
        unsigned int seglen;
+       int mode;
+
+       if (cmd->convert_src == TRIG_TIMER) {
+               if (cmd->start_src == TRIG_EXT)
+                       mode = 2;
+               else
+                       mode = 1;
+       } else {        /* TRIG_EXT */
+               mode = 3;
+       }
 
        start_pacer(dev, -1, 0, 0);     /*  stop pacer */
 
-       seglen = check_channel_list(dev, s, devpriv->ai_chanlist,
-                                   devpriv->ai_n_chan);
+       seglen = pci171x_ai_check_chanlist(dev, s, cmd);
        if (seglen < 1)
                return -EINVAL;
-       setup_channel_list(dev, s, devpriv->ai_chanlist,
-                          devpriv->ai_n_chan, seglen);
+       setup_channel_list(dev, s, cmd->chanlist, cmd->chanlist_len, seglen);
 
        outb(0, dev->iobase + PCI171x_CLRFIFO);
        outb(0, dev->iobase + PCI171x_CLRINT);
 
-       devpriv->ai_do = mode;
-
        devpriv->ai_act_scan = 0;
        s->async->cur_chan = 0;
        devpriv->ai_buf_ptr = 0;
@@ -983,14 +981,14 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
 
        devpriv->CntrlReg &= Control_CNT0;
        /*  don't we want wake up every scan?  devpriv->ai_eos=1; */
-       if ((devpriv->ai_flags & TRIG_WAKE_EOS)) {
+       if (cmd->flags & TRIG_WAKE_EOS) {
                devpriv->ai_eos = 1;
        } else {
                devpriv->CntrlReg |= Control_ONEFH;
                devpriv->ai_eos = 0;
        }
 
-       if ((devpriv->ai_scans == 0) || (devpriv->ai_scans == -1))
+       if (cmd->stop_arg == 0)
                devpriv->neverending_ai = 1;
        /* well, user want neverending */
        else
@@ -999,8 +997,6 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
        switch (mode) {
        case 1:
        case 2:
-               if (devpriv->ai_timer1 < this_board->ai_ns_min)
-                       devpriv->ai_timer1 = this_board->ai_ns_min;
                devpriv->CntrlReg |= Control_PACER | Control_IRQEN;
                if (mode == 2) {
                        devpriv->ai_et_CntrlReg = devpriv->CntrlReg;
@@ -1013,8 +1009,8 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
                }
                i8253_cascade_ns_to_timer(devpriv->i8254_osc_base,
                                          &divisor1, &divisor2,
-                                         &devpriv->ai_timer1,
-                                         devpriv->ai_flags);
+                                         &cmd->convert_arg,
+                                         cmd->flags);
                outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);
                if (mode != 2) {
                        /*  start pacer */
@@ -1105,53 +1101,14 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev,
        if (err)
                return 4;
 
-       /* step 5: complain about special chanlist considerations */
+       /* Step 5: check channel list */
 
-       if (cmd->chanlist) {
-               if (!check_channel_list(dev, s, cmd->chanlist,
-                                       cmd->chanlist_len))
-                       return 5;       /*  incorrect channels list */
-       }
+       if (!pci171x_ai_check_chanlist(dev, s, cmd))
+               return 5;
 
        return 0;
 }
 
-/*
-==============================================================================
-*/
-static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
-{
-       struct pci1710_private *devpriv = dev->private;
-       struct comedi_cmd *cmd = &s->async->cmd;
-
-       devpriv->ai_n_chan = cmd->chanlist_len;
-       devpriv->ai_chanlist = cmd->chanlist;
-       devpriv->ai_flags = cmd->flags;
-       devpriv->ai_data_len = s->async->prealloc_bufsz;
-       devpriv->ai_timer1 = 0;
-       devpriv->ai_timer2 = 0;
-
-       if (cmd->stop_src == TRIG_COUNT)
-               devpriv->ai_scans = cmd->stop_arg;
-       else
-               devpriv->ai_scans = 0;
-
-
-       if (cmd->scan_begin_src == TRIG_FOLLOW) {       /*  mode 1, 2, 3 */
-               if (cmd->convert_src == TRIG_TIMER) {   /*  mode 1 and 2 */
-                       devpriv->ai_timer1 = cmd->convert_arg;
-                       return pci171x_ai_docmd_and_mode(cmd->start_src ==
-                                                        TRIG_EXT ? 2 : 1, dev,
-                                                        s);
-               }
-               if (cmd->convert_src == TRIG_EXT) {     /*  mode 3 */
-                       return pci171x_ai_docmd_and_mode(3, dev, s);
-               }
-       }
-
-       return -1;
-}
-
 /*
 ==============================================================================
 */
index 818a0d7e3d5808e984d402b7693f4c006efde8b7..4ac320884ac61cacb830cd0da4ddb19a18a64aa8 100644 (file)
@@ -281,22 +281,18 @@ static int dio200_start_intr(struct comedi_device *dev,
        return retval;
 }
 
-/*
- * Internal trigger function to start acquisition for an 'INTERRUPT' subdevice.
- */
-static int
-dio200_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s,
-                         unsigned int trignum)
+static int dio200_inttrig_start_intr(struct comedi_device *dev,
+                                    struct comedi_subdevice *s,
+                                    unsigned int trig_num)
 {
-       struct dio200_subdev_intr *subpriv;
+       struct dio200_subdev_intr *subpriv = s->private;
+       struct comedi_cmd *cmd = &s->async->cmd;
        unsigned long flags;
        int event = 0;
 
-       if (trignum != 0)
+       if (trig_num != cmd->start_arg)
                return -EINVAL;
 
-       subpriv = s->private;
-
        spin_lock_irqsave(&subpriv->spinlock, flags);
        s->async->inttrig = NULL;
        if (subpriv->active)
@@ -528,16 +524,11 @@ static int dio200_subdev_intr_cmd(struct comedi_device *dev,
                break;
        }
 
-       /* Set up start of acquisition. */
-       switch (cmd->start_src) {
-       case TRIG_INT:
+       if (cmd->start_src == TRIG_INT)
                s->async->inttrig = dio200_inttrig_start_intr;
-               break;
-       default:
-               /* TRIG_NOW */
+       else    /* TRIG_NOW */
                event = dio200_start_intr(dev, s);
-               break;
-       }
+
        spin_unlock_irqrestore(&subpriv->spinlock, flags);
 
        if (event)
index b21d7b48f1daf93ecc8365a21413cbe70023b7b0..2834d0a9342afe866e079f02808c3394868ae0f4 100644 (file)
@@ -314,7 +314,7 @@ static int pc236_intr_cmdtest(struct comedi_device *dev,
        err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
        err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
        err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, 1);
+       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
        err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
@@ -402,6 +402,7 @@ static int pc236_common_attach(struct comedi_device *dev, unsigned long iobase,
                        s->maxdata = 1;
                        s->range_table = &range_digital;
                        s->insn_bits = pc236_intr_insn;
+                       s->len_chanlist = 1;
                        s->do_cmdtest = pc236_intr_cmdtest;
                        s->do_cmd = pc236_intr_cmd;
                        s->cancel = pc236_intr_cancel;
index 29e01e280039d2c0519a52baaab16db15aaae4bb..f0b04cac4a6e9d07e8be112d49020b5dc2b615c3 100644 (file)
@@ -466,16 +466,6 @@ pci224_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
        return i;
 }
 
-/*
- * Just a wrapper for the inline function 'i8253_cascade_ns_to_timer'.
- */
-static void
-pci224_cascade_ns_to_timer(int osc_base, unsigned int *d1, unsigned int *d2,
-                          unsigned int *nanosec, int round_mode)
-{
-       i8253_cascade_ns_to_timer(osc_base, d1, d2, nanosec, round_mode);
-}
-
 /*
  * Kills a command running on the AO subdevice.
  */
@@ -671,14 +661,13 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev,
        cfc_handle_events(dev, s);
 }
 
-/*
- * Internal trigger function to start acquisition on AO subdevice.
- */
-static int
-pci224_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s,
-                       unsigned int trignum)
+static int pci224_ao_inttrig_start(struct comedi_device *dev,
+                                  struct comedi_subdevice *s,
+                                  unsigned int trig_num)
 {
-       if (trignum != 0)
+       struct comedi_cmd *cmd = &s->async->cmd;
+
+       if (trig_num != cmd->start_arg)
                return -EINVAL;
 
        s->async->inttrig = NULL;
@@ -687,6 +676,37 @@ pci224_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s,
        return 1;
 }
 
+static int pci224_ao_check_chanlist(struct comedi_device *dev,
+                                   struct comedi_subdevice *s,
+                                   struct comedi_cmd *cmd)
+{
+       unsigned int range0 = CR_RANGE(cmd->chanlist[0]);
+       unsigned int chan_mask = 0;
+       int i;
+
+       for (i = 0; i < cmd->chanlist_len; i++) {
+               unsigned int chan = CR_CHAN(cmd->chanlist[i]);
+               unsigned int range = CR_RANGE(cmd->chanlist[i]);
+
+               if (chan_mask & (1 << chan)) {
+                       dev_dbg(dev->class_dev,
+                               "%s: entries in chanlist must contain no duplicate channels\n",
+                               __func__);
+                       return -EINVAL;
+               }
+               chan_mask |= (1 << chan);
+
+               if (range != range0) {
+                       dev_dbg(dev->class_dev,
+                               "%s: entries in chanlist must all have the same range index\n",
+                               __func__);
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
 #define MAX_SCAN_PERIOD                0xFFFFFFFFU
 #define MIN_SCAN_PERIOD                2500
 #define CONVERT_PERIOD         625
@@ -821,98 +841,23 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
        /* Step 4: fix up any arguments. */
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
-               unsigned int div1, div2, round;
-               int round_mode = cmd->flags & TRIG_ROUND_MASK;
-
                tmp = cmd->scan_begin_arg;
-               /* Check whether to use a single timer. */
-               switch (round_mode) {
-               case TRIG_ROUND_NEAREST:
-               default:
-                       round = I8254_OSC_BASE_10MHZ / 2;
-                       break;
-               case TRIG_ROUND_DOWN:
-                       round = 0;
-                       break;
-               case TRIG_ROUND_UP:
-                       round = I8254_OSC_BASE_10MHZ - 1;
-                       break;
-               }
-               /* Be careful to avoid overflow! */
-               div2 = cmd->scan_begin_arg / I8254_OSC_BASE_10MHZ;
-               div2 += (round + cmd->scan_begin_arg % I8254_OSC_BASE_10MHZ) /
-                       I8254_OSC_BASE_10MHZ;
-               if (div2 <= 0x10000) {
-                       /* A single timer will suffice. */
-                       if (div2 < 2)
-                               div2 = 2;
-                       cmd->scan_begin_arg = div2 * I8254_OSC_BASE_10MHZ;
-                       if (cmd->scan_begin_arg < div2 ||
-                           cmd->scan_begin_arg < I8254_OSC_BASE_10MHZ) {
-                               /* Overflow! */
-                               cmd->scan_begin_arg = MAX_SCAN_PERIOD;
-                       }
-               } else {
-                       /* Use two timers. */
-                       div1 = devpriv->cached_div1;
-                       div2 = devpriv->cached_div2;
-                       pci224_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
-                                                  &div1, &div2,
-                                                  &cmd->scan_begin_arg,
-                                                  round_mode);
-                       devpriv->cached_div1 = div1;
-                       devpriv->cached_div2 = div2;
-               }
+               /* Use two timers. */
+               i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
+                                         &devpriv->cached_div1,
+                                         &devpriv->cached_div2,
+                                         &cmd->scan_begin_arg,
+                                         cmd->flags);
                if (tmp != cmd->scan_begin_arg)
                        err++;
-
        }
 
        if (err)
                return 4;
 
-       /* Step 5: check channel list. */
-
-       if (cmd->chanlist && (cmd->chanlist_len > 0)) {
-               unsigned int range;
-               enum { range_err = 1, dupchan_err = 2, };
-               unsigned errors;
-               unsigned int n;
-               unsigned int ch;
-
-               /*
-                * Check all channels have the same range index.  Don't care
-                * about analogue reference, as we can't configure it.
-                *
-                * Check the list has no duplicate channels.
-                */
-               range = CR_RANGE(cmd->chanlist[0]);
-               errors = 0;
-               tmp = 0;
-               for (n = 0; n < cmd->chanlist_len; n++) {
-                       ch = CR_CHAN(cmd->chanlist[n]);
-                       if (tmp & (1U << ch))
-                               errors |= dupchan_err;
-
-                       tmp |= (1U << ch);
-                       if (CR_RANGE(cmd->chanlist[n]) != range)
-                               errors |= range_err;
-
-               }
-               if (errors) {
-                       if (errors & dupchan_err) {
-                               dev_dbg(dev->class_dev,
-                                       "%s: entries in chanlist must contain no duplicate channels\n",
-                                       __func__);
-                       }
-                       if (errors & range_err) {
-                               dev_dbg(dev->class_dev,
-                                       "%s: entries in chanlist must all have the same range index\n",
-                                       __func__);
-                       }
-                       err++;
-               }
-       }
+       /* Step 5: check channel list if it exists */
+       if (cmd->chanlist && cmd->chanlist_len > 0)
+               err |= pci224_ao_check_chanlist(dev, s, cmd);
 
        if (err)
                return 5;
@@ -920,9 +865,32 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
        return 0;
 }
 
-/*
- * 'do_cmd' function for AO subdevice.
- */
+static void pci224_ao_start_pacer(struct comedi_device *dev,
+                                 struct comedi_subdevice *s)
+{
+       struct pci224_private *devpriv = dev->private;
+
+       /*
+        * The output of timer Z2-0 will be used as the scan trigger
+        * source.
+        */
+       /* Make sure Z2-0 is gated on.  */
+       outb(GAT_CONFIG(0, GAT_VCC), devpriv->iobase1 + PCI224_ZGAT_SCE);
+       /* Cascading with Z2-2. */
+       /* Make sure Z2-2 is gated on.  */
+       outb(GAT_CONFIG(2, GAT_VCC), devpriv->iobase1 + PCI224_ZGAT_SCE);
+       /* Z2-2 needs 10 MHz clock. */
+       outb(CLK_CONFIG(2, CLK_10MHZ), devpriv->iobase1 + PCI224_ZCLK_SCE);
+       /* Load Z2-2 mode (2) and counter (div1). */
+       i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0,
+                       2, devpriv->cached_div1, 2);
+       /* Z2-0 is clocked from Z2-2's output. */
+       outb(CLK_CONFIG(0, CLK_OUTNM1), devpriv->iobase1 + PCI224_ZCLK_SCE);
+       /* Load Z2-0 mode (2) and counter (div2). */
+       i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0,
+                  0, devpriv->cached_div2, 2);
+}
+
 static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 {
        struct pci224_private *devpriv = dev->private;
@@ -978,72 +946,8 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
             dev->iobase + PCI224_DACCON);
 
-       if (cmd->scan_begin_src == TRIG_TIMER) {
-               unsigned int div1, div2, round;
-               unsigned int ns = cmd->scan_begin_arg;
-               int round_mode = cmd->flags & TRIG_ROUND_MASK;
-
-               /* Check whether to use a single timer. */
-               switch (round_mode) {
-               case TRIG_ROUND_NEAREST:
-               default:
-                       round = I8254_OSC_BASE_10MHZ / 2;
-                       break;
-               case TRIG_ROUND_DOWN:
-                       round = 0;
-                       break;
-               case TRIG_ROUND_UP:
-                       round = I8254_OSC_BASE_10MHZ - 1;
-                       break;
-               }
-               /* Be careful to avoid overflow! */
-               div2 = cmd->scan_begin_arg / I8254_OSC_BASE_10MHZ;
-               div2 += (round + cmd->scan_begin_arg % I8254_OSC_BASE_10MHZ) /
-                       I8254_OSC_BASE_10MHZ;
-               if (div2 <= 0x10000) {
-                       /* A single timer will suffice. */
-                       if (div2 < 2)
-                               div2 = 2;
-                       div2 &= 0xffff;
-                       div1 = 1;       /* Flag that single timer to be used. */
-               } else {
-                       /* Use two timers. */
-                       div1 = devpriv->cached_div1;
-                       div2 = devpriv->cached_div2;
-                       pci224_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
-                                                  &div1, &div2,
-                                                  &ns, round_mode);
-               }
-
-               /*
-                * The output of timer Z2-0 will be used as the scan trigger
-                * source.
-                */
-               /* Make sure Z2-0 is gated on.  */
-               outb(GAT_CONFIG(0, GAT_VCC),
-                    devpriv->iobase1 + PCI224_ZGAT_SCE);
-               if (div1 == 1) {
-                       /* Not cascading.  Z2-0 needs 10 MHz clock. */
-                       outb(CLK_CONFIG(0, CLK_10MHZ),
-                            devpriv->iobase1 + PCI224_ZCLK_SCE);
-               } else {
-                       /* Cascading with Z2-2. */
-                       /* Make sure Z2-2 is gated on.  */
-                       outb(GAT_CONFIG(2, GAT_VCC),
-                            devpriv->iobase1 + PCI224_ZGAT_SCE);
-                       /* Z2-2 needs 10 MHz clock. */
-                       outb(CLK_CONFIG(2, CLK_10MHZ),
-                            devpriv->iobase1 + PCI224_ZCLK_SCE);
-                       /* Load Z2-2 mode (2) and counter (div1). */
-                       i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0,
-                                  2, div1, 2);
-                       /* Z2-0 is clocked from Z2-2's output. */
-                       outb(CLK_CONFIG(0, CLK_OUTNM1),
-                            devpriv->iobase1 + PCI224_ZCLK_SCE);
-               }
-               /* Load Z2-0 mode (2) and counter (div2). */
-               i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0, 0, div2, 2);
-       }
+       if (cmd->scan_begin_src == TRIG_TIMER)
+               pci224_ao_start_pacer(dev, s);
 
        /*
         * Sort out end of acquisition.
@@ -1061,23 +965,15 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
                break;
        }
 
-       /*
-        * Sort out start of acquisition.
-        */
-       switch (cmd->start_src) {
-       case TRIG_INT:
-               spin_lock_irqsave(&devpriv->ao_spinlock, flags);
-               s->async->inttrig = &pci224_ao_inttrig_start;
-               spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
-               break;
-       case TRIG_EXT:
+       spin_lock_irqsave(&devpriv->ao_spinlock, flags);
+       if (cmd->start_src == TRIG_INT) {
+               s->async->inttrig = pci224_ao_inttrig_start;
+       } else {        /* TRIG_EXT */
                /* Enable external interrupt trigger to start acquisition. */
-               spin_lock_irqsave(&devpriv->ao_spinlock, flags);
                devpriv->intsce |= PCI224_INTR_EXT;
                outb(devpriv->intsce, devpriv->iobase1 + PCI224_INT_SCE);
-               spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
-               break;
        }
+       spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
 
        return 0;
 }
index 99e60835dc4a9417941f5a15e3b948f678be3019..d7ffd18206f93836ab3c098a3fd3b7cbd00e2197 100644 (file)
@@ -953,6 +953,38 @@ static int pci230_ao_rinsn(struct comedi_device *dev,
        return i;
 }
 
+static int pci230_ao_check_chanlist(struct comedi_device *dev,
+                                   struct comedi_subdevice *s,
+                                   struct comedi_cmd *cmd)
+{
+       unsigned int prev_chan = CR_CHAN(cmd->chanlist[0]);
+       unsigned int range0 = CR_RANGE(cmd->chanlist[0]);
+       int i;
+
+       for (i = 1; i < cmd->chanlist_len; i++) {
+               unsigned int chan = CR_CHAN(cmd->chanlist[i]);
+               unsigned int range = CR_RANGE(cmd->chanlist[i]);
+
+               if (chan < prev_chan) {
+                       dev_dbg(dev->class_dev,
+                               "%s: channel numbers must increase\n",
+                               __func__);
+                       return -EINVAL;
+               }
+
+               if (range != range0) {
+                       dev_dbg(dev->class_dev,
+                               "%s: channels must have the same range\n",
+                               __func__);
+                       return -EINVAL;
+               }
+
+               prev_chan = chan;
+       }
+
+       return 0;
+}
+
 static int pci230_ao_cmdtest(struct comedi_device *dev,
                             struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
@@ -1065,48 +1097,9 @@ static int pci230_ao_cmdtest(struct comedi_device *dev,
        if (err)
                return 4;
 
-       /* Step 5: check channel list if it exists. */
-
-       if (cmd->chanlist && cmd->chanlist_len > 0) {
-               enum {
-                       seq_err = (1 << 0),
-                       range_err = (1 << 1)
-               };
-               unsigned int errors;
-               unsigned int n;
-               unsigned int chan, prev_chan;
-               unsigned int range, first_range;
-
-               prev_chan = CR_CHAN(cmd->chanlist[0]);
-               first_range = CR_RANGE(cmd->chanlist[0]);
-               errors = 0;
-               for (n = 1; n < cmd->chanlist_len; n++) {
-                       chan = CR_CHAN(cmd->chanlist[n]);
-                       range = CR_RANGE(cmd->chanlist[n]);
-                       /* Channel numbers must strictly increase. */
-                       if (chan < prev_chan)
-                               errors |= seq_err;
-
-                       /* Ranges must be the same. */
-                       if (range != first_range)
-                               errors |= range_err;
-
-                       prev_chan = chan;
-               }
-               if (errors != 0) {
-                       err++;
-                       if ((errors & seq_err) != 0) {
-                               dev_dbg(dev->class_dev,
-                                       "%s: channel numbers must increase\n",
-                                       __func__);
-                       }
-                       if ((errors & range_err) != 0) {
-                               dev_dbg(dev->class_dev,
-                                       "%s: channels must have the same range\n",
-                                       __func__);
-                       }
-               }
-       }
+       /* Step 5: check channel list if it exists */
+       if (cmd->chanlist && cmd->chanlist_len > 0)
+               err |= pci230_ao_check_chanlist(dev, s, cmd);
 
        if (err)
                return 5;
@@ -1434,7 +1427,9 @@ static int pci230_ao_inttrig_start(struct comedi_device *dev,
                                   struct comedi_subdevice *s,
                                   unsigned int trig_num)
 {
-       if (trig_num != 0)
+       struct comedi_cmd *cmd = &s->async->cmd;
+
+       if (trig_num != cmd->start_src)
                return -EINVAL;
 
        s->async->inttrig = NULL;
@@ -1552,6 +1547,109 @@ static int pci230_ai_check_scan_period(struct comedi_cmd *cmd)
        return !err;
 }
 
+static int pci230_ai_check_chanlist(struct comedi_device *dev,
+                                   struct comedi_subdevice *s,
+                                   struct comedi_cmd *cmd)
+{
+       struct pci230_private *devpriv = dev->private;
+       unsigned int max_diff_chan = (s->n_chan / 2) - 1;
+       unsigned int prev_chan = 0;
+       unsigned int prev_range = 0;
+       unsigned int prev_aref = 0;
+       unsigned int prev_polarity = 0;
+       unsigned int subseq_len = 0;
+       int i;
+
+       for (i = 0; i < cmd->chanlist_len; i++) {
+               unsigned int chanspec = cmd->chanlist[i];
+               unsigned int chan = CR_CHAN(chanspec);
+               unsigned int range = CR_RANGE(chanspec);
+               unsigned int aref = CR_AREF(chanspec);
+               unsigned int polarity = pci230_ai_bipolar[range];
+
+               if (aref == AREF_DIFF && chan >= max_diff_chan) {
+                       dev_dbg(dev->class_dev,
+                               "%s: differential channel number out of range 0 to %u\n",
+                               __func__, max_diff_chan);
+                       return -EINVAL;
+               }
+
+               if (i > 0) {
+                       /*
+                        * Channel numbers must strictly increase or
+                        * subsequence must repeat exactly.
+                        */
+                       if (chan <= prev_chan && subseq_len == 0)
+                               subseq_len = i;
+
+                       if (subseq_len > 0 &&
+                           cmd->chanlist[i % subseq_len] != chanspec) {
+                                       dev_dbg(dev->class_dev,
+                                               "%s: channel numbers must increase or sequence must repeat exactly\n",
+                                               __func__);
+                                       return -EINVAL;
+                       }
+
+                       if (aref != prev_aref) {
+                               dev_dbg(dev->class_dev,
+                                       "%s: channel sequence analogue references must be all the same (single-ended or differential)\n",
+                                       __func__);
+                               return -EINVAL;
+                       }
+
+                       if (polarity != prev_polarity) {
+                               dev_dbg(dev->class_dev,
+                                       "%s: channel sequence ranges must be all bipolar or all unipolar\n",
+                                       __func__);
+                               return -EINVAL;
+                       }
+
+                       if (aref != AREF_DIFF && range != prev_range &&
+                           ((chan ^ prev_chan) & ~1) == 0) {
+                               dev_dbg(dev->class_dev,
+                                       "%s: single-ended channel pairs must have the same range\n",
+                                       __func__);
+                               return -EINVAL;
+                       }
+               }
+               prev_chan = chan;
+               prev_range = range;
+               prev_aref = aref;
+               prev_polarity = polarity;
+       }
+
+       if (subseq_len == 0)
+               subseq_len = cmd->chanlist_len;
+
+       if ((cmd->chanlist_len % subseq_len) != 0) {
+               dev_dbg(dev->class_dev,
+                       "%s: sequence must repeat exactly\n", __func__);
+               return -EINVAL;
+       }
+
+       /*
+        * Buggy PCI230+ or PCI260+ requires channel 0 to be (first) in the
+        * sequence if the sequence contains more than one channel. Hardware
+        * versions 1 and 2 have the bug. There is no hardware version 3.
+        *
+        * Actually, there are two firmwares that report themselves as
+        * hardware version 1 (the boards have different ADC chips with
+        * slightly different timing requirements, which was supposed to
+        * be invisible to software). The first one doesn't seem to have
+        * the bug, but the second one does, and we can't tell them apart!
+        */
+       if (devpriv->hwver > 0 && devpriv->hwver < 4) {
+               if (subseq_len > 1 && CR_CHAN(cmd->chanlist[0]) != 0) {
+                       dev_info(dev->class_dev,
+                                "amplc_pci230: ai_cmdtest: Buggy PCI230+/260+ h/w version %u requires first channel of multi-channel sequence to be 0 (corrected in h/w version 4)\n",
+                                devpriv->hwver);
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
 static int pci230_ai_cmdtest(struct comedi_device *dev,
                             struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
@@ -1740,136 +1838,9 @@ static int pci230_ai_cmdtest(struct comedi_device *dev,
        if (err)
                return 4;
 
-       /* Step 5: check channel list if it exists. */
-
-       if (cmd->chanlist && cmd->chanlist_len > 0) {
-               enum {
-                       seq_err = 1 << 0,
-                       rangepair_err = 1 << 1,
-                       polarity_err = 1 << 2,
-                       aref_err = 1 << 3,
-                       diffchan_err = 1 << 4,
-                       buggy_chan0_err = 1 << 5
-               };
-               unsigned int errors;
-               unsigned int chan, prev_chan;
-               unsigned int range, prev_range;
-               unsigned int polarity, prev_polarity;
-               unsigned int aref, prev_aref;
-               unsigned int subseq_len;
-               unsigned int n;
-
-               subseq_len = 0;
-               errors = 0;
-               prev_chan = prev_aref = prev_range = prev_polarity = 0;
-               for (n = 0; n < cmd->chanlist_len; n++) {
-                       chan = CR_CHAN(cmd->chanlist[n]);
-                       range = CR_RANGE(cmd->chanlist[n]);
-                       aref = CR_AREF(cmd->chanlist[n]);
-                       polarity = pci230_ai_bipolar[range];
-                       /* Only the first half of the channels are available if
-                        * differential.  (These are remapped in software.  In
-                        * hardware, only the even channels are available.) */
-                       if ((aref == AREF_DIFF)
-                           && (chan >= (s->n_chan / 2))) {
-                               errors |= diffchan_err;
-                       }
-                       if (n > 0) {
-                               /* Channel numbers must strictly increase or
-                                * subsequence must repeat exactly. */
-                               if ((chan <= prev_chan)
-                                   && (subseq_len == 0)) {
-                                       subseq_len = n;
-                               }
-                               if ((subseq_len > 0)
-                                   && (cmd->chanlist[n] !=
-                                       cmd->chanlist[n % subseq_len])) {
-                                       errors |= seq_err;
-                               }
-                               /* Channels must have same AREF. */
-                               if (aref != prev_aref)
-                                       errors |= aref_err;
-
-                               /* Channel ranges must have same polarity. */
-                               if (polarity != prev_polarity)
-                                       errors |= polarity_err;
-
-                               /* Single-ended channel pairs must have same
-                                * range.  */
-                               if ((aref != AREF_DIFF)
-                                   && (((chan ^ prev_chan) & ~1) == 0)
-                                   && (range != prev_range)) {
-                                       errors |= rangepair_err;
-                               }
-                       }
-                       prev_chan = chan;
-                       prev_range = range;
-                       prev_aref = aref;
-                       prev_polarity = polarity;
-               }
-               if (subseq_len == 0) {
-                       /* Subsequence is whole sequence. */
-                       subseq_len = n;
-               }
-               /* If channel list is a repeating subsequence, need a whole
-                * number of repeats. */
-               if ((n % subseq_len) != 0)
-                       errors |= seq_err;
-
-               if ((devpriv->hwver > 0) && (devpriv->hwver < 4)) {
-                       /*
-                        * Buggy PCI230+ or PCI260+ requires channel 0 to be
-                        * (first) in the sequence if the sequence contains
-                        * more than one channel.  Hardware versions 1 and 2
-                        * have the bug.  There is no hardware version 3.
-                        *
-                        * Actually, there are two firmwares that report
-                        * themselves as hardware version 1 (the boards
-                        * have different ADC chips with slightly different
-                        * timing requirements, which was supposed to be
-                        * invisible to software).  The first one doesn't
-                        * seem to have the bug, but the second one
-                        * does, and we can't tell them apart!
-                        */
-                       if ((subseq_len > 1)
-                           && (CR_CHAN(cmd->chanlist[0]) != 0)) {
-                               errors |= buggy_chan0_err;
-                       }
-               }
-               if (errors != 0) {
-                       err++;
-                       if ((errors & seq_err) != 0) {
-                               dev_dbg(dev->class_dev,
-                                       "%s: channel numbers must increase or sequence must repeat exactly\n",
-                                       __func__);
-                       }
-                       if ((errors & rangepair_err) != 0) {
-                               dev_dbg(dev->class_dev,
-                                       "%s: single-ended channel pairs must have the same range\n",
-                                       __func__);
-                       }
-                       if ((errors & polarity_err) != 0) {
-                               dev_dbg(dev->class_dev,
-                                       "%s: channel sequence ranges must be all bipolar or all unipolar\n",
-                                       __func__);
-                       }
-                       if ((errors & aref_err) != 0) {
-                               dev_dbg(dev->class_dev,
-                                       "%s: channel sequence analogue references must be all the same (single-ended or differential)\n",
-                                       __func__);
-                       }
-                       if ((errors & diffchan_err) != 0) {
-                               dev_dbg(dev->class_dev,
-                                       "%s: differential channel number out of range 0 to %u\n",
-                                       __func__, (s->n_chan / 2) - 1);
-                       }
-                       if ((errors & buggy_chan0_err) != 0) {
-                               dev_info(dev->class_dev,
-                                        "amplc_pci230: ai_cmdtest: Buggy PCI230+/260+ h/w version %u requires first channel of multi-channel sequence to be 0 (corrected in h/w version 4)\n",
-                                        devpriv->hwver);
-                       }
-               }
-       }
+       /* Step 5: check channel list if it exists */
+       if (cmd->chanlist && cmd->chanlist_len > 0)
+               err |= pci230_ai_check_chanlist(dev, s, cmd);
 
        if (err)
                return 5;
@@ -2177,7 +2148,9 @@ static int pci230_ai_inttrig_start(struct comedi_device *dev,
                                   struct comedi_subdevice *s,
                                   unsigned int trig_num)
 {
-       if (trig_num != 0)
+       struct comedi_cmd *cmd = &s->async->cmd;
+
+       if (trig_num != cmd->start_arg)
                return -EINVAL;
 
        s->async->inttrig = NULL;
@@ -2463,12 +2436,10 @@ static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
                }
        }
 
-       if (cmd->start_src == TRIG_INT) {
+       if (cmd->start_src == TRIG_INT)
                s->async->inttrig = pci230_ai_inttrig_start;
-       } else {
-               /* TRIG_NOW */
+       else    /* TRIG_NOW */
                pci230_ai_start(dev, s);
-       }
 
        return 0;
 }
index 83a265f3408c76559cd063e345bcdeec96fd4e89..26fc00e552a857fb9d2c3b34455d9d0e7036a5ff 100644 (file)
@@ -803,6 +803,33 @@ static int trimpot_read_insn(struct comedi_device *dev,
        return 1;
 }
 
+static int cb_pcidas_ai_check_chanlist(struct comedi_device *dev,
+                                      struct comedi_subdevice *s,
+                                      struct comedi_cmd *cmd)
+{
+       unsigned int chan0 = CR_CHAN(cmd->chanlist[0]);
+       unsigned int range0 = CR_RANGE(cmd->chanlist[0]);
+       int i;
+
+       for (i = 1; i < cmd->chanlist_len; i++) {
+               unsigned int chan = CR_CHAN(cmd->chanlist[i]);
+               unsigned int range = CR_RANGE(cmd->chanlist[i]);
+
+               if (chan != (chan0 + i) % s->n_chan) {
+                       dev_dbg(dev->class_dev,
+                               "entries in chanlist must be consecutive channels, counting upwards\n");
+                       return -EINVAL;
+               }
+
+               if (range != range0) {
+                       dev_dbg(dev->class_dev,
+                               "entries in chanlist must all have the same gain\n");
+                       return -EINVAL;
+               }
+       }
+       return 0;
+}
+
 static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
                                struct comedi_subdevice *s,
                                struct comedi_cmd *cmd)
@@ -811,7 +838,6 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
        struct cb_pcidas_private *devpriv = dev->private;
        int err = 0;
        int tmp;
-       int i, gain, start_chan;
 
        /* Step 1 : check if triggers are trivially valid */
 
@@ -846,9 +872,12 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
        if (err)
                return 2;
 
-       /* step 3: arguments are trivially compatible */
+       /* Step 3: check if arguments are trivially valid */
 
        switch (cmd->start_src) {
+       case TRIG_NOW:
+               err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               break;
        case TRIG_EXT:
                /* External trigger, only CR_EDGE and CR_INVERT flags allowed */
                if ((cmd->start_arg
@@ -862,9 +891,6 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
                        err |= -EINVAL;
                }
                break;
-       default:
-               err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-               break;
        }
 
        if (cmd->scan_begin_src == TRIG_TIMER)
@@ -907,24 +933,9 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
        if (err)
                return 4;
 
-       /*  check channel/gain list against card's limitations */
-       if (cmd->chanlist) {
-               gain = CR_RANGE(cmd->chanlist[0]);
-               start_chan = CR_CHAN(cmd->chanlist[0]);
-               for (i = 1; i < cmd->chanlist_len; i++) {
-                       if (CR_CHAN(cmd->chanlist[i]) !=
-                           (start_chan + i) % s->n_chan) {
-                               comedi_error(dev,
-                                            "entries in chanlist must be consecutive channels, counting upwards\n");
-                               err++;
-                       }
-                       if (CR_RANGE(cmd->chanlist[i]) != gain) {
-                               comedi_error(dev,
-                                            "entries in chanlist must all have the same gain\n");
-                               err++;
-                       }
-               }
-       }
+       /* Step 5: check channel list if it exists */
+       if (cmd->chanlist && cmd->chanlist_len > 0)
+               err |= cb_pcidas_ai_check_chanlist(dev, s, cmd);
 
        if (err)
                return 5;
@@ -1035,6 +1046,25 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev,
        return 0;
 }
 
+static int cb_pcidas_ao_check_chanlist(struct comedi_device *dev,
+                                      struct comedi_subdevice *s,
+                                      struct comedi_cmd *cmd)
+{
+       unsigned int chan0 = CR_CHAN(cmd->chanlist[0]);
+
+       if (cmd->chanlist_len > 1) {
+               unsigned int chan1 = CR_CHAN(cmd->chanlist[1]);
+
+               if (chan0 != 0 || chan1 != 1) {
+                       dev_dbg(dev->class_dev,
+                               "channels must be ordered channel 0, channel 1 in chanlist\n");
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
 static int cb_pcidas_ao_cmdtest(struct comedi_device *dev,
                                struct comedi_subdevice *s,
                                struct comedi_cmd *cmd)
@@ -1097,15 +1127,9 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev,
        if (err)
                return 4;
 
-       /*  check channel/gain list against card's limitations */
-       if (cmd->chanlist && cmd->chanlist_len > 1) {
-               if (CR_CHAN(cmd->chanlist[0]) != 0 ||
-                   CR_CHAN(cmd->chanlist[1]) != 1) {
-                       comedi_error(dev,
-                                    "channels must be ordered channel 0, channel 1 in chanlist\n");
-                       err++;
-               }
-       }
+       /* Step 5: check channel list if it exists */
+       if (cmd->chanlist && cmd->chanlist_len > 0)
+               err |= cb_pcidas_ao_check_chanlist(dev, s, cmd);
 
        if (err)
                return 5;
@@ -1145,7 +1169,7 @@ static int cb_pcidas_ao_inttrig(struct comedi_device *dev,
        struct comedi_cmd *cmd = &s->async->cmd;
        unsigned long flags;
 
-       if (trig_num != 0)
+       if (trig_num != cmd->start_arg)
                return -EINVAL;
 
        /*  load up fifo */
index f9afcbe1da545cf653a447004ec13162a8404271..0e13ac9f34736b47a21a0723a77bb0a2025dfd9b 100644 (file)
@@ -1995,14 +1995,52 @@ static void check_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd)
        return;
 }
 
+static int cb_pcidas64_ai_check_chanlist(struct comedi_device *dev,
+                                        struct comedi_subdevice *s,
+                                        struct comedi_cmd *cmd)
+{
+       const struct pcidas64_board *board = comedi_board(dev);
+       unsigned int aref0 = CR_AREF(cmd->chanlist[0]);
+       int i;
+
+       for (i = 1; i < cmd->chanlist_len; i++) {
+               unsigned int aref = CR_AREF(cmd->chanlist[i]);
+
+               if (aref != aref0) {
+                       dev_dbg(dev->class_dev,
+                               "all elements in chanlist must use the same analog reference\n");
+                       return -EINVAL;
+               }
+       }
+
+       if (board->layout == LAYOUT_4020) {
+               unsigned int chan0 = CR_CHAN(cmd->chanlist[0]);
+
+               for (i = 1; i < cmd->chanlist_len; i++) {
+                       unsigned int chan = CR_CHAN(cmd->chanlist[i]);
+
+                       if (chan != (chan0 + i)) {
+                               dev_dbg(dev->class_dev,
+                                       "chanlist must use consecutive channels\n");
+                               return -EINVAL;
+                       }
+               }
+               if (cmd->chanlist_len == 3) {
+                       dev_dbg(dev->class_dev,
+                               "chanlist cannot be 3 channels long, use 1, 2, or 4 channels\n");
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
 static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
                      struct comedi_cmd *cmd)
 {
        const struct pcidas64_board *thisboard = comedi_board(dev);
        int err = 0;
        unsigned int tmp_arg, tmp_arg2;
-       int i;
-       int aref;
        unsigned int triggers;
 
        /* Step 1 : check if triggers are trivially valid */
@@ -2040,15 +2078,24 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
 
        if (cmd->convert_src == TRIG_EXT && cmd->scan_begin_src == TRIG_TIMER)
                err |= -EINVAL;
-       if (cmd->stop_src != TRIG_COUNT &&
-           cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_EXT)
-               err |= -EINVAL;
 
        if (err)
                return 2;
 
        /* Step 3: check if arguments are trivially valid */
 
+       switch (cmd->start_src) {
+       case TRIG_NOW:
+               err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               break;
+       case TRIG_EXT:
+               /*
+                * start_arg is the CR_CHAN | CR_INVERT of the
+                * external trigger.
+                */
+               break;
+       }
+
        if (cmd->convert_src == TRIG_TIMER) {
                if (thisboard->layout == LAYOUT_4020) {
                        err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
@@ -2098,36 +2145,9 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
        if (err)
                return 4;
 
-       /*  make sure user is doesn't change analog reference mid chanlist */
-       if (cmd->chanlist) {
-               aref = CR_AREF(cmd->chanlist[0]);
-               for (i = 1; i < cmd->chanlist_len; i++) {
-                       if (aref != CR_AREF(cmd->chanlist[i])) {
-                               comedi_error(dev,
-                                            "all elements in chanlist must use the same analog reference");
-                               err++;
-                               break;
-                       }
-               }
-               /*  check 4020 chanlist */
-               if (thisboard->layout == LAYOUT_4020) {
-                       unsigned int first_channel = CR_CHAN(cmd->chanlist[0]);
-                       for (i = 1; i < cmd->chanlist_len; i++) {
-                               if (CR_CHAN(cmd->chanlist[i]) !=
-                                   first_channel + i) {
-                                       comedi_error(dev,
-                                                    "chanlist must use consecutive channels");
-                                       err++;
-                                       break;
-                               }
-                       }
-                       if (cmd->chanlist_len == 3) {
-                               comedi_error(dev,
-                                            "chanlist cannot be 3 channels long, use 1, 2, or 4 channels");
-                               err++;
-                       }
-               }
-       }
+       /* Step 5: check channel list if it exists */
+       if (cmd->chanlist && cmd->chanlist_len > 0)
+               err |= cb_pcidas64_ai_check_chanlist(dev, s, cmd);
 
        if (err)
                return 5;
@@ -3204,7 +3224,7 @@ static int ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
        struct comedi_cmd *cmd = &s->async->cmd;
        int retval;
 
-       if (trig_num != 0)
+       if (trig_num != cmd->start_arg)
                return -EINVAL;
 
        retval = prep_ao_dma(dev, cmd);
@@ -3247,13 +3267,32 @@ static int ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        return 0;
 }
 
+static int cb_pcidas64_ao_check_chanlist(struct comedi_device *dev,
+                                        struct comedi_subdevice *s,
+                                        struct comedi_cmd *cmd)
+{
+       unsigned int chan0 = CR_CHAN(cmd->chanlist[0]);
+       int i;
+
+       for (i = 1; i < cmd->chanlist_len; i++) {
+               unsigned int chan = CR_CHAN(cmd->chanlist[i]);
+
+               if (chan != (chan0 + i)) {
+                       dev_dbg(dev->class_dev,
+                               "chanlist must use consecutive channels\n");
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
 static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
                      struct comedi_cmd *cmd)
 {
        const struct pcidas64_board *thisboard = comedi_board(dev);
        int err = 0;
        unsigned int tmp_arg;
-       int i;
 
        /* Step 1 : check if triggers are trivially valid */
 
@@ -3285,6 +3324,8 @@ static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
 
        /* Step 3: check if arguments are trivially valid */
 
+       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+
        if (cmd->scan_begin_src == TRIG_TIMER) {
                err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
                                                 thisboard->ao_scan_speed);
@@ -3315,17 +3356,9 @@ static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
        if (err)
                return 4;
 
-       if (cmd->chanlist) {
-               unsigned int first_channel = CR_CHAN(cmd->chanlist[0]);
-               for (i = 1; i < cmd->chanlist_len; i++) {
-                       if (CR_CHAN(cmd->chanlist[i]) != first_channel + i) {
-                               comedi_error(dev,
-                                            "chanlist must use consecutive channels");
-                               err++;
-                               break;
-                       }
-               }
-       }
+       /* Step 5: check channel list if it exists */
+       if (cmd->chanlist && cmd->chanlist_len > 0)
+               err |= cb_pcidas64_ao_check_chanlist(dev, s, cmd);
 
        if (err)
                return 5;
index 9de81c7712fb9103ae9054f54b37abf4dfa2c0b8..50723b9406305c2a12ffb2c69fd44af37cc03172 100644 (file)
@@ -181,7 +181,7 @@ static int parport_intr_cmdtest(struct comedi_device *dev,
        err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
        err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
        err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, 1);
+       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
        err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
@@ -295,6 +295,7 @@ static int parport_attach(struct comedi_device *dev,
                s->maxdata      = 1;
                s->range_table  = &range_digital;
                s->insn_bits    = parport_intr_insn_bits;
+               s->len_chanlist = 1;
                s->do_cmdtest   = parport_intr_cmdtest;
                s->do_cmd       = parport_intr_cmd;
                s->cancel       = parport_intr_cancel;
index cd9562556d2c8118f9c76a3b18cf1de65d9cee40..ad5014a4074e540f5e3a64b72144ad3f7871cfe9 100644 (file)
@@ -413,11 +413,7 @@ static int waveform_attach(struct comedi_device *dev,
        s->n_chan = N_CHANS;
        s->maxdata = 0xffff;
        s->range_table = &waveform_ai_ranges;
-       s->len_chanlist = s->n_chan * 2;
        s->insn_write = waveform_ao_insn_write;
-       s->do_cmd = NULL;
-       s->do_cmdtest = NULL;
-       s->cancel = NULL;
 
        /* Our default loopback value is just a 0V flatline */
        for (i = 0; i < s->n_chan; i++)
index 6a7d652ff5647650c266bf35bf99c1962fcc78b5..eb774c3ef17f45ed490b786c7a5e84e183b46021 100644 (file)
@@ -600,13 +600,40 @@ static void das16_timer_interrupt(unsigned long arg)
                mod_timer(&devpriv->timer, jiffies + timer_period());
 }
 
+static int das16_ai_check_chanlist(struct comedi_device *dev,
+                                  struct comedi_subdevice *s,
+                                  struct comedi_cmd *cmd)
+{
+       unsigned int chan0 = CR_CHAN(cmd->chanlist[0]);
+       unsigned int range0 = CR_RANGE(cmd->chanlist[0]);
+       int i;
+
+       for (i = 1; i < cmd->chanlist_len; i++) {
+               unsigned int chan = CR_CHAN(cmd->chanlist[i]);
+               unsigned int range = CR_RANGE(cmd->chanlist[i]);
+
+               if (chan != ((chan0 + i) % s->n_chan)) {
+                       dev_dbg(dev->class_dev,
+                               "entries in chanlist must be consecutive channels, counting upwards\n");
+                       return -EINVAL;
+               }
+
+               if (range != range0) {
+                       dev_dbg(dev->class_dev,
+                               "entries in chanlist must all have the same gain\n");
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
 static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
                          struct comedi_cmd *cmd)
 {
        const struct das16_board *board = comedi_board(dev);
        struct das16_private_struct *devpriv = dev->private;
        int err = 0, tmp;
-       int gain, start_chan, i;
        int mask;
 
        /* Step 1 : check if triggers are trivially valid */
@@ -693,24 +720,10 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
        if (err)
                return 4;
 
-       /*  check channel/gain list against card's limitations */
-       if (cmd->chanlist) {
-               gain = CR_RANGE(cmd->chanlist[0]);
-               start_chan = CR_CHAN(cmd->chanlist[0]);
-               for (i = 1; i < cmd->chanlist_len; i++) {
-                       if (CR_CHAN(cmd->chanlist[i]) !=
-                           (start_chan + i) % s->n_chan) {
-                               dev_err(dev->class_dev,
-                                       "entries in chanlist must be consecutive channels, counting upwards\n");
-                               err++;
-                       }
-                       if (CR_RANGE(cmd->chanlist[i]) != gain) {
-                               dev_err(dev->class_dev,
-                                       "entries in chanlist must all have the same gain\n");
-                               err++;
-                       }
-               }
-       }
+       /* Step 5: check channel list if it exists */
+       if (cmd->chanlist && cmd->chanlist_len > 0)
+               err |= das16_ai_check_chanlist(dev, s, cmd);
+
        if (err)
                return 5;
 
index 779225831dc0688e5677ab1ef2f5d8dca05f75ab..a9cd21068ea89df337dbecb2e62c29e8837e4813 100644 (file)
@@ -150,11 +150,39 @@ static void munge_sample_array(unsigned short *array, unsigned int num_elements)
                array[i] = munge_sample(array[i]);
 }
 
+static int das16m1_ai_check_chanlist(struct comedi_device *dev,
+                                    struct comedi_subdevice *s,
+                                    struct comedi_cmd *cmd)
+{
+       int i;
+
+       if (cmd->chanlist_len == 1)
+               return 0;
+
+       if ((cmd->chanlist_len % 2) != 0) {
+               dev_dbg(dev->class_dev,
+                       "chanlist must be of even length or length 1\n");
+               return -EINVAL;
+       }
+
+       for (i = 0; i < cmd->chanlist_len; i++) {
+               unsigned int chan = CR_CHAN(cmd->chanlist[i]);
+
+               if ((i % 2) != (chan % 2)) {
+                       dev_dbg(dev->class_dev,
+                                "even/odd channels must go have even/odd chanlist indices\n");
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
 static int das16m1_cmd_test(struct comedi_device *dev,
                            struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
        struct das16m1_private_struct *devpriv = dev->private;
-       unsigned int err = 0, tmp, i;
+       unsigned int err = 0, tmp;
 
        /* Step 1 : check if triggers are trivially valid */
 
@@ -216,22 +244,9 @@ static int das16m1_cmd_test(struct comedi_device *dev,
        if (err)
                return 4;
 
-       /*  check chanlist against board's peculiarities */
-       if (cmd->chanlist && cmd->chanlist_len > 1) {
-               for (i = 0; i < cmd->chanlist_len; i++) {
-                       /*  even/odd channels must go into even/odd queue addresses */
-                       if ((i % 2) != (CR_CHAN(cmd->chanlist[i]) % 2)) {
-                               comedi_error(dev, "bad chanlist:\n"
-                                            " even/odd channels must go have even/odd chanlist indices");
-                               err++;
-                       }
-               }
-               if ((cmd->chanlist_len % 2) != 0) {
-                       comedi_error(dev,
-                                    "chanlist must be of even length or length 1");
-                       err++;
-               }
-       }
+       /* Step 5: check channel list if it exists */
+       if (cmd->chanlist && cmd->chanlist_len > 0)
+               err |= das16m1_ai_check_chanlist(dev, s, cmd);
 
        if (err)
                return 5;
index 8e975d6b06db175fe3dff11b3caab1f61e828084..d581029146cb3de06d19b24ba12f3cc6ba49568e 100644 (file)
@@ -757,6 +757,26 @@ static unsigned int burst_convert_arg(unsigned int convert_arg, int round_mode)
        return micro_sec * 1000;
 }
 
+static int das1800_ai_check_chanlist(struct comedi_device *dev,
+                                    struct comedi_subdevice *s,
+                                    struct comedi_cmd *cmd)
+{
+       unsigned int unipolar0 = CR_RANGE(cmd->chanlist[0]) & UNIPOLAR;
+       int i;
+
+       for (i = 1; i < cmd->chanlist_len; i++) {
+               unsigned int unipolar = CR_RANGE(cmd->chanlist[i]) & UNIPOLAR;
+
+               if (unipolar != unipolar0) {
+                       dev_dbg(dev->class_dev,
+                               "unipolar and bipolar ranges cannot be mixed in the chanlist\n");
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
 /* test analog input cmd */
 static int das1800_ai_do_cmdtest(struct comedi_device *dev,
                                 struct comedi_subdevice *s,
@@ -766,8 +786,6 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev,
        struct das1800_private *devpriv = dev->private;
        int err = 0;
        unsigned int tmp_arg;
-       int i;
-       int unipolar;
 
        /* Step 1 : check if triggers are trivially valid */
 
@@ -873,18 +891,9 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev,
        if (err)
                return 4;
 
-       /*  make sure user is not trying to mix unipolar and bipolar ranges */
-       if (cmd->chanlist) {
-               unipolar = CR_RANGE(cmd->chanlist[0]) & UNIPOLAR;
-               for (i = 1; i < cmd->chanlist_len; i++) {
-                       if (unipolar != (CR_RANGE(cmd->chanlist[i]) & UNIPOLAR)) {
-                               comedi_error(dev,
-                                            "unipolar and bipolar ranges cannot be mixed in the chanlist");
-                               err++;
-                               break;
-                       }
-               }
-       }
+       /* Step 5: check channel list if it exists */
+       if (cmd->chanlist && cmd->chanlist_len > 0)
+               err |= das1800_ai_check_chanlist(dev, s, cmd);
 
        if (err)
                return 5;
index e0cfb6cb547b9027db5ae7af3cd83601bce79d24..d18eea6c01aa69a0cf10eb90494b6f617321e628 100644 (file)
@@ -125,7 +125,7 @@ struct das6402_boardinfo {
        unsigned int maxdata;
 };
 
-struct das6402_boardinfo das6402_boards[] = {
+static struct das6402_boardinfo das6402_boards[] = {
        {
                .name           = "das6402-12",
                .maxdata        = 0x0fff,
index 3e408370dcf339cf15080662cb9b21fb6562964c..b23a12ce765142f9ab897c4d34f9872dd68d2859 100644 (file)
@@ -300,6 +300,34 @@ static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
        return 0;
 }
 
+static int das800_ai_check_chanlist(struct comedi_device *dev,
+                                   struct comedi_subdevice *s,
+                                   struct comedi_cmd *cmd)
+{
+       unsigned int chan0 = CR_CHAN(cmd->chanlist[0]);
+       unsigned int range0 = CR_RANGE(cmd->chanlist[0]);
+       int i;
+
+       for (i = 1; i < cmd->chanlist_len; i++) {
+               unsigned int chan = CR_CHAN(cmd->chanlist[i]);
+               unsigned int range = CR_RANGE(cmd->chanlist[i]);
+
+               if (chan != (chan0 + i) % s->n_chan) {
+                       dev_dbg(dev->class_dev,
+                               "chanlist must be consecutive, counting upwards\n");
+                       return -EINVAL;
+               }
+
+               if (range != range0) {
+                       dev_dbg(dev->class_dev,
+                               "chanlist must all have the same gain\n");
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
 static int das800_ai_do_cmdtest(struct comedi_device *dev,
                                struct comedi_subdevice *s,
                                struct comedi_cmd *cmd)
@@ -366,27 +394,9 @@ static int das800_ai_do_cmdtest(struct comedi_device *dev,
        if (err)
                return 4;
 
-       /*  check channel/gain list against card's limitations */
-       if (cmd->chanlist) {
-               unsigned int chan = CR_CHAN(cmd->chanlist[0]);
-               unsigned int range = CR_RANGE(cmd->chanlist[0]);
-               unsigned int next;
-               int i;
-
-               for (i = 1; i < cmd->chanlist_len; i++) {
-                       next = cmd->chanlist[i];
-                       if (CR_CHAN(next) != (chan + i) % N_CHAN_AI) {
-                               dev_err(dev->class_dev,
-                                       "chanlist must be consecutive, counting upwards\n");
-                               err++;
-                       }
-                       if (CR_RANGE(next) != range) {
-                               dev_err(dev->class_dev,
-                                       "chanlist must all have the same gain\n");
-                               err++;
-                       }
-               }
-       }
+       /* Step 5: check channel list if it exists */
+       if (cmd->chanlist && cmd->chanlist_len > 0)
+               err |= das800_ai_check_chanlist(dev, s, cmd);
 
        if (err)
                return 5;
index c8a36eb5f01573d07a36fa2852fa12a3c56c1583..68260e6658e425f7ab631b8c447e35a5c4eb6e24 100644 (file)
@@ -243,13 +243,39 @@ static int dmm32at_ns_to_timer(unsigned int *ns, int round)
        return *ns;
 }
 
+static int dmm32at_ai_check_chanlist(struct comedi_device *dev,
+                                    struct comedi_subdevice *s,
+                                    struct comedi_cmd *cmd)
+{
+       unsigned int chan0 = CR_CHAN(cmd->chanlist[0]);
+       unsigned int range0 = CR_RANGE(cmd->chanlist[0]);
+       int i;
+
+       for (i = 1; i < cmd->chanlist_len; i++) {
+               unsigned int chan = CR_CHAN(cmd->chanlist[i]);
+               unsigned int range = CR_RANGE(cmd->chanlist[i]);
+
+               if (chan != (chan0 + i) % s->n_chan) {
+                       dev_dbg(dev->class_dev,
+                               "entries in chanlist must be consecutive channels, counting upwards\n");
+                       return -EINVAL;
+               }
+               if (range != range0) {
+                       dev_dbg(dev->class_dev,
+                               "entries in chanlist must all have the same gain\n");
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
 static int dmm32at_ai_cmdtest(struct comedi_device *dev,
                              struct comedi_subdevice *s,
                              struct comedi_cmd *cmd)
 {
        int err = 0;
        int tmp;
-       int start_chan, gain, i;
 
        /* Step 1 : check if triggers are trivially valid */
 
@@ -349,26 +375,9 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev,
        if (err)
                return 4;
 
-       /* step 5 check the channel list, the channel list for this
-          board must be consecutive and gains must be the same */
-
-       if (cmd->chanlist) {
-               gain = CR_RANGE(cmd->chanlist[0]);
-               start_chan = CR_CHAN(cmd->chanlist[0]);
-               for (i = 1; i < cmd->chanlist_len; i++) {
-                       if (CR_CHAN(cmd->chanlist[i]) !=
-                           (start_chan + i) % s->n_chan) {
-                               comedi_error(dev,
-                                            "entries in chanlist must be consecutive channels, counting upwards\n");
-                               err++;
-                       }
-                       if (CR_RANGE(cmd->chanlist[i]) != gain) {
-                               comedi_error(dev,
-                                            "entries in chanlist must all have the same gain\n");
-                               err++;
-                       }
-               }
-       }
+       /* Step 5: check channel list if it exists */
+       if (cmd->chanlist && cmd->chanlist_len > 0)
+               err |= dmm32at_ai_check_chanlist(dev, s, cmd);
 
        if (err)
                return 5;
index 16cc100531e5dbdb879220c206001c2b8d18cbf7..474f52dac15de990fe59cbe8a5fed3986b9ce68d 100644 (file)
@@ -852,7 +852,7 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev,
        err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
        err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, 5000);
        err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_max(&cmd->scan_end_arg, 2);
+       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT) {
                /* any count is allowed */
@@ -878,12 +878,14 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev,
 }
 
 static int dt282x_ao_inttrig(struct comedi_device *dev,
-                            struct comedi_subdevice *s, unsigned int x)
+                            struct comedi_subdevice *s,
+                            unsigned int trig_num)
 {
        struct dt282x_private *devpriv = dev->private;
+       struct comedi_cmd *cmd = &s->async->cmd;
        int size;
 
-       if (x != 0)
+       if (trig_num != cmd->start_src)
                return -EINVAL;
 
        size = cfc_read_array_from_buffer(s, devpriv->dma[0].buf,
index 08d7655e24e720a91ef1ad6900e593aa0e8a6f3e..22333c1ad88c6f7c2bf526dda6e3ca458d6e4779 100644 (file)
@@ -360,12 +360,30 @@ static int gsc_hpdi_cmd(struct comedi_device *dev,
        return 0;
 }
 
+static int gsc_hpdi_check_chanlist(struct comedi_device *dev,
+                                  struct comedi_subdevice *s,
+                                  struct comedi_cmd *cmd)
+{
+       int i;
+
+       for (i = 0; i < cmd->chanlist_len; i++) {
+               unsigned int chan = CR_CHAN(cmd->chanlist[i]);
+
+               if (chan != i) {
+                       dev_dbg(dev->class_dev,
+                               "chanlist must be ch 0 to 31 in order\n");
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
 static int gsc_hpdi_cmd_test(struct comedi_device *dev,
                             struct comedi_subdevice *s,
                             struct comedi_cmd *cmd)
 {
        int err = 0;
-       int i;
 
        if (s->io_bits)
                return -EINVAL;
@@ -392,6 +410,8 @@ static int gsc_hpdi_cmd_test(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
+       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+
        if (!cmd->chanlist_len || !cmd->chanlist) {
                cmd->chanlist_len = 32;
                err |= -EINVAL;
@@ -411,17 +431,9 @@ static int gsc_hpdi_cmd_test(struct comedi_device *dev,
        if (err)
                return 4;
 
-       /* step 5: complain about special chanlist considerations */
-
-       for (i = 0; i < cmd->chanlist_len; i++) {
-               if (CR_CHAN(cmd->chanlist[i]) != i) {
-                       /*  XXX could support 8 or 16 channels */
-                       dev_err(dev->class_dev,
-                               "chanlist must be ch 0 to 31 in order");
-                       err |= -EINVAL;
-                       break;
-               }
-       }
+       /* Step 5: check channel list if it exists */
+       if (cmd->chanlist && cmd->chanlist_len > 0)
+               err |= gsc_hpdi_check_chanlist(dev, s, cmd);
 
        if (err)
                return 5;
index f02b31b317ec05a822325ee0dbb2349140fab5c2..5fc4850afb7437ef54bf0ada6de0b22d7071f09f 100644 (file)
@@ -598,67 +598,35 @@ static int me4000_ai_cancel(struct comedi_device *dev,
        return 0;
 }
 
-static int ai_check_chanlist(struct comedi_device *dev,
-                            struct comedi_subdevice *s, struct comedi_cmd *cmd)
+static int me4000_ai_check_chanlist(struct comedi_device *dev,
+                                   struct comedi_subdevice *s,
+                                   struct comedi_cmd *cmd)
 {
-       const struct me4000_board *thisboard = comedi_board(dev);
-       int aref;
+       const struct me4000_board *board = comedi_board(dev);
+       unsigned int max_diff_chan = board->ai_diff_nchan;
+       unsigned int aref0 = CR_AREF(cmd->chanlist[0]);
        int i;
 
-       /* Check whether a channel list is available */
-       if (!cmd->chanlist_len) {
-               dev_err(dev->class_dev, "No channel list available\n");
-               return -EINVAL;
-       }
-
-       /* Check the channel list size */
-       if (cmd->chanlist_len > ME4000_AI_CHANNEL_LIST_COUNT) {
-               dev_err(dev->class_dev, "Channel list is to large\n");
-               return -EINVAL;
-       }
-
-       /* Check the pointer */
-       if (!cmd->chanlist) {
-               dev_err(dev->class_dev, "NULL pointer to channel list\n");
-               return -EFAULT;
-       }
-
-       /* Check whether aref is equal for all entries */
-       aref = CR_AREF(cmd->chanlist[0]);
        for (i = 0; i < cmd->chanlist_len; i++) {
-               if (CR_AREF(cmd->chanlist[i]) != aref) {
-                       dev_err(dev->class_dev,
+               unsigned int chan = CR_CHAN(cmd->chanlist[i]);
+               unsigned int range = CR_RANGE(cmd->chanlist[i]);
+               unsigned int aref = CR_AREF(cmd->chanlist[i]);
+
+               if (aref != aref0) {
+                       dev_dbg(dev->class_dev,
                                "Mode is not equal for all entries\n");
                        return -EINVAL;
                }
-       }
 
-       /* Check whether channels are available for this ending */
-       if (aref == SDF_DIFF) {
-               for (i = 0; i < cmd->chanlist_len; i++) {
-                       if (CR_CHAN(cmd->chanlist[i]) >=
-                           thisboard->ai_diff_nchan) {
-                               dev_err(dev->class_dev,
+               if (aref == SDF_DIFF) {
+                       if (chan >= max_diff_chan) {
+                               dev_dbg(dev->class_dev,
                                        "Channel number to high\n");
                                return -EINVAL;
                        }
-               }
-       } else {
-               for (i = 0; i < cmd->chanlist_len; i++) {
-                       if (CR_CHAN(cmd->chanlist[i]) >= thisboard->ai_nchan) {
-                               dev_err(dev->class_dev,
-                                       "Channel number to high\n");
-                               return -EINVAL;
-                       }
-               }
-       }
 
-       /* Check if bipolar is set for all entries when in differential mode */
-       if (aref == SDF_DIFF) {
-               for (i = 0; i < cmd->chanlist_len; i++) {
-                       if (CR_RANGE(cmd->chanlist[i]) != 1 &&
-                           CR_RANGE(cmd->chanlist[i]) != 2) {
-                               dev_err(dev->class_dev,
+                       if (!comedi_range_is_bipolar(s, range)) {
+                               dev_dbg(dev->class_dev,
                                       "Bipolar is not selected in differential mode\n");
                                return -EINVAL;
                        }
@@ -934,22 +902,13 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
                err |= -EINVAL;
        }
 
-       if (cmd->stop_src == TRIG_NONE && cmd->scan_end_src == TRIG_NONE) {
-       } else if (cmd->stop_src == TRIG_COUNT &&
-                  cmd->scan_end_src == TRIG_NONE) {
-       } else if (cmd->stop_src == TRIG_NONE &&
-                  cmd->scan_end_src == TRIG_COUNT) {
-       } else if (cmd->stop_src == TRIG_COUNT &&
-                  cmd->scan_end_src == TRIG_COUNT) {
-       } else {
-               err |= -EINVAL;
-       }
-
        if (err)
                return 2;
 
        /* Step 3: check if arguments are trivially valid */
 
+       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+
        if (cmd->chanlist_len < 1) {
                cmd->chanlist_len = 1;
                err |= -EINVAL;
@@ -1091,10 +1050,11 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
        if (err)
                return 4;
 
-       /*
-        * Stage 5. Check the channel list.
-        */
-       if (ai_check_chanlist(dev, s, cmd))
+       /* Step 5: check channel list if it exists */
+       if (cmd->chanlist && cmd->chanlist_len > 0)
+               err |= me4000_ai_check_chanlist(dev, s, cmd);
+
+       if (err)
                return 5;
 
        return 0;
index 860fc81fb11c62bbaabcd714f1dfb2992d729734..2b2dafe29c05f1b04e4e93f1d2de5219c75af701 100644 (file)
@@ -253,7 +253,7 @@ static int ni6527_intr_cmdtest(struct comedi_device *dev,
        err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
        err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
        err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, 1);
+       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
        err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
@@ -421,6 +421,7 @@ static int ni6527_auto_attach(struct comedi_device *dev,
                s->range_table  = &range_digital;
                s->insn_config  = ni6527_intr_insn_config;
                s->insn_bits    = ni6527_intr_insn_bits;
+               s->len_chanlist = 1;
                s->do_cmdtest   = ni6527_intr_cmdtest;
                s->do_cmd       = ni6527_intr_cmd;
                s->cancel       = ni6527_intr_cancel;
index 6e42001f686e3906ff288a73618b12fff59a6e7a..2051a7c5de109d4222e3646a22a4d28db717c474 100644 (file)
@@ -473,7 +473,7 @@ static int ni_65xx_intr_cmdtest(struct comedi_device *dev,
        err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
        err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
        err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, 1);
+       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
        err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
@@ -671,6 +671,7 @@ static int ni_65xx_auto_attach(struct comedi_device *dev,
        s->n_chan = 1;
        s->range_table = &range_unknown;
        s->maxdata = 1;
+       s->len_chanlist = 1;
        s->do_cmdtest = ni_65xx_intr_cmdtest;
        s->do_cmd = ni_65xx_intr_cmd;
        s->cancel = ni_65xx_intr_cancel;
index 4e39b1f63d818f2c3435a62d955b594715993df9..afbf251ba270676c9df8b5292f42209385282b23 100644 (file)
@@ -287,14 +287,54 @@ static int a2150_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
        return 0;
 }
 
+static int a2150_ai_check_chanlist(struct comedi_device *dev,
+                                  struct comedi_subdevice *s,
+                                  struct comedi_cmd *cmd)
+{
+       unsigned int chan0 = CR_CHAN(cmd->chanlist[0]);
+       unsigned int aref0 = CR_AREF(cmd->chanlist[0]);
+       int i;
+
+       if (cmd->chanlist_len == 2 && (chan0 == 1 || chan0 == 3)) {
+               dev_dbg(dev->class_dev,
+                       "length 2 chanlist must be channels 0,1 or channels 2,3\n");
+               return -EINVAL;
+       }
+
+       if (cmd->chanlist_len == 3) {
+               dev_dbg(dev->class_dev,
+                       "chanlist must have 1,2 or 4 channels\n");
+               return -EINVAL;
+       }
+
+       for (i = 1; i < cmd->chanlist_len; i++) {
+               unsigned int chan = CR_CHAN(cmd->chanlist[i]);
+               unsigned int aref = CR_AREF(cmd->chanlist[i]);
+
+               if (chan != (chan0 + i)) {
+                       dev_dbg(dev->class_dev,
+                               "entries in chanlist must be consecutive channels, counting upwards\n");
+                       return -EINVAL;
+               }
+
+               if (chan == 2)
+                       aref0 = aref;
+               if (aref != aref0) {
+                       dev_dbg(dev->class_dev,
+                               "channels 0/1 and 2/3 must have the same analog reference\n");
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
 static int a2150_ai_cmdtest(struct comedi_device *dev,
                            struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
        const struct a2150_board *thisboard = comedi_board(dev);
        int err = 0;
        int tmp;
-       int startChan;
-       int i;
 
        /* Step 1 : check if triggers are trivially valid */
 
@@ -348,33 +388,9 @@ static int a2150_ai_cmdtest(struct comedi_device *dev,
        if (err)
                return 4;
 
-       /*  check channel/gain list against card's limitations */
-       if (cmd->chanlist) {
-               startChan = CR_CHAN(cmd->chanlist[0]);
-               for (i = 1; i < cmd->chanlist_len; i++) {
-                       if (CR_CHAN(cmd->chanlist[i]) != (startChan + i)) {
-                               comedi_error(dev,
-                                            "entries in chanlist must be consecutive channels, counting upwards\n");
-                               err++;
-                       }
-               }
-               if (cmd->chanlist_len == 2 && CR_CHAN(cmd->chanlist[0]) == 1) {
-                       comedi_error(dev,
-                                    "length 2 chanlist must be channels 0,1 or channels 2,3");
-                       err++;
-               }
-               if (cmd->chanlist_len == 3) {
-                       comedi_error(dev,
-                                    "chanlist must have 1,2 or 4 channels");
-                       err++;
-               }
-               if (CR_AREF(cmd->chanlist[0]) != CR_AREF(cmd->chanlist[1]) ||
-                   CR_AREF(cmd->chanlist[2]) != CR_AREF(cmd->chanlist[3])) {
-                       comedi_error(dev,
-                                    "channels 0/1 and 2/3 must have the same analog reference");
-                       err++;
-               }
-       }
+       /* Step 5: check channel list if it exists */
+       if (cmd->chanlist && cmd->chanlist_len > 0)
+               err |= a2150_ai_check_chanlist(dev, s, cmd);
 
        if (err)
                return 5;
index f4216e825f03a8e63e2c2a0ec743b148337e62f1..fc9d31420956ffdd278eb5a864836efc4cb775ea 100644 (file)
@@ -546,72 +546,60 @@ static enum scan_mode labpc_ai_scan_mode(const struct comedi_cmd *cmd)
        return 0;
 }
 
-static int labpc_ai_chanlist_invalid(const struct comedi_device *dev,
-                                    const struct comedi_cmd *cmd,
-                                    enum scan_mode mode)
+static int labpc_ai_check_chanlist(struct comedi_device *dev,
+                                  struct comedi_subdevice *s,
+                                  struct comedi_cmd *cmd)
 {
-       int channel, range, aref, i;
-
-       if (cmd->chanlist == NULL)
-               return 0;
+       enum scan_mode mode = labpc_ai_scan_mode(cmd);
+       unsigned int chan0 = CR_CHAN(cmd->chanlist[0]);
+       unsigned int range0 = CR_RANGE(cmd->chanlist[0]);
+       unsigned int aref0 = CR_AREF(cmd->chanlist[0]);
+       int i;
 
        if (mode == MODE_SINGLE_CHAN)
                return 0;
 
-       if (mode == MODE_SINGLE_CHAN_INTERVAL) {
-               if (cmd->chanlist_len > 0xff) {
-                       comedi_error(dev,
-                                    "ni_labpc: chanlist too long for single channel interval mode\n");
-                       return 1;
-               }
-       }
-
-       channel = CR_CHAN(cmd->chanlist[0]);
-       range = CR_RANGE(cmd->chanlist[0]);
-       aref = CR_AREF(cmd->chanlist[0]);
-
        for (i = 0; i < cmd->chanlist_len; i++) {
+               unsigned int chan = CR_CHAN(cmd->chanlist[i]);
+               unsigned int range = CR_RANGE(cmd->chanlist[i]);
+               unsigned int aref = CR_AREF(cmd->chanlist[i]);
 
                switch (mode) {
+               case MODE_SINGLE_CHAN:
+                       break;
                case MODE_SINGLE_CHAN_INTERVAL:
-                       if (CR_CHAN(cmd->chanlist[i]) != channel) {
-                               comedi_error(dev,
-                                            "channel scanning order specified in chanlist is not supported by hardware.\n");
-                               return 1;
+                       if (chan != chan0) {
+                               dev_dbg(dev->class_dev,
+                                       "channel scanning order specified in chanlist is not supported by hardware\n");
+                               return -EINVAL;
                        }
                        break;
                case MODE_MULT_CHAN_UP:
-                       if (CR_CHAN(cmd->chanlist[i]) != i) {
-                               comedi_error(dev,
-                                            "channel scanning order specified in chanlist is not supported by hardware.\n");
-                               return 1;
+                       if (chan != i) {
+                               dev_dbg(dev->class_dev,
+                                       "channel scanning order specified in chanlist is not supported by hardware\n");
+                               return -EINVAL;
                        }
                        break;
                case MODE_MULT_CHAN_DOWN:
-                       if (CR_CHAN(cmd->chanlist[i]) !=
-                           cmd->chanlist_len - i - 1) {
-                               comedi_error(dev,
-                                            "channel scanning order specified in chanlist is not supported by hardware.\n");
-                               return 1;
+                       if (chan != (cmd->chanlist_len - i - 1)) {
+                               dev_dbg(dev->class_dev,
+                                       "channel scanning order specified in chanlist is not supported by hardware\n");
+                               return -EINVAL;
                        }
                        break;
-               default:
-                       dev_err(dev->class_dev,
-                               "ni_labpc: bug! in chanlist check\n");
-                       return 1;
-                       break;
                }
 
-               if (CR_RANGE(cmd->chanlist[i]) != range) {
-                       comedi_error(dev,
-                                    "entries in chanlist must all have the same range\n");
-                       return 1;
+               if (range != range0) {
+                       dev_dbg(dev->class_dev,
+                               "entries in chanlist must all have the same range\n");
+                       return -EINVAL;
                }
 
-               if (CR_AREF(cmd->chanlist[i]) != aref) {
-                       comedi_error(dev,
-                                    "entries in chanlist must all have the same reference\n");
-                       return 1;
+               if (aref != aref0) {
+                       dev_dbg(dev->class_dev,
+                               "entries in chanlist must all have the same reference\n");
+                       return -EINVAL;
                }
        }
 
@@ -661,8 +649,14 @@ static int labpc_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       if (cmd->start_arg == TRIG_NOW)
+       switch (cmd->start_src) {
+       case TRIG_NOW:
                err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               break;
+       case TRIG_EXT:
+               /* start_arg value is ignored */
+               break;
+       }
 
        if (!cmd->chanlist_len)
                err |= -EINVAL;
@@ -711,7 +705,11 @@ static int labpc_ai_cmdtest(struct comedi_device *dev,
        if (err)
                return 4;
 
-       if (labpc_ai_chanlist_invalid(dev, cmd, mode))
+       /* Step 5: check channel list if it exists */
+       if (cmd->chanlist && cmd->chanlist_len > 0)
+               err |= labpc_ai_check_chanlist(dev, s, cmd);
+
+       if (err)
                return 5;
 
        return 0;
index 8a0e3b7236ad8d06de8f7e01bc4ac03a9022f92f..087b533625df72af99634af14ac606b4c3e74170 100644 (file)
@@ -2080,7 +2080,7 @@ static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
        const struct ni_board_struct *board = comedi_board(dev);
        struct ni_private *devpriv = dev->private;
        int err = 0;
-       int tmp;
+       unsigned int tmp;
        unsigned int sources;
 
        /* Step 1 : check if triggers are trivially valid */
@@ -2119,17 +2119,19 @@ static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
 
        /* Step 3: check if arguments are trivially valid */
 
-       if (cmd->start_src == TRIG_EXT) {
-               /* external trigger */
-               unsigned int tmp = CR_CHAN(cmd->start_arg);
+       switch (cmd->start_src) {
+       case TRIG_NOW:
+       case TRIG_INT:
+               err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               break;
+       case TRIG_EXT:
+               tmp = CR_CHAN(cmd->start_arg);
 
                if (tmp > 16)
                        tmp = 16;
                tmp |= (cmd->start_arg & (CR_INVERT | CR_EDGE));
                err |= cfc_check_trigger_arg_is(&cmd->start_arg, tmp);
-       } else {
-               /* true for both TRIG_NOW and TRIG_INT */
-               err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               break;
        }
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
@@ -2510,30 +2512,28 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        }
 #endif
 
-       switch (cmd->start_src) {
-       case TRIG_NOW:
+       if (cmd->start_src == TRIG_NOW) {
                /* AI_START1_Pulse */
                devpriv->stc_writew(dev, AI_START1_Pulse | devpriv->ai_cmd2,
                                    AI_Command_2_Register);
                s->async->inttrig = NULL;
-               break;
-       case TRIG_EXT:
+       } else if (cmd->start_src == TRIG_EXT) {
                s->async->inttrig = NULL;
-               break;
-       case TRIG_INT:
-               s->async->inttrig = &ni_ai_inttrig;
-               break;
+       } else {        /* TRIG_INT */
+               s->async->inttrig = ni_ai_inttrig;
        }
 
        return 0;
 }
 
-static int ni_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
-                        unsigned int trignum)
+static int ni_ai_inttrig(struct comedi_device *dev,
+                        struct comedi_subdevice *s,
+                        unsigned int trig_num)
 {
        struct ni_private *devpriv = dev->private;
+       struct comedi_cmd *cmd = &s->async->cmd;
 
-       if (trignum != 0)
+       if (trig_num != cmd->start_arg)
                return -EINVAL;
 
        devpriv->stc_writew(dev, AI_START1_Pulse | devpriv->ai_cmd2,
@@ -2946,17 +2946,19 @@ static int ni_ao_insn_config(struct comedi_device *dev,
        return -EINVAL;
 }
 
-static int ni_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
-                        unsigned int trignum)
+static int ni_ao_inttrig(struct comedi_device *dev,
+                        struct comedi_subdevice *s,
+                        unsigned int trig_num)
 {
        const struct ni_board_struct *board __maybe_unused = comedi_board(dev);
        struct ni_private *devpriv = dev->private;
+       struct comedi_cmd *cmd = &s->async->cmd;
        int ret;
        int interrupt_b_bits;
        int i;
        static const int timeout = 1000;
 
-       if (trignum != 0)
+       if (trig_num != cmd->start_arg)
                return -EINVAL;
 
        /* Null trig at beginning prevent ao start trigger from executing more than
@@ -3217,7 +3219,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
                            AO_BC_TC_Interrupt_Enable, 1);
        }
 
-       s->async->inttrig = &ni_ao_inttrig;
+       s->async->inttrig = ni_ao_inttrig;
 
        return 0;
 }
@@ -3228,7 +3230,7 @@ static int ni_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
        const struct ni_board_struct *board = comedi_board(dev);
        struct ni_private *devpriv = dev->private;
        int err = 0;
-       int tmp;
+       unsigned int tmp;
 
        /* Step 1 : check if triggers are trivially valid */
 
@@ -3258,17 +3260,18 @@ static int ni_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
 
        /* Step 3: check if arguments are trivially valid */
 
-       if (cmd->start_src == TRIG_EXT) {
-               /* external trigger */
-               unsigned int tmp = CR_CHAN(cmd->start_arg);
+       switch (cmd->start_src) {
+       case TRIG_INT:
+               err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               break;
+       case TRIG_EXT:
+               tmp = CR_CHAN(cmd->start_arg);
 
                if (tmp > 18)
                        tmp = 18;
                tmp |= (cmd->start_arg & (CR_INVERT | CR_EDGE));
                err |= cfc_check_trigger_arg_is(&cmd->start_arg, tmp);
-       } else {
-               /* true for both TRIG_NOW and TRIG_INT */
-               err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               break;
        }
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
@@ -3304,11 +3307,6 @@ static int ni_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
        if (err)
                return 4;
 
-       /* step 5: fix up chanlist */
-
-       if (err)
-               return 5;
-
        return 0;
 }
 
@@ -3439,12 +3437,27 @@ static int ni_m_series_dio_insn_bits(struct comedi_device *dev,
        return insn->n;
 }
 
+static int ni_cdio_check_chanlist(struct comedi_device *dev,
+                                 struct comedi_subdevice *s,
+                                 struct comedi_cmd *cmd)
+{
+       int i;
+
+       for (i = 0; i < cmd->chanlist_len; ++i) {
+               unsigned int chan = CR_CHAN(cmd->chanlist[i]);
+
+               if (chan != i)
+                       return -EINVAL;
+       }
+
+       return 0;
+}
+
 static int ni_cdio_cmdtest(struct comedi_device *dev,
                           struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
        int err = 0;
        int tmp;
-       unsigned i;
 
        /* Step 1 : check if triggers are trivially valid */
 
@@ -3484,12 +3497,9 @@ static int ni_cdio_cmdtest(struct comedi_device *dev,
        if (err)
                return 4;
 
-       /* step 5: check chanlist */
-
-       for (i = 0; i < cmd->chanlist_len; ++i) {
-               if (cmd->chanlist[i] != i)
-                       err = 1;
-       }
+       /* Step 5: check channel list if it exists */
+       if (cmd->chanlist && cmd->chanlist_len > 0)
+               err |= ni_cdio_check_chanlist(dev, s, cmd);
 
        if (err)
                return 5;
@@ -3530,21 +3540,28 @@ static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        retval = ni_request_cdo_mite_channel(dev);
        if (retval < 0)
                return retval;
-       s->async->inttrig = &ni_cdo_inttrig;
+
+       s->async->inttrig = ni_cdo_inttrig;
+
        return 0;
 }
 
-static int ni_cdo_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
-                         unsigned int trignum)
+static int ni_cdo_inttrig(struct comedi_device *dev,
+                         struct comedi_subdevice *s,
+                         unsigned int trig_num)
 {
 #ifdef PCIDMA
        struct ni_private *devpriv = dev->private;
        unsigned long flags;
 #endif
+       struct comedi_cmd *cmd = &s->async->cmd;
        int retval = 0;
        unsigned i;
        const unsigned timeout = 1000;
 
+       if (trig_num != cmd->start_arg)
+               return -EINVAL;
+
        s->async->inttrig = NULL;
 
        /* read alloc the entire buffer */
index 85ac2d964f5c07a4fe0e8f427d242725e6e9870f..962c2353a79ff11aede8c47ed941de797f7a5556 100644 (file)
@@ -773,11 +773,13 @@ static int setup_mite_dma(struct comedi_device *dev, struct comedi_subdevice *s)
 }
 
 static int ni_pcidio_inttrig(struct comedi_device *dev,
-                            struct comedi_subdevice *s, unsigned int trignum)
+                            struct comedi_subdevice *s,
+                            unsigned int trig_num)
 {
        struct nidio96_private *devpriv = dev->private;
+       struct comedi_cmd *cmd = &s->async->cmd;
 
-       if (trignum != 0)
+       if (trig_num != cmd->start_arg)
                return -EINVAL;
 
        writeb(devpriv->OpModeBits, devpriv->mite->daq_io_addr + OpMode);
index 7d64f8892f0819efb4b27148f5b66360dd4a1b6a..b9d23db4004bf74d90bce77032fe87acb199db7c 100644 (file)
@@ -89,14 +89,16 @@ static void ni_tio_configure_dma(struct ni_gpct *counter, short enable,
 
 static int ni_tio_input_inttrig(struct comedi_device *dev,
                                struct comedi_subdevice *s,
-                               unsigned int trignum)
+                               unsigned int trig_num)
 {
+       struct ni_gpct *counter = s->private;
+       struct comedi_cmd *cmd = &s->async->cmd;
        unsigned long flags;
        int retval = 0;
-       struct ni_gpct *counter = s->private;
 
        BUG_ON(counter == NULL);
-       if (trignum != 0)
+
+       if (trig_num != cmd->start_src)
                return -EINVAL;
 
        spin_lock_irqsave(&counter->lock, flags);
@@ -271,8 +273,16 @@ int ni_tio_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       if (cmd->start_src != TRIG_EXT)
+       switch (cmd->start_src) {
+       case TRIG_NOW:
+       case TRIG_INT:
+       case TRIG_OTHER:
                err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               break;
+       case TRIG_EXT:
+               /* start_arg is the start_trigger passed to ni_tio_arm() */
+               break;
+       }
 
        if (cmd->scan_begin_src != TRIG_EXT)
                err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
index cf9568ee46e46f2bcb064c5339baebb3c007aa8e..07ff1e22e61ca67e8bbb7768924c2dcbc19b81ae 100644 (file)
@@ -197,7 +197,7 @@ static int pcl726_intr_cmdtest(struct comedi_device *dev,
        err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
        err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
        err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, 1);
+       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
        err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
@@ -430,6 +430,7 @@ static int pcl726_attach(struct comedi_device *dev,
                s->maxdata      = 1;
                s->range_table  = &range_digital;
                s->insn_bits    = pcl726_intr_insn_bits;
+               s->len_chanlist = 1;
                s->do_cmdtest   = pcl726_intr_cmdtest;
                s->do_cmd       = pcl726_intr_cmd;
                s->cancel       = pcl726_intr_cancel;
index 160eac8083db16fb6a5b6f8bb5eaeacfa7686a12..0cf115e54308b3670ebf708174f535cecb1064da 100644 (file)
@@ -761,7 +761,6 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev,
                err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
 
        err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1);
-       err |= cfc_check_trigger_arg_max(&cmd->chanlist_len, MAX_CHANLIST_LEN);
        err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
@@ -811,8 +810,9 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
                                devpriv->ai_dma = 0;
                                break;
                        }
-       } else
+       } else {
                devpriv->ai_dma = 0;
+       }
 
        devpriv->ai_act_scan = 0;
        devpriv->ai_poll_ptr = 0;
index e89bca8453491e9e05f6fd7e8d762f3280024c31..bb29ecfcfef4badb94d4f0ca8cc93da1d33d5ec9 100644 (file)
@@ -464,18 +464,16 @@ static int pcmmio_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
        return 0;
 }
 
-/*
- * Internal trigger function to start acquisition for an 'INTERRUPT' subdevice.
- */
-static int
-pcmmio_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s,
-                         unsigned int trignum)
+static int pcmmio_inttrig_start_intr(struct comedi_device *dev,
+                                    struct comedi_subdevice *s,
+                                    unsigned int trig_num)
 {
        struct pcmmio_private *devpriv = dev->private;
+       struct comedi_cmd *cmd = &s->async->cmd;
        unsigned long flags;
        int event = 0;
 
-       if (trignum != 0)
+       if (trig_num != cmd->start_arg)
                return -EINVAL;
 
        spin_lock_irqsave(&devpriv->spinlock, flags);
@@ -517,15 +515,11 @@ static int pcmmio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        }
 
        /* Set up start of acquisition. */
-       switch (cmd->start_src) {
-       case TRIG_INT:
+       if (cmd->start_src == TRIG_INT)
                s->async->inttrig = pcmmio_inttrig_start_intr;
-               break;
-       default:
-               /* TRIG_NOW */
+       else    /* TRIG_NOW */
                event = pcmmio_start_intr(dev, s);
-               break;
-       }
+
        spin_unlock_irqrestore(&devpriv->spinlock, flags);
 
        if (event)
index a8f390f7a87418a4de01d4efd6759ad828fa553a..ea45424e841078191a1a1100279b342d5b243b58 100644 (file)
@@ -460,20 +460,18 @@ static int pcmuio_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
        return 0;
 }
 
-/*
- * Internal trigger function to start acquisition for an 'INTERRUPT' subdevice.
- */
-static int
-pcmuio_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s,
-                         unsigned int trignum)
+static int pcmuio_inttrig_start_intr(struct comedi_device *dev,
+                                    struct comedi_subdevice *s,
+                                    unsigned int trig_num)
 {
        struct pcmuio_private *devpriv = dev->private;
+       struct comedi_cmd *cmd = &s->async->cmd;
        int asic = pcmuio_subdevice_to_asic(s);
        struct pcmuio_asic *chip = &devpriv->asics[asic];
        unsigned long flags;
        int event = 0;
 
-       if (trignum != 0)
+       if (trig_num != cmd->start_arg)
                return -EINVAL;
 
        spin_lock_irqsave(&chip->spinlock, flags);
@@ -518,15 +516,11 @@ static int pcmuio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        }
 
        /* Set up start of acquisition. */
-       switch (cmd->start_src) {
-       case TRIG_INT:
+       if (cmd->start_src == TRIG_INT)
                s->async->inttrig = pcmuio_inttrig_start_intr;
-               break;
-       default:
-               /* TRIG_NOW */
+       else    /* TRIG_NOW */
                event = pcmuio_start_intr(dev, s);
-               break;
-       }
+
        spin_unlock_irqrestore(&chip->spinlock, flags);
 
        if (event)
index cd3fdf973bdd6b8d5856127e95736aea5e920773..e7c2e34624d905a2111f40a7f84965a446c09377 100644 (file)
@@ -878,6 +878,8 @@ static int rtd_ai_cmdtest(struct comedi_device *dev,
                err |= cfc_check_trigger_arg_max(&cmd->convert_arg, 9);
        }
 
+       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+
        if (cmd->stop_src == TRIG_COUNT) {
                /* TODO check for rounding error due to counter wrap */
        } else {
@@ -891,10 +893,6 @@ static int rtd_ai_cmdtest(struct comedi_device *dev,
 
        /* step 4: fix up any arguments */
 
-       if (cmd->chanlist_len > RTD_MAX_CHANLIST) {
-               cmd->chanlist_len = RTD_MAX_CHANLIST;
-               err++;
-       }
        if (cmd->scan_begin_src == TRIG_TIMER) {
                tmp = cmd->scan_begin_arg;
                rtd_ns_to_timer(&cmd->scan_begin_arg,
index 95fadf343f27333fa38abe65ed6361c5b9c6c901..647b9e50bd74d69469b1ceae097ff88929295182 100644 (file)
@@ -295,10 +295,24 @@ static void s626_debi_replace(struct comedi_device *dev, unsigned int addr,
 
 /* **************  EEPROM ACCESS FUNCTIONS  ************** */
 
-static uint32_t s626_i2c_handshake(struct comedi_device *dev, uint32_t val)
+static int s626_i2c_handshake_eoc(struct comedi_device *dev,
+                                struct comedi_subdevice *s,
+                                struct comedi_insn *insn,
+                                unsigned long context)
+{
+       bool status;
+
+       status = s626_mc_test(dev, S626_MC2_UPLD_IIC, S626_P_MC2);
+       if (status)
+               return 0;
+       return -EBUSY;
+}
+
+static int s626_i2c_handshake(struct comedi_device *dev, uint32_t val)
 {
        struct s626_private *devpriv = dev->private;
        unsigned int ctrl;
+       int ret;
 
        /* Write I2C command to I2C Transfer Control shadow register */
        writel(val, devpriv->mmio + S626_P_I2CCTRL);
@@ -308,8 +322,9 @@ static uint32_t s626_i2c_handshake(struct comedi_device *dev, uint32_t val)
         * wait for upload confirmation.
         */
        s626_mc_enable(dev, S626_MC2_UPLD_IIC, S626_P_MC2);
-       while (!s626_mc_test(dev, S626_MC2_UPLD_IIC, S626_P_MC2))
-               ;
+       ret = comedi_timeout(dev, NULL, NULL, s626_i2c_handshake_eoc, 0);
+       if (ret)
+               return ret;
 
        /* Wait until I2C bus transfer is finished or an error occurs */
        do {
@@ -2029,8 +2044,9 @@ static int s626_ai_insn_read(struct comedi_device *dev,
        /* Wait for the data to arrive in FB BUFFER 1 register. */
 
        /* Wait for ADC done */
-       while (!(readl(devpriv->mmio + S626_P_PSR) & S626_PSR_GPIO2))
-               ;
+       ret = comedi_timeout(dev, s, insn, s626_ai_eoc, 0);
+       if (ret)
+               return ret;
 
        /* Fetch ADC data from audio interface's input shift register. */
 
@@ -2060,9 +2076,12 @@ static int s626_ai_load_polllist(uint8_t *ppl, struct comedi_cmd *cmd)
 }
 
 static int s626_ai_inttrig(struct comedi_device *dev,
-                          struct comedi_subdevice *s, unsigned int trignum)
+                          struct comedi_subdevice *s,
+                          unsigned int trig_num)
 {
-       if (trignum != 0)
+       struct comedi_cmd *cmd = &s->async->cmd;
+
+       if (trig_num != cmd->start_arg)
                return -EINVAL;
 
        /* Start executing the RPS program */
@@ -2298,12 +2317,18 @@ static int s626_ai_cmdtest(struct comedi_device *dev,
        if (err)
                return 2;
 
-       /* step 3: make sure arguments are trivially compatible */
+       /* Step 3: check if arguments are trivially valid */
 
-       if (cmd->start_src != TRIG_EXT)
+       switch (cmd->start_src) {
+       case TRIG_NOW:
+       case TRIG_INT:
                err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       if (cmd->start_src == TRIG_EXT)
+               break;
+       case TRIG_EXT:
                err |= cfc_check_trigger_arg_max(&cmd->start_arg, 39);
+               break;
+       }
+
        if (cmd->scan_begin_src == TRIG_EXT)
                err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg, 39);
        if (cmd->convert_src == TRIG_EXT)
@@ -2681,8 +2706,9 @@ static int s626_initialize(struct comedi_device *dev)
        writel(S626_I2C_CLKSEL | S626_I2C_ABORT,
               devpriv->mmio + S626_P_I2CSTAT);
        s626_mc_enable(dev, S626_MC2_UPLD_IIC, S626_P_MC2);
-       while (!(readl(devpriv->mmio + S626_P_MC2) & S626_MC2_UPLD_IIC))
-               ;
+       ret = comedi_timeout(dev, NULL, NULL, s626_i2c_handshake_eoc, 0);
+       if (ret)
+               return ret;
 
        /*
         * Per SAA7146 data sheet, write to STATUS
@@ -2691,8 +2717,9 @@ static int s626_initialize(struct comedi_device *dev)
        for (i = 0; i < 2; i++) {
                writel(S626_I2C_CLKSEL, devpriv->mmio + S626_P_I2CSTAT);
                s626_mc_enable(dev, S626_MC2_UPLD_IIC, S626_P_MC2);
-               while (!s626_mc_test(dev, S626_MC2_UPLD_IIC, S626_P_MC2))
-                       ;
+               ret = comedi_timeout(dev, NULL, NULL, s626_i2c_handshake_eoc, 0);
+               if (ret)
+                       return ret;
        }
 
        /*
index b59af030358190a9539b16c7fd8d8b20fb16c30a..4002f49f0082add9288950b5fed1a2f781aec82d 100644 (file)
@@ -692,15 +692,16 @@ static int receive_dux_commands(struct comedi_device *dev, unsigned int command)
 
 static int usbdux_ai_inttrig(struct comedi_device *dev,
                             struct comedi_subdevice *s,
-                            unsigned int trignum)
+                            unsigned int trig_num)
 {
        struct usbdux_private *devpriv = dev->private;
-       int ret = -EINVAL;
+       struct comedi_cmd *cmd = &s->async->cmd;
+       int ret;
 
-       down(&devpriv->sem);
+       if (trig_num != cmd->start_arg)
+               return -EINVAL;
 
-       if (trignum != 0)
-               goto ai_trig_exit;
+       down(&devpriv->sem);
 
        if (!devpriv->ai_cmd_running) {
                devpriv->ai_cmd_running = 1;
@@ -913,15 +914,16 @@ ao_write_exit:
 
 static int usbdux_ao_inttrig(struct comedi_device *dev,
                             struct comedi_subdevice *s,
-                            unsigned int trignum)
+                            unsigned int trig_num)
 {
        struct usbdux_private *devpriv = dev->private;
-       int ret = -EINVAL;
+       struct comedi_cmd *cmd = &s->async->cmd;
+       int ret;
 
-       down(&devpriv->sem);
+       if (trig_num != cmd->start_arg)
+               return -EINVAL;
 
-       if (trignum != 0)
-               goto ao_trig_exit;
+       down(&devpriv->sem);
 
        if (!devpriv->ao_cmd_running) {
                devpriv->ao_cmd_running = 1;
index d6fae11ee4e05eb3fe7908d6b3f99175141d3b6c..a4d7bfbcc6b9f1574cbc9eb4b1e17e843541288d 100644 (file)
@@ -398,8 +398,7 @@ static int usbduxfast_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       if (cmd->start_src == TRIG_NOW)
-               err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
 
        if (!cmd->chanlist_len)
                err |= -EINVAL;
@@ -451,21 +450,20 @@ static int usbduxfast_ai_cmdtest(struct comedi_device *dev,
 
 static int usbduxfast_ai_inttrig(struct comedi_device *dev,
                                 struct comedi_subdevice *s,
-                                unsigned int trignum)
+                                unsigned int trig_num)
 {
        struct usbduxfast_private *devpriv = dev->private;
+       struct comedi_cmd *cmd = &s->async->cmd;
        int ret;
 
        if (!devpriv)
                return -EFAULT;
 
+       if (trig_num != cmd->start_arg)
+               return -EINVAL;
+
        down(&devpriv->sem);
 
-       if (trignum != 0) {
-               dev_err(dev->class_dev, "invalid trignum\n");
-               up(&devpriv->sem);
-               return -EINVAL;
-       }
        if (!devpriv->ai_cmd_running) {
                devpriv->ai_cmd_running = 1;
                ret = usbduxfast_submit_urb(dev);
@@ -837,12 +835,7 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev,
                        return ret;
                }
                s->async->inttrig = NULL;
-       } else {
-               /*
-                * TRIG_INT
-                * don't enable the acquision operation
-                * wait for an internal signal
-                */
+       } else {        /* TRIG_INT */
                s->async->inttrig = usbduxfast_ai_inttrig;
        }
        up(&devpriv->sem);
index 88c60b6020c48b971682f2d31700dd549ecdd1af..b57c974e5cb673e454b510169ffddd3a194e429f 100644 (file)
@@ -663,12 +663,13 @@ static int usbduxsigma_receive_cmd(struct comedi_device *dev, int command)
 
 static int usbduxsigma_ai_inttrig(struct comedi_device *dev,
                                  struct comedi_subdevice *s,
-                                 unsigned int trignum)
+                                 unsigned int trig_num)
 {
        struct usbduxsigma_private *devpriv = dev->private;
+       struct comedi_cmd *cmd = &s->async->cmd;
        int ret;
 
-       if (trignum != 0)
+       if (trig_num != cmd->start_arg)
                return -EINVAL;
 
        down(&devpriv->sem);
@@ -738,7 +739,6 @@ static int usbduxsigma_ai_cmd(struct comedi_device *dev,
                }
                s->async->inttrig = NULL;
        } else {        /* TRIG_INT */
-               /* wait for an internal signal and submit the urbs later */
                s->async->inttrig = usbduxsigma_ai_inttrig;
        }
 
@@ -856,12 +856,13 @@ static int usbduxsigma_ao_insn_write(struct comedi_device *dev,
 
 static int usbduxsigma_ao_inttrig(struct comedi_device *dev,
                                  struct comedi_subdevice *s,
-                                 unsigned int trignum)
+                                 unsigned int trig_num)
 {
        struct usbduxsigma_private *devpriv = dev->private;
+       struct comedi_cmd *cmd = &s->async->cmd;
        int ret;
 
-       if (trignum != 0)
+       if (trig_num != cmd->start_arg)
                return -EINVAL;
 
        down(&devpriv->sem);
@@ -1027,7 +1028,6 @@ static int usbduxsigma_ao_cmd(struct comedi_device *dev,
                }
                s->async->inttrig = NULL;
        } else {        /* TRIG_INT */
-               /* wait for an internal signal and submit the urbs later */
                s->async->inttrig = usbduxsigma_ao_inttrig;
        }
 
index 20be9571990a30410816f8847e48ea59e273ae2e..e6fb331c6735492e1a1fcf26012c2f429c6833b7 100644 (file)
@@ -28,7 +28,7 @@ static struct crystalhd_adp *g_adp_info;
 
 static irqreturn_t chd_dec_isr(int irq, void *arg)
 {
-       struct crystalhd_adp *adp = (struct crystalhd_adp *) arg;
+       struct crystalhd_adp *adp = arg;
        int rc = 0;
        if (adp)
                rc = crystalhd_cmd_interrupt(&adp->cmds);
@@ -112,7 +112,7 @@ static void chd_dec_free_iodata(struct crystalhd_adp *adp,
 }
 
 static inline int crystalhd_user_data(void __user *ud, void *dr,
-                        int size, int set)
+                                     int size, int set)
 {
        int rc;
 
@@ -135,7 +135,8 @@ static inline int crystalhd_user_data(void __user *ud, void *dr,
 }
 
 static int chd_dec_fetch_cdata(struct crystalhd_adp *adp,
-        struct crystalhd_ioctl_data *io, uint32_t m_sz, unsigned long ua)
+                              struct crystalhd_ioctl_data *io, uint32_t m_sz,
+                              unsigned long ua)
 {
        unsigned long ua_off;
        int rc = 0;
@@ -154,7 +155,7 @@ static int chd_dec_fetch_cdata(struct crystalhd_adp *adp,
        io->add_cdata_sz = m_sz;
        ua_off = ua + sizeof(io->udata);
        rc = crystalhd_user_data((void __user *)ua_off, io->add_cdata,
-                       io->add_cdata_sz, 0);
+                                io->add_cdata_sz, 0);
        if (rc) {
                BCMLOG_ERR("failed to pull add_cdata sz:%x ua_off:%x\n",
                           io->add_cdata_sz, (unsigned int)ua_off);
@@ -167,7 +168,8 @@ static int chd_dec_fetch_cdata(struct crystalhd_adp *adp,
 }
 
 static int chd_dec_release_cdata(struct crystalhd_adp *adp,
-                        struct crystalhd_ioctl_data *io, unsigned long ua)
+                                struct crystalhd_ioctl_data *io,
+                                unsigned long ua)
 {
        unsigned long ua_off;
        int rc;
@@ -180,7 +182,7 @@ static int chd_dec_release_cdata(struct crystalhd_adp *adp,
        if (io->cmd != BCM_IOC_FW_DOWNLOAD) {
                ua_off = ua + sizeof(io->udata);
                rc = crystalhd_user_data((void __user *)ua_off, io->add_cdata,
-                                       io->add_cdata_sz, 1);
+                                        io->add_cdata_sz, 1);
                if (rc) {
                        BCMLOG_ERR(
                                "failed to push add_cdata sz:%x ua_off:%x\n",
@@ -210,7 +212,7 @@ static int chd_dec_proc_user_data(struct crystalhd_adp *adp,
        }
 
        rc = crystalhd_user_data((void __user *)ua, &io->udata,
-                       sizeof(io->udata), set);
+                                sizeof(io->udata), set);
        if (rc) {
                BCMLOG_ERR("failed to %s iodata\n", (set ? "set" : "get"));
                return rc;
@@ -382,7 +384,7 @@ static int chd_dec_init_chdev(struct crystalhd_adp *adp)
        }
 
        dev = device_create(crystalhd_class, NULL,
-                        MKDEV(adp->chd_dec_major, 0), NULL, "crystalhd");
+                           MKDEV(adp->chd_dec_major, 0), NULL, "crystalhd");
        if (IS_ERR(dev)) {
                rc = PTR_ERR(dev);
                BCMLOG_ERR("failed to create device\n");
@@ -397,8 +399,7 @@ static int chd_dec_init_chdev(struct crystalhd_adp *adp)
 
        /* Allocate general purpose ioctl pool. */
        for (i = 0; i < CHD_IODATA_POOL_SZ; i++) {
-               temp = kzalloc(sizeof(struct crystalhd_ioctl_data),
-                                        GFP_KERNEL);
+               temp = kzalloc(sizeof(*temp), GFP_KERNEL);
                if (!temp) {
                        BCMLOG_ERR("ioctl data pool kzalloc failed\n");
                        rc = -ENOMEM;
@@ -549,11 +550,11 @@ static int chd_dec_pci_probe(struct pci_dev *pdev,
        enum BC_STATUS sts = BC_STS_SUCCESS;
 
        BCMLOG(BCMLOG_DBG,
-               "PCI_INFO: Vendor:0x%04x Device:0x%04x s_vendor:0x%04x s_device: 0x%04x\n",
-               pdev->vendor, pdev->device, pdev->subsystem_vendor,
-               pdev->subsystem_device);
+              "PCI_INFO: Vendor:0x%04x Device:0x%04x s_vendor:0x%04x s_device: 0x%04x\n",
+              pdev->vendor, pdev->device, pdev->subsystem_vendor,
+              pdev->subsystem_device);
 
-       pinfo = kzalloc(sizeof(struct crystalhd_adp), GFP_KERNEL);
+       pinfo = kzalloc(sizeof(*pinfo), GFP_KERNEL);
        if (!pinfo) {
                BCMLOG_ERR("Failed to allocate memory\n");
                return -ENOMEM;
index 9b4198b1e634e01982b3b3b8720aa9267a9aef2a..4fa27c8931b1ae41ed75830baebba680bd7286dc 100644 (file)
@@ -159,8 +159,8 @@ prep_hdw_info(void)
                hi->ndev = NULL;
                hi->addr[0] = 0L;
                hi->addr[1] = 0L;
-               hi->addr_mapped[0] = 0L;
-               hi->addr_mapped[1] = 0L;
+               hi->addr_mapped[0] = NULL;
+               hi->addr_mapped[1] = NULL;
        }
 }
 
@@ -174,14 +174,14 @@ cleanup_ioremap(void)
                if (hi->pci_slot == 0xff)
                        break;
                if (hi->addr_mapped[0]) {
-                       iounmap((void *)(hi->addr_mapped[0]));
+                       iounmap(hi->addr_mapped[0]);
                        release_mem_region((long) hi->addr[0], hi->len[0]);
-                       hi->addr_mapped[0] = 0;
+                       hi->addr_mapped[0] = NULL;
                }
                if (hi->addr_mapped[1]) {
-                       iounmap((void *)(hi->addr_mapped[1]));
+                       iounmap(hi->addr_mapped[1]);
                        release_mem_region((long) hi->addr[1], hi->len[1]);
-                       hi->addr_mapped[1] = 0;
+                       hi->addr_mapped[1] = NULL;
                }
        }
 }
@@ -205,7 +205,7 @@ cleanup_devs(void)
 #ifdef CONFIG_SBE_PMCC4_NCOMM
                free_irq(hi->pdev[1]->irq, hi->ndev);
 #endif
-               OS_kfree(hi->ndev);
+               kfree(hi->ndev);
        }
 }
 
@@ -329,7 +329,7 @@ c4hw_attach_all(void)
                                return -ENOMEM;
                        }
 
-                       hi->addr_mapped[j] = (unsigned long)ioremap(hi->addr[j], hi->len[j]);
+                       hi->addr_mapped[j] = ioremap(hi->addr[j], hi->len[j]);
                        if (!hi->addr_mapped[j]) {
                                pr_warning("%s: ioremap fails, addr=0x%lx, len=0x%lx ?\n",
                                           hi->devname, hi->addr[j], hi->len[j]);
index b02f5ade6661b0840c5a6918cf45da58a292f89d..4b4609db9f89c2ce9cf02ad6e0b1649af13c01bf 100644 (file)
@@ -60,7 +60,6 @@ status_t    c4_chan_work_init(mpi_t *, mch_t *);
 void        musycc_wq_chan_restart(void *);
 status_t __init c4_init(ci_t *, u_char *, u_char *);
 status_t __init c4_init2(ci_t *);
-ci_t       *__init c4_new(void *);
 int __init  c4hw_attach_all(void);
 void __init hdw_sn_get(hdw_info_t *, int);
 
@@ -418,7 +417,7 @@ create_chan(struct net_device *ndev, ci_t *ci,
                struct c4_priv *priv;
 
                /* allocate then fill in private data structure */
-               priv = OS_kmalloc(sizeof(struct c4_priv));
+               priv = kzalloc(sizeof(struct c4_priv), GFP_KERNEL);
                if (!priv) {
                        pr_warning("%s: no memory for net_device !\n",
                                   ci->devname);
@@ -428,7 +427,7 @@ create_chan(struct net_device *ndev, ci_t *ci,
                if (!dev) {
                        pr_warning("%s: no memory for hdlc_device !\n",
                                   ci->devname);
-                       OS_kfree(priv);
+                       kfree(priv);
                        return NULL;
                }
                priv->ci = ci;
@@ -972,8 +971,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, unsigned long f1,
 
        if (register_netdev(ndev) ||
                (c4_init(ci, (u_char *) f0, (u_char *) f1) != SBE_DRVR_SUCCESS)) {
-               OS_kfree(netdev_priv(ndev));
-               OS_kfree(ndev);
+               kfree(netdev_priv(ndev));
+               kfree(ndev);
                error_flag = -ENODEV;
                return NULL;
        }
@@ -998,8 +997,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, unsigned long f1,
                pr_warning("%s: MUSYCC could not get irq: %d\n",
                           ndev->name, irq0);
                unregister_netdev(ndev);
-               OS_kfree(netdev_priv(ndev));
-               OS_kfree(ndev);
+               kfree(netdev_priv(ndev));
+               kfree(ndev);
                error_flag = -EIO;
                return NULL;
        }
@@ -1008,8 +1007,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, unsigned long f1,
                pr_warning("%s: EBUS could not get irq: %d\n", hi->devname, irq1);
                unregister_netdev(ndev);
                free_irq(irq0, ndev);
-               OS_kfree(netdev_priv(ndev));
-               OS_kfree(ndev);
+               kfree(netdev_priv(ndev));
+               kfree(ndev);
                error_flag = -EIO;
                return NULL;
        }
@@ -1068,8 +1067,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, unsigned long f1,
                unregister_netdev(ndev);
                free_irq(irq1, ndev);
                free_irq(irq0, ndev);
-               OS_kfree(netdev_priv(ndev));
-               OS_kfree(ndev);
+               kfree(netdev_priv(ndev));
+               kfree(ndev);
                /* failure, error_flag is set */
                return NULL;
        }
index 7b4f6f2108e3b9015a9c8b2de81c5998c06a6216..872cdae02704302fa157d428f59d510aa651b31f 100644 (file)
@@ -744,7 +744,8 @@ musycc_init(ci_t *ci)
 
 #define INT_QUEUE_BOUNDARY  4
 
-    regaddr = OS_kmalloc((INT_QUEUE_SIZE + 1) * sizeof(u_int32_t));
+       regaddr = kzalloc((INT_QUEUE_SIZE + 1) * sizeof(u_int32_t),
+                         GFP_KERNEL | GFP_DMA);
     if (!regaddr)
        return -ENOMEM;
     ci->iqd_p_saved = regaddr;      /* save orig value for free's usage */
@@ -765,11 +766,12 @@ musycc_init(ci_t *ci)
 
 #define GROUP_BOUNDARY   0x800
 
-       regaddr = OS_kmalloc(sizeof(struct musycc_groupr) + GROUP_BOUNDARY);
+       regaddr = kzalloc(sizeof(struct musycc_groupr) + GROUP_BOUNDARY,
+                         GFP_KERNEL | GFP_DMA);
        if (!regaddr) {
            for (gchan = 0; gchan < i; gchan++) {
                pi = &ci->port[gchan];
-               OS_kfree(pi->reg);
+               kfree(pi->reg);
                pi->reg = NULL;
            }
            return -ENOMEM;
@@ -1576,10 +1578,10 @@ musycc_chan_down(ci_t *dummy, int channum)
        if (ch->mdr[i].mem_token)
            OS_mem_token_free(ch->mdr[i].mem_token);
 
-    OS_kfree(ch->mdr);
+    kfree(ch->mdr);
     ch->mdr = NULL;
     ch->rxd_num = 0;
-    OS_kfree(ch->mdt);
+    kfree(ch->mdt);
     ch->mdt = NULL;
     ch->txd_num = 0;
 
index 78cc1709ebdb62549bb9658a580905ce6659e67e..ba588f1b211062f996fefe564efa295f9088faa1 100644 (file)
@@ -28,6 +28,7 @@
 #include "sbecom_inline_linux.h"
 #include "pmcc4.h"
 #include "sbe_promformat.h"
+#include "pmc93x6_eeprom.h"
 
 #ifndef TRUE
 #define TRUE   1
  *      using.
  */
 
-#define EE_MFG      (long)0     /* Index to manufacturing record */
-#define EE_FIRST    0x28        /* Index to start testing at */
-#define EE_LIMIT    128         /* Index to end testing at */
-
+#define EE_MFG      (long)0    /* Index to manufacturing record */
+#define EE_FIRST    0x28       /* Index to start testing at */
+#define EE_LIMIT    128                /* Index to end testing at */
 
 /*  Bit Ordering for Instructions
-**
-**  A0, A1, A2, A3, A4, A5, A6, OP0, OP1, SB   (lsb, or 1st bit out)
-**
-*/
-
-#define EPROM_EWEN      0x0019  /* Erase/Write enable (reversed) */
-#define EPROM_EWDS      0x0001  /* Erase/Write disable (reversed) */
-#define EPROM_READ      0x0003  /* Read (reversed) */
-#define EPROM_WRITE     0x0005  /* Write (reversed) */
-#define EPROM_ERASE     0x0007  /* Erase (reversed) */
-#define EPROM_ERAL      0x0009  /* Erase All (reversed) */
-#define EPROM_WRAL      0x0011  /* Write All (reversed) */
-
-#define EPROM_ADR_SZ    7       /* Number of bits in offset address */
-#define EPROM_OP_SZ     3       /* Number of bits in command */
-#define SIZE_ADDR_OP    (EPROM_ADR_SZ + EPROM_OP_SZ)
-#define LC46A_MAX_OPS   10      /* Number of bits in Instruction */
-#define NUM_OF_BITS     8       /* Number of bits in data */
+ *
+ *  A0, A1, A2, A3, A4, A5, A6, OP0, OP1, SB   (lsb, or 1st bit out)
+ *
+ */
 
+#define EPROM_EWEN      0x0019 /* Erase/Write enable (reversed) */
+#define EPROM_EWDS      0x0001 /* Erase/Write disable (reversed) */
+#define EPROM_READ      0x0003 /* Read (reversed) */
+#define EPROM_WRITE     0x0005 /* Write (reversed) */
+#define EPROM_ERASE     0x0007 /* Erase (reversed) */
+#define EPROM_ERAL      0x0009 /* Erase All (reversed) */
+#define EPROM_WRAL      0x0011 /* Write All (reversed) */
 
-/* EEPROM signal bits */
-#define EPROM_ACTIVE_OUT_BIT    0x0001  /* Out data bit */
-#define EPROM_ACTIVE_IN_BIT     0x0002  /* In data bit */
-#define ACTIVE_IN_BIT_SHIFT     0x0001  /* Shift In data bit to LSB */
-#define EPROM_ENCS              0x0004  /* Set EEPROM CS during operation */
+#define EPROM_ADR_SZ    7      /* Number of bits in offset address */
+#define EPROM_OP_SZ     3      /* Number of bits in command */
+#define SIZE_ADDR_OP    (EPROM_ADR_SZ + EPROM_OP_SZ)
+#define LC46A_MAX_OPS   10     /* Number of bits in Instruction */
+#define NUM_OF_BITS     8      /* Number of bits in data */
 
+/* EEPROM signal bits */
+#define EPROM_ACTIVE_OUT_BIT    0x0001 /* Out data bit */
+#define EPROM_ACTIVE_IN_BIT     0x0002 /* In data bit */
+#define ACTIVE_IN_BIT_SHIFT     0x0001 /* Shift In data bit to LSB */
+#define EPROM_ENCS              0x0004 /* Set EEPROM CS during operation */
 
 /*------------------------------------------------------------------------
  *      The ByteReverse table is used to reverses the 8 bits within a byte
  */
 
 static unsigned char ByteReverse[256];
-static int  ByteReverseBuilt = FALSE;
-
+static int ByteReverseBuilt = FALSE;
 
 /*------------------------------------------------------------------------
  *      mfg_template - initial serial EEPROM data structure
  *------------------------------------------------------------------------
  */
 
-static u8 mfg_template[sizeof(FLD_TYPE2)] =
-{
-    PROM_FORMAT_TYPE2,          /* type; */
-    0x00, 0x1A,                 /* length[2]; */
-    0x00, 0x00, 0x00, 0x00,     /* Crc32[4]; */
-    0x11, 0x76,                 /* Id[2]; */
-    0x07, 0x05,                 /* SubId[2] E1; */
-    0x00, 0xA0, 0xD6, 0x00, 0x00, 0x00, /* Serial[6]; */
-    0x00, 0x00, 0x00, 0x00,     /* CreateTime[4]; */
-    0x00, 0x00, 0x00, 0x00,     /* HeatRunTime[4]; */
-    0x00, 0x00, 0x00, 0x00,     /* HeatRunIterations[4]; */
-    0x00, 0x00, 0x00, 0x00,     /* HeatRunErrors[4]; */
+static u8 mfg_template[sizeof(FLD_TYPE2)] = {
+       PROM_FORMAT_TYPE2,      /* type; */
+       0x00, 0x1A,             /* length[2]; */
+       0x00, 0x00, 0x00, 0x00, /* Crc32[4]; */
+       0x11, 0x76,             /* Id[2]; */
+       0x07, 0x05,             /* SubId[2] E1; */
+       0x00, 0xA0, 0xD6, 0x00, 0x00, 0x00,     /* Serial[6]; */
+       0x00, 0x00, 0x00, 0x00, /* CreateTime[4]; */
+       0x00, 0x00, 0x00, 0x00, /* HeatRunTime[4]; */
+       0x00, 0x00, 0x00, 0x00, /* HeatRunIterations[4]; */
+       0x00, 0x00, 0x00, 0x00, /* HeatRunErrors[4]; */
 };
 
-
 /*------------------------------------------------------------------------
  *      BuildByteReverse - build the 8-bit reverse table
  *------------------------------------------------------------------------
@@ -113,39 +108,35 @@ static u8 mfg_template[sizeof(FLD_TYPE2)] =
  *      (the MSB becomes the LSB etc.).
  */
 
-static void
-BuildByteReverse (void)
+static void BuildByteReverse(void)
 {
-    long        half;           /* Used to build by powers to 2 */
-    int         i;
+       /* Used to build by powers to 2 */
+       long half;
+       int i;
 
-    ByteReverse[0] = 0;
+       ByteReverse[0] = 0;
 
-    for (half = 1; half < sizeof (ByteReverse); half <<= 1)
-        for (i = 0; i < half; i++)
-            ByteReverse[half + i] = (char) (ByteReverse[i] | (0x80 / half));
+       for (half = 1; half < sizeof(ByteReverse); half <<= 1)
+               for (i = 0; i < half; i++)
+                       ByteReverse[half + i] =
+                           (char)(ByteReverse[i] | (0x80 / half));
 
-    ByteReverseBuilt = TRUE;
+       ByteReverseBuilt = TRUE;
 }
 
-
 /*------------------------------------------------------------------------
  *      eeprom_delay - small delay for EEPROM timing
  *------------------------------------------------------------------------
  */
 
-static void
-eeprom_delay (void)
+static void eeprom_delay(void)
 {
-    int         timeout;
+       int timeout;
 
-    for (timeout = 20; timeout; --timeout)
-    {
-        OS_uwait_dummy ();
-    }
+       for (timeout = 20; timeout; --timeout)
+               OS_uwait_dummy();
 }
 
-
 /*------------------------------------------------------------------------
  *      eeprom_put_byte - Send a byte to the EEPROM serially
  *------------------------------------------------------------------------
@@ -154,23 +145,23 @@ eeprom_delay (void)
  *      the data to the EEPROM.
  */
 
-void
-eeprom_put_byte (long addr, long data, int count)
+static void eeprom_put_byte(long addr, long data, int count)
 {
-    u_int32_t output;
-
-    while (--count >= 0)
-    {
-        output = (data & EPROM_ACTIVE_OUT_BIT) ? 1 : 0; /* Get next data bit */
-        output |= EPROM_ENCS;       /* Add Chip Select */
-        data >>= 1;
-
-        eeprom_delay ();
-        pci_write_32 ((u_int32_t *) addr, output);      /* Output it */
-    }
+       u_int32_t output;
+
+       while (--count >= 0) {
+               /* Get next data bit */
+               output = (data & EPROM_ACTIVE_OUT_BIT) ? 1 : 0;
+               /* Add Chip Select */
+               output |= EPROM_ENCS;
+               data >>= 1;
+
+               eeprom_delay();
+               /* Output it */
+               pci_write_32((u_int32_t *) addr, output);
+       }
 }
 
-
 /*------------------------------------------------------------------------
  *      eeprom_get_byte - Receive a byte from the EEPROM serially
  *------------------------------------------------------------------------
@@ -179,37 +170,35 @@ eeprom_put_byte (long addr, long data, int count)
  *      from the  EEPROM.
  */
 
-u_int32_t
-eeprom_get_byte (long addr)
+static u_int32_t eeprom_get_byte(long addr)
 {
-    u_int32_t   input;
-    u_int32_t   data;
-    int         count;
+       u_int32_t input;
+       u_int32_t data;
+       int count;
 
 /*  Start the Reading of DATA
-**
-**  The first read is a dummy as the data is latched in the
-**  EPLD and read on the next read access to the EEPROM.
-*/
+ *
+ *  The first read is a dummy as the data is latched in the
+ *  EPLD and read on the next read access to the EEPROM.
+ */
 
-    input = pci_read_32 ((u_int32_t *) addr);
+       input = pci_read_32((u_int32_t *) addr);
 
-    data = 0;
-    count = NUM_OF_BITS;
-    while (--count >= 0)
-    {
-        eeprom_delay ();
-        input = pci_read_32 ((u_int32_t *) addr);
+       data = 0;
+       count = NUM_OF_BITS;
+       while (--count >= 0) {
+               eeprom_delay();
+               input = pci_read_32((u_int32_t *) addr);
 
-        data <<= 1;                 /* Shift data over */
-        data |= (input & EPROM_ACTIVE_IN_BIT) ? 1 : 0;
+               /* Shift data over */
+               data <<= 1;
+               data |= (input & EPROM_ACTIVE_IN_BIT) ? 1 : 0;
 
-    }
+       }
 
-    return data;
+       return data;
 }
 
-
 /*------------------------------------------------------------------------
  *      disable_pmc_eeprom - Disable writes to the EEPROM
  *------------------------------------------------------------------------
@@ -217,16 +206,14 @@ eeprom_get_byte (long addr)
  *      Issue the EEPROM command to disable writes.
  */
 
-static void
-disable_pmc_eeprom (long addr)
+static void disable_pmc_eeprom(long addr)
 {
-    eeprom_put_byte (addr, EPROM_EWDS, SIZE_ADDR_OP);
+       eeprom_put_byte(addr, EPROM_EWDS, SIZE_ADDR_OP);
 
-    pci_write_32 ((u_int32_t *) addr, 0);       /* this removes Chip Select
-                                                 * from EEPROM */
+       /* this removes Chip Select from EEPROM */
+       pci_write_32((u_int32_t *) addr, 0);
 }
 
-
 /*------------------------------------------------------------------------
  *      enable_pmc_eeprom - Enable writes to the EEPROM
  *------------------------------------------------------------------------
@@ -234,16 +221,14 @@ disable_pmc_eeprom (long addr)
  *      Issue the EEPROM command to enable writes.
  */
 
-static void
-enable_pmc_eeprom (long addr)
+static void enable_pmc_eeprom(long addr)
 {
-    eeprom_put_byte (addr, EPROM_EWEN, SIZE_ADDR_OP);
+       eeprom_put_byte(addr, EPROM_EWEN, SIZE_ADDR_OP);
 
-    pci_write_32 ((u_int32_t *) addr, 0);       /* this removes Chip Select
-                                                 * from EEPROM */
+       /* this removes Chip Select from EEPROM */
+       pci_write_32((u_int32_t *) addr, 0);
 }
 
-
 /*------------------------------------------------------------------------
  *      pmc_eeprom_read - EEPROM location read
  *------------------------------------------------------------------------
@@ -252,34 +237,40 @@ enable_pmc_eeprom (long addr)
  *      the contents of the specified location to the calling routine.
  */
 
-u_int32_t
-pmc_eeprom_read (long addr, long mem_offset)
+static u_int32_t pmc_eeprom_read(long addr, long mem_offset)
 {
-    u_int32_t   data;           /* Data from chip */
+       /* Data from chip */
+       u_int32_t data;
 
-    if (!ByteReverseBuilt)
-        BuildByteReverse ();
+       if (!ByteReverseBuilt)
+               BuildByteReverse();
 
-    mem_offset = ByteReverse[0x7F & mem_offset];        /* Reverse address */
-    /*
-     * NOTE: The max offset address is 128 or half the reversal table. So the
-     * LSB is always zero and counts as a built in shift of one bit.  So even
-     * though we need to shift 3 bits to make room for the command, we only
-     * need to shift twice more because of the built in shift.
-     */
-    mem_offset <<= 2;               /* Shift for command */
-    mem_offset |= EPROM_READ;       /* Add command */
+       /* Reverse address */
+       mem_offset = ByteReverse[0x7F & mem_offset];
 
-    eeprom_put_byte (addr, mem_offset, SIZE_ADDR_OP);   /* Output chip address */
+       /*
+        * NOTE: The max offset address is 128 or half the reversal table. So
+        * the LSB is always zero and counts as a built in shift of one bit.
+        * So even though we need to shift 3 bits to make room for the command,
+        * we only need to shift twice more because of the built in shift.
+        */
 
-    data = eeprom_get_byte (addr);  /* Read chip data */
+       /* Shift for command */
+       mem_offset <<= 2;
+       /* Add command */
+       mem_offset |= EPROM_READ;
 
-    pci_write_32 ((u_int32_t *) addr, 0);       /* Remove Chip Select from
-                                                 * EEPROM */
+       /* Output chip address */
+       eeprom_put_byte(addr, mem_offset, SIZE_ADDR_OP);
 
-    return (data & 0x000000FF);
-}
+       /* Read chip data */
+       data = eeprom_get_byte(addr);
+
+       /* Remove Chip Select from EEPROM */
+       pci_write_32((u_int32_t *) addr, 0);
 
+       return (data & 0x000000FF);
+}
 
 /*------------------------------------------------------------------------
  *      pmc_eeprom_write - EEPROM location write
@@ -292,189 +283,181 @@ pmc_eeprom_read (long addr, long mem_offset)
  *      operation succeeded.
  */
 
-int
-pmc_eeprom_write (long addr, long mem_offset, u_int32_t data)
+static int pmc_eeprom_write(long addr, long mem_offset, u_int32_t data)
 {
-    volatile u_int32_t temp;
-    int         count;
+       u_int32_t temp;
+       int count;
+
+       if (!ByteReverseBuilt)
+               BuildByteReverse();
+
+       /* Reverse address */
+       mem_offset = ByteReverse[0x7F & mem_offset];
 
-    if (!ByteReverseBuilt)
-        BuildByteReverse ();
+       /*
+        * NOTE: The max offset address is 128 or half the reversal table. So
+        * the LSB is always zero and counts as a built in shift of one bit.
+        * So even though we need to shift 3 bits to make room for the command,
+        * we only need to shift twice more because of the built in shift.
+        */
 
-    mem_offset = ByteReverse[0x7F & mem_offset];        /* Reverse address */
-    /*
-     * NOTE: The max offset address is 128 or half the reversal table. So the
-     * LSB is always zero and counts as a built in shift of one bit.  So even
-     * though we need to shift 3 bits to make room for the command, we only
-     * need to shift twice more because of the built in shift.
-     */
-    mem_offset <<= 2;               /* Shift for command */
-    mem_offset |= EPROM_WRITE;      /* Add command */
+       /* Shift for command */
+       mem_offset <<= 2;
+       /* Add command */
+       mem_offset |= EPROM_WRITE;
 
-    eeprom_put_byte (addr, mem_offset, SIZE_ADDR_OP);   /* Output chip address */
+       /* Output chip address */
+       eeprom_put_byte(addr, mem_offset, SIZE_ADDR_OP);
 
-    data = ByteReverse[0xFF & data];/* Reverse data */
-    eeprom_put_byte (addr, data, NUM_OF_BITS);  /* Output chip data */
+       /* Reverse data */
+       data = ByteReverse[0xFF & data];
+       /* Output chip data */
+       eeprom_put_byte(addr, data, NUM_OF_BITS);
 
-    pci_write_32 ((u_int32_t *) addr, 0);       /* Remove Chip Select from
-                                                 * EEPROM */
+       /* Remove Chip Select from EEPROM */
+       pci_write_32((u_int32_t *) addr, 0);
 
 /*
-**  Must see Data In at a low state before completing this transaction.
-**
-**  Afterwards, the data bit will return to a high state, ~6 ms, terminating
-**  the operation.
-*/
-    pci_write_32 ((u_int32_t *) addr, EPROM_ENCS);      /* Re-enable Chip Select */
-    temp = pci_read_32 ((u_int32_t *) addr);    /* discard first read */
-    temp = pci_read_32 ((u_int32_t *) addr);
-    if (temp & EPROM_ACTIVE_IN_BIT)
-    {
-        temp = pci_read_32 ((u_int32_t *) addr);
-        if (temp & EPROM_ACTIVE_IN_BIT)
-        {
-            pci_write_32 ((u_int32_t *) addr, 0);       /* Remove Chip Select
-                                                         * from EEPROM */
-            return (1);
-        }
-    }
-    count = 1000;
-    while (count--)
-    {
-        for (temp = 0; temp < 0x10; temp++)
-            OS_uwait_dummy ();
-
-        if (pci_read_32 ((u_int32_t *) addr) & EPROM_ACTIVE_IN_BIT)
-            break;
-    }
-
-    if (count == -1)
-        return (2);
-
-    return (0);
+ *  Must see Data In at a low state before completing this transaction.
+ *
+ *  Afterwards, the data bit will return to a high state, ~6 ms, terminating
+ *  the operation.
+ */
+       /* Re-enable Chip Select */
+       pci_write_32((u_int32_t *) addr, EPROM_ENCS);
+       /* discard first read */
+       temp = pci_read_32((u_int32_t *) addr);
+       temp = pci_read_32((u_int32_t *) addr);
+       if (temp & EPROM_ACTIVE_IN_BIT) {
+               temp = pci_read_32((u_int32_t *) addr);
+               if (temp & EPROM_ACTIVE_IN_BIT) {
+                       /* Remove Chip Select from EEPROM */
+                       pci_write_32((u_int32_t *) addr, 0);
+                       return 1;
+               }
+       }
+       count = 1000;
+       while (count--) {
+               for (temp = 0; temp < 0x10; temp++)
+                       OS_uwait_dummy();
+
+               if (pci_read_32((u_int32_t *) addr) & EPROM_ACTIVE_IN_BIT)
+                       break;
+       }
+
+       if (count == -1)
+               return 2;
+
+       return 0;
 }
 
-
 /*------------------------------------------------------------------------
  *      pmcGetBuffValue - read the specified value from buffer
  *------------------------------------------------------------------------
  */
 
-long
-pmcGetBuffValue (char *ptr, int size)
+static long pmcGetBuffValue(char *ptr, int size)
 {
-    long        value = 0;
-    int         index;
+       long value = 0;
+       int index;
 
-    for (index = 0; index < size; ++index)
-    {
-        value <<= 8;
-        value |= ptr[index] & 0xFF;
-    }
+       for (index = 0; index < size; ++index) {
+               value <<= 8;
+               value |= ptr[index] & 0xFF;
+       }
 
-    return value;
+       return value;
 }
 
-
 /*------------------------------------------------------------------------
  *      pmcSetBuffValue - save the specified value to buffer
  *------------------------------------------------------------------------
  */
 
-void
-pmcSetBuffValue (char *ptr, long value, int size)
+static void pmcSetBuffValue(char *ptr, long value, int size)
 {
-    int         index = size;
+       int index = size;
 
-    while (--index >= 0)
-    {
-        ptr[index] = (char) (value & 0xFF);
-        value >>= 8;
-    }
+       while (--index >= 0) {
+               ptr[index] = (char)(value & 0xFF);
+               value >>= 8;
+       }
 }
 
-
 /*------------------------------------------------------------------------
  *      pmc_eeprom_read_buffer - read EEPROM data into specified buffer
  *------------------------------------------------------------------------
  */
 
 void
-pmc_eeprom_read_buffer (long addr, long mem_offset, char *dest_ptr, int size)
+pmc_eeprom_read_buffer(long addr, long mem_offset, char *dest_ptr, int size)
 {
-    while (--size >= 0)
-        *dest_ptr++ = (char) pmc_eeprom_read (addr, mem_offset++);
+       while (--size >= 0)
+               *dest_ptr++ = (char)pmc_eeprom_read(addr, mem_offset++);
 }
 
-
 /*------------------------------------------------------------------------
  *      pmc_eeprom_write_buffer - write EEPROM data from specified buffer
  *------------------------------------------------------------------------
  */
 
 void
-pmc_eeprom_write_buffer (long addr, long mem_offset, char *dest_ptr, int size)
+pmc_eeprom_write_buffer(long addr, long mem_offset, char *dest_ptr, int size)
 {
-    enable_pmc_eeprom (addr);
+       enable_pmc_eeprom(addr);
 
-    while (--size >= 0)
-        pmc_eeprom_write (addr, mem_offset++, *dest_ptr++);
+       while (--size >= 0)
+               pmc_eeprom_write(addr, mem_offset++, *dest_ptr++);
 
-    disable_pmc_eeprom (addr);
+       disable_pmc_eeprom(addr);
 }
 
-
 /*------------------------------------------------------------------------
  *      pmcCalcCrc - calculate the CRC for the serial EEPROM structure
  *------------------------------------------------------------------------
  */
 
-u_int32_t
-pmcCalcCrc_T01 (void *bufp)
+static u_int32_t pmcCalcCrc_T01(void *bufp)
 {
-    FLD_TYPE2  *buf = bufp;
-    u_int32_t   crc;            /* CRC of the structure */
+       FLD_TYPE2 *buf = bufp;
+       /* CRC of the structure */
+       u_int32_t crc;
 
-    /* Calc CRC for type and length fields */
-    sbeCrc (
-            (u_int8_t *) &buf->type,
-            (u_int32_t) STRUCT_OFFSET (FLD_TYPE1, Crc32),
-            (u_int32_t) 0,
-            (u_int32_t *) &crc);
+       /* Calc CRC for type and length fields */
+       sbeCrc((u_int8_t *) &buf->type,
+              (u_int32_t) STRUCT_OFFSET(FLD_TYPE1, Crc32),
+              (u_int32_t) 0, (u_int32_t *) &crc);
 
 #ifdef EEPROM_TYPE_DEBUG
-    pr_info("sbeCrc: crc 1 calculated as %08x\n", crc); /* RLD DEBUG */
+       /* RLD DEBUG */
+       pr_info("sbeCrc: crc 1 calculated as %08x\n", crc);
 #endif
-    return ~crc;
+       return ~crc;
 }
 
-u_int32_t
-pmcCalcCrc_T02 (void *bufp)
+static u_int32_t pmcCalcCrc_T02(void *bufp)
 {
-    FLD_TYPE2  *buf = bufp;
-    u_int32_t   crc;            /* CRC of the structure */
-
-    /* Calc CRC for type and length fields */
-    sbeCrc (
-            (u_int8_t *) &buf->type,
-            (u_int32_t) STRUCT_OFFSET (FLD_TYPE2, Crc32),
-            (u_int32_t) 0,
-            (u_int32_t *) &crc);
-
-    /* Calc CRC for remaining fields */
-    sbeCrc (
-            (u_int8_t *) &buf->Id[0],
-            (u_int32_t) (sizeof (FLD_TYPE2) - STRUCT_OFFSET (FLD_TYPE2, Id)),
-            (u_int32_t) crc,
-            (u_int32_t *) &crc);
+       FLD_TYPE2 *buf = bufp;
+       /* CRC of the structure */
+       u_int32_t crc;
+
+       /* Calc CRC for type and length fields */
+       sbeCrc((u_int8_t *) &buf->type,
+              (u_int32_t) STRUCT_OFFSET(FLD_TYPE2, Crc32),
+              (u_int32_t) 0, (u_int32_t *) &crc);
+
+       /* Calc CRC for remaining fields */
+       sbeCrc((u_int8_t *) &buf->Id[0],
+              (u_int32_t) (sizeof(FLD_TYPE2) - STRUCT_OFFSET(FLD_TYPE2, Id)),
+              (u_int32_t) crc, (u_int32_t *) &crc);
 
 #ifdef EEPROM_TYPE_DEBUG
-    pr_info("sbeCrc: crc 2 calculated as %08x\n", crc); /* RLD DEBUG */
+       /* RLD DEBUG */
+       pr_info("sbeCrc: crc 2 calculated as %08x\n", crc);
 #endif
-    return crc;
+       return crc;
 }
 
-
 /*------------------------------------------------------------------------
  *      pmc_init_seeprom - initialize the serial EEPROM structure
  *------------------------------------------------------------------------
@@ -485,64 +468,65 @@ pmcCalcCrc_T02 (void *bufp)
  *      serial number field.
  */
 
-void
-pmc_init_seeprom (u_int32_t addr, u_int32_t serialNum)
+void pmc_init_seeprom(u_int32_t addr, u_int32_t serialNum)
 {
-    PROMFORMAT  buffer;         /* Memory image of structure */
-    u_int32_t   crc;            /* CRC of structure */
-    time_t      createTime;
+       /* Memory image of structure */
+       PROMFORMAT buffer;
+       /* CRC of structure */
+       u_int32_t crc;
+       time_t createTime;
 
-    createTime = get_seconds ();
+       createTime = get_seconds();
 
-    /* use template data */
-    memcpy(&buffer.fldType2, mfg_template, sizeof(buffer.fldType2));
+       /* use template data */
+       memcpy(&buffer.fldType2, mfg_template, sizeof(buffer.fldType2));
 
-    /* Update serial number field in buffer */
-    pmcSetBuffValue (&buffer.fldType2.Serial[3], serialNum, 3);
+       /* Update serial number field in buffer */
+       pmcSetBuffValue(&buffer.fldType2.Serial[3], serialNum, 3);
 
-    /* Update create time field in buffer */
-    pmcSetBuffValue (&buffer.fldType2.CreateTime[0], createTime, 4);
+       /* Update create time field in buffer */
+       pmcSetBuffValue(&buffer.fldType2.CreateTime[0], createTime, 4);
 
-    /* Update CRC field in buffer */
-    crc = pmcCalcCrc_T02 (&buffer);
-    pmcSetBuffValue (&buffer.fldType2.Crc32[0], crc, 4);
+       /* Update CRC field in buffer */
+       crc = pmcCalcCrc_T02(&buffer);
+       pmcSetBuffValue(&buffer.fldType2.Crc32[0], crc, 4);
 
 #ifdef DEBUG
-    for (i = 0; i < sizeof (FLD_TYPE2); ++i)
-        pr_info("[%02X] = %02X\n", i, buffer.bytes[i] & 0xFF);
+       for (i = 0; i < sizeof(FLD_TYPE2); ++i)
+               pr_info("[%02X] = %02X\n", i, buffer.bytes[i] & 0xFF);
 #endif
 
-    /* Write structure to serial EEPROM */
-    pmc_eeprom_write_buffer (addr, EE_MFG, (char *) &buffer, sizeof (FLD_TYPE2));
+       /* Write structure to serial EEPROM */
+       pmc_eeprom_write_buffer(addr, EE_MFG, (char *)&buffer,
+                               sizeof(FLD_TYPE2));
 }
 
-
-char
-pmc_verify_cksum (void *bufp)
+char pmc_verify_cksum(void *bufp)
 {
-    FLD_TYPE1  *buf1 = bufp;
-    FLD_TYPE2  *buf2 = bufp;
-    u_int32_t   crc1, crc2;     /* CRC read from EEPROM */
+       FLD_TYPE1 *buf1 = bufp;
+       FLD_TYPE2 *buf2 = bufp;
+       /* CRC read from EEPROM */
+       u_int32_t crc1, crc2;
 
-    /* Retrieve contents of CRC field */
-    crc1 = pmcGetBuffValue (&buf1->Crc32[0], sizeof (buf1->Crc32));
+       /* Retrieve contents of CRC field */
+       crc1 = pmcGetBuffValue(&buf1->Crc32[0], sizeof(buf1->Crc32));
 #ifdef EEPROM_TYPE_DEBUG
-    pr_info("EEPROM: chksum 1 reads   as %08x\n", crc1);        /* RLD DEBUG */
+       /* RLD DEBUG */
+       pr_info("EEPROM: chksum 1 reads   as %08x\n", crc1);
 #endif
-    if ((buf1->type == PROM_FORMAT_TYPE1) &&
-        (pmcCalcCrc_T01 ((void *) buf1) == crc1))
-        return PROM_FORMAT_TYPE1;   /* checksum type 1 verified */
+       if ((buf1->type == PROM_FORMAT_TYPE1) &&
+           (pmcCalcCrc_T01((void *)buf1) == crc1))
+               return PROM_FORMAT_TYPE1;       /* checksum type 1 verified */
 
-    crc2 = pmcGetBuffValue (&buf2->Crc32[0], sizeof (buf2->Crc32));
+       crc2 = pmcGetBuffValue(&buf2->Crc32[0], sizeof(buf2->Crc32));
 #ifdef EEPROM_TYPE_DEBUG
-    pr_info("EEPROM: chksum 2 reads   as %08x\n", crc2);        /* RLD DEBUG */
+       /* RLD DEBUG */
+       pr_info("EEPROM: chksum 2 reads   as %08x\n", crc2);
 #endif
-    if ((buf2->type == PROM_FORMAT_TYPE2) &&
-        (pmcCalcCrc_T02 ((void *) buf2) == crc2))
-        return PROM_FORMAT_TYPE2;   /* checksum type 2 verified */
+       if ((buf2->type == PROM_FORMAT_TYPE2) &&
+           (pmcCalcCrc_T02((void *)buf2) == crc2))
+               return PROM_FORMAT_TYPE2;       /* checksum type 2 verified */
 
-    return PROM_FORMAT_Unk;         /* failed to validate */
+       /* failed to validate */
+       return PROM_FORMAT_Unk;
 }
-
-
-/*** End-of-File ***/
index 621a72926475677d5a9158bcba8fa44a29628cde..76bebdd18b3aa9bd717a88cb81b60671c846c5ac 100644 (file)
@@ -122,35 +122,6 @@ c4_find_chan (int channum)
     return NULL;
 }
 
-
-ci_t       *__init
-c4_new (void *hi)
-{
-    ci_t       *ci;
-
-#ifdef SBE_MAP_DEBUG
-    pr_warning("c4_new() entered, ci needs %u.\n",
-               (unsigned int) sizeof (ci_t));
-#endif
-
-    ci = (ci_t *) OS_kmalloc (sizeof (ci_t));
-    if (ci)
-    {
-        ci->hdw_info = hi;
-        ci->state = C_INIT;         /* mark as hardware not available */
-        ci->next = c4_list;
-        c4_list = ci;
-        ci->brdno = ci->next ? ci->next->brdno + 1 : 0;
-    } else
-        pr_warning("failed CI malloc, size %u.\n",
-                   (unsigned int) sizeof (ci_t));
-
-    if (!CI)
-        CI = ci;                    /* DEBUG, only board 0 usage */
-    return ci;
-}
-
-
 /***
  * Check port state and set LED states using watchdog or ioctl...
  * also check for in-band SF loopback commands (& cause results if they are there)
@@ -485,12 +456,12 @@ c4_cleanup (void)
             for (j = 0; j < MUSYCC_NCHANS; j++)
             {
                 if (pi->chan[j])
-                    OS_kfree (pi->chan[j]);     /* free mch_t struct */
+                    kfree(pi->chan[j]);     /* free mch_t struct */
             }
-            OS_kfree (pi->regram_saved);
+            kfree(pi->regram_saved);
         }
-        OS_kfree (ci->iqd_p_saved);
-        OS_kfree (ci);
+        kfree(ci->iqd_p_saved);
+        kfree(ci);
         ci = next;                  /* cleanup next board, if any */
     }
 }
@@ -619,7 +590,7 @@ c4_init (ci_t *ci, u_char *func0, u_char *func1)
         /* allocate channel structures for this port */
         for (j = 0; j < MUSYCC_NCHANS; j++)
         {
-            ch = OS_kmalloc (sizeof (mch_t));
+               ch = kzalloc(sizeof(mch_t), GFP_KERNEL | GFP_DMA);
             if (ch)
             {
                 pi->chan[j] = ch;
@@ -1368,8 +1339,8 @@ c4_chan_up (ci_t *ci, int channum)
     ch->txd_num = txnum;
     ch->rxix_irq_srv = 0;
 
-    ch->mdr = OS_kmalloc (sizeof (struct mdesc) * rxnum);
-    ch->mdt = OS_kmalloc (sizeof (struct mdesc) * txnum);
+       ch->mdr = kzalloc(sizeof(struct mdesc) * rxnum, GFP_KERNEL | GFP_DMA);
+       ch->mdt = kzalloc(sizeof(struct mdesc) * txnum, GFP_KERNEL | GFP_DMA);
     if (ch->p.chan_mode == CFG_CH_PROTO_TRANS)
                tmp = __constant_cpu_to_le32 (cxt1e1_max_mru | EOBIRQ_ENABLE);
     else
@@ -1462,10 +1433,10 @@ errfree:
         i--;
         OS_mem_token_free (ch->mdr[i].mem_token);
     }
-    OS_kfree (ch->mdt);
+    kfree(ch->mdt);
     ch->mdt = NULL;
     ch->txd_num = 0;
-    OS_kfree (ch->mdr);
+    kfree(ch->mdr);
     ch->mdr = NULL;
     ch->rxd_num = 0;
     ch->state = DOWN;
index eb28f095ff8c29c840d149165687b5e5037c0872..451f12f5b04c828d51e95680e95732366af0d1b3 100644 (file)
@@ -262,7 +262,7 @@ struct s_hdw_info
     struct pci_dev *pdev[2];
 
     unsigned long addr[2];
-    unsigned long addr_mapped[2];
+    void __iomem *addr_mapped[2];
     unsigned long len[2];
 
     union
index ba3ff3efe0634356cb7488aa61f168ac798a0223..f5835c29ef324783dc3e16a72f283d9d0239ff84 100644 (file)
@@ -39,27 +39,6 @@ void        pci_write_32 (u_int32_t *p, u_int32_t v);
  * system dependent callbacks
  */
 
-/**********/
-/* malloc */
-/**********/
-
-static inline void *
-OS_kmalloc (size_t size)
-{
-    char       *ptr = kmalloc (size, GFP_KERNEL | GFP_DMA);
-
-    if (ptr)
-        memset (ptr, 0, size);
-    return ptr;
-}
-
-static inline void
-OS_kfree (void *x)
-{
-    kfree (x);
-}
-
-
 /****************/
 /* memory token */
 /****************/
@@ -197,7 +176,7 @@ static inline int
 OS_free_watchdog (struct watchdog *wd)
 {
     OS_stop_watchdog (wd);
-    OS_kfree (wd);
+    kfree(wd);
     return 0;
 }
 
index 81fa8a3a462cc6e216b052b455791dcc7b544207..a51780f60484608569ebe6b7e2a53b7a8765a6a9 100644 (file)
@@ -101,7 +101,8 @@ sbeCrc(u_int8_t *buffer,          /* data buffer to crc */
                tbl = &CRCTable;
                genCrcTable(tbl);
 #else
-               tbl = (u_int32_t *) OS_kmalloc(CRC_TABLE_ENTRIES * sizeof(u_int32_t));
+               tbl = kzalloc(CRC_TABLE_ENTRIES * sizeof(u_int32_t),
+                             GFP_KERNEL);
                if (!tbl) {
                        *result = 0;   /* dummy up return value due to malloc
                                        * failure */
@@ -125,7 +126,7 @@ sbeCrc(u_int8_t *buffer,          /* data buffer to crc */
 
 #ifndef STATIC_CRC_TABLE
        crcTableInit = 0;
-       OS_kfree(tbl);
+       kfree(tbl);
 #endif
 }
 
index 840c647fbf410798588724b6e10ebeb612fa901d..1c2e52e8b5fe401b88505fb5acb43c48d05a3010 100644 (file)
@@ -72,7 +72,7 @@ static int sbecom_proc_get_sbe_info(struct seq_file *m, void *v)
        char       *spd;
        struct sbe_brd_info *bip;
 
-       bip = OS_kmalloc(sizeof(struct sbe_brd_info));
+       bip = kzalloc(sizeof(struct sbe_brd_info), GFP_KERNEL | GFP_DMA);
        if (!bip)
                return -ENOMEM;
 
index a5fc3c75ed4e11343102ab99b6629ae0a2521979..3c9278a224e2b86fa5d398d44248e6f94135f72c 100644 (file)
  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  * PURPOSE.  See the GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *
- *     NOTE TO LINUX KERNEL HACKERS:  DO NOT REFORMAT THIS CODE!
- *
- *     This is shared code between Digi's CVS archive and the
- *     Linux Kernel sources.
- *     Changing the source just for reformatting needlessly breaks
- *     our CVS diff history.
- *
- *     Send any bug fixes/changes to:  Eng.Linux at digi dot com.
- *     Thank you.
- *
  */
 
 /*
 
 #include "dgap.h"
 
-#define init_MUTEX(sem)         sema_init(sem, 1)
-#define DECLARE_MUTEX(name)     \
-       struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
-
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Digi International, http://www.digi.com");
 MODULE_DESCRIPTION("Driver for the Digi International EPCA PCI based product line");
 MODULE_SUPPORTED_DEVICE("dgap");
 
-/**************************************************************************
- *
- * protos for this file
- *
- */
-
 static int dgap_start(void);
 static void dgap_init_globals(void);
 static int dgap_found_board(struct pci_dev *pdev, int id);
@@ -105,7 +80,6 @@ static int dgap_probe1(struct pci_dev *pdev, int card_type);
 static int dgap_do_remap(struct board_t *brd);
 static irqreturn_t dgap_intr(int irq, void *voidbrd);
 
-/* Our function prototypes */
 static int dgap_tty_open(struct tty_struct *tty, struct file *file);
 static void dgap_tty_close(struct tty_struct *tty, struct file *file);
 static int dgap_block_til_ready(struct tty_struct *tty, struct file *file,
@@ -161,9 +135,9 @@ static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds);
 static int dgap_event(struct board_t *bd);
 
 static void dgap_poll_tasklet(unsigned long data);
-static void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1,
-                       uchar byte2, uint ncmds);
-static void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds);
+static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 byte1,
+                       u8 byte2, uint ncmds);
+static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 word, uint ncmds);
 static void dgap_wmove(struct channel_t *ch, char *buf, uint cnt);
 static int dgap_param(struct tty_struct *tty);
 static void dgap_parity_scan(struct channel_t *ch, unsigned char *cbuf,
@@ -210,22 +184,21 @@ static uint dgap_config_get_useintr(struct board_t *bd);
 static uint dgap_config_get_altpin(struct board_t *bd);
 
 static int dgap_ms_sleep(ulong ms);
-static void dgap_do_bios_load(struct board_t *brd, const uchar *ubios, int len);
-static void dgap_do_fep_load(struct board_t *brd, const uchar *ufep, int len);
+static void dgap_do_bios_load(struct board_t *brd, const u8 *ubios, int len);
+static void dgap_do_fep_load(struct board_t *brd, const u8 *ufep, int len);
 #ifdef DIGI_CONCENTRATORS_SUPPORTED
-static void dgap_do_conc_load(struct board_t *brd, uchar *uaddr, int len);
+static void dgap_do_conc_load(struct board_t *brd, u8 *uaddr, int len);
 #endif
 static int dgap_after_config_loaded(int board);
 static int dgap_finalize_board_init(struct board_t *brd);
 
 static void dgap_get_vpd(struct board_t *brd);
 static void dgap_do_reset_board(struct board_t *brd);
-static int dgap_do_wait_for_bios(struct board_t *brd);
-static int dgap_do_wait_for_fep(struct board_t *brd);
+static int dgap_test_bios(struct board_t *brd);
+static int dgap_test_fep(struct board_t *brd);
 static int dgap_tty_register_ports(struct board_t *brd);
 static int dgap_firmware_load(struct pci_dev *pdev, int card_type);
 
-/* Driver unload function */
 static void dgap_cleanup_module(void);
 
 module_exit(dgap_cleanup_module);
@@ -237,22 +210,14 @@ static const struct file_operations DgapBoardFops = {
        .owner  = THIS_MODULE,
 };
 
-/*
- * Globals
- */
 static uint dgap_NumBoards;
 static struct board_t *dgap_Board[MAXBOARDS];
 static ulong dgap_poll_counter;
 static char *dgap_config_buf;
 static int dgap_driver_state = DRIVER_INITIALIZED;
-DEFINE_SPINLOCK(dgap_dl_lock);
 static wait_queue_head_t dgap_dl_wait;
-static int dgap_dl_action;
 static int dgap_poll_tick = 20;        /* Poll interval - 20 ms */
 
-/*
- * Static vars.
- */
 static struct class *dgap_class;
 
 static struct board_t *dgap_BoardsByMajor[256];
@@ -310,7 +275,7 @@ MODULE_DEVICE_TABLE(pci, dgap_pci_tbl);
  */
 struct board_id {
        uint config_type;
-       uchar *name;
+       u8 *name;
        uint maxports;
        uint dpatype;
 };
@@ -342,10 +307,10 @@ static struct pci_driver dgap_driver = {
 };
 
 struct firmware_info {
-       uchar *conf_name;       /* dgap.conf */
-       uchar *bios_name;       /* BIOS filename */
-       uchar *fep_name;        /* FEP  filename */
-       uchar *con_name;        /* Concentrator filename  FIXME*/
+       u8 *conf_name;       /* dgap.conf */
+       u8 *bios_name;  /* BIOS filename */
+       u8 *fep_name;   /* FEP  filename */
+       u8 *con_name;   /* Concentrator filename  FIXME*/
        int num;                /* sequence number */
 };
 
@@ -655,8 +620,6 @@ static void dgap_cleanup_module(void)
        class_destroy(dgap_class);
        unregister_chrdev(DIGI_DGAP_MAJOR, "dgap");
 
-       kfree(dgap_config_buf);
-
        for (i = 0; i < dgap_NumBoards; ++i) {
                dgap_remove_ports_sysfiles(dgap_Board[i]);
                dgap_tty_uninit(dgap_Board[i]);
@@ -819,9 +782,8 @@ static int dgap_found_board(struct pci_dev *pdev, int id)
        if (i)
                brd->state = BOARD_FAILED;
 
-       pr_info("dgap: board %d: %s (rev %d), irq %ld, %s\n",
-               dgap_NumBoards, brd->name, brd->rev, brd->irq,
-               brd->state ? "NOT READY\0" : "READY\0");
+       pr_info("dgap: board %d: %s (rev %d), irq %ld\n",
+               dgap_NumBoards, brd->name, brd->rev, brd->irq);
 
        return 0;
 }
@@ -863,7 +825,7 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type)
        dgap_get_vpd(brd);
        dgap_do_reset_board(brd);
 
-       if (fw_info[card_type].conf_name) {
+       if ((fw_info[card_type].conf_name) && !dgap_config_buf) {
                ret = request_firmware(&fw, fw_info[card_type].conf_name,
                                         &pdev->dev);
                if (ret) {
@@ -871,20 +833,22 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type)
                                fw_info[card_type].conf_name);
                        return ret;
                }
+
+               dgap_config_buf = kmalloc(fw->size + 1, GFP_KERNEL);
                if (!dgap_config_buf) {
-                       dgap_config_buf = kmalloc(fw->size + 1, GFP_ATOMIC);
-                       if (!dgap_config_buf) {
-                               release_firmware(fw);
-                               return -ENOMEM;
-                       }
+                       release_firmware(fw);
+                       return -ENOMEM;
                }
 
                memcpy(dgap_config_buf, fw->data, fw->size);
                release_firmware(fw);
                dgap_config_buf[fw->size + 1] = '\0';
 
-               if (dgap_parsefile(&dgap_config_buf, TRUE) != 0)
+               if (dgap_parsefile(&dgap_config_buf, TRUE) != 0) {
+                       kfree(dgap_config_buf);
                        return -EINVAL;
+               }
+               kfree(dgap_config_buf);
        }
 
        ret = dgap_after_config_loaded(brd->boardnum);
@@ -926,8 +890,9 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type)
                release_firmware(fw);
 
                /* Wait for BIOS to test board... */
-               if (!dgap_do_wait_for_bios(brd))
-                       return -ENXIO;
+               ret = dgap_test_bios(brd);
+               if (ret)
+                       return ret;
        }
 
        if (fw_info[card_type].fep_name) {
@@ -942,8 +907,9 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type)
                release_firmware(fw);
 
                /* Wait for FEP to load on board... */
-               if (!dgap_do_wait_for_fep(brd))
-                       return -ENXIO;
+               ret = dgap_test_fep(brd);
+               if (ret)
+                       return ret;
        }
 
 #ifdef DIGI_CONCENTRATORS_SUPPORTED
@@ -1197,7 +1163,6 @@ static void dgap_init_globals(void)
        init_timer(&dgap_poll_timer);
 
        init_waitqueue_head(&dgap_dl_wait);
-       dgap_dl_action = 0;
 }
 
 /************************************************************************
@@ -1328,8 +1293,8 @@ static int dgap_tty_init(struct board_t *brd)
        int i;
        int tlw;
        uint true_count = 0;
-       uchar *vaddr;
-       uchar modem = 0;
+       u8 *vaddr;
+       u8 modem = 0;
        struct channel_t *ch;
        struct bs_t *bs;
        struct cm_t *cm;
@@ -1540,8 +1505,8 @@ static void dgap_tty_uninit(struct board_t *brd)
  * dgap_sniff - Dump data out to the "sniff" buffer if the
  * proc sniff file is opened...
  */
-static void dgap_sniff_nowait_nolock(struct channel_t *ch, uchar *text,
-                                    uchar *buf, int len)
+static void dgap_sniff_nowait_nolock(struct channel_t *ch, u8 *text,
+                                    u8 *buf, int len)
 {
        struct timeval tv;
        int n;
@@ -1675,8 +1640,8 @@ static void dgap_input(struct channel_t *ch)
        int flip_len;
        int len = 0;
        int n = 0;
-       uchar *buf;
-       uchar tmpchar;
+       u8 *buf;
+       u8 tmpchar;
        int s = 0;
 
        if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
@@ -2445,7 +2410,7 @@ static int dgap_tty_chars_in_buffer(struct tty_struct *tty)
        struct channel_t *ch = NULL;
        struct un_t *un = NULL;
        struct bs_t *bs = NULL;
-       uchar tbusy;
+       u8 tbusy;
        uint chars = 0;
        u16 thead, ttail, tmask, chead, ctail;
        ulong   lock_flags = 0;
@@ -2878,8 +2843,8 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf,
                n -= remain;
                vaddr = ch->ch_taddr + head;
 
-               memcpy_toio(vaddr, (uchar *) buf, remain);
-               dgap_sniff_nowait_nolock(ch, "USER WRITE", (uchar *) buf,
+               memcpy_toio(vaddr, (u8 *) buf, remain);
+               dgap_sniff_nowait_nolock(ch, "USER WRITE", (u8 *) buf,
                                        remain);
 
                head = ch->ch_tstart;
@@ -2894,8 +2859,8 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf,
                vaddr = ch->ch_taddr + head;
                remain = n;
 
-               memcpy_toio(vaddr, (uchar *) buf, remain);
-               dgap_sniff_nowait_nolock(ch, "USER WRITE", (uchar *)buf,
+               memcpy_toio(vaddr, (u8 *) buf, remain);
+               dgap_sniff_nowait_nolock(ch, "USER WRITE", (u8 *)buf,
                                        remain);
 
                head += remain;
@@ -2950,7 +2915,7 @@ static int dgap_tty_tiocmget(struct tty_struct *tty)
        struct channel_t *ch;
        struct un_t *un;
        int result = -EIO;
-       uchar mstat = 0;
+       u8 mstat = 0;
        ulong lock_flags;
 
        if (!tty || tty->magic != TTY_MAGIC)
@@ -3176,7 +3141,7 @@ static void dgap_tty_send_xchar(struct tty_struct *tty, char c)
 static int dgap_get_modem_info(struct channel_t *ch, unsigned int __user *value)
 {
        int result = 0;
-       uchar mstat = 0;
+       u8 mstat = 0;
        ulong lock_flags;
        int rc = 0;
 
@@ -4336,9 +4301,9 @@ static int dgap_tty_register_ports(struct board_t *brd)
  * Copies the BIOS code from the user to the board,
  * and starts the BIOS running.
  */
-static void dgap_do_bios_load(struct board_t *brd, const uchar *ubios, int len)
+static void dgap_do_bios_load(struct board_t *brd, const u8 *ubios, int len)
 {
-       uchar *addr;
+       u8 *addr;
        uint offset;
        int i;
 
@@ -4369,16 +4334,15 @@ static void dgap_do_bios_load(struct board_t *brd, const uchar *ubios, int len)
 /*
  * Checks to see if the BIOS completed running on the card.
  */
-static int dgap_do_wait_for_bios(struct board_t *brd)
+static int dgap_test_bios(struct board_t *brd)
 {
-       uchar *addr;
+       u8 *addr;
        u16 word;
        u16 err1;
        u16 err2;
-       int ret = 0;
 
        if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase)
-               return ret;
+               return -EINVAL;
 
        addr = brd->re_map_membase;
        word = readw(addr + POSTAREA);
@@ -4392,7 +4356,7 @@ static int dgap_do_wait_for_bios(struct board_t *brd)
        while (brd->wait_for_bios < 1000) {
                /* Check to see if BIOS thinks board is good. (GD). */
                if (word == *(u16 *) "GD")
-                       return 1;
+                       return 0;
                msleep_interruptible(10);
                brd->wait_for_bios++;
                word = readw(addr + POSTAREA);
@@ -4406,16 +4370,16 @@ static int dgap_do_wait_for_bios(struct board_t *brd)
        brd->state = BOARD_FAILED;
        brd->dpastatus = BD_NOBIOS;
 
-       return ret;
+       return -EIO;
 }
 
 /*
  * Copies the FEP code from the user to the board,
  * and starts the FEP running.
  */
-static void dgap_do_fep_load(struct board_t *brd, const uchar *ufep, int len)
+static void dgap_do_fep_load(struct board_t *brd, const u8 *ufep, int len)
 {
-       uchar *addr;
+       u8 *addr;
        uint offset;
 
        if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase)
@@ -4434,8 +4398,8 @@ static void dgap_do_fep_load(struct board_t *brd, const uchar *ufep, int len)
         * it its config string describing how the concentrators look.
         */
        if ((brd->type == PCX) || (brd->type == PEPC)) {
-               uchar string[100];
-               uchar *config, *xconfig;
+               u8 string[100];
+               u8 *config, *xconfig;
                int i = 0;
 
                xconfig = dgap_create_config_string(brd, string);
@@ -4457,16 +4421,15 @@ static void dgap_do_fep_load(struct board_t *brd, const uchar *ufep, int len)
 /*
  * Waits for the FEP to report thats its ready for us to use.
  */
-static int dgap_do_wait_for_fep(struct board_t *brd)
+static int dgap_test_fep(struct board_t *brd)
 {
-       uchar *addr;
+       u8 *addr;
        u16 word;
        u16 err1;
        u16 err2;
-       int ret = 0;
 
        if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase)
-               return ret;
+               return -EINVAL;
 
        addr = brd->re_map_membase;
        word = readw(addr + FEPSTAT);
@@ -4486,7 +4449,7 @@ static int dgap_do_wait_for_fep(struct board_t *brd)
                        if (word == *(u16 *) "5A")
                                brd->bd_flags |= BD_FEP5PLUS;
 
-                       return 1;
+                       return 0;
                }
                msleep_interruptible(10);
                brd->wait_for_fep++;
@@ -4501,7 +4464,7 @@ static int dgap_do_wait_for_fep(struct board_t *brd)
        brd->state = BOARD_FAILED;
        brd->dpastatus = BD_NOFEP;
 
-       return ret;
+       return -EIO;
 }
 
 /*
@@ -4509,7 +4472,7 @@ static int dgap_do_wait_for_fep(struct board_t *brd)
  */
 static void dgap_do_reset_board(struct board_t *brd)
 {
-       uchar check;
+       u8 check;
        u32 check1;
        u32 check2;
        int i = 0;
@@ -4557,7 +4520,7 @@ static void dgap_do_reset_board(struct board_t *brd)
 /*
  * Sends a concentrator image into the FEP5 board.
  */
-static void dgap_do_conc_load(struct board_t *brd, uchar *uaddr, int len)
+static void dgap_do_conc_load(struct board_t *brd, u8 *uaddr, int len)
 {
        char *vaddr;
        u16 offset = 0;
@@ -4590,8 +4553,8 @@ static void dgap_get_vpd(struct board_t *brd)
        u16 vpd_offset;
        u16 image_length;
        u16 i;
-       uchar byte1;
-       uchar byte2;
+       u8 byte1;
+       u8 byte2;
 
        /*
         * Poke the magic number at the PCI Rom Address location.
@@ -4770,8 +4733,8 @@ out:
  *                        in the cmd buffer before returning.
  *
  *=======================================================================*/
-static void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1,
-                       uchar byte2, uint ncmds)
+static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 byte1,
+                       u8 byte2, uint ncmds)
 {
        char            *vaddr = NULL;
        struct cm_t     *cm_addr = NULL;
@@ -4813,7 +4776,7 @@ static void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1,
         * Put the data in the circular command buffer.
         */
        writeb(cmd, (char *) (vaddr + head + CMDSTART + 0));
-       writeb((uchar) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1));
+       writeb((u8) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1));
        writeb(byte1, (char *) (vaddr + head + CMDSTART + 2));
        writeb(byte2, (char *) (vaddr + head + CMDSTART + 3));
 
@@ -4856,7 +4819,7 @@ static void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1,
  *                        in the cmd buffer before returning.
  *
  *=======================================================================*/
-static void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds)
+static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 word, uint ncmds)
 {
        char            *vaddr = NULL;
        struct cm_t     *cm_addr = NULL;
@@ -4897,7 +4860,7 @@ static void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds)
         * Put the data in the circular command buffer.
         */
        writeb(cmd, (char *) (vaddr + head + CMDSTART + 0));
-       writeb((uchar) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1));
+       writeb((u8) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1));
        writew((u16) word, (char *) (vaddr + head + CMDSTART + 2));
 
        head = (head + 4) & (CMDMAX - CMDSTART - 4);
@@ -4981,9 +4944,9 @@ static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds)
         */
 
        /* Write an FF to tell the FEP that we want an extended command */
-       writeb((uchar) 0xff, (char *) (vaddr + head + CMDSTART + 0));
+       writeb((u8) 0xff, (char *) (vaddr + head + CMDSTART + 0));
 
-       writeb((uchar) ch->ch_portnum, (uchar *) (vaddr + head + CMDSTART + 1));
+       writeb((u8) ch->ch_portnum, (u8 *) (vaddr + head + CMDSTART + 1));
        writew((u16) cmd, (char *) (vaddr + head + CMDSTART + 2));
 
        /*
@@ -5088,7 +5051,7 @@ static void dgap_wmove(struct channel_t *ch, char *buf, uint cnt)
  */
 static uint dgap_get_custom_baud(struct channel_t *ch)
 {
-       uchar *vaddr;
+       u8 *vaddr;
        ulong offset = 0;
        uint value = 0;
 
@@ -5160,8 +5123,8 @@ static int dgap_param(struct tty_struct *tty)
        u16     head;
        u16     cflag;
        u16     iflag;
-       uchar   mval;
-       uchar   hflow;
+       u8      mval;
+       u8      hflow;
 
        if (!tty || tty->magic != TTY_MAGIC)
                return -ENXIO;
@@ -5427,7 +5390,7 @@ static int dgap_param(struct tty_struct *tty)
                ch->ch_hflow = hflow;
 
                /* Okay to have channel and board locks held calling this */
-               dgap_cmdb(ch, SHFLOW, (uchar) hflow, 0xff, 0);
+               dgap_cmdb(ch, SHFLOW, (u8) hflow, 0xff, 0);
        }
 
 
@@ -5455,7 +5418,7 @@ static int dgap_param(struct tty_struct *tty)
                ch->ch_mostat = mval;
 
                /* Okay to have channel and board locks held calling this */
-               dgap_cmdb(ch, SMODEM, (uchar) mval, D_RTS(ch)|D_DTR(ch), 0);
+               dgap_cmdb(ch, SMODEM, (u8) mval, D_RTS(ch)|D_DTR(ch), 0);
        }
 
        /*
@@ -5609,8 +5572,8 @@ static int dgap_event(struct board_t *bd)
        ulong           lock_flags;
        ulong           lock_flags2;
        struct bs_t     *bs;
-       uchar           *event;
-       uchar           *vaddr = NULL;
+       u8              *event;
+       u8              *vaddr = NULL;
        struct ev_t     *eaddr = NULL;
        uint            head;
        uint            tail;
index 6b8f5f8583272f09ac950ff2a5f7cc07d87711d6..b23570bd183dbcabc56fedc3a01e69554b7e95d4 100644 (file)
@@ -39,9 +39,6 @@
 # define FALSE 0
 #endif
 
-/* Required for our shared headers! */
-typedef unsigned char          uchar;
-
 #if !defined(TTY_FLIPBUF_SIZE)
 # define TTY_FLIPBUF_SIZE 512
 #endif
@@ -61,7 +58,7 @@ typedef unsigned char         uchar;
 
 /*
  * defines from dgap_pci.h
- */ 
+ */
 #define PCIMAX 32                      /* maximum number of PCI boards */
 
 #define DIGI_VID               0x114F
@@ -186,7 +183,7 @@ typedef unsigned char               uchar;
                        ECHOCTL | ECHOKE | IEXTEN)
 
 #ifndef _POSIX_VDISABLE
-#define   _POSIX_VDISABLE '\0'
+#define _POSIX_VDISABLE ('\0')
 #endif
 
 #define SNIFF_MAX      65536           /* Sniff buffer size (2^n) */
@@ -207,9 +204,11 @@ typedef unsigned char              uchar;
 #define EVSTART         0x0800L         /* Start of event buffer        */
 #define EVMAX           0x0c00L         /* End of event buffer          */
 #define FEP5_PLUS       0x0E40          /* ASCII '5' and ASCII 'A' is here  */
-#define ECS_SEG         0x0E44          /* Segment of the extended channel structure */
-#define LINE_SPEED      0x10            /* Offset into ECS_SEG for line speed   */
-                                        /* if the fep has extended capabilities */
+#define ECS_SEG         0x0E44          /* Segment of the extended      */
+                                       /* channel structure            */
+#define LINE_SPEED      0x10            /* Offset into ECS_SEG for line */
+                                       /* speed if the fep has extended */
+                                       /* capabilities                 */
 
 /* BIOS MAGIC SPOTS */
 #define ERROR           0x0C14L                /* BIOS error code              */
@@ -247,12 +246,12 @@ typedef unsigned char             uchar;
 
 #define FEPTIMEOUT 200000
 
-#define ENABLE_INTR            0x0e04          /* Enable interrupts flag */
-#define FEPPOLL_MIN            1               /* minimum of 1 millisecond */
-#define FEPPOLL_MAX            20              /* maximum of 20 milliseconds */
-#define FEPPOLL                        0x0c26          /* Fep event poll interval */
+#define ENABLE_INTR    0x0e04          /* Enable interrupts flag */
+#define FEPPOLL_MIN    1               /* minimum of 1 millisecond */
+#define FEPPOLL_MAX    20              /* maximum of 20 milliseconds */
+#define FEPPOLL                0x0c26          /* Fep event poll interval */
 
-#define        IALTPIN                 0x0080          /* Input flag to swap DSR <-> DCD */
+#define        IALTPIN         0x0080          /* Input flag to swap DSR <-> DCD */
 
 /************************************************************************
  * FEP supported functions
@@ -280,14 +279,12 @@ typedef unsigned char             uchar;
 #define SPINTFC                0xfc            /* Reserved                     */
 #define SCOMMODE       0xfd            /* Set RS232/422 mode           */
 
-
 /************************************************************************
  *     Modes for SCOMMODE
  ************************************************************************/
 #define MODE_232       0x00
 #define MODE_422       0x01
 
-
 /************************************************************************
  *      Event flags.
  ************************************************************************/
@@ -362,13 +359,13 @@ typedef unsigned char             uchar;
 #define MC8E8K  36
 
 #define AVANFS 42      /* start of Avanstar family definitions */
-#define A8P    42
+#define A8P    42
 #define A16P   43
 #define AVANFE 43      /* end of Avanstar family definitions */
 
-#define DA2000FS       44      /* start of AccelePort 2000 family definitions */
-#define DA22           44 /* AccelePort 2002 */
-#define DA24           45 /* AccelePort 2004 */
+#define DA2000FS       44 /* start of AccelePort 2000 family definitions */
+#define DA22           44 /* AccelePort 2002 */
+#define DA24           45 /* AccelePort 2004 */
 #define DA28           46 /* AccelePort 2008 */
 #define DA216          47 /* AccelePort 2016 */
 #define DAR4           48 /* AccelePort RAS 4 port */
@@ -492,8 +489,6 @@ enum {
        REQUESTED_CONCENTRATOR
 };
 
-
-
 /*
  * Modem line constants are defined as macros because DSR and
  * DCD are swapable using the ditty altpin option.
@@ -505,14 +500,12 @@ enum {
 #define D_RI(ch)        DM_RI           /* Ring indicator       */
 #define D_DTR(ch)       DM_DTR          /* Data terminal ready  */
 
-
 /*************************************************************************
  *
  * Structures and closely related defines.
  *
  *************************************************************************/
 
-
 /*
  * A structure to hold a statistics counter.  We also
  * compute moving averages for this counter.
@@ -524,7 +517,6 @@ struct macounter {
        ulong           ema;    /* Exponential moving average */
 };
 
-
 /************************************************************************
  * Device flag definitions for bd_flags.
  ************************************************************************/
@@ -546,11 +538,11 @@ struct board_t {
        u16             device;         /* PCI device ID */
        u16             subvendor;      /* PCI subsystem vendor ID */
        u16             subdevice;      /* PCI subsystem device ID */
-       uchar           rev;            /* PCI revision ID */
+       u8              rev;            /* PCI revision ID */
        uint            pci_bus;        /* PCI bus value */
        uint            pci_slot;       /* PCI slot value */
        u16             maxports;       /* MAX ports this board can handle */
-       uchar           vpd[VPDSIZE];   /* VPD of board, if found */
+       u8              vpd[VPDSIZE];   /* VPD of board, if found */
        u32             bd_flags;       /* Board flags */
 
        spinlock_t      bd_lock;        /* Used to protect board */
@@ -571,20 +563,22 @@ struct board_t {
        ulong           irq;            /* Interrupt request number */
        ulong           intr_count;     /* Count of interrupts */
        u32             intr_used;      /* Non-zero if using interrupts */
-       u32             intr_running;   /* Non-zero if FEP knows its doing interrupts */
+       u32             intr_running;   /* Non-zero if FEP knows its doing */
+                                       /* interrupts */
 
        ulong           port;           /* Start of base io port of the card */
        ulong           port_end;       /* End of base io port of the card */
        ulong           membase;        /* Start of base memory of the card */
        ulong           membase_end;    /* End of base memory of the card */
 
-       uchar           *re_map_port;   /* Remapped io port of the card */
-       uchar           *re_map_membase;/* Remapped memory of the card */
+       u8              *re_map_port;   /* Remapped io port of the card */
+       u8              *re_map_membase;/* Remapped memory of the card */
 
-       uchar           runwait;        /* # Processes waiting for FEP  */
-       uchar           inhibit_poller; /* Tells  the poller to leave us alone */
+       u8              runwait;        /* # Processes waiting for FEP  */
+       u8              inhibit_poller; /* Tells the poller to leave us alone */
 
-       struct channel_t *channels[MAXPORTS]; /* array of pointers to our channels. */
+       struct channel_t *channels[MAXPORTS]; /* array of pointers to our */
+                                             /* channels.                */
 
        struct tty_driver       *SerialDriver;
        struct tty_port *SerialPorts;
@@ -599,20 +593,23 @@ struct board_t {
        u32             dgap_Serial_Major;
        u32             dgap_TransparentPrint_Major;
 
-       struct bs_t     *bd_bs;                 /* Base structure pointer       */
+       struct bs_t     *bd_bs;         /* Base structure pointer         */
 
-       char    *flipbuf;               /* Our flip buffer, alloced if board is found */
-       char    *flipflagbuf;           /* Our flip flag buffer, alloced if board is found */
+       char    *flipbuf;               /* Our flip buffer, alloced if    */
+                                       /* board is found                 */
+       char    *flipflagbuf;           /* Our flip flag buffer, alloced  */
+                                       /* if board is found              */
 
-       u16             dpatype;        /* The board "type", as defined by DPA */
-       u16             dpastatus;      /* The board "status", as defined by DPA */
-       wait_queue_head_t kme_wait;     /* Needed for DPA support */
+       u16             dpatype;        /* The board "type", as defined   */
+                                       /* by DPA                         */
+       u16             dpastatus;      /* The board "status", as defined */
+                                       /* by DPA                         */
+       wait_queue_head_t kme_wait;     /* Needed for DPA support         */
 
-       u32             conc_dl_status; /* Status of any pending conc download */
+       u32             conc_dl_status; /* Status of any pending conc     */
+                                       /* download                       */
 };
 
-
-
 /************************************************************************
  * Unit flag definitions for un_flags.
  ************************************************************************/
@@ -650,7 +647,6 @@ struct un_t {
        struct device *un_sysfs;
 };
 
-
 /************************************************************************
  * Device flag definitions for ch_flags.
  ************************************************************************/
@@ -677,7 +673,6 @@ struct un_t {
 #define SNIFF_WAIT_DATA        0x2
 #define SNIFF_WAIT_SPACE 0x4
 
-
 /************************************************************************
  ***   Definitions for Digi ditty(1) command.
  ************************************************************************/
@@ -689,8 +684,8 @@ struct un_t {
 
 #if !defined(TIOCMODG)
 
-#define        TIOCMODG        (('d'<<8) | 250)                /* get modem ctrl state */
-#define        TIOCMODS        (('d'<<8) | 251)                /* set modem ctrl state */
+#define        TIOCMODG        (('d'<<8) | 250)        /* get modem ctrl state */
+#define        TIOCMODS        (('d'<<8) | 251)        /* set modem ctrl state */
 
 #ifndef TIOCM_LE
 #define                TIOCM_LE        0x01            /* line enable          */
@@ -709,16 +704,15 @@ struct un_t {
 #endif
 
 #if !defined(TIOCMSET)
-#define        TIOCMSET        (('d'<<8) | 252)                /* set modem ctrl state */
-#define        TIOCMGET        (('d'<<8) | 253)                /* set modem ctrl state */
+#define        TIOCMSET        (('d'<<8) | 252)        /* set modem ctrl state */
+#define        TIOCMGET        (('d'<<8) | 253)        /* set modem ctrl state */
 #endif
 
 #if !defined(TIOCMBIC)
-#define        TIOCMBIC        (('d'<<8) | 254)                /* set modem ctrl state */
-#define        TIOCMBIS        (('d'<<8) | 255)                /* set modem ctrl state */
+#define        TIOCMBIC        (('d'<<8) | 254)        /* set modem ctrl state */
+#define        TIOCMBIS        (('d'<<8) | 255)        /* set modem ctrl state */
 #endif
 
-
 #if !defined(TIOCSDTR)
 #define        TIOCSDTR        (('e'<<8) | 0)          /* set DTR              */
 #define        TIOCCDTR        (('e'<<8) | 1)          /* clear DTR            */
@@ -737,26 +731,25 @@ struct un_t {
                                                /* Adapter Memory       */
 
 #define        DIGI_GETFLOW    (('e'<<8) | 99)         /* Get startc/stopc flow */
-                                               /* control characters    */
-#define        DIGI_SETFLOW    (('e'<<8) | 100)                /* Set startc/stopc flow */
+                                               /* control characters    */
+#define        DIGI_SETFLOW    (('e'<<8) | 100)        /* Set startc/stopc flow */
                                                /* control characters    */
-#define        DIGI_GETAFLOW   (('e'<<8) | 101)                /* Get Aux. startc/stopc */
-                                               /* flow control chars    */
-#define        DIGI_SETAFLOW   (('e'<<8) | 102)                /* Set Aux. startc/stopc */
+#define        DIGI_GETAFLOW   (('e'<<8) | 101)        /* Get Aux. startc/stopc */
+                                               /* flow control chars    */
+#define        DIGI_SETAFLOW   (('e'<<8) | 102)        /* Set Aux. startc/stopc */
                                                /* flow control chars    */
 
-#define DIGI_GEDELAY   (('d'<<8) | 246)                /* Get edelay */
-#define DIGI_SEDELAY   (('d'<<8) | 247)                /* Set edelay */
+#define DIGI_GEDELAY   (('d'<<8) | 246)        /* Get edelay */
+#define DIGI_SEDELAY   (('d'<<8) | 247)        /* Set edelay */
 
 struct digiflow_t {
-       unsigned char   startc;                         /* flow cntl start char */
-       unsigned char   stopc;                          /* flow cntl stop char  */
+       unsigned char   startc;                 /* flow cntl start char */
+       unsigned char   stopc;                  /* flow cntl stop char  */
 };
 
-
 #ifdef FLOW_2200
-#define        F2200_GETA      (('e'<<8) | 104)                /* Get 2x36 flow cntl flags */
-#define        F2200_SETAW     (('e'<<8) | 105)                /* Set 2x36 flow cntl flags */
+#define        F2200_GETA      (('e'<<8) | 104)        /* Get 2x36 flow cntl flags */
+#define        F2200_SETAW     (('e'<<8) | 105)        /* Set 2x36 flow cntl flags */
 #define                F2200_MASK      0x03            /* 2200 flow cntl bit mask  */
 #define                FCNTL_2200      0x01            /* 2x36 terminal flow cntl  */
 #define                PCNTL_2200      0x02            /* 2x36 printer flow cntl   */
@@ -830,59 +823,6 @@ struct rw_t {
        unsigned char   rw_data[128];   /* Data to read/write           */
 };
 
-/***********************************************************************
- * Shrink Buffer and Board Information definitions and structures.
-
- ************************************************************************/
-                       /* Board type return codes */
-#define        PCXI_TYPE 1     /* Board type at the designated port is a PC/Xi */
-#define PCXM_TYPE 2     /* Board type at the designated port is a PC/Xm */
-#define        PCXE_TYPE 3     /* Board type at the designated port is a PC/Xe */
-#define        MCXI_TYPE 4     /* Board type at the designated port is a MC/Xi */
-#define COMXI_TYPE 5     /* Board type at the designated port is a COM/Xi */
-
-                        /* Non-Zero Result codes. */
-#define RESULT_NOBDFND 1 /* A Digi product at that port is not config installed */
-#define RESULT_NODESCT 2 /* A memory descriptor was not obtainable */
-#define RESULT_NOOSSIG 3 /* FEP/OS signature was not detected on the board */
-#define RESULT_TOOSML  4 /* Too small an area to shrink.  */
-#define RESULT_NOCHAN  5 /* Channel structure for the board was not found */
-
-struct shrink_buf_struct {
-       unsigned long   shrink_buf_vaddr;       /* Virtual address of board */
-       unsigned long   shrink_buf_phys;        /* Physical address of board */
-       unsigned long   shrink_buf_bseg;        /* Amount of board memory */
-       unsigned long   shrink_buf_hseg;        /* '186 Beginning of Dual-Port */
-
-       unsigned long   shrink_buf_lseg;        /* '186 Beginning of freed memory                                               */
-       unsigned long   shrink_buf_mseg;        /* Linear address from start of
-                                                  dual-port were freed memory
-                                                  begins, host viewpoint. */
-
-       unsigned long   shrink_buf_bdparam;     /* Parameter for xxmemon and
-                                                  xxmemoff */
-
-       unsigned long   shrink_buf_reserva;     /* Reserved */
-       unsigned long   shrink_buf_reservb;     /* Reserved */
-       unsigned long   shrink_buf_reservc;     /* Reserved */
-       unsigned long   shrink_buf_reservd;     /* Reserved */
-
-       unsigned char   shrink_buf_result;      /* Reason for call failing
-                                                  Zero is Good return */
-       unsigned char   shrink_buf_init;        /* Non-Zero if it caused an
-                                                  xxinit call. */
-
-       unsigned char   shrink_buf_anports;     /* Number of async ports  */
-       unsigned char   shrink_buf_snports;     /* Number of sync  ports */
-       unsigned char   shrink_buf_type;        /* Board type 1 = PC/Xi,
-                                                             2 = PC/Xm,
-                                                             3 = PC/Xe
-                                                             4 = MC/Xi
-                                                             5 = COMX/i */
-       unsigned char   shrink_buf_card;        /* Card number */
-
-};
-
 /************************************************************************
  * Structure to get driver status information
  ************************************************************************/
@@ -892,7 +832,7 @@ struct digi_dinfo {
        char            dinfo_version[16];      /* driver version       */
 };
 
-#define        DIGI_GETDD      (('d'<<8) | 248)                /* get driver info      */
+#define        DIGI_GETDD      (('d'<<8) | 248)        /* get driver info      */
 
 /************************************************************************
  * Structure used with ioctl commands for per-board information
@@ -912,7 +852,7 @@ struct digi_info {
        char            info_reserved[7];       /* for future expansion    */
 };
 
-#define        DIGI_GETBD      (('d'<<8) | 249)                /* get board info          */
+#define        DIGI_GETBD      (('d'<<8) | 249)        /* get board info          */
 
 struct digi_stat {
        unsigned int    info_chan;              /* Channel number (0 based)  */
@@ -927,7 +867,7 @@ struct digi_stat {
        unsigned long   info_reserved[8];       /* for future expansion    */
 };
 
-#define        DIGI_GETSTAT    (('d'<<8) | 244)                /* get board info          */
+#define        DIGI_GETSTAT    (('d'<<8) | 244)        /* get board info          */
 /************************************************************************
  *
  * Structure used with ioctl commands for per-channel information
@@ -936,9 +876,9 @@ struct digi_stat {
 struct digi_ch {
        unsigned long   info_bdnum;             /* Board number (0 based)  */
        unsigned long   info_channel;           /* Channel index number    */
-       unsigned long   info_ch_cflag;          /* Channel cflag           */
-       unsigned long   info_ch_iflag;          /* Channel iflag           */
-       unsigned long   info_ch_oflag;          /* Channel oflag           */
+       unsigned long   info_ch_cflag;          /* Channel cflag           */
+       unsigned long   info_ch_iflag;          /* Channel iflag           */
+       unsigned long   info_ch_oflag;          /* Channel oflag           */
        unsigned long   info_chsize;            /* Channel structure size  */
        unsigned long   info_sleep_stat;        /* sleep status            */
        dev_t           info_dev;               /* device number           */
@@ -970,7 +910,7 @@ struct digi_cmd {
 #define INFO_CH_WLOW   0x0020
 #define INFO_XXBUF_BUSY 0x0040
 
-#define        DIGI_GETCH      (('d'<<8) | 245)                /* get board info          */
+#define        DIGI_GETCH      (('d'<<8) | 245)        /* get board info          */
 
 /* Board type definitions */
 
@@ -1015,12 +955,13 @@ struct digi_cmd {
 #define BD_TRIBOOT     0x8
 #define        BD_BADKME       0x80
 
-#define DIGI_LOOPBACK        (('d'<<8) | 252)          /* Enable/disable UART internal loopback */
-#define DIGI_SPOLL            (('d'<<8) | 254)         /* change poller rate   */
+#define DIGI_LOOPBACK  (('d'<<8) | 252)        /* Enable/disable UART  */
+                                               /* internal loopback    */
+#define DIGI_SPOLL     (('d'<<8) | 254)        /* change poller rate   */
 
-#define DIGI_SETCUSTOMBAUD     _IOW('e', 106, int)     /* Set integer baud rate */
-#define DIGI_GETCUSTOMBAUD     _IOR('e', 107, int)     /* Get integer baud rate */
-#define DIGI_RESET_PORT                (('e'<<8) | 93)         /* Reset port           */
+#define DIGI_SETCUSTOMBAUD _IOW('e', 106, int) /* Set integer baud rate */
+#define DIGI_GETCUSTOMBAUD _IOR('e', 107, int) /* Get integer baud rate */
+#define DIGI_RESET_PORT           (('e'<<8) | 93)      /* Reset port            */
 
 /************************************************************************
  * Channel information structure.
@@ -1041,14 +982,14 @@ struct channel_t {
        wait_queue_head_t ch_flags_wait;
 
        u32     pscan_state;
-       uchar   pscan_savechar;
+       u8      pscan_savechar;
 
        u32 ch_portnum;                 /* Port number, 0 offset.       */
        u32 ch_open_count;              /* open count                   */
        u32     ch_flags;               /* Channel flags                */
 
-
-       u32     ch_close_delay;         /* How long we should drop RTS/DTR for */
+       u32     ch_close_delay;         /* How long we should drop      */
+                                       /* RTS/DTR for                  */
 
        u32     ch_cpstime;             /* Time for CPS calculations    */
 
@@ -1057,7 +998,7 @@ struct channel_t {
        tcflag_t ch_c_oflag;            /* channel oflags               */
        tcflag_t ch_c_lflag;            /* channel lflags               */
 
-       u16  ch_fepiflag;            /* FEP tty iflags               */
+       u16  ch_fepiflag;               /* FEP tty iflags               */
        u16  ch_fepcflag;               /* FEP tty cflags               */
        u16  ch_fepoflag;               /* FEP tty oflags               */
        u16  ch_wopen;                  /* Waiting for open process cnt */
@@ -1071,33 +1012,33 @@ struct channel_t {
 
        u16  ch_cook;                   /* Output character mask        */
 
-       uchar   ch_card;                /* Card channel is on           */
-       uchar   ch_stopc;               /* Stop character               */
-       uchar   ch_startc;              /* Start character              */
-
-       uchar   ch_mostat;              /* FEP output modem status      */
-       uchar   ch_mistat;              /* FEP input modem status       */
-       uchar   ch_mforce;              /* Modem values to be forced    */
-       uchar   ch_mval;                /* Force values                 */
-       uchar   ch_fepstopc;            /* FEP stop character           */
-       uchar   ch_fepstartc;           /* FEP start character          */
-
-       uchar   ch_astopc;              /* Auxiliary Stop character     */
-       uchar   ch_astartc;             /* Auxiliary Start character    */
-       uchar   ch_fepastopc;           /* Auxiliary FEP stop char      */
-       uchar   ch_fepastartc;          /* Auxiliary FEP start char     */
-
-       uchar   ch_hflow;               /* FEP hardware handshake       */
-       uchar   ch_dsr;                 /* stores real dsr value        */
-       uchar   ch_cd;                  /* stores real cd value         */
-       uchar   ch_tx_win;              /* channel tx buffer window     */
-       uchar   ch_rx_win;              /* channel rx buffer window     */
+       u8   ch_card;                   /* Card channel is on           */
+       u8   ch_stopc;                  /* Stop character               */
+       u8   ch_startc;                 /* Start character              */
+
+       u8   ch_mostat;                 /* FEP output modem status      */
+       u8   ch_mistat;                 /* FEP input modem status       */
+       u8   ch_mforce;                 /* Modem values to be forced    */
+       u8   ch_mval;                   /* Force values                 */
+       u8   ch_fepstopc;               /* FEP stop character           */
+       u8   ch_fepstartc;              /* FEP start character          */
+
+       u8   ch_astopc;                 /* Auxiliary Stop character     */
+       u8   ch_astartc;                /* Auxiliary Start character    */
+       u8   ch_fepastopc;              /* Auxiliary FEP stop char      */
+       u8   ch_fepastartc;             /* Auxiliary FEP start char     */
+
+       u8   ch_hflow;                  /* FEP hardware handshake       */
+       u8   ch_dsr;                    /* stores real dsr value        */
+       u8   ch_cd;                     /* stores real cd value         */
+       u8   ch_tx_win;                 /* channel tx buffer window     */
+       u8   ch_rx_win;                 /* channel rx buffer window     */
        uint    ch_custom_speed;        /* Custom baud, if set          */
-       uint    ch_baud_info;           /* Current baud info for /proc output   */
-       ulong   ch_rxcount;             /* total of data received so far        */
-       ulong   ch_txcount;             /* total of data transmitted so far     */
-       ulong   ch_err_parity;          /* Count of parity errors on channel    */
-       ulong   ch_err_frame;           /* Count of framing errors on channel   */
+       uint    ch_baud_info;           /* Current baud info for /proc output */
+       ulong   ch_rxcount;             /* total of data received so far      */
+       ulong   ch_txcount;             /* total of data transmitted so far   */
+       ulong   ch_err_parity;          /* Count of parity errors on channel  */
+       ulong   ch_err_frame;           /* Count of framing errors on channel */
        ulong   ch_err_break;           /* Count of breaks on channel   */
        ulong   ch_err_overrun;         /* Count of overruns on channel */
 
@@ -1112,34 +1053,34 @@ struct channel_t {
  * Command structure definition.
  ************************************************************************/
 struct cm_t {
-       volatile unsigned short cm_head;        /* Command buffer head offset   */
-       volatile unsigned short cm_tail;        /* Command buffer tail offset   */
-       volatile unsigned short cm_start;       /* start offset of buffer       */
-       volatile unsigned short cm_max;         /* last offset of buffer        */
+       unsigned short cm_head;         /* Command buffer head offset */
+       unsigned short cm_tail;         /* Command buffer tail offset */
+       unsigned short cm_start;        /* start offset of buffer     */
+       unsigned short cm_max;          /* last offset of buffer      */
 };
 
 /************************************************************************
  * Event structure definition.
  ************************************************************************/
 struct ev_t {
-       volatile unsigned short ev_head;        /* Command buffer head offset   */
-       volatile unsigned short ev_tail;        /* Command buffer tail offset   */
-       volatile unsigned short ev_start;       /* start offset of buffer       */
-       volatile unsigned short ev_max;         /* last offset of buffer        */
+       unsigned short ev_head;         /* Command buffer head offset */
+       unsigned short ev_tail;         /* Command buffer tail offset */
+       unsigned short ev_start;        /* start offset of buffer     */
+       unsigned short ev_max;          /* last offset of buffer      */
 };
 
 /************************************************************************
  * Download buffer structure.
  ************************************************************************/
 struct downld_t {
-       uchar   dl_type;                /* Header                       */
-       uchar   dl_seq;                 /* Download sequence            */
+       u8      dl_type;                /* Header                       */
+       u8      dl_seq;                 /* Download sequence            */
        ushort  dl_srev;                /* Software revision number     */
        ushort  dl_lrev;                /* Low revision number          */
        ushort  dl_hrev;                /* High revision number         */
        ushort  dl_seg;                 /* Start segment address        */
        ushort  dl_size;                /* Number of bytes to download  */
-       uchar   dl_data[1024];          /* Download data                */
+       u8      dl_data[1024];          /* Download data                */
 };
 
 /************************************************************************
@@ -1152,70 +1093,74 @@ struct downld_t {
  *        U = unknown (may be changed w/o notice)                       *
  ************************************************************************/
 struct bs_t {
-       volatile unsigned short  tp_jmp;        /* Transmit poll jump            */
-       volatile unsigned short  tc_jmp;        /* Cooked procedure jump         */
-       volatile unsigned short  ri_jmp;        /* Not currently used            */
-       volatile unsigned short  rp_jmp;        /* Receive poll jump             */
-
-       volatile unsigned short  tx_seg;        /* W  Tx segment         */
-       volatile unsigned short  tx_head;       /* W  Tx buffer head offset     */
-       volatile unsigned short  tx_tail;       /* R  Tx buffer tail offset     */
-       volatile unsigned short  tx_max;        /* W  Tx buffer size - 1         */
-
-       volatile unsigned short  rx_seg;        /* W  Rx segment                */
-       volatile unsigned short  rx_head;       /* W  Rx buffer head offset     */
-       volatile unsigned short  rx_tail;       /* R  Rx buffer tail offset     */
-       volatile unsigned short  rx_max;        /* W  Rx buffer size - 1         */
-
-       volatile unsigned short  tx_lw;         /* W  Tx buffer low water mark  */
-       volatile unsigned short  rx_lw;         /* W  Rx buffer low water mark  */
-       volatile unsigned short  rx_hw;         /* W  Rx buffer high water mark */
-       volatile unsigned short  incr;          /* W  Increment to next channel */
-
-       volatile unsigned short  fepdev;        /* U  SCC device base address    */
-       volatile unsigned short  edelay;        /* W  Exception delay            */
-       volatile unsigned short  blen;          /* W  Break length              */
-       volatile unsigned short  btime;         /* U  Break complete time       */
-
-       volatile unsigned short  iflag;         /* C  UNIX input flags          */
-       volatile unsigned short  oflag;         /* C  UNIX output flags         */
-       volatile unsigned short  cflag;         /* C  UNIX control flags        */
-       volatile unsigned short  wfill[13];     /* U  Reserved for expansion    */
-
-       volatile unsigned char   num;           /* U  Channel number            */
-       volatile unsigned char   ract;          /* U  Receiver active counter   */
-       volatile unsigned char   bstat;         /* U  Break status bits         */
-       volatile unsigned char   tbusy;         /* W  Transmit busy             */
-       volatile unsigned char   iempty;        /* W  Transmit empty event enable */
-       volatile unsigned char   ilow;          /* W  Transmit low-water event enable */
-       volatile unsigned char   idata;         /* W  Receive data interrupt enable */
-       volatile unsigned char   eflag;         /* U  Host event flags          */
-
-       volatile unsigned char   tflag;         /* U  Transmit flags            */
-       volatile unsigned char   rflag;         /* U  Receive flags             */
-       volatile unsigned char   xmask;         /* U  Transmit ready flags      */
-       volatile unsigned char   xval;          /* U  Transmit ready value      */
-       volatile unsigned char   m_stat;        /* RC Modem status bits          */
-       volatile unsigned char   m_change;      /* U  Modem bits which changed  */
-       volatile unsigned char   m_int;         /* W  Modem interrupt enable bits */
-       volatile unsigned char   m_last;        /* U  Last modem status         */
-
-       volatile unsigned char   mtran;         /* C   Unreported modem trans   */
-       volatile unsigned char   orun;          /* C   Buffer overrun occurred  */
-       volatile unsigned char   astartc;       /* W   Auxiliary Xon char       */
-       volatile unsigned char   astopc;        /* W   Auxiliary Xoff char      */
-       volatile unsigned char   startc;        /* W   Xon character             */
-       volatile unsigned char   stopc;         /* W   Xoff character           */
-       volatile unsigned char   vnextc;        /* W   Vnext character           */
-       volatile unsigned char   hflow;         /* C   Software flow control    */
-       
-       volatile unsigned char   fillc;         /* U   Delay Fill character     */
-       volatile unsigned char   ochar;         /* U   Saved output character   */
-       volatile unsigned char   omask;         /* U   Output character mask    */
-
-       volatile unsigned char   bfill[13];     /* U   Reserved for expansion   */
-
-       volatile unsigned char   scc[16];       /* U   SCC registers            */
+       unsigned short  tp_jmp;         /* Transmit poll jump    */
+       unsigned short  tc_jmp;         /* Cooked procedure jump */
+       unsigned short  ri_jmp;         /* Not currently used    */
+       unsigned short  rp_jmp;         /* Receive poll jump     */
+
+       unsigned short  tx_seg;         /* W Tx segment  */
+       unsigned short  tx_head;        /* W Tx buffer head offset */
+       unsigned short  tx_tail;        /* R Tx buffer tail offset */
+       unsigned short  tx_max;         /* W Tx buffer size - 1    */
+
+       unsigned short  rx_seg;         /* W Rx segment     */
+       unsigned short  rx_head;        /* W Rx buffer head offset */
+       unsigned short  rx_tail;        /* R Rx buffer tail offset */
+       unsigned short  rx_max;         /* W Rx buffer size - 1    */
+
+       unsigned short  tx_lw;          /* W Tx buffer low water mark */
+       unsigned short  rx_lw;          /* W Rx buffer low water mark */
+       unsigned short  rx_hw;          /* W Rx buffer high water mark*/
+       unsigned short  incr;           /* W Increment to next channel*/
+
+       unsigned short  fepdev;         /* U SCC device base address  */
+       unsigned short  edelay;         /* W Exception delay          */
+       unsigned short  blen;           /* W Break length             */
+       unsigned short  btime;          /* U Break complete time      */
+
+       unsigned short  iflag;          /* C UNIX input flags         */
+       unsigned short  oflag;          /* C UNIX output flags        */
+       unsigned short  cflag;          /* C UNIX control flags       */
+       unsigned short  wfill[13];      /* U Reserved for expansion   */
+
+       unsigned char   num;            /* U Channel number           */
+       unsigned char   ract;           /* U Receiver active counter  */
+       unsigned char   bstat;          /* U Break status bits        */
+       unsigned char   tbusy;          /* W Transmit busy            */
+       unsigned char   iempty;         /* W Transmit empty event     */
+                                       /* enable                     */
+       unsigned char   ilow;           /* W Transmit low-water event */
+                                       /* enable                     */
+       unsigned char   idata;          /* W Receive data interrupt   */
+                                       /* enable                     */
+       unsigned char   eflag;          /* U Host event flags         */
+
+       unsigned char   tflag;          /* U Transmit flags           */
+       unsigned char   rflag;          /* U Receive flags            */
+       unsigned char   xmask;          /* U Transmit ready flags     */
+       unsigned char   xval;           /* U Transmit ready value     */
+       unsigned char   m_stat;         /* RC Modem status bits       */
+       unsigned char   m_change;       /* U Modem bits which changed */
+       unsigned char   m_int;          /* W Modem interrupt enable   */
+                                       /* bits                       */
+       unsigned char   m_last;         /* U Last modem status        */
+
+       unsigned char   mtran;          /* C Unreported modem trans   */
+       unsigned char   orun;           /* C Buffer overrun occurred  */
+       unsigned char   astartc;        /* W Auxiliary Xon char       */
+       unsigned char   astopc;         /* W Auxiliary Xoff char      */
+       unsigned char   startc;         /* W Xon character            */
+       unsigned char   stopc;          /* W Xoff character           */
+       unsigned char   vnextc;         /* W Vnext character          */
+       unsigned char   hflow;          /* C Software flow control    */
+
+       unsigned char   fillc;          /* U Delay Fill character     */
+       unsigned char   ochar;          /* U Saved output character   */
+       unsigned char   omask;          /* U Output character mask    */
+
+       unsigned char   bfill[13];      /* U Reserved for expansion   */
+
+       unsigned char   scc[16];        /* U SCC registers            */
 };
 
 struct cnode {
@@ -1225,7 +1170,7 @@ struct cnode {
 
        union {
                struct {
-                       char  type;     /* Board Type           */
+                       char  type;     /* Board Type           */
                        long  port;     /* I/O Address          */
                        char  *portstr; /* I/O Address in string */
                        long  addr;     /* Memory Address       */
@@ -1294,29 +1239,17 @@ struct cnode {
                } module;
 
                char *ttyname;
-
                char *cuname;
-
                char *printname;
-
                long majornumber;
-
                long altpin;
-
                long ttysize;
-
                long chsize;
-
                long bssize;
-
                long unsize;
-
                long f2size;
-
                long vpixsize;
-
                long useintr;
        } u;
 };
-
 #endif
index 5e846344550484e2bb22527c0fd10c6c4dcdae33..027906249598a4aa1d41a5c1579d9c44f5803363 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
 #include <linux/kernel.h>
@@ -169,9 +165,9 @@ int dma_fifo_in(struct dma_fifo *fifo, const void *src, int n)
        memcpy(fifo->data, src + l, n - l);
 
        if (FAIL(fifo, addr_check(fifo->done, fifo->in, fifo->in + n) ||
-                       fifo->avail < n,
-                       "fifo corrupt: in:%u out:%u done:%u n:%d avail:%d",
-                       fifo->in, fifo->out, fifo->done, n, fifo->avail))
+                fifo->avail < n,
+                "fifo corrupt: in:%u out:%u done:%u n:%d avail:%d",
+                fifo->in, fifo->out, fifo->done, n, fifo->avail))
                return -ENXIO;
 
        fifo->in += n;
@@ -236,12 +232,12 @@ int dma_fifo_out_pend(struct dma_fifo *fifo, struct dma_pending *pended)
        ++fifo->open;
 
        if (FAIL(fifo, fifo->open > fifo->open_limit,
-                       "past open limit:%d (limit:%d)",
-                       fifo->open, fifo->open_limit))
+                "past open limit:%d (limit:%d)",
+                fifo->open, fifo->open_limit))
                return -ENXIO;
        if (FAIL(fifo, fifo->out & (fifo->align - 1),
-                       "fifo out unaligned:%u (align:%u)",
-                       fifo->out, fifo->align))
+                "fifo out unaligned:%u (align:%u)",
+                fifo->out, fifo->align))
                return -ENXIO;
 
        return len - n;
@@ -264,8 +260,8 @@ int dma_fifo_out_complete(struct dma_fifo *fifo, struct dma_pending *complete)
                return -EINVAL;
 
        if (FAIL(fifo, list_empty(&fifo->pending) != (fifo->open == 0),
-                       "pending list disagrees with open count:%d",
-                       fifo->open))
+                "pending list disagrees with open count:%d",
+                fifo->open))
                return -ENXIO;
 
        tmp = complete->data;
@@ -282,10 +278,10 @@ int dma_fifo_out_complete(struct dma_fifo *fifo, struct dma_pending *complete)
                }
 
                if (FAIL(fifo, pending->out != fifo->done ||
-                               addr_check(fifo->in, fifo->done, pending->next),
-                               "in:%u out:%u done:%u saved:%u next:%u",
-                               fifo->in, fifo->out, fifo->done, pending->out,
-                               pending->next))
+                        addr_check(fifo->in, fifo->done, pending->next),
+                        "in:%u out:%u done:%u saved:%u next:%u",
+                        fifo->in, fifo->out, fifo->done, pending->out,
+                        pending->next))
                        return -ENXIO;
 
                list_del_init(&pending->link);
@@ -300,7 +296,7 @@ int dma_fifo_out_complete(struct dma_fifo *fifo, struct dma_pending *complete)
        if (FAIL(fifo, fifo->open < 0, "open dma:%d < 0", fifo->open))
                return -ENXIO;
        if (FAIL(fifo, fifo->avail > fifo->size, "fifo avail:%d > size:%d",
-                       fifo->avail, fifo->size))
+                fifo->avail, fifo->size))
                return -ENXIO;
 
        return 0;
index a113fe1e6f198323194595ebb6f06ab4d691a768..410988224f89021593e7c3890bcab540278c0f86 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
 #ifndef _DMA_FIFO_H_
@@ -85,15 +81,15 @@ static inline bool dp_is_completed(struct dma_pending *dp)
        return (unsigned long)dp->data & 1UL;
 }
 
-extern void dma_fifo_init(struct dma_fifo *fifo);
-extern int dma_fifo_alloc(struct dma_fifo *fifo, int size, unsigned align,
-                         int tx_limit, int open_limit, gfp_t gfp_mask);
-extern void dma_fifo_free(struct dma_fifo *fifo);
-extern void dma_fifo_reset(struct dma_fifo *fifo);
-extern int dma_fifo_in(struct dma_fifo *fifo, const void *src, int n);
-extern int dma_fifo_out_pend(struct dma_fifo *fifo, struct dma_pending *pended);
-extern int dma_fifo_out_complete(struct dma_fifo *fifo,
-                                struct dma_pending *complete);
+void dma_fifo_init(struct dma_fifo *fifo);
+int dma_fifo_alloc(struct dma_fifo *fifo, int size, unsigned align,
+                  int tx_limit, int open_limit, gfp_t gfp_mask);
+void dma_fifo_free(struct dma_fifo *fifo);
+void dma_fifo_reset(struct dma_fifo *fifo);
+int dma_fifo_in(struct dma_fifo *fifo, const void *src, int n);
+int dma_fifo_out_pend(struct dma_fifo *fifo, struct dma_pending *pended);
+int dma_fifo_out_complete(struct dma_fifo *fifo,
+                         struct dma_pending *complete);
 
 /* returns the # of used bytes in the fifo */
 static inline int dma_fifo_level(struct dma_fifo *fifo)
index b22142ee52625c8bce4130b24cf0e9046544a050..384758b11e3c15ca6b0c96e07c1c399b23d7d159 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -530,7 +526,7 @@ static void fwtty_emit_breaks(struct work_struct *work)
        while (n) {
                t = min(n, 16);
                c = tty_insert_flip_string_fixed_flag(&port->port, buf,
-                               TTY_BREAK, t);
+                                                     TTY_BREAK, t);
                n -= c;
                brk += c;
                if (c < t)
@@ -638,9 +634,9 @@ static void fwtty_port_handler(struct fw_card *card,
 
        switch (tcode) {
        case TCODE_WRITE_QUADLET_REQUEST:
-               if (addr != port->rx_handler.offset || len != 4)
+               if (addr != port->rx_handler.offset || len != 4) {
                        rcode = RCODE_ADDRESS_ERROR;
-               else {
+               else {
                        fwtty_update_port_status(port, *(unsigned *)data);
                        rcode = RCODE_COMPLETE;
                }
@@ -741,7 +737,7 @@ static int fwtty_tx(struct fwtty_port *port, bool drain)
        /* try to write as many dma transactions out as possible */
        n = -EAGAIN;
        while (!tty->stopped && !tty->hw_stopped &&
-                       !test_bit(STOP_TX, &port->flags)) {
+              !test_bit(STOP_TX, &port->flags)) {
                txn = kmem_cache_alloc(fwtty_txn_cache, GFP_ATOMIC);
                if (!txn) {
                        n = -ENOMEM;
@@ -756,11 +752,11 @@ static int fwtty_tx(struct fwtty_port *port, bool drain)
 
                if (n < 0) {
                        kmem_cache_free(fwtty_txn_cache, txn);
-                       if (n == -EAGAIN)
+                       if (n == -EAGAIN) {
                                ++port->stats.tx_stall;
-                       else if (n == -ENODATA)
+                       } else if (n == -ENODATA) {
                                fwtty_profile_data(port->stats.txns, 0);
-                       else {
+                       else {
                                ++port->stats.fifo_errs;
                                fwtty_err_ratelimited(port, "fifo err: %d\n",
                                                      n);
@@ -884,7 +880,7 @@ static void fwserial_destroy(struct kref *kref)
        for (j = 0; j < num_ports; ++i, ++j) {
                port_table_corrupt |= port_table[i] != ports[j];
                WARN_ONCE(port_table_corrupt, "port_table[%d]: %p != ports[%d]: %p",
-                    i, port_table[i], j, ports[j]);
+                         i, port_table[i], j, ports[j]);
 
                port_table[i] = NULL;
        }
@@ -1257,15 +1253,16 @@ static int set_serial_info(struct fwtty_port *port,
                return -EFAULT;
 
        if (tmp.irq != 0 || tmp.port != 0 || tmp.custom_divisor != 0 ||
-                       tmp.baud_base != 400000000)
+           tmp.baud_base != 400000000)
                return -EPERM;
 
        if (!capable(CAP_SYS_ADMIN)) {
                if (((tmp.flags & ~ASYNC_USR_MASK) !=
                     (port->port.flags & ~ASYNC_USR_MASK)))
                        return -EPERM;
-       } else
+       } else {
                port->port.close_delay = tmp.close_delay * HZ / 100;
+       }
 
        return 0;
 }
@@ -1308,9 +1305,9 @@ static void fwtty_set_termios(struct tty_struct *tty, struct ktermios *old)
        spin_lock_bh(&port->lock);
        baud = set_termios(port, tty);
 
-       if ((baud == 0) && (old->c_cflag & CBAUD))
+       if ((baud == 0) && (old->c_cflag & CBAUD)) {
                port->mctrl &= ~(TIOCM_DTR | TIOCM_RTS);
-       else if ((baud != 0) && !(old->c_cflag & CBAUD)) {
+       else if ((baud != 0) && !(old->c_cflag & CBAUD)) {
                if (C_CRTSCTS(tty) || !test_bit(TTY_THROTTLED, &tty->flags))
                        port->mctrl |= TIOCM_DTR | TIOCM_RTS;
                else
@@ -1733,8 +1730,9 @@ static inline int fwserial_send_mgmt_sync(struct fwtty_peer *peer,
                    rcode == RCODE_GENERATION) {
                        fwtty_dbg(&peer->unit, "mgmt write error: %d\n", rcode);
                        continue;
-               } else
+               } else {
                        break;
+               }
        } while (--tries > 0);
        return rcode;
 }
@@ -1809,7 +1807,7 @@ static void fwserial_release_port(struct fwtty_port *port, bool reset)
        port->max_payload = link_speed_to_max_payload(SCODE_100);
        dma_fifo_change_tx_limit(&port->tx_fifo, port->max_payload);
 
-       rcu_assign_pointer(port->peer, NULL);
+       RCU_INIT_POINTER(port->peer, NULL);
        spin_unlock_bh(&port->lock);
 
        if (port->port.console && port->fwcon_ops->notify != NULL)
@@ -1818,7 +1816,7 @@ static void fwserial_release_port(struct fwtty_port *port, bool reset)
 
 static void fwserial_plug_timeout(unsigned long data)
 {
-       struct fwtty_peer *peer = (struct fwtty_peer *) data;
+       struct fwtty_peer *peer = (struct fwtty_peer *)data;
        struct fwtty_port *port;
 
        spin_lock_bh(&peer->lock);
@@ -2242,7 +2240,7 @@ static int fwserial_create(struct fw_unit *unit)
                port->max_payload = link_speed_to_max_payload(SCODE_100);
                dma_fifo_init(&port->tx_fifo);
 
-               rcu_assign_pointer(port->peer, NULL);
+               RCU_INIT_POINTER(port->peer, NULL);
                serial->ports[i] = port;
 
                /* get unique bus addr region for port's status & recv fifo */
@@ -2744,9 +2742,9 @@ static int fwserial_parse_mgmt_write(struct fwtty_peer *peer,
                break;
 
        case FWSC_VIRT_CABLE_UNPLUG_RSP:
-               if (peer->state != FWPS_UNPLUG_PENDING)
+               if (peer->state != FWPS_UNPLUG_PENDING) {
                        rcode = RCODE_CONFLICT_ERROR;
-               else {
+               else {
                        if (be16_to_cpu(pkt->hdr.code) & FWSC_RSP_NACK)
                                fwtty_notice(&peer->unit, "NACK unplug?\n");
                        port = peer_revert_state(peer);
index 93d65b0f0f83d6180a7d3cfb960e05619b081135..183af00532341919406768b0a361b45a2918d9c5 100644 (file)
@@ -5,7 +5,6 @@ Audio
 
 NAND
 ----
-- Switch from spinlock to mutex
 - Remove excess checking of parameters in calls
 - Use dma coherent memory not kmalloc/__pa for the memory (this is just
   a cleanliness issue not a correctness one)
index 7ac2602242f1f4e6527025b0b2566b52e01687f3..9243845418d64f61656f14716c5e79fd13ea3bff 100644 (file)
@@ -147,6 +147,7 @@ static ssize_t goldfish_audio_write(struct file *fp, const char __user *buf,
 
        while (count > 0) {
                ssize_t copy = count;
+
                if (copy > WRITE_BUFFER_SIZE)
                        copy = WRITE_BUFFER_SIZE;
                wait_event_interruptible(data->wait, (data->buffer_status &
index eca0873098cd5fccede95f5034d6a8015ce319cd..2a292df71e7c5d83bf8fdd1a3d86c590c00c73ae 100644 (file)
 #include <linux/vmalloc.h>
 #include <linux/mtd/mtd.h>
 #include <linux/platform_device.h>
+#include <linux/mutex.h>
 
 #include <asm/div64.h>
 
 #include "goldfish_nand_reg.h"
 
 struct goldfish_nand {
-       spinlock_t              lock;
+       struct mutex            lock;
        unsigned char __iomem  *base;
        struct cmd_params       *cmd_params;
        size_t                  mtd_count;
@@ -77,10 +78,9 @@ static u32 goldfish_nand_cmd(struct mtd_info *mtd, enum nand_cmd cmd,
 {
        struct goldfish_nand *nand = mtd->priv;
        u32 rv;
-       unsigned long irq_flags;
        unsigned char __iomem  *base = nand->base;
 
-       spin_lock_irqsave(&nand->lock, irq_flags);
+       mutex_lock(&nand->lock);
        if (goldfish_nand_cmd_with_params(mtd, cmd, addr, len, ptr, &rv)) {
                writel(mtd - nand->mtd, base + NAND_DEV);
                writel((u32)(addr >> 32), base + NAND_ADDR_HIGH);
@@ -90,7 +90,7 @@ static u32 goldfish_nand_cmd(struct mtd_info *mtd, enum nand_cmd cmd,
                writel(cmd, base + NAND_COMMAND);
                rv = readl(base + NAND_RESULT);
        }
-       spin_unlock_irqrestore(&nand->lock, irq_flags);
+       mutex_unlock(&nand->lock);
        return rv;
 }
 
@@ -307,12 +307,11 @@ static int goldfish_nand_init_device(struct platform_device *pdev,
        u32 name_len;
        u32 result;
        u32 flags;
-       unsigned long irq_flags;
        unsigned char __iomem  *base = nand->base;
        struct mtd_info *mtd = &nand->mtd[id];
        char *name;
 
-       spin_lock_irqsave(&nand->lock, irq_flags);
+       mutex_lock(&nand->lock);
        writel(id, base + NAND_DEV);
        flags = readl(base + NAND_DEV_FLAGS);
        name_len = readl(base + NAND_DEV_NAME_LEN);
@@ -329,7 +328,7 @@ static int goldfish_nand_init_device(struct platform_device *pdev,
                "goldfish nand dev%d: size %llx, page %d, extra %d, erase %d\n",
                       id, mtd->size, mtd->writesize,
                       mtd->oobsize, mtd->erasesize);
-       spin_unlock_irqrestore(&nand->lock, irq_flags);
+       mutex_unlock(&nand->lock);
 
        mtd->priv = nand;
 
@@ -405,7 +404,7 @@ static int goldfish_nand_probe(struct platform_device *pdev)
        if (nand == NULL)
                return -ENOMEM;
 
-       spin_lock_init(&nand->lock);
+       mutex_init(&nand->lock);
        nand->base = base;
        nand->mtd_count = num_dev;
        platform_set_drvdata(pdev, nand);
@@ -425,6 +424,7 @@ static int goldfish_nand_remove(struct platform_device *pdev)
 {
        struct goldfish_nand *nand = platform_get_drvdata(pdev);
        int i;
+
        for (i = 0; i < nand->mtd_count; i++) {
                if (nand->mtd[i].name)
                        mtd_device_unregister(&nand->mtd[i]);
index 363329808a4fb88b723abbbdd31193f6c315741f..b87e382ad76898c5bdc6e01d34b8a41d7759196e 100644 (file)
@@ -37,26 +37,6 @@ config AD7606_IFACE_SPI
          Say yes here to include parallel interface support on the AD7606
          ADC driver.
 
-config AD799X
-       tristate "Analog Devices AD799x ADC driver"
-       depends on I2C
-       select IIO_TRIGGER if IIO_BUFFER
-       select AD799X_RING_BUFFER
-       help
-         Say yes here to build support for Analog Devices:
-         ad7991, ad7995, ad7999, ad7992, ad7993, ad7994, ad7997, ad7998
-         i2c analog to digital converters (ADC). Provides direct access
-         via sysfs.
-
-config AD799X_RING_BUFFER
-       bool "Analog Devices AD799x: use ring buffer"
-       depends on AD799X
-       select IIO_BUFFER
-       select IIO_TRIGGERED_BUFFER
-       help
-         Say yes here to include ring buffer support in the AD799X
-         ADC driver.
-
 config AD7780
        tristate "Analog Devices AD7780 and similar ADCs driver"
        depends on SPI
index 3e9fb143d25b4d3fe18ffc7c3abaf0133b51ef6f..afdcd1ff08ff1a775c9254d5d2aacaf4c162e263 100644 (file)
@@ -8,10 +8,6 @@ ad7606-$(CONFIG_AD7606_IFACE_PARALLEL) += ad7606_par.o
 ad7606-$(CONFIG_AD7606_IFACE_SPI) += ad7606_spi.o
 obj-$(CONFIG_AD7606) += ad7606.o
 
-ad799x-y := ad799x_core.o
-ad799x-$(CONFIG_AD799X_RING_BUFFER) += ad799x_ring.o
-obj-$(CONFIG_AD799X) += ad799x.o
-
 obj-$(CONFIG_AD7291) += ad7291.o
 obj-$(CONFIG_AD7780) += ad7780.o
 obj-$(CONFIG_AD7816) += ad7816.o
index 93c7299e83539c2e38edb4d3b10e44867c2333dc..ec89d055cf585b8201f42cdf303cab13609eb3b5 100644 (file)
@@ -14,7 +14,7 @@
  */
 
 /**
- * struct ad7606_platform_data - platform/board specifc information
+ * struct ad7606_platform_data - platform/board specific information
  * @default_os:                default oversampling value {0, 2, 4, 8, 16, 32, 64}
  * @default_range:     default range +/-{5000, 10000} mVolt
  * @gpio_convst:       number of gpio connected to the CONVST pin
@@ -41,7 +41,7 @@ struct ad7606_platform_data {
 };
 
 /**
- * struct ad7606_chip_info - chip specifc information
+ * struct ad7606_chip_info - chip specific information
  * @name:              identification string for chip
  * @int_vref_mv:       the internal reference voltage
  * @channels:          channel specification
index 2369cf28412ed682046e99c715b21a0b778faee5..158d770f961ac289824aaa1d6cfbfbf9314bd265 100644 (file)
@@ -40,7 +40,7 @@
 
 
 /*
- * struct ad7816_chip_info - chip specifc information
+ * struct ad7816_chip_info - chip specific information
  */
 
 struct ad7816_chip_info {
diff --git a/drivers/staging/iio/adc/ad799x.h b/drivers/staging/iio/adc/ad799x.h
deleted file mode 100644 (file)
index fc8c852..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2010-2011 Michael Hennerich, Analog Devices Inc.
- * Copyright (C) 2008-2010 Jonathan Cameron
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * ad799x.h
- */
-
-#ifndef _AD799X_H_
-#define  _AD799X_H_
-
-#define AD799X_CHANNEL_SHIFT                   4
-#define AD799X_STORAGEBITS                     16
-/*
- * AD7991, AD7995 and AD7999 defines
- */
-
-#define AD7991_REF_SEL                         0x08
-#define AD7991_FLTR                            0x04
-#define AD7991_BIT_TRIAL_DELAY                 0x02
-#define AD7991_SAMPLE_DELAY                    0x01
-
-/*
- * AD7992, AD7993, AD7994, AD7997 and AD7998 defines
- */
-
-#define AD7998_FLTR                            0x08
-#define AD7998_ALERT_EN                                0x04
-#define AD7998_BUSY_ALERT                      0x02
-#define AD7998_BUSY_ALERT_POL                  0x01
-
-#define AD7998_CONV_RES_REG                    0x0
-#define AD7998_ALERT_STAT_REG                  0x1
-#define AD7998_CONF_REG                                0x2
-#define AD7998_CYCLE_TMR_REG                   0x3
-
-#define AD7998_DATALOW_REG(x)                  ((x) * 3 + 0x4)
-#define AD7998_DATAHIGH_REG(x)                 ((x) * 3 + 0x5)
-#define AD7998_HYST_REG(x)                     ((x) * 3 + 0x6)
-
-#define AD7998_CYC_MASK                                0x7
-#define AD7998_CYC_DIS                         0x0
-#define AD7998_CYC_TCONF_32                    0x1
-#define AD7998_CYC_TCONF_64                    0x2
-#define AD7998_CYC_TCONF_128                   0x3
-#define AD7998_CYC_TCONF_256                   0x4
-#define AD7998_CYC_TCONF_512                   0x5
-#define AD7998_CYC_TCONF_1024                  0x6
-#define AD7998_CYC_TCONF_2048                  0x7
-
-#define AD7998_ALERT_STAT_CLEAR                        0xFF
-
-/*
- * AD7997 and AD7997 defines
- */
-
-#define AD7997_8_READ_SINGLE                   0x80
-#define AD7997_8_READ_SEQUENCE                 0x70
-/* TODO: move this into a common header */
-#define RES_MASK(bits) ((1 << (bits)) - 1)
-
-enum {
-       ad7991,
-       ad7995,
-       ad7999,
-       ad7992,
-       ad7993,
-       ad7994,
-       ad7997,
-       ad7998
-};
-
-struct ad799x_state;
-
-/**
- * struct ad799x_chip_info - chip specifc information
- * @channel:           channel specification
- * @num_channels:      number of channels
- * @monitor_mode:      whether the chip supports monitor interrupts
- * @default_config:    device default configuration
- * @event_attrs:       pointer to the monitor event attribute group
- */
-
-struct ad799x_chip_info {
-       struct iio_chan_spec            channel[9];
-       int                             num_channels;
-       u16                             default_config;
-       const struct iio_info           *info;
-};
-
-struct ad799x_state {
-       struct i2c_client               *client;
-       const struct ad799x_chip_info   *chip_info;
-       struct regulator                *reg;
-       struct regulator                *vref;
-       unsigned                        id;
-       u16                             config;
-
-       u8                              *rx_buf;
-       unsigned int                    transfer_size;
-};
-
-#ifdef CONFIG_AD799X_RING_BUFFER
-int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev);
-void ad799x_ring_cleanup(struct iio_dev *indio_dev);
-#else /* CONFIG_AD799X_RING_BUFFER */
-
-static inline int
-ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev)
-{
-       return 0;
-}
-
-static inline void ad799x_ring_cleanup(struct iio_dev *indio_dev)
-{
-}
-#endif /* CONFIG_AD799X_RING_BUFFER */
-#endif /* _AD799X_H_ */
diff --git a/drivers/staging/iio/adc/ad799x_ring.c b/drivers/staging/iio/adc/ad799x_ring.c
deleted file mode 100644 (file)
index 0ff6c03..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2010-2012 Michael Hennerich, Analog Devices Inc.
- * Copyright (C) 2008-2010 Jonathan Cameron
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * ad799x_ring.c
- */
-
-#include <linux/interrupt.h>
-#include <linux/slab.h>
-#include <linux/kernel.h>
-#include <linux/list.h>
-#include <linux/i2c.h>
-#include <linux/bitops.h>
-
-#include <linux/iio/iio.h>
-#include <linux/iio/buffer.h>
-#include <linux/iio/trigger_consumer.h>
-#include <linux/iio/triggered_buffer.h>
-
-#include "ad799x.h"
-
-/**
- * ad799x_trigger_handler() bh of trigger launched polling to ring buffer
- *
- * Currently there is no option in this driver to disable the saving of
- * timestamps within the ring.
- **/
-
-static irqreturn_t ad799x_trigger_handler(int irq, void *p)
-{
-       struct iio_poll_func *pf = p;
-       struct iio_dev *indio_dev = pf->indio_dev;
-       struct ad799x_state *st = iio_priv(indio_dev);
-       int b_sent;
-       u8 cmd;
-
-       switch (st->id) {
-       case ad7991:
-       case ad7995:
-       case ad7999:
-               cmd = st->config |
-                       (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT);
-               break;
-       case ad7992:
-       case ad7993:
-       case ad7994:
-               cmd = (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT) |
-                       AD7998_CONV_RES_REG;
-               break;
-       case ad7997:
-       case ad7998:
-               cmd = AD7997_8_READ_SEQUENCE | AD7998_CONV_RES_REG;
-               break;
-       default:
-               cmd = 0;
-       }
-
-       b_sent = i2c_smbus_read_i2c_block_data(st->client,
-                       cmd, st->transfer_size, st->rx_buf);
-       if (b_sent < 0)
-               goto out;
-
-       iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf,
-                       iio_get_time_ns());
-out:
-       iio_trigger_notify_done(indio_dev->trig);
-
-       return IRQ_HANDLED;
-}
-
-int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev)
-{
-       return iio_triggered_buffer_setup(indio_dev, NULL,
-               &ad799x_trigger_handler, NULL);
-}
-
-void ad799x_ring_cleanup(struct iio_dev *indio_dev)
-{
-       iio_triggered_buffer_cleanup(indio_dev);
-}
index 970d9edc73b6cc0d978a6a21a100de6c1a7a6994..c5492ba50751d3b9c415e15d4e43f5fed277ca58 100644 (file)
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 
-/*
- * SPEAR registers definitions
- */
-
-#define SCAN_RATE_LO(x)                ((x) & 0xFFFF)
-#define SCAN_RATE_HI(x)                (((x) >> 0x10) & 0xFFFF)
-#define CLK_LOW(x)             (((x) & 0xf) << 0)
-#define CLK_HIGH(x)            (((x) & 0xf) << 4)
+/* SPEAR registers definitions */
+#define SPEAR600_ADC_SCAN_RATE_LO(x)   ((x) & 0xFFFF)
+#define SPEAR600_ADC_SCAN_RATE_HI(x)   (((x) >> 0x10) & 0xFFFF)
+#define SPEAR_ADC_CLK_LOW(x)           (((x) & 0xf) << 0)
+#define SPEAR_ADC_CLK_HIGH(x)          (((x) & 0xf) << 4)
 
 /* Bit definitions for SPEAR_ADC_STATUS */
-#define START_CONVERSION       (1 << 0)
-#define CHANNEL_NUM(x)         ((x) << 1)
-#define ADC_ENABLE             (1 << 4)
-#define AVG_SAMPLE(x)          ((x) << 5)
-#define VREF_INTERNAL          (1 << 9)
+#define SPEAR_ADC_STATUS_START_CONVERSION      (1 << 0)
+#define SPEAR_ADC_STATUS_CHANNEL_NUM(x)                ((x) << 1)
+#define SPEAR_ADC_STATUS_ADC_ENABLE            (1 << 4)
+#define SPEAR_ADC_STATUS_AVG_SAMPLE(x)         ((x) << 5)
+#define SPEAR_ADC_STATUS_VREF_INTERNAL         (1 << 9)
 
-#define DATA_MASK              0x03ff
-#define DATA_BITS              10
+#define SPEAR_ADC_DATA_MASK            0x03ff
+#define SPEAR_ADC_DATA_BITS            10
 
-#define MOD_NAME "spear-adc"
+#define SPEAR_ADC_MOD_NAME "spear-adc"
 
-#define ADC_CHANNEL_NUM                8
+#define SPEAR_ADC_CHANNEL_NUM          8
 
-#define CLK_MIN                        2500000
-#define CLK_MAX                        20000000
+#define SPEAR_ADC_CLK_MIN                      2500000
+#define SPEAR_ADC_CLK_MAX                      20000000
 
 struct adc_regs_spear3xx {
        u32 status;
        u32 average;
        u32 scan_rate;
        u32 clk;        /* Not avail for 1340 & 1310 */
-       u32 ch_ctrl[ADC_CHANNEL_NUM];
-       u32 ch_data[ADC_CHANNEL_NUM];
+       u32 ch_ctrl[SPEAR_ADC_CHANNEL_NUM];
+       u32 ch_data[SPEAR_ADC_CHANNEL_NUM];
 };
 
 struct chan_data {
@@ -66,14 +63,14 @@ struct adc_regs_spear6xx {
        u32 status;
        u32 pad[2];
        u32 clk;
-       u32 ch_ctrl[ADC_CHANNEL_NUM];
-       struct chan_data ch_data[ADC_CHANNEL_NUM];
+       u32 ch_ctrl[SPEAR_ADC_CHANNEL_NUM];
+       struct chan_data ch_data[SPEAR_ADC_CHANNEL_NUM];
        u32 scan_rate_lo;
        u32 scan_rate_hi;
        struct chan_data average;
 };
 
-struct spear_adc_info {
+struct spear_adc_state {
        struct device_node *np;
        struct adc_regs_spear3xx __iomem *adc_base_spear3xx;
        struct adc_regs_spear6xx __iomem *adc_base_spear6xx;
@@ -91,100 +88,129 @@ struct spear_adc_info {
  * static inline functions, because of different register offsets
  * on different SoC variants (SPEAr300 vs SPEAr600 etc).
  */
-static void spear_adc_set_status(struct spear_adc_info *info, u32 val)
+static void spear_adc_set_status(struct spear_adc_state *st, u32 val)
 {
-       __raw_writel(val, &info->adc_base_spear6xx->status);
+       __raw_writel(val, &st->adc_base_spear6xx->status);
 }
 
-static void spear_adc_set_clk(struct spear_adc_info *info, u32 val)
+static void spear_adc_set_clk(struct spear_adc_state *st, u32 val)
 {
        u32 clk_high, clk_low, count;
-       u32 apb_clk = clk_get_rate(info->clk);
+       u32 apb_clk = clk_get_rate(st->clk);
 
        count = (apb_clk + val - 1) / val;
        clk_low = count / 2;
        clk_high = count - clk_low;
-       info->current_clk = apb_clk / count;
+       st->current_clk = apb_clk / count;
 
-       __raw_writel(CLK_LOW(clk_low) | CLK_HIGH(clk_high),
-                    &info->adc_base_spear6xx->clk);
+       __raw_writel(SPEAR_ADC_CLK_LOW(clk_low) | SPEAR_ADC_CLK_HIGH(clk_high),
+                    &st->adc_base_spear6xx->clk);
 }
 
-static void spear_adc_set_ctrl(struct spear_adc_info *info, int n,
+static void spear_adc_set_ctrl(struct spear_adc_state *st, int n,
                               u32 val)
 {
-       __raw_writel(val, &info->adc_base_spear6xx->ch_ctrl[n]);
+       __raw_writel(val, &st->adc_base_spear6xx->ch_ctrl[n]);
 }
 
-static u32 spear_adc_get_average(struct spear_adc_info *info)
+static u32 spear_adc_get_average(struct spear_adc_state *st)
 {
-       if (of_device_is_compatible(info->np, "st,spear600-adc")) {
-               return __raw_readl(&info->adc_base_spear6xx->average.msb) &
-                       DATA_MASK;
+       if (of_device_is_compatible(st->np, "st,spear600-adc")) {
+               return __raw_readl(&st->adc_base_spear6xx->average.msb) &
+                       SPEAR_ADC_DATA_MASK;
        } else {
-               return __raw_readl(&info->adc_base_spear3xx->average) &
-                       DATA_MASK;
+               return __raw_readl(&st->adc_base_spear3xx->average) &
+                       SPEAR_ADC_DATA_MASK;
        }
 }
 
-static void spear_adc_set_scanrate(struct spear_adc_info *info, u32 rate)
+static void spear_adc_set_scanrate(struct spear_adc_state *st, u32 rate)
 {
-       if (of_device_is_compatible(info->np, "st,spear600-adc")) {
-               __raw_writel(SCAN_RATE_LO(rate),
-                            &info->adc_base_spear6xx->scan_rate_lo);
-               __raw_writel(SCAN_RATE_HI(rate),
-                            &info->adc_base_spear6xx->scan_rate_hi);
+       if (of_device_is_compatible(st->np, "st,spear600-adc")) {
+               __raw_writel(SPEAR600_ADC_SCAN_RATE_LO(rate),
+                            &st->adc_base_spear6xx->scan_rate_lo);
+               __raw_writel(SPEAR600_ADC_SCAN_RATE_HI(rate),
+                            &st->adc_base_spear6xx->scan_rate_hi);
        } else {
-               __raw_writel(rate, &info->adc_base_spear3xx->scan_rate);
+               __raw_writel(rate, &st->adc_base_spear3xx->scan_rate);
        }
 }
 
-static int spear_read_raw(struct iio_dev *indio_dev,
-                         struct iio_chan_spec const *chan,
-                         int *val,
-                         int *val2,
-                         long mask)
+static int spear_adc_read_raw(struct iio_dev *indio_dev,
+                             struct iio_chan_spec const *chan,
+                             int *val,
+                             int *val2,
+                             long mask)
 {
-       struct spear_adc_info *info = iio_priv(indio_dev);
+       struct spear_adc_state *st = iio_priv(indio_dev);
        u32 status;
 
        switch (mask) {
        case IIO_CHAN_INFO_RAW:
                mutex_lock(&indio_dev->mlock);
 
-               status = CHANNEL_NUM(chan->channel) |
-                       AVG_SAMPLE(info->avg_samples) |
-                       START_CONVERSION | ADC_ENABLE;
-               if (info->vref_external == 0)
-                       status |= VREF_INTERNAL;
+               status = SPEAR_ADC_STATUS_CHANNEL_NUM(chan->channel) |
+                       SPEAR_ADC_STATUS_AVG_SAMPLE(st->avg_samples) |
+                       SPEAR_ADC_STATUS_START_CONVERSION |
+                       SPEAR_ADC_STATUS_ADC_ENABLE;
+               if (st->vref_external == 0)
+                       status |= SPEAR_ADC_STATUS_VREF_INTERNAL;
 
-               spear_adc_set_status(info, status);
-               wait_for_completion(&info->completion); /* set by ISR */
-               *val = info->value;
+               spear_adc_set_status(st, status);
+               wait_for_completion(&st->completion); /* set by ISR */
+               *val = st->value;
 
                mutex_unlock(&indio_dev->mlock);
 
                return IIO_VAL_INT;
 
        case IIO_CHAN_INFO_SCALE:
-               *val = info->vref_external;
-               *val2 = DATA_BITS;
+               *val = st->vref_external;
+               *val2 = SPEAR_ADC_DATA_BITS;
                return IIO_VAL_FRACTIONAL_LOG2;
+       case IIO_CHAN_INFO_SAMP_FREQ:
+               *val = st->current_clk;
+               return IIO_VAL_INT;
        }
 
        return -EINVAL;
 }
 
+static int spear_adc_write_raw(struct iio_dev *indio_dev,
+                              struct iio_chan_spec const *chan,
+                              int val,
+                              int val2,
+                              long mask)
+{
+       struct spear_adc_state *st = iio_priv(indio_dev);
+       int ret = 0;
+
+       if (mask != IIO_CHAN_INFO_SAMP_FREQ)
+               return -EINVAL;
+
+       mutex_lock(&indio_dev->mlock);
+
+       if ((val < SPEAR_ADC_CLK_MIN) ||
+               (val > SPEAR_ADC_CLK_MAX) ||
+               (val2 != 0)) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+       spear_adc_set_clk(st, val);
+
+out:
+       mutex_unlock(&indio_dev->mlock);
+       return ret;
+}
+
 #define SPEAR_ADC_CHAN(idx) {                          \
        .type = IIO_VOLTAGE,                            \
        .indexed = 1,                                   \
        .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),   \
        .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),   \
+       .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),\
        .channel = idx,                                 \
-       .scan_type = {                                  \
-               .sign = 'u',                            \
-               .storagebits = 16,                      \
-       },                                              \
 }
 
 static const struct iio_chan_spec spear_adc_iio_channels[] = {
@@ -200,92 +226,34 @@ static const struct iio_chan_spec spear_adc_iio_channels[] = {
 
 static irqreturn_t spear_adc_isr(int irq, void *dev_id)
 {
-       struct spear_adc_info *info = (struct spear_adc_info *)dev_id;
+       struct spear_adc_state *st = (struct spear_adc_state *)dev_id;
 
        /* Read value to clear IRQ */
-       info->value = spear_adc_get_average(info);
-       complete(&info->completion);
+       st->value = spear_adc_get_average(st);
+       complete(&st->completion);
 
        return IRQ_HANDLED;
 }
 
-static int spear_adc_configure(struct spear_adc_info *info)
+static int spear_adc_configure(struct spear_adc_state *st)
 {
        int i;
 
        /* Reset ADC core */
-       spear_adc_set_status(info, 0);
-       __raw_writel(0, &info->adc_base_spear6xx->clk);
+       spear_adc_set_status(st, 0);
+       __raw_writel(0, &st->adc_base_spear6xx->clk);
        for (i = 0; i < 8; i++)
-               spear_adc_set_ctrl(info, i, 0);
-       spear_adc_set_scanrate(info, 0);
+               spear_adc_set_ctrl(st, i, 0);
+       spear_adc_set_scanrate(st, 0);
 
-       spear_adc_set_clk(info, info->sampling_freq);
+       spear_adc_set_clk(st, st->sampling_freq);
 
        return 0;
 }
 
-static ssize_t spear_adc_read_frequency(struct device *dev,
-                                       struct device_attribute *attr,
-                                       char *buf)
-{
-       struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-       struct spear_adc_info *info = iio_priv(indio_dev);
-
-       return sprintf(buf, "%d\n", info->current_clk);
-}
-
-static ssize_t spear_adc_write_frequency(struct device *dev,
-                                        struct device_attribute *attr,
-                                        const char *buf,
-                                        size_t len)
-{
-       struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-       struct spear_adc_info *info = iio_priv(indio_dev);
-       u32 clk_high, clk_low, count;
-       u32 apb_clk = clk_get_rate(info->clk);
-       unsigned long lval;
-       int ret;
-
-       ret = kstrtoul(buf, 10, &lval);
-       if (ret)
-               return ret;
-
-       mutex_lock(&indio_dev->mlock);
-
-       if ((lval < CLK_MIN) || (lval > CLK_MAX)) {
-               ret = -EINVAL;
-               goto out;
-       }
-
-       count = (apb_clk + lval - 1) / lval;
-       clk_low = count / 2;
-       clk_high = count - clk_low;
-       info->current_clk = apb_clk / count;
-       spear_adc_set_clk(info, lval);
-
-out:
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret ? ret : len;
-}
-
-static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
-                             spear_adc_read_frequency,
-                             spear_adc_write_frequency);
-
-static struct attribute *spear_attributes[] = {
-       &iio_dev_attr_sampling_frequency.dev_attr.attr,
-       NULL
-};
-
-static const struct attribute_group spear_attribute_group = {
-       .attrs = spear_attributes,
-};
-
-static const struct iio_info spear_adc_iio_info = {
-       .read_raw = &spear_read_raw,
-       .attrs = &spear_attribute_group,
+static const struct iio_info spear_adc_info = {
+       .read_raw = &spear_adc_read_raw,
+       .write_raw = &spear_adc_write_raw,
        .driver_module = THIS_MODULE,
 };
 
@@ -293,40 +261,40 @@ static int spear_adc_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
        struct device *dev = &pdev->dev;
-       struct spear_adc_info *info;
-       struct iio_dev *iodev = NULL;
+       struct spear_adc_state *st;
+       struct iio_dev *indio_dev = NULL;
        int ret = -ENODEV;
        int irq;
 
-       iodev = devm_iio_device_alloc(dev, sizeof(struct spear_adc_info));
-       if (!iodev) {
+       indio_dev = devm_iio_device_alloc(dev, sizeof(struct spear_adc_state));
+       if (!indio_dev) {
                dev_err(dev, "failed allocating iio device\n");
                return -ENOMEM;
        }
 
-       info = iio_priv(iodev);
-       info->np = np;
+       st = iio_priv(indio_dev);
+       st->np = np;
 
        /*
         * SPEAr600 has a different register layout than other SPEAr SoC's
         * (e.g. SPEAr3xx). Let's provide two register base addresses
         * to support multi-arch kernels.
         */
-       info->adc_base_spear6xx = of_iomap(np, 0);
-       if (!info->adc_base_spear6xx) {
+       st->adc_base_spear6xx = of_iomap(np, 0);
+       if (!st->adc_base_spear6xx) {
                dev_err(dev, "failed mapping memory\n");
                return -ENOMEM;
        }
-       info->adc_base_spear3xx =
-               (struct adc_regs_spear3xx __iomem *)info->adc_base_spear6xx;
+       st->adc_base_spear3xx =
+               (struct adc_regs_spear3xx __iomem *)st->adc_base_spear6xx;
 
-       info->clk = clk_get(dev, NULL);
-       if (IS_ERR(info->clk)) {
+       st->clk = clk_get(dev, NULL);
+       if (IS_ERR(st->clk)) {
                dev_err(dev, "failed getting clock\n");
                goto errout1;
        }
 
-       ret = clk_prepare_enable(info->clk);
+       ret = clk_prepare_enable(st->clk);
        if (ret) {
                dev_err(dev, "failed enabling clock\n");
                goto errout2;
@@ -339,14 +307,15 @@ static int spear_adc_probe(struct platform_device *pdev)
                goto errout3;
        }
 
-       ret = devm_request_irq(dev, irq, spear_adc_isr, 0, MOD_NAME, info);
+       ret = devm_request_irq(dev, irq, spear_adc_isr, 0, SPEAR_ADC_MOD_NAME,
+                              st);
        if (ret < 0) {
                dev_err(dev, "failed requesting interrupt\n");
                goto errout3;
        }
 
        if (of_property_read_u32(np, "sampling-frequency",
-                                &info->sampling_freq)) {
+                                &st->sampling_freq)) {
                dev_err(dev, "sampling-frequency missing in DT\n");
                ret = -EINVAL;
                goto errout3;
@@ -356,28 +325,28 @@ static int spear_adc_probe(struct platform_device *pdev)
         * Optional avg_samples defaults to 0, resulting in single data
         * conversion
         */
-       of_property_read_u32(np, "average-samples", &info->avg_samples);
+       of_property_read_u32(np, "average-samples", &st->avg_samples);
 
        /*
         * Optional vref_external defaults to 0, resulting in internal vref
         * selection
         */
-       of_property_read_u32(np, "vref-external", &info->vref_external);
+       of_property_read_u32(np, "vref-external", &st->vref_external);
 
-       spear_adc_configure(info);
+       spear_adc_configure(st);
 
-       platform_set_drvdata(pdev, iodev);
+       platform_set_drvdata(pdev, indio_dev);
 
-       init_completion(&info->completion);
+       init_completion(&st->completion);
 
-       iodev->name = MOD_NAME;
-       iodev->dev.parent = dev;
-       iodev->info = &spear_adc_iio_info;
-       iodev->modes = INDIO_DIRECT_MODE;
-       iodev->channels = spear_adc_iio_channels;
-       iodev->num_channels = ARRAY_SIZE(spear_adc_iio_channels);
+       indio_dev->name = SPEAR_ADC_MOD_NAME;
+       indio_dev->dev.parent = dev;
+       indio_dev->info = &spear_adc_info;
+       indio_dev->modes = INDIO_DIRECT_MODE;
+       indio_dev->channels = spear_adc_iio_channels;
+       indio_dev->num_channels = ARRAY_SIZE(spear_adc_iio_channels);
 
-       ret = iio_device_register(iodev);
+       ret = iio_device_register(indio_dev);
        if (ret)
                goto errout3;
 
@@ -386,23 +355,23 @@ static int spear_adc_probe(struct platform_device *pdev)
        return 0;
 
 errout3:
-       clk_disable_unprepare(info->clk);
+       clk_disable_unprepare(st->clk);
 errout2:
-       clk_put(info->clk);
+       clk_put(st->clk);
 errout1:
-       iounmap(info->adc_base_spear6xx);
+       iounmap(st->adc_base_spear6xx);
        return ret;
 }
 
 static int spear_adc_remove(struct platform_device *pdev)
 {
-       struct iio_dev *iodev = platform_get_drvdata(pdev);
-       struct spear_adc_info *info = iio_priv(iodev);
+       struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+       struct spear_adc_state *st = iio_priv(indio_dev);
 
-       iio_device_unregister(iodev);
-       clk_disable_unprepare(info->clk);
-       clk_put(info->clk);
-       iounmap(info->adc_base_spear6xx);
+       iio_device_unregister(indio_dev);
+       clk_disable_unprepare(st->clk);
+       clk_put(st->clk);
+       iounmap(st->adc_base_spear6xx);
 
        return 0;
 }
@@ -419,7 +388,7 @@ static struct platform_driver spear_adc_driver = {
        .probe          = spear_adc_probe,
        .remove         = spear_adc_remove,
        .driver         = {
-               .name   = MOD_NAME,
+               .name   = SPEAR_ADC_MOD_NAME,
                .owner  = THIS_MODULE,
                .of_match_table = of_match_ptr(spear_adc_dt_ids),
        },
index 9f0ebb329008c40a809101f17206c5b0e8acf544..5f1770e6f6c3211edf5b3b063857fadb6fdcbcaa 100644 (file)
 #define ID_ADT75XX             0x10
 
 /*
- * struct adt7316_chip_info - chip specifc information
+ * struct adt7316_chip_info - chip specific information
  */
 
 struct adt7316_chip_info {
@@ -208,7 +208,7 @@ struct adt7316_chip_info {
        (ADT7316_TEMP_INT_MASK)
 
 /*
- * struct adt7316_chip_info - chip specifc information
+ * struct adt7316_chip_info - chip specific information
  */
 
 struct adt7316_limit_regs {
index f2c309d1eb5945a45137aab8882229a4b9ebab0c..87110d940e9a429d65d136abff4d93805ad8bdc7 100644 (file)
@@ -78,7 +78,7 @@ enum {
 };
 
 /*
- * struct ad7152_chip_info - chip specifc information
+ * struct ad7152_chip_info - chip specific information
  */
 
 struct ad7152_chip_info {
index cbb1588d591fdb698ffd22a58db3af0293e0be27..e6e9eaa9eab5477bf1f66ea64c01809e22527ea9 100644 (file)
@@ -91,7 +91,7 @@
 #define AD7746_CAPDAC_DACP(x)          ((x) & 0x7F)
 
 /*
- * struct ad7746_chip_info - chip specifc information
+ * struct ad7746_chip_info - chip specific information
  */
 
 struct ad7746_chip_info {
index 0a60def92735e16566185d7d6eee8c30f4b7395d..fa9649879662f11464bc294adf9e2e7a82abe3db 100644 (file)
@@ -165,8 +165,9 @@ taos_i2c_read(struct i2c_client *client, u8 reg, u8 *val, unsigned int len)
                /* select register to write */
                ret = i2c_smbus_write_byte(client, (TSL258X_CMD_REG | reg));
                if (ret < 0) {
-                       dev_err(&client->dev, "taos_i2c_read failed to write"
-                               " register %x\n", reg);
+                       dev_err(&client->dev,
+                               "taos_i2c_read failed to write register %x\n",
+                               reg);
                        return ret;
                }
                /* read the data */
@@ -211,7 +212,7 @@ static int taos_get_lux(struct iio_dev *indio_dev)
        if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
                /* device is not enabled */
                dev_err(&chip->client->dev, "taos_get_lux device is not enabled\n");
-               ret = -EBUSY ;
+               ret = -EBUSY;
                goto out_unlock;
        }
 
@@ -231,8 +232,9 @@ static int taos_get_lux(struct iio_dev *indio_dev)
                int reg = TSL258X_CMD_REG | (TSL258X_ALS_CHAN0LO + i);
                ret = taos_i2c_read(chip->client, reg, &buf[i], 1);
                if (ret < 0) {
-                       dev_err(&chip->client->dev, "taos_get_lux failed to read"
-                               " register %x\n", reg);
+                       dev_err(&chip->client->dev,
+                               "taos_get_lux failed to read register %x\n",
+                               reg);
                        goto out_unlock;
                }
        }
@@ -449,7 +451,7 @@ static int taos_chip_on(struct iio_dev *indio_dev)
                }
        }
 
-       msleep(3);
+       usleep_range(3000, 3500);
        /* NOW enable the ADC
         * initialize the desired mode of operation */
        utmp = TSL258X_CNTL_PWR_ON | TSL258X_CNTL_ADC_ENBL;
@@ -809,9 +811,7 @@ static int taos_probe(struct i2c_client *clientp,
 
        if (!i2c_check_functionality(clientp->adapter,
                I2C_FUNC_SMBUS_BYTE_DATA)) {
-               dev_err(&clientp->dev,
-                       "taos_probe() - i2c smbus byte data "
-                       "functions unsupported\n");
+               dev_err(&clientp->dev, "taos_probe() - i2c smbus byte data func unsupported\n");
                return -EOPNOTSUPP;
        }
 
@@ -830,30 +830,32 @@ static int taos_probe(struct i2c_client *clientp,
                ret = i2c_smbus_write_byte(clientp,
                                (TSL258X_CMD_REG | (TSL258X_CNTRL + i)));
                if (ret < 0) {
-                       dev_err(&clientp->dev, "i2c_smbus_write_bytes() to cmd "
-                               "reg failed in taos_probe(), err = %d\n", ret);
+                       dev_err(&clientp->dev,
+                               "i2c_smbus_write_byte to cmd reg failed in taos_probe(), err = %d\n",
+                               ret);
                        return ret;
                }
                ret = i2c_smbus_read_byte(clientp);
                if (ret < 0) {
-                       dev_err(&clientp->dev, "i2c_smbus_read_byte from "
-                               "reg failed in taos_probe(), err = %d\n", ret);
-
+                       dev_err(&clientp->dev,
+                               "i2c_smbus_read_byte from reg failed in taos_probe(), err = %d\n",
+                               ret);
                        return ret;
                }
                buf[i] = ret;
        }
 
        if (!taos_tsl258x_device(buf)) {
-               dev_info(&clientp->dev, "i2c device found but does not match "
-                       "expected id in taos_probe()\n");
+               dev_info(&clientp->dev,
+                       "i2c device found but does not match expected id in taos_probe()\n");
                return -EINVAL;
        }
 
        ret = i2c_smbus_write_byte(clientp, (TSL258X_CMD_REG | TSL258X_CNTRL));
        if (ret < 0) {
-               dev_err(&clientp->dev, "i2c_smbus_write_byte() to cmd reg "
-                       "failed in taos_probe(), err = %d\n", ret);
+               dev_err(&clientp->dev,
+                       "i2c_smbus_write_byte() to cmd reg failed in taos_probe(), err = %d\n",
+                       ret);
                return ret;
        }
 
index 48a6afa8408805ff3a8f2ab25689ebccc3e419cf..38ecb4bb6e4c0ee167e5b9cb09822730cda6c741 100644 (file)
@@ -33,7 +33,8 @@ static int iio_trig_periodic_rtc_set_state(struct iio_trigger *trig, bool state)
        struct iio_prtc_trigger_info *trig_info = iio_trigger_get_drvdata(trig);
        if (trig_info->frequency == 0)
                return -EINVAL;
-       printk(KERN_INFO "trigger frequency is %d\n", trig_info->frequency);
+       dev_info(&trig_info->rtc->dev, "trigger frequency is %d\n",
+                       trig_info->frequency);
        return rtc_irq_set_state(trig_info->rtc, &trig_info->task, state);
 }
 
index 4144a75e5f71bc6258d9d8dcdc1a02b3b2a2f035..bc7f8bd227c7186a2e054d82a19c75ebcd72ea4a 100644 (file)
@@ -517,7 +517,7 @@ int imx_drm_encoder_get_mux_id(struct device_node *node,
                of_node_put(port);
                if (port == imx_crtc->port) {
                        ret = of_graph_parse_endpoint(ep, &endpoint);
-                       return ret ? ret : endpoint.id;
+                       return ret ? ret : endpoint.port;
                }
        } while (ep);
 
index d47dedd2cdb416fceb7b0bf90f3fda129e8036ab..886a0d49031ba1e68a3d5b9d273c0d86327a4f7e 100644 (file)
@@ -120,8 +120,6 @@ struct imx_hdmi {
        struct clk *isfr_clk;
        struct clk *iahb_clk;
 
-       enum drm_connector_status connector_status;
-
        struct hdmi_data_info hdmi_data;
        int vic;
 
@@ -659,13 +657,10 @@ static inline void hdmi_phy_test_dout(struct imx_hdmi *hdmi,
 
 static bool hdmi_phy_wait_i2c_done(struct imx_hdmi *hdmi, int msec)
 {
-       unsigned char val = 0;
-       val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3;
-       while (!val) {
-               udelay(1000);
+       while ((hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) {
                if (msec-- == 0)
                        return false;
-               val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3;
+               udelay(1000);
        }
        return true;
 }
@@ -1382,7 +1377,9 @@ static enum drm_connector_status imx_hdmi_connector_detect(struct drm_connector
 {
        struct imx_hdmi *hdmi = container_of(connector, struct imx_hdmi,
                                             connector);
-       return hdmi->connector_status;
+
+       return hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_HPD ?
+               connector_status_connected : connector_status_disconnected;
 }
 
 static int imx_hdmi_connector_get_modes(struct drm_connector *connector)
@@ -1524,7 +1521,6 @@ static irqreturn_t imx_hdmi_irq(int irq, void *dev_id)
 
                        hdmi_modb(hdmi, 0, HDMI_PHY_HPD, HDMI_PHY_POL0);
 
-                       hdmi->connector_status = connector_status_connected;
                        imx_hdmi_poweron(hdmi);
                } else {
                        dev_dbg(hdmi->dev, "EVENT=plugout\n");
@@ -1532,7 +1528,6 @@ static irqreturn_t imx_hdmi_irq(int irq, void *dev_id)
                        hdmi_modb(hdmi, HDMI_PHY_HPD, HDMI_PHY_HPD,
                                HDMI_PHY_POL0);
 
-                       hdmi->connector_status = connector_status_disconnected;
                        imx_hdmi_poweroff(hdmi);
                }
                drm_helper_hpd_irq_event(hdmi->connector.dev);
@@ -1606,7 +1601,6 @@ static int imx_hdmi_bind(struct device *dev, struct device *master, void *data)
                return -ENOMEM;
 
        hdmi->dev = dev;
-       hdmi->connector_status = connector_status_disconnected;
        hdmi->sample_rate = 48000;
        hdmi->ratio = 100;
 
@@ -1628,7 +1622,7 @@ static int imx_hdmi_bind(struct device *dev, struct device *master, void *data)
 
        irq = platform_get_irq(pdev, 0);
        if (irq < 0)
-               return -EINVAL;
+               return irq;
 
        ret = devm_request_threaded_irq(dev, irq, imx_hdmi_hardirq,
                                        imx_hdmi_irq, IRQF_SHARED,
index ca85d3d70ae3f454cb019844590183af58356ce9..0ea00de2cc9ad5134ae13418c6a348e4020544a1 100644 (file)
@@ -900,7 +900,8 @@ static void ipu_irq_handle(struct ipu_soc *ipu, const int *regs, int num_regs)
                status &= ipu_cm_read(ipu, IPU_INT_CTRL(regs[i]));
 
                for_each_set_bit(bit, &status, 32) {
-                       irq = irq_linear_revmap(ipu->domain, regs[i] * 32 + bit);
+                       irq = irq_linear_revmap(ipu->domain,
+                                               regs[i] * 32 + bit);
                        if (irq)
                                generic_handle_irq(irq);
                }
@@ -1053,7 +1054,8 @@ static int ipu_irq_init(struct ipu_soc *ipu)
        }
 
        ret = irq_alloc_domain_generic_chips(ipu->domain, 32, 1, "IPU",
-                                            handle_level_irq, 0, IRQF_VALID, 0);
+                                            handle_level_irq, 0,
+                                            IRQF_VALID, 0);
        if (ret < 0) {
                dev_err(ipu->dev, "failed to alloc generic irq chips\n");
                irq_domain_remove(ipu->domain);
index d5de8bb5c803f87b84dbfea1a2aaac5843f3661a..55f1b6b083d1266d6fcd00c2211920db204f73cf 100644 (file)
@@ -91,6 +91,7 @@ enum ipu_dc_map {
        IPU_DC_MAP_RGB565,
        IPU_DC_MAP_GBR24, /* TVEv2 */
        IPU_DC_MAP_BGR666,
+       IPU_DC_MAP_LVDS666,
        IPU_DC_MAP_BGR24,
 };
 
@@ -153,6 +154,8 @@ static int ipu_pixfmt_to_map(u32 fmt)
                return IPU_DC_MAP_GBR24;
        case V4L2_PIX_FMT_BGR666:
                return IPU_DC_MAP_BGR666;
+       case v4l2_fourcc('L', 'V', 'D', '6'):
+               return IPU_DC_MAP_LVDS666;
        case V4L2_PIX_FMT_BGR24:
                return IPU_DC_MAP_BGR24;
        default:
@@ -367,7 +370,8 @@ int ipu_dc_init(struct ipu_soc *ipu, struct device *dev,
        writel(DC_WR_CH_CONF_WORD_SIZE_24 | DC_WR_CH_CONF_DISP_ID_PARALLEL(0),
                        priv->channels[5].base + DC_WR_CH_CONF);
 
-       writel(DC_GEN_SYNC_1_6_SYNC | DC_GEN_SYNC_PRIORITY_1, priv->dc_reg + DC_GEN);
+       writel(DC_GEN_SYNC_1_6_SYNC | DC_GEN_SYNC_PRIORITY_1,
+               priv->dc_reg + DC_GEN);
 
        ipu->dc_priv = priv;
 
@@ -398,6 +402,12 @@ int ipu_dc_init(struct ipu_soc *ipu, struct device *dev,
        ipu_dc_map_config(priv, IPU_DC_MAP_BGR666, 1, 11, 0xfc); /* green */
        ipu_dc_map_config(priv, IPU_DC_MAP_BGR666, 2, 17, 0xfc); /* red */
 
+       /* lvds666 */
+       ipu_dc_map_clear(priv, IPU_DC_MAP_LVDS666);
+       ipu_dc_map_config(priv, IPU_DC_MAP_LVDS666, 0, 5, 0xfc); /* blue */
+       ipu_dc_map_config(priv, IPU_DC_MAP_LVDS666, 1, 13, 0xfc); /* green */
+       ipu_dc_map_config(priv, IPU_DC_MAP_LVDS666, 2, 21, 0xfc); /* red */
+
        /* bgr24 */
        ipu_dc_map_clear(priv, IPU_DC_MAP_BGR24);
        ipu_dc_map_config(priv, IPU_DC_MAP_BGR24, 2, 7, 0xff); /* red */
index c60b6c645f42000df73f7ee4ba198cca6c65d27f..eaf4dda1a0c442ce53acfe01f181892d7bed4253 100644 (file)
@@ -219,6 +219,8 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data)
                        imxpd->interface_pix_fmt = V4L2_PIX_FMT_RGB565;
                else if (!strcmp(fmt, "bgr666"))
                        imxpd->interface_pix_fmt = V4L2_PIX_FMT_BGR666;
+               else if (!strcmp(fmt, "lvds666"))
+                       imxpd->interface_pix_fmt = v4l2_fourcc('L', 'V', 'D', '6');
        }
 
        panel_node = of_parse_phandle(np, "fsl,panel", 0);
index e61183906548be5f8cc91b1b303b7d2a20e82664..1e7449d6d1209dc400e9dd8233421e3cd630f14b 100644 (file)
@@ -9,6 +9,7 @@
 #include "usb.h"
 #include "scsiglue.h"
 #include "transport.h"
+#include "smil.h"
 #include "init.h"
 
 /*
index 98d2e3ba854568d7a3c860a257bea3a76339caf4..32c724df621d162072c52476749bd101dfba2346 100644 (file)
@@ -1,7 +1,6 @@
 #include "common.h"
 
 extern u32 MediaChange;
-extern int Check_D_MediaFmt(struct us_data *);
 
 
 
index 39951738d231f93d79d8297de38e2f197daf624f..f938759337e6b1830fd18b4b6757e007604d0cb9 100644 (file)
@@ -204,6 +204,7 @@ extern struct keucr_media_area    CisArea;
 int         Init_D_SmartMedia(void);
 int         Pwoff_D_SmartMedia(void);
 int         Check_D_SmartMedia(void);
+int         Check_D_MediaFmt(struct us_data *);
 int         Check_D_Parameter(struct us_data *, u16 *, u8 *, u8 *);
 int         Media_D_ReadSector(struct us_data *, u32, u16, u8 *);
 int         Media_D_WriteSector(struct us_data *, u32, u16, u8 *);
@@ -284,6 +285,4 @@ u8 correct_data(u8 *, u8 *, u8,   u8,   u8);
 int  _Correct_D_SwECC(u8 *, u8 *, u8 *);
 void _Calculate_D_SwECC(u8 *, u8 *);
 
-void SM_Init(void);
-
 #endif /* already included */
index 44ced82650392c60a26f624c2f67122a426ed959..e981f14f3bf95f20eaf5df317db534da2070ba16 100644 (file)
@@ -133,6 +133,7 @@ void Set_D_LogBlockAddr(u8 *redundant)
 void Set_D_FailBlock(u8 *redundant)
 {
        char i;
+
        for (i = 0; i < REDTSIZE; i++)
                *redundant++ = (u8)((i == REDT_BLOCK) ? 0xF0 : 0xFF);
 }
index ae9414755d2f9b0dbb5620c6cc5d2d74a9d768f0..5e59525271f8badc1700904929e23a115258a8ec 100644 (file)
@@ -669,6 +669,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
        /*  R/W data */
        if (transfer_length) {
                unsigned int pipe;
+
                if (srb->sc_data_direction == DMA_FROM_DEVICE)
                        pipe = us->recv_bulk_pipe;
                else
index 77f1b421e957f158c9de7503d6c3309a74a89642..ef511c76a6e36eac338098f6209fd7af39856d44 100644 (file)
@@ -124,6 +124,7 @@ static int line6_send_raw_message_async_part(struct message *msg,
 static int line6_start_listen(struct usb_line6 *line6)
 {
        int err;
+
        usb_fill_int_urb(line6->urb_listen, line6->usbdev,
                         usb_rcvintpipe(line6->usbdev, line6->ep_control_read),
                         line6->buffer_listen, LINE6_BUFSIZE_LISTEN,
index 661080b3c39df8c2f8e1c43ed9473d4eb603cc25..a3136b189ee5bc7f670f96379e81e0f58c253871 100644 (file)
@@ -475,7 +475,7 @@ int line6_init_pcm(struct usb_line6 *line6,
                MISSING_CASE;
        }
 
-       line6pcm = kzalloc(sizeof(struct snd_line6_pcm), GFP_KERNEL);
+       line6pcm = kzalloc(sizeof(*line6pcm), GFP_KERNEL);
 
        if (line6pcm == NULL)
                return -ENOMEM;
index 41869caf19a70d2b250aaffba94cf6df9f0f67c9..0f72db5665fef43479d6477136ae0ae0970f7643 100644 (file)
@@ -34,6 +34,7 @@ static void change_volume(struct urb *urb_out, int volume[],
 
        if (bytes_per_frame == 4) {
                short *p, *buf_end;
+
                p = (short *)urb_out->transfer_buffer;
                buf_end = p + urb_out->transfer_buffer_length / sizeof(*p);
 
@@ -48,6 +49,7 @@ static void change_volume(struct urb *urb_out, int volume[],
 
                for (; p < buf_end; p += 3) {
                        int val;
+
                        val = p[0] + (p[1] << 8) + ((signed char)p[2] << 16);
                        val = (val * volume[chn & 1]) >> 8;
                        p[0] = val;
@@ -116,6 +118,7 @@ static void add_monitor_signal(struct urb *urb_out, unsigned char *signal,
 
        if (bytes_per_frame == 4) {
                short *pi, *po, *buf_end;
+
                pi = (short *)signal;
                po = (short *)urb_out->transfer_buffer;
                buf_end = po + urb_out->transfer_buffer_length / sizeof(*po);
@@ -171,6 +174,7 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm)
 
                if (fsize == 0) {
                        int n;
+
                        line6pcm->count_out += frame_increment;
                        n = line6pcm->count_out / frame_factor;
                        line6pcm->count_out -= n * frame_factor;
@@ -207,6 +211,7 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm)
                           copy the data to the temp buffer.
                         */
                        int len;
+
                        len = runtime->buffer_size - line6pcm->pos_out;
 
                        if (len > 0) {
index af2e7e50c135079cb7fa97154fdd72000458d39e..dcab6478a3b3fe16d8dd17daadd7ddf28a9deb86 100644 (file)
@@ -213,6 +213,7 @@ static int snd_toneport_source_info(struct snd_kcontrol *kcontrol,
                                    struct snd_ctl_elem_info *uinfo)
 {
        const int size = ARRAY_SIZE(toneport_source_info);
+
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
        uinfo->count = 1;
        uinfo->value.enumerated.items = size;
index 4a6c7da721748d45eccb1cb780f1126558183cef..26b53f6420e5013a757e412cf8a3ccea35437528 100644 (file)
@@ -42,6 +42,7 @@
 #endif
 
 #include <linux/libcfs/linux/libcfs.h>
+#include <linux/gfp.h>
 
 #include "curproc.h"
 
index c87efb49ebc28f49c6d119a95a6d95f2fd91372f..a140e5d918602059525505f939ff6bac61d0e434 100644 (file)
@@ -128,7 +128,7 @@ struct cfs_cpt_table *cfs_cpt_table_alloc(unsigned int ncpt);
 int
 cfs_cpt_number(struct cfs_cpt_table *cptab);
 /**
- * return number of HW cores or hypter-threadings in a CPU partition \a cpt
+ * return number of HW cores or hyper-threadings in a CPU partition \a cpt
  */
 int cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt);
 /**
@@ -152,7 +152,7 @@ int cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu);
  */
 int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt);
 /**
- * add \a cpu to CPU partion @cpt of \a cptab, return 1 for success,
+ * add \a cpu to CPU partition @cpt of \a cptab, return 1 for success,
  * otherwise 0 is returned
  */
 int cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu);
@@ -202,6 +202,11 @@ void cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt);
  */
 int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt);
 
+/**
+ * return number of HTs in the same core of \a cpu
+ */
+int cfs_cpu_ht_nsiblings(int cpu);
+
 /**
  * iterate over all CPU partitions in \a cptab
  */
index 776e9c0e48c13742170523c4934d5056d6886080..9e610a9ce51f97bfa7ee6a4c2a2ea750f734be48 100644 (file)
@@ -31,7 +31,7 @@
 struct cfs_crypto_hash_type {
        char            *cht_name;      /**< hash algorithm name, equal to
                                         * format name for crypto api */
-       unsigned int    cht_key;        /**< init key by default (vaild for
+       unsigned int    cht_key;        /**< init key by default (valid for
                                         * 4 bytes context like crc32, adler */
        unsigned int    cht_size;       /**< hash digest size */
 };
index 2bd4885ce06cb669dee19c1403d6941f4b33cc28..b270d84def98a823bbf30a5f9ce86aeb8b5763b5 100644 (file)
@@ -183,7 +183,7 @@ struct libcfs_debug_msg_data {
 do {                                                           \
        (data)->msg_subsys = DEBUG_SUBSYSTEM;                   \
        (data)->msg_file   = __FILE__;                          \
-       (data)->msg_fn     = __FUNCTION__;                      \
+       (data)->msg_fn     = __func__;                          \
        (data)->msg_line   = __LINE__;                          \
        (data)->msg_cdls   = (cdls);                            \
        (data)->msg_mask   = (mask);                            \
@@ -193,7 +193,7 @@ do {                                                                \
        static struct libcfs_debug_msg_data dataname = {        \
               .msg_subsys = DEBUG_SUBSYSTEM,                   \
               .msg_file   = __FILE__,                          \
-              .msg_fn     = __FUNCTION__,                      \
+              .msg_fn     = __func__,                          \
               .msg_line   = __LINE__,                          \
               .msg_cdls   = (cdls)      };                     \
        dataname.msg_mask   = (mask);
index e5d5db2556225a7e8f612decadc2736da3e00040..954164361ca405231d42a85366d4086e9c158d48 100644 (file)
@@ -59,8 +59,8 @@
 /*
  * Ideally we would use HAVE_HASH_LONG for this, but on linux we configure
  * the linux kernel and user space at the same time, so we need to differentiate
- * between them explicitely. If this is not needed on other architectures, then
- * we'll need to move the functions to archi specific headers.
+ * between them explicitly. If this is not needed on other architectures, then
+ * we'll need to move the functions to architecture specific headers.
  */
 
 #include <linux/hash.h>
@@ -86,7 +86,7 @@ union cfs_hash_lock {
 
 /**
  * cfs_hash_bucket is a container of:
- * - lock, couter ...
+ * - lock, counter ...
  * - array of hash-head starting from hsb_head[0], hash-head can be one of
  *   . cfs_hash_head_t
  *   . cfs_hash_head_dep_t
@@ -136,7 +136,7 @@ enum cfs_hash_tag {
        CFS_HASH_NO_BKTLOCK     = 1 << 1,
        /** rwlock to protect bucket */
        CFS_HASH_RW_BKTLOCK     = 1 << 2,
-       /** spinlcok to protect bucket */
+       /** spinlock to protect bucket */
        CFS_HASH_SPIN_BKTLOCK   = 1 << 3,
        /** always add new item to tail */
        CFS_HASH_ADD_TAIL       = 1 << 4,
index dddccca120c90be3a5d4a366b1a55caabe873971..740bfcd2f09aad5f0e680d5c45d6a761865339f8 100644 (file)
@@ -153,7 +153,7 @@ do {                                                                            \
  * default allocator
  */
 #define LIBCFS_ALLOC(ptr, size) \
-       LIBCFS_ALLOC_GFP(ptr, size, __GFP_IO)
+       LIBCFS_ALLOC_GFP(ptr, size, GFP_NOFS)
 
 /**
  * non-sleeping allocator
@@ -177,7 +177,7 @@ do {                                                                            \
 
 /** default numa allocator */
 #define LIBCFS_CPT_ALLOC(ptr, cptab, cpt, size)                                    \
-       LIBCFS_CPT_ALLOC_GFP(ptr, cptab, cpt, size, __GFP_IO)
+       LIBCFS_CPT_ALLOC_GFP(ptr, cptab, cpt, size, GFP_NOFS)
 
 #define LIBCFS_FREE(ptr, size)                                   \
 do {                                                               \
index d6e00f92e4a03b44bcd3be2e8af3d55c9b558552..b75e401d9a973c883f6c4785907e210f2c226991 100644 (file)
@@ -66,7 +66,7 @@
  * - spin_unlock(x)
  * - spin_unlock_bh(x)
  * - spin_trylock(x)
- * - spin_is_locked(x)
+ * - assert_spin_locked(x)
  *
  * - spin_lock_irq(x)
  * - spin_lock_irqsave(x, f)
index 2af15d41e77aefe1e9925dce785bdeefe62b0f02..72c76ad96ce941d66f72f5458ef462e8abe29563 100644 (file)
 #include <linux/memcontrol.h>
 #include <linux/mm_inline.h>
 
+#ifndef HAVE_LIBCFS_CPT
+/* Need this for cfs_cpt_table */
+#include <libcfs/libcfs_cpu.h>
+#endif
+
 #define CFS_PAGE_MASK             (~((__u64)PAGE_CACHE_SIZE-1))
 #define page_index(p)       ((p)->index)
 
index 856fcfaafafa702f7140c435e86967230ffc8f95..06ff463e4af635e4a9afacb3fe7956cf5eb127b9 100644 (file)
@@ -181,7 +181,7 @@ lnet_net_lock_current(void)
 #define MAX_PORTALS     64
 
 /* these are only used by code with LNET_USE_LIB_FREELIST, but we still
- * exported them to !LNET_USE_LIB_FREELIST for easy implemetation */
+ * exported them to !LNET_USE_LIB_FREELIST for easy implementation */
 #define LNET_FL_MAX_MES                2048
 #define LNET_FL_MAX_MDS                2048
 #define LNET_FL_MAX_EQS                512
index 1c13ef7df80e0e0b26a2cb0e4c396c10177cb001..a63654b660de4523636085c0240a8172d85ef52e 100644 (file)
@@ -204,7 +204,7 @@ typedef struct lnet_msg {
        unsigned int      msg_receiving:1;    /* being received */
        unsigned int      msg_txcredit:1;     /* taken an NI send credit */
        unsigned int      msg_peertxcredit:1; /* taken a peer send credit */
-       unsigned int      msg_rtrcredit:1;    /* taken a globel router credit */
+       unsigned int      msg_rtrcredit:1;    /* taken a global router credit */
        unsigned int      msg_peerrtrcredit:1; /* taken a peer router credit */
        unsigned int      msg_onactivelist:1; /* on the activelist */
 
@@ -342,7 +342,7 @@ typedef struct lnet_lnd {
 
        /* Start receiving 'mlen' bytes of payload data, skipping the following
         * 'rlen' - 'mlen' bytes. 'private' is the 'private' passed to
-        * lnet_parse().  Return non-zero for immedaite failure, otherwise
+        * lnet_parse().  Return non-zero for immediate failure, otherwise
         * complete later with lnet_finalize().  This also gives back a receive
         * credit if the LND does flow control. */
        int (*lnd_recv)(struct lnet_ni *ni, void *private, lnet_msg_t *msg,
@@ -594,7 +594,7 @@ struct lnet_match_table {
        unsigned int            mt_cpt;
        unsigned int            mt_portal;      /* portal index */
        /* match table is set as "enabled" if there's non-exhausted MD
-        * attached on mt_mhash, it's only valide for wildcard portal */
+        * attached on mt_mhash, it's only valid for wildcard portal */
        unsigned int            mt_enabled;
        /* bitmap to flag whether MEs on mt_hash are exhausted or not */
        __u64                   mt_exhausted[LNET_MT_EXHAUSTED_BMAP];
index e060599314d587c09ef6cae2708bf43e31ea2d32..87fe9ac76a6ca8e7b75c0084dd2df17ae509d608 100644 (file)
@@ -402,7 +402,7 @@ typedef struct {
 /* add stat in session */
 typedef struct {
        int                  lstio_sta_key;       /* IN: session key */
-       int                  lstio_sta_timeout;      /* IN: timeout for stat requst */
+       int                  lstio_sta_timeout;      /* IN: timeout for stat request */
        int                  lstio_sta_nmlen;   /* IN: group name length */
        char               *lstio_sta_namep;    /* IN: group name */
        int                  lstio_sta_count;   /* IN: # of pid */
index 564f5d3a9b4d0d41ba972bb2d3921e621f5e3c19..313442a7ed3e0f1f20a17726f58b56a86f6115fd 100644 (file)
@@ -66,7 +66,7 @@
 /*#define PTL_MD_LUSTRE_COMPLETION_SEMANTICS */
 
 /* Can compare handles directly on Cray Portals */
-#define PtlHandleIsEqual(a,b) ((a) == (b))
+#define PtlHandleIsEqual(a, b) ((a) == (b))
 
 /* Different error types on Cray Portals*/
 #define ptl_err_t ptl_ni_fail_t
index 7d12b3a23a964cf2637b5a0fd27302616633770c..0d3ec5be0a00a202303a217f4c158432e9c1147d 100644 (file)
                                         * above is for bulk data transfer */
 #define LNET_MSG_MATCHBITS       0      /* the value for the message channel */
 
-typedef struct
-{
+typedef struct {
        lnet_hdr_t      kptlim_hdr;          /* portals header */
        char          kptlim_payload[0];      /* piggy-backed payload */
 } WIRE_ATTR kptl_immediate_msg_t;
 
-typedef struct
-{
+typedef struct {
        lnet_hdr_t      kptlrm_hdr;          /* portals header */
        __u64        kptlrm_matchbits;       /* matchbits */
 } WIRE_ATTR kptl_rdma_msg_t;
 
-typedef struct
-{
+typedef struct {
        __u64        kptlhm_matchbits;       /* matchbits */
        __u32        kptlhm_max_msg_size;    /* max message size */
 } WIRE_ATTR kptl_hello_msg_t;
 
-typedef struct
-{
+typedef struct {
        /* First 2 fields fixed FOR ALL TIME */
        __u32      ptlm_magic;     /* I'm a Portals LND message */
        __u16      ptlm_version;   /* this is my version number */
@@ -107,7 +103,7 @@ typedef struct
 } kptl_msg_t;
 
 /* kptl_msg_t::ptlm_credits is only a __u8 */
-#define PTLLND_MSG_MAX_CREDITS ((typeof(((kptl_msg_t*) 0)->ptlm_credits)) -1)
+#define PTLLND_MSG_MAX_CREDITS ((typeof(((kptl_msg_t*) 0)->ptlm_credits)) - 1)
 
 #define PTLLND_MSG_MAGIC               LNET_PROTO_PTL_MAGIC
 #define PTLLND_MSG_VERSION           0x04
index c833ce8544d3cb3a92df25e3040954c1cce07ce1..2add7976b3b225f1b305739c0286279e36864a4c 100644 (file)
@@ -112,7 +112,7 @@ static inline void LNetInvalidateHandle(lnet_handle_any_t *h)
  */
 static inline int LNetHandleIsEqual (lnet_handle_any_t h1, lnet_handle_any_t h2)
 {
-       return (h1.cookie == h2.cookie);
+       return h1.cookie == h2.cookie;
 }
 
 /**
@@ -122,7 +122,7 @@ static inline int LNetHandleIsEqual (lnet_handle_any_t h1, lnet_handle_any_t h2)
  */
 static inline int LNetHandleIsInvalid(lnet_handle_any_t h)
 {
-       return (LNET_WIRE_HANDLE_COOKIE_NONE == h.cookie);
+       return LNET_WIRE_HANDLE_COOKIE_NONE == h.cookie;
 }
 
 /**
@@ -181,7 +181,7 @@ typedef struct {
         * address of an array of lnet_kiov_t and the length field specifies
         * the number of entries in the array. The length can't be bigger
         * than LNET_MAX_IOV. The lnet_kiov_t is used to describe page-based
-        * fragments that are not necessarily mapped in virtal memory.
+        * fragments that are not necessarily mapped in virtual memory.
         * - LNET_MD_IOVEC bit set: The start field points to the starting
         * address of an array of struct iovec and the length field specifies
         * the number of entries in the array. The length can't be bigger
@@ -381,7 +381,7 @@ typedef enum {
 
 #define LNET_SEQ_BASETYPE       long
 typedef unsigned LNET_SEQ_BASETYPE lnet_seq_t;
-#define LNET_SEQ_GT(a,b)       (((signed LNET_SEQ_BASETYPE)((a) - (b))) > 0)
+#define LNET_SEQ_GT(a, b)      (((signed LNET_SEQ_BASETYPE)((a) - (b))) > 0)
 
 /**
  * Information about an event on a MD.
index 0061c8afa206af92e5c527a1c995451c22d2ee18..892c41991f83cd27b4aa651b972b11ca1888117e 100644 (file)
@@ -1141,7 +1141,7 @@ kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages)
        for (i = 0; i < npages; i++) {
                p->ibp_pages[i] = alloc_pages_node(
                                    cfs_cpt_spread_node(lnet_cpt_table(), cpt),
-                                   __GFP_IO, 0);
+                                   GFP_NOFS, 0);
                if (p->ibp_pages[i] == NULL) {
                        CERROR("Can't allocate page %d of %d\n", i, npages);
                        kiblnd_free_pages(p);
index 45c23194081b282e36c22071b8651b91921efdc4..85b8d815282d5b05517343578ea3db8e46766439 100644 (file)
@@ -338,7 +338,7 @@ lnet_counters_get(lnet_counters_t *counters)
                counters->send_count   += ctr->send_count;
                counters->recv_count   += ctr->recv_count;
                counters->route_count  += ctr->route_count;
-               counters->drop_length  += ctr->drop_length;
+               counters->drop_count   += ctr->drop_count;
                counters->send_length  += ctr->send_length;
                counters->recv_length  += ctr->recv_length;
                counters->route_length += ctr->route_length;
@@ -986,12 +986,11 @@ lnet_shutdown_lndnis (void)
                        break;
                }
 
-               while (!list_empty(&ni->ni_list)) {
+               if (!list_empty(&ni->ni_list)) {
                        lnet_net_unlock(LNET_LOCK_EX);
                        ++i;
                        if ((i & (-i)) == i) {
-                               CDEBUG(D_WARNING,
-                                      "Waiting for zombie LNI %s\n",
+                               CDEBUG(D_WARNING, "Waiting for zombie LNI %s\n",
                                       libcfs_nid2str(ni->ni_nid));
                        }
                        set_current_state(TASK_UNINTERRUPTIBLE);
@@ -1016,6 +1015,8 @@ lnet_shutdown_lndnis (void)
                               libcfs_nid2str(ni->ni_nid));
 
                lnet_ni_free(ni);
+               i = 2;
+
                lnet_net_lock(LNET_LOCK_EX);
        }
 
index ddd813cab501d97be25f1a23e7ddf351093ceddb..6f5674d1aa7255c4b07b765405e8ba471c1466e3 100644 (file)
 #include <lustre_fid.h>
 #include "fid_internal.h"
 
+/* Format: [0x64BIT_INT - 0x64BIT_INT] + 32 bytes just in case */
+#define MAX_FID_RANGE_STRLEN (32 + 2 * 2 * sizeof(__u64))
 /*
  * Note: this function is only used for testing, it is no safe for production
  * use.
  */
-static int
-lprocfs_fid_write_common(const char *buffer, unsigned long count,
-                        struct lu_seq_range *range)
+static int lprocfs_fid_write_common(const char __user *buffer, size_t count,
+                                   struct lu_seq_range *range)
 {
        struct lu_seq_range tmp;
        int rc;
+       char kernbuf[MAX_FID_RANGE_STRLEN];
 
        LASSERT(range != NULL);
 
-       rc = sscanf(buffer, "[%llx - %llx]\n",
+       if (count >= sizeof(kernbuf))
+               return -EINVAL;
+
+       if (copy_from_user(kernbuf, buffer, count))
+               return -EFAULT;
+
+       kernbuf[count] = 0;
+
+       if (count == 5 && strcmp(kernbuf, "clear") == 0) {
+               memset(range, 0, sizeof(*range));
+               return count;
+       }
+
+       /* of the form "[0x0000000240000400 - 0x000000028000400]" */
+       rc = sscanf(kernbuf, "[%llx - %llx]\n",
                    (long long unsigned *)&tmp.lsr_start,
                    (long long unsigned *)&tmp.lsr_end);
-       if (rc != 2 || !range_is_sane(&tmp) || range_is_zero(&tmp))
+       if (!range_is_sane(&tmp) || range_is_zero(&tmp) ||
+           tmp.lsr_start < range->lsr_start || tmp.lsr_end > range->lsr_end)
                return -EINVAL;
        *range = tmp;
-       return 0;
+       return count;
 }
 
 /* Client side procfs stuff */
-static ssize_t
-lprocfs_fid_space_seq_write(struct file *file, const char *buffer,
-                           size_t count, loff_t *off)
+static ssize_t lprocfs_fid_space_seq_write(struct file *file,
+                                          const char __user *buffer,
+                                          size_t count, loff_t *off)
 {
        struct lu_client_seq *seq = ((struct seq_file *)file->private_data)->private;
        int rc;
@@ -114,9 +131,9 @@ lprocfs_fid_space_seq_show(struct seq_file *m, void *unused)
        return rc;
 }
 
-static ssize_t
-lprocfs_fid_width_seq_write(struct file *file, const char *buffer,
-                           size_t count, loff_t *off)
+static ssize_t lprocfs_fid_width_seq_write(struct file *file,
+                                          const char __user *buffer,
+                                          size_t count, loff_t *off)
 {
        struct lu_client_seq *seq = ((struct seq_file *)file->private_data)->private;
        __u64  max;
index 9304c269afa9536da170e4724fc561ba63e6e92b..9b7921d1dea849779a6b2dfc66d7cdae98f1a04e 100644 (file)
@@ -441,7 +441,8 @@ struct dt_object_operations {
                                        struct dt_object *dt,
                                        struct lustre_capa *old,
                                        __u64 opc);
-       int (*do_object_sync)(const struct lu_env *, struct dt_object *);
+       int (*do_object_sync)(const struct lu_env *env, struct dt_object *obj,
+                             __u64 start, __u64 end);
        /**
         * Get object info of next level. Currently, only get inode from osd.
         * This is only used by quota b=16542
@@ -900,13 +901,13 @@ static inline int dt_object_lock(const struct lu_env *env,
 int dt_lookup_dir(const struct lu_env *env, struct dt_object *dir,
                  const char *name, struct lu_fid *fid);
 
-static inline int dt_object_sync(const struct lu_env *env,
-                                struct dt_object *o)
+static inline int dt_object_sync(const struct lu_env *env, struct dt_object *o,
+                                __u64 start, __u64 end)
 {
        LASSERT(o);
        LASSERT(o->do_ops);
        LASSERT(o->do_ops->do_object_sync);
-       return o->do_ops->do_object_sync(env, o);
+       return o->do_ops->do_object_sync(env, o, start, end);
 }
 
 int dt_declare_version_set(const struct lu_env *env, struct dt_object *o,
diff --git a/drivers/staging/lustre/lustre/include/ioctl.h b/drivers/staging/lustre/lustre/include/ioctl.h
deleted file mode 100644 (file)
index b986920..0000000
+++ /dev/null
@@ -1,106 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2003, 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.
- */
-
-#ifndef _IOWR
-
-/* On i386 and x86_64, _ASM_I386_IOCTL_H is defined by the kernel's ioctl.h,
- * and on newer kernels this header is shared as _ASM_GENERIC_IOCTL_H.
- *
- * We can avoid any problems with the kernel header being included again by
- * defining _ASM_I386_IOCTL_H here so that a later occurrence of <asm/ioctl.h>
- * does not include the kernel's ioctl.h after this one. b=14746 */
-#define _ASM_I386_IOCTL_H
-#define _ASM_GENERIC_IOCTL_H
-
-/* ioctl command encoding: 32 bits total, command in lower 16 bits,
- * size of the parameter structure in the lower 14 bits of the
- * upper 16 bits.
- * Encoding the size of the parameter structure in the ioctl request
- * The highest 2 bits are reserved for indicating the ``access mode''.
- * NOTE: This limits the max parameter size to 16kB -1 !
- */
-
-/*
- * The following is for compatibility across the various Linux
- * platforms.  The i386 ioctl numbering scheme doesn't really enforce
- * a type field.  De facto, however, the top 8 bits of the lower 16
- * bits are indeed used as a type field, so we might just as well make
- * this explicit here.  Please be sure to use the decoding macros
- * below from now on.
- */
-#define _IOC_NRBITS     8
-#define _IOC_TYPEBITS   8
-#define _IOC_SIZEBITS   14
-#define _IOC_DIRBITS    2
-
-#define _IOC_NRMASK     ((1 << _IOC_NRBITS)-1)
-#define _IOC_TYPEMASK   ((1 << _IOC_TYPEBITS)-1)
-#define _IOC_SIZEMASK   ((1 << _IOC_SIZEBITS)-1)
-#define _IOC_DIRMASK    ((1 << _IOC_DIRBITS)-1)
-
-#define _IOC_NRSHIFT    0
-#define _IOC_TYPESHIFT  (_IOC_NRSHIFT+_IOC_NRBITS)
-#define _IOC_SIZESHIFT  (_IOC_TYPESHIFT+_IOC_TYPEBITS)
-#define _IOC_DIRSHIFT   (_IOC_SIZESHIFT+_IOC_SIZEBITS)
-
-/*
- * Direction bits.
- */
-#define _IOC_NONE       0U
-#define _IOC_WRITE      1U
-#define _IOC_READ       2U
-
-#define _IOC(dir,type,nr,size) (((dir)  << _IOC_DIRSHIFT) | ((type) << _IOC_TYPESHIFT) | ((nr)   << _IOC_NRSHIFT) | ((size) << _IOC_SIZESHIFT))
-
-/* used to create numbers */
-#define _IO(type,nr)       _IOC(_IOC_NONE,(type),(nr),0)
-#define _IOR(type,nr,size)      _IOC(_IOC_READ,(type),(nr),sizeof(size))
-#define _IOW(type,nr,size)      _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
-#define _IOWR(type,nr,size)     _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
-
-/* used to decode ioctl numbers.. */
-#define _IOC_DIR(nr)       (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
-#define _IOC_TYPE(nr)     (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
-#define _IOC_NR(nr)         (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
-#define _IOC_SIZE(nr)     (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
-
-/* ...and for the drivers/sound files... */
-
-#define IOC_IN   (_IOC_WRITE << _IOC_DIRSHIFT)
-#define IOC_OUT         (_IOC_READ << _IOC_DIRSHIFT)
-#define IOC_INOUT       ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
-#define IOCSIZE_MASK    (_IOC_SIZEMASK << _IOC_SIZESHIFT)
-#define IOCSIZE_SHIFT   (_IOC_SIZESHIFT)
-
-#endif /* _IOWR */
index dc36f75eb6353fce182dab039ecdad6155f13ed4..fea7e6cd44c303fe001ba53b702cbde6b4f0b717 100644 (file)
@@ -104,7 +104,7 @@ static inline void __client_obd_list_lock(client_obd_lock_t *lock,
 }
 
 #define client_obd_list_lock(lock) \
-       __client_obd_list_lock(lock, __FUNCTION__, __LINE__)
+       __client_obd_list_lock(lock, __func__, __LINE__)
 
 static inline void client_obd_list_unlock(client_obd_lock_t *lock)
 {
index 428e3e4ce05c1a72776c75b56be47f069bb139ad..9ce12c78d47a740e89fb405bf86c2c589c30e55d 100644 (file)
@@ -687,7 +687,7 @@ static int name##_single_open(cfs_inode_t *inode, struct file *file)        \
 {                                                                      \
        return single_open(file, name##_seq_show, PDE_DATA(inode));     \
 }                                                                      \
-struct file_operations name##_fops = {                              \
+static struct file_operations name##_fops = {                          \
        .owner   = THIS_MODULE,                                     \
        .open    = name##_single_open,                               \
        .read    = seq_read,                                           \
@@ -730,7 +730,7 @@ struct file_operations name##_fops = {                                   \
        {                                                               \
                return single_open(file, NULL, PDE_DATA(inode));        \
        }                                                               \
-       struct file_operations name##_##type##_fops = {                 \
+       static struct file_operations name##_##type##_fops = {  \
                .open   = name##_##type##_open,                         \
                .write  = name##_##type##_write,                        \
                .release = lprocfs_single_release,                      \
index 6773bca1e0d834084d22f14e73db81672329a3f3..98149f5da1538c7dce90bb12bf76d31e857e505f 100644 (file)
@@ -515,6 +515,10 @@ enum lu_object_header_attr {
  * whether object is backed by persistent storage entity.
  */
 struct lu_object_header {
+       /**
+        * Fid, uniquely identifying this object.
+        */
+       struct lu_fid           loh_fid;
        /**
         * Object flags from enum lu_object_header_flags. Set and checked
         * atomically.
@@ -524,10 +528,6 @@ struct lu_object_header {
         * Object reference count. Protected by lu_site::ls_guard.
         */
        atomic_t           loh_ref;
-       /**
-        * Fid, uniquely identifying this object.
-        */
-       struct lu_fid     loh_fid;
        /**
         * Common object attributes, cached for efficiency. From enum
         * lu_object_header_attr.
index 50a2a7f786dc5d4fbbcad62da76f63d605e14114..b451a888ca3a54c68d8c4ba60bf837a5435d1745 100644 (file)
  *
  *     // current thread acquired a temporary reference to foo.
  *     foo_get(foo);
- *     lu_ref_add(&foo->reference, __FUNCTION__, current);
+ *     lu_ref_add(&foo->reference, __func__, current);
  *
  *     ...
  *
  *     // temporary reference is released.
- *     lu_ref_del(&foo->reference, __FUNCTION__, current);
+ *     lu_ref_del(&foo->reference, __func__, current);
  *     foo_put(foo);
  * \endcode
  *
index 87905bbc68e1f678d1dc1942e6c05ba7909e3f96..83014c9fea6585ccea38c9b5d06bf6a5910e8bdd 100644 (file)
@@ -265,7 +265,7 @@ static inline __u64 range_space(const struct lu_seq_range *range)
 
 static inline void range_init(struct lu_seq_range *range)
 {
-       range->lsr_start = range->lsr_end = range->lsr_index = 0;
+       memset(range, 0, sizeof(*range));
 }
 
 /**
@@ -1682,6 +1682,30 @@ static inline __u32 lov_mds_md_size(__u16 stripes, __u32 lmm_magic)
                                stripes * sizeof(struct lov_ost_data_v1);
 }
 
+static inline __u32
+lov_mds_md_max_stripe_count(size_t buf_size, __u32 lmm_magic)
+{
+       switch (lmm_magic) {
+       case LOV_MAGIC_V1: {
+               struct lov_mds_md_v1 lmm;
+
+               if (buf_size < sizeof(lmm))
+                       return 0;
+
+               return (buf_size - sizeof(lmm)) / sizeof(lmm.lmm_objects[0]);
+       }
+       case LOV_MAGIC_V3: {
+               struct lov_mds_md_v3 lmm;
+
+               if (buf_size < sizeof(lmm))
+                       return 0;
+
+               return (buf_size - sizeof(lmm)) / sizeof(lmm.lmm_objects[0]);
+       }
+       default:
+               return 0;
+       }
+}
 
 #define OBD_MD_FLID    (0x00000001ULL) /* object ID */
 #define OBD_MD_FLATIME     (0x00000002ULL) /* access time */
@@ -2681,6 +2705,8 @@ enum seq_op {
  * protocol, this will limit the max number of OSTs per LOV */
 
 #define LOV_DESC_MAGIC 0xB0CCDE5C
+#define LOV_DESC_QOS_MAXAGE_DEFAULT 5  /* Seconds */
+#define LOV_DESC_STRIPE_SIZE_DEFAULT (1 << LNET_MTU_BITS)
 
 /* LOV settings descriptor (should only contain static info) */
 struct lov_desc {
index f5f369e603def0286d32edd8bd7be8b5a36dbaa4..95c754f2075f4f211d23a70ead54c8068aa70717 100644 (file)
@@ -1106,7 +1106,8 @@ static inline struct hsm_action_item * hai_zero(struct hsm_action_list *hal)
 {
        return (struct hsm_action_item *)(hal->hal_fsname +
                                          cfs_size_round(strlen(hal-> \
-                                                               hal_fsname)));
+                                                               hal_fsname)
+                                                        + 1));
 }
 /* Return pointer to next hai */
 static inline struct hsm_action_item * hai_next(struct hsm_action_item *hai)
@@ -1121,7 +1122,7 @@ static inline int hal_size(struct hsm_action_list *hal)
        int i, sz;
        struct hsm_action_item *hai;
 
-       sz = sizeof(*hal) + cfs_size_round(strlen(hal->hal_fsname));
+       sz = sizeof(*hal) + cfs_size_round(strlen(hal->hal_fsname) + 1);
        hai = hai_zero(hal);
        for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai))
                sz += cfs_size_round(hai->hai_len);
index 7ec91edd680096932d4872adb1def8d0478fb5be..6146ccb8cce0042fa5eea48bed71b8dbe3f7dd18 100644 (file)
@@ -48,7 +48,6 @@
 /* lib/debug.c */
 void dump_lniobuf(struct niobuf_local *lnb);
 int dump_req(struct ptlrpc_request *req);
-void dump_lsm(int level, struct lov_stripe_md *lsm);
 int block_debug_setup(void *addr, int len, __u64 off, __u64 id);
 int block_debug_check(char *who, void *addr, int len, __u64 off, __u64 id);
 
index 3e25f001c07d6889188891f3289d45acb31d7074..0c6b7841e56d09b47ba168082af285d04991fa46 100644 (file)
@@ -212,7 +212,7 @@ struct ldlm_pool_ops {
        int (*po_recalc)(struct ldlm_pool *pl);
        /** Cancel at least \a nr locks from pool \a pl */
        int (*po_shrink)(struct ldlm_pool *pl, int nr,
-                        unsigned int gfp_mask);
+                        gfp_t gfp_mask);
        int (*po_setup)(struct ldlm_pool *pl, int limit);
 };
 
@@ -260,7 +260,7 @@ struct ldlm_pool {
        /** Recalculation period for pool. */
        time_t                  pl_recalc_period;
        /** Recalculation and shrink operations. */
-       struct ldlm_pool_ops    *pl_ops;
+       const struct ldlm_pool_ops      *pl_ops;
        /** Number of planned locks for next period. */
        int                     pl_grant_plan;
        /** Pool statistics. */
@@ -1312,11 +1312,11 @@ int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *,
                              const struct ldlm_res_id *);
 
 #define LDLM_RESOURCE_ADDREF(res) do {                           \
-       lu_ref_add_atomic(&(res)->lr_reference, __FUNCTION__, current);  \
+       lu_ref_add_atomic(&(res)->lr_reference, __func__, current);  \
 } while (0)
 
 #define LDLM_RESOURCE_DELREF(res) do {                           \
-       lu_ref_del(&(res)->lr_reference, __FUNCTION__, current);  \
+       lu_ref_del(&(res)->lr_reference, __func__, current);      \
 } while (0)
 
 /* ldlm_request.c */
@@ -1445,7 +1445,7 @@ static inline void unlock_res(struct ldlm_resource *res)
 /** Check if resource is already locked, assert if not. */
 static inline void check_res_locked(struct ldlm_resource *res)
 {
-       LASSERT(spin_is_locked(&res->lr_lock));
+       assert_spin_locked(&res->lr_lock);
 }
 
 struct ldlm_resource * lock_res_and_lock(struct ldlm_lock *lock);
@@ -1463,7 +1463,7 @@ void ldlm_pools_fini(void);
 int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns,
                   int idx, ldlm_side_t client);
 int ldlm_pool_shrink(struct ldlm_pool *pl, int nr,
-                    unsigned int gfp_mask);
+                    gfp_t gfp_mask);
 void ldlm_pool_fini(struct ldlm_pool *pl);
 int ldlm_pool_setup(struct ldlm_pool *pl, int limit);
 int ldlm_pool_recalc(struct ldlm_pool *pl);
index 0368ca6ffcc1cdee96f3899c5b8e431e5b98db9f..bdc981214805eddc8e3beb32ff01c727c362796c 100644 (file)
@@ -94,19 +94,6 @@ struct obd_client_handle {
 void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs);
 void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs);
 
-/* l_lock.c */
-struct lustre_lock {
-       int                     l_depth;
-       struct task_struct      *l_owner;
-       struct semaphore        l_sem;
-       spinlock_t              l_spin;
-};
-
-void l_lock_init(struct lustre_lock *);
-void l_lock(struct lustre_lock *);
-void l_unlock(struct lustre_lock *);
-int l_has_lock(struct lustre_lock *);
-
 /*
  * For md echo client
  */
index 896c7576aa0feecef689d295a7c64766bbd403be..1a9a9228b795efea1f5bc8ff2307c71aa2c6d247 100644 (file)
@@ -206,11 +206,7 @@ int llog_setup(const struct lu_env *env, struct obd_device *obd,
 int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt);
 int llog_cleanup(const struct lu_env *env, struct llog_ctxt *);
 int llog_sync(struct llog_ctxt *ctxt, struct obd_export *exp, int flags);
-int llog_obd_add(const struct lu_env *env, struct llog_ctxt *ctxt,
-                struct llog_rec_hdr *rec, struct lov_stripe_md *lsm,
-                struct llog_cookie *logcookies, int numcookies);
 int llog_cancel(const struct lu_env *env, struct llog_ctxt *ctxt,
-               struct lov_stripe_md *lsm, int count,
                struct llog_cookie *cookies, int flags);
 
 int obd_llog_init(struct obd_device *obd, struct obd_llog_group *olg,
@@ -242,7 +238,6 @@ struct llog_operations {
                        int flags);
        int (*lop_cleanup)(const struct lu_env *env, struct llog_ctxt *ctxt);
        int (*lop_cancel)(const struct lu_env *env, struct llog_ctxt *ctxt,
-                         struct lov_stripe_md *lsm, int count,
                          struct llog_cookie *cookies, int flags);
        int (*lop_connect)(struct llog_ctxt *ctxt, struct llog_logid *logid,
                           struct llog_gen *gen, struct obd_uuid *uuid);
@@ -296,11 +291,6 @@ struct llog_operations {
        int (*lop_add)(const struct lu_env *env, struct llog_handle *lgh,
                       struct llog_rec_hdr *rec, struct llog_cookie *cookie,
                       void *buf, struct thandle *th);
-       /* Old llog_add version, used in MDS-LOV-OSC now and will gone with
-        * LOD/OSP replacement */
-       int (*lop_obd_add)(const struct lu_env *env, struct llog_ctxt *ctxt,
-                          struct llog_rec_hdr *rec, struct lov_stripe_md *lsm,
-                          struct llog_cookie *logcookies, int numcookies);
 };
 
 /* In-memory descriptor for a log object or log catalog */
index 468f36344a34d86275ae9a0b09abda6318f967e5..66765d4d201ddf65a2b4cbfc741861b2f0705fd9 100644 (file)
@@ -140,17 +140,26 @@ static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck,
        mutex_unlock(&lck->rpcl_mutex);
 }
 
+/* Update the maximum observed easize and cookiesize.  The default easize
+ * and cookiesize is initialized to the minimum value but allowed to grow
+ * up to a single page in size if required to handle the common case.
+ */
 static inline void mdc_update_max_ea_from_body(struct obd_export *exp,
                                               struct mdt_body *body)
 {
        if (body->valid & OBD_MD_FLMODEASIZE) {
-               if (exp->exp_obd->u.cli.cl_max_mds_easize < body->max_mdsize)
-                       exp->exp_obd->u.cli.cl_max_mds_easize =
-                                               body->max_mdsize;
-               if (exp->exp_obd->u.cli.cl_max_mds_cookiesize <
-                                               body->max_cookiesize)
-                       exp->exp_obd->u.cli.cl_max_mds_cookiesize =
-                                               body->max_cookiesize;
+               struct client_obd *cli = &exp->exp_obd->u.cli;
+
+               if (cli->cl_max_mds_easize < body->max_mdsize) {
+                       cli->cl_max_mds_easize = body->max_mdsize;
+                       cli->cl_default_mds_easize =
+                           min_t(__u32, body->max_mdsize, PAGE_CACHE_SIZE);
+               }
+               if (cli->cl_max_mds_cookiesize < body->max_cookiesize) {
+                       cli->cl_max_mds_cookiesize = body->max_cookiesize;
+                       cli->cl_default_mds_cookiesize =
+                           min_t(__u32, body->max_cookiesize, PAGE_CACHE_SIZE);
+               }
        }
 }
 
index 745adbb74cfce7eb34a8ba11cd5ce9a8c7ee23ee..f6b7d10cb78cf64c46652370cf803c4af0e1b6a5 100644 (file)
 #define LDLM_MAXREQSIZE   (5 * 1024)
 #define LDLM_MAXREPSIZE   (1024)
 
+#define MDS_MAXREQSIZE         (5 * 1024)      /* >= 4736 */
+
 #define OST_MAXREQSIZE         (5 * 1024)
 
 /* Macro to hide a typecast. */
@@ -717,7 +719,7 @@ struct ptlrpc_nrs_pol_ops {
         *                       \a nrq
         * \param[in,out] nrq    The request
         *
-        * \pre spin_is_locked(&svcpt->scp_req_lock)
+        * \pre assert_spin_locked(&svcpt->scp_req_lock)
         *
         * \see ptlrpc_nrs_req_stop_nolock()
         */
index 72cf3fe4b0c9b51d5a62590eb9886d4a3ef6362f..d5c4613f182d934f282c685502bf0ffa61fa2219 100644 (file)
@@ -132,6 +132,13 @@ static inline bool lsm_has_objects(struct lov_stripe_md *lsm)
        return true;
 }
 
+static inline int lov_stripe_md_size(unsigned int stripe_count)
+{
+       struct lov_stripe_md lsm;
+
+       return sizeof(lsm) + stripe_count * sizeof(lsm.lsm_oinfo[0]);
+}
+
 struct obd_info;
 
 typedef int (*obd_enqueue_update_f)(void *cookie, int rc);
@@ -309,9 +316,10 @@ struct client_obd {
        int                   cl_conn_count;
        /* max_mds_easize is purely a performance thing so we don't have to
         * call obd_size_diskmd() all the time. */
-       int                   cl_default_mds_easize;
-       int                   cl_max_mds_easize;
-       int                   cl_max_mds_cookiesize;
+       int                      cl_default_mds_easize;
+       int                      cl_max_mds_easize;
+       int                      cl_default_mds_cookiesize;
+       int                      cl_max_mds_cookiesize;
 
        enum lustre_sec_part     cl_sp_me;
        enum lustre_sec_part     cl_sp_to;
@@ -398,7 +406,7 @@ struct client_obd {
        struct mdc_rpc_lock     *cl_close_lock;
 
        /* mgc datastruct */
-       struct semaphore         cl_mgc_sem;
+       struct mutex             cl_mgc_mutex;
        struct local_oid_storage *cl_mgc_los;
        struct dt_object        *cl_mgc_configs_dir;
        atomic_t             cl_mgc_refcount;
@@ -598,6 +606,7 @@ struct lmv_obd {
        int                     max_easize;
        int                     max_def_easize;
        int                     max_cookiesize;
+       int                     max_def_cookiesize;
        int                     server_timeout;
 
        int                     tgts_size; /* size of tgts array */
@@ -989,7 +998,10 @@ enum obd_cleanup_stage {
 #define KEY_LOCK_TO_STRIPE      "lock_to_stripe"
 #define KEY_LOVDESC         "lovdesc"
 #define KEY_LOV_IDX         "lov_idx"
-#define KEY_MAX_EASIZE   "max_easize"
+#define KEY_MAX_EASIZE         "max_easize"
+#define KEY_DEFAULT_EASIZE     "default_easize"
+#define KEY_MAX_COOKIESIZE     "max_cookiesize"
+#define KEY_DEFAULT_COOKIESIZE "default_cookiesize"
 #define KEY_MDS_CONN       "mds_conn"
 #define KEY_MGSSEC           "mgssec"
 #define KEY_NEXT_ID         "next_id"
@@ -1383,7 +1395,7 @@ struct md_ops {
                          const char *, int, int, int,
                          struct ptlrpc_request **);
 
-       int (*m_init_ea_size)(struct obd_export *, int, int, int);
+       int (*m_init_ea_size)(struct obd_export *, int, int, int, int);
 
        int (*m_get_lustre_md)(struct obd_export *, struct ptlrpc_request *,
                               struct obd_export *, struct obd_export *,
index 9d1f266e55e4f52c20bf4c5d46a1f3cccc20bfc0..61ba370794f8c8a1d92779f670397998ecb856d4 100644 (file)
@@ -711,15 +711,6 @@ static inline int obd_size_diskmd(struct obd_export *exp,
        return obd_packmd(exp, NULL, mem_src);
 }
 
-/* helper functions */
-static inline int obd_alloc_diskmd(struct obd_export *exp,
-                                  struct lov_mds_md **disk_tgt)
-{
-       LASSERT(disk_tgt);
-       LASSERT(*disk_tgt == NULL);
-       return obd_packmd(exp, disk_tgt, NULL);
-}
-
 static inline int obd_free_diskmd(struct obd_export *exp,
                                  struct lov_mds_md **disk_tgt)
 {
@@ -2055,12 +2046,13 @@ static inline ldlm_mode_t md_lock_match(struct obd_export *exp, __u64 flags,
 }
 
 static inline int md_init_ea_size(struct obd_export *exp, int easize,
-                                 int def_asize, int cookiesize)
+                                 int def_asize, int cookiesize,
+                                 int def_cookiesize)
 {
        EXP_CHECK_MD_OP(exp, init_ea_size);
        EXP_MD_COUNTER_INCREMENT(exp, init_ea_size);
        return MDP(exp->exp_obd, init_ea_size)(exp, easize, def_asize,
-                                              cookiesize);
+                                              cookiesize, def_cookiesize);
 }
 
 static inline int md_get_remote_perm(struct obd_export *exp,
@@ -2133,7 +2125,7 @@ extern struct kmem_cache *obdo_cachep;
 
 #define OBDO_ALLOC(ptr)                                                       \
 do {                                                                     \
-       OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, __GFP_IO);        \
+       OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, GFP_NOFS);             \
 } while(0)
 
 #define OBDO_FREE(ptr)                                                 \
diff --git a/drivers/staging/lustre/lustre/include/obd_lov.h b/drivers/staging/lustre/lustre/include/obd_lov.h
deleted file mode 100644 (file)
index 235718b..0000000
+++ /dev/null
@@ -1,116 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef _OBD_LOV_H__
-#define _OBD_LOV_H__
-
-#define LOV_DEFAULT_STRIPE_SIZE (1 << LNET_MTU_BITS)
-
-static inline int lov_stripe_md_size(__u16 stripes)
-{
-       return sizeof(struct lov_stripe_md) + stripes*sizeof(struct lov_oinfo*);
-}
-
-struct lov_version_size {
-       __u32   lvs_magic;
-       size_t  lvs_lmm_size;
-       size_t  lvs_lod_size;
-};
-
-static inline __u32 lov_mds_md_stripecnt(int ea_size, __u32 lmm_magic)
-{
-       static const struct lov_version_size lmm_ver_size[] = {
-                       { .lvs_magic = LOV_MAGIC_V3,
-                         .lvs_lmm_size = sizeof(struct lov_mds_md_v3),
-                         .lvs_lod_size = sizeof(struct lov_ost_data_v1) },
-                       { .lvs_magic = LOV_MAGIC_V1,
-                         .lvs_lmm_size = sizeof(struct lov_mds_md_v1),
-                         .lvs_lod_size = sizeof(struct lov_ost_data_v1)} };
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(lmm_ver_size); i++) {
-               if (lmm_magic == lmm_ver_size[i].lvs_magic) {
-                       if (ea_size <= lmm_ver_size[i].lvs_lmm_size)
-                               return 0;
-                       return (ea_size - lmm_ver_size[i].lvs_lmm_size) /
-                               lmm_ver_size[i].lvs_lod_size;
-               }
-       }
-
-       /* Invalid LOV magic, so no stripes could fit */
-       return 0;
-}
-
-/* lov_do_div64(a, b) returns a % b, and a = a / b.
- * The 32-bit code is LOV-specific due to knowing about stripe limits in
- * order to reduce the divisor to a 32-bit number.  If the divisor is
- * already a 32-bit value the compiler handles this directly. */
-#if BITS_PER_LONG > 32
-# define lov_do_div64(n,base) ({                                       \
-       uint64_t __base = (base);                                       \
-       uint64_t __rem;                                                 \
-       __rem = ((uint64_t)(n)) % __base;                               \
-       (n) = ((uint64_t)(n)) / __base;                                 \
-       __rem;                                                          \
-  })
-#else
-# define lov_do_div64(n,base) ({                                       \
-       uint64_t __rem;                                                 \
-       if ((sizeof(base) > 4) && (((base) & 0xffffffff00000000ULL) != 0)) {  \
-               int __remainder;                                              \
-               LASSERTF(!((base) & (LOV_MIN_STRIPE_SIZE - 1)), "64 bit lov " \
-                        "division %llu / %llu\n", (n), (uint64_t)(base));    \
-               __remainder = (n) & (LOV_MIN_STRIPE_SIZE - 1);          \
-               (n) >>= LOV_MIN_STRIPE_BITS;                            \
-               __rem = do_div(n, (base) >> LOV_MIN_STRIPE_BITS);       \
-               __rem <<= LOV_MIN_STRIPE_BITS;                          \
-               __rem += __remainder;                                   \
-       } else {                                                        \
-               __rem = do_div(n, base);                                \
-       }                                                               \
-       __rem;                                                          \
-  })
-#endif
-
-#define IOC_LOV_TYPE              'g'
-#define IOC_LOV_MIN_NR          50
-#define IOC_LOV_SET_OSC_ACTIVE  _IOWR('g', 50, long)
-#define IOC_LOV_MAX_NR          50
-
-#define QOS_DEFAULT_THRESHOLD     10 /* MB */
-#define QOS_DEFAULT_MAXAGE           5  /* Seconds */
-
-#endif
index 5ec336968fc876c15be23a3ca86f872eae08ab96..cc5af509b2616fa988e6cacdfab53151794cab80 100644 (file)
@@ -641,8 +641,8 @@ do {                                                                              \
 #define OBD_ALLOC_GFP(ptr, size, gfp_mask)                                   \
        __OBD_MALLOC_VERBOSE(ptr, NULL, 0, size, gfp_mask)
 
-#define OBD_ALLOC(ptr, size) OBD_ALLOC_GFP(ptr, size, __GFP_IO)
-#define OBD_ALLOC_WAIT(ptr, size) OBD_ALLOC_GFP(ptr, size, GFP_IOFS)
+#define OBD_ALLOC(ptr, size) OBD_ALLOC_GFP(ptr, size, GFP_NOFS)
+#define OBD_ALLOC_WAIT(ptr, size) OBD_ALLOC_GFP(ptr, size, GFP_KERNEL)
 #define OBD_ALLOC_PTR(ptr) OBD_ALLOC(ptr, sizeof(*(ptr)))
 #define OBD_ALLOC_PTR_WAIT(ptr) OBD_ALLOC_WAIT(ptr, sizeof(*(ptr)))
 
@@ -650,7 +650,7 @@ do {                                                                              \
        __OBD_MALLOC_VERBOSE(ptr, cptab, cpt, size, gfp_mask)
 
 #define OBD_CPT_ALLOC(ptr, cptab, cpt, size)                                 \
-       OBD_CPT_ALLOC_GFP(ptr, cptab, cpt, size, __GFP_IO)
+       OBD_CPT_ALLOC_GFP(ptr, cptab, cpt, size, GFP_NOFS)
 
 #define OBD_CPT_ALLOC_PTR(ptr, cptab, cpt)                                   \
        OBD_CPT_ALLOC(ptr, cptab, cpt, sizeof(*(ptr)))
@@ -793,10 +793,10 @@ do {                                                                        \
 } while(0)
 
 #define OBD_SLAB_ALLOC(ptr, slab, size)                                              \
-       OBD_SLAB_ALLOC_GFP(ptr, slab, size, __GFP_IO)
+       OBD_SLAB_ALLOC_GFP(ptr, slab, size, GFP_NOFS)
 
 #define OBD_SLAB_CPT_ALLOC(ptr, slab, cptab, cpt, size)                              \
-       OBD_SLAB_CPT_ALLOC_GFP(ptr, slab, cptab, cpt, size, __GFP_IO)
+       OBD_SLAB_CPT_ALLOC_GFP(ptr, slab, cptab, cpt, size, GFP_NOFS)
 
 #define OBD_SLAB_ALLOC_PTR(ptr, slab)                                        \
        OBD_SLAB_ALLOC(ptr, slab, sizeof(*(ptr)))
index 6907a16dbbd1dc39ca9e10445978eb8560348088..dc24cfa5803722dd86669102189c27d793b83ecf 100644 (file)
@@ -63,7 +63,7 @@
 
 #include "../llite/llite_internal.h"
 
-const struct cl_req_operations ccc_req_ops;
+static const struct cl_req_operations ccc_req_ops;
 
 /*
  * ccc_ prefix stands for "Common Client Code".
@@ -112,12 +112,11 @@ static struct lu_kmem_descr ccc_caches[] = {
  *
  */
 
-void *ccc_key_init(const struct lu_context *ctx,
-                         struct lu_context_key *key)
+void *ccc_key_init(const struct lu_context *ctx, struct lu_context_key *key)
 {
        struct ccc_thread_info *info;
 
-       OBD_SLAB_ALLOC_PTR_GFP(info, ccc_thread_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(info, ccc_thread_kmem, GFP_NOFS);
        if (info == NULL)
                info = ERR_PTR(-ENOMEM);
        return info;
@@ -135,7 +134,7 @@ void *ccc_session_key_init(const struct lu_context *ctx,
 {
        struct ccc_session *session;
 
-       OBD_SLAB_ALLOC_PTR_GFP(session, ccc_session_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(session, ccc_session_kmem, GFP_NOFS);
        if (session == NULL)
                session = ERR_PTR(-ENOMEM);
        return session;
@@ -251,7 +250,7 @@ int ccc_req_init(const struct lu_env *env, struct cl_device *dev,
        struct ccc_req *vrq;
        int result;
 
-       OBD_SLAB_ALLOC_PTR_GFP(vrq, ccc_req_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(vrq, ccc_req_kmem, GFP_NOFS);
        if (vrq != NULL) {
                cl_req_slice_add(req, &vrq->crq_cl, dev, &ccc_req_ops);
                result = 0;
@@ -327,7 +326,7 @@ struct lu_object *ccc_object_alloc(const struct lu_env *env,
        struct ccc_object *vob;
        struct lu_object  *obj;
 
-       OBD_SLAB_ALLOC_PTR_GFP(vob, ccc_object_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(vob, ccc_object_kmem, GFP_NOFS);
        if (vob != NULL) {
                struct cl_object_header *hdr;
 
@@ -396,7 +395,7 @@ int ccc_lock_init(const struct lu_env *env,
 
        CLOBINVRNT(env, obj, ccc_object_invariant(obj));
 
-       OBD_SLAB_ALLOC_PTR_GFP(clk, ccc_lock_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(clk, ccc_lock_kmem, GFP_NOFS);
        if (clk != NULL) {
                cl_lock_slice_add(lock, &clk->clk_cl, obj, lkops);
                result = 0;
@@ -963,7 +962,7 @@ void ccc_req_attr_set(const struct lu_env *env,
               JOBSTATS_JOBID_SIZE);
 }
 
-const struct cl_req_operations ccc_req_ops = {
+static const struct cl_req_operations ccc_req_ops = {
        .cro_attr_set   = ccc_req_attr_set,
        .cro_completion = ccc_req_completion
 };
index e04c2d37c249fb83d6fe599336ff53f93e15a1c4..21de1cd2afbaca90db6637205bd13d1cf7f139c9 100644 (file)
@@ -56,7 +56,7 @@ int cl_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp)
        __u32 valsize = sizeof(struct lov_desc);
        int rc, easize, def_easize, cookiesize;
        struct lov_desc desc;
-       __u16 stripes;
+       __u16 stripes, def_stripes;
 
        rc = obd_get_info(NULL, dt_exp, sizeof(KEY_LOVDESC), KEY_LOVDESC,
                          &valsize, &desc, NULL);
@@ -67,15 +67,20 @@ int cl_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp)
        lsm.lsm_stripe_count = stripes;
        easize = obd_size_diskmd(dt_exp, &lsm);
 
-       lsm.lsm_stripe_count = desc.ld_default_stripe_count;
+       def_stripes = min_t(__u32, desc.ld_default_stripe_count,
+                           LOV_MAX_STRIPE_COUNT);
+       lsm.lsm_stripe_count = def_stripes;
        def_easize = obd_size_diskmd(dt_exp, &lsm);
 
        cookiesize = stripes * sizeof(struct llog_cookie);
 
-       CDEBUG(D_HA, "updating max_mdsize/max_cookiesize: %d/%d\n",
-              easize, cookiesize);
+       /* default cookiesize is 0 because from 2.4 server doesn't send
+        * llog cookies to client. */
+       CDEBUG(D_HA,
+              "updating def/max_easize: %d/%d def/max_cookiesize: 0/%d\n",
+              def_easize, easize, cookiesize);
 
-       rc = md_init_ea_size(md_exp, easize, def_easize, cookiesize);
+       rc = md_init_ea_size(md_exp, easize, def_easize, cookiesize, 0);
        return rc;
 }
 
index ac5d66aa7f022969fd7e37e6f3cc31f1965a76cc..bde3a82ce0dd29d944a926f0dcb075b885bf939b 100644 (file)
@@ -104,7 +104,7 @@ struct ldlm_interval *ldlm_interval_alloc(struct ldlm_lock *lock)
        struct ldlm_interval *node;
 
        LASSERT(lock->l_resource->lr_type == LDLM_EXTENT);
-       OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, GFP_NOFS);
        if (node == NULL)
                return NULL;
 
index 8cd79633dea31c6d4d3ae9b1524bcfffc1831cd8..f997566ef11e1d402366be4b90ab8b9d71f0da7a 100644 (file)
@@ -247,7 +247,7 @@ typedef enum ldlm_policy_res ldlm_policy_res_t;
        struct __##var##__dummy_read {;} /* semicolon catcher */
 
 #define LDLM_POOL_PROC_WRITER(var, type)                                   \
-       int lprocfs_wr_##var(struct file *file, const char *buffer,         \
+       static int lprocfs_wr_##var(struct file *file, const char *buffer,  \
                             unsigned long count, void *data)               \
        {                                                                   \
                struct ldlm_pool *pl = data;                                \
index 1a8c0d7005c7a36b9e4d302ec279851cf47c1a57..8bb59155968f9e8991ba32075ecc1f3161a3d69d 100644 (file)
@@ -325,7 +325,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg)
        }
 
        init_rwsem(&cli->cl_sem);
-       sema_init(&cli->cl_mgc_sem, 1);
+       mutex_init(&cli->cl_mgc_mutex);
        cli->cl_conn_count = 0;
        memcpy(server_uuid.uuid, lustre_cfg_buf(lcfg, 2),
               min_t(unsigned int, LUSTRE_CFG_BUFLEN(lcfg, 2),
@@ -514,7 +514,7 @@ int client_connect_import(const struct lu_env *env,
                LASSERT (imp->imp_state == LUSTRE_IMP_DISCON);
                GOTO(out_ldlm, rc);
        }
-       LASSERT((*exp)->exp_connection);
+       LASSERT(*exp != NULL && (*exp)->exp_connection);
 
        if (data) {
                LASSERTF((ocd->ocd_connect_flags & data->ocd_connect_flags) ==
index 0548aca45e8e96223658557b493cf3db1dce49fe..1b3f5c1eb80857c0109d0b9a8b525357d29af316 100644 (file)
@@ -232,8 +232,6 @@ int ldlm_lock_remove_from_lru_nolock(struct ldlm_lock *lock)
 
                LASSERT(lock->l_resource->lr_type != LDLM_FLOCK);
                list_del_init(&lock->l_lru);
-               if (lock->l_flags & LDLM_FL_SKIPPED)
-                       lock->l_flags &= ~LDLM_FL_SKIPPED;
                LASSERT(ns->ns_nr_unused > 0);
                ns->ns_nr_unused--;
                rc = 1;
@@ -271,6 +269,8 @@ void ldlm_lock_add_to_lru_nolock(struct ldlm_lock *lock)
        LASSERT(list_empty(&lock->l_lru));
        LASSERT(lock->l_resource->lr_type != LDLM_FLOCK);
        list_add_tail(&lock->l_lru, &ns->ns_unused_list);
+       if (lock->l_flags & LDLM_FL_SKIPPED)
+               lock->l_flags &= ~LDLM_FL_SKIPPED;
        LASSERT(ns->ns_nr_unused >= 0);
        ns->ns_nr_unused++;
 }
@@ -437,7 +437,7 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource)
        if (resource == NULL)
                LBUG();
 
-       OBD_SLAB_ALLOC_PTR_GFP(lock, ldlm_lock_slab, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(lock, ldlm_lock_slab, GFP_NOFS);
        if (lock == NULL)
                return NULL;
 
@@ -1624,7 +1624,7 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns,
         * have to allocate the interval node early otherwise we can't regrant
         * this lock in the future. - jay */
        if (!local && (*flags & LDLM_FL_REPLAY) && res->lr_type == LDLM_EXTENT)
-               OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, __GFP_IO);
+               OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, GFP_NOFS);
 
        lock_res_and_lock(lock);
        if (local && lock->l_req_mode == lock->l_granted_mode) {
@@ -2146,7 +2146,7 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
 
        /* I can't check the type of lock here because the bitlock of lock
         * is not held here, so do the allocation blindly. -jay */
-       OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, GFP_NOFS);
        if (node == NULL)
                /* Actually, this causes EDEADLOCK to be returned */
                return NULL;
index 6758646f575f7f9690709ed1971458d416bef00b..2cc698179b63ac72f089971a9e3ea2af11898bd3 100644 (file)
@@ -378,7 +378,7 @@ static int ldlm_srv_pool_recalc(struct ldlm_pool *pl)
  * locks smaller in next 10h.
  */
 static int ldlm_srv_pool_shrink(struct ldlm_pool *pl,
-                               int nr, unsigned int gfp_mask)
+                               int nr, gfp_t gfp_mask)
 {
        __u32 limit;
 
@@ -518,7 +518,7 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl)
  * passed \a pl according to \a nr and \a gfp_mask.
  */
 static int ldlm_cli_pool_shrink(struct ldlm_pool *pl,
-                               int nr, unsigned int gfp_mask)
+                               int nr, gfp_t gfp_mask)
 {
        struct ldlm_namespace *ns;
        int unused;
@@ -546,13 +546,13 @@ static int ldlm_cli_pool_shrink(struct ldlm_pool *pl,
                return ldlm_cancel_lru(ns, nr, LCF_ASYNC, LDLM_CANCEL_SHRINK);
 }
 
-struct ldlm_pool_ops ldlm_srv_pool_ops = {
+static const struct ldlm_pool_ops ldlm_srv_pool_ops = {
        .po_recalc = ldlm_srv_pool_recalc,
        .po_shrink = ldlm_srv_pool_shrink,
        .po_setup  = ldlm_srv_pool_setup
 };
 
-struct ldlm_pool_ops ldlm_cli_pool_ops = {
+static const struct ldlm_pool_ops ldlm_cli_pool_ops = {
        .po_recalc = ldlm_cli_pool_recalc,
        .po_shrink = ldlm_cli_pool_shrink
 };
@@ -603,7 +603,7 @@ int ldlm_pool_recalc(struct ldlm_pool *pl)
  * freeable locks. Otherwise, return the number of canceled locks.
  */
 int ldlm_pool_shrink(struct ldlm_pool *pl, int nr,
-                    unsigned int gfp_mask)
+                    gfp_t gfp_mask)
 {
        int cancel = 0;
 
@@ -718,7 +718,7 @@ LPROC_SEQ_FOPS_RO(lprocfs_grant_speed);
                snprintf(var_name, MAX_STRING_SIZE, #name);     \
                pool_vars[0].data = var;                        \
                pool_vars[0].fops = ops;                        \
-               lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);\
+               lprocfs_add_vars(pl->pl_proc_dir, pool_vars, NULL);\
        } while (0)
 
 static int ldlm_pool_proc_init(struct ldlm_pool *pl)
@@ -1029,7 +1029,7 @@ static struct completion ldlm_pools_comp;
  * count locks from all namespaces (if possible). Returns number of
  * cached locks.
  */
-static unsigned long ldlm_pools_count(ldlm_side_t client, unsigned int gfp_mask)
+static unsigned long ldlm_pools_count(ldlm_side_t client, gfp_t gfp_mask)
 {
        int total = 0, nr_ns;
        struct ldlm_namespace *ns;
@@ -1082,7 +1082,7 @@ static unsigned long ldlm_pools_count(ldlm_side_t client, unsigned int gfp_mask)
        return total;
 }
 
-static unsigned long ldlm_pools_scan(ldlm_side_t client, int nr, unsigned int gfp_mask)
+static unsigned long ldlm_pools_scan(ldlm_side_t client, int nr, gfp_t gfp_mask)
 {
        unsigned long freed = 0;
        int tmp, nr_ns;
index 2824d4a9a85b39422f8b4f75a715d96bc4baf7ff..a4cec5e63ce07cae7bc814cba4f201b29f7b1846 100644 (file)
@@ -1014,7 +1014,7 @@ static struct ldlm_resource *ldlm_resource_new(void)
        struct ldlm_resource *res;
        int idx;
 
-       OBD_SLAB_ALLOC_PTR_GFP(res, ldlm_resource_slab, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(res, ldlm_resource_slab, GFP_NOFS);
        if (res == NULL)
                return NULL;
 
index 1fb37008cda242706108d2833b12588f68d77004..d985e83ba2c31cb944d6dfe4f73e5b3ab3317b4a 100644 (file)
@@ -74,6 +74,20 @@ cfs_cpt_table_free(struct cfs_cpt_table *cptab)
 }
 EXPORT_SYMBOL(cfs_cpt_table_free);
 
+int
+cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
+{
+       int     rc = 0;
+
+       rc = snprintf(buf, len, "%d\t: %d\n", 0, 0);
+       len -= rc;
+       if (len <= 0)
+               return -EFBIG;
+
+       return rc;
+}
+EXPORT_SYMBOL(cfs_cpt_table_print);
+
 int
 cfs_cpt_number(struct cfs_cpt_table *cptab)
 {
@@ -160,6 +174,13 @@ cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt)
 }
 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)
 {
index 77b1ef64ecc0c340a1132c35faef72e92398a5fe..fc21210d77ec9a32955fb894f5d045cb125842f6 100644 (file)
@@ -71,7 +71,7 @@ struct cfs_cpt_data {
        /* reserved for hotplug */
        unsigned long           cpt_version;
        /* mutex to protect cpt_cpumask */
-       struct semaphore        cpt_mutex;
+       struct mutex            cpt_mutex;
        /* scratch buffer for set/unset_node */
        cpumask_t               *cpt_cpumask;
 };
@@ -420,14 +420,14 @@ cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node)
                return 0;
        }
 
-       down(&cpt_data.cpt_mutex);
+       mutex_lock(&cpt_data.cpt_mutex);
 
        mask = cpt_data.cpt_cpumask;
        cfs_node_to_cpumask(node, mask);
 
        rc = cfs_cpt_set_cpumask(cptab, cpt, mask);
 
-       up(&cpt_data.cpt_mutex);
+       mutex_unlock(&cpt_data.cpt_mutex);
 
        return rc;
 }
@@ -444,14 +444,14 @@ cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node)
                return;
        }
 
-       down(&cpt_data.cpt_mutex);
+       mutex_lock(&cpt_data.cpt_mutex);
 
        mask = cpt_data.cpt_cpumask;
        cfs_node_to_cpumask(node, mask);
 
        cfs_cpt_unset_cpumask(cptab, cpt, mask);
 
-       up(&cpt_data.cpt_mutex);
+       mutex_unlock(&cpt_data.cpt_mutex);
 }
 EXPORT_SYMBOL(cfs_cpt_unset_node);
 
@@ -881,7 +881,7 @@ cfs_cpt_table_create_pattern(char *pattern)
                        break;
                }
 
-               if (sscanf(str, "%u%n", &cpt, &n) < 1) {
+               if (sscanf(str, "%d%n", &cpt, &n) < 1) {
                        CERROR("Invalid cpu pattern %s\n", str);
                        goto failed;
                }
@@ -969,11 +969,11 @@ cfs_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu)
                        break;
                }
 
-               down(&cpt_data.cpt_mutex);
+               mutex_lock(&cpt_data.cpt_mutex);
                /* if all HTs in a core are offline, it may break affinity */
                cfs_cpu_ht_siblings(cpu, cpt_data.cpt_cpumask);
                warn = any_online_cpu(*cpt_data.cpt_cpumask) >= nr_cpu_ids;
-               up(&cpt_data.cpt_mutex);
+               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 "
@@ -1017,7 +1017,7 @@ cfs_cpu_init(void)
        }
 
        spin_lock_init(&cpt_data.cpt_lock);
-       sema_init(&cpt_data.cpt_mutex, 1);
+       mutex_init(&cpt_data.cpt_mutex);
 
 #ifdef CONFIG_HOTPLUG_CPU
        register_hotcpu_notifier(&cfs_cpu_notifier);
index e6eae0666f0d30c599960431a2b530235f98e0ab..9a3b07bd2fac0237e1a5eb6384d7547f1bfe319e 100644 (file)
@@ -44,6 +44,7 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg)
 {
        struct libcfs_ioctl_hdr   *hdr;
        struct libcfs_ioctl_data  *data;
+       int orig_len;
        int err;
 
        hdr = (struct libcfs_ioctl_hdr *)buf;
@@ -69,9 +70,12 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg)
                return -EINVAL;
        }
 
+       orig_len = hdr->ioc_len;
        err = copy_from_user(buf, (void *)arg, hdr->ioc_len);
        if (err)
                return err;
+       if (orig_len != data->ioc_len)
+               return -EINVAL;
 
        if (libcfs_ioctl_is_invalid(data)) {
                CERROR("PORTALS: ioctl not correctly formatted\n");
index 24ae26d5def395a530998691d5606db25bb19b7c..b16ee08fe742457c2b7754e942797b1bd3015a5d 100644 (file)
@@ -87,7 +87,8 @@ kportal_memhog_free (struct libcfs_device_userstate *ldu)
 }
 
 int
-kportal_memhog_alloc (struct libcfs_device_userstate *ldu, int npages, int flags)
+kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages,
+                    gfp_t flags)
 {
        struct page **level0p;
        struct page **level1p;
index cfb274fc9cbdf0b98548b56130502201b3e7e779..87705ae4480f256cf984e47577e628ffba738fba 100644 (file)
@@ -227,11 +227,11 @@ libcfs_ip_addr2str(__u32 addr, char *str)
 int
 libcfs_ip_str2addr(const char *str, int nob, __u32 *addr)
 {
-       int   a;
-       int   b;
-       int   c;
-       int   d;
-       int   n = nob;                    /* XscanfX */
+       unsigned int    a;
+       unsigned int    b;
+       unsigned int    c;
+       unsigned int    d;
+       int             n = nob; /* XscanfX */
 
        /* numeric IP? */
        if (sscanf(str, "%u.%u.%u.%u%n", &a, &b, &c, &d, &n) >= 4 &&
@@ -419,7 +419,7 @@ libcfs_str2net_internal(const char *str, __u32 *net)
 {
        struct netstrfns *uninitialized_var(nf);
        int            nob;
-       int            netnum;
+       unsigned int   netnum;
        int            i;
 
        for (i = 0; i < libcfs_nnetstrfns; i++) {
index c8599eefeb76ded414f1b28a06cf9c3f7dd0788c..07845e8442430e5ceb44e8298bc3237242ad4b4f 100644 (file)
@@ -66,7 +66,7 @@ cfs_tage_from_list(struct list_head *list)
        return list_entry(list, struct cfs_trace_page, linkage);
 }
 
-static struct cfs_trace_page *cfs_tage_alloc(int gfp)
+static struct cfs_trace_page *cfs_tage_alloc(gfp_t gfp)
 {
        struct page         *page;
        struct cfs_trace_page *tage;
@@ -114,7 +114,7 @@ static void cfs_tage_to_tail(struct cfs_trace_page *tage,
        list_move_tail(&tage->linkage, queue);
 }
 
-int cfs_trace_refill_stock(struct cfs_trace_cpu_data *tcd, int gfp,
+int cfs_trace_refill_stock(struct cfs_trace_cpu_data *tcd, gfp_t gfp,
                           struct list_head *stock)
 {
        int i;
@@ -416,13 +416,13 @@ console:
                        cdls->cdls_delay /= libcfs_console_backoff * 4;
                } else {
                        cdls->cdls_delay *= libcfs_console_backoff;
-
-                       if (cdls->cdls_delay < libcfs_console_min_delay)
-                               cdls->cdls_delay = libcfs_console_min_delay;
-                       else if (cdls->cdls_delay > libcfs_console_max_delay)
-                               cdls->cdls_delay = libcfs_console_max_delay;
                }
 
+               if (cdls->cdls_delay < libcfs_console_min_delay)
+                       cdls->cdls_delay = libcfs_console_min_delay;
+               else if (cdls->cdls_delay > libcfs_console_max_delay)
+                       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;
        }
index 7e8d17c12b5bf753132285e4e9d81909d0fafd94..55ecfc9f201b3b0476be4d5e40e7cd9baca7f688 100644 (file)
@@ -307,7 +307,7 @@ cfs_trace_put_tcd (struct cfs_trace_cpu_data *tcd)
        put_cpu();
 }
 
-int cfs_trace_refill_stock(struct cfs_trace_cpu_data *tcd, int gfp,
+int cfs_trace_refill_stock(struct cfs_trace_cpu_data *tcd, gfp_t gfp,
                           struct list_head *stock);
 
 
index ba16fd5db704d775cd84deb3f53c38c34a59c5f5..0a03bf7ba3eb2e907425f980d7c8208ce46697cc 100644 (file)
@@ -75,7 +75,7 @@ typedef struct cfs_wi_sched {
        char                    ws_name[CFS_WS_NAME_LEN];
 } cfs_wi_sched_t;
 
-struct cfs_workitem_data {
+static struct cfs_workitem_data {
        /** serialize */
        spinlock_t              wi_glock;
        /** list of all schedulers */
index 8b5508086174f91fa7b36ef8811d3fae759ad11f..7d520d8f4a6923125f012471588b2f9f026c4828 100644 (file)
@@ -69,8 +69,7 @@ static void ll_release(struct dentry *de)
                ll_intent_release(lld->lld_it);
                OBD_FREE(lld->lld_it, sizeof(*lld->lld_it));
        }
-       LASSERT(lld->lld_cwd_count == 0);
-       LASSERT(lld->lld_mnt_count == 0);
+
        de->d_fsdata = NULL;
        call_rcu(&lld->lld_rcu_head, free_dentry_data);
 }
@@ -82,8 +81,9 @@ static void ll_release(struct dentry *de)
  * an AST before calling d_revalidate_it().  The dentry still exists (marked
  * INVALID) so d_lookup() matches it, but we have no lock on it (so
  * lock_match() fails) and we spin around real_lookup(). */
-int ll_dcompare(const struct dentry *parent, const struct dentry *dentry,
-               unsigned int len, const char *str, const struct qstr *name)
+static int ll_dcompare(const struct dentry *parent, const struct dentry *dentry,
+                      unsigned int len, const char *str,
+                      const struct qstr *name)
 {
        if (len != name->len)
                return 1;
@@ -238,7 +238,8 @@ void ll_intent_release(struct lookup_intent *it)
        ll_intent_drop_lock(it);
        /* We are still holding extra reference on a request, need to free it */
        if (it_disposition(it, DISP_ENQ_OPEN_REF))
-                ptlrpc_req_finished(it->d.lustre.it_data); /* ll_file_open */
+               ptlrpc_req_finished(it->d.lustre.it_data); /* ll_file_open */
+
        if (it_disposition(it, DISP_ENQ_CREATE_REF)) /* create rec */
                ptlrpc_req_finished(it->d.lustre.it_data);
 
@@ -316,15 +317,6 @@ void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry)
        }
 }
 
-void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft)
-{
-       struct lookup_intent *it = *itp;
-
-       if (!it || it->it_op == IT_GETXATTR)
-               it = *itp = deft;
-
-}
-
 static int ll_revalidate_dentry(struct dentry *dentry,
                                unsigned int lookup_flags)
 {
@@ -356,7 +348,7 @@ static int ll_revalidate_dentry(struct dentry *dentry,
 /*
  * Always trust cached dentries. Update statahead window if necessary.
  */
-int ll_revalidate_nd(struct dentry *dentry, unsigned int flags)
+static int ll_revalidate_nd(struct dentry *dentry, unsigned int flags)
 {
        int rc;
 
@@ -368,7 +360,7 @@ int ll_revalidate_nd(struct dentry *dentry, unsigned int flags)
 }
 
 
-void ll_d_iput(struct dentry *de, struct inode *inode)
+static void ll_d_iput(struct dentry *de, struct inode *inode)
 {
        LASSERT(inode);
        if (!find_cbdata(inode))
@@ -376,7 +368,7 @@ void ll_d_iput(struct dentry *de, struct inode *inode)
        iput(inode);
 }
 
-struct dentry_operations ll_d_ops = {
+const struct dentry_operations ll_d_ops = {
        .d_revalidate = ll_revalidate_nd,
        .d_release = ll_release,
        .d_delete  = ll_ddelete,
index 7fbc18e3e654a19484b8f7c028f9964256eea72c..ae6f61aa4da6f661943b7730f415ff15640b796b 100644 (file)
@@ -632,7 +632,7 @@ out:
        return rc;
 }
 
-int ll_send_mgc_param(struct obd_export *mgc, char *string)
+static int ll_send_mgc_param(struct obd_export *mgc, char *string)
 {
        struct mgs_send_param *msp;
        int rc = 0;
@@ -795,7 +795,7 @@ int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp,
        int rc, lmmsize;
        struct md_op_data *op_data;
 
-       rc = ll_get_max_mdsize(sbi, &lmmsize);
+       rc = ll_get_default_mdsize(sbi, &lmmsize);
        if (rc)
                return rc;
 
@@ -1804,6 +1804,11 @@ out_rmdir:
                /* Compute the whole struct size */
                totalsize = hur_len(hur);
                OBD_FREE_PTR(hur);
+
+               /* Final size will be more than double totalsize */
+               if (totalsize >= MDS_MAXREQSIZE / 3)
+                       return -E2BIG;
+
                OBD_ALLOC_LARGE(hur, totalsize);
                if (hur == NULL)
                        return -ENOMEM;
@@ -1959,17 +1964,17 @@ out:
        return ret;
 }
 
-int ll_dir_open(struct inode *inode, struct file *file)
+static int ll_dir_open(struct inode *inode, struct file *file)
 {
        return ll_file_open(inode, file);
 }
 
-int ll_dir_release(struct inode *inode, struct file *file)
+static int ll_dir_release(struct inode *inode, struct file *file)
 {
        return ll_file_release(inode, file);
 }
 
-struct file_operations ll_dir_operations = {
+const struct file_operations ll_dir_operations = {
        .llseek   = ll_dir_seek,
        .open     = ll_dir_open,
        .release  = ll_dir_release,
index 8e844a6371e0600c76ae814e080df1cfd1d3099d..562e33751197f3c87293d8d77d709ececfc1e1b5 100644 (file)
 
 #include "cl_object.h"
 
-struct ll_file_data *ll_file_data_get(void)
+static int
+ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg);
+
+static int ll_lease_close(struct obd_client_handle *och, struct inode *inode,
+                         bool *lease_broken);
+
+static enum llioc_iter
+ll_iocontrol_call(struct inode *inode, struct file *file,
+                 unsigned int cmd, unsigned long arg, int *rcp);
+
+static struct ll_file_data *ll_file_data_get(void)
 {
        struct ll_file_data *fd;
 
-       OBD_SLAB_ALLOC_PTR_GFP(fd, ll_file_data_slab, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(fd, ll_file_data_slab, GFP_NOFS);
        if (fd == NULL)
                return NULL;
        fd->fd_write_failed = false;
@@ -247,8 +257,8 @@ int ll_md_real_close(struct inode *inode, fmode_t fmode)
        return rc;
 }
 
-int ll_md_close(struct obd_export *md_exp, struct inode *inode,
-               struct file *file)
+static int ll_md_close(struct obd_export *md_exp, struct inode *inode,
+                      struct file *file)
 {
        struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
        struct ll_inode_info *lli = ll_i2info(inode);
@@ -482,8 +492,8 @@ static int ll_och_fill(struct obd_export *md_exp, struct lookup_intent *it,
        return md_set_open_replay_data(md_exp, och, it);
 }
 
-int ll_local_open(struct file *file, struct lookup_intent *it,
-                 struct ll_file_data *fd, struct obd_client_handle *och)
+static int ll_local_open(struct file *file, struct lookup_intent *it,
+                        struct ll_file_data *fd, struct obd_client_handle *och)
 {
        struct inode *inode = file->f_dentry->d_inode;
        struct ll_inode_info *lli = ll_i2info(inode);
@@ -733,8 +743,9 @@ static int ll_md_blocking_lease_ast(struct ldlm_lock *lock,
 /**
  * Acquire a lease and open the file.
  */
-struct obd_client_handle *ll_lease_open(struct inode *inode, struct file *file,
-                                       fmode_t fmode, __u64 open_flags)
+static struct obd_client_handle *
+ll_lease_open(struct inode *inode, struct file *file, fmode_t fmode,
+             __u64 open_flags)
 {
        struct lookup_intent it = { .it_op = IT_OPEN };
        struct ll_sb_info *sbi = ll_i2sbi(inode);
@@ -862,14 +873,13 @@ out:
        OBD_FREE_PTR(och);
        return ERR_PTR(rc);
 }
-EXPORT_SYMBOL(ll_lease_open);
 
 /**
  * Release lease and close the file.
  * It will check if the lease has ever broken.
  */
-int ll_lease_close(struct obd_client_handle *och, struct inode *inode,
-                       bool *lease_broken)
+static int ll_lease_close(struct obd_client_handle *och, struct inode *inode,
+                         bool *lease_broken)
 {
        struct ldlm_lock *lock;
        bool cancelled = true;
@@ -895,7 +905,6 @@ int ll_lease_close(struct obd_client_handle *och, struct inode *inode,
                                       NULL);
        return rc;
 }
-EXPORT_SYMBOL(ll_lease_close);
 
 /* Fills the obdo with the attributes for the lsm */
 static int ll_lsm_getattr(struct lov_stripe_md *lsm, struct obd_export *exp,
@@ -1440,7 +1449,7 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
        struct md_op_data *op_data;
        int rc, lmmsize;
 
-       rc = ll_get_max_mdsize(sbi, &lmmsize);
+       rc = ll_get_default_mdsize(sbi, &lmmsize);
        if (rc)
                return rc;
 
@@ -1590,7 +1599,8 @@ static int ll_lov_getstripe(struct inode *inode, unsigned long arg)
        return rc;
 }
 
-int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg)
+static int
+ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg)
 {
        struct ll_inode_info   *lli = ll_i2info(inode);
        struct ll_file_data    *fd = LUSTRE_FPRIVATE(file);
@@ -1710,13 +1720,13 @@ out:
  * Get size for inode for which FIEMAP mapping is requested.
  * Make the FIEMAP get_info call and returns the result.
  */
-int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap,
-             int num_bytes)
+static int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap,
+                       size_t num_bytes)
 {
        struct obd_export *exp = ll_i2dtexp(inode);
        struct lov_stripe_md *lsm = NULL;
        struct ll_fiemap_info_key fm_key = { .name = KEY_FIEMAP, };
-       int vallen = num_bytes;
+       __u32 vallen = num_bytes;
        int rc;
 
        /* Checks for fiemap flags */
@@ -2190,7 +2200,8 @@ out:
        return rc;
 }
 
-long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+static long
+ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
        struct inode            *inode = file->f_dentry->d_inode;
        struct ll_file_data     *fd = LUSTRE_FPRIVATE(file);
@@ -2509,7 +2520,7 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 }
 
 
-loff_t ll_file_seek(struct file *file, loff_t offset, int origin)
+static loff_t ll_file_seek(struct file *file, loff_t offset, int origin)
 {
        struct inode *inode = file->f_dentry->d_inode;
        loff_t retval, eof = 0;
@@ -2533,7 +2544,7 @@ loff_t ll_file_seek(struct file *file, loff_t offset, int origin)
        return retval;
 }
 
-int ll_flush(struct file *file, fl_owner_t id)
+static int ll_flush(struct file *file, fl_owner_t id)
 {
        struct inode *inode = file->f_dentry->d_inode;
        struct ll_inode_info *lli = ll_i2info(inode);
@@ -2559,7 +2570,7 @@ int ll_flush(struct file *file, fl_owner_t id)
 
 /**
  * Called to make sure a portion of file has been written out.
- * if @local_only is not true, it will send OST_SYNC RPCs to ost.
+ * if @mode is not CL_FSYNC_LOCAL, it will send OST_SYNC RPCs to OST.
  *
  * Return how many pages have been written.
  */
@@ -2653,11 +2664,10 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync)
        if (!err)
                ptlrpc_req_finished(req);
 
-       if (datasync && S_ISREG(inode->i_mode)) {
+       if (S_ISREG(inode->i_mode)) {
                struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
 
-               err = cl_sync_file_range(inode, 0, OBD_OBJECT_EOF,
-                               CL_FSYNC_ALL, 0);
+               err = cl_sync_file_range(inode, start, end, CL_FSYNC_ALL, 0);
                if (rc == 0 && err < 0)
                        rc = err;
                if (rc < 0)
@@ -2670,7 +2680,8 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync)
        return rc;
 }
 
-int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
+static int
+ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
 {
        struct inode *inode = file->f_dentry->d_inode;
        struct ll_sb_info *sbi = ll_i2sbi(inode);
@@ -2799,7 +2810,8 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
        return rc;
 }
 
-int ll_file_noflock(struct file *file, int cmd, struct file_lock *file_lock)
+static int
+ll_file_noflock(struct file *file, int cmd, struct file_lock *file_lock)
 {
        return -ENOSYS;
 }
@@ -2882,16 +2894,16 @@ static int ll_inode_revalidate_fini(struct inode *inode, int rc)
                if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
                        return 0;
        } else if (rc != 0) {
-               CERROR("%s: revalidate FID "DFID" error: rc = %d\n",
-                      ll_get_fsname(inode->i_sb, NULL, 0),
-                      PFID(ll_inode2fid(inode)), rc);
+               CDEBUG_LIMIT((rc == -EACCES || rc == -EIDRM) ? D_INFO : D_ERROR,
+                            "%s: revalidate FID "DFID" error: rc = %d\n",
+                            ll_get_fsname(inode->i_sb, NULL, 0),
+                            PFID(ll_inode2fid(inode)), rc);
        }
 
        return rc;
 }
 
-int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it,
-                            __u64 ibits)
+static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits)
 {
        struct inode *inode = dentry->d_inode;
        struct ptlrpc_request *req = NULL;
@@ -2956,7 +2968,7 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it,
                int ealen = 0;
 
                if (S_ISREG(inode->i_mode)) {
-                       rc = ll_get_max_mdsize(sbi, &ealen);
+                       rc = ll_get_default_mdsize(sbi, &ealen);
                        if (rc)
                                return rc;
                        valid |= OBD_MD_FLEASIZE | OBD_MD_FLMODEASIZE;
@@ -2986,13 +2998,12 @@ out:
        return rc;
 }
 
-int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it,
-                          __u64 ibits)
+static int ll_inode_revalidate(struct dentry *dentry, __u64 ibits)
 {
        struct inode *inode = dentry->d_inode;
        int rc;
 
-       rc = __ll_inode_revalidate_it(dentry, it, ibits);
+       rc = __ll_inode_revalidate(dentry, ibits);
        if (rc != 0)
                return rc;
 
@@ -3015,16 +3026,15 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it,
        return rc;
 }
 
-int ll_getattr_it(struct vfsmount *mnt, struct dentry *de,
-                 struct lookup_intent *it, struct kstat *stat)
+int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat)
 {
        struct inode *inode = de->d_inode;
        struct ll_sb_info *sbi = ll_i2sbi(inode);
        struct ll_inode_info *lli = ll_i2info(inode);
        int res = 0;
 
-       res = ll_inode_revalidate_it(de, it, MDS_INODELOCK_UPDATE |
-                                            MDS_INODELOCK_LOOKUP);
+       res = ll_inode_revalidate(de, MDS_INODELOCK_UPDATE |
+                                     MDS_INODELOCK_LOOKUP);
        ll_stats_ops_tally(sbi, LPROC_LL_GETATTR, 1);
 
        if (res)
@@ -3050,15 +3060,9 @@ int ll_getattr_it(struct vfsmount *mnt, struct dentry *de,
 
        return 0;
 }
-int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat)
-{
-       struct lookup_intent it = { .it_op = IT_GETATTR };
 
-       return ll_getattr_it(mnt, de, &it, stat);
-}
-
-int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
-               __u64 start, __u64 len)
+static int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
+                    __u64 start, __u64 len)
 {
        int rc;
        size_t num_bytes;
@@ -3076,21 +3080,24 @@ int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
        fiemap->fm_extent_count = fieinfo->fi_extents_max;
        fiemap->fm_start = start;
        fiemap->fm_length = len;
-       memcpy(&fiemap->fm_extents[0], fieinfo->fi_extents_start,
-              sizeof(struct ll_fiemap_extent));
+       if (extent_count > 0)
+               memcpy(&fiemap->fm_extents[0], fieinfo->fi_extents_start,
+                      sizeof(struct ll_fiemap_extent));
 
        rc = ll_do_fiemap(inode, fiemap, num_bytes);
 
        fieinfo->fi_flags = fiemap->fm_flags;
        fieinfo->fi_extents_mapped = fiemap->fm_mapped_extents;
-       memcpy(fieinfo->fi_extents_start, &fiemap->fm_extents[0],
-              fiemap->fm_mapped_extents * sizeof(struct ll_fiemap_extent));
+       if (extent_count > 0)
+               memcpy(fieinfo->fi_extents_start, &fiemap->fm_extents[0],
+                      fiemap->fm_mapped_extents *
+                      sizeof(struct ll_fiemap_extent));
 
        OBD_FREE_LARGE(fiemap, num_bytes);
        return rc;
 }
 
-struct posix_acl * ll_get_acl(struct inode *inode, int type)
+struct posix_acl *ll_get_acl(struct inode *inode, int type)
 {
        struct ll_inode_info *lli = ll_i2info(inode);
        struct posix_acl *acl = NULL;
@@ -3117,10 +3124,8 @@ int ll_inode_permission(struct inode *inode, int mask)
        * need to do it before permission check. */
 
        if (inode == inode->i_sb->s_root->d_inode) {
-               struct lookup_intent it = { .it_op = IT_LOOKUP };
-
-               rc = __ll_inode_revalidate_it(inode->i_sb->s_root, &it,
-                                             MDS_INODELOCK_LOOKUP);
+               rc = __ll_inode_revalidate(inode->i_sb->s_root,
+                                          MDS_INODELOCK_LOOKUP);
                if (rc)
                        return rc;
        }
@@ -3272,8 +3277,9 @@ void ll_iocontrol_unregister(void *magic)
 EXPORT_SYMBOL(ll_iocontrol_register);
 EXPORT_SYMBOL(ll_iocontrol_unregister);
 
-enum llioc_iter ll_iocontrol_call(struct inode *inode, struct file *file,
-                       unsigned int cmd, unsigned long arg, int *rcp)
+static enum llioc_iter
+ll_iocontrol_call(struct inode *inode, struct file *file,
+                 unsigned int cmd, unsigned long arg, int *rcp)
 {
        enum llioc_iter ret = LLIOC_CONT;
        struct llioc_data *data;
@@ -3358,7 +3364,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock)
         * layout here. Please note that we can't use the LVB buffer in
         * completion AST because it doesn't have a large enough buffer */
        oc = ll_mdscapa_get(inode);
-       rc = ll_get_max_mdsize(sbi, &lmmsize);
+       rc = ll_get_default_mdsize(sbi, &lmmsize);
        if (rc == 0)
                rc = md_getxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc,
                                OBD_MD_FLXATTR, XATTR_NAME_LOV, NULL, 0,
@@ -3368,7 +3374,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock)
                return rc;
 
        body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
-       if (body == NULL || body->eadatasize > lmmsize)
+       if (body == NULL)
                GOTO(out, rc = -EPROTO);
 
        lmmsize = body->eadatasize;
@@ -3435,7 +3441,7 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode,
                if (lvb_ready) {
                        /* layout_gen must be valid if layout lock is not
                         * cancelled and stripe has already set */
-                       *gen = lli->lli_layout_gen;
+                       *gen = ll_layout_version_get(lli);
                        rc = 0;
                }
                GOTO(out, rc);
@@ -3533,32 +3539,20 @@ int ll_layout_refresh(struct inode *inode, __u32 *gen)
        };
        int rc;
 
-       *gen = lli->lli_layout_gen;
-       if (!(sbi->ll_flags & LL_SBI_LAYOUT_LOCK))
+       *gen = ll_layout_version_get(lli);
+       if (!(sbi->ll_flags & LL_SBI_LAYOUT_LOCK) || *gen != LL_LAYOUT_GEN_NONE)
                return 0;
 
        /* sanity checks */
        LASSERT(fid_is_sane(ll_inode2fid(inode)));
        LASSERT(S_ISREG(inode->i_mode));
 
-       /* mostly layout lock is caching on the local side, so try to match
-        * it before grabbing layout lock mutex. */
-       mode = ll_take_md_lock(inode, MDS_INODELOCK_LAYOUT, &lockh, 0,
-                              LCK_CR | LCK_CW | LCK_PR | LCK_PW);
-       if (mode != 0) { /* hit cached lock */
-               rc = ll_layout_lock_set(&lockh, mode, inode, gen, false);
-               if (rc == 0)
-                       return 0;
-
-               /* better hold lli_layout_mutex to try again otherwise
-                * it will have starvation problem. */
-       }
-
        /* take layout lock mutex to enqueue layout lock exclusively. */
        mutex_lock(&lli->lli_layout_mutex);
 
 again:
-       /* try again. Maybe somebody else has done this. */
+       /* mostly layout lock is caching on the local side, so try to match
+        * it before grabbing layout lock mutex. */
        mode = ll_take_md_lock(inode, MDS_INODELOCK_LAYOUT, &lockh, 0,
                               LCK_CR | LCK_CW | LCK_PR | LCK_PW);
        if (mode != 0) { /* hit cached lock */
index edd512b20ee3a6f3589b5531f4073654e104f99b..d06d0b1ab08afed32af5b019ba90a31c5e74cf7b 100644 (file)
@@ -68,6 +68,8 @@ static unsigned long long ll_capa_renewal_noent = 0;
 static unsigned long long ll_capa_renewal_failed = 0;
 static unsigned long long ll_capa_renewal_retries = 0;
 
+static int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa);
+
 static inline void update_capa_timer(struct obd_capa *ocapa, cfs_time_t expiry)
 {
        if (cfs_time_before(expiry, ll_capa_timer.expires) ||
@@ -515,7 +517,7 @@ static inline void delay_capa_renew(struct obd_capa *oc, cfs_time_t delay)
        oc->c_expiry = cfs_time_add(oc->c_expiry, cfs_time_seconds(delay));
 }
 
-int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa)
+static int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa)
 {
        struct inode *inode = ocapa->u.cli.inode;
        int rc = 0;
index 69aba0afca41b2eafd481991c269770d4697c42a..dde7632ba01fa8dab671fb43995723bba1f5d3dd 100644 (file)
 #define LUSTRE_FPRIVATE(file) ((file)->private_data)
 
 struct ll_dentry_data {
-       int                             lld_cwd_count;
-       int                             lld_mnt_count;
-       struct obd_client_handle        lld_cwd_och;
-       struct obd_client_handle        lld_mnt_och;
        struct lookup_intent            *lld_it;
        unsigned int                    lld_sa_generation;
        unsigned int                    lld_invalid:1;
@@ -83,8 +79,6 @@ struct ll_dentry_data {
 
 #define ll_d2d(de) ((struct ll_dentry_data*)((de)->d_fsdata))
 
-extern struct file_operations ll_pgcache_seq_fops;
-
 #define LLI_INODE_MAGIC                 0x111d0de5
 #define LLI_INODE_DEAD           0xdeadd00d
 
@@ -120,16 +114,12 @@ enum lli_flags {
        /* Sizeon-on-MDS attributes are changed. An attribute update needs to
         * be sent to MDS. */
        LLIF_SOM_DIRTY    = (1 << 3),
-       /* File is contented */
-       LLIF_CONTENDED    = (1 << 4),
-       /* Truncate uses server lock for this file */
-       LLIF_SRVLOCK        = (1 << 5),
        /* File data is modified. */
-       LLIF_DATA_MODIFIED      = (1 << 6),
+       LLIF_DATA_MODIFIED      = (1 << 4),
        /* File is being restored */
-       LLIF_FILE_RESTORING     = (1 << 7),
+       LLIF_FILE_RESTORING     = (1 << 5),
        /* Xattr cache is attached to the file */
-       LLIF_XATTR_CACHE        = (1 << 8),
+       LLIF_XATTR_CACHE        = (1 << 6),
 };
 
 struct ll_inode_info {
@@ -194,7 +184,6 @@ struct ll_inode_info {
                         * cleanup the dir readahead. */
                        void                       *d_opendir_key;
                        struct ll_statahead_info       *d_sai;
-                       struct posix_acl               *d_def_acl;
                        /* protect statahead stuff. */
                        spinlock_t                      d_sa_lock;
                        /* "opendir_pid" is the token when lookup/revalid
@@ -205,14 +194,12 @@ struct ll_inode_info {
 #define lli_readdir_mutex       u.d.d_readdir_mutex
 #define lli_opendir_key         u.d.d_opendir_key
 #define lli_sai                 u.d.d_sai
-#define lli_def_acl         u.d.d_def_acl
 #define lli_sa_lock         u.d.d_sa_lock
 #define lli_opendir_pid         u.d.d_opendir_pid
 
                /* for non-directory */
                struct {
-                       struct semaphore                f_size_sem;
-                       void                            *f_size_sem_owner;
+                       struct mutex                    f_size_mutex;
                        char                            *f_symlink_name;
                        __u64                           f_maxbytes;
                        /*
@@ -233,11 +220,6 @@ struct ll_inode_info {
                        /* for writepage() only to communicate to fsync */
                        int                             f_async_rc;
 
-                       /* volatile file criteria is based on file name, this
-                        * flag is used to keep the test result, so the strcmp
-                        * is done only once
-                        */
-                       bool                            f_volatile;
                        /*
                         * whenever a process try to read/write the file, the
                         * jobid of the process will be saved here, and it'll
@@ -249,8 +231,7 @@ struct ll_inode_info {
                        char                 f_jobid[JOBSTATS_JOBID_SIZE];
                } f;
 
-#define lli_size_sem       u.f.f_size_sem
-#define lli_size_sem_owner      u.f.f_size_sem_owner
+#define lli_size_mutex          u.f.f_size_mutex
 #define lli_symlink_name       u.f.f_symlink_name
 #define lli_maxbytes       u.f.f_maxbytes
 #define lli_trunc_sem     u.f.f_trunc_sem
@@ -261,7 +242,6 @@ struct ll_inode_info {
 #define lli_agl_index          u.f.f_agl_index
 #define lli_async_rc           u.f.f_async_rc
 #define lli_jobid              u.f.f_jobid
-#define lli_volatile           u.f.f_volatile
 
        } u;
 
@@ -280,14 +260,33 @@ struct ll_inode_info {
 
        /* mutex to request for layout lock exclusively. */
        struct mutex                    lli_layout_mutex;
-       /* valid only inside LAYOUT ibits lock, protected by lli_layout_mutex */
+       /* Layout version, protected by lli_layout_lock */
        __u32                           lli_layout_gen;
+       spinlock_t                      lli_layout_lock;
 
        struct rw_semaphore             lli_xattrs_list_rwsem;
        struct mutex                    lli_xattrs_enq_lock;
        struct list_head                lli_xattrs;/* ll_xattr_entry->xe_list */
 };
 
+static inline __u32 ll_layout_version_get(struct ll_inode_info *lli)
+{
+       __u32 gen;
+
+       spin_lock(&lli->lli_layout_lock);
+       gen = lli->lli_layout_gen;
+       spin_unlock(&lli->lli_layout_lock);
+
+       return gen;
+}
+
+static inline void ll_layout_version_set(struct ll_inode_info *lli, __u32 gen)
+{
+       spin_lock(&lli->lli_layout_lock);
+       lli->lli_layout_gen = gen;
+       spin_unlock(&lli->lli_layout_lock);
+}
+
 int ll_xattr_cache_destroy(struct inode *inode);
 
 int ll_xattr_cache_get(struct inode *inode,
@@ -300,7 +299,7 @@ int ll_xattr_cache_get(struct inode *inode,
  * Locking to guarantee consistency of non-atomic updates to long long i_size,
  * consistency between file size and KMS.
  *
- * Implemented by ->lli_size_sem and ->lsm_lock, nested in that order.
+ * Implemented by ->lli_size_mutex and ->lsm_lock, nested in that order.
  */
 
 void ll_inode_size_lock(struct inode *inode);
@@ -442,10 +441,6 @@ enum stats_track_type {
        "xattr",        \
 }
 
-/* default value for ll_sb_info->contention_time */
-#define SBI_DEFAULT_CONTENTION_SECONDS     60
-/* default value for lockless_truncate_enable */
-#define SBI_DEFAULT_LOCKLESS_TRUNCATE_ENABLE 1
 #define RCE_HASHES      32
 
 struct rmtacl_ctl_entry {
@@ -656,12 +651,6 @@ static inline struct inode *ll_info2i(struct ll_inode_info *lli)
        return &lli->lli_vfs_inode;
 }
 
-struct it_cb_data {
-       struct inode  *icbd_parent;
-       struct dentry **icbd_childp;
-       obd_id  hash;
-};
-
 __u32 ll_i2suppgid(struct inode *i);
 void ll_i2gids(__u32 *suppgids, struct inode *i1,struct inode *i2);
 
@@ -669,21 +658,13 @@ static inline int ll_need_32bit_api(struct ll_sb_info *sbi)
 {
 #if BITS_PER_LONG == 32
        return 1;
+#elif defined(CONFIG_COMPAT)
+       return unlikely(is_compat_task() || (sbi->ll_flags & LL_SBI_32BIT_API));
 #else
-       return unlikely(
-#ifdef CONFIG_COMPAT
-               is_compat_task() ||
-#endif
-               (sbi->ll_flags & LL_SBI_32BIT_API)
-       );
+       return unlikely(sbi->ll_flags & LL_SBI_32BIT_API);
 #endif
 }
 
-#define LLAP_MAGIC 98764321
-
-extern struct kmem_cache *ll_async_page_slab;
-extern size_t ll_async_page_slab_size;
-
 void ll_ra_read_in(struct file *f, struct ll_ra_read *rar);
 void ll_ra_read_ex(struct file *f, struct ll_ra_read *rar);
 struct ll_ra_read *ll_ra_read_get(struct file *f);
@@ -716,14 +697,16 @@ static inline void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid,
 
 /* llite/dir.c */
 void ll_release_page(struct page *page, int remove);
-extern struct file_operations ll_dir_operations;
-extern struct inode_operations ll_dir_inode_operations;
+extern const struct file_operations ll_dir_operations;
+extern const struct inode_operations ll_dir_inode_operations;
 struct page *ll_get_dir_page(struct inode *dir, __u64 hash,
                             struct ll_dir_chain *chain);
 int ll_dir_read(struct inode *inode, struct dir_context *ctx);
 
 int ll_get_mdt_idx(struct inode *inode);
 /* llite/namei.c */
+extern const struct inode_operations ll_special_inode_operations;
+
 int ll_objects_destroy(struct ptlrpc_request *request,
                       struct inode *dir);
 struct inode *ll_iget(struct super_block *sb, ino_t hash,
@@ -738,43 +721,34 @@ int ll_prepare_write(struct file *, struct page *, unsigned from, unsigned to);
 int ll_commit_write(struct file *, struct page *, unsigned from, unsigned to);
 int ll_writepage(struct page *page, struct writeback_control *wbc);
 int ll_writepages(struct address_space *, struct writeback_control *wbc);
-void ll_removepage(struct page *page);
 int ll_readpage(struct file *file, struct page *page);
 void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras);
-int ll_file_punch(struct inode *, loff_t, int);
-ssize_t ll_file_lockless_io(struct file *, char *, size_t, loff_t *, int);
-void ll_clear_file_contended(struct inode*);
-int ll_sync_page_range(struct inode *, struct address_space *, loff_t, size_t);
 int ll_readahead(const struct lu_env *env, struct cl_io *io,
                 struct ll_readahead_state *ras, struct address_space *mapping,
                 struct cl_page_list *queue, int flags);
 
+#ifndef MS_HAS_NEW_AOPS
+extern const struct address_space_operations ll_aops;
+#else
+extern const struct address_space_operations_ext ll_aops;
+#endif
+
 /* llite/file.c */
 extern struct file_operations ll_file_operations;
 extern struct file_operations ll_file_operations_flock;
 extern struct file_operations ll_file_operations_noflock;
 extern struct inode_operations ll_file_inode_operations;
-extern int ll_inode_revalidate_it(struct dentry *, struct lookup_intent *,
-                                 __u64);
 extern int ll_have_md_lock(struct inode *inode, __u64 *bits,
                           ldlm_mode_t l_req_mode);
 extern ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits,
                                   struct lustre_handle *lockh, __u64 flags,
                                   ldlm_mode_t mode);
-int __ll_inode_revalidate_it(struct dentry *, struct lookup_intent *,
-                            __u64 bits);
-int ll_revalidate_nd(struct dentry *dentry, unsigned int flags);
 int ll_file_open(struct inode *inode, struct file *file);
 int ll_file_release(struct inode *inode, struct file *file);
 int ll_glimpse_ioctl(struct ll_sb_info *sbi,
                     struct lov_stripe_md *lsm, lstat_t *st);
 void ll_ioepoch_open(struct ll_inode_info *lli, __u64 ioepoch);
-int ll_local_open(struct file *file,
-                 struct lookup_intent *it, struct ll_file_data *fd,
-                 struct obd_client_handle *och);
 int ll_release_openhandle(struct dentry *, struct lookup_intent *);
-int ll_md_close(struct obd_export *md_exp, struct inode *inode,
-               struct file *file);
 int ll_md_real_close(struct inode *inode, fmode_t fmode);
 void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data,
                      struct obd_client_handle **och, unsigned long flags);
@@ -782,15 +756,10 @@ void ll_done_writing_attr(struct inode *inode, struct md_op_data *op_data);
 int ll_som_update(struct inode *inode, struct md_op_data *op_data);
 int ll_inode_getattr(struct inode *inode, struct obdo *obdo,
                     __u64 ioepoch, int sync);
-int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data,
-                 struct md_open_data **mod);
 void ll_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data,
                          struct lustre_handle *fh);
-int ll_getattr_it(struct vfsmount *mnt, struct dentry *de,
-              struct lookup_intent *it, struct kstat *stat);
 int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat);
-struct ll_file_data *ll_file_data_get(void);
-struct posix_acl * ll_get_acl(struct inode *inode, int type);
+struct posix_acl *ll_get_acl(struct inode *inode, int type);
 
 int ll_inode_permission(struct inode *inode, int mask);
 
@@ -805,44 +774,30 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
 int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp,
                     int *lmm_size, struct ptlrpc_request **request);
 int ll_fsync(struct file *file, loff_t start, loff_t end, int data);
-int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap,
-             int num_bytes);
 int ll_merge_lvb(const struct lu_env *env, struct inode *inode);
-int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg);
-int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg);
 int ll_fid2path(struct inode *inode, void *arg);
 int ll_data_version(struct inode *inode, __u64 *data_version, int extent_lock);
 int ll_hsm_release(struct inode *inode);
 
-struct obd_client_handle *ll_lease_open(struct inode *inode, struct file *file,
-                                       fmode_t mode, __u64 flags);
-int ll_lease_close(struct obd_client_handle *och, struct inode *inode,
-                  bool *lease_broken);
-
 /* llite/dcache.c */
 
 int ll_d_init(struct dentry *de);
-extern struct dentry_operations ll_d_ops;
+extern const struct dentry_operations ll_d_ops;
 void ll_intent_drop_lock(struct lookup_intent *);
 void ll_intent_release(struct lookup_intent *);
 void ll_invalidate_aliases(struct inode *);
-void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft);
 void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry);
-int ll_dcompare(const struct dentry *parent, const struct dentry *dentry,
-               unsigned int len, const char *str, const struct qstr *d_name);
 int ll_revalidate_it_finish(struct ptlrpc_request *request,
                            struct lookup_intent *it, struct dentry *de);
 
 /* llite/llite_lib.c */
 extern struct super_operations lustre_super_operations;
 
-char *ll_read_opt(const char *opt, char *data);
 void ll_lli_init(struct ll_inode_info *lli);
 int ll_fill_super(struct super_block *sb, struct vfsmount *mnt);
 void ll_put_super(struct super_block *sb);
 void ll_kill_super(struct super_block *sb);
 struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock);
-struct inode *ll_inode_from_lock(struct ldlm_lock *lock);
 void ll_clear_inode(struct inode *inode);
 int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import);
 int ll_setattr(struct dentry *de, struct iattr *attr);
@@ -862,9 +817,11 @@ void ll_dirty_page_discard_warn(struct page *page, int ioret);
 int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
                  struct super_block *, struct lookup_intent *);
 void lustre_dump_dentry(struct dentry *, int recur);
-void lustre_dump_inode(struct inode *);
 int ll_obd_statfs(struct inode *inode, void *arg);
 int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize);
+int ll_get_default_mdsize(struct ll_sb_info *sbi, int *default_mdsize);
+int ll_get_max_cookiesize(struct ll_sb_info *sbi, int *max_cookiesize);
+int ll_get_default_cookiesize(struct ll_sb_info *sbi, int *default_cookiesize);
 int ll_process_config(struct lustre_cfg *lcfg);
 struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
                                      struct inode *i1, struct inode *i2,
@@ -881,15 +838,6 @@ void get_uuid2fsid(const char *name, int len, __kernel_fsid_t *fsid);
 struct inode *search_inode_for_lustre(struct super_block *sb,
                                      const struct lu_fid *fid);
 
-/* llite/special.c */
-extern struct inode_operations ll_special_inode_operations;
-extern struct file_operations ll_special_chr_inode_fops;
-extern struct file_operations ll_special_chr_file_fops;
-extern struct file_operations ll_special_blk_inode_fops;
-extern struct file_operations ll_special_fifo_inode_fops;
-extern struct file_operations ll_special_fifo_file_fops;
-extern struct file_operations ll_special_sock_inode_fops;
-
 /* llite/symlink.c */
 extern struct inode_operations ll_fast_symlink_inode_operations;
 
@@ -957,11 +905,6 @@ struct vvp_io {
         * Set when cui_bead has been initialized.
         */
        int               cui_ra_window_set;
-       /**
-        * Partially truncated page, that vvp_io_trunc_start() keeps locked
-        * across truncate.
-        */
-       struct cl_page      *cui_partpage;
 };
 
 /**
@@ -990,12 +933,9 @@ struct ll_cl_context {
        struct cl_page *lcc_page;
        struct lu_env  *lcc_env;
        int          lcc_refcheck;
-       int          lcc_created;
 };
 
 struct vvp_thread_info {
-       struct ost_lvb       vti_lvb;
-       struct cl_2queue     vti_queue;
        struct iovec     vti_local_iov;
        struct vvp_io_args   vti_args;
        struct ra_io_arg     vti_ria;
@@ -1042,25 +982,17 @@ static inline struct vvp_io *vvp_env_io(const struct lu_env *env)
        return &vvp_env_session(env)->vs_ios;
 }
 
+int vvp_global_init(void);
+void vvp_global_fini(void);
+
 void ll_queue_done_writing(struct inode *inode, unsigned long flags);
 void ll_close_thread_shutdown(struct ll_close_queue *lcq);
 int ll_close_thread_start(struct ll_close_queue **lcq_ret);
 
 /* llite/llite_mmap.c */
-typedef struct rb_root  rb_root_t;
-typedef struct rb_node  rb_node_t;
-
-struct ll_lock_tree_node;
-struct ll_lock_tree {
-       rb_root_t                      lt_root;
-       struct list_head                      lt_locked_list;
-       struct ll_file_data         *lt_fd;
-};
 
 int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last);
 int ll_file_mmap(struct file * file, struct vm_area_struct * vma);
-struct ll_lock_tree_node * ll_node_from_inode(struct inode *inode, __u64 start,
-                                             __u64 end, ldlm_mode_t mode);
 void policy_from_vma(ldlm_policy_data_t *policy,
                struct vm_area_struct *vma, unsigned long addr, size_t count);
 struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr,
@@ -1127,11 +1059,6 @@ static inline struct lu_fid *ll_inode2fid(struct inode *inode)
        return fid;
 }
 
-static inline int ll_mds_max_easize(struct super_block *sb)
-{
-       return sbi2mdc(ll_s2sbi(sb))->cl_max_mds_easize;
-}
-
 static inline __u64 ll_file_maxbytes(struct inode *inode)
 {
        return ll_i2info(inode)->lli_maxbytes;
@@ -1149,7 +1076,6 @@ int ll_removexattr(struct dentry *dentry, const char *name);
 extern struct kmem_cache *ll_remote_perm_cachep;
 extern struct kmem_cache *ll_rmtperm_hash_cachep;
 
-struct hlist_head *alloc_rmtperm_hash(void);
 void free_rmtperm_hash(struct hlist_head *hash);
 int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm);
 int lustre_check_remote_perm(struct inode *inode, int mask);
@@ -1162,7 +1088,6 @@ void ll_capa_thread_stop(void);
 void ll_capa_timer_callback(unsigned long unused);
 
 struct obd_capa *ll_add_capa(struct inode *inode, struct obd_capa *ocapa);
-int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa);
 
 void ll_capa_open(struct inode *inode);
 void ll_capa_close(struct inode *inode);
@@ -1182,14 +1107,12 @@ extern struct lu_device_type vvp_device_type;
  */
 int cl_sb_init(struct super_block *sb);
 int cl_sb_fini(struct super_block *sb);
-enum cl_lock_mode  vvp_mode_from_vma(struct vm_area_struct *vma);
 void ll_io_init(struct cl_io *io, const struct file *file, int write);
 
 void ras_update(struct ll_sb_info *sbi, struct inode *inode,
                struct ll_readahead_state *ras, unsigned long index,
                unsigned hit);
 void ll_ra_count_put(struct ll_sb_info *sbi, unsigned long len);
-int ll_is_file_contended(struct file *file);
 void ll_ra_stats_inc(struct address_space *mapping, enum ra_stat which);
 
 /* llite/llite_rmtacl.c */
@@ -1262,7 +1185,6 @@ struct ll_statahead_info {
        unsigned int        sai_skip_hidden;/* skipped hidden dentry count */
        unsigned int        sai_ls_all:1,   /* "ls -al", do stat-ahead for
                                                 * hidden entries */
-                               sai_in_readpage:1,/* statahead is in readdir()*/
                                sai_agl_valid:1;/* AGL is valid for the dir */
        wait_queue_head_t            sai_waitq;      /* stat-ahead wait queue */
        struct ptlrpc_thread    sai_thread;     /* stat-ahead thread */
@@ -1387,9 +1309,6 @@ typedef enum llioc_iter (*llioc_callback_t)(struct inode *inode,
                struct file *file, unsigned int cmd, unsigned long arg,
                void *magic, int *rcp);
 
-enum llioc_iter ll_iocontrol_call(struct inode *inode, struct file *file,
-               unsigned int cmd, unsigned long arg, int *rcp);
-
 /* export functions */
 /* Register ioctl block dynamatically for a regular file.
  *
@@ -1431,7 +1350,7 @@ static inline void cl_isize_unlock(struct inode *inode)
 
 static inline void cl_isize_write_nolock(struct inode *inode, loff_t kms)
 {
-       LASSERT(down_trylock(&ll_i2info(inode)->lli_size_sem) != 0);
+       LASSERT(mutex_is_locked(&ll_i2info(inode)->lli_size_mutex));
        i_size_write(inode, kms);
 }
 
index 7c4fd97a7fa0502684263a011e04064b1148be34..7372986ac145923b9ae9535dab1f33fe10133158 100644 (file)
 struct kmem_cache *ll_file_data_slab;
 struct proc_dir_entry *proc_lustre_fs_root;
 
-LIST_HEAD(ll_super_blocks);
-DEFINE_SPINLOCK(ll_sb_lock);
-
-#ifndef MS_HAS_NEW_AOPS
-extern struct address_space_operations ll_aops;
-#else
-extern struct address_space_operations_ext ll_aops;
-#endif
+static LIST_HEAD(ll_super_blocks);
+static DEFINE_SPINLOCK(ll_sb_lock);
 
 #ifndef log2
 #define log2(n) ffz(~(n))
@@ -143,7 +137,7 @@ static struct ll_sb_info *ll_init_sbi(void)
        return sbi;
 }
 
-void ll_free_sbi(struct super_block *sb)
+static void ll_free_sbi(struct super_block *sb)
 {
        struct ll_sb_info *sbi = ll_s2sbi(sb);
 
@@ -634,7 +628,46 @@ int ll_get_max_mdsize(struct ll_sb_info *sbi, int *lmmsize)
        return rc;
 }
 
-void ll_dump_inode(struct inode *inode)
+int ll_get_default_mdsize(struct ll_sb_info *sbi, int *lmmsize)
+{
+       int size, rc;
+
+       size = sizeof(int);
+       rc = obd_get_info(NULL, sbi->ll_md_exp, sizeof(KEY_DEFAULT_EASIZE),
+                        KEY_DEFAULT_EASIZE, &size, lmmsize, NULL);
+       if (rc)
+               CERROR("Get default mdsize error rc %d\n", rc);
+
+       return rc;
+}
+
+int ll_get_max_cookiesize(struct ll_sb_info *sbi, int *lmmsize)
+{
+       int size, rc;
+
+       size = sizeof(int);
+       rc = obd_get_info(NULL, sbi->ll_md_exp, sizeof(KEY_MAX_COOKIESIZE),
+                         KEY_MAX_COOKIESIZE, &size, lmmsize, NULL);
+       if (rc)
+               CERROR("Get max cookiesize error rc %d\n", rc);
+
+       return rc;
+}
+
+int ll_get_default_cookiesize(struct ll_sb_info *sbi, int *lmmsize)
+{
+       int size, rc;
+
+       size = sizeof(int);
+       rc = obd_get_info(NULL, sbi->ll_md_exp, sizeof(KEY_DEFAULT_COOKIESIZE),
+                         KEY_DEFAULT_COOKIESIZE, &size, lmmsize, NULL);
+       if (rc)
+               CERROR("Get default cookiesize error rc %d\n", rc);
+
+       return rc;
+}
+
+static void ll_dump_inode(struct inode *inode)
 {
        struct ll_d_hlist_node *tmp;
        int dentry_count = 0;
@@ -677,7 +710,7 @@ void lustre_dump_dentry(struct dentry *dentry, int recur)
        }
 }
 
-void client_common_put_super(struct super_block *sb)
+static void client_common_put_super(struct super_block *sb)
 {
        struct ll_sb_info *sbi = ll_s2sbi(sb);
 
@@ -726,30 +759,6 @@ void ll_kill_super(struct super_block *sb)
        }
 }
 
-char *ll_read_opt(const char *opt, char *data)
-{
-       char *value;
-       char *retval;
-
-       CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
-       if (strncmp(opt, data, strlen(opt)))
-               return NULL;
-       value = strchr(data, '=');
-       if (value == NULL)
-               return NULL;
-
-       value++;
-       OBD_ALLOC(retval, strlen(value) + 1);
-       if (!retval) {
-               CERROR("out of memory!\n");
-               return NULL;
-       }
-
-       memcpy(retval, value, strlen(value)+1);
-       CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval);
-       return retval;
-}
-
 static inline int ll_set_opt(const char *opt, char *data, int fl)
 {
        if (strncmp(opt, data, strlen(opt)) != 0)
@@ -927,7 +936,8 @@ void ll_lli_init(struct ll_inode_info *lli)
        mutex_init(&lli->lli_och_mutex);
        spin_lock_init(&lli->lli_agl_lock);
        lli->lli_has_smd = false;
-       lli->lli_layout_gen = LL_LAYOUT_GEN_NONE;
+       spin_lock_init(&lli->lli_layout_lock);
+       ll_layout_version_set(lli, LL_LAYOUT_GEN_NONE);
        lli->lli_clob = NULL;
 
        init_rwsem(&lli->lli_xattrs_list_rwsem);
@@ -938,12 +948,10 @@ void ll_lli_init(struct ll_inode_info *lli)
                mutex_init(&lli->lli_readdir_mutex);
                lli->lli_opendir_key = NULL;
                lli->lli_sai = NULL;
-               lli->lli_def_acl = NULL;
                spin_lock_init(&lli->lli_sa_lock);
                lli->lli_opendir_pid = 0;
        } else {
-               sema_init(&lli->lli_size_sem, 1);
-               lli->lli_size_sem_owner = NULL;
+               mutex_init(&lli->lli_size_mutex);
                lli->lli_symlink_name = NULL;
                init_rwsem(&lli->lli_trunc_sem);
                mutex_init(&lli->lli_write_mutex);
@@ -952,7 +960,6 @@ void ll_lli_init(struct ll_inode_info *lli)
                INIT_LIST_HEAD(&lli->lli_agl_list);
                lli->lli_agl_index = 0;
                lli->lli_async_rc = 0;
-               lli->lli_volatile = false;
        }
        mutex_init(&lli->lli_layout_mutex);
 }
@@ -1151,28 +1158,6 @@ struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock)
        return inode;
 }
 
-struct inode *ll_inode_from_lock(struct ldlm_lock *lock)
-{
-       struct inode *inode = NULL;
-       /* NOTE: we depend on atomic igrab() -bzzz */
-       lock_res_and_lock(lock);
-       if (lock->l_ast_data) {
-               struct ll_inode_info *lli = ll_i2info(lock->l_ast_data);
-               if (lli->lli_inode_magic == LLI_INODE_MAGIC) {
-                       inode = igrab(lock->l_ast_data);
-               } else {
-                       inode = lock->l_ast_data;
-                       LDLM_DEBUG_LIMIT(inode->i_state & I_FREEING ?  D_INFO :
-                                        D_WARNING, lock, "l_ast_data %p is "
-                                        "bogus: magic %08x", lock->l_ast_data,
-                                        lli->lli_inode_magic);
-                       inode = NULL;
-               }
-       }
-       unlock_res_and_lock(lock);
-       return inode;
-}
-
 void ll_clear_inode(struct inode *inode)
 {
        struct ll_inode_info *lli = ll_i2info(inode);
@@ -1449,7 +1434,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
                if (attr->ia_valid & ATTR_SIZE)
                        inode_dio_write_done(inode);
                mutex_unlock(&inode->i_mutex);
-               down_write(&lli->lli_trunc_sem);
        }
 
        memcpy(&op_data->op_attr, attr, sizeof(*attr));
@@ -1513,7 +1497,11 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
                 * excessive to send mtime/atime updates to OSTs when not
                 * setting times to past, but it is necessary due to possible
                 * time de-synchronization between MDT inode and OST objects */
+               if (attr->ia_valid & ATTR_SIZE)
+                       down_write(&lli->lli_trunc_sem);
                rc = ll_setattr_ost(inode, attr);
+               if (attr->ia_valid & ATTR_SIZE)
+                       up_write(&lli->lli_trunc_sem);
 out:
        if (op_data) {
                if (op_data->op_ioepoch) {
@@ -1524,7 +1512,6 @@ out:
                ll_finish_md_op_data(op_data);
        }
        if (!S_ISDIR(inode->i_mode)) {
-               up_write(&lli->lli_trunc_sem);
                mutex_lock(&inode->i_mutex);
                if ((attr->ia_valid & ATTR_SIZE) && !hsm_import)
                        inode_dio_wait(inode);
@@ -1658,10 +1645,7 @@ void ll_inode_size_lock(struct inode *inode)
        LASSERT(!S_ISDIR(inode->i_mode));
 
        lli = ll_i2info(inode);
-       LASSERT(lli->lli_size_sem_owner != current);
-       down(&lli->lli_size_sem);
-       LASSERT(lli->lli_size_sem_owner == NULL);
-       lli->lli_size_sem_owner = current;
+       mutex_lock(&lli->lli_size_mutex);
 }
 
 void ll_inode_size_unlock(struct inode *inode)
@@ -1669,9 +1653,7 @@ void ll_inode_size_unlock(struct inode *inode)
        struct ll_inode_info *lli;
 
        lli = ll_i2info(inode);
-       LASSERT(lli->lli_size_sem_owner == current);
-       lli->lli_size_sem_owner = NULL;
-       up(&lli->lli_size_sem);
+       mutex_unlock(&lli->lli_size_mutex);
 }
 
 void ll_update_inode(struct inode *inode, struct lustre_md *md)
@@ -2420,11 +2402,12 @@ void ll_dirty_page_discard_warn(struct page *page, int ioret)
                        path = ll_d_path(dentry, buf, PAGE_SIZE);
        }
 
-       CWARN("%s: dirty page discard: %s/fid: "DFID"/%s may get corrupted "
-             "(rc %d)\n", ll_get_fsname(page->mapping->host->i_sb, NULL, 0),
-             s2lsi(page->mapping->host->i_sb)->lsi_lmd->lmd_dev,
-             PFID(&obj->cob_header.coh_lu.loh_fid),
-             (path && !IS_ERR(path)) ? path : "", ioret);
+       CDEBUG(D_WARNING,
+              "%s: dirty page discard: %s/fid: "DFID"/%s may get corrupted "
+              "(rc %d)\n", ll_get_fsname(page->mapping->host->i_sb, NULL, 0),
+              s2lsi(page->mapping->host->i_sb)->lsi_lmd->lmd_dev,
+              PFID(&obj->cob_header.coh_lu.loh_fid),
+              (path && !IS_ERR(path)) ? path : "", ioret);
 
        if (dentry != NULL)
                dput(dentry);
index 90b2c0d275f9e17ead658b67abda524524d78678..426c739616653f134396922b3735e50d00634333 100644 (file)
 #include "llite_internal.h"
 #include <linux/lustre_compat25.h>
 
-struct page *ll_nopage(struct vm_area_struct *vma, unsigned long address,
-                      int *type);
-
-static struct vm_operations_struct ll_file_vm_ops;
+static const struct vm_operations_struct ll_file_vm_ops;
 
 void policy_from_vma(ldlm_policy_data_t *policy,
                            struct vm_area_struct *vma, unsigned long addr,
@@ -97,10 +94,10 @@ struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr,
  * \retval EINVAL if env can't allocated
  * \return other error codes from cl_io_init.
  */
-struct cl_io *ll_fault_io_init(struct vm_area_struct *vma,
-                              struct lu_env **env_ret,
-                              struct cl_env_nest *nest,
-                              pgoff_t index, unsigned long *ra_flags)
+static struct cl_io *
+ll_fault_io_init(struct vm_area_struct *vma, struct lu_env **env_ret,
+                struct cl_env_nest *nest, pgoff_t index,
+                unsigned long *ra_flags)
 {
        struct file            *file = vma->vm_file;
        struct inode           *inode = file->f_dentry->d_inode;
@@ -446,14 +443,6 @@ static void ll_vm_close(struct vm_area_struct *vma)
        LASSERT(atomic_read(&vob->cob_mmap_cnt) >= 0);
 }
 
-
-/* return the user space pointer that maps to a file offset via a vma */
-static inline unsigned long file_to_user(struct vm_area_struct *vma, __u64 byte)
-{
-       return vma->vm_start + (byte - ((__u64)vma->vm_pgoff << PAGE_CACHE_SHIFT));
-
-}
-
 /* XXX put nice comment here.  talk about __free_pte -> dirty pages and
  * nopage's reference passing to the pte */
 int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last)
@@ -470,7 +459,7 @@ int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last)
        return rc;
 }
 
-static struct vm_operations_struct ll_file_vm_ops = {
+static const struct vm_operations_struct ll_file_vm_ops = {
        .fault                  = ll_fault,
        .page_mkwrite           = ll_page_mkwrite,
        .open                   = ll_vm_open,
index 3580069789fc1e34b162271e069346f87d0b9391..e0e112b710d72a17dc31bdedc1f634ab7cbfb9d4 100644 (file)
@@ -98,7 +98,7 @@ struct inode *search_inode_for_lustre(struct super_block *sb,
        if (inode)
                return inode;
 
-       rc = ll_get_max_mdsize(sbi, &eadatalen);
+       rc = ll_get_default_mdsize(sbi, &eadatalen);
        if (rc)
                return ERR_PTR(rc);
 
@@ -290,7 +290,7 @@ static struct dentry *ll_get_parent(struct dentry *dchild)
        CDEBUG(D_INFO, "getting parent for (%lu,"DFID")\n",
                        dir->i_ino, PFID(ll_inode2fid(dir)));
 
-       rc = ll_get_max_mdsize(sbi, &lmmsize);
+       rc = ll_get_default_mdsize(sbi, &lmmsize);
        if (rc != 0)
                return ERR_PTR(rc);
 
index f78eda235c7ab43a561efb21cfc0b4c50be4bcbe..b9694b8cb5dd6e2a200d7f94df765e68e0f788d5 100644 (file)
@@ -122,9 +122,6 @@ struct lloop_device {
        loff_t         lo_offset;
        loff_t         lo_sizelimit;
        int               lo_flags;
-       int             (*ioctl)(struct lloop_device *, int cmd,
-                                   unsigned long arg);
-
        struct file      *lo_backing_file;
        struct block_device *lo_device;
        unsigned             lo_blocksize;
@@ -509,7 +506,6 @@ static int loop_set_fd(struct lloop_device *lo, struct file *unused,
        lo->lo_device = bdev;
        lo->lo_flags = lo_flags;
        lo->lo_backing_file = file;
-       lo->ioctl = NULL;
        lo->lo_sizelimit = 0;
        lo->old_gfp_mask = mapping_gfp_mask(mapping);
        mapping_set_gfp_mask(mapping, lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS));
@@ -568,7 +564,6 @@ static int loop_clr_fd(struct lloop_device *lo, struct block_device *bdev,
 
        down(&lo->lo_sem);
        lo->lo_backing_file = NULL;
-       lo->ioctl = NULL;
        lo->lo_device = NULL;
        lo->lo_offset = 0;
        lo->lo_sizelimit = 0;
@@ -624,7 +619,10 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode,
        case LL_IOC_LLOOP_INFO: {
                struct lu_fid fid;
 
-               LASSERT(lo->lo_backing_file != NULL);
+               if (lo->lo_backing_file == NULL) {
+                       err = -ENOENT;
+                       break;
+               }
                if (inode == NULL)
                        inode = lo->lo_backing_file->f_dentry->d_inode;
                if (lo->lo_state == LLOOP_BOUND)
index a9a104a6a4ee16c71d6e0f75326424cc1536bfd7..77ee9e58cf87c7bc34a9b541ffa9af244342d2f5 100644 (file)
 #include <obd_support.h>
 
 #include "llite_internal.h"
+#include "vvp_internal.h"
 
 /* /proc/lustre/llite mount point registration */
-extern struct file_operations vvp_dump_pgcache_file_ops;
-struct file_operations ll_rw_extents_stats_fops;
-struct file_operations ll_rw_extents_stats_pp_fops;
-struct file_operations ll_rw_offset_stats_fops;
+static struct file_operations ll_rw_extents_stats_fops;
+static struct file_operations ll_rw_extents_stats_pp_fops;
+static struct file_operations ll_rw_offset_stats_fops;
 
 static int ll_blksize_seq_show(struct seq_file *m, void *v)
 {
@@ -367,8 +367,9 @@ static int ll_max_cached_mb_seq_show(struct seq_file *m, void *v)
                        cache->ccc_lru_shrinkers);
 }
 
-static ssize_t ll_max_cached_mb_seq_write(struct file *file, const char *buffer,
-                                     size_t count, loff_t *off)
+static ssize_t ll_max_cached_mb_seq_write(struct file *file,
+                                         const char __user *buffer,
+                                         size_t count, loff_t *off)
 {
        struct super_block *sb = ((struct seq_file *)file->private_data)->private;
        struct ll_sb_info *sbi = ll_s2sbi(sb);
@@ -376,9 +377,18 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file, const char *buffer,
        int mult, rc, pages_number;
        int diff = 0;
        int nrpages = 0;
+       char kernbuf[128];
+
+       if (count >= sizeof(kernbuf))
+               return -EINVAL;
+
+       if (copy_from_user(kernbuf, buffer, count))
+               return -EFAULT;
+       kernbuf[count] = 0;
 
        mult = 1 << (20 - PAGE_CACHE_SHIFT);
-       buffer = lprocfs_find_named_value(buffer, "max_cached_mb:", &count);
+       buffer += lprocfs_find_named_value(kernbuf, "max_cached_mb:", &count) -
+                 kernbuf;
        rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
        if (rc)
                return rc;
@@ -681,7 +691,7 @@ static ssize_t ll_lazystatfs_seq_write(struct file *file, const char *buffer,
 }
 LPROC_SEQ_FOPS(ll_lazystatfs);
 
-static int ll_maxea_size_seq_show(struct seq_file *m, void *v)
+static int ll_max_easize_seq_show(struct seq_file *m, void *v)
 {
        struct super_block *sb = m->private;
        struct ll_sb_info *sbi = ll_s2sbi(sb);
@@ -694,7 +704,52 @@ static int ll_maxea_size_seq_show(struct seq_file *m, void *v)
 
        return seq_printf(m, "%u\n", ealen);
 }
-LPROC_SEQ_FOPS_RO(ll_maxea_size);
+LPROC_SEQ_FOPS_RO(ll_max_easize);
+
+static int ll_defult_easize_seq_show(struct seq_file *m, void *v)
+{
+       struct super_block *sb = m->private;
+       struct ll_sb_info *sbi = ll_s2sbi(sb);
+       unsigned int ealen;
+       int rc;
+
+       rc = ll_get_default_mdsize(sbi, &ealen);
+       if (rc)
+               return rc;
+
+       return seq_printf(m, "%u\n", ealen);
+}
+LPROC_SEQ_FOPS_RO(ll_defult_easize);
+
+static int ll_max_cookiesize_seq_show(struct seq_file *m, void *v)
+{
+       struct super_block *sb = m->private;
+       struct ll_sb_info *sbi = ll_s2sbi(sb);
+       unsigned int cookielen;
+       int rc;
+
+       rc = ll_get_max_cookiesize(sbi, &cookielen);
+       if (rc)
+               return rc;
+
+       return seq_printf(m, "%u\n", cookielen);
+}
+LPROC_SEQ_FOPS_RO(ll_max_cookiesize);
+
+static int ll_defult_cookiesize_seq_show(struct seq_file *m, void *v)
+{
+       struct super_block *sb = m->private;
+       struct ll_sb_info *sbi = ll_s2sbi(sb);
+       unsigned int cookielen;
+       int rc;
+
+       rc = ll_get_default_cookiesize(sbi, &cookielen);
+       if (rc)
+               return rc;
+
+       return seq_printf(m, "%u\n", cookielen);
+}
+LPROC_SEQ_FOPS_RO(ll_defult_cookiesize);
 
 static int ll_sbi_flags_seq_show(struct seq_file *m, void *v)
 {
@@ -781,7 +836,10 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = {
        { "statahead_agl",    &ll_statahead_agl_fops, 0 },
        { "statahead_stats",  &ll_statahead_stats_fops, 0, 0 },
        { "lazystatfs",       &ll_lazystatfs_fops, 0 },
-       { "max_easize",       &ll_maxea_size_fops, 0, 0 },
+       { "max_easize",       &ll_max_easize_fops, 0, 0 },
+       { "default_easize",   &ll_defult_easize_fops, 0, 0 },
+       { "max_cookiesize",   &ll_max_cookiesize_fops, 0, 0 },
+       { "default_cookiesize", &ll_defult_cookiesize_fops, 0, 0 },
        { "sbi_flags",        &ll_sbi_flags_fops, 0, 0 },
        { "xattr_cache",      &ll_xattr_cache_fops, 0, 0 },
        { 0 }
@@ -789,7 +847,7 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = {
 
 #define MAX_STRING_SIZE 128
 
-struct llite_file_opcode {
+static const struct llite_file_opcode {
        __u32       opcode;
        __u32       type;
        const char *opname;
@@ -1115,7 +1173,8 @@ static int ll_rw_extents_stats_pp_seq_show(struct seq_file *seq, void *v)
 }
 
 static ssize_t ll_rw_extents_stats_pp_seq_write(struct file *file,
-                                               const char *buf, size_t len,
+                                               const char __user *buf,
+                                               size_t len,
                                                loff_t *off)
 {
        struct seq_file *seq = file->private_data;
@@ -1124,10 +1183,24 @@ static ssize_t ll_rw_extents_stats_pp_seq_write(struct file *file,
        int i;
        int value = 1, rc = 0;
 
+       if (len == 0)
+               return -EINVAL;
+
        rc = lprocfs_write_helper(buf, len, &value);
-       if (rc < 0 && (strcmp(buf, "disabled") == 0 ||
-                      strcmp(buf, "Disabled") == 0))
-               value = 0;
+       if (rc < 0 && len < 16) {
+               char kernbuf[16];
+
+               if (copy_from_user(kernbuf, buf, len))
+                       return -EFAULT;
+               kernbuf[len] = 0;
+
+               if (kernbuf[len - 1] == '\n')
+                       kernbuf[len - 1] = 0;
+
+               if (strcmp(kernbuf, "disabled") == 0 ||
+                   strcmp(kernbuf, "Disabled") == 0)
+                       value = 0;
+       }
 
        if (value == 0)
                sbi->ll_rw_stats_on = 0;
@@ -1174,8 +1247,9 @@ static int ll_rw_extents_stats_seq_show(struct seq_file *seq, void *v)
        return 0;
 }
 
-static ssize_t ll_rw_extents_stats_seq_write(struct file *file, const char *buf,
-                                       size_t len, loff_t *off)
+static ssize_t ll_rw_extents_stats_seq_write(struct file *file,
+                                            const char __user *buf,
+                                            size_t len, loff_t *off)
 {
        struct seq_file *seq = file->private_data;
        struct ll_sb_info *sbi = seq->private;
@@ -1183,15 +1257,30 @@ static ssize_t ll_rw_extents_stats_seq_write(struct file *file, const char *buf,
        int i;
        int value = 1, rc = 0;
 
+       if (len == 0)
+               return -EINVAL;
+
        rc = lprocfs_write_helper(buf, len, &value);
-       if (rc < 0 && (strcmp(buf, "disabled") == 0 ||
-                      strcmp(buf, "Disabled") == 0))
-               value = 0;
+       if (rc < 0 && len < 16) {
+               char kernbuf[16];
+
+               if (copy_from_user(kernbuf, buf, len))
+                       return -EFAULT;
+               kernbuf[len] = 0;
+
+               if (kernbuf[len - 1] == '\n')
+                       kernbuf[len - 1] = 0;
+
+               if (strcmp(kernbuf, "disabled") == 0 ||
+                   strcmp(kernbuf, "Disabled") == 0)
+                       value = 0;
+       }
 
        if (value == 0)
                sbi->ll_rw_stats_on = 0;
        else
                sbi->ll_rw_stats_on = 1;
+
        spin_lock(&sbi->ll_pp_extent_lock);
        for (i = 0; i <= LL_PROCESS_HIST_MAX; i++) {
                io_extents->pp_extents[i].pid = 0;
@@ -1202,7 +1291,6 @@ static ssize_t ll_rw_extents_stats_seq_write(struct file *file, const char *buf,
 
        return len;
 }
-
 LPROC_SEQ_FOPS(ll_rw_extents_stats);
 
 void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid,
@@ -1362,8 +1450,9 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v)
        return 0;
 }
 
-static ssize_t ll_rw_offset_stats_seq_write(struct file *file, const char *buf,
-                                      size_t len, loff_t *off)
+static ssize_t ll_rw_offset_stats_seq_write(struct file *file,
+                                           const char __user *buf,
+                                           size_t len, loff_t *off)
 {
        struct seq_file *seq = file->private_data;
        struct ll_sb_info *sbi = seq->private;
@@ -1371,11 +1460,25 @@ static ssize_t ll_rw_offset_stats_seq_write(struct file *file, const char *buf,
        struct ll_rw_process_info *offset_info = sbi->ll_rw_offset_info;
        int value = 1, rc = 0;
 
+       if (len == 0)
+               return -EINVAL;
+
        rc = lprocfs_write_helper(buf, len, &value);
 
-       if (rc < 0 && (strcmp(buf, "disabled") == 0 ||
-                          strcmp(buf, "Disabled") == 0))
-               value = 0;
+       if (rc < 0 && len < 16) {
+               char kernbuf[16];
+
+               if (copy_from_user(kernbuf, buf, len))
+                       return -EFAULT;
+               kernbuf[len] = 0;
+
+               if (kernbuf[len - 1] == '\n')
+                       kernbuf[len - 1] = 0;
+
+               if (strcmp(kernbuf, "disabled") == 0 ||
+                   strcmp(kernbuf, "Disabled") == 0)
+                       value = 0;
+       }
 
        if (value == 0)
                sbi->ll_rw_stats_on = 0;
index 25a6ea580f000ff8fe3b81255fd3066adca81747..dfa1e745dfd6849c5907fad59e0f811352c6c753 100644 (file)
@@ -75,14 +75,6 @@ static int ll_d_mountpoint(struct dentry *dparent, struct dentry *dchild,
        return mounted;
 }
 
-int ll_unlock(__u32 mode, struct lustre_handle *lockh)
-{
-       ldlm_lock_decref(lockh, mode);
-
-       return 0;
-}
-
-
 /* called from iget5_locked->find_inode() under inode_hash_lock spinlock */
 static int ll_test_inode(struct inode *inode, void *opaque)
 {
@@ -433,12 +425,10 @@ struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de)
        return de;
 }
 
-int ll_lookup_it_finish(struct ptlrpc_request *request,
-                       struct lookup_intent *it, void *data)
+static int ll_lookup_it_finish(struct ptlrpc_request *request,
+                              struct lookup_intent *it,
+                              struct inode *parent, struct dentry **de)
 {
-       struct it_cb_data *icbd = data;
-       struct dentry **de = icbd->icbd_childp;
-       struct inode *parent = icbd->icbd_parent;
        struct inode *inode = NULL;
        __u64 bits = 0;
        int rc;
@@ -513,7 +503,6 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
        struct dentry *save = dentry, *retval;
        struct ptlrpc_request *req = NULL;
        struct md_op_data *op_data;
-       struct it_cb_data icbd;
        __u32 opc;
        int rc;
 
@@ -527,7 +516,8 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
        if (d_mountpoint(dentry))
                CERROR("Tell Peter, lookup on mtpt, it %s\n", LL_IT2STR(it));
 
-       ll_frob_intent(&it, &lookup_it);
+       if (it == NULL || it->it_op == IT_GETXATTR)
+               it = &lookup_it;
 
        if (it->it_op == IT_GETATTR) {
                rc = ll_statahead_enter(parent, &dentry, 0);
@@ -538,9 +528,6 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
                }
        }
 
-       icbd.icbd_childp = &dentry;
-       icbd.icbd_parent = parent;
-
        if (it->it_op & IT_CREAT)
                opc = LUSTRE_OPC_CREATE;
        else
@@ -562,7 +549,7 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
        if (rc < 0)
                GOTO(out, retval = ERR_PTR(rc));
 
-       rc = ll_lookup_it_finish(req, it, &icbd);
+       rc = ll_lookup_it_finish(req, it, parent, &dentry);
        if (rc != 0) {
                ll_intent_release(it);
                GOTO(out, retval = ERR_PTR(rc));
@@ -697,10 +684,7 @@ out_release:
 
 
 /* We depend on "mode" being set with the proper file type/umask by now */
-static struct inode *ll_create_node(struct inode *dir, const char *name,
-                                   int namelen, const void *data, int datalen,
-                                   int mode, __u64 extra,
-                                   struct lookup_intent *it)
+static struct inode *ll_create_node(struct inode *dir, struct lookup_intent *it)
 {
        struct inode *inode = NULL;
        struct ptlrpc_request *request = NULL;
@@ -757,14 +741,10 @@ static int ll_create_it(struct inode *dir, struct dentry *dentry, int mode,
        if (rc)
                return rc;
 
-       inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len,
-                              NULL, 0, mode, 0, it);
+       inode = ll_create_node(dir, it);
        if (IS_ERR(inode))
                return PTR_ERR(inode);
 
-       if (filename_is_volatile(dentry->d_name.name, dentry->d_name.len, NULL))
-               ll_i2info(inode)->lli_volatile = true;
-
        d_instantiate(dentry, inode);
        return 0;
 }
@@ -1238,7 +1218,7 @@ static int ll_rename(struct inode *old_dir, struct dentry *old_dentry,
        return err;
 }
 
-struct inode_operations ll_dir_inode_operations = {
+const struct inode_operations ll_dir_inode_operations = {
        .mknod        = ll_mknod,
        .atomic_open        = ll_atomic_open,
        .lookup      = ll_lookup_nd,
@@ -1260,7 +1240,7 @@ struct inode_operations ll_dir_inode_operations = {
        .get_acl            = ll_get_acl,
 };
 
-struct inode_operations ll_special_inode_operations = {
+const struct inode_operations ll_special_inode_operations = {
        .setattr        = ll_setattr,
        .getattr        = ll_getattr,
        .permission     = ll_inode_permission,
index dedd56ae1e6d52f2ee3bab2fe209c2d42f928a14..a8b1117b8f6012f249c6811e4cd3e26b98113653 100644 (file)
@@ -77,7 +77,7 @@ static inline void free_ll_remote_perm(struct ll_remote_perm *lrp)
        OBD_SLAB_FREE(lrp, ll_remote_perm_cachep, sizeof(*lrp));
 }
 
-struct hlist_head *alloc_rmtperm_hash(void)
+static struct hlist_head *alloc_rmtperm_hash(void)
 {
        struct hlist_head *hash;
        int i;
index 416f7a094a6d2fc81f9cc5f2ab5291bc6e733daf..f0122c568a099fbb2ea519ddc4bca5d97a34495a 100644 (file)
@@ -77,12 +77,6 @@ static void ll_cl_fini(struct ll_cl_context *lcc)
                cl_page_put(env, page);
        }
 
-       if (io && lcc->lcc_created) {
-               cl_io_end(env, io);
-               cl_io_unlock(env, io);
-               cl_io_iter_fini(env, io);
-               cl_io_fini(env, io);
-       }
        cl_env_put(env, &lcc->lcc_refcheck);
 }
 
@@ -167,7 +161,6 @@ static struct ll_cl_context *ll_cl_init(struct file *file,
                        }
                } else
                        result = io->ci_result;
-               lcc->lcc_created = 1;
        }
 
        lcc->lcc_io = io;
index 7e3e0967993b5f6fecc7bfa965ef9a444cd0037f..b401d36b5739c88f9c133a5fc21f65c1dade0915 100644 (file)
@@ -529,9 +529,9 @@ static int ll_write_end(struct file *file, struct address_space *mapping,
 }
 
 #ifdef CONFIG_MIGRATION
-int ll_migratepage(struct address_space *mapping,
-               struct page *newpage, struct page *page
-               , enum migrate_mode mode
+static int ll_migratepage(struct address_space *mapping,
+                        struct page *newpage, struct page *page,
+                        enum migrate_mode mode
                )
 {
        /* Always fail page migration until we have a proper implementation */
@@ -540,9 +540,8 @@ int ll_migratepage(struct address_space *mapping,
 #endif
 
 #ifndef MS_HAS_NEW_AOPS
-struct address_space_operations ll_aops = {
-       .readpage       = ll_readpage,
-//     .readpages      = ll_readpages,
+const struct address_space_operations ll_aops = {
+       .readpage       = ll_readpage,
        .direct_IO      = ll_direct_IO_26,
        .writepage      = ll_writepage,
        .writepages     = ll_writepages,
@@ -554,10 +553,9 @@ struct address_space_operations ll_aops = {
 #ifdef CONFIG_MIGRATION
        .migratepage    = ll_migratepage,
 #endif
-       .bmap      = NULL
 };
 #else
-struct address_space_operations_ext ll_aops = {
+const struct address_space_operations_ext ll_aops = {
        .orig_aops.readpage       = ll_readpage,
 //     .orig_aops.readpages      = ll_readpages,
        .orig_aops.direct_IO      = ll_direct_IO_26,
@@ -571,7 +569,6 @@ struct address_space_operations_ext ll_aops = {
 #ifdef CONFIG_MIGRATION
        .orig_aops.migratepage    = ll_migratepage,
 #endif
-       .orig_aops.bmap    = NULL,
        .write_begin    = ll_write_begin,
        .write_end      = ll_write_end
 };
index c8624b5a98750674268dae162b4a1120bb988cc1..1b47774d7447ed7fedcf42fe25788d79cd0fe060 100644 (file)
@@ -958,13 +958,18 @@ static int ll_agl_thread(void *arg)
        struct ptlrpc_thread     *thread = &sai->sai_agl_thread;
        struct l_wait_info      lwi    = { 0 };
 
-       CDEBUG(D_READA, "agl thread started: [pid %d] [parent %.*s]\n",
-              current_pid(), parent->d_name.len, parent->d_name.name);
+       thread->t_pid = current_pid();
+       CDEBUG(D_READA, "agl thread started: sai %p, parent %.*s\n",
+              sai, parent->d_name.len, parent->d_name.name);
 
        atomic_inc(&sbi->ll_agl_total);
        spin_lock(&plli->lli_agl_lock);
        sai->sai_agl_valid = 1;
-       thread_set_flags(thread, SVC_RUNNING);
+       if (thread_is_init(thread))
+               /* If someone else has changed the thread state
+                * (e.g. already changed to SVC_STOPPING), we can't just
+                * blindly overwrite that setting. */
+               thread_set_flags(thread, SVC_RUNNING);
        spin_unlock(&plli->lli_agl_lock);
        wake_up(&thread->t_ctl_waitq);
 
@@ -1004,8 +1009,8 @@ static int ll_agl_thread(void *arg)
        spin_unlock(&plli->lli_agl_lock);
        wake_up(&thread->t_ctl_waitq);
        ll_sai_put(sai);
-       CDEBUG(D_READA, "agl thread stopped: [pid %d] [parent %.*s]\n",
-              current_pid(), parent->d_name.len, parent->d_name.name);
+       CDEBUG(D_READA, "agl thread stopped: sai %p, parent %.*s\n",
+              sai, parent->d_name.len, parent->d_name.name);
        return 0;
 }
 
@@ -1016,8 +1021,8 @@ static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai)
        struct ll_inode_info  *plli;
        struct task_struct *task;
 
-       CDEBUG(D_READA, "start agl thread: [pid %d] [parent %.*s]\n",
-              current_pid(), parent->d_name.len, parent->d_name.name);
+       CDEBUG(D_READA, "start agl thread: sai %p, parent %.*s\n",
+              sai, parent->d_name.len, parent->d_name.name);
 
        plli = ll_i2info(parent->d_inode);
        task = kthread_run(ll_agl_thread, parent,
@@ -1050,15 +1055,20 @@ static int ll_statahead_thread(void *arg)
        struct ll_dir_chain       chain;
        struct l_wait_info      lwi    = { 0 };
 
-       CDEBUG(D_READA, "statahead thread started: [pid %d] [parent %.*s]\n",
-              current_pid(), parent->d_name.len, parent->d_name.name);
+       thread->t_pid = current_pid();
+       CDEBUG(D_READA, "statahead thread starting: sai %p, parent %.*s\n",
+              sai, parent->d_name.len, parent->d_name.name);
 
        if (sbi->ll_flags & LL_SBI_AGL_ENABLED)
                ll_start_agl(parent, sai);
 
        atomic_inc(&sbi->ll_sa_total);
        spin_lock(&plli->lli_sa_lock);
-       thread_set_flags(thread, SVC_RUNNING);
+       if (thread_is_init(thread))
+               /* If someone else has changed the thread state
+                * (e.g. already changed to SVC_STOPPING), we can't just
+                * blindly overwrite that setting. */
+               thread_set_flags(thread, SVC_RUNNING);
        spin_unlock(&plli->lli_sa_lock);
        wake_up(&thread->t_ctl_waitq);
 
@@ -1220,9 +1230,7 @@ do_it:
                         */
                        ll_release_page(page, le32_to_cpu(dp->ldp_flags) &
                                              LDF_COLLIDE);
-                       sai->sai_in_readpage = 1;
                        page = ll_get_dir_page(dir, pos, &chain);
-                       sai->sai_in_readpage = 0;
                } else {
                        LASSERT(le32_to_cpu(dp->ldp_flags) & LDF_COLLIDE);
                        ll_release_page(page, 1);
@@ -1239,8 +1247,8 @@ out:
                spin_unlock(&plli->lli_agl_lock);
                wake_up(&agl_thread->t_ctl_waitq);
 
-               CDEBUG(D_READA, "stop agl thread: [pid %d]\n",
-                      current_pid());
+               CDEBUG(D_READA, "stop agl thread: sai %p pid %u\n",
+                      sai, (unsigned int)agl_thread->t_pid);
                l_wait_event(agl_thread->t_ctl_waitq,
                             thread_is_stopped(agl_thread),
                             &lwi);
@@ -1266,8 +1274,8 @@ out:
        wake_up(&thread->t_ctl_waitq);
        ll_sai_put(sai);
        dput(parent);
-       CDEBUG(D_READA, "statahead thread stopped: [pid %d] [parent %.*s]\n",
-              current_pid(), parent->d_name.len, parent->d_name.name);
+       CDEBUG(D_READA, "statahead thread stopped: sai %p, parent %.*s\n",
+              sai, parent->d_name.len, parent->d_name.name);
        return rc;
 }
 
@@ -1298,8 +1306,8 @@ void ll_stop_statahead(struct inode *dir, void *key)
                        spin_unlock(&lli->lli_sa_lock);
                        wake_up(&thread->t_ctl_waitq);
 
-                       CDEBUG(D_READA, "stop statahead thread: [pid %d]\n",
-                              current_pid());
+                       CDEBUG(D_READA, "stop statahead thread: sai %p pid %u\n",
+                              lli->lli_sai, (unsigned int)thread->t_pid);
                        l_wait_event(thread->t_ctl_waitq,
                                     thread_is_stopped(thread),
                                     &lwi);
@@ -1473,10 +1481,10 @@ ll_sai_unplug(struct ll_statahead_info *sai, struct ll_sa_entry *entry)
                        CDEBUG(D_READA, "Statahead for dir "DFID" hit "
                               "ratio too low: hit/miss "LPU64"/"LPU64
                               ", sent/replied "LPU64"/"LPU64", stopping "
-                              "statahead thread: pid %d\n",
+                              "statahead thread\n",
                               PFID(&lli->lli_fid), sai->sai_hit,
                               sai->sai_miss, sai->sai_sent,
-                              sai->sai_replied, current_pid());
+                              sai->sai_replied);
                        spin_lock(&lli->lli_sa_lock);
                        if (!thread_is_stopped(thread))
                                thread_set_flags(thread, SVC_STOPPING);
@@ -1553,12 +1561,6 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
                        return entry ? 1 : -EAGAIN;
                }
 
-               /* if statahead is busy in readdir, help it do post-work */
-               while (!ll_sa_entry_stated(entry) &&
-                      sai->sai_in_readpage &&
-                      !sa_received_empty(sai))
-                       ll_post_statahead(sai);
-
                if (!ll_sa_entry_stated(entry)) {
                        sai->sai_index_wait = entry->se_index;
                        lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(30), NULL,
@@ -1655,9 +1657,15 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
                GOTO(out, rc = -EAGAIN);
        }
 
-       CDEBUG(D_READA, "start statahead thread: [pid %d] [parent %.*s]\n",
-              current_pid(), parent->d_name.len, parent->d_name.name);
+       CDEBUG(D_READA, "start statahead thread: sai %p, parent %.*s\n",
+              sai, parent->d_name.len, parent->d_name.name);
 
+       /* The sai buffer already has one reference taken at allocation time,
+        * but as soon as we expose the sai by attaching it to the lli that
+        * default reference can be dropped by another thread calling
+        * ll_stop_statahead. We need to take a local reference to protect
+        * the sai buffer while we intend to access it. */
+       ll_sai_get(sai);
        lli->lli_sai = sai;
 
        plli = ll_i2info(parent->d_inode);
@@ -1670,6 +1678,9 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
                lli->lli_opendir_key = NULL;
                thread_set_flags(thread, SVC_STOPPED);
                thread_set_flags(&sai->sai_agl_thread, SVC_STOPPED);
+               /* Drop both our own local reference and the default
+                * reference from allocation time. */
+               ll_sai_put(sai);
                ll_sai_put(sai);
                LASSERT(lli->lli_sai == NULL);
                return -EAGAIN;
@@ -1678,6 +1689,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
        l_wait_event(thread->t_ctl_waitq,
                     thread_is_running(thread) || thread_is_stopped(thread),
                     &lwi);
+       ll_sai_put(sai);
 
        /*
         * We don't stat-ahead for the first dirent since we are already in
index e21e1c760a8ec690d0a873c36e63967e9911f043..951fdb1265b9ad0c982a0d8e575cdea987f3d3f0 100644 (file)
@@ -52,7 +52,7 @@ static struct inode *ll_alloc_inode(struct super_block *sb)
 {
        struct ll_inode_info *lli;
        ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_ALLOC_INODE, 1);
-       OBD_SLAB_ALLOC_PTR_GFP(lli, ll_inode_cachep, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(lli, ll_inode_cachep, GFP_NOFS);
        if (lli == NULL)
                return NULL;
 
@@ -72,7 +72,7 @@ static void ll_destroy_inode(struct inode *inode)
        call_rcu(&inode->i_rcu, ll_inode_destroy_callback);
 }
 
-int ll_init_inodecache(void)
+static int ll_init_inodecache(void)
 {
        ll_inode_cachep = kmem_cache_create("lustre_inode_cache",
                                               sizeof(struct ll_inode_info),
@@ -82,7 +82,7 @@ int ll_init_inodecache(void)
        return 0;
 }
 
-void ll_destroy_inodecache(void)
+static void ll_destroy_inodecache(void)
 {
        kmem_cache_destroy(ll_inode_cachep);
 }
@@ -103,9 +103,6 @@ MODULE_ALIAS_FS("lustre");
 
 void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg));
 
-int vvp_global_init(void);
-void vvp_global_fini(void);
-
 static int __init init_lustre_lite(void)
 {
        int i, rc, seed[2];
index 80d48b5ae24706655c0290ad01f59bb1591f3912..129d3023dcea817da79a0bcb8d6f673f89a1e974 100644 (file)
@@ -120,7 +120,7 @@ static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd)
        struct inode *inode = dentry->d_inode;
        struct ptlrpc_request *request = NULL;
        int rc;
-       char *symname;
+       char *symname = NULL;
 
        CDEBUG(D_VFSTRACE, "VFS Op\n");
        /* Limit the recursive symlink depth to 5 instead of default
index c4d1580b7be53530a646f054db571043c46ff23a..0f68c16abe30de49e2abb8a8c2d34fd0c009029e 100644 (file)
@@ -43,7 +43,7 @@
 
 #include <obd.h>
 #include <lustre_lite.h>
-
+#include "llite_internal.h"
 #include "vvp_internal.h"
 
 /*****************************************************************************
@@ -57,7 +57,7 @@
  * "llite_" (var. "ll_") prefix.
  */
 
-struct kmem_cache *vvp_thread_kmem;
+static struct kmem_cache *vvp_thread_kmem;
 static struct kmem_cache *vvp_session_kmem;
 static struct lu_kmem_descr vvp_caches[] = {
        {
@@ -80,7 +80,7 @@ static void *vvp_key_init(const struct lu_context *ctx,
 {
        struct vvp_thread_info *info;
 
-       OBD_SLAB_ALLOC_PTR_GFP(info, vvp_thread_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(info, vvp_thread_kmem, GFP_NOFS);
        if (info == NULL)
                info = ERR_PTR(-ENOMEM);
        return info;
@@ -98,7 +98,7 @@ static void *vvp_session_key_init(const struct lu_context *ctx,
 {
        struct vvp_session *session;
 
-       OBD_SLAB_ALLOC_PTR_GFP(session, vvp_session_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(session, vvp_session_kmem, GFP_NOFS);
        if (session == NULL)
                session = ERR_PTR(-ENOMEM);
        return session;
@@ -536,7 +536,7 @@ static int vvp_dump_pgcache_seq_open(struct inode *inode, struct file *filp)
        return result;
 }
 
-struct file_operations vvp_dump_pgcache_file_ops = {
+const struct file_operations vvp_dump_pgcache_file_ops = {
        .owner   = THIS_MODULE,
        .open    = vvp_dump_pgcache_seq_open,
        .read    = seq_read,
index c82bf17f55a6fb808e8c77d9882644c5d58ce3c3..3c9a03d99559f02b0903c34bf6fd2534f287010d 100644 (file)
@@ -57,6 +57,6 @@ struct lu_object *vvp_object_alloc(const struct lu_env *env,
 
 struct ccc_object *cl_inode2ccc(struct inode *inode);
 
-extern struct kmem_cache *vvp_thread_kmem;
+extern const struct file_operations vvp_dump_pgcache_file_ops;
 
 #endif /* VVP_INTERNAL_H */
index c7d70091246ea2a09c8377eadd00bcb92bd734f7..7dd2b4723c5fd6fdded98fadbcb63a68ce8c80fa 100644 (file)
@@ -80,7 +80,7 @@ static bool can_populate_pages(const struct lu_env *env, struct cl_io *io,
        case CIT_WRITE:
                /* don't need lock here to check lli_layout_gen as we have held
                 * extent lock and GROUP lock has to hold to swap layout */
-               if (lli->lli_layout_gen != cio->cui_layout_gen) {
+               if (ll_layout_version_get(lli) != cio->cui_layout_gen) {
                        io->ci_need_restart = 1;
                        /* this will return application a short read/write */
                        io->ci_continue = 0;
@@ -190,7 +190,7 @@ static void vvp_io_fault_fini(const struct lu_env *env,
        vvp_io_fini(env, ios);
 }
 
-enum cl_lock_mode vvp_mode_from_vma(struct vm_area_struct *vma)
+static enum cl_lock_mode vvp_mode_from_vma(struct vm_area_struct *vma)
 {
        /*
         * we only want to hold PW locks if the mmap() can generate
index 25973dedd9a25badbc760d158986aefeeed1f989..65b6db1b71b4ff37d76bb96026e39594d21661b0 100644 (file)
@@ -120,13 +120,28 @@ static int vvp_attr_set(const struct lu_env *env, struct cl_object *obj,
        return 0;
 }
 
-int vvp_conf_set(const struct lu_env *env, struct cl_object *obj,
-               const struct cl_object_conf *conf)
+static int vvp_conf_set(const struct lu_env *env, struct cl_object *obj,
+                       const struct cl_object_conf *conf)
 {
        struct ll_inode_info *lli = ll_i2info(conf->coc_inode);
 
        if (conf->coc_opc == OBJECT_CONF_INVALIDATE) {
-               lli->lli_layout_gen = LL_LAYOUT_GEN_NONE;
+               CDEBUG(D_VFSTRACE, DFID ": losing layout lock\n",
+                      PFID(&lli->lli_fid));
+
+               ll_layout_version_set(lli, LL_LAYOUT_GEN_NONE);
+
+               /* Clean up page mmap for this inode.
+                * The reason for us to do this is that if the page has
+                * already been installed into memory space, the process
+                * can access it without interacting with lustre, so this
+                * page may be stale due to layout change, and the process
+                * will never be notified.
+                * This operation is expensive but mmap processes have to pay
+                * a price themselves. */
+               unmap_mapping_range(conf->coc_inode->i_mapping,
+                                   0, OBD_OBJECT_EOF, 0);
+
                return 0;
        }
 
@@ -134,18 +149,18 @@ int vvp_conf_set(const struct lu_env *env, struct cl_object *obj,
                return 0;
 
        if (conf->u.coc_md != NULL && conf->u.coc_md->lsm != NULL) {
-               CDEBUG(D_VFSTRACE, "layout lock change: %u -> %u\n",
-                       lli->lli_layout_gen,
-                       conf->u.coc_md->lsm->lsm_layout_gen);
+               CDEBUG(D_VFSTRACE, DFID ": layout version change: %u -> %u\n",
+                      PFID(&lli->lli_fid), lli->lli_layout_gen,
+                      conf->u.coc_md->lsm->lsm_layout_gen);
 
                lli->lli_has_smd = lsm_has_objects(conf->u.coc_md->lsm);
-               lli->lli_layout_gen = conf->u.coc_md->lsm->lsm_layout_gen;
+               ll_layout_version_set(lli, conf->u.coc_md->lsm->lsm_layout_gen);
        } else {
-               CDEBUG(D_VFSTRACE, "layout lock destroyed: %u.\n",
-                       lli->lli_layout_gen);
+               CDEBUG(D_VFSTRACE, DFID ": layout nuked: %u.\n",
+                      PFID(&lli->lli_fid), lli->lli_layout_gen);
 
                lli->lli_has_smd = false;
-               lli->lli_layout_gen = LL_LAYOUT_GEN_EMPTY;
+               ll_layout_version_set(lli, LL_LAYOUT_GEN_EMPTY);
        }
        return 0;
 }
index b1ed4d9ea6beaf752c72136551f6c1ea1f067ad5..67a1de41c5b2f0bdb59dbe7dd329b5d3cf83016b 100644 (file)
@@ -124,6 +124,11 @@ int ll_setxattr_common(struct inode *inode, const char *name,
        if (rc)
                return rc;
 
+       if ((xattr_type == XATTR_ACL_ACCESS_T ||
+            xattr_type == XATTR_ACL_DEFAULT_T) &&
+           !inode_owner_or_capable(inode))
+               return -EPERM;
+
        /* b10667: ignore lustre special xattr for now */
        if ((xattr_type == XATTR_TRUSTED_T && strcmp(name, "trusted.lov") == 0) ||
            (xattr_type == XATTR_LUSTRE_T && strcmp(name, "lustre.lov") == 0))
index 4defa2fd83b35687697c6fac6213372da1cd4e94..4dd83fc036872973cc67e1b2a1e34eb8c46dd01f 100644 (file)
@@ -120,7 +120,7 @@ static int ll_xattr_cache_add(struct list_head *cache,
                return -EPROTO;
        }
 
-       OBD_SLAB_ALLOC_PTR_GFP(xattr, xattr_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(xattr, xattr_kmem, GFP_NOFS);
        if (xattr == NULL) {
                CDEBUG(D_CACHE, "failed to allocate xattr\n");
                return -ENOMEM;
@@ -232,7 +232,7 @@ static int ll_xattr_cache_list(struct list_head *cache,
  * \retval 0 @cache is not initialized
  * \retval 1 @cache is initialized
  */
-int ll_xattr_cache_valid(struct ll_inode_info *lli)
+static int ll_xattr_cache_valid(struct ll_inode_info *lli)
 {
        return !!(lli->lli_flags & LLIF_XATTR_CACHE);
 }
index 3ba0a0a1d945f9be02cf4c1a9238acb6cd8e1530..4edf8a31221c3f32725af99987dca6ae08e75e00 100644 (file)
@@ -280,7 +280,7 @@ static void lmv_set_timeouts(struct obd_device *obd)
 }
 
 static int lmv_init_ea_size(struct obd_export *exp, int easize,
-                           int def_easize, int cookiesize)
+                           int def_easize, int cookiesize, int def_cookiesize)
 {
        struct obd_device   *obd = exp->exp_obd;
        struct lmv_obd      *lmv = &obd->u.lmv;
@@ -300,6 +300,10 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize,
                lmv->max_cookiesize = cookiesize;
                change = 1;
        }
+       if (lmv->max_def_cookiesize < def_cookiesize) {
+               lmv->max_def_cookiesize = def_cookiesize;
+               change = 1;
+       }
        if (change == 0)
                return 0;
 
@@ -315,7 +319,7 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize,
                }
 
                rc = md_init_ea_size(lmv->tgts[i]->ltd_exp, easize, def_easize,
-                                    cookiesize);
+                                    cookiesize, def_cookiesize);
                if (rc) {
                        CERROR("%s: obd_init_ea_size() failed on MDT target %d:"
                               " rc = %d.\n", obd->obd_name, i, rc);
@@ -400,8 +404,8 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
        tgt->ltd_exp = mdc_exp;
        lmv->desc.ld_active_tgt_count++;
 
-       md_init_ea_size(tgt->ltd_exp, lmv->max_easize,
-                       lmv->max_def_easize, lmv->max_cookiesize);
+       md_init_ea_size(tgt->ltd_exp, lmv->max_easize, lmv->max_def_easize,
+                       lmv->max_cookiesize, lmv->max_def_cookiesize);
 
        CDEBUG(D_CONFIG, "Connected to %s(%s) successfully (%d)\n",
                mdc_obd->obd_name, mdc_obd->obd_uuid.uuid,
@@ -527,9 +531,8 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
                        spin_unlock(&lmv->lmv_lock);
                } else {
                        int easize = sizeof(struct lmv_stripe_md) +
-                                    lmv->desc.ld_tgt_count *
-                                    sizeof(struct lu_fid);
-                       lmv_init_ea_size(obd->obd_self_export, easize, 0, 0);
+                               lmv->desc.ld_tgt_count * sizeof(struct lu_fid);
+                       lmv_init_ea_size(obd->obd_self_export, easize, 0, 0, 0);
                }
        }
 
@@ -578,7 +581,7 @@ int lmv_check_connect(struct obd_device *obd)
        class_export_put(lmv->exp);
        lmv->connected = 1;
        easize = lmv_get_easize(lmv);
-       lmv_init_ea_size(obd->obd_self_export, easize, 0, 0);
+       lmv_init_ea_size(obd->obd_self_export, easize, 0, 0, 0);
        lmv_init_unlock(lmv);
        return 0;
 
@@ -2340,7 +2343,11 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp,
                                return 0;
                }
                return -EINVAL;
-       } else if (KEY_IS(KEY_MAX_EASIZE) || KEY_IS(KEY_CONN_DATA)) {
+       } else if (KEY_IS(KEY_MAX_EASIZE) ||
+                  KEY_IS(KEY_DEFAULT_EASIZE) ||
+                  KEY_IS(KEY_MAX_COOKIESIZE) ||
+                  KEY_IS(KEY_DEFAULT_COOKIESIZE) ||
+                  KEY_IS(KEY_CONN_DATA)) {
                rc = lmv_check_connect(obd);
                if (rc)
                        return rc;
index 5d5c3081c4670d3ce965651f34ff00a12bc424ad..ae73c82ce499ffc585d4afc81d5c36637bbb44e9 100644 (file)
@@ -200,19 +200,19 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file)
 LPROC_SEQ_FOPS_RO_TYPE(lmv, uuid);
 
 struct lprocfs_vars lprocfs_lmv_obd_vars[] = {
-       { "numobd",       &lmv_numobd_fops,       0, 0 },
-       { "placement",    &lmv_placement_fops,    0, 0 },
-       { "activeobd",    &lmv_activeobd_fops,    0, 0 },
-       { "uuid",         &lmv_uuid_fops,         0, 0 },
-       { "desc_uuid",    &lmv_desc_uuid_fops,    0, 0 },
-       { 0 }
+       { "numobd",       &lmv_numobd_fops,       NULL, 0 },
+       { "placement",    &lmv_placement_fops,    NULL, 0 },
+       { "activeobd",    &lmv_activeobd_fops,    NULL, 0 },
+       { "uuid",         &lmv_uuid_fops,         NULL, 0 },
+       { "desc_uuid",    &lmv_desc_uuid_fops,    NULL, 0 },
+       { NULL }
 };
 
 LPROC_SEQ_FOPS_RO_TYPE(lmv, numrefs);
 
 static struct lprocfs_vars lprocfs_lmv_module_vars[] = {
-       { "num_refs",      &lmv_numrefs_fops, 0, 0 },
-       { 0 }
+       { "num_refs",      &lmv_numrefs_fops, NULL, 0 },
+       { NULL }
 };
 
 struct file_operations lmv_proc_target_fops = {
index 9a5f26d5558d6bf6010051a8276b1625cda85c92..a908edb533d3c3e4e7fb2820f846b5bcfa719181 100644 (file)
@@ -1,5 +1,5 @@
 obj-$(CONFIG_LUSTRE_FS) += lov.o
-lov-y := lov_log.o lov_obd.o lov_pack.o lov_offset.o lov_merge.o \
+lov-y := lov_obd.o lov_pack.o lov_offset.o lov_merge.o \
         lov_request.o lov_ea.o lov_dev.o lov_object.o lov_page.o  \
         lov_lock.o lov_io.o lovsub_dev.o lovsub_object.o lovsub_page.o      \
         lovsub_lock.o lovsub_io.o lov_pool.o
index 1f33b04b0c38c06c02f9dae360ff5269666d63e4..53e5781ba1d9d7fbe1d1f4bbbb89511d19c6c1ce 100644 (file)
@@ -143,7 +143,7 @@ static void *lov_key_init(const struct lu_context *ctx,
 {
        struct lov_thread_info *info;
 
-       OBD_SLAB_ALLOC_PTR_GFP(info, lov_thread_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(info, lov_thread_kmem, GFP_NOFS);
        if (info != NULL)
                INIT_LIST_HEAD(&info->lti_closure.clc_list);
        else
@@ -170,7 +170,7 @@ static void *lov_session_key_init(const struct lu_context *ctx,
 {
        struct lov_session *info;
 
-       OBD_SLAB_ALLOC_PTR_GFP(info, lov_session_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(info, lov_session_kmem, GFP_NOFS);
        if (info == NULL)
                info = ERR_PTR(-ENOMEM);
        return info;
@@ -260,7 +260,7 @@ static int lov_req_init(const struct lu_env *env, struct cl_device *dev,
        struct lov_req *lr;
        int result;
 
-       OBD_SLAB_ALLOC_PTR_GFP(lr, lov_req_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(lr, lov_req_kmem, GFP_NOFS);
        if (lr != NULL) {
                cl_req_slice_add(req, &lr->lr_cl, dev, &lov_req_ops);
                result = 0;
index 6f356e025543739f0a39f68a061756b2be5e0ab5..a0c148e31f69c6044edf84b29824a77a102fceee 100644 (file)
@@ -44,7 +44,6 @@
 #include <linux/libcfs/libcfs.h>
 
 #include <obd_class.h>
-#include <obd_lov.h>
 #include <lustre/lustre_idl.h>
 
 #include "lov_internal.h"
@@ -101,7 +100,7 @@ struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size)
                return NULL;
 
        for (i = 0; i < stripe_count; i++) {
-               OBD_SLAB_ALLOC_PTR_GFP(loi, lov_oinfo_slab, __GFP_IO);
+               OBD_SLAB_ALLOC_PTR_GFP(loi, lov_oinfo_slab, GFP_NOFS);
                if (loi == NULL)
                        goto err;
                lsm->lsm_oinfo[i] = loi;
@@ -346,3 +345,14 @@ const struct lsm_operations lsm_v3_ops = {
        .lsm_lmm_verify  = lsm_lmm_verify_v3,
        .lsm_unpackmd      = lsm_unpackmd_v3,
 };
+
+void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm)
+{
+       CDEBUG(level, "lsm %p, objid "DOSTID", maxbytes "LPX64", magic 0x%08X,"
+              " stripe_size %u, stripe_count %u, refc: %d,"
+              " layout_gen %u, pool ["LOV_POOLNAMEF"]\n", lsm,
+              POSTID(&lsm->lsm_oi), lsm->lsm_maxbytes, lsm->lsm_magic,
+              lsm->lsm_stripe_size, lsm->lsm_stripe_count,
+              atomic_read(&lsm->lsm_refc), lsm->lsm_layout_gen,
+              lsm->lsm_pool_name);
+}
index 2b22a03c038ea2a2ebcde5a1d2883a9505e6a8ff..38508a5c827f5c43525d57e0c1bc92ea74c54034 100644 (file)
 #define LOV_INTERNAL_H
 
 #include <obd_class.h>
-#include <obd_lov.h>
 #include <lustre/lustre_user.h>
 
+/* lov_do_div64(a, b) returns a % b, and a = a / b.
+ * The 32-bit code is LOV-specific due to knowing about stripe limits in
+ * order to reduce the divisor to a 32-bit number.  If the divisor is
+ * already a 32-bit value the compiler handles this directly. */
+#if BITS_PER_LONG == 64
+# define lov_do_div64(n, base) ({                                      \
+       uint64_t __base = (base);                                       \
+       uint64_t __rem;                                                 \
+       __rem = ((uint64_t)(n)) % __base;                               \
+       (n) = ((uint64_t)(n)) / __base;                                 \
+       __rem;                                                          \
+})
+#elif BITS_PER_LONG == 32
+# define lov_do_div64(n, base) ({                                      \
+       uint64_t __rem;                                                 \
+       if ((sizeof(base) > 4) && (((base) & 0xffffffff00000000ULL) != 0)) {  \
+               int __remainder;                                              \
+               LASSERTF(!((base) & (LOV_MIN_STRIPE_SIZE - 1)), "64 bit lov " \
+                        "division %llu / %llu\n", (n), (uint64_t)(base));    \
+               __remainder = (n) & (LOV_MIN_STRIPE_SIZE - 1);          \
+               (n) >>= LOV_MIN_STRIPE_BITS;                            \
+               __rem = do_div(n, (base) >> LOV_MIN_STRIPE_BITS);       \
+               __rem <<= LOV_MIN_STRIPE_BITS;                          \
+               __rem += __remainder;                                   \
+       } else {                                                        \
+               __rem = do_div(n, base);                                \
+       }                                                               \
+       __rem;                                                          \
+})
+#endif
+
 struct lov_lock_handles {
        struct portals_handle   llh_handle;
        atomic_t            llh_refcount;
@@ -251,10 +281,6 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg,
                            __u32 *indexp, int *genp);
 int lov_del_target(struct obd_device *obd, __u32 index,
                   struct obd_uuid *uuidp, int gen);
-/* lov_log.c */
-int lov_llog_init(struct obd_device *obd, struct obd_llog_group *olg,
-                 struct obd_device *tgt, int *idx);
-int lov_llog_finish(struct obd_device *obd, int count);
 
 /* lov_pack.c */
 int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmm,
@@ -279,6 +305,7 @@ void lov_dump_lmm(int level, void *lmm);
 /* lov_ea.c */
 struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size);
 void lsm_free_plain(struct lov_stripe_md *lsm);
+void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm);
 
 int lovea_destroy_object(struct lov_obd *lov, struct lov_stripe_md *lsm,
                         struct obdo *oa, void *data);
index ed2726e523e8bae70e3dbd831064b813f2b51cb5..08ac3745f0dae3c57c2490ca0cf95f9ccb507f82 100644 (file)
@@ -144,7 +144,7 @@ static struct cl_lock *lov_sublock_alloc(const struct lu_env *env,
 
        LASSERT(idx < lck->lls_nr);
 
-       OBD_SLAB_ALLOC_PTR_GFP(link, lov_lock_link_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(link, lov_lock_link_kmem, GFP_NOFS);
        if (link != NULL) {
                struct lov_sublock_env *subenv;
                struct lov_lock_sub  *lls;
@@ -346,41 +346,7 @@ static int lov_lock_sub_init(const struct lu_env *env,
                }
        }
        LASSERT(nr == lck->lls_nr);
-       /*
-        * Then, create sub-locks. Once at least one sub-lock was created,
-        * top-lock can be reached by other threads.
-        */
-       for (i = 0; i < lck->lls_nr; ++i) {
-               struct cl_lock       *sublock;
-               struct lov_lock_link *link;
 
-               if (lck->lls_sub[i].sub_lock == NULL) {
-                       sublock = lov_sublock_alloc(env, io, lck, i, &link);
-                       if (IS_ERR(sublock)) {
-                               result = PTR_ERR(sublock);
-                               break;
-                       }
-                       cl_lock_get_trust(sublock);
-                       cl_lock_mutex_get(env, sublock);
-                       cl_lock_mutex_get(env, parent);
-                       /*
-                        * recheck under mutex that sub-lock wasn't created
-                        * concurrently, and that top-lock is still alive.
-                        */
-                       if (lck->lls_sub[i].sub_lock == NULL &&
-                           parent->cll_state < CLS_FREEING) {
-                               lov_sublock_adopt(env, lck, sublock, i, link);
-                               cl_lock_mutex_put(env, parent);
-                       } else {
-                               OBD_SLAB_FREE_PTR(link, lov_lock_link_kmem);
-                               cl_lock_mutex_put(env, parent);
-                               cl_lock_unhold(env, sublock,
-                                              "lov-parent", parent);
-                       }
-                       cl_lock_mutex_put(env, sublock);
-                       cl_lock_put(env, sublock);
-               }
-       }
        /*
         * Some sub-locks can be missing at this point. This is not a problem,
         * because enqueue will create them anyway. Main duty of this function
@@ -533,7 +499,7 @@ static int lov_lock_enqueue_one(const struct lu_env *env, struct lov_lock *lck,
 static int lov_sublock_fill(const struct lu_env *env, struct cl_lock *parent,
                            struct cl_io *io, struct lov_lock *lck, int idx)
 {
-       struct lov_lock_link *link;
+       struct lov_lock_link *link = NULL;
        struct cl_lock       *sublock;
        int                result;
 
@@ -1159,7 +1125,7 @@ int lov_lock_init_raid0(const struct lu_env *env, struct cl_object *obj,
        struct lov_lock *lck;
        int result;
 
-       OBD_SLAB_ALLOC_PTR_GFP(lck, lov_lock_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(lck, lov_lock_kmem, GFP_NOFS);
        if (lck != NULL) {
                cl_lock_slice_add(lock, &lck->lls_cl, obj, &lov_lock_ops);
                result = lov_lock_sub_init(env, lck, io);
@@ -1194,7 +1160,7 @@ int lov_lock_init_empty(const struct lu_env *env, struct cl_object *obj,
        struct lov_lock *lck;
        int result = -ENOMEM;
 
-       OBD_SLAB_ALLOC_PTR_GFP(lck, lov_lock_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(lck, lov_lock_kmem, GFP_NOFS);
        if (lck != NULL) {
                cl_lock_slice_add(lock, &lck->lls_cl, obj, &lov_empty_lock_ops);
                lck->lls_orig = lock->cll_descr;
diff --git a/drivers/staging/lustre/lustre/lov/lov_log.c b/drivers/staging/lustre/lustre/lov/lov_log.c
deleted file mode 100644 (file)
index 3eedd93..0000000
+++ /dev/null
@@ -1,272 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2003, 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.
- *
- * lustre/lov/lov_log.c
- *
- * Author: Phil Schwan <phil@clusterfs.com>
- * Author: Peter Braam <braam@clusterfs.com>
- * Author: Mike Shaver <shaver@clusterfs.com>
- */
-
-#define DEBUG_SUBSYSTEM S_LOV
-#include <linux/libcfs/libcfs.h>
-
-#include <obd_support.h>
-#include <lustre_lib.h>
-#include <lustre_net.h>
-#include <lustre/lustre_idl.h>
-#include <lustre_dlm.h>
-#include <lustre_mds.h>
-#include <obd_class.h>
-#include <obd_lov.h>
-#include <obd_ost.h>
-#include <lprocfs_status.h>
-#include <lustre_log.h>
-
-#include "lov_internal.h"
-
-/* Add log records for each OSC that this object is striped over, and return
- * cookies for each one.  We _would_ have nice abstraction here, except that
- * we need to keep cookies in stripe order, even if some are NULL, so that
- * the right cookies are passed back to the right OSTs at the client side.
- * Unset cookies should be all-zero (which will never occur naturally). */
-static int lov_llog_origin_add(const struct lu_env *env,
-                              struct llog_ctxt *ctxt,
-                              struct llog_rec_hdr *rec,
-                              struct lov_stripe_md *lsm,
-                              struct llog_cookie *logcookies, int numcookies)
-{
-       struct obd_device *obd = ctxt->loc_obd;
-       struct lov_obd *lov = &obd->u.lov;
-       int i, rc = 0, cookies = 0;
-
-       LASSERTF(logcookies && numcookies >= lsm->lsm_stripe_count,
-                "logcookies %p, numcookies %d lsm->lsm_stripe_count %d \n",
-                logcookies, numcookies, lsm->lsm_stripe_count);
-
-       for (i = 0; i < lsm->lsm_stripe_count; i++) {
-               struct lov_oinfo *loi = lsm->lsm_oinfo[i];
-               struct obd_device *child =
-                       lov->lov_tgts[loi->loi_ost_idx]->ltd_exp->exp_obd;
-               struct llog_ctxt *cctxt = llog_get_context(child, ctxt->loc_idx);
-
-               /* fill mds unlink/setattr log record */
-               switch (rec->lrh_type) {
-               case MDS_UNLINK_REC: {
-                       struct llog_unlink_rec *lur = (struct llog_unlink_rec *)rec;
-                       lur->lur_oid = ostid_id(&loi->loi_oi);
-                       lur->lur_oseq = (__u32)ostid_seq(&loi->loi_oi);
-                       break;
-               }
-               case MDS_SETATTR64_REC: {
-                       struct llog_setattr64_rec *lsr = (struct llog_setattr64_rec *)rec;
-                       lsr->lsr_oi = loi->loi_oi;
-                       break;
-               }
-               default:
-                       break;
-               }
-
-               /* inject error in llog_obd_add() below */
-               if (OBD_FAIL_CHECK(OBD_FAIL_MDS_FAIL_LOV_LOG_ADD)) {
-                       llog_ctxt_put(cctxt);
-                       cctxt = NULL;
-               }
-               rc = llog_obd_add(env, cctxt, rec, NULL, logcookies + cookies,
-                                 numcookies - cookies);
-               llog_ctxt_put(cctxt);
-               if (rc < 0) {
-                       CERROR("Can't add llog (rc = %d) for stripe %d\n",
-                              rc, cookies);
-                       memset(logcookies + cookies, 0,
-                              sizeof(struct llog_cookie));
-                       rc = 1; /* skip this cookie */
-               }
-               /* Note that rc is always 1 if llog_obd_add was successful */
-               cookies += rc;
-       }
-       return cookies;
-}
-
-static int lov_llog_origin_connect(struct llog_ctxt *ctxt,
-                                  struct llog_logid *logid,
-                                  struct llog_gen *gen,
-                                  struct obd_uuid *uuid)
-{
-       struct obd_device *obd = ctxt->loc_obd;
-       struct lov_obd *lov = &obd->u.lov;
-       int i, rc = 0, err = 0;
-
-       obd_getref(obd);
-       for (i = 0; i < lov->desc.ld_tgt_count; i++) {
-               struct obd_device *child;
-               struct llog_ctxt *cctxt;
-
-               if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_active)
-                       continue;
-               if (uuid && !obd_uuid_equals(uuid, &lov->lov_tgts[i]->ltd_uuid))
-                       continue;
-               CDEBUG(D_CONFIG, "connect %d/%d\n", i, lov->desc.ld_tgt_count);
-               child = lov->lov_tgts[i]->ltd_exp->exp_obd;
-               cctxt = llog_get_context(child, ctxt->loc_idx);
-               rc = llog_connect(cctxt, logid, gen, uuid);
-               llog_ctxt_put(cctxt);
-
-               if (rc) {
-                       CERROR("error osc_llog_connect tgt %d (%d)\n", i, rc);
-                       if (!err)
-                               err = rc;
-               }
-       }
-       obd_putref(obd);
-
-       return err;
-}
-
-/* the replicators commit callback */
-static int lov_llog_repl_cancel(const struct lu_env *env,
-                               struct llog_ctxt *ctxt,
-                               struct lov_stripe_md *lsm,
-                               int count, struct llog_cookie *cookies,
-                               int flags)
-{
-       struct lov_obd *lov;
-       struct obd_device *obd = ctxt->loc_obd;
-       int rc = 0, i;
-
-       LASSERT(lsm != NULL);
-       LASSERT(count == lsm->lsm_stripe_count);
-
-       lov = &obd->u.lov;
-       obd_getref(obd);
-       for (i = 0; i < count; i++, cookies++) {
-               struct lov_oinfo *loi = lsm->lsm_oinfo[i];
-               struct obd_device *child =
-                       lov->lov_tgts[loi->loi_ost_idx]->ltd_exp->exp_obd;
-               struct llog_ctxt *cctxt =
-                       llog_get_context(child, ctxt->loc_idx);
-               int err;
-
-               err = llog_cancel(env, cctxt, NULL, 1, cookies, flags);
-               llog_ctxt_put(cctxt);
-               if (err && lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
-                       CERROR("%s: objid "DOSTID" subobj "DOSTID
-                              " on OST idx %d: rc = %d\n",
-                              obd->obd_name, POSTID(&lsm->lsm_oi),
-                              POSTID(&loi->loi_oi), loi->loi_ost_idx, err);
-                       if (!rc)
-                               rc = err;
-               }
-       }
-       obd_putref(obd);
-       return rc;
-}
-
-static struct llog_operations lov_mds_ost_orig_logops = {
-       .lop_obd_add    = lov_llog_origin_add,
-       .lop_connect    = lov_llog_origin_connect,
-};
-
-static struct llog_operations lov_size_repl_logops = {
-       .lop_cancel     = lov_llog_repl_cancel,
-};
-
-int lov_llog_init(struct obd_device *obd, struct obd_llog_group *olg,
-                 struct obd_device *disk_obd, int *index)
-{
-       struct lov_obd *lov = &obd->u.lov;
-       struct obd_device *child;
-       int i, rc = 0;
-
-       LASSERT(olg == &obd->obd_olg);
-       rc = llog_setup(NULL, obd, olg, LLOG_MDS_OST_ORIG_CTXT, disk_obd,
-                       &lov_mds_ost_orig_logops);
-       if (rc)
-               return rc;
-
-       rc = llog_setup(NULL, obd, olg, LLOG_SIZE_REPL_CTXT, disk_obd,
-                       &lov_size_repl_logops);
-       if (rc)
-               GOTO(err_cleanup, rc);
-
-       obd_getref(obd);
-       /* count may not match lov->desc.ld_tgt_count during dynamic ost add */
-       for (i = 0; i < lov->desc.ld_tgt_count; i++) {
-               if (!lov->lov_tgts[i])
-                       continue;
-
-               if (index && i != *index)
-                       continue;
-
-               child = lov->lov_tgts[i]->ltd_obd;
-               rc = obd_llog_init(child, &child->obd_olg, disk_obd, &i);
-               if (rc)
-                       CERROR("error osc_llog_init idx %d osc '%s' tgt '%s' "
-                              "(rc=%d)\n", i, child->obd_name,
-                              disk_obd->obd_name, rc);
-               rc = 0;
-       }
-       obd_putref(obd);
-       GOTO(err_cleanup, rc);
-err_cleanup:
-       if (rc) {
-               struct llog_ctxt *ctxt =
-                       llog_get_context(obd, LLOG_SIZE_REPL_CTXT);
-               if (ctxt)
-                       llog_cleanup(NULL, ctxt);
-               ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
-               if (ctxt)
-                       llog_cleanup(NULL, ctxt);
-       }
-       return rc;
-}
-
-int lov_llog_finish(struct obd_device *obd, int count)
-{
-       struct llog_ctxt *ctxt;
-
-       /* cleanup our llogs only if the ctxts have been setup
-        * (client lov doesn't setup, mds lov does). */
-       ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
-       if (ctxt)
-               llog_cleanup(NULL, ctxt);
-
-       ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT);
-       if (ctxt)
-               llog_cleanup(NULL, ctxt);
-
-       /* lov->tgt llogs are cleaned during osc_cleanup. */
-       return 0;
-}
index 9defa55d9919e4cf87e93b8ddc7c29a795bb9fbc..da959e90137143163fd0f7df0276dde97702f30a 100644 (file)
@@ -39,8 +39,6 @@
 #include <linux/libcfs/libcfs.h>
 
 #include <obd_class.h>
-#include <obd_lov.h>
-
 #include "lov_internal.h"
 
 /** Merge the lock value block(&lvb) attributes and KMS from each of the
@@ -60,7 +58,7 @@ int lov_merge_lvb_kms(struct lov_stripe_md *lsm,
        int i;
        int rc = 0;
 
-       LASSERT(spin_is_locked(&lsm->lsm_lock));
+       assert_spin_locked(&lsm->lsm_lock);
        LASSERT(lsm->lsm_lock_owner == current_pid());
 
        CDEBUG(D_INODE, "MDT ID "DOSTID" initial value: s="LPU64" m="LPU64
@@ -147,7 +145,7 @@ int lov_adjust_kms(struct obd_export *exp, struct lov_stripe_md *lsm,
        int stripe = 0;
        __u64 kms;
 
-       LASSERT(spin_is_locked(&lsm->lsm_lock));
+       assert_spin_locked(&lsm->lsm_lock);
        LASSERT(lsm->lsm_lock_owner == current_pid());
 
        if (shrink) {
index 02509d0cb1066503172bdfc67ae046fc51993c2b..12e778c422557473e31b609589c0f613b1ce35e4 100644 (file)
 #include <lustre/lustre_idl.h>
 #include <lustre_dlm.h>
 #include <lustre_mds.h>
-#include <lustre_debug.h>
 #include <obd_class.h>
-#include <obd_lov.h>
 #include <obd_ost.h>
 #include <lprocfs_status.h>
 #include <lustre_param.h>
 #include <cl_object.h>
 #include <lclient.h> /* for cl_client_lru */
 #include <lustre/ll_fiemap.h>
-#include <lustre_log.h>
 #include <lustre_fid.h>
 
 #include "lov_internal.h"
@@ -726,8 +723,8 @@ void lov_fix_desc_stripe_size(__u64 *val)
                if (*val != 0)
                        LCONSOLE_INFO("Increasing default stripe size to "
                                      "minimum %u\n",
-                                     LOV_DEFAULT_STRIPE_SIZE);
-               *val = LOV_DEFAULT_STRIPE_SIZE;
+                                     LOV_DESC_STRIPE_SIZE_DEFAULT);
+               *val = LOV_DESC_STRIPE_SIZE_DEFAULT;
        } else if (*val & (LOV_MIN_STRIPE_SIZE - 1)) {
                *val &= ~(LOV_MIN_STRIPE_SIZE - 1);
                LCONSOLE_WARN("Changing default stripe size to "LPU64" (a "
@@ -753,9 +750,8 @@ void lov_fix_desc_pattern(__u32 *val)
 
 void lov_fix_desc_qos_maxage(__u32 *val)
 {
-       /* fix qos_maxage */
        if (*val == 0)
-               *val = QOS_DEFAULT_MAXAGE;
+               *val = LOV_DESC_QOS_MAXAGE_DEFAULT;
 }
 
 void lov_fix_desc(struct lov_desc *desc)
@@ -861,12 +857,10 @@ static int lov_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
                }
                break;
        }
-       case OBD_CLEANUP_EXPORTS:
-               rc = obd_llog_finish(obd, 0);
-               if (rc != 0)
-                       CERROR("failed to cleanup llogging subsystems\n");
+       default:
                break;
        }
+
        return rc;
 }
 
@@ -2254,11 +2248,12 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key,
        if (fm_end_offset == -EINVAL)
                GOTO(out, rc = -EINVAL);
 
+       if (fiemap_count_to_size(fiemap->fm_extent_count) > *vallen)
+               fiemap->fm_extent_count = fiemap_size_to_count(*vallen);
        if (fiemap->fm_extent_count == 0) {
                get_num_extents = 1;
                count_local = 0;
        }
-
        /* Check each stripe */
        for (cur_stripe = start_stripe, i = 0; i < stripe_count;
             i++, cur_stripe = (cur_stripe + 1) % lsm->lsm_stripe_count) {
@@ -2808,8 +2803,6 @@ struct obd_ops lov_obd_ops = {
        .o_get_info         = lov_get_info,
        .o_set_info_async      = lov_set_info_async,
        .o_extent_calc   = lov_extent_calc,
-       .o_llog_init       = lov_llog_init,
-       .o_llog_finish   = lov_llog_finish,
        .o_notify             = lov_notify,
        .o_pool_new         = lov_pool_new,
        .o_pool_rem         = lov_pool_remove,
index d6b2cb45b938fb01b7d91158adbe9f27adb29f84..992c80ab3d5380df5eb84ef93bc7b9b91c0e3c24 100644 (file)
@@ -42,7 +42,6 @@
 #define DEBUG_SUBSYSTEM S_LOV
 
 #include "lov_cl_internal.h"
-#include <lustre_debug.h>
 
 /** \addtogroup lov
  *  @{
@@ -885,7 +884,7 @@ struct lu_object *lov_object_alloc(const struct lu_env *env,
        struct lov_object *lov;
        struct lu_object  *obj;
 
-       OBD_SLAB_ALLOC_PTR_GFP(lov, lov_object_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(lov, lov_object_kmem, GFP_NOFS);
        if (lov != NULL) {
                obj = lov2lu(lov);
                lu_object_init(obj, NULL, dev);
index 04863a7c5e0bd127fac135eac97a5431295f736c..379568f8245cd81ab5ede771f3a2341ce4dc4693 100644 (file)
@@ -39,7 +39,6 @@
 #include <linux/libcfs/libcfs.h>
 
 #include <obd_class.h>
-#include <obd_lov.h>
 
 #include "lov_internal.h"
 
index 74200cf1b331b08faf24a8db6b399ab19ef1c99b..59ab7c30ffbfa1fca04e026b57e21dd9d1f1bcab 100644 (file)
@@ -44,7 +44,6 @@
 
 #include <lustre_net.h>
 #include <obd.h>
-#include <obd_lov.h>
 #include <obd_class.h>
 #include <obd_support.h>
 #include <lustre/lustre_user.h>
@@ -177,8 +176,9 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
                 * Anyway, this is pretty inaccurate since ld_tgt_count now
                 * represents max index and we should rely on the actual number
                 * of OSTs instead */
-               stripe_count = lov_mds_md_stripecnt(lov->lov_ocd.ocd_max_easize,
-                                                   lmm_magic);
+               stripe_count = lov_mds_md_max_stripe_count(
+                       lov->lov_ocd.ocd_max_easize, lmm_magic);
+
                if (stripe_count > lov->desc.ld_tgt_count)
                        stripe_count = lov->desc.ld_tgt_count;
        }
@@ -264,8 +264,8 @@ __u16 lov_get_stripecnt(struct lov_obd *lov, __u32 magic, __u16 stripe_count)
         * larger EA sizes */
        if (lov->lov_ocd.ocd_connect_flags & OBD_CONNECT_MAX_EASIZE &&
            lov->lov_ocd.ocd_max_easize)
-               max_stripes = lov_mds_md_stripecnt(lov->lov_ocd.ocd_max_easize,
-                                                  magic);
+               max_stripes = lov_mds_md_max_stripe_count(
+                       lov->lov_ocd.ocd_max_easize, magic);
 
        if (stripe_count > max_stripes)
                stripe_count = max_stripes;
index a5481d7eb5d609597e16fd0dded4b95b05b444b3..bd6490d0129cc7f5a56bba734f7d496e67ab4a30 100644 (file)
@@ -39,7 +39,6 @@
 #include <linux/libcfs/libcfs.h>
 
 #include <obd_class.h>
-#include <obd_lov.h>
 #include <lustre/lustre_idl.h>
 
 #include "lov_internal.h"
index 926c35a25ceb6e7faf0507d4e7ad7ae393882760..52fb6c162ad7dc6e18049d6133137e70943cc299 100644 (file)
@@ -146,7 +146,7 @@ static int lovsub_req_init(const struct lu_env *env, struct cl_device *dev,
        struct lovsub_req *lsr;
        int result;
 
-       OBD_SLAB_ALLOC_PTR_GFP(lsr, lovsub_req_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(lsr, lovsub_req_kmem, GFP_NOFS);
        if (lsr != NULL) {
                cl_req_slice_add(req, &lsr->lsrq_cl, dev, &lovsub_req_ops);
                result = 0;
index 80305aa61712350e2fe23023470785699f8dfdbf..62b696d25d81242fdafb7a6b7b4318a017ecd162 100644 (file)
@@ -453,7 +453,7 @@ int lovsub_lock_init(const struct lu_env *env, struct cl_object *obj,
        struct lovsub_lock *lsk;
        int result;
 
-       OBD_SLAB_ALLOC_PTR_GFP(lsk, lovsub_lock_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(lsk, lovsub_lock_kmem, GFP_NOFS);
        if (lsk != NULL) {
                INIT_LIST_HEAD(&lsk->lss_parents);
                cl_lock_slice_add(lock, &lsk->lss_cl, obj, &lovsub_lock_ops);
index 89760b3bf3f7aebb82793c5c7e3fce23a3d91e5f..57e3629fccee30fe8f57a1500fe33d86c3f774bb 100644 (file)
@@ -145,7 +145,7 @@ struct lu_object *lovsub_object_alloc(const struct lu_env *env,
        struct lovsub_object *los;
        struct lu_object     *obj;
 
-       OBD_SLAB_ALLOC_PTR_GFP(los, lovsub_object_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(los, lovsub_object_kmem, GFP_NOFS);
        if (los != NULL) {
                struct cl_object_header *hdr;
 
index 53022ec390f07be32f8bc2609f1a879bda50bf76..1a8cd98ad6d75c8d3bacae36ba9b4dfeb234680d 100644 (file)
@@ -442,9 +442,9 @@ static struct ptlrpc_request *mdc_intent_unlink_pack(struct obd_export *exp,
        mdc_unlink_pack(req, op_data);
 
        req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
-                            obddev->u.cli.cl_max_mds_easize);
+                            obddev->u.cli.cl_default_mds_easize);
        req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
-                            obddev->u.cli.cl_max_mds_cookiesize);
+                            obddev->u.cli.cl_default_mds_cookiesize);
        ptlrpc_request_set_replen(req);
        return req;
 }
@@ -462,6 +462,7 @@ static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp,
                                               OBD_MD_FLRMTPERM : OBD_MD_FLACL);
        struct ldlm_intent    *lit;
        int                 rc;
+       int                 easize;
 
        req = ptlrpc_request_alloc(class_exp2cliimp(exp),
                                   &RQF_LDLM_INTENT_GETATTR);
@@ -482,12 +483,15 @@ static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp,
        lit = req_capsule_client_get(&req->rq_pill, &RMF_LDLM_INTENT);
        lit->opc = (__u64)it->it_op;
 
+       if (obddev->u.cli.cl_default_mds_easize > 0)
+               easize = obddev->u.cli.cl_default_mds_easize;
+       else
+               easize = obddev->u.cli.cl_max_mds_easize;
+
        /* pack the intended request */
-       mdc_getattr_pack(req, valid, it->it_flags, op_data,
-                        obddev->u.cli.cl_max_mds_easize);
+       mdc_getattr_pack(req, valid, it->it_flags, op_data, easize);
 
-       req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
-                            obddev->u.cli.cl_max_mds_easize);
+       req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER, easize);
        if (client_is_remote(exp))
                req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
                                     sizeof(struct mdt_remote_perm));
@@ -528,7 +532,7 @@ static struct ptlrpc_request *mdc_intent_layout_pack(struct obd_export *exp,
        layout->li_opc = LAYOUT_INTENT_ACCESS;
 
        req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER,
-                       obd->u.cli.cl_max_mds_easize);
+                            obd->u.cli.cl_default_mds_easize);
        ptlrpc_request_set_replen(req);
        return req;
 }
@@ -893,7 +897,10 @@ resend:
        mdc_put_rpc_lock(obddev->u.cli.cl_rpc_lock, it);
 
        if (rc < 0) {
-               CERROR("ldlm_cli_enqueue: %d\n", rc);
+               CDEBUG_LIMIT((rc == -EACCES || rc == -EIDRM) ? D_INFO : D_ERROR,
+                            "%s: ldlm_cli_enqueue failed: rc = %d\n",
+                            obddev->obd_name, rc);
+
                mdc_clear_replay_flag(req, rc);
                ptlrpc_req_finished(req);
                return rc;
index d79aa1641feffa4161f6edc533aa300d18a5fb93..08e80940ee4dc8cac3e165579463468e49b0d6ff 100644 (file)
@@ -199,7 +199,8 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data,
        *request = req;
        if (rc && req->rq_commit_cb) {
                /* Put an extra reference on \var mod on error case. */
-               obd_mod_put(*mod);
+               if (mod != NULL && *mod != NULL)
+                       obd_mod_put(*mod);
                req->rq_commit_cb(req);
        }
        return rc;
@@ -357,9 +358,9 @@ int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data,
        mdc_unlink_pack(req, op_data);
 
        req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
-                            obd->u.cli.cl_max_mds_easize);
+                            obd->u.cli.cl_default_mds_easize);
        req_capsule_set_size(&req->rq_pill, &RMF_LOGCOOKIES, RCL_SERVER,
-                            obd->u.cli.cl_max_mds_cookiesize);
+                            obd->u.cli.cl_default_mds_cookiesize);
        ptlrpc_request_set_replen(req);
 
        *request = req;
@@ -470,9 +471,9 @@ int mdc_rename(struct obd_export *exp, struct md_op_data *op_data,
        mdc_rename_pack(req, op_data, old, oldlen, new, newlen);
 
        req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
-                            obd->u.cli.cl_max_mds_easize);
+                            obd->u.cli.cl_default_mds_easize);
        req_capsule_set_size(&req->rq_pill, &RMF_LOGCOOKIES, RCL_SERVER,
-                            obd->u.cli.cl_max_mds_cookiesize);
+                            obd->u.cli.cl_default_mds_cookiesize);
        ptlrpc_request_set_replen(req);
 
        rc = mdc_reint(req, obd->u.cli.cl_rpc_lock, LUSTRE_IMP_FULL);
index bde9f93c149bf054ca7b3a9b4643c559f8950f2c..fca43cf1d671059811b1fc31ea64d4d732d9cac2 100644 (file)
@@ -903,9 +903,9 @@ int mdc_close(struct obd_export *exp, struct md_op_data *op_data,
        mdc_close_pack(req, op_data);
 
        req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
-                            obd->u.cli.cl_max_mds_easize);
+                            obd->u.cli.cl_default_mds_easize);
        req_capsule_set_size(&req->rq_pill, &RMF_LOGCOOKIES, RCL_SERVER,
-                            obd->u.cli.cl_max_mds_cookiesize);
+                            obd->u.cli.cl_default_mds_cookiesize);
 
        ptlrpc_request_set_replen(req);
 
@@ -2153,12 +2153,40 @@ int mdc_get_info(const struct lu_env *env, struct obd_export *exp,
 
                if (*vallen != sizeof(int))
                        return -EINVAL;
-               mdsize = *(int*)val;
+               mdsize = *(int *)val;
                if (mdsize > exp->exp_obd->u.cli.cl_max_mds_easize)
                        exp->exp_obd->u.cli.cl_max_mds_easize = mdsize;
                max_easize = val;
                *max_easize = exp->exp_obd->u.cli.cl_max_mds_easize;
                return 0;
+       } else if (KEY_IS(KEY_DEFAULT_EASIZE)) {
+               int *default_easize;
+
+               if (*vallen != sizeof(int))
+                       return -EINVAL;
+               default_easize = val;
+               *default_easize = exp->exp_obd->u.cli.cl_default_mds_easize;
+               return 0;
+       } else if (KEY_IS(KEY_MAX_COOKIESIZE)) {
+               int mdsize, *max_cookiesize;
+
+               if (*vallen != sizeof(int))
+                       return -EINVAL;
+               mdsize = *(int *)val;
+               if (mdsize > exp->exp_obd->u.cli.cl_max_mds_cookiesize)
+                       exp->exp_obd->u.cli.cl_max_mds_cookiesize = mdsize;
+               max_cookiesize = val;
+               *max_cookiesize = exp->exp_obd->u.cli.cl_max_mds_cookiesize;
+               return 0;
+       } else if (KEY_IS(KEY_DEFAULT_COOKIESIZE)) {
+               int *default_cookiesize;
+
+               if (*vallen != sizeof(int))
+                       return -EINVAL;
+               default_cookiesize = val;
+               *default_cookiesize =
+                       exp->exp_obd->u.cli.cl_default_mds_cookiesize;
+               return 0;
        } else if (KEY_IS(KEY_CONN_DATA)) {
                struct obd_import *imp = class_exp2cliimp(exp);
                struct obd_connect_data *data = val;
@@ -2439,11 +2467,15 @@ err_rpc_lock:
 }
 
 /* Initialize the default and maximum LOV EA and cookie sizes.  This allows
- * us to make MDS RPCs with large enough reply buffers to hold the
- * maximum-sized (= maximum striped) EA and cookie without having to
- * calculate this (via a call into the LOV + OSCs) each time we make an RPC. */
+ * us to make MDS RPCs with large enough reply buffers to hold a default
+ * sized EA and cookie without having to calculate this (via a call into the
+ * LOV + OSCs) each time we make an RPC.  The maximum size is also tracked
+ * but not used to avoid wastefully vmalloc()'ing large reply buffers when
+ * a large number of stripes is possible.  If a larger reply buffer is
+ * required it will be reallocated in the ptlrpc layer due to overflow.
+ */
 static int mdc_init_ea_size(struct obd_export *exp, int easize,
-                    int def_easize, int cookiesize)
+                           int def_easize, int cookiesize, int def_cookiesize)
 {
        struct obd_device *obd = exp->exp_obd;
        struct client_obd *cli = &obd->u.cli;
@@ -2457,6 +2489,9 @@ static int mdc_init_ea_size(struct obd_export *exp, int easize,
        if (cli->cl_max_mds_cookiesize < cookiesize)
                cli->cl_max_mds_cookiesize = cookiesize;
 
+       if (cli->cl_default_mds_cookiesize < def_cookiesize)
+               cli->cl_default_mds_cookiesize = def_cookiesize;
+
        return 0;
 }
 
index de9fb1433eddf7ea7d02e3d33256dd45f2cf18f5..a806aeffe026188962db81911f4ee39d442273a4 100644 (file)
@@ -672,8 +672,8 @@ static int mgc_fs_setup(struct obd_device *obd, struct super_block *sb)
        if (env == NULL)
                return -ENOMEM;
 
-       /* The mgc fs exclusion sem. Only one fs can be setup at a time. */
-       down(&cli->cl_mgc_sem);
+       /* The mgc fs exclusion mutex. Only one fs can be setup at a time. */
+       mutex_lock(&cli->cl_mgc_mutex);
 
        cfs_cleanup_group_info();
 
@@ -727,7 +727,7 @@ out_los:
        if (rc < 0) {
                local_oid_storage_fini(env, cli->cl_mgc_los);
                cli->cl_mgc_los = NULL;
-               up(&cli->cl_mgc_sem);
+               mutex_unlock(&cli->cl_mgc_mutex);
        }
 out_env:
        lu_env_fini(env);
@@ -759,7 +759,7 @@ static int mgc_fs_cleanup(struct obd_device *obd)
 
 unlock:
        class_decref(obd, "mgc_fs", obd);
-       up(&cli->cl_mgc_sem);
+       mutex_unlock(&cli->cl_mgc_mutex);
 
        return 0;
 }
index d795cef3f16452658eb6408644f1952b0010149b..df77c4fc0eacdd2528b1542ce01931f362bedc83 100644 (file)
@@ -139,7 +139,7 @@ static void cl_lock_trace0(int level, const struct lu_env *env,
               func, line);
 }
 #define cl_lock_trace(level, env, prefix, lock)                         \
-       cl_lock_trace0(level, env, prefix, lock, __FUNCTION__, __LINE__)
+       cl_lock_trace0(level, env, prefix, lock, __func__, __LINE__)
 
 #define RETIP ((unsigned long)__builtin_return_address(0))
 
@@ -360,7 +360,7 @@ static struct cl_lock *cl_lock_alloc(const struct lu_env *env,
        struct cl_lock    *lock;
        struct lu_object_header *head;
 
-       OBD_SLAB_ALLOC_PTR_GFP(lock, cl_lock_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(lock, cl_lock_kmem, GFP_NOFS);
        if (lock != NULL) {
                atomic_set(&lock->cll_ref, 1);
                lock->cll_descr = *descr;
@@ -478,7 +478,7 @@ static struct cl_lock *cl_lock_lookup(const struct lu_env *env,
        struct cl_object_header *head;
 
        head = cl_object_header(obj);
-       LINVRNT(spin_is_locked(&head->coh_lock_guard));
+       assert_spin_locked(&head->coh_lock_guard);
        CS_LOCK_INC(obj, lookup);
        list_for_each_entry(lock, &head->coh_locks, cll_linkage) {
                int matched;
@@ -533,6 +533,7 @@ static struct cl_lock *cl_lock_find(const struct lu_env *env,
                        spin_lock(&head->coh_lock_guard);
                        ghost = cl_lock_lookup(env, obj, io, need);
                        if (ghost == NULL) {
+                               cl_lock_get_trust(lock);
                                list_add_tail(&lock->cll_linkage,
                                                  &head->coh_locks);
                                spin_unlock(&head->coh_lock_guard);
@@ -791,15 +792,22 @@ static void cl_lock_delete0(const struct lu_env *env, struct cl_lock *lock)
        LINVRNT(cl_lock_invariant(env, lock));
 
        if (lock->cll_state < CLS_FREEING) {
+               bool in_cache;
+
                LASSERT(lock->cll_state != CLS_INTRANSIT);
                cl_lock_state_set(env, lock, CLS_FREEING);
 
                head = cl_object_header(lock->cll_descr.cld_obj);
 
                spin_lock(&head->coh_lock_guard);
-               list_del_init(&lock->cll_linkage);
+               in_cache = !list_empty(&lock->cll_linkage);
+               if (in_cache)
+                       list_del_init(&lock->cll_linkage);
                spin_unlock(&head->coh_lock_guard);
 
+               if (in_cache) /* coh_locks cache holds a refcount. */
+                       cl_lock_put(env, lock);
+
                /*
                 * From now on, no new references to this lock can be acquired
                 * by cl_lock_lookup().
index 0fc256f59e92ae7303bb5ce64f8751cc80dc70fd..41cbc95b916e2d6e1806692cbd8edb1ecf234d59 100644 (file)
@@ -220,7 +220,7 @@ int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj,
        struct lu_object_header *top;
        int result;
 
-       LASSERT(spin_is_locked(cl_object_attr_guard(obj)));
+       assert_spin_locked(cl_object_attr_guard(obj));
 
        top = obj->co_lu.lo_header;
        result = 0;
@@ -251,7 +251,7 @@ int cl_object_attr_set(const struct lu_env *env, struct cl_object *obj,
        struct lu_object_header *top;
        int result;
 
-       LASSERT(spin_is_locked(cl_object_attr_guard(obj)));
+       assert_spin_locked(cl_object_attr_guard(obj));
 
        top = obj->co_lu.lo_header;
        result = 0;
@@ -684,7 +684,7 @@ static struct lu_env *cl_env_new(__u32 ctx_tags, __u32 ses_tags, void *debug)
        struct lu_env *env;
        struct cl_env *cle;
 
-       OBD_SLAB_ALLOC_PTR_GFP(cle, cl_env_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(cle, cl_env_kmem, GFP_NOFS);
        if (cle != NULL) {
                int rc;
 
index 2a5ce376e577747a6f820163a1adbcefdcb1be08..1b616e4fe140b49ca1e8bb800efce30f0a8709da 100644 (file)
@@ -130,7 +130,7 @@ struct cl_page *cl_page_lookup(struct cl_object_header *hdr, pgoff_t index)
 {
        struct cl_page *page;
 
-       LASSERT(spin_is_locked(&hdr->coh_page_guard));
+       assert_spin_locked(&hdr->coh_page_guard);
 
        page = radix_tree_lookup(&hdr->coh_tree, index);
        if (page != NULL)
@@ -292,7 +292,7 @@ static struct cl_page *cl_page_alloc(const struct lu_env *env,
        struct lu_object_header *head;
 
        OBD_ALLOC_GFP(page, cl_object_header(o)->coh_page_bufsize,
-                       __GFP_IO);
+                       GFP_NOFS);
        if (page != NULL) {
                int result = 0;
                atomic_set(&page->cp_ref, 1);
index 15f71bbb7276af56c11fada156ff914eaee8357e..a4e7e754177f628006cfb7874899b08e1a8cca03 100644 (file)
@@ -56,18 +56,6 @@ void dump_lniobuf(struct niobuf_local *nb)
 }
 EXPORT_SYMBOL(dump_lniobuf);
 
-void dump_lsm(int level, struct lov_stripe_md *lsm)
-{
-       CDEBUG(level, "lsm %p, objid "DOSTID", maxbytes "LPX64", magic 0x%08X,"
-              " stripe_size %u, stripe_count %u, refc: %d,"
-              " layout_gen %u, pool ["LOV_POOLNAMEF"]\n", lsm,
-              POSTID(&lsm->lsm_oi), lsm->lsm_maxbytes, lsm->lsm_magic,
-              lsm->lsm_stripe_size, lsm->lsm_stripe_count,
-              atomic_read(&lsm->lsm_refc), lsm->lsm_layout_gen,
-              lsm->lsm_pool_name);
-}
-EXPORT_SYMBOL(dump_lsm);
-
 #define LPDS sizeof(__u64)
 int block_debug_setup(void *addr, int len, __u64 off, __u64 id)
 {
index f2bdea33041da230bd5430834b055fc6bc04a4e1..3210ad8184b9e636374f9b6b50e85ff26335453c 100644 (file)
@@ -72,7 +72,7 @@ static struct obd_device *obd_device_alloc(void)
 {
        struct obd_device *obd;
 
-       OBD_SLAB_ALLOC_PTR_GFP(obd, obd_device_cachep, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(obd, obd_device_cachep, GFP_NOFS);
        if (obd != NULL) {
                obd->obd_magic = OBD_DEVICE_MAGIC;
        }
@@ -615,13 +615,13 @@ int class_notify_sptlrpc_conf(const char *fsname, int namelen)
                if (strncmp(obd->obd_name, fsname, namelen))
                        continue;
 
-               class_incref(obd, __FUNCTION__, obd);
+               class_incref(obd, __func__, obd);
                read_unlock(&obd_dev_lock);
                rc2 = obd_set_info_async(NULL, obd->obd_self_export,
                                         sizeof(KEY_SPTLRPC_CONF),
                                         KEY_SPTLRPC_CONF, 0, NULL, NULL);
                rc = rc ? rc : rc2;
-               class_decref(obd, __FUNCTION__, obd);
+               class_decref(obd, __func__, obd);
                read_lock(&obd_dev_lock);
        }
        read_unlock(&obd_dev_lock);
index ba20776ebfa142ec36ee358ba67287d782ecdf57..0334882070ef33f558ef0f88c15b5de22eeca13f 100644 (file)
@@ -122,6 +122,8 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg)
                OBD_FREE_LARGE(*buf, hdr.ioc_len);
                return err;
        }
+       if (hdr.ioc_len != data->ioc_len)
+               return -EINVAL;
 
        if (obd_ioctl_is_invalid(data)) {
                CERROR("ioctl not correctly formatted\n");
@@ -244,7 +246,7 @@ static int obd_proc_health_seq_show(struct seq_file *m, void *v)
                if (obd->obd_stopping)
                        continue;
 
-               class_incref(obd, __FUNCTION__, current);
+               class_incref(obd, __func__, current);
                read_unlock(&obd_dev_lock);
 
                if (obd_health_check(NULL, obd)) {
@@ -252,7 +254,7 @@ static int obd_proc_health_seq_show(struct seq_file *m, void *v)
                                      obd->obd_name);
                        rc++;
                }
-               class_decref(obd, __FUNCTION__, current);
+               class_decref(obd, __func__, current);
                read_lock(&obd_dev_lock);
        }
        read_unlock(&obd_dev_lock);
@@ -277,8 +279,15 @@ static ssize_t obd_proc_jobid_var_seq_write(struct file *file, const char *buffe
                return -EINVAL;
 
        memset(obd_jobid_var, 0, JOBSTATS_JOBID_VAR_MAX_LEN + 1);
+
+       /* This might leave the var invalid on error, which is probably fine.*/
+       if (copy_from_user(obd_jobid_var, buffer, count))
+               return -EFAULT;
+
        /* Trim the trailing '\n' if any */
-       memcpy(obd_jobid_var, buffer, count - (buffer[count - 1] == '\n'));
+       if (obd_jobid_var[count - 1] == '\n')
+               obd_jobid_var[count - 1] = 0;
+
        return count;
 }
 LPROC_SEQ_FOPS(obd_proc_jobid_var);
index 71817af75396faf1dd26eaf7067710545b4ad7fd..2c6d81eb5c6541909ceb06a19556848e7f3053e7 100644 (file)
@@ -226,34 +226,7 @@ int llog_sync(struct llog_ctxt *ctxt, struct obd_export *exp, int flags)
 }
 EXPORT_SYMBOL(llog_sync);
 
-int llog_obd_add(const struct lu_env *env, struct llog_ctxt *ctxt,
-                struct llog_rec_hdr *rec, struct lov_stripe_md *lsm,
-                struct llog_cookie *logcookies, int numcookies)
-{
-       int raised, rc;
-
-       if (!ctxt) {
-               CERROR("No ctxt\n");
-               return -ENODEV;
-       }
-
-       if (ctxt->loc_flags & LLOG_CTXT_FLAG_UNINITIALIZED)
-               return -ENXIO;
-
-       CTXT_CHECK_OP(ctxt, obd_add, -EOPNOTSUPP);
-       raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE);
-       if (!raised)
-               cfs_cap_raise(CFS_CAP_SYS_RESOURCE);
-       rc = CTXTP(ctxt, obd_add)(env, ctxt, rec, lsm, logcookies,
-                                 numcookies);
-       if (!raised)
-               cfs_cap_lower(CFS_CAP_SYS_RESOURCE);
-       return rc;
-}
-EXPORT_SYMBOL(llog_obd_add);
-
 int llog_cancel(const struct lu_env *env, struct llog_ctxt *ctxt,
-               struct lov_stripe_md *lsm, int count,
                struct llog_cookie *cookies, int flags)
 {
        int rc;
@@ -264,7 +237,7 @@ int llog_cancel(const struct lu_env *env, struct llog_ctxt *ctxt,
        }
 
        CTXT_CHECK_OP(ctxt, cancel, -EOPNOTSUPP);
-       rc = CTXTP(ctxt, cancel)(env, ctxt, lsm, count, cookies, flags);
+       rc = CTXTP(ctxt, cancel)(env, ctxt, cookies, flags);
        return rc;
 }
 EXPORT_SYMBOL(llog_cancel);
index 6f8ba54e9667a3558690cdfabbf17b1861c018eb..419a32361359d16f0f0c437fc4bf069d34ec1c00 100644 (file)
@@ -187,7 +187,7 @@ int lustre_start_simple(char *obdname, char *type, char *uuid,
        int rc;
        CDEBUG(D_MOUNT, "Starting obd %s (typ=%s)\n", obdname, type);
 
-       rc = do_lcfg(obdname, 0, LCFG_ATTACH, type, uuid, 0, 0);
+       rc = do_lcfg(obdname, 0, LCFG_ATTACH, type, uuid, NULL, NULL);
        if (rc) {
                CERROR("%s attach error %d\n", obdname, rc);
                return rc;
@@ -195,7 +195,7 @@ int lustre_start_simple(char *obdname, char *type, char *uuid,
        rc = do_lcfg(obdname, 0, LCFG_SETUP, s1, s2, s3, s4);
        if (rc) {
                CERROR("%s setup error %d\n", obdname, rc);
-               do_lcfg(obdname, 0, LCFG_DETACH, 0, 0, 0, 0);
+               do_lcfg(obdname, 0, LCFG_DETACH, NULL, NULL, NULL, NULL);
        }
        return rc;
 }
@@ -337,7 +337,8 @@ int lustre_start_mgc(struct super_block *sb)
                        lnet_process_id_t id;
                        while ((rc = LNetGetId(i++, &id)) != -ENOENT) {
                                rc = do_lcfg(mgcname, id.nid,
-                                            LCFG_ADD_UUID, niduuid, 0,0,0);
+                                            LCFG_ADD_UUID, niduuid,
+                                            NULL, NULL, NULL);
                        }
                } else {
                        /* Use mgsnode= nids */
@@ -351,7 +352,8 @@ int lustre_start_mgc(struct super_block *sb)
                        }
                        while (class_parse_nid(ptr, &nid, &ptr) == 0) {
                                rc = do_lcfg(mgcname, nid,
-                                            LCFG_ADD_UUID, niduuid, 0,0,0);
+                                            LCFG_ADD_UUID, niduuid,
+                                            NULL, NULL, NULL);
                                i++;
                        }
                }
@@ -360,7 +362,7 @@ int lustre_start_mgc(struct super_block *sb)
                ptr = lsi->lsi_lmd->lmd_dev;
                while (class_parse_nid(ptr, &nid, &ptr) == 0) {
                        rc = do_lcfg(mgcname, nid,
-                                    LCFG_ADD_UUID, niduuid, 0,0,0);
+                                    LCFG_ADD_UUID, niduuid, NULL, NULL, NULL);
                        i++;
                        /* Stop at the first failover nid */
                        if (*ptr == ':')
@@ -396,13 +398,13 @@ int lustre_start_mgc(struct super_block *sb)
                while (class_parse_nid_quiet(ptr, &nid, &ptr) == 0) {
                        j++;
                        rc = do_lcfg(mgcname, nid,
-                                    LCFG_ADD_UUID, niduuid, 0,0,0);
+                                    LCFG_ADD_UUID, niduuid, NULL, NULL, NULL);
                        if (*ptr == ':')
                                break;
                }
                if (j > 0) {
                        rc = do_lcfg(mgcname, 0, LCFG_ADD_CONN,
-                                    niduuid, 0, 0, 0);
+                                    niduuid, NULL, NULL, NULL);
                        i++;
                } else {
                        /* at ":/fsname" */
@@ -532,7 +534,7 @@ static int lustre_stop_mgc(struct super_block *sb)
        for (i = 0; i < lsi->lsi_lmd->lmd_mgs_failnodes; i++) {
                sprintf(ptr, "_%x", i);
                rc = do_lcfg(LUSTRE_MGC_OBDNAME, 0, LCFG_DEL_UUID,
-                            niduuid, 0, 0, 0);
+                            niduuid, NULL, NULL, NULL);
                if (rc)
                        CERROR("del MDC UUID %s failed: rc = %d\n",
                               niduuid, rc);
index 754aa8e5566526f8edbe462a67b9a091ded5f7e8..cdc46719bbd47aabcb81beee5097ed60e39ca986 100644 (file)
@@ -47,7 +47,6 @@
 #include <lustre_fid.h>
 #include <lustre_acl.h>
 #include <lustre_net.h>
-#include <obd_lov.h>
 
 #include "echo_internal.h"
 
@@ -428,7 +427,7 @@ static int echo_lock_init(const struct lu_env *env,
 {
        struct echo_lock *el;
 
-       OBD_SLAB_ALLOC_PTR_GFP(el, echo_lock_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(el, echo_lock_kmem, GFP_NOFS);
        if (el != NULL) {
                cl_lock_slice_add(lock, &el->el_cl, obj, &echo_lock_ops);
                el->el_object = cl2echo_obj(obj);
@@ -599,7 +598,7 @@ static struct lu_object *echo_object_alloc(const struct lu_env *env,
 
        /* we're the top dev. */
        LASSERT(hdr == NULL);
-       OBD_SLAB_ALLOC_PTR_GFP(eco, echo_object_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(eco, echo_object_kmem, GFP_NOFS);
        if (eco != NULL) {
                struct cl_object_header *hdr = &eco->eo_hdr;
 
@@ -663,7 +662,7 @@ static void *echo_thread_key_init(const struct lu_context *ctx,
 {
        struct echo_thread_info *info;
 
-       OBD_SLAB_ALLOC_PTR_GFP(info, echo_thread_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(info, echo_thread_kmem, GFP_NOFS);
        if (info == NULL)
                info = ERR_PTR(-ENOMEM);
        return info;
@@ -693,7 +692,7 @@ static void *echo_session_key_init(const struct lu_context *ctx,
 {
        struct echo_session_info *session;
 
-       OBD_SLAB_ALLOC_PTR_GFP(session, echo_session_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(session, echo_session_kmem, GFP_NOFS);
        if (session == NULL)
                session = ERR_PTR(-ENOMEM);
        return session;
@@ -2432,7 +2431,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
        int                  i;
        int                  rc;
        int                  verify;
-       int                  gfp_mask;
+       gfp_t                gfp_mask;
        int                  brw_flags = 0;
 
        verify = (ostid_id(&oa->o_oi) != ECHO_PERSISTENT_OBJID &&
index 0b59fc16c50cd920e889266518dadb1468c003d6..358e32cd05d27ae3794401ba32be7510d06fa424 100644 (file)
@@ -174,15 +174,25 @@ static int osc_cached_mb_seq_show(struct seq_file *m, void *v)
 }
 
 /* shrink the number of caching pages to a specific number */
-static ssize_t osc_cached_mb_seq_write(struct file *file, const char *buffer,
-                                  size_t count, loff_t *off)
+static ssize_t osc_cached_mb_seq_write(struct file *file,
+                                      const char __user *buffer,
+                                      size_t count, loff_t *off)
 {
        struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
        struct client_obd *cli = &dev->u.cli;
        int pages_number, mult, rc;
+       char kernbuf[128];
+
+       if (count >= sizeof(kernbuf))
+               return -EINVAL;
+
+       if (copy_from_user(kernbuf, buffer, count))
+               return -EFAULT;
+       kernbuf[count] = 0;
 
        mult = 1 << (20 - PAGE_CACHE_SHIFT);
-       buffer = lprocfs_find_named_value(buffer, "used_mb:", &count);
+       buffer += lprocfs_find_named_value(kernbuf, "used_mb:", &count) -
+                 kernbuf;
        rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
        if (rc)
                return rc;
index fe9989a49f81da900902eec0efef949ccecadf71..00f38eeb57865936a9af0877d631afeb5d2ec79d 100644 (file)
@@ -1311,7 +1311,7 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap,
 static void osc_consume_write_grant(struct client_obd *cli,
                                    struct brw_page *pga)
 {
-       LASSERT(spin_is_locked(&cli->cl_loi_list_lock.lock));
+       assert_spin_locked(&cli->cl_loi_list_lock.lock);
        LASSERT(!(pga->flag & OBD_BRW_FROM_GRANT));
        atomic_inc(&obd_dirty_pages);
        cli->cl_dirty += PAGE_CACHE_SIZE;
@@ -1326,7 +1326,7 @@ static void osc_consume_write_grant(struct client_obd *cli,
 static void osc_release_write_grant(struct client_obd *cli,
                                    struct brw_page *pga)
 {
-       LASSERT(spin_is_locked(&cli->cl_loi_list_lock.lock));
+       assert_spin_locked(&cli->cl_loi_list_lock.lock);
        if (!(pga->flag & OBD_BRW_FROM_GRANT)) {
                return;
        }
index 9e7899fa4cc491c038bbc39802ada20d0969d601..e74b7bb9776cecd699f4f0b3c8dc05255874dfc8 100644 (file)
@@ -176,7 +176,16 @@ static inline void osc_object_unlock(struct osc_object *obj)
 
 static inline int osc_object_is_locked(struct osc_object *obj)
 {
+#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
        return spin_is_locked(&obj->oo_lock);
+#else
+       /*
+        * It is not perfect to return true all the time.
+        * But since this function is only used for assertion
+        * and checking, it seems OK.
+        */
+       return 1;
+#endif
 }
 
 /*
index 35f25786763719a0b1ac407a5b3dae0015612fb6..6a6483920c4d9b84f1f58b41a9d833864de533f7 100644 (file)
@@ -122,7 +122,7 @@ static void *osc_key_init(const struct lu_context *ctx,
 {
        struct osc_thread_info *info;
 
-       OBD_SLAB_ALLOC_PTR_GFP(info, osc_thread_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(info, osc_thread_kmem, GFP_NOFS);
        if (info == NULL)
                info = ERR_PTR(-ENOMEM);
        return info;
@@ -146,7 +146,7 @@ static void *osc_session_init(const struct lu_context *ctx,
 {
        struct osc_session *info;
 
-       OBD_SLAB_ALLOC_PTR_GFP(info, osc_session_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(info, osc_session_kmem, GFP_NOFS);
        if (info == NULL)
                info = ERR_PTR(-ENOMEM);
        return info;
index 5f3c545418d11cd765068ae6f3d5409e82618c5f..09e06eb085302bf78d343b7c965b456705912932 100644 (file)
@@ -509,12 +509,11 @@ static void osc_io_setattr_end(const struct lu_env *env,
 static int osc_io_read_start(const struct lu_env *env,
                             const struct cl_io_slice *slice)
 {
-       struct osc_io    *oio   = cl2osc_io(env, slice);
        struct cl_object *obj   = slice->cis_obj;
        struct cl_attr   *attr  = &osc_env_info(env)->oti_attr;
        int rc = 0;
 
-       if (oio->oi_lockless == 0 && !slice->cis_io->ci_noatime) {
+       if (!slice->cis_io->ci_noatime) {
                cl_object_attr_lock(obj);
                attr->cat_atime = LTIME_S(CURRENT_TIME);
                rc = cl_object_attr_set(env, obj, attr, CAT_ATIME);
@@ -526,24 +525,17 @@ static int osc_io_read_start(const struct lu_env *env,
 static int osc_io_write_start(const struct lu_env *env,
                              const struct cl_io_slice *slice)
 {
-       struct osc_io    *oio   = cl2osc_io(env, slice);
        struct cl_object *obj   = slice->cis_obj;
        struct cl_attr   *attr  = &osc_env_info(env)->oti_attr;
-       int           result = 0;
+       int rc = 0;
 
-       if (oio->oi_lockless == 0) {
-               OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_DELAY_SETTIME, 1);
-               cl_object_attr_lock(obj);
-               result = cl_object_attr_get(env, obj, attr);
-               if (result == 0) {
-                       attr->cat_mtime = attr->cat_ctime =
-                               LTIME_S(CURRENT_TIME);
-                       result = cl_object_attr_set(env, obj, attr,
-                                                   CAT_MTIME | CAT_CTIME);
-               }
-               cl_object_attr_unlock(obj);
-       }
-       return result;
+       OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_DELAY_SETTIME, 1);
+       cl_object_attr_lock(obj);
+       attr->cat_mtime = attr->cat_ctime = LTIME_S(CURRENT_TIME);
+       rc = cl_object_attr_set(env, obj, attr, CAT_MTIME | CAT_CTIME);
+       cl_object_attr_unlock(obj);
+
+       return rc;
 }
 
 static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj,
@@ -812,7 +804,7 @@ int osc_req_init(const struct lu_env *env, struct cl_device *dev,
        struct osc_req *or;
        int result;
 
-       OBD_SLAB_ALLOC_PTR_GFP(or, osc_req_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(or, osc_req_kmem, GFP_NOFS);
        if (or != NULL) {
                cl_req_slice_add(req, &or->or_cl, dev, &osc_req_ops);
                result = 0;
index ef7b9c2b208ecb18d67a734a72222685a00c9fcb..a46129bec17af74e0974c9529debd70f579bb967 100644 (file)
@@ -1192,6 +1192,7 @@ static int osc_lock_wait(const struct lu_env *env,
 
                LASSERT(olck->ols_agl);
                olck->ols_agl = 0;
+               olck->ols_flags &= ~LDLM_FL_BLOCK_NOWAIT;
                rc = osc_lock_enqueue(env, slice, NULL, CEF_ASYNC | CEF_MUST);
                if (rc != 0)
                        return rc;
@@ -1558,7 +1559,7 @@ int osc_lock_init(const struct lu_env *env,
        struct osc_lock *clk;
        int result;
 
-       OBD_SLAB_ALLOC_PTR_GFP(clk, osc_lock_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(clk, osc_lock_kmem, GFP_NOFS);
        if (clk != NULL) {
                __u32 enqflags = lock->cll_descr.cld_enq_flags;
 
index 9d34de873fac8e5062d112c05b3bddf0cddec8dd..f9bfdc8201256263ee7d67117b3c379cfd933034 100644 (file)
@@ -260,7 +260,7 @@ struct lu_object *osc_object_alloc(const struct lu_env *env,
        struct osc_object *osc;
        struct lu_object  *obj;
 
-       OBD_SLAB_ALLOC_PTR_GFP(osc, osc_object_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(osc, osc_object_kmem, GFP_NOFS);
        if (osc != NULL) {
                obj = osc2lu(osc);
                lu_object_init(obj, NULL, dev);
index ee6953ac7353f9bcbf8e93343c20704a5e1e769f..294db843012b9502f75e7324728a18171445b56d 100644 (file)
@@ -44,7 +44,6 @@
 #include <lustre/lustre_user.h>
 #include <obd_cksum.h>
 #include <obd_ost.h>
-#include <obd_lov.h>
 
 #include <lustre_ha.h>
 #include <lprocfs_status.h>
index 4c9e006950878afdb1660d26683cd94be219e053..7246e8ce9c1965d0e4daba8a753aca761fc20eab 100644 (file)
@@ -379,6 +379,34 @@ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req)
        return rc;
 }
 
+struct kmem_cache *request_cache;
+
+int ptlrpc_request_cache_init(void)
+{
+       request_cache = kmem_cache_create("ptlrpc_cache",
+                                         sizeof(struct ptlrpc_request),
+                                         0, SLAB_HWCACHE_ALIGN, NULL);
+       return request_cache == NULL ? -ENOMEM : 0;
+}
+
+void ptlrpc_request_cache_fini(void)
+{
+       kmem_cache_destroy(request_cache);
+}
+
+struct ptlrpc_request *ptlrpc_request_cache_alloc(int flags)
+{
+       struct ptlrpc_request *req;
+
+       OBD_SLAB_ALLOC_PTR_GFP(req, request_cache, flags);
+       return req;
+}
+
+void ptlrpc_request_cache_free(struct ptlrpc_request *req)
+{
+       OBD_SLAB_FREE_PTR(req, request_cache);
+}
+
 /**
  * Wind down request pool \a pool.
  * Frees all requests from the pool too
@@ -397,7 +425,7 @@ void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool)
                LASSERT(req->rq_reqbuf);
                LASSERT(req->rq_reqbuf_len == pool->prp_rq_size);
                OBD_FREE_LARGE(req->rq_reqbuf, pool->prp_rq_size);
-               OBD_FREE(req, sizeof(*req));
+               ptlrpc_request_cache_free(req);
        }
        spin_unlock(&pool->prp_lock);
        OBD_FREE(pool, sizeof(*pool));
@@ -427,12 +455,12 @@ void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq)
                struct lustre_msg *msg;
 
                spin_unlock(&pool->prp_lock);
-               OBD_ALLOC(req, sizeof(struct ptlrpc_request));
+               req = ptlrpc_request_cache_alloc(GFP_NOFS);
                if (!req)
                        return;
                OBD_ALLOC_LARGE(msg, size);
                if (!msg) {
-                       OBD_FREE(req, sizeof(struct ptlrpc_request));
+                       ptlrpc_request_cache_free(req);
                        return;
                }
                req->rq_reqbuf = msg;
@@ -668,7 +696,7 @@ struct ptlrpc_request *__ptlrpc_request_alloc(struct obd_import *imp,
                request = ptlrpc_prep_req_from_pool(pool);
 
        if (!request)
-               OBD_ALLOC_PTR(request);
+               request = ptlrpc_request_cache_alloc(GFP_NOFS);
 
        if (request) {
                LASSERTF((unsigned long)imp > 0x1000, "%p", imp);
@@ -739,7 +767,7 @@ void ptlrpc_request_free(struct ptlrpc_request *request)
        if (request->rq_pool)
                __ptlrpc_free_req_to_pool(request);
        else
-               OBD_FREE_PTR(request);
+               ptlrpc_request_cache_free(request);
 }
 EXPORT_SYMBOL(ptlrpc_request_free);
 
@@ -2233,7 +2261,7 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked)
        if (request->rq_pool)
                __ptlrpc_free_req_to_pool(request);
        else
-               OBD_FREE(request, sizeof(*request));
+               ptlrpc_request_cache_free(request);
 }
 
 static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked);
@@ -2243,7 +2271,7 @@ static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked);
  */
 void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request)
 {
-       LASSERT(spin_is_locked(&request->rq_import->imp_lock));
+       assert_spin_locked(&request->rq_import->imp_lock);
        (void)__ptlrpc_req_finished(request, 1);
 }
 EXPORT_SYMBOL(ptlrpc_req_finished_with_imp_lock);
@@ -2424,9 +2452,7 @@ void ptlrpc_free_committed(struct obd_import *imp)
        bool                   skip_committed_list = true;
 
        LASSERT(imp != NULL);
-
-       LASSERT(spin_is_locked(&imp->imp_lock));
-
+       assert_spin_locked(&imp->imp_lock);
 
        if (imp->imp_peer_committed_transno == imp->imp_last_transno_checked &&
            imp->imp_generation == imp->imp_last_generation_checked) {
@@ -2557,7 +2583,7 @@ void ptlrpc_retain_replayable_request(struct ptlrpc_request *req,
 {
        struct list_head *tmp;
 
-       LASSERT(spin_is_locked(&imp->imp_lock));
+       assert_spin_locked(&imp->imp_lock);
 
        if (req->rq_transno == 0) {
                DEBUG_REQ(D_EMERG, req, "saving request with zero transno");
@@ -3023,7 +3049,7 @@ void *ptlrpcd_alloc_work(struct obd_import *imp,
                return ERR_PTR(-EINVAL);
 
        /* copy some code from deprecated fakereq. */
-       OBD_ALLOC_PTR(req);
+       req = ptlrpc_request_cache_alloc(GFP_NOFS);
        if (req == NULL) {
                CERROR("ptlrpc: run out of memory!\n");
                return ERR_PTR(-ENOMEM);
index 6ea0a491cfb3d39fcbf3b5bc373341236869210f..aa85239f6cd5a7dffa422114ff574bd2c69e2222 100644 (file)
@@ -307,7 +307,7 @@ void request_in_callback(lnet_event_t *ev)
                        /* We moaned above already... */
                        return;
                }
-               OBD_ALLOC_GFP(req, sizeof(*req), ALLOC_ATOMIC_TRY);
+               req = ptlrpc_request_cache_alloc(ALLOC_ATOMIC_TRY);
                if (req == NULL) {
                        CERROR("Can't allocate incoming request descriptor: "
                               "Dropping %s RPC from %s\n",
index 7852bf30a3a092dd8dbac4edb93986ae4bdfabde..93794bd928cbf7c6b49d012cf551670184917c9c 100644 (file)
@@ -176,31 +176,31 @@ int gss_cli_ctx_unwrap_bulk(struct ptlrpc_cli_ctx *ctx,
        switch (SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc)) {
        case SPTLRPC_SVC_NULL:
                vmsg = req->rq_repdata;
+               LASSERT(vmsg != NULL && vmsg->lm_bufcount >= 3);
                voff = vmsg->lm_bufcount - 1;
-               LASSERT(vmsg && vmsg->lm_bufcount >= 3);
 
                rmsg = req->rq_reqbuf;
+               LASSERT(rmsg != NULL && rmsg->lm_bufcount >= 3);
                roff = rmsg->lm_bufcount - 1; /* last segment */
-               LASSERT(rmsg && rmsg->lm_bufcount >= 3);
                break;
        case SPTLRPC_SVC_AUTH:
        case SPTLRPC_SVC_INTG:
                vmsg = req->rq_repdata;
+               LASSERT(vmsg != NULL && vmsg->lm_bufcount >= 4);
                voff = vmsg->lm_bufcount - 2;
-               LASSERT(vmsg && vmsg->lm_bufcount >= 4);
 
                rmsg = req->rq_reqbuf;
+               LASSERT(rmsg != NULL && rmsg->lm_bufcount >= 4);
                roff = rmsg->lm_bufcount - 2; /* second last segment */
-               LASSERT(rmsg && rmsg->lm_bufcount >= 4);
                break;
        case SPTLRPC_SVC_PRIV:
                vmsg = req->rq_repdata;
+               LASSERT(vmsg != NULL && vmsg->lm_bufcount >= 2);
                voff = vmsg->lm_bufcount - 1;
-               LASSERT(vmsg && vmsg->lm_bufcount >= 2);
 
                rmsg = req->rq_clrbuf;
+               LASSERT(rmsg != NULL && rmsg->lm_bufcount >= 2);
                roff = rmsg->lm_bufcount - 1; /* last segment */
-               LASSERT(rmsg && rmsg->lm_bufcount >= 2);
                break;
        default:
                LBUG();
index 7a1ff4fecbe3c3d1ffd4f9894da2ac2b0c383fc7..3be5bc14c4ed5865633133d5a6847118789f7f57 100644 (file)
@@ -137,7 +137,7 @@ void ctx_enhash_pf(struct ptlrpc_cli_ctx *ctx, struct hlist_head *hash)
 static
 void ctx_unhash_pf(struct ptlrpc_cli_ctx *ctx, struct hlist_head *freelist)
 {
-       LASSERT(spin_is_locked(&ctx->cc_sec->ps_lock));
+       assert_spin_locked(&ctx->cc_sec->ps_lock);
        LASSERT(atomic_read(&ctx->cc_refcount) > 0);
        LASSERT(test_bit(PTLRPC_CTX_CACHED_BIT, &ctx->cc_flags));
        LASSERT(!hlist_unhashed(&ctx->cc_cache));
@@ -719,7 +719,7 @@ void gss_unhash_msg_nolock(struct gss_upcall_msg *gmsg)
        __u32 idx = gmsg->gum_mechidx;
 
        LASSERT(idx < MECH_MAX);
-       LASSERT(spin_is_locked(&upcall_locks[idx]));
+       assert_spin_locked(&upcall_locks[idx]);
 
        if (list_empty(&gmsg->gum_list))
                return;
index 537aa6204a516d0e3f199011bfd257339c4dee0f..1c73194421a6ccb2126f39584f71ebf545b9a8d8 100644 (file)
@@ -194,7 +194,7 @@ int ptlrpc_set_import_discon(struct obd_import *imp, __u32 conn_cnt)
 /* Must be called with imp_lock held! */
 static void ptlrpc_deactivate_and_unlock_import(struct obd_import *imp)
 {
-       LASSERT(spin_is_locked(&imp->imp_lock));
+       assert_spin_locked(&imp->imp_lock);
 
        CDEBUG(D_HA, "setting import %s INVALID\n", obd2cli_tgt(imp->imp_obd));
        imp->imp_invalid = 1;
@@ -381,6 +381,11 @@ void ptlrpc_activate_import(struct obd_import *imp)
        struct obd_device *obd = imp->imp_obd;
 
        spin_lock(&imp->imp_lock);
+       if (imp->imp_deactive != 0) {
+               spin_unlock(&imp->imp_lock);
+               return;
+       }
+
        imp->imp_invalid = 0;
        spin_unlock(&imp->imp_lock);
        obd_import_event(obd, imp, IMP_EVENT_ACTIVE);
@@ -1399,26 +1404,33 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
 {
        struct ptlrpc_request *req;
        int rq_opc, rc = 0;
-       int nowait = imp->imp_obd->obd_force;
 
-       if (nowait)
+       if (imp->imp_obd->obd_force)
                GOTO(set_state, rc);
 
        switch (imp->imp_connect_op) {
-       case OST_CONNECT: rq_opc = OST_DISCONNECT; break;
-       case MDS_CONNECT: rq_opc = MDS_DISCONNECT; break;
-       case MGS_CONNECT: rq_opc = MGS_DISCONNECT; break;
+       case OST_CONNECT:
+               rq_opc = OST_DISCONNECT;
+               break;
+       case MDS_CONNECT:
+               rq_opc = MDS_DISCONNECT;
+               break;
+       case MGS_CONNECT:
+               rq_opc = MGS_DISCONNECT;
+               break;
        default:
-               CERROR("don't know how to disconnect from %s (connect_op %d)\n",
-                      obd2cli_tgt(imp->imp_obd), imp->imp_connect_op);
-               return -EINVAL;
+               rc = -EINVAL;
+               CERROR("%s: don't know how to disconnect from %s "
+                      "(connect_op %d): rc = %d\n",
+                      imp->imp_obd->obd_name, obd2cli_tgt(imp->imp_obd),
+                      imp->imp_connect_op, rc);
+               return rc;
        }
 
        if (ptlrpc_import_in_recovery(imp)) {
                struct l_wait_info lwi;
                cfs_duration_t timeout;
 
-
                if (AT_OFF) {
                        if (imp->imp_server_timeout)
                                timeout = cfs_time_seconds(obd_timeout / 2);
@@ -1441,7 +1453,6 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
        spin_lock(&imp->imp_lock);
        if (imp->imp_state != LUSTRE_IMP_FULL)
                GOTO(out, 0);
-
        spin_unlock(&imp->imp_lock);
 
        req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_DISCONNECT,
@@ -1474,6 +1485,9 @@ out:
        memset(&imp->imp_remote_handle, 0, sizeof(imp->imp_remote_handle));
        spin_unlock(&imp->imp_lock);
 
+       if (rc == -ETIMEDOUT || rc == -ENOTCONN || rc == -ESHUTDOWN)
+               rc = 0;
+
        return rc;
 }
 EXPORT_SYMBOL(ptlrpc_disconnect_import);
index 58f1c8bf25b0b41a207dccb86186a0e7169c9dda..6b9c6db1f2df6d3048c99bf4b8ede5441eda002e 100644 (file)
@@ -449,7 +449,7 @@ void nrs_policy_get_info_locked(struct ptlrpc_nrs_policy *policy,
 {
        LASSERT(policy != NULL);
        LASSERT(info != NULL);
-       LASSERT(spin_is_locked(&policy->pol_nrs->nrs_lock));
+       assert_spin_locked(&policy->pol_nrs->nrs_lock);
 
        memcpy(info->pi_name, policy->pol_desc->pd_name, NRS_POL_NAME_MAX);
 
@@ -1190,7 +1190,7 @@ int lprocfs_wr_evict_client(struct file *file, const char *buffer,
         * the proc entries under the being destroyed export{}, so I have
         * to drop the lock at first here.
         * - jay, jxiong@clusterfs.com */
-       class_incref(obd, __FUNCTION__, current);
+       class_incref(obd, __func__, current);
 
        if (strncmp(tmpbuf, "nid:", 4) == 0)
                obd_export_evict_by_nid(obd, tmpbuf + 4);
@@ -1199,7 +1199,7 @@ int lprocfs_wr_evict_client(struct file *file, const char *buffer,
        else
                obd_export_evict_by_uuid(obd, tmpbuf);
 
-       class_decref(obd, __FUNCTION__, current);
+       class_decref(obd, __func__, current);
 
 out:
        OBD_FREE(kbuf, BUFLEN);
index bcba1c8e8693b5badc5ecdfdf7d42c0917a4b076..12151aa2a1e5101ba6fe862a36bec0435fcdf2b6 100644 (file)
@@ -746,7 +746,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs,
        LASSERT(desc->pd_compat != NULL);
 
        OBD_CPT_ALLOC_GFP(policy, svcpt->scp_service->srv_cptable,
-                         svcpt->scp_cpt, sizeof(*policy), __GFP_IO);
+                         svcpt->scp_cpt, sizeof(*policy), GFP_NOFS);
        if (policy == NULL)
                return -ENOMEM;
 
index 45c0b84621e4b617752c72df385b11139aa737d4..cddeeb6bb23d826971f2bec635d74c452b81be9e 100644 (file)
@@ -300,6 +300,7 @@ lustre_get_emerg_rs(struct ptlrpc_service_part *svcpt)
        spin_unlock(&svcpt->scp_rep_lock);
 
        memset(rs, 0, svcpt->scp_service->srv_max_reply_size);
+       rs->rs_size = svcpt->scp_service->srv_max_reply_size;
        rs->rs_svcpt = svcpt;
        rs->rs_prealloc = 1;
 out:
index 6dff502ce23e6fdc3764cda314a3cf346b582735..38099d9dfdaeb65f028d3d59492c0ac415c20df4 100644 (file)
@@ -368,7 +368,7 @@ EXPORT_SYMBOL(ptlrpc_pinger_sending_on_import);
 void ptlrpc_pinger_commit_expected(struct obd_import *imp)
 {
        ptlrpc_update_next_ping(imp, 1);
-       LASSERT(spin_is_locked(&imp->imp_lock));
+       assert_spin_locked(&imp->imp_lock);
        /*
         * Avoid reading stale imp_connect_data.  When not sure if pings are
         * expected or not on next connection, we assume they are not and force
index e3b5a920bca2f5f6ad6500638c9d3b56a3a5a3b7..7c9405530596745d51ef95175f3f4972e04612d2 100644 (file)
@@ -55,6 +55,10 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc);
 /* client.c */
 struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned npages, unsigned max_brw,
                                         unsigned type, unsigned portal);
+int ptlrpc_request_cache_init(void);
+void ptlrpc_request_cache_fini(void);
+struct ptlrpc_request *ptlrpc_request_cache_alloc(int flags);
+void ptlrpc_request_cache_free(struct ptlrpc_request *req);
 void ptlrpc_init_xid(void);
 
 /* events.c */
index 0efd35887a15994efe20e6d842ee12bac2a6edf5..251ae75c2dd99b5457915a4ba70c132d6f3761ff 100644 (file)
@@ -73,29 +73,34 @@ __init int ptlrpc_init(void)
                return rc;
 
        cleanup_phase = 1;
+       rc = ptlrpc_request_cache_init();
+       if (rc)
+               GOTO(cleanup, rc);
 
+       cleanup_phase = 2;
        rc = ptlrpc_init_portals();
        if (rc)
                GOTO(cleanup, rc);
-       cleanup_phase = 2;
+
+       cleanup_phase = 3;
 
        rc = ptlrpc_connection_init();
        if (rc)
                GOTO(cleanup, rc);
-       cleanup_phase = 3;
 
+       cleanup_phase = 4;
        ptlrpc_put_connection_superhack = ptlrpc_connection_put;
 
        rc = ptlrpc_start_pinger();
        if (rc)
                GOTO(cleanup, rc);
-       cleanup_phase = 4;
 
+       cleanup_phase = 5;
        rc = ldlm_init();
        if (rc)
                GOTO(cleanup, rc);
-       cleanup_phase = 5;
 
+       cleanup_phase = 6;
        rc = sptlrpc_init();
        if (rc)
                GOTO(cleanup, rc);
@@ -115,19 +120,29 @@ cleanup:
        switch (cleanup_phase) {
        case 8:
                ptlrpc_nrs_fini();
+               /* Fall through */
        case 7:
                sptlrpc_fini();
-       case 5:
+               /* Fall through */
+       case 6:
                ldlm_exit();
-       case 4:
+               /* Fall through */
+       case 5:
                ptlrpc_stop_pinger();
-       case 3:
+               /* Fall through */
+       case 4:
                ptlrpc_connection_fini();
-       case 2:
+               /* Fall through */
+       case 3:
                ptlrpc_exit_portals();
+               /* Fall through */
+       case 2:
+               ptlrpc_request_cache_fini();
+               /* Fall through */
        case 1:
                ptlrpc_hr_fini();
                req_layout_fini();
+               /* Fall through */
        default: ;
        }
 
@@ -142,6 +157,7 @@ static void __exit ptlrpc_exit(void)
        ldlm_exit();
        ptlrpc_stop_pinger();
        ptlrpc_exit_portals();
+       ptlrpc_request_cache_fini();
        ptlrpc_hr_fini();
        ptlrpc_connection_fini();
 }
index 48ae328ce24ec138063647ab68b5e824c4a6b8a4..9cec8a649dc3fb45e0cdaccc287579eb6bff0142 100644 (file)
@@ -49,7 +49,6 @@
 #include <obd.h>
 #include <obd_ost.h>
 #include <obd_class.h>
-#include <obd_lov.h> /* for IOC_LOV_SET_OSC_ACTIVE */
 #include <linux/list.h>
 
 #include "ptlrpc_internal.h"
@@ -369,11 +368,14 @@ EXPORT_SYMBOL(ptlrpc_recover_import);
 int ptlrpc_import_in_recovery(struct obd_import *imp)
 {
        int in_recovery = 1;
+
        spin_lock(&imp->imp_lock);
        if (imp->imp_state == LUSTRE_IMP_FULL ||
            imp->imp_state == LUSTRE_IMP_CLOSED ||
-           imp->imp_state == LUSTRE_IMP_DISCON)
+           imp->imp_state == LUSTRE_IMP_DISCON ||
+           imp->imp_obd->obd_no_recov)
                in_recovery = 0;
        spin_unlock(&imp->imp_lock);
+
        return in_recovery;
 }
index d80418057f296f7167b3355f56c689e051cd4c01..28ac824a73fb8356de35bc76c57c7e1a269adb4a 100644 (file)
@@ -354,7 +354,7 @@ static int import_sec_check_expire(struct obd_import *imp)
                return 0;
 
        CDEBUG(D_SEC, "found delayed sec adapt expired, do it now\n");
-       return sptlrpc_import_sec_adapt(imp, NULL, 0);
+       return sptlrpc_import_sec_adapt(imp, NULL, NULL);
 }
 
 static int import_sec_validate_get(struct obd_import *imp,
@@ -904,7 +904,7 @@ int sptlrpc_import_check_ctx(struct obd_import *imp)
                return -EACCES;
        }
 
-       OBD_ALLOC_PTR(req);
+       req = ptlrpc_request_cache_alloc(GFP_NOFS);
        if (!req)
                return -ENOMEM;
 
@@ -920,7 +920,7 @@ int sptlrpc_import_check_ctx(struct obd_import *imp)
        rc = sptlrpc_req_refresh_ctx(req, 0);
        LASSERT(list_empty(&req->rq_ctx_chain));
        sptlrpc_cli_ctx_put(req->rq_cli_ctx, 1);
-       OBD_FREE_PTR(req);
+       ptlrpc_request_cache_free(req);
 
        return rc;
 }
@@ -1088,7 +1088,7 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req,
        int                  early_bufsz, early_size;
        int                  rc;
 
-       OBD_ALLOC_PTR(early_req);
+       early_req = ptlrpc_request_cache_alloc(GFP_NOFS);
        if (early_req == NULL)
                return -ENOMEM;
 
@@ -1160,7 +1160,7 @@ err_ctx:
 err_buf:
        OBD_FREE_LARGE(early_buf, early_bufsz);
 err_req:
-       OBD_FREE_PTR(early_req);
+       ptlrpc_request_cache_free(early_req);
        return rc;
 }
 
@@ -1177,7 +1177,7 @@ void sptlrpc_cli_finish_early_reply(struct ptlrpc_request *early_req)
 
        sptlrpc_cli_ctx_put(early_req->rq_cli_ctx, 1);
        OBD_FREE_LARGE(early_req->rq_repbuf, early_req->rq_repbuf_len);
-       OBD_FREE_PTR(early_req);
+       ptlrpc_request_cache_free(early_req);
 }
 
 /**************************************************
@@ -2086,8 +2086,18 @@ int sptlrpc_svc_alloc_rs(struct ptlrpc_request *req, int msglen)
 
        rc = policy->sp_sops->alloc_rs(req, msglen);
        if (unlikely(rc == -ENOMEM)) {
+               struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt;
+               if (svcpt->scp_service->srv_max_reply_size <
+                  msglen + sizeof(struct ptlrpc_reply_state)) {
+                       /* Just return failure if the size is too big */
+                       CERROR("size of message is too big (%zd), %d allowed",
+                               msglen + sizeof(struct ptlrpc_reply_state),
+                               svcpt->scp_service->srv_max_reply_size);
+                       return -ENOMEM;
+               }
+
                /* failed alloc, try emergency pool */
-               rs = lustre_get_emerg_rs(req->rq_rqbd->rqbd_svcpt);
+               rs = lustre_get_emerg_rs(svcpt);
                if (rs == NULL)
                        return -ENOMEM;
 
index 9656681327478657530642ef6ecd37c83228ad23..9d51badea73dbfa0fcde3edd4d9cf1a3e697f5d7 100644 (file)
@@ -421,7 +421,7 @@ static int enc_pools_add_pages(int npages)
                        goto out_pools;
 
                for (j = 0; j < PAGES_PER_POOL && alloced < npages; j++) {
-                       pools[i][j] = alloc_page(__GFP_IO |
+                       pools[i][j] = alloc_page(GFP_NOFS |
                                                     __GFP_HIGHMEM);
                        if (pools[i][j] == NULL)
                                goto out_pools;
@@ -450,7 +450,7 @@ out:
 
 static inline void enc_pools_wakeup(void)
 {
-       LASSERT(spin_is_locked(&page_pools.epp_lock));
+       assert_spin_locked(&page_pools.epp_lock);
        LASSERT(page_pools.epp_waitqlen >= 0);
 
        if (unlikely(page_pools.epp_waitqlen)) {
index 192adec5382a327f30de3975cd3baa6c495b90a8..d278f2e218030720daa291e0799941d1dc05ca6b 100644 (file)
@@ -384,8 +384,8 @@ void ptlrpc_dispatch_difficult_reply(struct ptlrpc_reply_state *rs)
 void
 ptlrpc_schedule_difficult_reply(struct ptlrpc_reply_state *rs)
 {
-       LASSERT(spin_is_locked(&rs->rs_svcpt->scp_rep_lock));
-       LASSERT(spin_is_locked(&rs->rs_lock));
+       assert_spin_locked(&rs->rs_svcpt->scp_rep_lock);
+       assert_spin_locked(&rs->rs_lock);
        LASSERT(rs->rs_difficult);
        rs->rs_scheduled_ever = 1;  /* flag any notification attempt */
 
@@ -842,7 +842,7 @@ static void ptlrpc_server_free_request(struct ptlrpc_request *req)
                /* NB request buffers use an embedded
                 * req if the incoming req unlinked the
                 * MD; this isn't one of them! */
-               OBD_FREE(req, sizeof(*req));
+               ptlrpc_request_cache_free(req);
        }
 }
 
@@ -1042,9 +1042,6 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay)
                return;
 
        exp->exp_last_request_time = new_time;
-       CDEBUG(D_HA, "updating export %s at "CFS_TIME_T" exp %p\n",
-              exp->exp_client_uuid.uuid,
-              exp->exp_last_request_time, exp);
 
        /* exports may get disconnected from the chain even though the
           export has references, so we must keep the spin lock while
@@ -1308,14 +1305,12 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req)
        }
        newdl = cfs_time_current_sec() + at_get(&svcpt->scp_at_estimate);
 
-       OBD_ALLOC(reqcopy, sizeof(*reqcopy));
+       reqcopy = ptlrpc_request_cache_alloc(GFP_NOFS);
        if (reqcopy == NULL)
                return -ENOMEM;
        OBD_ALLOC_LARGE(reqmsg, req->rq_reqlen);
-       if (!reqmsg) {
-               OBD_FREE(reqcopy, sizeof(*reqcopy));
-               return -ENOMEM;
-       }
+       if (!reqmsg)
+               GOTO(out_free, rc = -ENOMEM);
 
        *reqcopy = *req;
        reqcopy->rq_reply_state = NULL;
@@ -1372,7 +1367,8 @@ out_put:
 out:
        sptlrpc_svc_ctx_decref(reqcopy);
        OBD_FREE_LARGE(reqmsg, req->rq_reqlen);
-       OBD_FREE(reqcopy, sizeof(*reqcopy));
+out_free:
+       ptlrpc_request_cache_free(reqcopy);
        return rc;
 }
 
index c83e3375104b5066db2a4991726fbb8a3aa45fde..75d7c63cb41328e8f88a86fdbf93ee091a147abd 100644 (file)
@@ -268,6 +268,7 @@ static void xlr_make_tx_desc(struct nlm_fmn_msg *msg, unsigned long addr,
        unsigned long physkb = virt_to_phys(skb);
        int cpu_core = nlm_core_id();
        int fr_stn_id = cpu_core * 8 + XLR_FB_STN;      /* FB to 6th bucket */
+
        msg->msg0 = (((u64)1 << 63)     |       /* End of packet descriptor */
                ((u64)127 << 54)        |       /* No Free back */
                (u64)skb->len << 40     |       /* Length of data */
index 08f9a4896116a3c4368a616d134a2d5a065f9371..136671a50d6e54ce08007422d0c4335d0ad4fd5d 100644 (file)
@@ -867,6 +867,7 @@ static void lcd_print(char c)
 static void lcd_clear_fast_s(void)
 {
        int pos;
+
        lcd_addr_x = lcd_addr_y = 0;
        lcd_gotoxy();
 
@@ -887,6 +888,7 @@ static void lcd_clear_fast_s(void)
 static void lcd_clear_fast_p8(void)
 {
        int pos;
+
        lcd_addr_x = lcd_addr_y = 0;
        lcd_gotoxy();
 
@@ -922,6 +924,7 @@ static void lcd_clear_fast_p8(void)
 static void lcd_clear_fast_tilcd(void)
 {
        int pos;
+
        lcd_addr_x = lcd_addr_y = 0;
        lcd_gotoxy();
 
@@ -1092,6 +1095,7 @@ static inline int handle_lcd_special_code(void)
                break;
        case 'k': {     /* kill end of line */
                int x;
+
                for (x = lcd_addr_x; x < lcd_bwidth; x++)
                        lcd_write_data(' ');
 
@@ -1217,111 +1221,113 @@ static inline int handle_lcd_special_code(void)
        return processed;
 }
 
+static void lcd_write_char(char c)
+{
+       /* first, we'll test if we're in escape mode */
+       if ((c != '\n') && lcd_escape_len >= 0) {
+               /* yes, let's add this char to the buffer */
+               lcd_escape[lcd_escape_len++] = c;
+               lcd_escape[lcd_escape_len] = 0;
+       } else {
+               /* aborts any previous escape sequence */
+               lcd_escape_len = -1;
+
+               switch (c) {
+               case LCD_ESCAPE_CHAR:
+                       /* start of an escape sequence */
+                       lcd_escape_len = 0;
+                       lcd_escape[lcd_escape_len] = 0;
+                       break;
+               case '\b':
+                       /* go back one char and clear it */
+                       if (lcd_addr_x > 0) {
+                               /* check if we're not at the
+                                  end of the line */
+                               if (lcd_addr_x < lcd_bwidth)
+                                       /* back one char */
+                                       lcd_write_cmd(0x10);
+                               lcd_addr_x--;
+                       }
+                       /* replace with a space */
+                       lcd_write_data(' ');
+                       /* back one char again */
+                       lcd_write_cmd(0x10);
+                       break;
+               case '\014':
+                       /* quickly clear the display */
+                       lcd_clear_fast();
+                       break;
+               case '\n':
+                       /* flush the remainder of the current line and
+                          go to the beginning of the next line */
+                       for (; lcd_addr_x < lcd_bwidth; lcd_addr_x++)
+                               lcd_write_data(' ');
+                       lcd_addr_x = 0;
+                       lcd_addr_y = (lcd_addr_y + 1) % lcd_height;
+                       lcd_gotoxy();
+                       break;
+               case '\r':
+                       /* go to the beginning of the same line */
+                       lcd_addr_x = 0;
+                       lcd_gotoxy();
+                       break;
+               case '\t':
+                       /* print a space instead of the tab */
+                       lcd_print(' ');
+                       break;
+               default:
+                       /* simply print this char */
+                       lcd_print(c);
+                       break;
+               }
+       }
+
+       /* now we'll see if we're in an escape mode and if the current
+          escape sequence can be understood. */
+       if (lcd_escape_len >= 2) {
+               int processed = 0;
+
+               if (!strcmp(lcd_escape, "[2J")) {
+                       /* clear the display */
+                       lcd_clear_fast();
+                       processed = 1;
+               } else if (!strcmp(lcd_escape, "[H")) {
+                       /* cursor to home */
+                       lcd_addr_x = lcd_addr_y = 0;
+                       lcd_gotoxy();
+                       processed = 1;
+               }
+               /* codes starting with ^[[L */
+               else if ((lcd_escape_len >= 3) &&
+                        (lcd_escape[0] == '[') &&
+                        (lcd_escape[1] == 'L')) {
+                       processed = handle_lcd_special_code();
+               }
+
+               /* LCD special escape codes */
+               /* flush the escape sequence if it's been processed
+                  or if it is getting too long. */
+               if (processed || (lcd_escape_len >= LCD_ESCAPE_LEN))
+                       lcd_escape_len = -1;
+       } /* escape codes */
+}
+
 static ssize_t lcd_write(struct file *file,
-                        const char *buf, size_t count, loff_t *ppos)
+       const char __user *buf, size_t count, loff_t *ppos)
 {
-       const char *tmp = buf;
+       const char __user *tmp = buf;
        char c;
 
-       for (; count-- > 0; (ppos ? (*ppos)++ : 0), ++tmp) {
+       for (; count-- > 0; (*ppos)++, tmp++) {
                if (!in_interrupt() && (((count + 1) & 0x1f) == 0))
                        /* let's be a little nice with other processes
                           that need some CPU */
                        schedule();
 
-               if (ppos == NULL && file == NULL)
-                       /* let's not use get_user() from the kernel ! */
-                       c = *tmp;
-               else if (get_user(c, tmp))
+               if (get_user(c, buf))
                        return -EFAULT;
 
-               /* first, we'll test if we're in escape mode */
-               if ((c != '\n') && lcd_escape_len >= 0) {
-                       /* yes, let's add this char to the buffer */
-                       lcd_escape[lcd_escape_len++] = c;
-                       lcd_escape[lcd_escape_len] = 0;
-               } else {
-                       /* aborts any previous escape sequence */
-                       lcd_escape_len = -1;
-
-                       switch (c) {
-                       case LCD_ESCAPE_CHAR:
-                               /* start of an escape sequence */
-                               lcd_escape_len = 0;
-                               lcd_escape[lcd_escape_len] = 0;
-                               break;
-                       case '\b':
-                               /* go back one char and clear it */
-                               if (lcd_addr_x > 0) {
-                                       /* check if we're not at the
-                                          end of the line */
-                                       if (lcd_addr_x < lcd_bwidth)
-                                               /* back one char */
-                                               lcd_write_cmd(0x10);
-                                       lcd_addr_x--;
-                               }
-                               /* replace with a space */
-                               lcd_write_data(' ');
-                               /* back one char again */
-                               lcd_write_cmd(0x10);
-                               break;
-                       case '\014':
-                               /* quickly clear the display */
-                               lcd_clear_fast();
-                               break;
-                       case '\n':
-                               /* flush the remainder of the current line and
-                                  go to the beginning of the next line */
-                               for (; lcd_addr_x < lcd_bwidth; lcd_addr_x++)
-                                       lcd_write_data(' ');
-                               lcd_addr_x = 0;
-                               lcd_addr_y = (lcd_addr_y + 1) % lcd_height;
-                               lcd_gotoxy();
-                               break;
-                       case '\r':
-                               /* go to the beginning of the same line */
-                               lcd_addr_x = 0;
-                               lcd_gotoxy();
-                               break;
-                       case '\t':
-                               /* print a space instead of the tab */
-                               lcd_print(' ');
-                               break;
-                       default:
-                               /* simply print this char */
-                               lcd_print(c);
-                               break;
-                       }
-               }
-
-               /* now we'll see if we're in an escape mode and if the current
-                  escape sequence can be understood. */
-               if (lcd_escape_len >= 2) {
-                       int processed = 0;
-
-                       if (!strcmp(lcd_escape, "[2J")) {
-                               /* clear the display */
-                               lcd_clear_fast();
-                               processed = 1;
-                       } else if (!strcmp(lcd_escape, "[H")) {
-                               /* cursor to home */
-                               lcd_addr_x = lcd_addr_y = 0;
-                               lcd_gotoxy();
-                               processed = 1;
-                       }
-                       /* codes starting with ^[[L */
-                       else if ((lcd_escape_len >= 3) &&
-                                (lcd_escape[0] == '[') &&
-                                (lcd_escape[1] == 'L')) {
-                               processed = handle_lcd_special_code();
-                       }
-
-                       /* LCD special escape codes */
-                       /* flush the escape sequence if it's been processed
-                          or if it is getting too long. */
-                       if (processed || (lcd_escape_len >= LCD_ESCAPE_LEN))
-                               lcd_escape_len = -1;
-               } /* escape codes */
+               lcd_write_char(c);
        }
 
        return tmp - buf;
@@ -1365,8 +1371,19 @@ static struct miscdevice lcd_dev = {
 /* public function usable from the kernel for any purpose */
 static void panel_lcd_print(const char *s)
 {
-       if (lcd_enabled && lcd_initialized)
-               lcd_write(NULL, s, strlen(s), NULL);
+       const char *tmp = s;
+       int count = strlen(s);
+
+       if (lcd_enabled && lcd_initialized) {
+               for (; count-- > 0; tmp++) {
+                       if (!in_interrupt() && (((count + 1) & 0x1f) == 0))
+                               /* let's be a little nice with other processes
+                                  that need some CPU */
+                               schedule();
+
+                       lcd_write_char(*tmp);
+               }
+       }
 }
 
 /* initialize the LCD driver */
@@ -1571,11 +1588,11 @@ static void lcd_init(void)
  */
 
 static ssize_t keypad_read(struct file *file,
-                          char *buf, size_t count, loff_t *ppos)
+                          char __user *buf, size_t count, loff_t *ppos)
 {
 
        unsigned i = *ppos;
-       char *tmp = buf;
+       char __user *tmp = buf;
 
        if (keypad_buflen == 0) {
                if (file->f_flags & O_NONBLOCK)
@@ -1747,16 +1764,20 @@ static inline int input_state_high(struct logical_input *input)
 
                        if (input->high_timer == 0) {
                                char *press_str = input->u.kbd.press_str;
+
                                if (press_str[0]) {
                                        int s = sizeof(input->u.kbd.press_str);
+
                                        keypad_send_key(press_str, s);
                                }
                        }
 
                        if (input->u.kbd.repeat_str[0]) {
                                char *repeat_str = input->u.kbd.repeat_str;
+
                                if (input->high_timer >= KEYPAD_REP_START) {
                                        int s = sizeof(input->u.kbd.repeat_str);
+
                                        input->high_timer -= KEYPAD_REP_DELAY;
                                        keypad_send_key(repeat_str, s);
                                }
@@ -1794,8 +1815,10 @@ static inline void input_state_falling(struct logical_input *input)
 
                        if (input->u.kbd.repeat_str[0]) {
                                char *repeat_str = input->u.kbd.repeat_str;
+
                                if (input->high_timer >= KEYPAD_REP_START) {
                                        int s = sizeof(input->u.kbd.repeat_str);
+
                                        input->high_timer -= KEYPAD_REP_DELAY;
                                        keypad_send_key(repeat_str, s);
                                }
@@ -1811,12 +1834,15 @@ static inline void input_state_falling(struct logical_input *input)
                /* call release event */
                if (input->type == INPUT_TYPE_STD) {
                        void (*release_fct)(int) = input->u.std.release_fct;
+
                        if (release_fct != NULL)
                                release_fct(input->u.std.release_data);
                } else if (input->type == INPUT_TYPE_KBD) {
                        char *release_str = input->u.kbd.release_str;
+
                        if (release_str[0]) {
                                int s = sizeof(input->u.kbd.release_str);
+
                                keypad_send_key(release_str, s);
                        }
                }
@@ -1933,6 +1959,7 @@ static int input_name2mask(const char *name, pmask_t *mask, pmask_t *value,
        om = im = m = v = 0ULL;
        while (*name) {
                int in, out, bit, neg;
+
                for (in = 0; (in < sizeof(sigtab)) &&
                             (sigtab[in] != *name); in++)
                        ;
@@ -2040,6 +2067,7 @@ static struct logical_input *panel_bind_callback(char *name,
 static void keypad_init(void)
 {
        int keynum;
+
        init_waitqueue_head(&keypad_read_wait);
        keypad_buflen = 0;      /* flushes any eventual noisy keystroke */
 
@@ -2298,7 +2326,7 @@ static void __exit panel_cleanup_module(void)
        unregister_reboot_notifier(&panel_notifier);
 
        if (scan_timer.function != NULL)
-               del_timer(&scan_timer);
+               del_timer_sync(&scan_timer);
 
        if (pprt != NULL) {
                if (keypad_enabled) {
index e843c6bd4525875bd1d0d5b86dffc0d98faa3101..f97f05f4165e70c96ed87ca7122f986f49112249 100644 (file)
@@ -442,6 +442,7 @@ static void __nat25_db_print(struct adapter *priv)
 void nat25_db_cleanup(struct adapter *priv)
 {
        int i;
+
        spin_lock_bh(&priv->br_ext_lock);
 
        for (i = 0; i < NAT25_HASH_SIZE; i++) {
index c2fb050337d505f475b29b1646bc07eebfb896bb..1e0b8b49fc1270c0073a440f1b282a4e89ff1b2f 100644 (file)
@@ -1431,41 +1431,6 @@ exit:
        return res;
 }
 
-u8 rtw_led_blink_cmd(struct adapter *padapter, struct LED_871x *pLed)
-{
-       struct  cmd_obj *pcmdobj;
-       struct  LedBlink_param *ledBlink_param;
-       struct  cmd_priv   *pcmdpriv = &padapter->cmdpriv;
-
-       u8      res = _SUCCESS;
-
-
-       RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_led_blink_cmd\n"));
-
-       pcmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct   cmd_obj));
-       if (pcmdobj == NULL) {
-               res = _FAIL;
-               goto exit;
-       }
-
-       ledBlink_param = (struct        LedBlink_param *)rtw_zmalloc(sizeof(struct      LedBlink_param));
-       if (ledBlink_param == NULL) {
-               kfree(pcmdobj);
-               res = _FAIL;
-               goto exit;
-       }
-
-       ledBlink_param->pLed = pLed;
-
-       init_h2fwcmd_w_parm_no_rsp(pcmdobj, ledBlink_param, GEN_CMD_CODE(_LedBlink));
-       res = rtw_enqueue_cmd(pcmdpriv, pcmdobj);
-
-exit:
-
-
-       return res;
-}
-
 u8 rtw_set_csa_cmd(struct adapter *padapter, u8 new_ch_no)
 {
        struct  cmd_obj *pcmdobj;
index 42b41ab1bce1de6e7afe1b592d77f831d8d48c56..87d6f063476b1535c4be14b7ebeb8754ab5b4679 100644 (file)
@@ -40,7 +40,6 @@ void BlinkTimerCallback(void *data)
 /*  */
 /*     Description: */
 /*             Callback function of LED BlinkWorkItem. */
-/*             We dispatch acture LED blink action according to LedStrategy. */
 /*  */
 void BlinkWorkItemCallback(struct work_struct *work)
 {
@@ -71,10 +70,9 @@ void ResetLedStatus(struct LED_871x *pLed)
 
 /*Description: */
 /*             Initialize an LED_871x object. */
-void InitLed871x(struct adapter *padapter, struct LED_871x *pLed, enum LED_PIN_871x LedPin)
+void InitLed871x(struct adapter *padapter, struct LED_871x *pLed)
 {
        pLed->padapter = padapter;
-       pLed->LedPin = LedPin;
 
        ResetLedStatus(pLed);
 
@@ -101,87 +99,6 @@ void DeInitLed871x(struct LED_871x *pLed)
 /*             It toggle off LED and schedule corresponding timer if necessary. */
 /*  */
 
-static void SwLedBlink(struct LED_871x *pLed)
-{
-       struct adapter *padapter = pLed->padapter;
-       struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
-       u8 bStopBlinking = false;
-
-       /*  Change LED according to BlinkingLedState specified. */
-       if (pLed->BlinkingLedState == RTW_LED_ON) {
-               SwLedOn(padapter, pLed);
-               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes));
-       } else {
-               SwLedOff(padapter, pLed);
-               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes));
-       }
-
-       /*  Determine if we shall change LED state again. */
-       pLed->BlinkTimes--;
-       switch (pLed->CurrLedState) {
-       case LED_BLINK_NORMAL:
-               if (pLed->BlinkTimes == 0)
-                       bStopBlinking = true;
-               break;
-       case LED_BLINK_StartToBlink:
-               if (check_fwstate(pmlmepriv, _FW_LINKED) && check_fwstate(pmlmepriv, WIFI_STATION_STATE))
-                       bStopBlinking = true;
-               if (check_fwstate(pmlmepriv, _FW_LINKED) &&
-                   (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ||
-                   check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)))
-                       bStopBlinking = true;
-               else if (pLed->BlinkTimes == 0)
-                       bStopBlinking = true;
-               break;
-       case LED_BLINK_WPS:
-               if (pLed->BlinkTimes == 0)
-                       bStopBlinking = true;
-               break;
-       default:
-               bStopBlinking = true;
-               break;
-       }
-
-       if (bStopBlinking) {
-               /* if (padapter->pwrctrlpriv.cpwm >= PS_STATE_S2) */
-               if (0) {
-                       SwLedOff(padapter, pLed);
-               } else if ((check_fwstate(pmlmepriv, _FW_LINKED)) && (!pLed->bLedOn)) {
-                       SwLedOn(padapter, pLed);
-               } else if ((check_fwstate(pmlmepriv, _FW_LINKED)) &&  pLed->bLedOn) {
-                       SwLedOff(padapter, pLed);
-               }
-               pLed->BlinkTimes = 0;
-               pLed->bLedBlinkInProgress = false;
-       } else {
-               /*  Assign LED state to toggle. */
-               if (pLed->BlinkingLedState == RTW_LED_ON)
-                       pLed->BlinkingLedState = RTW_LED_OFF;
-               else
-                       pLed->BlinkingLedState = RTW_LED_ON;
-
-               /*  Schedule a timer to toggle LED state. */
-               switch (pLed->CurrLedState) {
-               case LED_BLINK_NORMAL:
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL);
-                       break;
-               case LED_BLINK_SLOWLY:
-               case LED_BLINK_StartToBlink:
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL);
-                       break;
-               case LED_BLINK_WPS:
-                       if (pLed->BlinkingLedState == RTW_LED_ON)
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL);
-                       else
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL);
-                       break;
-               default:
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL);
-                       break;
-               }
-       }
-}
-
 static void SwLedBlink1(struct LED_871x *pLed)
 {
        struct adapter *padapter = pLed->padapter;
@@ -277,1051 +194,115 @@ static void SwLedBlink1(struct LED_871x *pLed)
                        }
                        pLed->BlinkTimes = 0;
                        pLed->bLedBlinkInProgress = false;
-               } else {
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA);
-               }
-               break;
-       case LED_BLINK_WPS:
-               if (pLed->bLedOn)
-                       pLed->BlinkingLedState = RTW_LED_OFF;
-               else
-                       pLed->BlinkingLedState = RTW_LED_ON;
-               _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
-               break;
-       case LED_BLINK_WPS_STOP:        /* WPS success */
-               if (pLed->BlinkingLedState == RTW_LED_ON)
-                       bStopBlinking = false;
-               else
-                       bStopBlinking = true;
-
-               if (bStopBlinking) {
-                       pLed->bLedLinkBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_NORMAL;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA);
-                       RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState));
-
-                       pLed->bLedWPSBlinkInProgress = false;
-               } else {
-                       pLed->BlinkingLedState = RTW_LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA);
-               }
-               break;
-       default:
-               break;
-       }
-}
-
-static void SwLedBlink2(struct LED_871x *pLed)
-{
-       struct adapter *padapter = pLed->padapter;
-       struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
-       u8 bStopBlinking = false;
-
-       /*  Change LED according to BlinkingLedState specified. */
-       if (pLed->BlinkingLedState == RTW_LED_ON) {
-               SwLedOn(padapter, pLed);
-               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes));
-       } else {
-               SwLedOff(padapter, pLed);
-               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes));
-       }
-
-       switch (pLed->CurrLedState) {
-       case LED_BLINK_SCAN:
-               pLed->BlinkTimes--;
-               if (pLed->BlinkTimes == 0)
-                       bStopBlinking = true;
-               if (bStopBlinking) {
-                       if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) {
-                               SwLedOff(padapter, pLed);
-                       } else if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-                               pLed->CurrLedState = RTW_LED_ON;
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                               SwLedOn(padapter, pLed);
-                               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop scan blink CurrLedState %d\n", pLed->CurrLedState));
-
-                       } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) {
-                               pLed->CurrLedState = RTW_LED_OFF;
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                               SwLedOff(padapter, pLed);
-                               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop scan blink CurrLedState %d\n", pLed->CurrLedState));
-                       }
-                       pLed->bLedScanBlinkInProgress = false;
-               } else {
-                       if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) {
-                               SwLedOff(padapter, pLed);
-                       } else {
-                                if (pLed->bLedOn)
-                                       pLed->BlinkingLedState = RTW_LED_OFF;
-                               else
-                                       pLed->BlinkingLedState = RTW_LED_ON;
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
-                       }
-               }
-               break;
-       case LED_BLINK_TXRX:
-               pLed->BlinkTimes--;
-               if (pLed->BlinkTimes == 0)
-                       bStopBlinking = true;
-               if (bStopBlinking) {
-                       if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) {
-                               SwLedOff(padapter, pLed);
-                       } else if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-                               pLed->CurrLedState = RTW_LED_ON;
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                               SwLedOn(padapter, pLed);
-                               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop CurrLedState %d\n", pLed->CurrLedState));
-                       } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) {
-                               pLed->CurrLedState = RTW_LED_OFF;
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                               SwLedOff(padapter, pLed);
-                               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop CurrLedState %d\n", pLed->CurrLedState));
-                       }
-                       pLed->bLedBlinkInProgress = false;
-               } else {
-                       if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) {
-                               SwLedOff(padapter, pLed);
-                       } else {
-                                if (pLed->bLedOn)
-                                       pLed->BlinkingLedState = RTW_LED_OFF;
-                               else
-                                       pLed->BlinkingLedState = RTW_LED_ON;
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA);
-                       }
-               }
-               break;
-       default:
-               break;
-       }
-}
-
-static void SwLedBlink3(struct LED_871x *pLed)
-{
-       struct adapter *padapter = pLed->padapter;
-       struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
-       u8 bStopBlinking = false;
-
-       /*  Change LED according to BlinkingLedState specified. */
-       if (pLed->BlinkingLedState == RTW_LED_ON) {
-               SwLedOn(padapter, pLed);
-               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes));
-       } else {
-               if (pLed->CurrLedState != LED_BLINK_WPS_STOP)
-                       SwLedOff(padapter, pLed);
-               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes));
-       }
-
-       switch (pLed->CurrLedState) {
-       case LED_BLINK_SCAN:
-               pLed->BlinkTimes--;
-               if (pLed->BlinkTimes == 0)
-                       bStopBlinking = true;
-               if (bStopBlinking) {
-                       if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) {
-                               SwLedOff(padapter, pLed);
-                       } else if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-                               pLed->CurrLedState = RTW_LED_ON;
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                               if (!pLed->bLedOn)
-                                       SwLedOn(padapter, pLed);
-                               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState));
-                       } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) {
-                               pLed->CurrLedState = RTW_LED_OFF;
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                               if (pLed->bLedOn)
-                                       SwLedOff(padapter, pLed);
-                               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState));
-                       }
-                       pLed->bLedScanBlinkInProgress = false;
-               } else {
-                       if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) {
-                               SwLedOff(padapter, pLed);
-                       } else {
-                               if (pLed->bLedOn)
-                                       pLed->BlinkingLedState = RTW_LED_OFF;
-                               else
-                                       pLed->BlinkingLedState = RTW_LED_ON;
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
-                       }
-               }
-               break;
-       case LED_BLINK_TXRX:
-               pLed->BlinkTimes--;
-               if (pLed->BlinkTimes == 0)
-                       bStopBlinking = true;
-               if (bStopBlinking) {
-                       if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) {
-                               SwLedOff(padapter, pLed);
-                       } else if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-                               pLed->CurrLedState = RTW_LED_ON;
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                               if (!pLed->bLedOn)
-                                       SwLedOn(padapter, pLed);
-                               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState));
-                       } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) {
-                               pLed->CurrLedState = RTW_LED_OFF;
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-
-                               if (pLed->bLedOn)
-                                       SwLedOff(padapter, pLed);
-                               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState));
-                       }
-                       pLed->bLedBlinkInProgress = false;
-               } else {
-                       if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) {
-                               SwLedOff(padapter, pLed);
-                       } else {
-                               if (pLed->bLedOn)
-                                       pLed->BlinkingLedState = RTW_LED_OFF;
-                               else
-                                       pLed->BlinkingLedState = RTW_LED_ON;
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA);
-                       }
-               }
-               break;
-       case LED_BLINK_WPS:
-               if (pLed->bLedOn)
-                       pLed->BlinkingLedState = RTW_LED_OFF;
-               else
-                       pLed->BlinkingLedState = RTW_LED_ON;
-               _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
-               break;
-       case LED_BLINK_WPS_STOP:        /* WPS success */
-               if (pLed->BlinkingLedState == RTW_LED_ON) {
-                       pLed->BlinkingLedState = RTW_LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA);
-                       bStopBlinking = false;
-               } else {
-                       bStopBlinking = true;
-               }
-               if (bStopBlinking) {
-                       if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) {
-                               SwLedOff(padapter, pLed);
-                       } else {
-                               pLed->CurrLedState = RTW_LED_ON;
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                               SwLedOn(padapter, pLed);
-                               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState));
-                       }
-                       pLed->bLedWPSBlinkInProgress = false;
-               }
-               break;
-       default:
-               break;
-       }
-}
-
-static void SwLedBlink4(struct LED_871x *pLed)
-{
-       struct adapter *padapter = pLed->padapter;
-       struct led_priv *ledpriv = &(padapter->ledpriv);
-       struct LED_871x *pLed1 = &(ledpriv->SwLed1);
-       u8 bStopBlinking = false;
-
-       /*  Change LED according to BlinkingLedState specified. */
-       if (pLed->BlinkingLedState == RTW_LED_ON) {
-               SwLedOn(padapter, pLed);
-               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes));
-       } else {
-               SwLedOff(padapter, pLed);
-               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes));
-       }
-
-       if (!pLed1->bLedWPSBlinkInProgress && pLed1->BlinkingLedState == LED_UNKNOWN) {
-               pLed1->BlinkingLedState = RTW_LED_OFF;
-               pLed1->CurrLedState = RTW_LED_OFF;
-               SwLedOff(padapter, pLed1);
-       }
-
-       switch (pLed->CurrLedState) {
-       case LED_BLINK_SLOWLY:
-               if (pLed->bLedOn)
-                       pLed->BlinkingLedState = RTW_LED_OFF;
-               else
-                       pLed->BlinkingLedState = RTW_LED_ON;
-               _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA);
-               break;
-       case LED_BLINK_StartToBlink:
-               if (pLed->bLedOn) {
-                       pLed->BlinkingLedState = RTW_LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL);
-               } else {
-                       pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL);
-               }
-               break;
-       case LED_BLINK_SCAN:
-               pLed->BlinkTimes--;
-               if (pLed->BlinkTimes == 0)
-                       bStopBlinking = false;
-               if (bStopBlinking) {
-                       if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) {
-                               SwLedOff(padapter, pLed);
-                       } else {
-                               pLed->bLedNoLinkBlinkInProgress = false;
-                               pLed->CurrLedState = LED_BLINK_SLOWLY;
-                               if (pLed->bLedOn)
-                                       pLed->BlinkingLedState = RTW_LED_OFF;
-                               else
-                                       pLed->BlinkingLedState = RTW_LED_ON;
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA);
-                       }
-                       pLed->bLedScanBlinkInProgress = false;
-               } else {
-                       if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) {
-                               SwLedOff(padapter, pLed);
-                       } else {
-                                if (pLed->bLedOn)
-                                       pLed->BlinkingLedState = RTW_LED_OFF;
-                               else
-                                       pLed->BlinkingLedState = RTW_LED_ON;
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
-                       }
-               }
-               break;
-       case LED_BLINK_TXRX:
-               pLed->BlinkTimes--;
-               if (pLed->BlinkTimes == 0)
-                       bStopBlinking = true;
-               if (bStopBlinking) {
-                       if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) {
-                               SwLedOff(padapter, pLed);
-                       } else {
-                               pLed->bLedNoLinkBlinkInProgress = true;
-                               pLed->CurrLedState = LED_BLINK_SLOWLY;
-                               if (pLed->bLedOn)
-                                       pLed->BlinkingLedState = RTW_LED_OFF;
-                               else
-                                       pLed->BlinkingLedState = RTW_LED_ON;
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA);
-                       }
-                       pLed->bLedBlinkInProgress = false;
-               } else {
-                       if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) {
-                               SwLedOff(padapter, pLed);
-                       } else {
-                                if (pLed->bLedOn)
-                                       pLed->BlinkingLedState = RTW_LED_OFF;
-                               else
-                                       pLed->BlinkingLedState = RTW_LED_ON;
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA);
-                       }
-               }
-               break;
-       case LED_BLINK_WPS:
-               if (pLed->bLedOn) {
-                       pLed->BlinkingLedState = RTW_LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL);
-               } else {
-                       pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL);
-               }
-               break;
-       case LED_BLINK_WPS_STOP:        /* WPS authentication fail */
-               if (pLed->bLedOn)
-                       pLed->BlinkingLedState = RTW_LED_OFF;
-               else
-                       pLed->BlinkingLedState = RTW_LED_ON;
-
-               _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL);
-               break;
-       case LED_BLINK_WPS_STOP_OVERLAP:        /* WPS session overlap */
-               pLed->BlinkTimes--;
-               if (pLed->BlinkTimes == 0) {
-                       if (pLed->bLedOn)
-                               pLed->BlinkTimes = 1;
-                       else
-                               bStopBlinking = true;
-               }
-
-               if (bStopBlinking) {
-                       pLed->BlinkTimes = 10;
-                       pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA);
-               } else {
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL);
-               }
-               break;
-       default:
-               break;
-       }
-       RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("SwLedBlink4 CurrLedState %d\n", pLed->CurrLedState));
-}
-
-static void SwLedBlink5(struct LED_871x *pLed)
-{
-       struct adapter *padapter = pLed->padapter;
-       u8 bStopBlinking = false;
-
-       /*  Change LED according to BlinkingLedState specified. */
-       if (pLed->BlinkingLedState == RTW_LED_ON) {
-               SwLedOn(padapter, pLed);
-               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes));
-       } else {
-               SwLedOff(padapter, pLed);
-               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes));
-       }
-
-       switch (pLed->CurrLedState) {
-       case LED_BLINK_SCAN:
-               pLed->BlinkTimes--;
-               if (pLed->BlinkTimes == 0)
-                       bStopBlinking = true;
-
-               if (bStopBlinking) {
-                       if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) {
-                               pLed->CurrLedState = RTW_LED_OFF;
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                               if (pLed->bLedOn)
-                                       SwLedOff(padapter, pLed);
-                       } else {
-                                       pLed->CurrLedState = RTW_LED_ON;
-                                       pLed->BlinkingLedState = RTW_LED_ON;
-                                       if (!pLed->bLedOn)
-                                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA);
-                       }
-
-                       pLed->bLedScanBlinkInProgress = false;
-               } else {
-                       if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) {
-                               SwLedOff(padapter, pLed);
-                       } else {
-                               if (pLed->bLedOn)
-                                       pLed->BlinkingLedState = RTW_LED_OFF;
-                               else
-                                       pLed->BlinkingLedState = RTW_LED_ON;
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
-                       }
-               }
-               break;
-       case LED_BLINK_TXRX:
-               pLed->BlinkTimes--;
-               if (pLed->BlinkTimes == 0)
-                       bStopBlinking = true;
-
-               if (bStopBlinking) {
-                       if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) {
-                               pLed->CurrLedState = RTW_LED_OFF;
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                               if (pLed->bLedOn)
-                                       SwLedOff(padapter, pLed);
-                       } else {
-                               pLed->CurrLedState = RTW_LED_ON;
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                               if (!pLed->bLedOn)
-                                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA);
-                       }
-
-                       pLed->bLedBlinkInProgress = false;
-               } else {
-                       if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) {
-                               SwLedOff(padapter, pLed);
-                       } else {
-                                if (pLed->bLedOn)
-                                       pLed->BlinkingLedState = RTW_LED_OFF;
-                               else
-                                       pLed->BlinkingLedState = RTW_LED_ON;
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA);
-                       }
-               }
-               break;
-
-       default:
-               break;
-       }
-
-       RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("SwLedBlink5 CurrLedState %d\n", pLed->CurrLedState));
-}
-
-static void SwLedBlink6(struct LED_871x *pLed)
-{
-       struct adapter *padapter = pLed->padapter;
-
-       /*  Change LED according to BlinkingLedState specified. */
-       if (pLed->BlinkingLedState == RTW_LED_ON) {
-               SwLedOn(padapter, pLed);
-               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes));
-       } else {
-               SwLedOff(padapter, pLed);
-               RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes));
-       }
-
-       RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("<==== blink6\n"));
-}
-
- /* ALPHA, added by chiyoko, 20090106 */
-static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAction)
-{
-       struct led_priv *ledpriv = &(padapter->ledpriv);
-       struct LED_871x *pLed = &(ledpriv->SwLed0);
-       struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
-
-       switch (LedAction) {
-       case LED_CTL_POWER_ON:
-       case LED_CTL_START_TO_LINK:
-       case LED_CTL_NO_LINK:
-               if (!pLed->bLedNoLinkBlinkInProgress) {
-                       if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed))
-                               return;
-                       if (pLed->bLedLinkBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedLinkBlinkInProgress = false;
-                       }
-                       if (pLed->bLedBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedBlinkInProgress = false;
-                       }
-
-                       pLed->bLedNoLinkBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_SLOWLY;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA);
-               }
-               break;
-       case LED_CTL_LINK:
-               if (!pLed->bLedLinkBlinkInProgress) {
-                       if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed))
-                               return;
-                       if (pLed->bLedNoLinkBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedNoLinkBlinkInProgress = false;
-                       }
-                       if (pLed->bLedBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedBlinkInProgress = false;
-                       }
-                       pLed->bLedLinkBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_NORMAL;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA);
-               }
-               break;
-       case LED_CTL_SITE_SURVEY:
-               if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) {
-                       ;
-               } else if (!pLed->bLedScanBlinkInProgress) {
-                       if (IS_LED_WPS_BLINKING(pLed))
-                               return;
-                       if (pLed->bLedNoLinkBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedNoLinkBlinkInProgress = false;
-                       }
-                       if (pLed->bLedLinkBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                                pLed->bLedLinkBlinkInProgress = false;
-                       }
-                       if (pLed->bLedBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedBlinkInProgress = false;
-                       }
-                       pLed->bLedScanBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_SCAN;
-                       pLed->BlinkTimes = 24;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
-                }
-               break;
-       case LED_CTL_TX:
-       case LED_CTL_RX:
-               if (!pLed->bLedBlinkInProgress) {
-                       if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed))
-                               return;
-                       if (pLed->bLedNoLinkBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedNoLinkBlinkInProgress = false;
-                       }
-                       if (pLed->bLedLinkBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedLinkBlinkInProgress = false;
-                       }
-                       pLed->bLedBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_TXRX;
-                       pLed->BlinkTimes = 2;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA);
-               }
-               break;
-       case LED_CTL_START_WPS: /* wait until xinpin finish */
-       case LED_CTL_START_WPS_BOTTON:
-                if (!pLed->bLedWPSBlinkInProgress) {
-                       if (pLed->bLedNoLinkBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedNoLinkBlinkInProgress = false;
-                       }
-                       if (pLed->bLedLinkBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                                pLed->bLedLinkBlinkInProgress = false;
-                       }
-                       if (pLed->bLedBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedBlinkInProgress = false;
-                       }
-                       if (pLed->bLedScanBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedScanBlinkInProgress = false;
-                       }
-                       pLed->bLedWPSBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_WPS;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
-                }
-               break;
-       case LED_CTL_STOP_WPS:
-               if (pLed->bLedNoLinkBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedNoLinkBlinkInProgress = false;
-               }
-               if (pLed->bLedLinkBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                        pLed->bLedLinkBlinkInProgress = false;
-               }
-               if (pLed->bLedBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedBlinkInProgress = false;
-               }
-               if (pLed->bLedScanBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedScanBlinkInProgress = false;
-               }
-               if (pLed->bLedWPSBlinkInProgress)
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-               else
-                       pLed->bLedWPSBlinkInProgress = true;
-               pLed->CurrLedState = LED_BLINK_WPS_STOP;
-               if (pLed->bLedOn) {
-                       pLed->BlinkingLedState = RTW_LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA);
-               } else {
-                       pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), 0);
-               }
-               break;
-       case LED_CTL_STOP_WPS_FAIL:
-               if (pLed->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedWPSBlinkInProgress = false;
-               }
-               pLed->bLedNoLinkBlinkInProgress = true;
-               pLed->CurrLedState = LED_BLINK_SLOWLY;
-               if (pLed->bLedOn)
-                       pLed->BlinkingLedState = RTW_LED_OFF;
-               else
-                       pLed->BlinkingLedState = RTW_LED_ON;
-               _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA);
-               break;
-       case LED_CTL_POWER_OFF:
-               pLed->CurrLedState = RTW_LED_OFF;
-               pLed->BlinkingLedState = RTW_LED_OFF;
-               if (pLed->bLedNoLinkBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedNoLinkBlinkInProgress = false;
-               }
-               if (pLed->bLedLinkBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedLinkBlinkInProgress = false;
-               }
-               if (pLed->bLedBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedBlinkInProgress = false;
-               }
-               if (pLed->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedWPSBlinkInProgress = false;
-               }
-               if (pLed->bLedScanBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedScanBlinkInProgress = false;
-               }
-               SwLedOff(padapter, pLed);
-               break;
-       default:
-               break;
-       }
-
-       RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState));
-}
-
- /* Arcadyan/Sitecom , added by chiyoko, 20090216 */
-static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAction)
-{
-       struct led_priv *ledpriv = &(padapter->ledpriv);
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct LED_871x *pLed = &(ledpriv->SwLed0);
-
-       switch (LedAction) {
-       case LED_CTL_SITE_SURVEY:
-               if (pmlmepriv->LinkDetectInfo.bBusyTraffic) {
-               } else if (!pLed->bLedScanBlinkInProgress) {
-                       if (IS_LED_WPS_BLINKING(pLed))
-                               return;
-
-                       if (pLed->bLedBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedBlinkInProgress = false;
-                       }
-                       pLed->bLedScanBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_SCAN;
-                       pLed->BlinkTimes = 24;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
-                }
-               break;
-       case LED_CTL_TX:
-       case LED_CTL_RX:
-               if ((!pLed->bLedBlinkInProgress) && (check_fwstate(pmlmepriv, _FW_LINKED))) {
-                       if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed))
-                               return;
-                       pLed->bLedBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_TXRX;
-                       pLed->BlinkTimes = 2;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA);
-               }
-               break;
-       case LED_CTL_LINK:
-               pLed->CurrLedState = RTW_LED_ON;
-               pLed->BlinkingLedState = RTW_LED_ON;
-               if (pLed->bLedBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedBlinkInProgress = false;
-               }
-               if (pLed->bLedScanBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedScanBlinkInProgress = false;
-               }
-               _set_timer(&(pLed->BlinkTimer), 0);
-               break;
-       case LED_CTL_START_WPS: /* wait until xinpin finish */
-       case LED_CTL_START_WPS_BOTTON:
-               if (!pLed->bLedWPSBlinkInProgress) {
-                       if (pLed->bLedBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedBlinkInProgress = false;
-                       }
-                       if (pLed->bLedScanBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedScanBlinkInProgress = false;
-                       }
-                       pLed->bLedWPSBlinkInProgress = true;
-                       pLed->CurrLedState = RTW_LED_ON;
-                       pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), 0);
-                }
-               break;
-       case LED_CTL_STOP_WPS:
-               pLed->bLedWPSBlinkInProgress = false;
-               if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) {
-                       SwLedOff(padapter, pLed);
-               } else {
-                       pLed->CurrLedState = RTW_LED_ON;
-                       pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), 0);
-                       RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState));
-               }
-               break;
-       case LED_CTL_STOP_WPS_FAIL:
-               pLed->bLedWPSBlinkInProgress = false;
-               if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) {
-                       SwLedOff(padapter, pLed);
-               } else {
-                       pLed->CurrLedState = RTW_LED_OFF;
-                       pLed->BlinkingLedState = RTW_LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer), 0);
-                       RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState));
-               }
-               break;
-       case LED_CTL_START_TO_LINK:
-       case LED_CTL_NO_LINK:
-               if (!IS_LED_BLINKING(pLed)) {
-                       pLed->CurrLedState = RTW_LED_OFF;
-                       pLed->BlinkingLedState = RTW_LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer), 0);
-               }
-               break;
-       case LED_CTL_POWER_OFF:
-               pLed->CurrLedState = RTW_LED_OFF;
-               pLed->BlinkingLedState = RTW_LED_OFF;
-               if (pLed->bLedBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedBlinkInProgress = false;
-               }
-               if (pLed->bLedScanBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedScanBlinkInProgress = false;
-               }
-               if (pLed->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedWPSBlinkInProgress = false;
-               }
-
-               _set_timer(&(pLed->BlinkTimer), 0);
-               break;
-       default:
-               break;
-       }
-
-       RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState));
-}
-
-  /* COREGA, added by chiyoko, 20090316 */
- static void SwLedControlMode3(struct adapter *padapter, enum LED_CTL_MODE LedAction)
-{
-       struct led_priv *ledpriv = &(padapter->ledpriv);
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct LED_871x *pLed = &(ledpriv->SwLed0);
-
-       switch (LedAction) {
-       case LED_CTL_SITE_SURVEY:
-               if (pmlmepriv->LinkDetectInfo.bBusyTraffic) {
-               } else if (!pLed->bLedScanBlinkInProgress) {
-                       if (IS_LED_WPS_BLINKING(pLed))
-                               return;
-
-                       if (pLed->bLedBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedBlinkInProgress = false;
-                       }
-                       pLed->bLedScanBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_SCAN;
-                       pLed->BlinkTimes = 24;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
-               }
-               break;
-       case LED_CTL_TX:
-       case LED_CTL_RX:
-               if ((!pLed->bLedBlinkInProgress) && (check_fwstate(pmlmepriv, _FW_LINKED))) {
-                       if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed))
-                               return;
-                       pLed->bLedBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_TXRX;
-                       pLed->BlinkTimes = 2;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA);
-               }
-               break;
-       case LED_CTL_LINK:
-               if (IS_LED_WPS_BLINKING(pLed))
-                       return;
-               pLed->CurrLedState = RTW_LED_ON;
-               pLed->BlinkingLedState = RTW_LED_ON;
-               if (pLed->bLedBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedBlinkInProgress = false;
-               }
-               if (pLed->bLedScanBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedScanBlinkInProgress = false;
-               }
-
-               _set_timer(&(pLed->BlinkTimer), 0);
-               break;
-       case LED_CTL_START_WPS: /* wait until xinpin finish */
-       case LED_CTL_START_WPS_BOTTON:
-               if (!pLed->bLedWPSBlinkInProgress) {
-                       if (pLed->bLedBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedBlinkInProgress = false;
-                       }
-                       if (pLed->bLedScanBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedScanBlinkInProgress = false;
-                       }
-                       pLed->bLedWPSBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_WPS;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
-               }
-               break;
-       case LED_CTL_STOP_WPS:
-               if (pLed->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedWPSBlinkInProgress = false;
-               } else {
-                       pLed->bLedWPSBlinkInProgress = true;
-               }
-
-               pLed->CurrLedState = LED_BLINK_WPS_STOP;
-               if (pLed->bLedOn) {
-                       pLed->BlinkingLedState = RTW_LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA);
-               } else {
-                       pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), 0);
-               }
-               break;
-       case LED_CTL_STOP_WPS_FAIL:
-               if (pLed->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedWPSBlinkInProgress = false;
-               }
-               pLed->CurrLedState = RTW_LED_OFF;
-               pLed->BlinkingLedState = RTW_LED_OFF;
-               _set_timer(&(pLed->BlinkTimer), 0);
-               break;
-       case LED_CTL_START_TO_LINK:
-       case LED_CTL_NO_LINK:
-               if (!IS_LED_BLINKING(pLed)) {
-                       pLed->CurrLedState = RTW_LED_OFF;
-                       pLed->BlinkingLedState = RTW_LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer), 0);
-               }
-               break;
-       case LED_CTL_POWER_OFF:
-               pLed->CurrLedState = RTW_LED_OFF;
-               pLed->BlinkingLedState = RTW_LED_OFF;
-               if (pLed->bLedBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedBlinkInProgress = false;
-               }
-               if (pLed->bLedScanBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedScanBlinkInProgress = false;
+               } else {
+                       if (pLed->bLedOn)
+                               pLed->BlinkingLedState = RTW_LED_OFF;
+                       else
+                               pLed->BlinkingLedState = RTW_LED_ON;
+                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA);
                }
-               if (pLed->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+               break;
+       case LED_BLINK_WPS:
+               if (pLed->bLedOn)
+                       pLed->BlinkingLedState = RTW_LED_OFF;
+               else
+                       pLed->BlinkingLedState = RTW_LED_ON;
+               _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
+               break;
+       case LED_BLINK_WPS_STOP:        /* WPS success */
+               if (pLed->BlinkingLedState == RTW_LED_ON)
+                       bStopBlinking = false;
+               else
+                       bStopBlinking = true;
+
+               if (bStopBlinking) {
+                       pLed->bLedLinkBlinkInProgress = true;
+                       pLed->CurrLedState = LED_BLINK_NORMAL;
+                       if (pLed->bLedOn)
+                               pLed->BlinkingLedState = RTW_LED_OFF;
+                       else
+                               pLed->BlinkingLedState = RTW_LED_ON;
+                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA);
+                       RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState));
+
                        pLed->bLedWPSBlinkInProgress = false;
+               } else {
+                       pLed->BlinkingLedState = RTW_LED_OFF;
+                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA);
                }
-
-               _set_timer(&(pLed->BlinkTimer), 0);
                break;
        default:
                break;
        }
-       RT_TRACE(_module_rtl8712_led_c_, _drv_info_,
-                ("CurrLedState %d\n", pLed->CurrLedState));
 }
 
- /* Edimax-Belkin, added by chiyoko, 20090413 */
-static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAction)
+ /* ALPHA, added by chiyoko, 20090106 */
+static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAction)
 {
        struct led_priv *ledpriv = &(padapter->ledpriv);
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct LED_871x *pLed = &(ledpriv->SwLed0);
-       struct LED_871x *pLed1 = &(ledpriv->SwLed1);
+       struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
 
        switch (LedAction) {
+       case LED_CTL_POWER_ON:
        case LED_CTL_START_TO_LINK:
-               if (pLed1->bLedWPSBlinkInProgress) {
-                       pLed1->bLedWPSBlinkInProgress = false;
-                       _cancel_timer_ex(&(pLed1->BlinkTimer));
-
-                       pLed1->BlinkingLedState = RTW_LED_OFF;
-                       pLed1->CurrLedState = RTW_LED_OFF;
-
-                       if (pLed1->bLedOn)
-                               _set_timer(&(pLed->BlinkTimer), 0);
-               }
-
-               if (!pLed->bLedStartToLinkBlinkInProgress) {
+       case LED_CTL_NO_LINK:
+               if (!pLed->bLedNoLinkBlinkInProgress) {
                        if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed))
                                return;
-                       if (pLed->bLedBlinkInProgress) {
+                       if (pLed->bLedLinkBlinkInProgress) {
                                _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedBlinkInProgress = false;
+                               pLed->bLedLinkBlinkInProgress = false;
                        }
-                       if (pLed->bLedNoLinkBlinkInProgress) {
+                       if (pLed->bLedBlinkInProgress) {
                                _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedNoLinkBlinkInProgress = false;
+                               pLed->bLedBlinkInProgress = false;
                        }
 
-                       pLed->bLedStartToLinkBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_StartToBlink;
-                       if (pLed->bLedOn) {
+                       pLed->bLedNoLinkBlinkInProgress = true;
+                       pLed->CurrLedState = LED_BLINK_SLOWLY;
+                       if (pLed->bLedOn)
                                pLed->BlinkingLedState = RTW_LED_OFF;
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL);
-                       } else {
+                       else
                                pLed->BlinkingLedState = RTW_LED_ON;
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL);
-                       }
+                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA);
                }
                break;
        case LED_CTL_LINK:
-       case LED_CTL_NO_LINK:
-               /* LED1 settings */
-               if (LedAction == LED_CTL_LINK) {
-                       if (pLed1->bLedWPSBlinkInProgress) {
-                               pLed1->bLedWPSBlinkInProgress = false;
-                               _cancel_timer_ex(&(pLed1->BlinkTimer));
-
-                               pLed1->BlinkingLedState = RTW_LED_OFF;
-                               pLed1->CurrLedState = RTW_LED_OFF;
-
-                               if (pLed1->bLedOn)
-                                       _set_timer(&(pLed->BlinkTimer), 0);
-                       }
-               }
-
-               if (!pLed->bLedNoLinkBlinkInProgress) {
+               if (!pLed->bLedLinkBlinkInProgress) {
                        if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed))
                                return;
+                       if (pLed->bLedNoLinkBlinkInProgress) {
+                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               pLed->bLedNoLinkBlinkInProgress = false;
+                       }
                        if (pLed->bLedBlinkInProgress) {
                                _cancel_timer_ex(&(pLed->BlinkTimer));
                                pLed->bLedBlinkInProgress = false;
                        }
-
-                       pLed->bLedNoLinkBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_SLOWLY;
+                       pLed->bLedLinkBlinkInProgress = true;
+                       pLed->CurrLedState = LED_BLINK_NORMAL;
                        if (pLed->bLedOn)
                                pLed->BlinkingLedState = RTW_LED_OFF;
                        else
                                pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA);
                }
                break;
        case LED_CTL_SITE_SURVEY:
                if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) {
+                       ;
                } else if (!pLed->bLedScanBlinkInProgress) {
                        if (IS_LED_WPS_BLINKING(pLed))
                                return;
-
                        if (pLed->bLedNoLinkBlinkInProgress) {
                                _cancel_timer_ex(&(pLed->BlinkTimer));
                                pLed->bLedNoLinkBlinkInProgress = false;
                        }
+                       if (pLed->bLedLinkBlinkInProgress) {
+                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                                pLed->bLedLinkBlinkInProgress = false;
+                       }
                        if (pLed->bLedBlinkInProgress) {
                                _cancel_timer_ex(&(pLed->BlinkTimer));
                                pLed->bLedBlinkInProgress = false;
@@ -1334,7 +315,7 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct
                        else
                                pLed->BlinkingLedState = RTW_LED_ON;
                        _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
-               }
+                }
                break;
        case LED_CTL_TX:
        case LED_CTL_RX:
@@ -1345,6 +326,10 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct
                                _cancel_timer_ex(&(pLed->BlinkTimer));
                                pLed->bLedNoLinkBlinkInProgress = false;
                        }
+                       if (pLed->bLedLinkBlinkInProgress) {
+                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               pLed->bLedLinkBlinkInProgress = false;
+                       }
                        pLed->bLedBlinkInProgress = true;
                        pLed->CurrLedState = LED_BLINK_TXRX;
                        pLed->BlinkTimes = 2;
@@ -1357,22 +342,15 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct
                break;
        case LED_CTL_START_WPS: /* wait until xinpin finish */
        case LED_CTL_START_WPS_BOTTON:
-               if (pLed1->bLedWPSBlinkInProgress) {
-                       pLed1->bLedWPSBlinkInProgress = false;
-                       _cancel_timer_ex(&(pLed1->BlinkTimer));
-
-                       pLed1->BlinkingLedState = RTW_LED_OFF;
-                       pLed1->CurrLedState = RTW_LED_OFF;
-
-                       if (pLed1->bLedOn)
-                               _set_timer(&(pLed->BlinkTimer), 0);
-               }
-
-               if (!pLed->bLedWPSBlinkInProgress) {
+                if (!pLed->bLedWPSBlinkInProgress) {
                        if (pLed->bLedNoLinkBlinkInProgress) {
                                _cancel_timer_ex(&(pLed->BlinkTimer));
                                pLed->bLedNoLinkBlinkInProgress = false;
                        }
+                       if (pLed->bLedLinkBlinkInProgress) {
+                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                                pLed->bLedLinkBlinkInProgress = false;
+                       }
                        if (pLed->bLedBlinkInProgress) {
                                _cancel_timer_ex(&(pLed->BlinkTimer));
                                pLed->bLedBlinkInProgress = false;
@@ -1383,56 +361,44 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct
                        }
                        pLed->bLedWPSBlinkInProgress = true;
                        pLed->CurrLedState = LED_BLINK_WPS;
-                       if (pLed->bLedOn) {
+                       if (pLed->bLedOn)
                                pLed->BlinkingLedState = RTW_LED_OFF;
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL);
-                       } else {
+                       else
                                pLed->BlinkingLedState = RTW_LED_ON;
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL);
-                       }
-               }
+                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
+                }
                break;
-       case LED_CTL_STOP_WPS:  /* WPS connect success */
-               if (pLed->bLedWPSBlinkInProgress) {
+       case LED_CTL_STOP_WPS:
+               if (pLed->bLedNoLinkBlinkInProgress) {
                        _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedWPSBlinkInProgress = false;
+                       pLed->bLedNoLinkBlinkInProgress = false;
                }
-
-               pLed->bLedNoLinkBlinkInProgress = true;
-               pLed->CurrLedState = LED_BLINK_SLOWLY;
-               if (pLed->bLedOn)
-                       pLed->BlinkingLedState = RTW_LED_OFF;
-               else
-                       pLed->BlinkingLedState = RTW_LED_ON;
-               _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA);
-
-               break;
-       case LED_CTL_STOP_WPS_FAIL:             /* WPS authentication fail */
-               if (pLed->bLedWPSBlinkInProgress) {
+               if (pLed->bLedLinkBlinkInProgress) {
                        _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedWPSBlinkInProgress = false;
+                        pLed->bLedLinkBlinkInProgress = false;
                }
-               pLed->bLedNoLinkBlinkInProgress = true;
-               pLed->CurrLedState = LED_BLINK_SLOWLY;
-               if (pLed->bLedOn)
-                       pLed->BlinkingLedState = RTW_LED_OFF;
+               if (pLed->bLedBlinkInProgress) {
+                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       pLed->bLedBlinkInProgress = false;
+               }
+               if (pLed->bLedScanBlinkInProgress) {
+                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       pLed->bLedScanBlinkInProgress = false;
+               }
+               if (pLed->bLedWPSBlinkInProgress)
+                       _cancel_timer_ex(&(pLed->BlinkTimer));
                else
+                       pLed->bLedWPSBlinkInProgress = true;
+               pLed->CurrLedState = LED_BLINK_WPS_STOP;
+               if (pLed->bLedOn) {
+                       pLed->BlinkingLedState = RTW_LED_OFF;
+                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA);
+               } else {
                        pLed->BlinkingLedState = RTW_LED_ON;
-               _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA);
-
-               /* LED1 settings */
-               if (pLed1->bLedWPSBlinkInProgress)
-                       _cancel_timer_ex(&(pLed1->BlinkTimer));
-               else
-                       pLed1->bLedWPSBlinkInProgress = true;
-               pLed1->CurrLedState = LED_BLINK_WPS_STOP;
-               if (pLed1->bLedOn)
-                       pLed1->BlinkingLedState = RTW_LED_OFF;
-               else
-                       pLed1->BlinkingLedState = RTW_LED_ON;
-               _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL);
+                       _set_timer(&(pLed->BlinkTimer), 0);
+               }
                break;
-       case LED_CTL_STOP_WPS_FAIL_OVERLAP:     /* WPS session overlap */
+       case LED_CTL_STOP_WPS_FAIL:
                if (pLed->bLedWPSBlinkInProgress) {
                        _cancel_timer_ex(&(pLed->BlinkTimer));
                        pLed->bLedWPSBlinkInProgress = false;
@@ -1444,24 +410,10 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct
                else
                        pLed->BlinkingLedState = RTW_LED_ON;
                _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA);
-
-               /* LED1 settings */
-               if (pLed1->bLedWPSBlinkInProgress)
-                       _cancel_timer_ex(&(pLed1->BlinkTimer));
-               else
-                       pLed1->bLedWPSBlinkInProgress = true;
-               pLed1->CurrLedState = LED_BLINK_WPS_STOP_OVERLAP;
-               pLed1->BlinkTimes = 10;
-               if (pLed1->bLedOn)
-                       pLed1->BlinkingLedState = RTW_LED_OFF;
-               else
-                       pLed1->BlinkingLedState = RTW_LED_ON;
-               _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL);
                break;
        case LED_CTL_POWER_OFF:
                pLed->CurrLedState = RTW_LED_OFF;
                pLed->BlinkingLedState = RTW_LED_OFF;
-
                if (pLed->bLedNoLinkBlinkInProgress) {
                        _cancel_timer_ex(&(pLed->BlinkTimer));
                        pLed->bLedNoLinkBlinkInProgress = false;
@@ -1482,87 +434,6 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct
                        _cancel_timer_ex(&(pLed->BlinkTimer));
                        pLed->bLedScanBlinkInProgress = false;
                }
-               if (pLed->bLedStartToLinkBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedStartToLinkBlinkInProgress = false;
-               }
-               if (pLed1->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed1->BlinkTimer));
-                       pLed1->bLedWPSBlinkInProgress = false;
-               }
-               pLed1->BlinkingLedState = LED_UNKNOWN;
-               SwLedOff(padapter, pLed);
-               SwLedOff(padapter, pLed1);
-               break;
-       default:
-               break;
-       }
-
-       RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState));
-}
-
-
-
- /* Sercomm-Belkin, added by chiyoko, 20090415 */
-static void
-SwLedControlMode5(
-       struct adapter *padapter,
-       enum LED_CTL_MODE LedAction
-)
-{
-       struct led_priv *ledpriv = &(padapter->ledpriv);
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct LED_871x *pLed = &(ledpriv->SwLed0);
-
-       switch (LedAction) {
-       case LED_CTL_POWER_ON:
-       case LED_CTL_NO_LINK:
-       case LED_CTL_LINK:      /* solid blue */
-               pLed->CurrLedState = RTW_LED_ON;
-               pLed->BlinkingLedState = RTW_LED_ON;
-
-               _set_timer(&(pLed->BlinkTimer), 0);
-               break;
-       case LED_CTL_SITE_SURVEY:
-               if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) {
-               } else if (!pLed->bLedScanBlinkInProgress) {
-                       if (pLed->bLedBlinkInProgress) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
-                               pLed->bLedBlinkInProgress = false;
-                       }
-                       pLed->bLedScanBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_SCAN;
-                       pLed->BlinkTimes = 24;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
-               }
-               break;
-       case LED_CTL_TX:
-       case LED_CTL_RX:
-               if (!pLed->bLedBlinkInProgress) {
-                       if (pLed->CurrLedState == LED_BLINK_SCAN)
-                               return;
-                       pLed->bLedBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_TXRX;
-                       pLed->BlinkTimes = 2;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA);
-               }
-               break;
-       case LED_CTL_POWER_OFF:
-               pLed->CurrLedState = RTW_LED_OFF;
-               pLed->BlinkingLedState = RTW_LED_OFF;
-
-               if (pLed->bLedBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
-                       pLed->bLedBlinkInProgress = false;
-               }
                SwLedOff(padapter, pLed);
                break;
        default:
@@ -1572,73 +443,18 @@ SwLedControlMode5(
        RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState));
 }
 
- /* WNC-Corega, added by chiyoko, 20090902 */
-static void
-SwLedControlMode6(
-       struct adapter *padapter,
-       enum LED_CTL_MODE LedAction
-)
-{
-       struct led_priv *ledpriv = &(padapter->ledpriv);
-       struct LED_871x *pLed0 = &(ledpriv->SwLed0);
-
-       switch (LedAction) {
-       case LED_CTL_POWER_ON:
-       case LED_CTL_LINK:
-       case LED_CTL_NO_LINK:
-               _cancel_timer_ex(&(pLed0->BlinkTimer));
-               pLed0->CurrLedState = RTW_LED_ON;
-               pLed0->BlinkingLedState = RTW_LED_ON;
-               _set_timer(&(pLed0->BlinkTimer), 0);
-               break;
-       case LED_CTL_POWER_OFF:
-               SwLedOff(padapter, pLed0);
-               break;
-       default:
-               break;
-       }
-
-       RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("ledcontrol 6 Led %d\n", pLed0->CurrLedState));
-}
-
 /*  */
 /*     Description: */
 /*             Handler function of LED Blinking. */
-/*             We dispatch acture LED blink action according to LedStrategy. */
 /*  */
 void BlinkHandler(struct LED_871x *pLed)
 {
        struct adapter *padapter = pLed->padapter;
-       struct led_priv *ledpriv = &(padapter->ledpriv);
 
        if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped))
                return;
 
-       switch (ledpriv->LedStrategy) {
-       case SW_LED_MODE0:
-               SwLedBlink(pLed);
-               break;
-       case SW_LED_MODE1:
-               SwLedBlink1(pLed);
-               break;
-       case SW_LED_MODE2:
-               SwLedBlink2(pLed);
-               break;
-       case SW_LED_MODE3:
-               SwLedBlink3(pLed);
-               break;
-       case SW_LED_MODE4:
-               SwLedBlink4(pLed);
-               break;
-       case SW_LED_MODE5:
-               SwLedBlink5(pLed);
-               break;
-       case SW_LED_MODE6:
-               SwLedBlink6(pLed);
-               break;
-       default:
-               break;
-       }
+       SwLedBlink1(pLed);
 }
 
 void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction)
@@ -1661,32 +477,5 @@ void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction)
             LedAction == LED_CTL_POWER_ON))
                return;
 
-       switch (ledpriv->LedStrategy) {
-       case SW_LED_MODE0:
-               break;
-       case SW_LED_MODE1:
-               SwLedControlMode1(padapter, LedAction);
-               break;
-       case SW_LED_MODE2:
-               SwLedControlMode2(padapter, LedAction);
-               break;
-       case SW_LED_MODE3:
-               SwLedControlMode3(padapter, LedAction);
-               break;
-       case SW_LED_MODE4:
-               SwLedControlMode4(padapter, LedAction);
-               break;
-       case SW_LED_MODE5:
-               SwLedControlMode5(padapter, LedAction);
-               break;
-       case SW_LED_MODE6:
-               SwLedControlMode6(padapter, LedAction);
-               break;
-       default:
-               break;
-       }
-
-       RT_TRACE(_module_rtl8712_led_c_, _drv_info_,
-                ("LedStrategy:%d, LedAction %d\n",
-                ledpriv->LedStrategy, LedAction));
+       SwLedControlMode1(padapter, LedAction);
 }
index 9425c4991ccd60ffdf20cae60609db883c052e43..0a15f8cf0d366c305be78e483e684a646eae574e 100644 (file)
@@ -1505,9 +1505,9 @@ static void find_phase_handler(struct adapter *padapter)
 
        rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH);
 
-        spin_lock_bh(&pmlmepriv->lock);
-        rtw_sitesurvey_cmd(padapter, &ssid, 1, NULL, 0);
-        spin_unlock_bh(&pmlmepriv->lock);
+       spin_lock_bh(&pmlmepriv->lock);
+       rtw_sitesurvey_cmd(padapter, &ssid, 1, NULL, 0);
+       spin_unlock_bh(&pmlmepriv->lock);
 }
 
 void p2p_concurrent_handler(struct adapter *padapter);
index e305d43ebd0656210d111403ad1ef5ab7a818f87..5c1d2d28eb9d09991acd3457db3c2a1adbd34fc1 100644 (file)
@@ -1871,7 +1871,7 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor
                        return true;
 
                prhdr = container_of(plist, struct recv_frame, list);
-               pattrib = &prhdr->attrib;
+               pattrib = &prhdr->attrib;
                preorder_ctrl->indicate_seq = pattrib->seq_num;
        }
 
index 3dd90599fd4be2b54e98cf824dbfc5959ccd171e..6c9e9a16b2e93f9755e0f52f03697af76ea11a6a 100644 (file)
@@ -1599,13 +1599,18 @@ int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_l
        pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len);
        if (pIE == NULL)
                return _FAIL;
+       if (ie_len > NDIS_802_11_LENGTH_RATES_EX)
+               return _FAIL;
 
        memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len);
        supportRateNum = ie_len;
 
        pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, _EXT_SUPPORTEDRATES_IE_, &ie_len, var_ie_len);
-       if (pIE)
+       if (pIE) {
+               if (supportRateNum + ie_len > NDIS_802_11_LENGTH_RATES_EX)
+                       return _FAIL;
                memcpy((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + supportRateNum), pIE->data, ie_len);
+       }
 
        return _SUCCESS;
 }
index 08dfd94163e6b078e5c9643e8b7921d621e0ee72..77dce584f0db29bf154ff54cbc2b9a6b0c8ba4bb 100644 (file)
@@ -35,16 +35,7 @@ void SwLedOn(struct adapter *padapter, struct LED_871x *pLed)
        if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
                return;
        LedCfg = rtw_read8(padapter, REG_LEDCFG2);
-       switch (pLed->LedPin) {
-       case LED_PIN_LED0:
-               rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0)|BIT5|BIT6); /*  SW control led0 on. */
-               break;
-       case LED_PIN_LED1:
-               rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x0f)|BIT5); /*  SW control led1 on. */
-               break;
-       default:
-               break;
-       }
+       rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0)|BIT5|BIT6); /*  SW control led0 on. */
        pLed->bLedOn = true;
 }
 
@@ -60,25 +51,15 @@ void SwLedOff(struct adapter *padapter, struct LED_871x *pLed)
 
        LedCfg = rtw_read8(padapter, REG_LEDCFG2);/* 0x4E */
 
-       switch (pLed->LedPin) {
-       case LED_PIN_LED0:
-               if (pHalData->bLedOpenDrain) {
+       if (pHalData->bLedOpenDrain) {
                        /*  Open-drain arrangement for controlling the LED) */
-                       LedCfg &= 0x90; /*  Set to software control. */
-                       rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3));
-                       LedCfg = rtw_read8(padapter, REG_MAC_PINMUX_CFG);
-                       LedCfg &= 0xFE;
-                       rtw_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg);
-               } else {
-                       rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3|BIT5|BIT6));
-               }
-               break;
-       case LED_PIN_LED1:
-               LedCfg &= 0x0f; /*  Set to software control. */
+               LedCfg &= 0x90; /*  Set to software control. */
                rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3));
-               break;
-       default:
-               break;
+               LedCfg = rtw_read8(padapter, REG_MAC_PINMUX_CFG);
+               LedCfg &= 0xFE;
+               rtw_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg);
+       } else {
+               rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3|BIT5|BIT6));
        }
 exit:
        pLed->bLedOn = false;
@@ -92,12 +73,13 @@ exit:
 void rtl8188eu_InitSwLeds(struct adapter *padapter)
 {
        struct led_priv *pledpriv = &(padapter->ledpriv);
+       struct hal_data_8188e   *haldata = GET_HAL_DATA(padapter);
 
+       pledpriv->bRegUseLed = true;
        pledpriv->LedControlHandler = LedControl8188eu;
+       haldata->bLedOpenDrain = true;
 
-       InitLed871x(padapter, &(pledpriv->SwLed0), LED_PIN_LED0);
-
-       InitLed871x(padapter, &(pledpriv->SwLed1), LED_PIN_LED1);
+       InitLed871x(padapter, &(pledpriv->SwLed0));
 }
 
 /*     Description: */
@@ -107,5 +89,4 @@ void rtl8188eu_DeInitSwLeds(struct adapter *padapter)
        struct led_priv *ledpriv = &(padapter->ledpriv);
 
        DeInitLed871x(&(ledpriv->SwLed0));
-       DeInitLed871x(&(ledpriv->SwLed1));
 }
index c92067f0ef1551dd66496fc58ebd9e4a81a76373..617e4c68dfa11ead17a2dbf32fb400ccfce52b44 100644 (file)
@@ -424,18 +424,6 @@ static void _InitBeaconMaxError(struct adapter *Adapter, bool              InfraMode)
 {
 }
 
-static void _InitHWLed(struct adapter *Adapter)
-{
-       struct led_priv *pledpriv = &(Adapter->ledpriv);
-
-       if (pledpriv->LedStrategy != HW_LED)
-               return;
-
-/*  HW led control */
-/*  to do .... */
-/* must consider cases of antenna diversity/ commbo card/solo card/mini card */
-}
-
 static void _InitRDGSetting(struct adapter *Adapter)
 {
        rtw_write8(Adapter, REG_RD_CTRL, 0xFF);
@@ -870,8 +858,6 @@ static u32 rtl8188eu_hal_init(struct adapter *Adapter)
        rtw_write16(Adapter, REG_PKT_VO_VI_LIFE_TIME, 0x0400);  /*  unit: 256us. 256ms */
        rtw_write16(Adapter, REG_PKT_BE_BK_LIFE_TIME, 0x0400);  /*  unit: 256us. 256ms */
 
-       _InitHWLed(Adapter);
-
        /* Keep RfRegChnlVal for later use. */
        haldata->RfRegChnlVal[0] = PHY_QueryRFReg(Adapter, (enum rf_radio_path)0, RF_CHNLBW, bRFRegOffsetMask);
        haldata->RfRegChnlVal[1] = PHY_QueryRFReg(Adapter, (enum rf_radio_path)1, RF_CHNLBW, bRFRegOffsetMask);
@@ -1129,16 +1115,6 @@ static unsigned int rtl8188eu_inirp_deinit(struct adapter *Adapter)
 /*     EEPROM/EFUSE Content Parsing */
 /*  */
 /*  */
-static void _ReadLEDSetting(struct adapter *Adapter, u8 *PROMContent, bool AutoloadFail)
-{
-       struct led_priv *pledpriv = &(Adapter->ledpriv);
-       struct hal_data_8188e   *haldata = GET_HAL_DATA(Adapter);
-
-       pledpriv->bRegUseLed = true;
-       pledpriv->LedStrategy = SW_LED_MODE1;
-       haldata->bLedOpenDrain = true;/*  Support Open-drain arrangement for controlling the LED. */
-}
-
 static void Hal_EfuseParsePIDVID_8188EU(struct adapter *adapt, u8 *hwinfo, bool AutoLoadFail)
 {
        struct hal_data_8188e   *haldata = GET_HAL_DATA(adapt);
@@ -1215,8 +1191,6 @@ readAdapterInfo_8188EU(
        /*  */
        Hal_InitChannelPlan(adapt);
        Hal_CustomizeByCustomerID_8188EU(adapt);
-
-       _ReadLEDSetting(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag);
 }
 
 static void _ReadPROMContent(
index 936c196699af6b8525ad11f9be1e71a4de0b393b..10cc1a1bcab94a933377b0af98dc1a84dfc59a18 100644 (file)
@@ -31,7 +31,6 @@
 
 #include <osdep_service.h>
 #include <wlan_bssdef.h>
-#include <drv_types_linux.h>
 #include <rtw_ht.h>
 #include <rtw_cmd.h>
 #include <rtw_xmit.h>
diff --git a/drivers/staging/rtl8188eu/include/drv_types_linux.h b/drivers/staging/rtl8188eu/include/drv_types_linux.h
deleted file mode 100644 (file)
index 812b744..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/******************************************************************************
- *
- * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- *
- ******************************************************************************/
-#ifndef __DRV_TYPES_LINUX_H__
-#define __DRV_TYPES_LINUX_H__
-
-
-#endif
index 3d347029ff7ab013e2617b5e650ce41750fc24fa..66467f711a59956b2c501f1d9b550e210016cdbb 100644 (file)
@@ -807,7 +807,6 @@ u8 rtw_chk_hi_queue_cmd(struct adapter *padapter);
 u8 rtw_set_ch_cmd(struct adapter *padapter, u8 ch, u8 bw, u8 ch_offset,
                  u8 enqueue);
 u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue);
-u8 rtw_led_blink_cmd(struct adapter *padapter, struct LED_871x *pLed);
 u8 rtw_set_csa_cmd(struct adapter *padapter, u8 new_ch_no);
 u8 rtw_tdls_cmd(struct adapter *padapter, u8 *addr, u8 option);
 
index 0da4e27a70faedce1e7e4a453ea2ae8292a9e0c7..c5194b620da4919b6c7c1e01c1180049201885aa 100644 (file)
 #include <osdep_service.h>
 #include <drv_types.h>
 
-#define MSECS(t)        (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000)
-
-#define LED_BLINK_NORMAL_INTERVAL              100
-#define LED_BLINK_SLOWLY_INTERVAL              200
-#define LED_BLINK_LONG_INTERVAL                        400
-
 #define LED_BLINK_NO_LINK_INTERVAL_ALPHA       1000
 #define LED_BLINK_LINK_INTERVAL_ALPHA          500     /* 500 */
 #define LED_BLINK_SCAN_INTERVAL_ALPHA          180     /* 150 */
 #define LED_BLINK_FASTER_INTERVAL_ALPHA                50
 #define LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA    5000
 
-#define LED_BLINK_NORMAL_INTERVAL_NETTRONIX    100
-#define LED_BLINK_SLOWLY_INTERVAL_NETTRONIX    2000
-
-#define LED_BLINK_SLOWLY_INTERVAL_PORNET       1000
-#define LED_BLINK_NORMAL_INTERVAL_PORNET       100
-
-#define LED_BLINK_FAST_INTERVAL_BITLAND                30
-
-/*  060403, rcnjko: Customized for AzWave. */
-#define LED_CM2_BLINK_ON_INTERVAL              250
-#define LED_CM2_BLINK_OFF_INTERVAL             4750
-
-#define LED_CM8_BLINK_INTERVAL                 500     /* for QMI */
-#define LED_CM8_BLINK_OFF_INTERVAL             3750    /* for QMI */
-
-/*  080124, lanhsin: Customized for RunTop */
-#define LED_RunTop_BLINK_INTERVAL              300
-
-/*  060421, rcnjko: Customized for Sercomm Printer Server case. */
-#define LED_CM3_BLINK_INTERVAL                 1500
-
 enum LED_CTL_MODE {
-       LED_CTL_POWER_ON = 1,
-       LED_CTL_LINK = 2,
-       LED_CTL_NO_LINK = 3,
-       LED_CTL_TX = 4,
-       LED_CTL_RX = 5,
-       LED_CTL_SITE_SURVEY = 6,
-       LED_CTL_POWER_OFF = 7,
-       LED_CTL_START_TO_LINK = 8,
-       LED_CTL_START_WPS = 9,
-       LED_CTL_STOP_WPS = 10,
-       LED_CTL_START_WPS_BOTTON = 11, /* added for runtop */
-       LED_CTL_STOP_WPS_FAIL = 12, /* added for ALPHA */
-       LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, /* added for BELKIN */
-       LED_CTL_CONNECTION_NO_TRANSFER = 14,
+       LED_CTL_POWER_ON,
+       LED_CTL_LINK,
+       LED_CTL_NO_LINK,
+       LED_CTL_TX,
+       LED_CTL_RX ,
+       LED_CTL_SITE_SURVEY,
+       LED_CTL_POWER_OFF,
+       LED_CTL_START_TO_LINK,
+       LED_CTL_START_WPS,
+       LED_CTL_STOP_WPS,
+       LED_CTL_START_WPS_BOTTON,
+       LED_CTL_STOP_WPS_FAIL
 };
 
 enum LED_STATE_871x {
-       LED_UNKNOWN = 0,
-       RTW_LED_ON = 1,
-       RTW_LED_OFF = 2,
-       LED_BLINK_NORMAL = 3,
-       LED_BLINK_SLOWLY = 4,
-       LED_BLINK_POWER_ON = 5,
-       LED_BLINK_SCAN = 6, /*  LED is blinking during scanning period,
-                            * the # of times to blink is depend on time
-                            * for scanning. */
-       LED_BLINK_NO_LINK = 7, /*  LED is blinking during no link state. */
-       LED_BLINK_StartToBlink = 8,/*  Customzied for Sercomm Printer
-                                   * Server case */
-       LED_BLINK_TXRX = 9,
-       LED_BLINK_WPS = 10,     /*  LED is blinkg during WPS communication */
-       LED_BLINK_WPS_STOP = 11,        /* for ALPHA */
-       LED_BLINK_WPS_STOP_OVERLAP = 12,        /* for BELKIN */
-       LED_BLINK_RUNTOP = 13, /*  Customized for RunTop */
-       LED_BLINK_CAMEO = 14,
-       LED_BLINK_XAVI = 15,
-       LED_BLINK_ALWAYS_ON = 16,
-};
-
-enum LED_PIN_871x {
-       LED_PIN_NULL = 0,
-       LED_PIN_LED0 = 1,
-       LED_PIN_LED1 = 2,
-       LED_PIN_LED2 = 3,
-       LED_PIN_GPIO0 = 4,
+       LED_UNKNOWN,
+       RTW_LED_ON,
+       RTW_LED_OFF,
+       LED_BLINK_NORMAL,
+       LED_BLINK_SLOWLY,
+       LED_BLINK_POWER_ON,
+       LED_BLINK_SCAN,
+       LED_BLINK_TXRX,
+       LED_BLINK_WPS,
+       LED_BLINK_WPS_STOP
 };
 
 struct LED_871x {
        struct adapter *padapter;
 
-       enum LED_PIN_871x       LedPin; /* Identify how to implement this
-                                        * SW led. */
        enum LED_STATE_871x     CurrLedState; /*  Current LED state. */
        enum LED_STATE_871x     BlinkingLedState; /*  Next state for blinking,
                                   * either RTW_LED_ON or RTW_LED_OFF are. */
@@ -139,34 +90,11 @@ struct LED_871x {
        ((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS_STOP || \
        ((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress)
 
-#define IS_LED_BLINKING(_LED_871x)                                     \
-       (((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress ||      \
-       ((struct LED_871x *)_LED_871x)->bLedScanBlinkInProgress)
-
-/*  LED customization. */
-
-enum LED_STRATEGY_871x {
-       SW_LED_MODE0 = 0, /* SW control 1 LED via GPIO0. It is default option.*/
-       SW_LED_MODE1 = 1, /*  2 LEDs, through LED0 and LED1. For ALPHA. */
-       SW_LED_MODE2 = 2, /*  SW control 1 LED via GPIO0, customized for AzWave
-                          * 8187 minicard. */
-       SW_LED_MODE3 = 3, /*  SW control 1 LED via GPIO0, customized for Sercomm
-                          * Printer Server case. */
-       SW_LED_MODE4 = 4, /* for Edimax / Belkin */
-       SW_LED_MODE5 = 5, /* for Sercomm / Belkin */
-       SW_LED_MODE6 = 6, /* for 88CU minicard, porting from ce SW_LED_MODE7 */
-       HW_LED = 50, /*  HW control 2 LEDs, LED0 and LED1 (there are 4
-                     * different control modes, see MAC.CONFIG1 for details.)*/
-       LED_ST_NONE = 99,
-};
-
 void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE      LedAction);
 
 struct led_priv{
        /* add for led control */
        struct LED_871x                 SwLed0;
-       struct LED_871x                 SwLed1;
-       enum LED_STRATEGY_871x  LedStrategy;
        u8      bRegUseLed;
        void (*LedControlHandler)(struct adapter *padapter,
                                  enum LED_CTL_MODE LedAction);
@@ -184,8 +112,7 @@ void BlinkWorkItemCallback(struct work_struct *work);
 
 void ResetLedStatus(struct LED_871x *pLed);
 
-void InitLed871x(struct adapter *padapter, struct LED_871x *pLed,
-                enum LED_PIN_871x LedPin);
+void InitLed871x(struct adapter *padapter, struct LED_871x *pLed);
 
 void DeInitLed871x(struct LED_871x *pLed);
 
index 2ff622ba24f0b46eaa8008ce816c13cfa90b5606..48bc5fca996d1ab872c4e68059838757fa3c9c5b 100644 (file)
@@ -32,10 +32,6 @@ struct pkt_file {
        size_t buf_len;
 };
 
-extern int rtw_ht_enable;
-extern int rtw_cbw40_enable;
-extern int rtw_ampdu_enable;/* for enable tx_ampdu */
-
 #define NR_XMITFRAME   256
 
 struct xmit_priv;
index b225d1c072109503e89b595fcf1fd3756651851f..9edb8e880ae8aad4ae02539a3368aa25426401c2 100644 (file)
@@ -84,9 +84,9 @@ static int rtw_uapsd_acbe_en;
 static int rtw_uapsd_acvi_en;
 static int rtw_uapsd_acvo_en;
 
-int rtw_ht_enable = 1;
-int rtw_cbw40_enable = 3; /*  0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */
-int rtw_ampdu_enable = 1;/* for enable tx_ampdu */
+static int rtw_ht_enable = 1;
+static int rtw_cbw40_enable = 3; /*  0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */
+static int rtw_ampdu_enable = 1;/* for enable tx_ampdu */
 static int rtw_rx_stbc = 1;/*  0: disable, bit(0):enable 2.4g, bit(1):enable 5g, default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */
 static int rtw_ampdu_amsdu;/*  0: disabled, 1:enabled, 2:auto */
 
index 2e49cd583212a70dc3bf8bf1ed22eb5d12d0e068..49a4ce44ada640bf9240c9ba3aba202916ecf90b 100644 (file)
@@ -62,10 +62,6 @@ static struct usb_device_id rtw_usb_id_tbl[] = {
 
 MODULE_DEVICE_TABLE(usb, rtw_usb_id_tbl);
 
-static struct specific_device_id specific_device_id_tbl[] = {
-       {}              /* empty table for now */
-};
-
 struct rtw_usb_drv {
        struct usb_driver usbdrv;
        int drv_registered;
@@ -360,28 +356,6 @@ static void rtw_dev_unload(struct adapter *padapter)
        RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-rtw_dev_unload\n"));
 }
 
-static void process_spec_devid(const struct usb_device_id *pdid)
-{
-       u16 vid, pid;
-       u32 flags;
-       int i;
-       int num = sizeof(specific_device_id_tbl) /
-                 sizeof(struct specific_device_id);
-
-       for (i = 0; i < num; i++) {
-               vid = specific_device_id_tbl[i].idVendor;
-               pid = specific_device_id_tbl[i].idProduct;
-               flags = specific_device_id_tbl[i].flags;
-
-               if ((pdid->idVendor == vid) && (pdid->idProduct == pid) &&
-                   (flags&SPEC_DEV_ID_DISABLE_HT)) {
-                       rtw_ht_enable = 0;
-                       rtw_cbw40_enable = 0;
-                       rtw_ampdu_enable = 0;
-               }
-       }
-}
-
 int rtw_hw_suspend(struct adapter *padapter)
 {
        struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
@@ -781,9 +755,6 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device
 
        RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_init\n"));
 
-       /* step 0. */
-       process_spec_devid(pdid);
-
        /* Initialize dvobj_priv */
        dvobj = usb_dvobj_init(pusb_intf);
        if (dvobj == NULL) {
index ad82bc348a75cc89d680196a330e41cec9429c05..282e293da18f03a85cfccabf14ccbf89d6847d2d 100644 (file)
@@ -5,4 +5,5 @@ config RTL8192E
        select WIRELESS_EXT
        select WEXT_PRIV
        select CRYPTO
+       select FW_LOADER
        ---help---
index 5f10e4075d39b6cdb8fc25c39d051f974fd54b88..79d86b9e80099d537a7013588230abe7805f4459 100644 (file)
@@ -373,7 +373,7 @@ u32 cmpk_message_handle_rx(struct net_device *dev,
                default:
 
                        RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():"
-                                "unknow CMD Element\n");
+                                "unknown CMD Element\n");
                        return 1;
                }
 
index abcd22f8fdda576e55854869b3e93e9731639825..1a95d1f87f9469c27612a394508ae34364f0242c 100644 (file)
@@ -228,13 +228,6 @@ bool init_firmware(struct net_device *dev)
        struct r8192_priv *priv = rtllib_priv(dev);
        bool                    rt_status = true;
 
-       u8      *firmware_img_buf[3] = { &Rtl8192PciEFwBootArray[0],
-                                        &Rtl8192PciEFwMainArray[0],
-                                        &Rtl8192PciEFwDataArray[0]};
-
-       u32     firmware_img_len[3] = { sizeof(Rtl8192PciEFwBootArray),
-                                       sizeof(Rtl8192PciEFwMainArray),
-                                       sizeof(Rtl8192PciEFwDataArray)};
        u32     file_length = 0;
        u8      *mapped_file = NULL;
        u8      init_step = 0;
@@ -257,77 +250,55 @@ bool init_firmware(struct net_device *dev)
                         " firmware state\n");
        }
 
-       priv->firmware_source = FW_SOURCE_IMG_FILE;
        for (init_step = starting_state; init_step <= FW_INIT_STEP2_DATA;
             init_step++) {
                if (rst_opt == OPT_SYSTEM_RESET) {
-                       switch (priv->firmware_source) {
-                       case FW_SOURCE_IMG_FILE:
-                       {
-                               if (pfirmware->firmware_buf_size[init_step] == 0) {
-                                       const char *fw_name[3] = {
-                                                       RTL8192E_BOOT_IMG_FW,
-                                                       RTL8192E_MAIN_IMG_FW,
-                                                       RTL8192E_DATA_IMG_FW
-                                       };
-                                       const struct firmware   *fw_entry;
-                                       int rc;
-                                       rc = request_firmware(&fw_entry,
-                                        fw_name[init_step], &priv->pdev->dev);
-                                       if (rc < 0) {
-                                               RT_TRACE(COMP_FIRMWARE, "request firm"
-                                                "ware fail!\n");
-                                               goto download_firmware_fail;
-                                       }
-                                       if (fw_entry->size >
+                       if (pfirmware->firmware_buf_size[init_step] == 0) {
+                               const char *fw_name[3] = {
+                                       RTL8192E_BOOT_IMG_FW,
+                                       RTL8192E_MAIN_IMG_FW,
+                                       RTL8192E_DATA_IMG_FW
+                               };
+                               const struct firmware *fw_entry;
+                               int rc;
+                               rc = request_firmware(&fw_entry,
+                                                     fw_name[init_step],
+                                                     &priv->pdev->dev);
+                               if (rc < 0) {
+                                       RT_TRACE(COMP_FIRMWARE, "request firmware fail!\n");
+                                       goto download_firmware_fail;
+                               }
+                               if (fw_entry->size >
                                    sizeof(pfirmware->firmware_buf[init_step])) {
-                                               RT_TRACE(COMP_FIRMWARE, "img file size "
+                                       RT_TRACE(COMP_FIRMWARE, "img file size "
                                                 "exceed the container struct "
                                                 "buffer fail!\n");
-                                               goto download_firmware_fail;
-                                       }
+                                       goto download_firmware_fail;
+                               }
 
-                                       if (init_step != FW_INIT_STEP1_MAIN) {
-                                               memcpy(pfirmware->firmware_buf[init_step],
+                               if (init_step != FW_INIT_STEP1_MAIN) {
+                                       memcpy(pfirmware->firmware_buf[init_step],
                                               fw_entry->data, fw_entry->size);
-                                               pfirmware->firmware_buf_size[init_step] =
-                                              fw_entry->size;
+                                       pfirmware->firmware_buf_size[init_step] =
+                                               fw_entry->size;
 
-                                       } else {
-                                               memset(pfirmware->firmware_buf[init_step],
+                               } else {
+                                       memset(pfirmware->firmware_buf[init_step],
                                               0, 128);
-                                               memcpy(&pfirmware->firmware_buf[init_step][128],
+                                       memcpy(&pfirmware->firmware_buf[init_step][128],
                                               fw_entry->data, fw_entry->size);
-                                               pfirmware->firmware_buf_size[init_step] =
-                                                        fw_entry->size + 128;
-                                       }
-
-                                       if (rst_opt == OPT_SYSTEM_RESET)
-                                               release_firmware(fw_entry);
+                                       pfirmware->firmware_buf_size[init_step] =
+                                               fw_entry->size + 128;
                                }
-                               mapped_file = pfirmware->firmware_buf[init_step];
-                               file_length = pfirmware->firmware_buf_size[init_step];
-                               break;
-                       }
-                       case FW_SOURCE_HEADER_FILE:
-                               mapped_file =  firmware_img_buf[init_step];
-                               file_length  = firmware_img_len[init_step];
-                               if (init_step == FW_INIT_STEP2_DATA) {
-                                       memcpy(pfirmware->firmware_buf[init_step], mapped_file, file_length);
-                                       pfirmware->firmware_buf_size[init_step] = file_length;
-                               }
-                               break;
 
-                       default:
-                               break;
+                               if (rst_opt == OPT_SYSTEM_RESET)
+                                       release_firmware(fw_entry);
                        }
-
-
-               } else if (rst_opt == OPT_FIRMWARE_RESET) {
-                       mapped_file = pfirmware->firmware_buf[init_step];
-                       file_length = pfirmware->firmware_buf_size[init_step];
                }
 
+               mapped_file = pfirmware->firmware_buf[init_step];
+               file_length = pfirmware->firmware_buf_size[init_step];
+
                rt_status = fw_download_code(dev, mapped_file, file_length);
                if (!rt_status) {
                        goto download_firmware_fail;
index 06d6abc8345ceea9f8d1fc0b5af3866a3726a356..94fa16b4993dfef689a483d376a304c4662e3a51 100644 (file)
@@ -43,11 +43,6 @@ enum desc_packet_type {
        DESC_PACKET_TYPE_NORMAL = 1,
 };
 
-enum firmware_source {
-       FW_SOURCE_IMG_FILE = 0,
-       FW_SOURCE_HEADER_FILE = 1,
-};
-
 enum firmware_status {
        FW_STATUS_0_INIT = 0,
        FW_STATUS_1_MOVE_BOOT_CODE = 1,
index 08e7dbb6694ba7fe2411ee3e19875f99a6d43e49..6767b5965c17568cfaddf6498f06d53f494c0df4 100644 (file)
 
 #include "r8192E_hwimg.h"
 
-u8 Rtl8192PciEFwBootArray[BootArrayLengthPciE] = {
-0x10,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x3c,0x08,0xbf,0xc0,0x25,0x08,0x00,0x08,
-0x3c,0x09,0xb0,0x03,0xad,0x28,0x00,0x20,0x40,0x80,0x68,0x00,0x00,0x00,0x00,0x00,
-0x3c,0x0a,0xd0,0x00,0x40,0x8a,0x60,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x01,
-0x25,0x08,0xa8,0x04,0x24,0x09,0x00,0x01,0x3c,0x01,0x7f,0xff,0x34,0x21,0xff,0xff,
-0x01,0x01,0x50,0x24,0x00,0x09,0x48,0x40,0x35,0x29,0x00,0x01,0x01,0x2a,0x10,0x2b,
-0x14,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x3c,0x0a,0x00,0x00,0x25,0x4a,0x00,0x00,
-0x4c,0x8a,0x00,0x00,0x4c,0x89,0x08,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x01,
-0x25,0x08,0xa8,0x04,0x3c,0x01,0x80,0x00,0x01,0x21,0x48,0x25,0x3c,0x0a,0xbf,0xc0,
-0x25,0x4a,0x00,0x7c,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0xad,0x00,0x00,0x00,
-0x21,0x08,0x00,0x04,0x01,0x09,0x10,0x2b,0x14,0x40,0xff,0xf8,0x00,0x00,0x00,0x00,
-0x3c,0x08,0x80,0x01,0x25,0x08,0x7f,0xff,0x24,0x09,0x00,0x01,0x3c,0x01,0x7f,0xff,
-0x34,0x21,0xff,0xff,0x01,0x01,0x50,0x24,0x00,0x09,0x48,0x40,0x35,0x29,0x00,0x01,
-0x01,0x2a,0x10,0x2b,0x14,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x01,
-0x25,0x4a,0x00,0x00,0x3c,0x01,0x7f,0xff,0x34,0x21,0xff,0xff,0x01,0x41,0x50,0x24,
-0x3c,0x09,0x00,0x01,0x35,0x29,0x7f,0xff,0x4c,0x8a,0x20,0x00,0x4c,0x89,0x28,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x08,0x04,0x10,
-0x00,0x00,0x00,0x00,0x40,0x88,0xa0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x3c,0x08,0xbf,0xc0,0x00,0x00,0x00,0x00,0x8d,0x09,0x00,0x00,0x00,0x00,0x00,0x00,
-0x3c,0x0a,0xbf,0xc0,0x25,0x4a,0x01,0x20,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,
-0x3c,0x08,0xb0,0x03,0x8d,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x35,0x29,0x00,0x10,
-0xad,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x00,0x25,0x08,0x4b,0x94,
-0x01,0x00,0x00,0x08,0x00,0x00,0x00,0x00,};
-
-u8 Rtl8192PciEFwMainArray[MainArrayLengthPciE] = {
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x40,0x04,0x68,0x00,0x40,0x05,0x70,0x00,0x40,0x06,0x40,0x00,0x0c,0x00,0x12,0x98,
-0x00,0x00,0x00,0x00,0x40,0x1a,0x68,0x00,0x33,0x5b,0x00,0x3c,0x17,0x60,0x00,0x09,
-0x00,0x00,0x00,0x00,0x40,0x1b,0x60,0x00,0x00,0x00,0x00,0x00,0x03,0x5b,0xd0,0x24,
-0x40,0x1a,0x70,0x00,0x03,0x40,0x00,0x08,0x42,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0xff,0x34,0x42,0xff,0xff,0x8c,0x43,0x00,0x00,
-0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x00,0xd0,
-0xac,0x62,0x00,0x00,0x00,0x00,0x20,0x21,0x27,0x85,0x8b,0x70,0x00,0x85,0x18,0x21,
-0x24,0x84,0x00,0x01,0x28,0x82,0x00,0x0a,0x14,0x40,0xff,0xfc,0xa0,0x60,0x00,0x00,
-0x27,0x82,0x8b,0x7a,0x24,0x04,0x00,0x06,0x24,0x84,0xff,0xff,0xa4,0x40,0x00,0x00,
-0x04,0x81,0xff,0xfd,0x24,0x42,0x00,0x02,0x24,0x02,0x00,0x03,0xa3,0x82,0x8b,0x70,
-0x24,0x02,0x00,0x0a,0x24,0x03,0x09,0xc4,0xa3,0x82,0x8b,0x72,0x24,0x02,0x00,0x04,
-0x24,0x04,0x00,0x01,0x24,0x05,0x00,0x02,0xa7,0x83,0x8b,0x86,0xa3,0x82,0x8b,0x78,
-0x24,0x03,0x04,0x00,0x24,0x02,0x02,0x00,0xaf,0x83,0x8b,0x8c,0xa3,0x85,0x8b,0x79,
-0xa7,0x82,0x8b,0x7a,0xa7,0x84,0x8b,0x7c,0xaf,0x84,0x8b,0x88,0xa3,0x84,0x8b,0x71,
-0xa3,0x80,0x8b,0x73,0xa3,0x80,0x8b,0x74,0xa3,0x80,0x8b,0x75,0xa3,0x84,0x8b,0x76,
-0xa3,0x85,0x8b,0x77,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,
-0x3c,0x02,0x80,0x00,0x24,0x42,0x01,0x7c,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,
-0x27,0x84,0x8b,0x98,0x00,0x00,0x10,0x21,0x24,0x42,0x00,0x01,0x00,0x02,0x16,0x00,
-0x00,0x02,0x16,0x03,0x28,0x43,0x00,0x03,0xac,0x80,0xff,0xfc,0xa0,0x80,0x00,0x00,
-0x14,0x60,0xff,0xf9,0x24,0x84,0x00,0x0c,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
-0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x01,0xc0,
-0x3c,0x08,0xb0,0x03,0xac,0x62,0x00,0x00,0x35,0x08,0x00,0x70,0x8d,0x02,0x00,0x00,
-0x00,0xa0,0x48,0x21,0x00,0x04,0x26,0x00,0x00,0x02,0x2a,0x43,0x00,0x06,0x36,0x00,
-0x00,0x07,0x3e,0x00,0x00,0x02,0x12,0x03,0x29,0x23,0x00,0x03,0x00,0x04,0x56,0x03,
-0x00,0x06,0x36,0x03,0x00,0x07,0x3e,0x03,0x30,0x48,0x00,0x01,0x10,0x60,0x00,0x11,
-0x30,0xa5,0x00,0x07,0x24,0x02,0x00,0x02,0x00,0x49,0x10,0x23,0x00,0x45,0x10,0x07,
-0x30,0x42,0x00,0x01,0x10,0x40,0x00,0x66,0x00,0x00,0x00,0x00,0x8f,0xa2,0x00,0x10,
-0x00,0x00,0x00,0x00,0x00,0x02,0x21,0x43,0x11,0x00,0x00,0x10,0x00,0x07,0x20,0x0b,
-0x15,0x20,0x00,0x06,0x24,0x02,0x00,0x01,0x3c,0x02,0xb0,0x05,0x34,0x42,0x01,0x20,
-0xa4,0x44,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x11,0x22,0x00,0x04,
-0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,0x08,0x00,0x00,0x94,0x34,0x42,0x01,0x24,
-0x3c,0x02,0xb0,0x05,0x08,0x00,0x00,0x94,0x34,0x42,0x01,0x22,0x15,0x20,0x00,0x54,
-0x24,0x02,0x00,0x01,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x74,0x90,0x43,0x00,0x00,
-0x00,0x00,0x00,0x00,0xaf,0x83,0x8b,0x94,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x70,
-0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x6b,0x00,0x08,0x11,0x60,0x00,0x18,
-0x00,0x09,0x28,0x40,0x00,0x00,0x40,0x21,0x27,0x85,0x8b,0x90,0x8c,0xa3,0x00,0x00,
-0x8c,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x62,0x38,0x23,0x00,0x43,0x10,0x2a,
-0x10,0x40,0x00,0x3d,0x00,0x00,0x00,0x00,0xac,0xa7,0x00,0x00,0x25,0x02,0x00,0x01,
-0x00,0x02,0x16,0x00,0x00,0x02,0x46,0x03,0x29,0x03,0x00,0x03,0x14,0x60,0xff,0xf3,
-0x24,0xa5,0x00,0x0c,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x70,0x90,0x62,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x4b,0x10,0x23,0xa0,0x62,0x00,0x00,0x00,0x09,0x28,0x40,
-0x00,0xa9,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x8b,0x98,0x00,0x0a,0x20,0x0b,
-0x00,0x43,0x18,0x21,0x10,0xc0,0x00,0x05,0x00,0x00,0x38,0x21,0x80,0x62,0x00,0x01,
-0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x80,0x62,0x00,0x00,
-0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,0x00,0xa9,0x10,0x21,0x24,0x07,0x00,0x01,
-0x00,0xa9,0x10,0x21,0x00,0x02,0x30,0x80,0x27,0x82,0x8b,0x98,0xa0,0x67,0x00,0x01,
-0x00,0xc2,0x38,0x21,0x80,0xe3,0x00,0x01,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x07,
-0x00,0x00,0x00,0x00,0x27,0x83,0x8b,0x90,0x00,0xc3,0x18,0x21,0x8c,0x62,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x21,0xac,0x62,0x00,0x00,0x27,0x85,0x8b,0x94,
-0x27,0x82,0x8b,0x90,0x00,0xc5,0x28,0x21,0x00,0xc2,0x10,0x21,0x8c,0x43,0x00,0x00,
-0x8c,0xa4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x64,0x18,0x2a,0x14,0x60,0x00,0x03,
-0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0xa0,0xe2,0x00,0x00,0xa0,0xe0,0x00,0x00,
-0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0xb7,0xac,0xa0,0x00,0x00,
-0x11,0x22,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x7c,
-0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0xaf,0x83,0x8b,0xac,0x08,0x00,0x00,0xa7,
-0x3c,0x02,0xb0,0x03,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x78,0x90,0x43,0x00,0x00,
-0x00,0x00,0x00,0x00,0xaf,0x83,0x8b,0xa0,0x08,0x00,0x00,0xa7,0x3c,0x02,0xb0,0x03,
-0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x04,0x10,
-0x3c,0x05,0xb0,0x03,0xac,0x62,0x00,0x00,0x34,0xa5,0x00,0x70,0x8c,0xa2,0x00,0x00,
-0x90,0x84,0x00,0x08,0x3c,0x06,0xb0,0x03,0x00,0x02,0x16,0x00,0x2c,0x83,0x00,0x03,
-0x34,0xc6,0x00,0x72,0x24,0x07,0x00,0x01,0x10,0x60,0x00,0x11,0x00,0x02,0x2f,0xc2,
-0x90,0xc2,0x00,0x00,0x00,0x00,0x18,0x21,0x00,0x02,0x16,0x00,0x10,0xa7,0x00,0x09,
-0x00,0x02,0x16,0x03,0x14,0x80,0x00,0x0c,0x30,0x43,0x00,0x03,0x83,0x82,0x8b,0x98,
-0x00,0x00,0x00,0x00,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0x02,0x16,0x00,
-0x00,0x02,0x1e,0x03,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x72,0xa0,0x43,0x00,0x00,
-0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0x45,0x00,0x05,0x10,0x87,0x00,0x04,
-0x30,0x43,0x00,0x06,0x93,0x82,0x8b,0xb0,0x08,0x00,0x01,0x1f,0x00,0x43,0x10,0x21,
-0x83,0x82,0x8b,0xa4,0x00,0x00,0x00,0x00,0x00,0x02,0x10,0x40,0x08,0x00,0x01,0x1f,
-0x00,0x45,0x10,0x21,0x10,0x80,0x00,0x05,0x00,0x00,0x18,0x21,0x24,0x63,0x00,0x01,
-0x00,0x64,0x10,0x2b,0x14,0x40,0xff,0xfd,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,
-0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x04,0xe4,
-0x3c,0x04,0xb0,0x02,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,0x34,0x84,0x00,0x08,
-0x24,0x02,0x00,0x01,0xaf,0x84,0x8b,0xc0,0xa3,0x82,0x8b,0xd0,0xa7,0x80,0x8b,0xc4,
-0xa7,0x80,0x8b,0xc6,0xaf,0x80,0x8b,0xc8,0xaf,0x80,0x8b,0xcc,0x03,0xe0,0x00,0x08,
-0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,
-0x24,0x42,0x05,0x24,0x3c,0x04,0xb0,0x03,0xac,0x62,0x00,0x00,0x34,0x84,0x00,0xac,
-0x80,0xa2,0x00,0x15,0x8c,0x83,0x00,0x00,0x27,0xbd,0xff,0xf0,0x00,0x43,0x10,0x21,
-0xac,0x82,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x10,0x3c,0x02,0xb0,0x03,
-0x3c,0x03,0x80,0x00,0x34,0x42,0x00,0x20,0x24,0x63,0x05,0x5c,0x27,0xbd,0xff,0xe0,
-0xac,0x43,0x00,0x00,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x18,
-0x8f,0x90,0x8b,0xc0,0x0c,0x00,0x02,0x98,0x00,0x80,0x88,0x21,0x14,0x40,0x00,0x2a,
-0x3c,0x02,0x00,0x80,0x16,0x20,0x00,0x02,0x34,0x42,0x02,0x01,0x24,0x02,0x02,0x01,
-0xae,0x02,0x00,0x00,0x97,0x84,0x8b,0xc4,0x97,0x82,0x8b,0xc6,0x3c,0x03,0xb0,0x02,
-0x00,0x83,0x20,0x21,0x24,0x42,0x00,0x04,0xa7,0x82,0x8b,0xc6,0xa4,0x82,0x00,0x00,
-0x8f,0x84,0x8b,0xc8,0x8f,0x82,0x8b,0xc0,0x93,0x85,0x8b,0x72,0x24,0x84,0x00,0x01,
-0x24,0x42,0x00,0x04,0x24,0x03,0x8f,0xff,0x3c,0x07,0xb0,0x06,0x3c,0x06,0xb0,0x03,
-0x00,0x43,0x10,0x24,0x00,0x85,0x28,0x2a,0x34,0xe7,0x80,0x18,0xaf,0x82,0x8b,0xc0,
-0xaf,0x84,0x8b,0xc8,0x10,0xa0,0x00,0x08,0x34,0xc6,0x01,0x08,0x8f,0x83,0x8b,0xcc,
-0x8f,0x84,0x8b,0x8c,0x8c,0xc2,0x00,0x00,0x00,0x64,0x18,0x21,0x00,0x43,0x10,0x2b,
-0x14,0x40,0x00,0x09,0x00,0x00,0x00,0x00,0x8c,0xe2,0x00,0x00,0x3c,0x03,0x0f,0x00,
-0x3c,0x04,0x04,0x00,0x00,0x43,0x10,0x24,0x10,0x44,0x00,0x03,0x00,0x00,0x00,0x00,
-0x0c,0x00,0x04,0x96,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,
-0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x27,0xbd,0xff,0xd8,0x3c,0x02,0xb0,0x03,
-0x3c,0x03,0x80,0x00,0x24,0x63,0x06,0x48,0xaf,0xb0,0x00,0x10,0x34,0x42,0x00,0x20,
-0x8f,0x90,0x8b,0xc0,0xac,0x43,0x00,0x00,0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,
-0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x20,0x00,0x80,0x88,0x21,0x00,0xa0,0x90,0x21,
-0x0c,0x00,0x02,0x98,0x00,0xc0,0x98,0x21,0x24,0x07,0x8f,0xff,0x14,0x40,0x00,0x19,
-0x26,0x03,0x00,0x04,0x24,0x02,0x0e,0x03,0xae,0x02,0x00,0x00,0x00,0x67,0x80,0x24,
-0x26,0x02,0x00,0x04,0xae,0x11,0x00,0x00,0x00,0x47,0x80,0x24,0x97,0x86,0x8b,0xc4,
-0x26,0x03,0x00,0x04,0xae,0x12,0x00,0x00,0x00,0x67,0x80,0x24,0xae,0x13,0x00,0x00,
-0x8f,0x84,0x8b,0xc0,0x3c,0x02,0xb0,0x02,0x97,0x85,0x8b,0xc6,0x00,0xc2,0x30,0x21,
-0x8f,0x82,0x8b,0xc8,0x24,0x84,0x00,0x10,0x24,0xa5,0x00,0x10,0x00,0x87,0x20,0x24,
-0x24,0x42,0x00,0x01,0xa7,0x85,0x8b,0xc6,0xaf,0x84,0x8b,0xc0,0xaf,0x82,0x8b,0xc8,
-0xa4,0xc5,0x00,0x00,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,
-0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,
-0x94,0x82,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x42,0xe0,0x00,0x14,0x40,0x00,0x14,
-0x00,0x00,0x00,0x00,0x90,0x82,0x00,0x02,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfc,
-0x00,0x82,0x28,0x21,0x8c,0xa4,0x00,0x00,0x3c,0x02,0x00,0x70,0x8c,0xa6,0x00,0x08,
-0x00,0x82,0x10,0x21,0x2c,0x43,0x00,0x06,0x10,0x60,0x00,0x09,0x3c,0x03,0x80,0x01,
-0x00,0x02,0x10,0x80,0x24,0x63,0x01,0xe8,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0xaf,0x86,0x80,0x14,
-0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,
-0x8c,0xa4,0x00,0x00,0x0c,0x00,0x17,0x84,0x00,0x00,0x00,0x00,0x08,0x00,0x01,0xdc,
-0x00,0x00,0x00,0x00,0x0c,0x00,0x24,0x49,0x00,0xc0,0x20,0x21,0x08,0x00,0x01,0xdc,
-0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,0x8c,0x44,0x00,0x00,
-0x8f,0x82,0x80,0x18,0x3c,0x03,0x00,0x0f,0x34,0x63,0x42,0x40,0x00,0x43,0x10,0x21,
-0x00,0x82,0x20,0x2b,0x10,0x80,0x00,0x09,0x24,0x03,0x00,0x05,0x8f,0x82,0x83,0x60,
-0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xaf,0x82,0x83,0x60,0x10,0x43,0x00,0x03,
-0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,
-0x8c,0x63,0x01,0x08,0x24,0x02,0x00,0x01,0xa3,0x82,0x80,0x11,0xaf,0x80,0x83,0x60,
-0xaf,0x83,0x80,0x18,0x08,0x00,0x01,0xf9,0x00,0x00,0x00,0x00,0x30,0x84,0x00,0xff,
-0x14,0x80,0x00,0x2f,0x00,0x00,0x00,0x00,0x8f,0x82,0x80,0x14,0xa3,0x85,0x83,0x93,
-0x10,0x40,0x00,0x2b,0x2c,0xa2,0x00,0x04,0x14,0x40,0x00,0x06,0x00,0x05,0x10,0x40,
-0x24,0xa2,0xff,0xfc,0x2c,0x42,0x00,0x08,0x10,0x40,0x00,0x09,0x24,0xa2,0xff,0xf0,
-0x00,0x05,0x10,0x40,0x27,0x84,0x83,0x9c,0x00,0x44,0x10,0x21,0x94,0x43,0x00,0x00,
-0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01,0x03,0xe0,0x00,0x08,0xa4,0x43,0x00,0x00,
-0x2c,0x42,0x00,0x10,0x14,0x40,0x00,0x0a,0x00,0x05,0x10,0x40,0x24,0xa2,0xff,0xe0,
-0x2c,0x42,0x00,0x10,0x14,0x40,0x00,0x06,0x00,0x05,0x10,0x40,0x24,0xa2,0xff,0xd0,
-0x2c,0x42,0x00,0x10,0x10,0x40,0x00,0x09,0x24,0xa2,0xff,0xc0,0x00,0x05,0x10,0x40,
-0x27,0x84,0x83,0x9c,0x00,0x44,0x10,0x21,0x94,0x43,0xff,0xf8,0x00,0x00,0x00,0x00,
-0x24,0x63,0x00,0x01,0x03,0xe0,0x00,0x08,0xa4,0x43,0xff,0xf8,0x2c,0x42,0x00,0x10,
-0x10,0x40,0x00,0x07,0x00,0x05,0x10,0x40,0x27,0x84,0x83,0x9c,0x00,0x44,0x10,0x21,
-0x94,0x43,0xff,0xf8,0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01,0xa4,0x43,0xff,0xf8,
-0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8f,0x86,0x8b,0xc0,0x8f,0x82,0x80,0x14,
-0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x10,0x40,0x00,0x2a,0x00,0xc0,0x38,0x21,
-0x24,0x02,0x00,0x07,0x24,0x03,0xff,0x9c,0xa3,0x82,0x83,0x9b,0xa3,0x83,0x83,0x9a,
-0x27,0x8a,0x83,0x98,0x00,0x00,0x20,0x21,0x24,0x09,0x8f,0xff,0x00,0x04,0x10,0x80,
-0x00,0x4a,0x28,0x21,0x8c,0xa2,0x00,0x00,0x24,0xe3,0x00,0x04,0x24,0x88,0x00,0x01,
-0xac,0xe2,0x00,0x00,0x10,0x80,0x00,0x02,0x00,0x69,0x38,0x24,0xac,0xa0,0x00,0x00,
-0x31,0x04,0x00,0xff,0x2c,0x82,0x00,0x27,0x14,0x40,0xff,0xf5,0x00,0x04,0x10,0x80,
-0x97,0x83,0x8b,0xc6,0x97,0x85,0x8b,0xc4,0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x9c,
-0x00,0xa2,0x28,0x21,0x3c,0x04,0xb0,0x06,0xa7,0x83,0x8b,0xc6,0x34,0x84,0x80,0x18,
-0xa4,0xa3,0x00,0x00,0x8c,0x85,0x00,0x00,0x24,0x02,0x8f,0xff,0x24,0xc6,0x00,0x9c,
-0x3c,0x03,0x0f,0x00,0x00,0xc2,0x30,0x24,0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,
-0xaf,0x86,0x8b,0xc0,0x10,0xa2,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x96,
-0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,
-0x27,0xbd,0x00,0x18,0x8f,0x86,0x8b,0xc0,0x27,0xbd,0xff,0xc8,0x24,0x02,0x00,0x08,
-0x24,0x03,0x00,0x20,0xaf,0xbf,0x00,0x30,0xa3,0xa2,0x00,0x13,0xa3,0xa3,0x00,0x12,
-0xa7,0xa4,0x00,0x10,0x00,0xc0,0x28,0x21,0x27,0xa9,0x00,0x10,0x00,0x00,0x38,0x21,
-0x24,0x08,0x8f,0xff,0x00,0x07,0x10,0x80,0x00,0x49,0x10,0x21,0x8c,0x44,0x00,0x00,
-0x24,0xe3,0x00,0x01,0x30,0x67,0x00,0xff,0x24,0xa2,0x00,0x04,0x2c,0xe3,0x00,0x08,
-0xac,0xa4,0x00,0x00,0x14,0x60,0xff,0xf7,0x00,0x48,0x28,0x24,0x97,0x83,0x8b,0xc6,
-0x97,0x85,0x8b,0xc4,0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x20,0x00,0xa2,0x28,0x21,
-0x3c,0x04,0xb0,0x06,0xa7,0x83,0x8b,0xc6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00,
-0x8c,0x85,0x00,0x00,0x24,0x02,0x8f,0xff,0x24,0xc6,0x00,0x20,0x3c,0x03,0x0f,0x00,
-0x00,0xc2,0x30,0x24,0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,0xaf,0x86,0x8b,0xc0,
-0x10,0xa2,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x96,0x00,0x00,0x00,0x00,
-0x8f,0xbf,0x00,0x30,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,
-0x93,0x82,0x8b,0xd0,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x11,0x24,0x06,0x00,0x01,
-0x8f,0x82,0x8b,0xc8,0x3c,0x05,0xb0,0x06,0x3c,0x04,0xb0,0x03,0x34,0xa5,0x80,0x18,
-0x34,0x84,0x01,0x08,0x14,0x40,0x00,0x09,0x00,0x00,0x30,0x21,0x97,0x82,0x8b,0xc4,
-0x8c,0x84,0x00,0x00,0x3c,0x03,0xb0,0x02,0x00,0x43,0x10,0x21,0xaf,0x84,0x8b,0xcc,
-0xa7,0x80,0x8b,0xc6,0xac,0x40,0x00,0x00,0xac,0x40,0x00,0x04,0x8c,0xa2,0x00,0x00,
-0x03,0xe0,0x00,0x08,0x00,0xc0,0x10,0x21,0x8f,0x86,0x8b,0xc0,0x8f,0x82,0x8b,0xc8,
-0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x00,0xc0,0x40,0x21,0x14,0x40,0x00,0x0a,
-0x00,0x40,0x50,0x21,0x00,0x00,0x38,0x21,0x27,0x89,0x83,0x68,0x24,0xe2,0x00,0x01,
-0x00,0x07,0x18,0x80,0x30,0x47,0x00,0xff,0x00,0x69,0x18,0x21,0x2c,0xe2,0x00,0x0a,
-0x14,0x40,0xff,0xfa,0xac,0x60,0x00,0x00,0x3c,0x02,0x00,0x80,0x10,0x82,0x00,0x6f,
-0x00,0x00,0x00,0x00,0x97,0x82,0x83,0x6e,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,
-0xa7,0x82,0x83,0x6e,0x90,0xa3,0x00,0x15,0x97,0x82,0x83,0x70,0x00,0x03,0x1e,0x00,
-0x00,0x03,0x1e,0x03,0x00,0x43,0x10,0x21,0xa7,0x82,0x83,0x70,0x8c,0xa4,0x00,0x20,
-0x3c,0x02,0x00,0x60,0x3c,0x03,0x00,0x20,0x00,0x82,0x20,0x24,0x10,0x83,0x00,0x54,
-0x00,0x00,0x00,0x00,0x14,0x80,0x00,0x47,0x00,0x00,0x00,0x00,0x97,0x82,0x83,0x74,
-0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x83,0x74,0x84,0xa3,0x00,0x06,
-0x8f,0x82,0x83,0x84,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21,0xaf,0x82,0x83,0x84,
-0x25,0x42,0x00,0x01,0x28,0x43,0x27,0x10,0xaf,0x82,0x8b,0xc8,0x10,0x60,0x00,0x09,
-0x24,0x02,0x00,0x04,0x93,0x83,0x80,0x11,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x05,
-0x24,0x02,0x00,0x04,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,
-0x27,0xbd,0x00,0x18,0x24,0x03,0x00,0x28,0xa3,0x83,0x83,0x6a,0xa3,0x82,0x83,0x6b,
-0x90,0xa2,0x00,0x18,0x93,0x83,0x83,0x93,0x00,0x00,0x38,0x21,0x00,0x02,0x16,0x00,
-0x00,0x02,0x16,0x03,0xa7,0x82,0x83,0x7e,0xa3,0x83,0x83,0x8c,0x27,0x89,0x83,0x68,
-0x24,0x05,0x8f,0xff,0x00,0x07,0x10,0x80,0x00,0x49,0x10,0x21,0x8c,0x44,0x00,0x00,
-0x24,0xe3,0x00,0x01,0x30,0x67,0x00,0xff,0x25,0x02,0x00,0x04,0x2c,0xe3,0x00,0x0a,
-0xad,0x04,0x00,0x00,0x14,0x60,0xff,0xf7,0x00,0x45,0x40,0x24,0x97,0x83,0x8b,0xc6,
-0x97,0x85,0x8b,0xc4,0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x28,0x00,0xa2,0x28,0x21,
-0x3c,0x04,0xb0,0x06,0xa7,0x83,0x8b,0xc6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00,
-0x8c,0x85,0x00,0x00,0x24,0x02,0x8f,0xff,0x24,0xc6,0x00,0x28,0x3c,0x03,0x0f,0x00,
-0x00,0xc2,0x30,0x24,0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,0xaf,0x86,0x8b,0xc0,
-0x10,0xa2,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x96,0x00,0x00,0x00,0x00,
-0x0c,0x00,0x02,0x36,0x00,0x00,0x00,0x00,0xa3,0x80,0x80,0x11,0x08,0x00,0x02,0xe5,
-0x00,0x00,0x00,0x00,0x97,0x82,0x83,0x76,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,
-0xa7,0x82,0x83,0x76,0x84,0xa3,0x00,0x06,0x8f,0x82,0x83,0x88,0x00,0x00,0x00,0x00,
-0x00,0x43,0x10,0x21,0xaf,0x82,0x83,0x88,0x08,0x00,0x02,0xdd,0x25,0x42,0x00,0x01,
-0x97,0x82,0x83,0x72,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x83,0x72,
-0x84,0xa3,0x00,0x06,0x8f,0x82,0x83,0x80,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21,
-0xaf,0x82,0x83,0x80,0x08,0x00,0x02,0xdd,0x25,0x42,0x00,0x01,0x97,0x82,0x83,0x6c,
-0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x83,0x6c,0x08,0x00,0x02,0xc5,
-0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xd0,0xaf,0xbf,0x00,0x28,0x8c,0xa3,0x00,0x20,
-0x8f,0x8a,0x8b,0xc0,0x3c,0x02,0x00,0x10,0x00,0x62,0x10,0x24,0x00,0xa0,0x38,0x21,
-0x01,0x40,0x48,0x21,0x10,0x40,0x00,0x3d,0x00,0x80,0x28,0x21,0x8c,0xe4,0x00,0x1c,
-0x34,0xa5,0x12,0x06,0xaf,0xa5,0x00,0x10,0x8c,0x82,0x00,0x08,0x00,0x03,0x1c,0x42,
-0x30,0x63,0x00,0x30,0x00,0x02,0x13,0x02,0x30,0x42,0x00,0x40,0x00,0x43,0x10,0x25,
-0x90,0xe6,0x00,0x10,0x90,0xe4,0x00,0x13,0x94,0xe8,0x00,0x0c,0x94,0xe3,0x00,0x1a,
-0x00,0x02,0x16,0x00,0x90,0xe7,0x00,0x12,0x00,0xa2,0x28,0x25,0x24,0x02,0x12,0x34,
-0xa7,0xa2,0x00,0x1c,0x24,0x02,0x56,0x78,0xaf,0xa5,0x00,0x10,0xa3,0xa6,0x00,0x18,
-0xa3,0xa7,0x00,0x1f,0xa7,0xa3,0x00,0x1a,0xa3,0xa4,0x00,0x19,0xa7,0xa8,0x00,0x20,
-0xa7,0xa2,0x00,0x22,0x00,0x00,0x28,0x21,0x27,0xa7,0x00,0x10,0x24,0x06,0x8f,0xff,
-0x00,0x05,0x10,0x80,0x00,0x47,0x10,0x21,0x8c,0x44,0x00,0x00,0x24,0xa3,0x00,0x01,
-0x30,0x65,0x00,0xff,0x25,0x22,0x00,0x04,0x2c,0xa3,0x00,0x05,0xad,0x24,0x00,0x00,
-0x14,0x60,0xff,0xf7,0x00,0x46,0x48,0x24,0x97,0x83,0x8b,0xc6,0x97,0x85,0x8b,0xc4,
-0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x14,0x00,0xa2,0x28,0x21,0x3c,0x04,0xb0,0x06,
-0xa7,0x83,0x8b,0xc6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00,0x8c,0x85,0x00,0x00,
-0x24,0x02,0x8f,0xff,0x25,0x46,0x00,0x14,0x3c,0x03,0x0f,0x00,0x00,0xc2,0x50,0x24,
-0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,0xaf,0x8a,0x8b,0xc0,0x10,0xa2,0x00,0x03,
-0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x96,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x28,
-0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,0x3c,0x05,0xb0,0x03,
-0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xc8,0x00,0x04,0x22,0x00,0x34,0xa5,0x00,0x20,
-0x24,0x42,0x0d,0xfc,0x3c,0x03,0xb0,0x00,0xaf,0xb5,0x00,0x24,0xaf,0xb4,0x00,0x20,
-0xaf,0xb2,0x00,0x18,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x30,0x00,0x83,0x80,0x21,
-0xaf,0xb7,0x00,0x2c,0xaf,0xb6,0x00,0x28,0xaf,0xb3,0x00,0x1c,0xaf,0xb1,0x00,0x14,
-0xac,0xa2,0x00,0x00,0x8e,0x09,0x00,0x00,0x00,0x00,0x90,0x21,0x26,0x10,0x00,0x08,
-0x00,0x09,0xa6,0x02,0x12,0x80,0x00,0x13,0x00,0x00,0xa8,0x21,0x24,0x13,0x00,0x02,
-0x3c,0x16,0x00,0xff,0x3c,0x17,0xff,0x00,0x8e,0x09,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x09,0x12,0x02,0x24,0x42,0x00,0x02,0x31,0x25,0x00,0xff,0x10,0xb3,0x00,0x76,
-0x30,0x51,0x00,0xff,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x18,0x00,0x00,0x00,0x00,
-0x02,0x51,0x10,0x21,0x30,0x52,0xff,0xff,0x02,0x54,0x18,0x2b,0x14,0x60,0xff,0xf2,
-0x02,0x11,0x80,0x21,0x12,0xa0,0x00,0x0a,0x3c,0x02,0xb0,0x06,0x34,0x42,0x80,0x18,
-0x8c,0x43,0x00,0x00,0x3c,0x04,0x0f,0x00,0x3c,0x02,0x04,0x00,0x00,0x64,0x18,0x24,
-0x10,0x62,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x96,0x00,0x00,0x00,0x00,
-0x8f,0xbf,0x00,0x30,0x7b,0xb6,0x01,0x7c,0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc,
-0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0x8e,0x09,0x00,0x04,
-0x24,0x15,0x00,0x01,0x8e,0x06,0x00,0x0c,0x00,0x09,0x11,0x42,0x00,0x09,0x18,0xc2,
-0x30,0x48,0x00,0x03,0x00,0x09,0x14,0x02,0x30,0x6c,0x00,0x03,0x00,0x09,0x26,0x02,
-0x11,0x15,0x00,0x45,0x30,0x43,0x00,0x0f,0x29,0x02,0x00,0x02,0x14,0x40,0x00,0x26,
-0x00,0x00,0x00,0x00,0x11,0x13,0x00,0x0f,0x00,0x00,0x38,0x21,0x00,0x07,0x22,0x02,
-0x30,0x84,0xff,0x00,0x3c,0x03,0x00,0xff,0x00,0x07,0x2e,0x02,0x00,0x07,0x12,0x00,
-0x00,0x43,0x10,0x24,0x00,0xa4,0x28,0x25,0x00,0xa2,0x28,0x25,0x00,0x07,0x1e,0x00,
-0x00,0xa3,0x28,0x25,0x0c,0x00,0x01,0x92,0x01,0x20,0x20,0x21,0x08,0x00,0x03,0xa5,
-0x02,0x51,0x10,0x21,0x11,0x95,0x00,0x0f,0x00,0x00,0x00,0x00,0x11,0x88,0x00,0x07,
-0x00,0x00,0x00,0x00,0x00,0x04,0x10,0x80,0x27,0x83,0x8b,0x70,0x00,0x43,0x10,0x21,
-0x8c,0x47,0x00,0x18,0x08,0x00,0x03,0xcc,0x00,0x07,0x22,0x02,0x00,0x04,0x10,0x40,
-0x27,0x83,0x8b,0x78,0x00,0x43,0x10,0x21,0x94,0x47,0x00,0x02,0x08,0x00,0x03,0xcc,
-0x00,0x07,0x22,0x02,0x27,0x82,0x8b,0x70,0x00,0x82,0x10,0x21,0x90,0x47,0x00,0x00,
-0x08,0x00,0x03,0xcc,0x00,0x07,0x22,0x02,0x15,0x00,0xff,0xdc,0x00,0x00,0x38,0x21,
-0x10,0x75,0x00,0x05,0x00,0x80,0x38,0x21,0x00,0x65,0x18,0x26,0x24,0x82,0x01,0x00,
-0x00,0x00,0x38,0x21,0x00,0x43,0x38,0x0a,0x24,0x02,0x00,0x01,0x11,0x82,0x00,0x0e,
-0x3c,0x02,0xb0,0x03,0x24,0x02,0x00,0x02,0x11,0x82,0x00,0x06,0x00,0x00,0x00,0x00,
-0x3c,0x02,0xb0,0x03,0x00,0xe2,0x10,0x21,0x8c,0x47,0x00,0x00,0x08,0x00,0x03,0xcc,
-0x00,0x07,0x22,0x02,0x3c,0x02,0xb0,0x03,0x00,0xe2,0x10,0x21,0x94,0x43,0x00,0x00,
-0x08,0x00,0x03,0xcb,0x30,0x67,0xff,0xff,0x00,0xe2,0x10,0x21,0x90,0x43,0x00,0x00,
-0x08,0x00,0x03,0xcb,0x30,0x67,0x00,0xff,0x30,0x62,0x00,0x03,0x00,0x02,0x12,0x00,
-0x11,0x95,0x00,0x07,0x00,0x44,0x38,0x21,0x11,0x93,0x00,0x03,0x00,0x00,0x00,0x00,
-0x08,0x00,0x03,0xfd,0x3c,0x02,0xb0,0x0a,0x08,0x00,0x04,0x02,0x3c,0x02,0xb0,0x0a,
-0x08,0x00,0x04,0x06,0x3c,0x02,0xb0,0x0a,0x8e,0x09,0x00,0x04,0x8e,0x02,0x00,0x08,
-0x8e,0x03,0x00,0x0c,0x00,0x09,0x41,0x42,0x00,0x02,0x22,0x02,0x00,0x03,0x3a,0x02,
-0x30,0x84,0xff,0x00,0x30,0xe7,0xff,0x00,0x00,0x02,0x5e,0x02,0x00,0x02,0x32,0x00,
-0x00,0x03,0x56,0x02,0x00,0x03,0x2a,0x00,0x01,0x64,0x58,0x25,0x00,0xd6,0x30,0x24,
-0x01,0x47,0x50,0x25,0x00,0x02,0x16,0x00,0x00,0xb6,0x28,0x24,0x00,0x03,0x1e,0x00,
-0x01,0x66,0x58,0x25,0x01,0x45,0x50,0x25,0x00,0x57,0x10,0x24,0x00,0x77,0x18,0x24,
-0x01,0x62,0x38,0x25,0x01,0x43,0x30,0x25,0x00,0x09,0x10,0xc2,0x00,0x09,0x1c,0x02,
-0x31,0x08,0x00,0x03,0x30,0x4c,0x00,0x03,0x30,0x63,0x00,0x0f,0x00,0x09,0x26,0x02,
-0x00,0xe0,0x58,0x21,0x15,0x00,0x00,0x28,0x00,0xc0,0x50,0x21,0x24,0x02,0x00,0x01,
-0x10,0x62,0x00,0x06,0x00,0x80,0x28,0x21,0x24,0x02,0x00,0x03,0x14,0x62,0xff,0x69,
-0x02,0x51,0x10,0x21,0x24,0x85,0x01,0x00,0x24,0x02,0x00,0x01,0x11,0x82,0x00,0x15,
-0x24,0x02,0x00,0x02,0x11,0x82,0x00,0x0a,0x3c,0x03,0xb0,0x03,0x00,0xa3,0x18,0x21,
-0x8c,0x62,0x00,0x00,0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24,0x00,0x44,0x10,0x24,
-0x00,0x45,0x10,0x25,0xac,0x62,0x00,0x00,0x08,0x00,0x03,0xa5,0x02,0x51,0x10,0x21,
-0x00,0xa3,0x18,0x21,0x94,0x62,0x00,0x00,0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24,
-0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25,0xa4,0x62,0x00,0x00,0x08,0x00,0x03,0xa5,
-0x02,0x51,0x10,0x21,0x3c,0x03,0xb0,0x03,0x00,0xa3,0x18,0x21,0x90,0x62,0x00,0x00,
-0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24,0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25,
-0x08,0x00,0x03,0xa4,0xa0,0x62,0x00,0x00,0x24,0x02,0x00,0x01,0x11,0x02,0x00,0x21,
-0x00,0x00,0x00,0x00,0x15,0x13,0xff,0x42,0x00,0x00,0x00,0x00,0x11,0x82,0x00,0x17,
-0x00,0x00,0x00,0x00,0x11,0x88,0x00,0x0b,0x00,0x00,0x00,0x00,0x27,0x83,0x8b,0x70,
-0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x18,0x00,0x06,0x18,0x27,
-0x00,0xe6,0x28,0x24,0x00,0x43,0x10,0x24,0x00,0x45,0x10,0x25,0x08,0x00,0x03,0xa4,
-0xac,0x82,0x00,0x18,0x27,0x83,0x8b,0x78,0x00,0x04,0x20,0x40,0x00,0x83,0x20,0x21,
-0x94,0x82,0x00,0x02,0x00,0x06,0x18,0x27,0x00,0xe6,0x28,0x24,0x00,0x43,0x10,0x24,
-0x00,0x45,0x10,0x25,0x08,0x00,0x03,0xa4,0xa4,0x82,0x00,0x02,0x27,0x83,0x8b,0x70,
-0x00,0x83,0x18,0x21,0x90,0x62,0x00,0x00,0x00,0x06,0x20,0x27,0x08,0x00,0x04,0x5a,
-0x00,0xe6,0x28,0x24,0x30,0x62,0x00,0x07,0x00,0x02,0x12,0x00,0x11,0x88,0x00,0x0f,
-0x00,0x44,0x10,0x21,0x11,0x93,0x00,0x07,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a,
-0x00,0x43,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x06,0x20,0x27,0x08,0x00,0x04,0x47,
-0x00,0xe6,0x28,0x24,0x3c,0x03,0xb0,0x0a,0x00,0x43,0x18,0x21,0x94,0x62,0x00,0x00,
-0x00,0x06,0x20,0x27,0x08,0x00,0x04,0x50,0x00,0xe6,0x28,0x24,0x3c,0x03,0xb0,0x0a,
-0x08,0x00,0x04,0x7d,0x00,0x43,0x18,0x21,0x97,0x85,0x8b,0xc4,0x3c,0x07,0xb0,0x02,
-0x3c,0x04,0xb0,0x03,0x3c,0x02,0x80,0x00,0x00,0xa7,0x28,0x21,0x34,0x84,0x00,0x20,
-0x24,0x42,0x12,0x58,0x24,0x03,0xff,0x80,0xac,0x82,0x00,0x00,0xa0,0xa3,0x00,0x07,
-0x97,0x82,0x8b,0xc6,0x97,0x85,0x8b,0xc4,0x3c,0x06,0xb0,0x06,0x30,0x42,0xff,0xf8,
-0x24,0x42,0x00,0x10,0x00,0xa2,0x10,0x21,0x30,0x42,0x0f,0xff,0x24,0x44,0x00,0x08,
-0x30,0x84,0x0f,0xff,0x00,0x05,0x28,0xc2,0x3c,0x03,0x00,0x40,0x00,0xa3,0x28,0x25,
-0x00,0x87,0x20,0x21,0x34,0xc6,0x80,0x18,0xac,0xc5,0x00,0x00,0xaf,0x84,0x8b,0xc0,
-0xa7,0x82,0x8b,0xc4,0xa7,0x80,0x8b,0xc6,0xaf,0x80,0x8b,0xc8,0x03,0xe0,0x00,0x08,
-0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff,0x30,0x84,0x00,0xff,0x24,0x02,0x00,0x01,
-0x00,0xe0,0x48,0x21,0x30,0xc6,0x00,0xff,0x8f,0xa7,0x00,0x10,0x10,0x82,0x00,0x07,
-0x00,0xa0,0x40,0x21,0x24,0x02,0x00,0x03,0x10,0x82,0x00,0x03,0x00,0x00,0x00,0x00,
-0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x24,0xa8,0x01,0x00,0x3c,0x03,0xb0,0x03,
-0x24,0x02,0x00,0x01,0x00,0x07,0x20,0x27,0x01,0x27,0x28,0x24,0x10,0xc2,0x00,0x14,
-0x01,0x03,0x18,0x21,0x24,0x02,0x00,0x02,0x10,0xc2,0x00,0x09,0x00,0x07,0x50,0x27,
-0x3c,0x03,0xb0,0x03,0x01,0x03,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x4a,0x10,0x24,0x00,0x45,0x10,0x25,0x08,0x00,0x04,0xe1,0xac,0x62,0x00,0x00,
-0x3c,0x03,0xb0,0x03,0x01,0x03,0x18,0x21,0x94,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x4a,0x10,0x24,0x00,0x45,0x10,0x25,0x03,0xe0,0x00,0x08,0xa4,0x62,0x00,0x00,
-0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25,
-0xa0,0x62,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0x84,0x00,0x07,
-0x00,0x04,0x22,0x00,0x30,0xa5,0x00,0xff,0x00,0x85,0x28,0x21,0x3c,0x02,0xb0,0x0a,
-0x00,0xa2,0x40,0x21,0x30,0xc6,0x00,0xff,0x24,0x02,0x00,0x01,0x8f,0xa4,0x00,0x10,
-0x10,0xc2,0x00,0x14,0x24,0x02,0x00,0x02,0x00,0x04,0x50,0x27,0x10,0xc2,0x00,0x09,
-0x00,0xe4,0x48,0x24,0x3c,0x03,0xb0,0x0a,0x00,0xa3,0x18,0x21,0x8c,0x62,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x4a,0x10,0x24,0x00,0x49,0x10,0x25,0x03,0xe0,0x00,0x08,
-0xac,0x62,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x00,0xa3,0x18,0x21,0x94,0x62,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x4a,0x10,0x24,0x00,0x49,0x10,0x25,0x03,0xe0,0x00,0x08,
-0xa4,0x62,0x00,0x00,0x91,0x02,0x00,0x00,0x00,0x04,0x18,0x27,0x00,0xe4,0x20,0x24,
-0x00,0x43,0x10,0x24,0x00,0x44,0x10,0x25,0x03,0xe0,0x00,0x08,0xa1,0x02,0x00,0x00,
-0x30,0xa9,0x00,0xff,0x27,0x83,0x8b,0x70,0x30,0x85,0x00,0xff,0x24,0x02,0x00,0x01,
-0x00,0x07,0x50,0x27,0x00,0xc7,0x40,0x24,0x11,0x22,0x00,0x17,0x00,0xa3,0x18,0x21,
-0x00,0x05,0x20,0x40,0x27,0x82,0x8b,0x70,0x00,0x05,0x28,0x80,0x27,0x83,0x8b,0x78,
-0x00,0x83,0x50,0x21,0x00,0xa2,0x20,0x21,0x24,0x02,0x00,0x02,0x00,0x07,0x40,0x27,
-0x11,0x22,0x00,0x07,0x00,0xc7,0x28,0x24,0x8c,0x82,0x00,0x18,0x00,0x00,0x00,0x00,
-0x00,0x48,0x10,0x24,0x00,0x45,0x10,0x25,0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x18,
-0x95,0x42,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x48,0x10,0x24,0x00,0x45,0x10,0x25,
-0x03,0xe0,0x00,0x08,0xa5,0x42,0x00,0x02,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x4a,0x10,0x24,0x00,0x48,0x10,0x25,0x03,0xe0,0x00,0x08,0xa0,0x62,0x00,0x00,
-0x00,0x04,0x32,0x02,0x30,0xc6,0xff,0x00,0x00,0x04,0x16,0x02,0x00,0x04,0x1a,0x00,
-0x3c,0x05,0x00,0xff,0x00,0x65,0x18,0x24,0x00,0x46,0x10,0x25,0x00,0x43,0x10,0x25,
-0x00,0x04,0x26,0x00,0x03,0xe0,0x00,0x08,0x00,0x44,0x10,0x25,0x3c,0x03,0xb0,0x03,
-0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xe8,0x34,0x63,0x00,0x20,0x24,0x42,0x14,0xdc,
-0x3c,0x04,0xb0,0x03,0xaf,0xbf,0x00,0x14,0xac,0x62,0x00,0x00,0xaf,0xb0,0x00,0x10,
-0x34,0x84,0x00,0x2c,0x8c,0x83,0x00,0x00,0xa7,0x80,0xbc,0x00,0x00,0x03,0x12,0x02,
-0x00,0x03,0x2d,0x02,0x30,0x42,0x0f,0xff,0xa3,0x83,0xbc,0x08,0xa7,0x85,0xbc,0x0c,
-0xa7,0x82,0xbc,0x0a,0xa7,0x80,0xbc,0x02,0xa7,0x80,0xbc,0x04,0xa7,0x80,0xbc,0x06,
-0x0c,0x00,0x06,0xd1,0x24,0x04,0x05,0x00,0x3c,0x05,0x08,0x00,0x00,0x45,0x28,0x25,
-0x24,0x04,0x05,0x00,0x0c,0x00,0x06,0xbf,0x00,0x40,0x80,0x21,0x3c,0x02,0xf7,0xff,
-0x34,0x42,0xff,0xff,0x02,0x02,0x80,0x24,0x02,0x00,0x28,0x21,0x0c,0x00,0x06,0xbf,
-0x24,0x04,0x05,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0xb0,0x03,0x34,0x42,0x01,0x08,
-0x34,0x63,0x01,0x18,0x8c,0x45,0x00,0x00,0x8c,0x64,0x00,0x00,0x3c,0x02,0x00,0x0f,
-0x3c,0x03,0x00,0x4c,0x30,0x84,0x02,0x00,0x34,0x63,0x4b,0x40,0xaf,0x85,0xbc,0x10,
-0x10,0x80,0x00,0x06,0x34,0x42,0x42,0x40,0xaf,0x83,0xbc,0x14,0x8f,0xbf,0x00,0x14,
-0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0xaf,0x82,0xbc,0x14,
-0x08,0x00,0x05,0x67,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,
-0x27,0xbd,0xff,0xc8,0x34,0x63,0x00,0x20,0x24,0x42,0x15,0xb8,0x30,0x84,0x00,0xff,
-0xaf,0xbf,0x00,0x30,0xaf,0xb7,0x00,0x2c,0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24,
-0xaf,0xb4,0x00,0x20,0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,
-0xaf,0xb0,0x00,0x10,0xac,0x62,0x00,0x00,0x10,0x80,0x00,0x1c,0x24,0x02,0x00,0x02,
-0x10,0x82,0x00,0x08,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x30,0x7b,0xb6,0x01,0x7c,
-0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,
-0x27,0xbd,0x00,0x38,0xa7,0x80,0xbc,0x00,0xa7,0x80,0xbc,0x02,0xa7,0x80,0xbc,0x04,
-0xa7,0x80,0xbc,0x06,0x0c,0x00,0x06,0xd1,0x24,0x04,0x05,0x00,0x3c,0x05,0x08,0x00,
-0x00,0x45,0x28,0x25,0x24,0x04,0x05,0x00,0x0c,0x00,0x06,0xbf,0x00,0x40,0x80,0x21,
-0x3c,0x05,0xf7,0xff,0x34,0xa5,0xff,0xff,0x02,0x05,0x28,0x24,0x0c,0x00,0x06,0xbf,
-0x24,0x04,0x05,0x00,0x08,0x00,0x05,0x82,0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xd1,
-0x24,0x04,0x05,0xa0,0x24,0x04,0x05,0xa4,0x0c,0x00,0x06,0xd1,0x00,0x02,0xbc,0x02,
-0x24,0x04,0x05,0xa8,0x00,0x02,0xb4,0x02,0x0c,0x00,0x06,0xd1,0x30,0x55,0xff,0xff,
-0x00,0x40,0x80,0x21,0x97,0x84,0xbc,0x00,0x97,0x82,0xbc,0x02,0x97,0x83,0xbc,0x06,
-0x02,0xe4,0x20,0x23,0x02,0xa2,0x10,0x23,0x00,0x82,0x20,0x21,0x97,0x82,0xbc,0x04,
-0x32,0x14,0xff,0xff,0x02,0x83,0x18,0x23,0x02,0xc2,0x10,0x23,0x00,0x82,0x20,0x21,
-0x93,0x82,0xbc,0x08,0x00,0x83,0x20,0x21,0x30,0x84,0xff,0xff,0x00,0x82,0x10,0x2b,
-0x14,0x40,0x00,0xaa,0x00,0x00,0x00,0x00,0x97,0x82,0xbc,0x0c,0x00,0x00,0x00,0x00,
-0x00,0x44,0x10,0x2b,0x14,0x40,0x00,0x7f,0x00,0x00,0x00,0x00,0x97,0x82,0xbc,0x0a,
-0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x2b,0x10,0x40,0x00,0x3a,0x00,0x00,0x00,0x00,
-0x0c,0x00,0x06,0xd1,0x24,0x04,0x04,0x50,0x30,0x51,0x00,0x7f,0x00,0x40,0x80,0x21,
-0x2e,0x22,0x00,0x32,0x10,0x40,0x00,0x13,0x24,0x02,0x00,0x20,0x12,0x22,0x00,0x17,
-0x24,0x02,0xff,0x80,0x02,0x02,0x10,0x24,0x26,0x31,0x00,0x01,0x00,0x51,0x80,0x25,
-0x02,0x00,0x28,0x21,0x0c,0x00,0x06,0xbf,0x24,0x04,0x04,0x50,0x02,0x00,0x28,0x21,
-0x0c,0x00,0x06,0xbf,0x24,0x04,0x04,0x58,0x02,0x00,0x28,0x21,0x0c,0x00,0x06,0xbf,
-0x24,0x04,0x04,0x60,0x02,0x00,0x28,0x21,0x24,0x04,0x04,0x68,0x0c,0x00,0x06,0xbf,
-0x00,0x00,0x00,0x00,0xa7,0x97,0xbc,0x00,0xa7,0x95,0xbc,0x02,0xa7,0x96,0xbc,0x04,
-0xa7,0x94,0xbc,0x06,0x08,0x00,0x05,0x82,0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xd1,
-0x24,0x04,0x02,0x08,0x3c,0x04,0x00,0xc0,0x00,0x40,0x28,0x21,0x00,0x44,0x10,0x24,
-0x00,0x02,0x15,0x82,0x24,0x03,0x00,0x03,0x10,0x43,0x00,0x07,0x00,0x00,0x00,0x00,
-0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25,
-0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x08,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x2c,
-0x00,0x40,0x90,0x21,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x02,0x42,0x90,0x24,
-0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x2c,0x08,0x00,0x05,0xc9,
-0x24,0x02,0xff,0x80,0x0c,0x00,0x06,0xd1,0x24,0x04,0x04,0x50,0x30,0x51,0x00,0x7f,
-0x24,0x02,0x00,0x20,0x16,0x22,0xff,0xdb,0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xd1,
-0x24,0x04,0x02,0x2c,0x34,0x52,0x40,0x00,0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xbf,
-0x24,0x04,0x02,0x2c,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x58,0x24,0x04,0x02,0x5c,
-0x0c,0x00,0x06,0xd1,0x00,0x02,0x9e,0x02,0x30,0x43,0x00,0xff,0x00,0x13,0x12,0x00,
-0x00,0x43,0x10,0x25,0x2c,0x43,0x00,0x04,0x14,0x60,0x00,0x1d,0x2c,0x42,0x00,0x11,
-0x10,0x40,0x00,0x0b,0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,
-0x02,0x42,0x90,0x24,0x02,0x40,0x28,0x21,0x24,0x04,0x02,0x2c,0x0c,0x00,0x06,0xbf,
-0x36,0x52,0x80,0x00,0x02,0x40,0x28,0x21,0x08,0x00,0x05,0xd7,0x24,0x04,0x02,0x2c,
-0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x08,0x3c,0x04,0x00,0xc0,0x00,0x40,0x28,0x21,
-0x00,0x44,0x10,0x24,0x00,0x02,0x15,0x82,0x24,0x03,0x00,0x02,0x14,0x43,0xff,0xee,
-0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25,
-0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x08,0x08,0x00,0x06,0x13,0x3c,0x02,0xff,0xff,
-0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x08,0x00,0x40,0x28,0x21,0x00,0x02,0x15,0x82,
-0x30,0x42,0x00,0x03,0x24,0x03,0x00,0x03,0x14,0x43,0xff,0xdf,0x3c,0x02,0xff,0x3f,
-0x34,0x42,0xff,0xff,0x00,0xa2,0x10,0x24,0x3c,0x03,0x00,0x80,0x08,0x00,0x06,0x28,
-0x00,0x43,0x28,0x25,0x0c,0x00,0x06,0xd1,0x24,0x04,0x04,0x50,0x30,0x51,0x00,0x7f,
-0x00,0x40,0x80,0x21,0x2e,0x22,0x00,0x32,0x10,0x40,0xff,0x9a,0x24,0x02,0x00,0x20,
-0x12,0x22,0x00,0x04,0x24,0x02,0xff,0x80,0x02,0x02,0x10,0x24,0x08,0x00,0x05,0xcb,
-0x26,0x31,0x00,0x02,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x08,0x3c,0x04,0x00,0xc0,
-0x00,0x40,0x28,0x21,0x00,0x44,0x10,0x24,0x00,0x02,0x15,0x82,0x24,0x03,0x00,0x03,
-0x10,0x43,0x00,0x07,0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,
-0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25,0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x08,
-0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x2c,0x00,0x40,0x90,0x21,0x3c,0x02,0xff,0xff,
-0x34,0x42,0x3f,0xff,0x02,0x42,0x90,0x24,0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xbf,
-0x24,0x04,0x02,0x2c,0x08,0x00,0x06,0x42,0x24,0x02,0xff,0x80,0x0c,0x00,0x06,0xd1,
-0x24,0x04,0x04,0x50,0x00,0x40,0x80,0x21,0x30,0x51,0x00,0x7f,0x24,0x02,0x00,0x20,
-0x12,0x22,0x00,0x1d,0x2e,0x22,0x00,0x21,0x14,0x40,0xff,0x72,0x24,0x02,0xff,0x80,
-0x02,0x02,0x10,0x24,0x26,0x31,0xff,0xff,0x00,0x51,0x80,0x25,0x24,0x04,0x04,0x50,
-0x0c,0x00,0x06,0xbf,0x02,0x00,0x28,0x21,0x24,0x04,0x04,0x58,0x0c,0x00,0x06,0xbf,
-0x02,0x00,0x28,0x21,0x24,0x04,0x04,0x60,0x0c,0x00,0x06,0xbf,0x02,0x00,0x28,0x21,
-0x02,0x00,0x28,0x21,0x0c,0x00,0x06,0xbf,0x24,0x04,0x04,0x68,0x24,0x02,0x00,0x20,
-0x16,0x22,0xff,0x60,0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x2c,
-0x00,0x40,0x90,0x21,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x02,0x42,0x10,0x24,
-0x08,0x00,0x06,0x19,0x34,0x52,0x80,0x00,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x2c,
-0x34,0x52,0x40,0x00,0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x2c,
-0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x58,0x24,0x04,0x02,0x5c,0x0c,0x00,0x06,0xd1,
-0x00,0x02,0x9e,0x02,0x30,0x43,0x00,0xff,0x00,0x13,0x12,0x00,0x00,0x43,0x10,0x25,
-0x2c,0x43,0x00,0x04,0x14,0x60,0x00,0x20,0x2c,0x42,0x00,0x11,0x10,0x40,0x00,0x0d,
-0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x02,0x42,0x90,0x24,
-0x02,0x40,0x28,0x21,0x24,0x04,0x02,0x2c,0x0c,0x00,0x06,0xbf,0x36,0x52,0x80,0x00,
-0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x2c,0x08,0x00,0x06,0x66,
-0x2e,0x22,0x00,0x21,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x08,0x3c,0x04,0x00,0xc0,
-0x00,0x40,0x28,0x21,0x00,0x44,0x10,0x24,0x00,0x02,0x15,0x82,0x24,0x03,0x00,0x02,
-0x14,0x43,0xff,0xec,0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,
-0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25,0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x08,
-0x08,0x00,0x06,0x96,0x3c,0x02,0xff,0xff,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x08,
-0x00,0x40,0x28,0x21,0x00,0x02,0x15,0x82,0x30,0x42,0x00,0x03,0x24,0x03,0x00,0x03,
-0x14,0x43,0xff,0xdc,0x3c,0x03,0x00,0x80,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,
-0x00,0xa2,0x10,0x24,0x08,0x00,0x06,0xae,0x00,0x43,0x28,0x25,0x30,0x83,0x00,0x03,
-0x00,0x04,0x20,0x40,0x00,0x83,0x20,0x23,0x3c,0x02,0xb0,0x0a,0x00,0x82,0x20,0x21,
-0x3c,0x06,0x00,0x01,0xac,0x85,0x00,0x00,0x24,0x07,0x00,0x01,0x00,0x00,0x28,0x21,
-0x34,0xc6,0x86,0x9f,0x8c,0x82,0x10,0x00,0x24,0xa5,0x00,0x01,0x10,0x47,0x00,0x03,
-0x00,0xc5,0x18,0x2b,0x10,0x60,0xff,0xfb,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,
-0x00,0x00,0x00,0x00,0x30,0x83,0x00,0x03,0x00,0x04,0x20,0x40,0x3c,0x02,0xb0,0x0a,
-0x00,0x83,0x20,0x23,0x00,0x82,0x20,0x21,0x3c,0x06,0x00,0x01,0x24,0x02,0xff,0xff,
-0xac,0x82,0x10,0x00,0x00,0x00,0x28,0x21,0x24,0x07,0x00,0x01,0x34,0xc6,0x86,0x9f,
-0x8c,0x82,0x10,0x00,0x24,0xa5,0x00,0x01,0x10,0x47,0x00,0x03,0x00,0xc5,0x18,0x2b,
-0x10,0x60,0xff,0xfb,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x00,0x03,0xe0,0x00,0x08,
-0x00,0x00,0x00,0x00,0x3c,0x05,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x1b,0x94,
-0x24,0x03,0x00,0x01,0x34,0xa5,0x00,0x20,0x3c,0x06,0xb0,0x03,0xac,0xa2,0x00,0x00,
-0x34,0xc6,0x01,0x04,0xa0,0x83,0x00,0x48,0xa0,0x80,0x00,0x04,0xa0,0x80,0x00,0x05,
-0xa0,0x80,0x00,0x06,0xa0,0x80,0x00,0x07,0xa0,0x80,0x00,0x08,0xa0,0x80,0x00,0x09,
-0xa0,0x80,0x00,0x0a,0xa0,0x80,0x00,0x11,0xa0,0x80,0x00,0x13,0xa0,0x80,0x00,0x49,
-0x94,0xc2,0x00,0x00,0xac,0x80,0x00,0x00,0xa0,0x80,0x00,0x4e,0x00,0x02,0x14,0x00,
-0x00,0x02,0x14,0x03,0x30,0x43,0x00,0xff,0x30,0x42,0xff,0x00,0xa4,0x82,0x00,0x44,
-0xa4,0x83,0x00,0x46,0xac,0x80,0x00,0x24,0xac,0x80,0x00,0x28,0xac,0x80,0x00,0x2c,
-0xac,0x80,0x00,0x30,0xac,0x80,0x00,0x34,0xac,0x80,0x00,0x38,0xac,0x80,0x00,0x3c,
-0x03,0xe0,0x00,0x08,0xac,0x80,0x00,0x40,0x84,0x83,0x00,0x0c,0x3c,0x07,0xb0,0x03,
-0x34,0xe7,0x00,0x20,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,
-0x27,0x83,0x90,0x04,0x00,0x43,0x10,0x21,0x8c,0x48,0x00,0x18,0x3c,0x02,0x80,0x00,
-0x24,0x42,0x1c,0x28,0xac,0xe2,0x00,0x00,0x8d,0x03,0x00,0x08,0x80,0x82,0x00,0x13,
-0x00,0x05,0x2c,0x00,0x00,0x03,0x1e,0x02,0x00,0x02,0x12,0x00,0x30,0x63,0x00,0x7e,
-0x00,0x62,0x18,0x21,0x00,0x65,0x18,0x21,0x3c,0x02,0xc0,0x00,0x3c,0x05,0xb0,0x05,
-0x34,0x42,0x04,0x00,0x24,0x63,0x00,0x01,0x3c,0x07,0xb0,0x05,0x3c,0x08,0xb0,0x05,
-0x34,0xa5,0x04,0x20,0xac,0xa3,0x00,0x00,0x00,0xc2,0x30,0x21,0x34,0xe7,0x04,0x24,
-0x35,0x08,0x02,0x28,0x24,0x02,0x00,0x01,0x24,0x03,0x00,0x20,0xac,0xe6,0x00,0x00,
-0xac,0x82,0x00,0x3c,0x03,0xe0,0x00,0x08,0xa1,0x03,0x00,0x00,0x27,0xbd,0xff,0xa8,
-0x00,0x07,0x60,0x80,0x27,0x82,0xb4,0x00,0xaf,0xbe,0x00,0x50,0xaf,0xb7,0x00,0x4c,
-0xaf,0xb5,0x00,0x44,0xaf,0xb4,0x00,0x40,0xaf,0xbf,0x00,0x54,0xaf,0xb6,0x00,0x48,
-0xaf,0xb3,0x00,0x3c,0xaf,0xb2,0x00,0x38,0xaf,0xb1,0x00,0x34,0xaf,0xb0,0x00,0x30,
-0x01,0x82,0x10,0x21,0x8c,0x43,0x00,0x00,0x00,0xe0,0x70,0x21,0x3c,0x02,0x80,0x00,
-0x94,0x73,0x00,0x14,0x3c,0x07,0xb0,0x03,0x34,0xe7,0x00,0x20,0x24,0x42,0x1c,0xbc,
-0x3c,0x03,0xb0,0x05,0xac,0xe2,0x00,0x00,0x34,0x63,0x01,0x28,0x90,0x67,0x00,0x00,
-0x00,0x13,0xa8,0xc0,0x02,0xb3,0x18,0x21,0x27,0x82,0x90,0x04,0x00,0x03,0x18,0x80,
-0x00,0x62,0x18,0x21,0x00,0x05,0x2c,0x00,0x00,0x07,0x3e,0x00,0x28,0xc2,0x00,0x03,
-0x00,0xc0,0xa0,0x21,0x00,0x80,0x78,0x21,0x00,0x05,0xbc,0x03,0x8c,0x68,0x00,0x18,
-0x02,0xa0,0x58,0x21,0x10,0x40,0x01,0x81,0x00,0x07,0xf6,0x03,0x00,0xde,0x10,0x07,
-0x30,0x5e,0x00,0x01,0x01,0x73,0x10,0x21,0x27,0x83,0x90,0x08,0x00,0x02,0x10,0x80,
-0x00,0x43,0x10,0x21,0x80,0x4d,0x00,0x06,0x8d,0x03,0x00,0x00,0x8d,0x02,0x00,0x04,
-0x8d,0x0a,0x00,0x08,0x8d,0x03,0x00,0x0c,0xaf,0xa2,0x00,0x20,0x11,0xa0,0x01,0x71,
-0xaf,0xa3,0x00,0x18,0x27,0x82,0xb4,0x00,0x01,0x82,0x10,0x21,0x8c,0x44,0x00,0x00,
-0x00,0x00,0x00,0x00,0x90,0x83,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x04,
-0x14,0x60,0x00,0x12,0x00,0x00,0xb0,0x21,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x46,
-0x90,0x43,0x00,0x00,0x2a,0x84,0x00,0x04,0x10,0x80,0x01,0x56,0x30,0x65,0x00,0x01,
-0x91,0xe2,0x00,0x09,0x00,0x00,0x00,0x00,0x12,0x82,0x00,0x02,0x00,0x00,0x00,0x00,
-0x00,0x00,0x28,0x21,0x14,0xa0,0x00,0x03,0x00,0x00,0x38,0x21,0x13,0xc0,0x00,0x03,
-0x38,0xf6,0x00,0x01,0x24,0x07,0x00,0x01,0x38,0xf6,0x00,0x01,0x01,0x73,0x10,0x21,
-0x00,0x02,0x30,0x80,0x27,0x83,0x90,0x10,0x00,0xc3,0x48,0x21,0x91,0x25,0x00,0x00,
-0x8f,0xa4,0x00,0x20,0x2c,0xa3,0x00,0x04,0x00,0x04,0x11,0xc3,0x30,0x42,0x00,0x01,
-0x00,0x03,0xb0,0x0b,0x12,0xc0,0x00,0xd8,0xaf,0xa2,0x00,0x24,0x93,0x90,0xbb,0xea,
-0x00,0x0a,0x16,0x42,0x30,0x52,0x00,0x3f,0x2e,0x06,0x00,0x0c,0x10,0xc0,0x00,0xc0,
-0x00,0xa0,0x20,0x21,0x2c,0xa2,0x00,0x10,0x14,0x40,0x00,0x04,0x00,0x90,0x10,0x2b,
-0x30,0xa2,0x00,0x07,0x24,0x44,0x00,0x04,0x00,0x90,0x10,0x2b,0x10,0x40,0x00,0x0b,
-0x01,0x73,0x10,0x21,0x27,0x85,0xbb,0x1c,0x00,0x10,0x10,0x40,0x00,0x50,0x10,0x21,
-0x00,0x45,0x10,0x21,0x90,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x18,0x2b,
-0x14,0x60,0xff,0xfa,0x00,0x10,0x10,0x40,0x01,0x73,0x10,0x21,0x00,0x02,0x10,0x80,
-0x27,0x83,0x90,0x08,0x00,0x43,0x10,0x21,0x31,0xa4,0x00,0x01,0x10,0x80,0x00,0xa5,
-0xa0,0x50,0x00,0x07,0x3c,0x04,0xb0,0x05,0x34,0x84,0x00,0x08,0x24,0x02,0x00,0x01,
-0x3c,0x03,0x80,0x00,0xa1,0xe2,0x00,0x4e,0xac,0x83,0x00,0x00,0x8c,0x85,0x00,0x00,
-0x3c,0x02,0x00,0xf0,0x3c,0x03,0x40,0xf0,0x34,0x42,0xf0,0x00,0x34,0x63,0xf0,0x00,
-0x24,0x17,0x00,0x0e,0x24,0x13,0x01,0x06,0xac,0x82,0x00,0x00,0xac,0x83,0x00,0x00,
-0x27,0x82,0xb4,0x00,0x01,0x82,0x10,0x21,0x8c,0x43,0x00,0x00,0x24,0x05,0x00,0x01,
-0xaf,0xa5,0x00,0x1c,0x90,0x62,0x00,0x16,0x00,0x13,0xa8,0xc0,0x32,0x51,0x00,0x02,
-0x34,0x42,0x00,0x04,0xa0,0x62,0x00,0x16,0x8f,0xa3,0x00,0x20,0x8f,0xa4,0x00,0x18,
-0x00,0x03,0x13,0x43,0x00,0x04,0x1a,0x02,0x30,0x47,0x00,0x01,0x12,0x20,0x00,0x04,
-0x30,0x64,0x07,0xff,0x2e,0x03,0x00,0x04,0x32,0x42,0x00,0x33,0x00,0x43,0x90,0x0b,
-0x8f,0xa5,0x00,0x24,0x8f,0xa6,0x00,0x1c,0x00,0x12,0x10,0x40,0x00,0x05,0x19,0xc0,
-0x00,0x47,0x10,0x21,0x00,0x06,0x2a,0x80,0x00,0x43,0x10,0x21,0x00,0x10,0x32,0x00,
-0x00,0x04,0x24,0x80,0x02,0x65,0x28,0x21,0x00,0xa4,0x28,0x21,0x00,0x46,0x10,0x21,
-0x00,0x17,0x1c,0x00,0x3c,0x04,0xc0,0x00,0x00,0x43,0x30,0x21,0x16,0x80,0x00,0x29,
-0x00,0xa4,0x28,0x21,0x3c,0x02,0xb0,0x05,0x34,0x42,0x04,0x00,0x3c,0x03,0xb0,0x05,
-0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x04,0x34,0x84,0x02,0x28,
-0x24,0x02,0x00,0x01,0xac,0x65,0x00,0x00,0xa0,0x82,0x00,0x00,0x3c,0x02,0xb0,0x09,
-0x34,0x42,0x01,0x46,0x90,0x44,0x00,0x00,0x91,0xe3,0x00,0x09,0x30,0x86,0x00,0x01,
-0x02,0x83,0x18,0x26,0x00,0x03,0x30,0x0b,0x14,0xc0,0x00,0x03,0x00,0x00,0x28,0x21,
-0x13,0xc0,0x00,0x03,0x02,0xb3,0x10,0x21,0x24,0x05,0x00,0x01,0x02,0xb3,0x10,0x21,
-0x27,0x83,0x90,0x08,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x84,0x48,0x00,0x04,
-0x00,0xa0,0x30,0x21,0x00,0xe0,0x20,0x21,0x02,0x80,0x28,0x21,0x02,0xc0,0x38,0x21,
-0x0c,0x00,0x00,0x70,0xaf,0xa8,0x00,0x10,0x7b,0xbe,0x02,0xbc,0x7b,0xb6,0x02,0x7c,
-0x7b,0xb4,0x02,0x3c,0x7b,0xb2,0x01,0xfc,0x7b,0xb0,0x01,0xbc,0x03,0xe0,0x00,0x08,
-0x27,0xbd,0x00,0x58,0x24,0x02,0x00,0x01,0x12,0x82,0x00,0x3d,0x3c,0x02,0xb0,0x05,
-0x24,0x02,0x00,0x02,0x12,0x82,0x00,0x31,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x03,
-0x12,0x82,0x00,0x25,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x10,0x12,0x82,0x00,0x19,
-0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x11,0x12,0x82,0x00,0x0d,0x3c,0x02,0xb0,0x05,
-0x24,0x02,0x00,0x12,0x16,0x82,0xff,0xd1,0x3c,0x02,0xb0,0x05,0x3c,0x03,0xb0,0x05,
-0x34,0x42,0x04,0x20,0x3c,0x04,0xb0,0x05,0x34,0x63,0x04,0x24,0xac,0x46,0x00,0x00,
-0x34,0x84,0x02,0x28,0xac,0x65,0x00,0x00,0x08,0x00,0x07,0xe6,0x24,0x02,0x00,0x20,
-0x34,0x42,0x04,0x40,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,
-0x34,0x63,0x04,0x44,0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x40,0x08,0x00,0x07,0xe6,
-0xac,0x65,0x00,0x00,0x34,0x42,0x04,0x28,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,
-0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x2c,0x34,0x84,0x02,0x28,0x24,0x02,0xff,0x80,
-0x08,0x00,0x07,0xe6,0xac,0x65,0x00,0x00,0x34,0x42,0x04,0x18,0x3c,0x03,0xb0,0x05,
-0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x1c,0x34,0x84,0x02,0x28,
-0x24,0x02,0x00,0x08,0x08,0x00,0x07,0xe6,0xac,0x65,0x00,0x00,0x34,0x42,0x04,0x10,
-0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x14,
-0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x04,0x08,0x00,0x07,0xe6,0xac,0x65,0x00,0x00,
-0x34,0x42,0x04,0x08,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,
-0x34,0x63,0x04,0x0c,0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x02,0x08,0x00,0x07,0xe6,
-0xac,0x65,0x00,0x00,0x24,0x17,0x00,0x14,0x08,0x00,0x07,0xb8,0x24,0x13,0x01,0x02,
-0x30,0xa2,0x00,0x07,0x24,0x44,0x00,0x0c,0x00,0x90,0x18,0x2b,0x10,0x60,0x00,0x0c,
-0x26,0x02,0x00,0x04,0x27,0x85,0xbb,0x1c,0x00,0x10,0x10,0x40,0x00,0x50,0x10,0x21,
-0x00,0x45,0x10,0x21,0x90,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x18,0x2b,
-0x14,0x60,0xff,0xfa,0x00,0x10,0x10,0x40,0x2e,0x06,0x00,0x0c,0x26,0x02,0x00,0x04,
-0x08,0x00,0x07,0xa2,0x00,0x46,0x80,0x0a,0x27,0x82,0xb4,0x00,0x01,0x82,0x20,0x21,
-0x8c,0x87,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0xe2,0x00,0x19,0x00,0x00,0x00,0x00,
-0x14,0x40,0x00,0x07,0x00,0x00,0x00,0x00,0x27,0x82,0x90,0x20,0x00,0xc2,0x10,0x21,
-0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x14,0x00,0x00,0x00,0x00,
-0x90,0xe3,0x00,0x16,0x27,0x82,0x90,0x08,0x00,0xc2,0x10,0x21,0x34,0x63,0x00,0x20,
-0x90,0x50,0x00,0x07,0xa0,0xe3,0x00,0x16,0x8c,0x84,0x00,0x00,0x00,0x0a,0x1e,0x42,
-0x24,0x06,0x00,0x01,0x90,0x82,0x00,0x16,0x30,0x71,0x00,0x02,0x30,0x72,0x00,0x3f,
-0x30,0x42,0x00,0xfb,0x24,0x17,0x00,0x18,0x24,0x13,0x01,0x03,0x24,0x15,0x08,0x18,
-0xaf,0xa6,0x00,0x1c,0x08,0x00,0x07,0xc2,0xa0,0x82,0x00,0x16,0x8d,0x02,0x00,0x04,
-0x00,0x0a,0x1c,0x42,0x30,0x42,0x00,0x10,0x14,0x40,0x00,0x15,0x30,0x72,0x00,0x3f,
-0x81,0x22,0x00,0x05,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x11,0x30,0x72,0x00,0x3e,
-0x27,0x83,0x90,0x18,0x00,0xc3,0x18,0x21,0x80,0x64,0x00,0x00,0x27,0x83,0xb5,0x78,
-0x00,0x04,0x11,0x00,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23,
-0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x05,0x90,0x43,0x00,0x04,
-0x00,0x00,0x00,0x00,0x00,0x64,0x18,0x24,0x30,0x63,0x00,0x01,0x02,0x43,0x90,0x25,
-0x27,0x85,0xb4,0x00,0x01,0x85,0x28,0x21,0x8c,0xa6,0x00,0x00,0x01,0x73,0x10,0x21,
-0x27,0x83,0x90,0x10,0x90,0xc4,0x00,0x16,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,
-0x30,0x84,0x00,0xdf,0x90,0x50,0x00,0x00,0xa0,0xc4,0x00,0x16,0x80,0xc6,0x00,0x12,
-0x8c,0xa3,0x00,0x00,0x2d,0xc4,0x00,0x02,0xaf,0xa6,0x00,0x1c,0x90,0x62,0x00,0x16,
-0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfb,0x14,0x80,0x00,0x06,0xa0,0x62,0x00,0x16,
-0x24,0x02,0x00,0x06,0x11,0xc2,0x00,0x03,0x24,0x02,0x00,0x04,0x15,0xc2,0xff,0x0e,
-0x32,0x51,0x00,0x02,0x32,0x51,0x00,0x02,0x2e,0x02,0x00,0x0c,0x14,0x40,0x00,0x0f,
-0x00,0x11,0x18,0x2b,0x32,0x02,0x00,0x0f,0x34,0x42,0x00,0x10,0x00,0x03,0x19,0x00,
-0x00,0x43,0x18,0x21,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xe0,0xa0,0x43,0x00,0x00,
-0x00,0x00,0x20,0x21,0x02,0x00,0x28,0x21,0x0c,0x00,0x02,0x03,0xaf,0xaf,0x00,0x28,
-0x8f,0xaf,0x00,0x28,0x08,0x00,0x07,0xc2,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0xbd,
-0x32,0x03,0x00,0xff,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x42,0x90,0x62,0x00,0x00,
-0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x0f,0x14,0x40,0xfe,0xaa,0x00,0x00,0x00,0x00,
-0x91,0xe2,0x00,0x09,0x00,0x00,0x00,0x00,0x02,0x82,0x10,0x26,0x08,0x00,0x07,0x79,
-0x00,0x02,0x28,0x0b,0x08,0x00,0x07,0x7f,0x00,0x00,0xb0,0x21,0x24,0x02,0x00,0x10,
-0x10,0xc2,0x00,0x08,0x24,0x02,0x00,0x11,0x10,0xc2,0xfe,0x7d,0x00,0x07,0x17,0x83,
-0x24,0x02,0x00,0x12,0x14,0xc2,0xfe,0x7b,0x00,0x07,0x17,0x43,0x08,0x00,0x07,0x59,
-0x30,0x5e,0x00,0x01,0x08,0x00,0x07,0x59,0x00,0x07,0xf7,0xc2,0x00,0x04,0x10,0x40,
-0x27,0x83,0x80,0x1c,0x00,0x43,0x10,0x21,0x00,0x80,0x40,0x21,0x94,0x44,0x00,0x00,
-0x2d,0x07,0x00,0x04,0x24,0xc2,0x00,0x03,0x00,0x47,0x30,0x0a,0x00,0x86,0x00,0x18,
-0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x23,0x8c,
-0xac,0x62,0x00,0x00,0x2d,0x06,0x00,0x10,0x00,0x00,0x20,0x12,0x00,0x04,0x22,0x42,
-0x24,0x84,0x00,0x01,0x24,0x83,0x00,0xc0,0x10,0xe0,0x00,0x0b,0x24,0x82,0x00,0x60,
-0x00,0x40,0x20,0x21,0x00,0x65,0x20,0x0a,0x3c,0x03,0xb0,0x03,0x34,0x63,0x01,0x00,
-0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x00,0x44,0x20,0x04,
-0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x24,0x85,0x00,0x28,0x24,0x83,0x00,0x24,
-0x31,0x02,0x00,0x08,0x14,0xc0,0xff,0xf4,0x24,0x84,0x00,0x14,0x00,0x60,0x20,0x21,
-0x08,0x00,0x08,0xfa,0x00,0xa2,0x20,0x0b,0x27,0xbd,0xff,0xe0,0x3c,0x03,0xb0,0x03,
-0x3c,0x02,0x80,0x00,0xaf,0xb0,0x00,0x10,0x24,0x42,0x24,0x28,0x00,0x80,0x80,0x21,
-0x34,0x63,0x00,0x20,0x3c,0x04,0xb0,0x03,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,
-0xaf,0xbf,0x00,0x1c,0x83,0xb1,0x00,0x33,0x83,0xa8,0x00,0x37,0x34,0x84,0x01,0x10,
-0xac,0x62,0x00,0x00,0x2e,0x02,0x00,0x10,0x00,0xe0,0x90,0x21,0x8c,0x87,0x00,0x00,
-0x14,0x40,0x00,0x0c,0x2e,0x02,0x00,0x0c,0x3c,0x02,0x00,0x0f,0x34,0x42,0xf0,0x00,
-0x00,0xe2,0x10,0x24,0x14,0x40,0x00,0x37,0x32,0x02,0x00,0x08,0x32,0x02,0x00,0x07,
-0x27,0x83,0x80,0xcc,0x00,0x43,0x10,0x21,0x90,0x50,0x00,0x00,0x00,0x00,0x00,0x00,
-0x2e,0x02,0x00,0x0c,0x14,0x40,0x00,0x03,0x02,0x00,0x20,0x21,0x32,0x02,0x00,0x0f,
-0x24,0x44,0x00,0x0c,0x00,0x87,0x10,0x06,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x07,
-0x2c,0x82,0x00,0x0c,0x00,0x04,0x10,0x80,0x27,0x83,0xb4,0x50,0x00,0x43,0x10,0x21,
-0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x82,0x00,0x0c,0x14,0x40,0x00,0x05,
-0x00,0x05,0x10,0x40,0x00,0x46,0x10,0x21,0x00,0x02,0x11,0x00,0x00,0x82,0x10,0x21,
-0x24,0x44,0x00,0x04,0x15,0x00,0x00,0x02,0x24,0x06,0x00,0x20,0x24,0x06,0x00,0x0e,
-0x0c,0x00,0x08,0xe3,0x00,0x00,0x00,0x00,0x00,0x40,0x30,0x21,0x3c,0x02,0xb0,0x03,
-0x34,0x42,0x01,0x00,0x90,0x43,0x00,0x00,0x2e,0x04,0x00,0x04,0x24,0x02,0x00,0x10,
-0x24,0x05,0x00,0x0a,0x00,0x44,0x28,0x0a,0x30,0x63,0x00,0x01,0x14,0x60,0x00,0x02,
-0x00,0x05,0x10,0x40,0x00,0xa0,0x10,0x21,0x30,0x45,0x00,0xff,0x00,0xc5,0x10,0x21,
-0x24,0x46,0x00,0x46,0x02,0x26,0x18,0x04,0xa6,0x43,0x00,0x00,0x8f,0xbf,0x00,0x1c,
-0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x00,0xc0,0x10,0x21,0x03,0xe0,0x00,0x08,
-0x27,0xbd,0x00,0x20,0x10,0x40,0xff,0xcf,0x2e,0x02,0x00,0x0c,0x32,0x02,0x00,0x07,
-0x27,0x83,0x80,0xc4,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x00,0x08,0x00,0x09,0x28,
-0x02,0x04,0x80,0x23,0x27,0xbd,0xff,0xb8,0x00,0x05,0x38,0x80,0x27,0x82,0xb4,0x00,
-0xaf,0xbe,0x00,0x40,0xaf,0xb6,0x00,0x38,0xaf,0xb3,0x00,0x2c,0xaf,0xbf,0x00,0x44,
-0xaf,0xb7,0x00,0x3c,0xaf,0xb5,0x00,0x34,0xaf,0xb4,0x00,0x30,0xaf,0xb2,0x00,0x28,
-0xaf,0xb1,0x00,0x24,0xaf,0xb0,0x00,0x20,0x00,0xe2,0x38,0x21,0x8c,0xe6,0x00,0x00,
-0xaf,0xa5,0x00,0x4c,0x3c,0x02,0x80,0x00,0x3c,0x05,0xb0,0x03,0x34,0xa5,0x00,0x20,
-0x24,0x42,0x25,0x84,0x24,0x03,0x00,0x01,0xac,0xa2,0x00,0x00,0xa0,0xc3,0x00,0x12,
-0x8c,0xe5,0x00,0x00,0x94,0xc3,0x00,0x06,0x90,0xa2,0x00,0x16,0xa4,0xc3,0x00,0x14,
-0x27,0x83,0x90,0x00,0x34,0x42,0x00,0x08,0xa0,0xa2,0x00,0x16,0x8c,0xe8,0x00,0x00,
-0xaf,0xa4,0x00,0x48,0x27,0x82,0x90,0x04,0x95,0x11,0x00,0x14,0x00,0x00,0x00,0x00,
-0x00,0x11,0x98,0xc0,0x02,0x71,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x82,0x10,0x21,
-0x8c,0x52,0x00,0x18,0x00,0x83,0x18,0x21,0x84,0x75,0x00,0x06,0x8e,0x45,0x00,0x08,
-0x8e,0x46,0x00,0x04,0x8e,0x47,0x00,0x04,0x00,0x05,0x1c,0x82,0x00,0x06,0x31,0x42,
-0x27,0x82,0x90,0x10,0x30,0x63,0x00,0x01,0x30,0xc6,0x00,0x01,0x00,0x82,0x20,0x21,
-0xa5,0x15,0x00,0x1a,0x00,0x05,0x14,0x42,0xaf,0xa3,0x00,0x18,0xaf,0xa6,0x00,0x1c,
-0x30,0xe7,0x00,0x10,0x30,0x56,0x00,0x01,0x80,0x97,0x00,0x06,0x14,0xe0,0x00,0x47,
-0x00,0x05,0xf7,0xc2,0x80,0x82,0x00,0x05,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x44,
-0x02,0x71,0x10,0x21,0x93,0x90,0xbb,0xe9,0x00,0x00,0x00,0x00,0x2e,0x02,0x00,0x0c,
-0x14,0x40,0x00,0x06,0x02,0x00,0x20,0x21,0x00,0x16,0x10,0x40,0x00,0x43,0x10,0x21,
-0x00,0x02,0x11,0x00,0x02,0x02,0x10,0x21,0x24,0x44,0x00,0x04,0x02,0x71,0x10,0x21,
-0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,0x00,0x80,0x80,0x21,
-0xa0,0x44,0x00,0x03,0xa0,0x44,0x00,0x00,0x02,0x00,0x20,0x21,0x02,0xc0,0x28,0x21,
-0x0c,0x00,0x08,0xe3,0x02,0xa0,0x30,0x21,0x02,0x71,0x18,0x21,0x00,0x03,0x88,0x80,
-0x00,0x40,0xa0,0x21,0x27,0x82,0x90,0x20,0x02,0x22,0x10,0x21,0x8c,0x44,0x00,0x00,
-0x26,0xe3,0x00,0x02,0x00,0x03,0x17,0xc2,0x00,0x62,0x18,0x21,0x00,0x04,0x25,0xc2,
-0x00,0x03,0x18,0x43,0x30,0x84,0x00,0x01,0x00,0x03,0x18,0x40,0x03,0xc4,0x20,0x24,
-0x14,0x80,0x00,0x15,0x02,0x43,0x38,0x21,0x3c,0x08,0xb0,0x03,0x35,0x08,0x00,0x28,
-0x8d,0x03,0x00,0x00,0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x48,0x27,0x82,0x90,0x08,
-0x02,0x22,0x10,0x21,0x24,0x63,0x00,0x01,0x02,0xa0,0x28,0x21,0xa4,0x54,0x00,0x04,
-0x00,0xc0,0x38,0x21,0x0c,0x00,0x07,0x2f,0xad,0x03,0x00,0x00,0x7b,0xbe,0x02,0x3c,
-0x7b,0xb6,0x01,0xfc,0x7b,0xb4,0x01,0xbc,0x7b,0xb2,0x01,0x7c,0x7b,0xb0,0x01,0x3c,
-0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x48,0x8f,0xa2,0x00,0x1c,0x8f,0xa6,0x00,0x18,
-0x02,0x00,0x20,0x21,0x02,0xc0,0x28,0x21,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0x0a,
-0xaf,0xa0,0x00,0x14,0x08,0x00,0x09,0xc6,0x02,0x82,0xa0,0x21,0x02,0x71,0x10,0x21,
-0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,0x90,0x50,0x00,0x00,
-0x08,0x00,0x09,0xb2,0xa0,0x50,0x00,0x03,0x27,0xbd,0xff,0xb8,0xaf,0xb1,0x00,0x24,
-0x8f,0xb1,0x00,0x5c,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,
-0x24,0x42,0x27,0xa8,0xaf,0xbe,0x00,0x40,0xaf,0xb7,0x00,0x3c,0xaf,0xb6,0x00,0x38,
-0xaf,0xb5,0x00,0x34,0xaf,0xb4,0x00,0x30,0xaf,0xa5,0x00,0x4c,0x8f,0xb5,0x00,0x58,
-0xaf,0xbf,0x00,0x44,0xaf,0xb3,0x00,0x2c,0xaf,0xb2,0x00,0x28,0xaf,0xb0,0x00,0x20,
-0x00,0xe0,0xb0,0x21,0xac,0x62,0x00,0x00,0x00,0x80,0xf0,0x21,0x00,0x00,0xb8,0x21,
-0x16,0x20,0x00,0x2b,0x00,0x00,0xa0,0x21,0x27,0x85,0xb4,0x00,0x00,0x07,0x10,0x80,
-0x00,0x45,0x10,0x21,0x8c,0x53,0x00,0x00,0x00,0x15,0x18,0x80,0x00,0x65,0x18,0x21,
-0x92,0x62,0x00,0x16,0x8c,0x72,0x00,0x00,0x30,0x42,0x00,0x03,0x14,0x40,0x00,0x2d,
-0x00,0x00,0x00,0x00,0x92,0x42,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x03,
-0x14,0x40,0x00,0x28,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x34,0x00,0x00,0x00,0x00,
-0x14,0x40,0x00,0x18,0x02,0x20,0x10,0x21,0x8c,0x82,0x00,0x38,0x00,0x00,0x00,0x00,
-0x14,0x40,0x00,0x14,0x02,0x20,0x10,0x21,0x8c,0x82,0x00,0x3c,0x00,0x00,0x00,0x00,
-0x14,0x40,0x00,0x0f,0x3c,0x03,0xb0,0x09,0x3c,0x05,0xb0,0x05,0x34,0x63,0x01,0x44,
-0x34,0xa5,0x02,0x52,0x94,0x66,0x00,0x00,0x90,0xa2,0x00,0x00,0x8f,0xa3,0x00,0x4c,
-0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x06,0x30,0x42,0x00,0x01,0x10,0x40,0x00,0x04,
-0x30,0xc6,0xff,0xff,0x2c,0xc2,0x00,0x41,0x10,0x40,0x00,0x09,0x24,0x05,0x00,0x14,
-0x02,0x20,0x10,0x21,0x7b,0xbe,0x02,0x3c,0x7b,0xb6,0x01,0xfc,0x7b,0xb4,0x01,0xbc,
-0x7b,0xb2,0x01,0x7c,0x7b,0xb0,0x01,0x3c,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x48,
-0x0c,0x00,0x07,0x0a,0x24,0x06,0x01,0x07,0x24,0x02,0x00,0x01,0x08,0x00,0x0a,0x2c,
-0xa3,0xc2,0x00,0x11,0x10,0xc0,0x00,0x1c,0x24,0x02,0x00,0x01,0x10,0xc2,0x00,0x17,
-0x00,0xc0,0x88,0x21,0x96,0x54,0x00,0x1a,0x02,0xa0,0xb8,0x21,0x12,0x20,0xff,0xed,
-0x02,0x20,0x10,0x21,0x27,0x83,0xb4,0x00,0x00,0x17,0x10,0x80,0x00,0x43,0x10,0x21,
-0x8c,0x44,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x28,0x80,0x86,0x00,0x12,
-0x8c,0x62,0x00,0x00,0x00,0x14,0x2c,0x00,0x00,0x05,0x2c,0x03,0x00,0x46,0x10,0x21,
-0x8f,0xa6,0x00,0x4c,0x02,0xe0,0x38,0x21,0x03,0xc0,0x20,0x21,0x0c,0x00,0x07,0x2f,
-0xac,0x62,0x00,0x00,0x08,0x00,0x0a,0x2c,0xaf,0xd1,0x00,0x40,0x96,0x74,0x00,0x1a,
-0x08,0x00,0x0a,0x3f,0x02,0xc0,0xb8,0x21,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,
-0x8c,0x50,0x00,0x00,0x02,0x60,0x20,0x21,0x0c,0x00,0x1e,0xf3,0x02,0x00,0x28,0x21,
-0x30,0x42,0x00,0xff,0x02,0x00,0x28,0x21,0x02,0x40,0x20,0x21,0x0c,0x00,0x1e,0xf3,
-0xaf,0xa2,0x00,0x18,0x8f,0xa4,0x00,0x18,0x00,0x00,0x00,0x00,0x10,0x80,0x00,0xed,
-0x30,0x50,0x00,0xff,0x12,0x00,0x00,0x18,0x24,0x11,0x00,0x01,0x96,0x63,0x00,0x14,
-0x96,0x44,0x00,0x14,0x27,0x85,0x90,0x00,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
-0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x00,0x04,0x18,0xc0,0x8c,0x46,0x00,0x08,
-0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x65,0x18,0x21,0x00,0x06,0x17,0x02,
-0x24,0x04,0x00,0xff,0x8c,0x63,0x00,0x08,0x10,0x44,0x00,0xd6,0x00,0x03,0x17,0x02,
-0x10,0x44,0x00,0xd5,0x3c,0x02,0x80,0x00,0x00,0x66,0x18,0x2b,0x24,0x11,0x00,0x02,
-0x24,0x02,0x00,0x01,0x00,0x43,0x88,0x0a,0x24,0x02,0x00,0x01,0x12,0x22,0x00,0x5a,
-0x24,0x02,0x00,0x02,0x16,0x22,0xff,0xbd,0x00,0x00,0x00,0x00,0x96,0x49,0x00,0x14,
-0x27,0x82,0x90,0x04,0x02,0xa0,0xb8,0x21,0x00,0x09,0x50,0xc0,0x01,0x49,0x18,0x21,
-0x00,0x03,0x40,0x80,0x01,0x02,0x10,0x21,0x8c,0x43,0x00,0x18,0x00,0x00,0x00,0x00,
-0x8c,0x65,0x00,0x08,0x8c,0x62,0x00,0x0c,0x8c,0x62,0x00,0x04,0x00,0x05,0x24,0x42,
-0x00,0x05,0x1c,0x82,0x30,0x42,0x00,0x10,0x30,0x66,0x00,0x01,0x14,0x40,0x00,0x41,
-0x30,0x87,0x00,0x01,0x27,0x82,0x90,0x18,0x01,0x02,0x10,0x21,0x80,0x44,0x00,0x00,
-0x27,0x82,0xb5,0x78,0x00,0x04,0x19,0x00,0x00,0x64,0x18,0x23,0x00,0x03,0x18,0x80,
-0x00,0x64,0x18,0x23,0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x90,0x45,0x00,0x05,
-0x27,0x84,0xb4,0xa0,0x00,0x64,0x18,0x21,0x90,0x63,0x00,0x00,0x10,0xa0,0x00,0x2b,
-0x2c,0x64,0x00,0x0c,0x14,0x80,0x00,0x04,0x00,0x60,0x10,0x21,0x00,0x06,0x11,0x00,
-0x00,0x62,0x10,0x21,0x24,0x42,0x00,0x24,0x3c,0x01,0xb0,0x03,0xa0,0x22,0x00,0xe1,
-0x14,0x80,0x00,0x06,0x00,0x60,0x28,0x21,0x00,0x07,0x10,0x40,0x00,0x46,0x10,0x21,
-0x00,0x02,0x11,0x00,0x00,0x62,0x10,0x21,0x24,0x45,0x00,0x04,0x01,0x49,0x10,0x21,
-0x27,0x83,0x90,0x10,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0xa0,0x18,0x21,
-0xa0,0x45,0x00,0x03,0xa0,0x45,0x00,0x00,0x24,0x02,0x00,0x08,0x12,0x02,0x00,0x0b,
-0x24,0x02,0x00,0x01,0x00,0x60,0x28,0x21,0x02,0x40,0x20,0x21,0x0c,0x00,0x1f,0x6f,
-0xaf,0xa2,0x00,0x10,0x30,0x54,0xff,0xff,0x92,0x42,0x00,0x16,0x00,0x00,0x00,0x00,
-0x02,0x02,0x10,0x25,0x08,0x00,0x0a,0x3f,0xa2,0x42,0x00,0x16,0x00,0x60,0x28,0x21,
-0x02,0x40,0x20,0x21,0x0c,0x00,0x1f,0x20,0xaf,0xa0,0x00,0x10,0x08,0x00,0x0a,0xc2,
-0x30,0x54,0xff,0xff,0x08,0x00,0x0a,0xaa,0x00,0x60,0x10,0x21,0x14,0x80,0xff,0xfd,
-0x00,0x00,0x00,0x00,0x00,0x06,0x11,0x00,0x00,0x62,0x10,0x21,0x08,0x00,0x0a,0xaa,
-0x24,0x42,0x00,0x04,0x27,0x82,0x90,0x10,0x01,0x02,0x10,0x21,0x90,0x43,0x00,0x00,
-0x08,0x00,0x0a,0xba,0xa0,0x43,0x00,0x03,0x96,0x69,0x00,0x14,0x02,0xc0,0xb8,0x21,
-0x24,0x0b,0x00,0x01,0x00,0x09,0x10,0xc0,0x00,0x49,0x18,0x21,0x00,0x03,0x40,0x80,
-0x00,0x40,0x50,0x21,0x27,0x82,0x90,0x04,0x01,0x02,0x10,0x21,0x8c,0x43,0x00,0x18,
-0x00,0x00,0x00,0x00,0x8c,0x65,0x00,0x08,0x8c,0x62,0x00,0x0c,0x8c,0x62,0x00,0x04,
-0x00,0x05,0x24,0x42,0x00,0x05,0x1c,0x82,0x30,0x42,0x00,0x10,0x30,0x66,0x00,0x01,
-0x10,0x40,0x00,0x0d,0x30,0x87,0x00,0x01,0x27,0x82,0x90,0x18,0x01,0x02,0x10,0x21,
-0x80,0x43,0x00,0x00,0x00,0x00,0x58,0x21,0x00,0x03,0x11,0x00,0x00,0x43,0x10,0x23,
-0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x23,0x00,0x02,0x10,0x80,0x27,0x83,0xb5,0x70,
-0x00,0x43,0x10,0x21,0xa0,0x40,0x00,0x04,0x11,0x60,0x00,0x4f,0x00,0x00,0x00,0x00,
-0x01,0x49,0x10,0x21,0x00,0x02,0x20,0x80,0x27,0x85,0x90,0x10,0x00,0x85,0x10,0x21,
-0x80,0x43,0x00,0x05,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x42,0x01,0x49,0x10,0x21,
-0x27,0x82,0x90,0x18,0x00,0x82,0x10,0x21,0x80,0x44,0x00,0x00,0x27,0x82,0xb5,0x78,
-0x00,0x04,0x19,0x00,0x00,0x64,0x18,0x23,0x00,0x03,0x18,0x80,0x00,0x64,0x18,0x23,
-0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x90,0x45,0x00,0x05,0x27,0x84,0xb4,0xa0,
-0x00,0x64,0x18,0x21,0x90,0x63,0x00,0x00,0x10,0xa0,0x00,0x2c,0x2c,0x64,0x00,0x0c,
-0x14,0x80,0x00,0x04,0x00,0x60,0x10,0x21,0x00,0x06,0x11,0x00,0x00,0x62,0x10,0x21,
-0x24,0x42,0x00,0x24,0x3c,0x01,0xb0,0x03,0xa0,0x22,0x00,0xe1,0x14,0x80,0x00,0x06,
-0x00,0x60,0x28,0x21,0x00,0x07,0x10,0x40,0x00,0x46,0x10,0x21,0x00,0x02,0x11,0x00,
-0x00,0x62,0x10,0x21,0x24,0x45,0x00,0x04,0x01,0x49,0x10,0x21,0x27,0x83,0x90,0x10,
-0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0xa0,0x18,0x21,0xa0,0x45,0x00,0x03,
-0xa0,0x45,0x00,0x00,0x8f,0xa4,0x00,0x18,0x24,0x02,0x00,0x08,0x10,0x82,0x00,0x0c,
-0x00,0x60,0x28,0x21,0x24,0x02,0x00,0x01,0x02,0x60,0x20,0x21,0x0c,0x00,0x1f,0x6f,
-0xaf,0xa2,0x00,0x10,0x8f,0xa3,0x00,0x18,0x30,0x54,0xff,0xff,0x92,0x62,0x00,0x16,
-0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x25,0x08,0x00,0x0a,0x3f,0xa2,0x62,0x00,0x16,
-0x02,0x60,0x20,0x21,0x0c,0x00,0x1f,0x20,0xaf,0xa0,0x00,0x10,0x08,0x00,0x0b,0x31,
-0x00,0x00,0x00,0x00,0x08,0x00,0x0b,0x19,0x00,0x60,0x10,0x21,0x14,0x80,0xff,0xfd,
-0x00,0x00,0x00,0x00,0x00,0x06,0x11,0x00,0x00,0x62,0x10,0x21,0x08,0x00,0x0b,0x19,
-0x24,0x42,0x00,0x04,0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x90,0x43,0x00,0x00,
-0x08,0x00,0x0b,0x29,0xa0,0x43,0x00,0x03,0x27,0x85,0x90,0x10,0x08,0x00,0x0b,0x45,
-0x01,0x49,0x10,0x21,0x3c,0x02,0x80,0x00,0x00,0x62,0x18,0x26,0x08,0x00,0x0a,0x7a,
-0x00,0xc2,0x30,0x26,0x12,0x00,0xff,0x2d,0x24,0x02,0x00,0x01,0x08,0x00,0x0a,0x7f,
-0x24,0x11,0x00,0x02,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xd0,
-0x24,0x42,0x2d,0x54,0x34,0x63,0x00,0x20,0x3c,0x05,0xb0,0x05,0xaf,0xb3,0x00,0x24,
-0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c,0xaf,0xbf,0x00,0x28,0xaf,0xb0,0x00,0x18,
-0xac,0x62,0x00,0x00,0x34,0xa5,0x02,0x42,0x90,0xa2,0x00,0x00,0x00,0x80,0x90,0x21,
-0x24,0x11,0x00,0x10,0x30,0x53,0x00,0xff,0x24,0x02,0x00,0x10,0x12,0x22,0x00,0xcf,
-0x00,0x00,0x18,0x21,0x24,0x02,0x00,0x11,0x12,0x22,0x00,0xc1,0x24,0x02,0x00,0x12,
-0x12,0x22,0x00,0xb4,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0xad,0xae,0x43,0x00,0x40,
-0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c,0x8c,0x44,0x00,0x00,0x3c,0x03,0x00,0x02,
-0x34,0x63,0x00,0xff,0x00,0x83,0x80,0x24,0x00,0x10,0x14,0x43,0x10,0x40,0x00,0x05,
-0x00,0x00,0x00,0x00,0x8e,0x42,0x00,0x34,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x92,
-0x00,0x00,0x00,0x00,0x93,0x83,0x8b,0x71,0x00,0x00,0x00,0x00,0x30,0x62,0x00,0x02,
-0x10,0x40,0x00,0x04,0x32,0x10,0x00,0xff,0x00,0x10,0x11,0xc3,0x14,0x40,0x00,0x86,
-0x00,0x00,0x00,0x00,0x16,0x00,0x00,0x15,0x02,0x00,0x10,0x21,0x26,0x22,0x00,0x01,
-0x30,0x51,0x00,0xff,0x2e,0x23,0x00,0x13,0x14,0x60,0xff,0xdb,0x24,0x03,0x00,0x02,
-0x12,0x63,0x00,0x73,0x24,0x02,0x00,0x05,0x2a,0x62,0x00,0x03,0x10,0x40,0x00,0x58,
-0x24,0x02,0x00,0x04,0x24,0x02,0x00,0x01,0x12,0x62,0x00,0x4b,0x02,0x40,0x20,0x21,
-0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,
-0x30,0x70,0x00,0xff,0x12,0x00,0x00,0x06,0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x28,
-0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,
-0x92,0x46,0x00,0x04,0x8e,0x43,0x00,0x24,0x24,0x02,0x00,0x07,0x02,0x40,0x20,0x21,
-0x00,0x00,0x28,0x21,0x24,0x07,0x00,0x06,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xea,
-0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x24,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c,
-0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,0x16,0x00,0xff,0xec,0x02,0x00,0x10,0x21,
-0x92,0x46,0x00,0x05,0x8e,0x43,0x00,0x28,0x24,0x02,0x00,0x05,0x02,0x40,0x20,0x21,
-0x24,0x05,0x00,0x01,0x24,0x07,0x00,0x04,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xea,
-0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x28,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c,
-0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,0x16,0x00,0xff,0xdc,0x02,0x00,0x10,0x21,
-0x92,0x46,0x00,0x06,0x8e,0x43,0x00,0x2c,0x24,0x02,0x00,0x03,0x02,0x40,0x20,0x21,
-0x24,0x05,0x00,0x02,0x00,0x00,0x38,0x21,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xea,
-0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x2c,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c,
-0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,0x16,0x00,0xff,0xcc,0x02,0x00,0x10,0x21,
-0x92,0x46,0x00,0x07,0x8e,0x43,0x00,0x30,0x24,0x02,0x00,0x02,0x02,0x40,0x20,0x21,
-0x24,0x05,0x00,0x03,0x24,0x07,0x00,0x01,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xea,
-0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x30,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c,
-0x08,0x00,0x0b,0x9b,0x30,0x42,0x00,0xff,0x92,0x46,0x00,0x04,0x8e,0x43,0x00,0x24,
-0x24,0x02,0x00,0x07,0x00,0x00,0x28,0x21,0x24,0x07,0x00,0x06,0xaf,0xa2,0x00,0x10,
-0x0c,0x00,0x09,0xea,0xaf,0xa3,0x00,0x14,0x08,0x00,0x0b,0x94,0xae,0x42,0x00,0x24,
-0x12,0x62,0x00,0x0d,0x24,0x02,0x00,0x03,0x24,0x02,0x00,0x08,0x16,0x62,0xff,0xa8,
-0x02,0x40,0x20,0x21,0x92,0x46,0x00,0x07,0x8e,0x42,0x00,0x30,0x24,0x05,0x00,0x03,
-0x24,0x07,0x00,0x01,0xaf,0xa3,0x00,0x10,0x0c,0x00,0x09,0xea,0xaf,0xa2,0x00,0x14,
-0x08,0x00,0x0b,0x94,0xae,0x42,0x00,0x30,0x92,0x46,0x00,0x06,0x8e,0x43,0x00,0x2c,
-0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x02,0x00,0x00,0x38,0x21,0xaf,0xa2,0x00,0x10,
-0x0c,0x00,0x09,0xea,0xaf,0xa3,0x00,0x14,0x08,0x00,0x0b,0x94,0xae,0x42,0x00,0x2c,
-0x92,0x46,0x00,0x05,0x8e,0x43,0x00,0x28,0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x01,
-0x24,0x07,0x00,0x04,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xea,0xaf,0xa3,0x00,0x14,
-0x08,0x00,0x0b,0x94,0xae,0x42,0x00,0x28,0x0c,0x00,0x01,0x57,0x24,0x04,0x00,0x01,
-0x08,0x00,0x0b,0x85,0x00,0x00,0x00,0x00,0x8f,0x84,0xb4,0x40,0xae,0x40,0x00,0x34,
-0x94,0x85,0x00,0x14,0x0c,0x00,0x1b,0x66,0x00,0x00,0x00,0x00,0x93,0x83,0x8b,0x71,
-0x00,0x00,0x00,0x00,0x30,0x62,0x00,0x02,0x10,0x40,0xff,0x69,0x00,0x00,0x00,0x00,
-0x0c,0x00,0x01,0x57,0x00,0x00,0x20,0x21,0x08,0x00,0x0b,0x7d,0x00,0x00,0x00,0x00,
-0x02,0x40,0x20,0x21,0x0c,0x00,0x09,0x61,0x02,0x20,0x28,0x21,0x08,0x00,0x0b,0x71,
-0x3c,0x02,0xb0,0x05,0x8e,0x42,0x00,0x3c,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x4a,
-0x00,0x00,0x00,0x00,0x8f,0x82,0xb4,0x48,0x00,0x00,0x00,0x00,0x90,0x42,0x00,0x0a,
-0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x2b,0x08,0x00,0x0b,0x6e,0xae,0x43,0x00,0x3c,
-0x8e,0x42,0x00,0x38,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x3d,0x24,0x02,0x00,0x12,
-0x8f,0x82,0xb4,0x44,0x00,0x00,0x00,0x00,0x90,0x42,0x00,0x0a,0x00,0x00,0x00,0x00,
-0x00,0x02,0x18,0x2b,0x08,0x00,0x0b,0x6e,0xae,0x43,0x00,0x38,0x8e,0x42,0x00,0x34,
-0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x30,0x24,0x02,0x00,0x11,0x8f,0x82,0xb4,0x40,
-0x00,0x00,0x00,0x00,0x90,0x42,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x2b,
-0x08,0x00,0x0b,0x6e,0xae,0x43,0x00,0x34,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,
-0x27,0xbd,0xff,0xe0,0x34,0x63,0x00,0x20,0x24,0x42,0x31,0x08,0x3c,0x08,0xb0,0x03,
-0xaf,0xb1,0x00,0x14,0xac,0x62,0x00,0x00,0x35,0x08,0x01,0x00,0xaf,0xbf,0x00,0x18,
-0xaf,0xb0,0x00,0x10,0x91,0x03,0x00,0x00,0x00,0xa0,0x48,0x21,0x24,0x11,0x00,0x0a,
-0x2c,0xa5,0x00,0x04,0x24,0x02,0x00,0x10,0x00,0x45,0x88,0x0a,0x30,0x63,0x00,0x01,
-0x00,0xc0,0x28,0x21,0x14,0x60,0x00,0x02,0x00,0x11,0x40,0x40,0x02,0x20,0x40,0x21,
-0x84,0x83,0x00,0x0c,0x31,0x11,0x00,0xff,0x01,0x20,0x20,0x21,0x00,0x03,0x10,0xc0,
-0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x08,0x00,0x43,0x10,0x21,
-0x84,0x43,0x00,0x04,0x24,0x06,0x00,0x0e,0x10,0xe0,0x00,0x06,0x02,0x23,0x80,0x21,
-0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,
-0x27,0xbd,0x00,0x20,0x0c,0x00,0x08,0xe3,0x00,0x00,0x00,0x00,0x02,0x11,0x18,0x21,
-0x08,0x00,0x0c,0x64,0x00,0x62,0x80,0x21,0x27,0xbd,0xff,0xd0,0xaf,0xbf,0x00,0x28,
-0xaf,0xb4,0x00,0x20,0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,0xaf,0xb5,0x00,0x24,
-0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x84,0x82,0x00,0x0c,0x3c,0x06,0xb0,0x03,
-0x34,0xc6,0x00,0x20,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x80,
-0x27,0x82,0x90,0x04,0x00,0x62,0x10,0x21,0x8c,0x55,0x00,0x18,0x3c,0x02,0x80,0x00,
-0x24,0x42,0x31,0xb8,0xac,0xc2,0x00,0x00,0x8e,0xb0,0x00,0x08,0x27,0x82,0x90,0x08,
-0x00,0x62,0x18,0x21,0x90,0x71,0x00,0x07,0x00,0x10,0x86,0x43,0x32,0x10,0x00,0x01,
-0x00,0xa0,0x38,0x21,0x02,0x00,0x30,0x21,0x00,0xa0,0x98,0x21,0x02,0x20,0x28,0x21,
-0x0c,0x00,0x0c,0x42,0x00,0x80,0x90,0x21,0x02,0x20,0x20,0x21,0x02,0x00,0x28,0x21,
-0x24,0x06,0x00,0x14,0x0c,0x00,0x08,0xe3,0x00,0x40,0xa0,0x21,0x86,0x43,0x00,0x0c,
-0x3c,0x09,0xb0,0x09,0x3c,0x08,0xb0,0x09,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
-0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,0x80,0x43,0x00,0x06,
-0x3c,0x07,0xb0,0x09,0x3c,0x05,0xb0,0x09,0x28,0x62,0x00,0x00,0x24,0x64,0x00,0x03,
-0x00,0x82,0x18,0x0b,0x00,0x03,0x18,0x83,0x3c,0x02,0xb0,0x09,0x00,0x03,0x18,0x80,
-0x34,0x42,0x01,0x02,0x35,0x29,0x01,0x10,0x35,0x08,0x01,0x14,0x34,0xe7,0x01,0x20,
-0x34,0xa5,0x01,0x24,0xa4,0x54,0x00,0x00,0x12,0x60,0x00,0x11,0x02,0xa3,0xa8,0x21,
-0x8e,0xa2,0x00,0x0c,0x8e,0xa3,0x00,0x08,0x00,0x02,0x14,0x00,0x00,0x03,0x1c,0x02,
-0x00,0x43,0x10,0x21,0xad,0x22,0x00,0x00,0x8e,0xa3,0x00,0x0c,0x00,0x00,0x00,0x00,
-0x00,0x03,0x1c,0x02,0xa5,0x03,0x00,0x00,0x8f,0xbf,0x00,0x28,0x7b,0xb4,0x01,0x3c,
-0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,
-0x8e,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0xad,0x22,0x00,0x00,0x8e,0xa4,0x00,0x08,
-0x00,0x00,0x00,0x00,0xa5,0x04,0x00,0x00,0x7a,0xa2,0x00,0x7c,0x00,0x00,0x00,0x00,
-0x00,0x03,0x1c,0x00,0x00,0x02,0x14,0x02,0x00,0x62,0x18,0x21,0xac,0xe3,0x00,0x00,
-0x8e,0xa2,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x14,0x02,0x08,0x00,0x0c,0xb6,
-0xa4,0xa2,0x00,0x00,0x27,0xbd,0xff,0xe0,0xaf,0xb2,0x00,0x18,0xaf,0xb0,0x00,0x10,
-0xaf,0xbf,0x00,0x1c,0xaf,0xb1,0x00,0x14,0x84,0x82,0x00,0x0c,0x00,0x80,0x90,0x21,
-0x3c,0x05,0xb0,0x03,0x00,0x02,0x20,0xc0,0x00,0x82,0x20,0x21,0x00,0x04,0x20,0x80,
-0x27,0x82,0x90,0x04,0x00,0x82,0x10,0x21,0x8c,0x51,0x00,0x18,0x3c,0x02,0x80,0x00,
-0x34,0xa5,0x00,0x20,0x24,0x42,0x33,0x34,0x27,0x83,0x90,0x08,0xac,0xa2,0x00,0x00,
-0x00,0x83,0x20,0x21,0x3c,0x02,0xb0,0x03,0x90,0x86,0x00,0x07,0x34,0x42,0x01,0x00,
-0x8e,0x23,0x00,0x08,0x90,0x44,0x00,0x00,0x2c,0xc5,0x00,0x04,0x24,0x02,0x00,0x10,
-0x24,0x10,0x00,0x0a,0x00,0x45,0x80,0x0a,0x00,0x03,0x1e,0x43,0x30,0x84,0x00,0x01,
-0x30,0x65,0x00,0x01,0x14,0x80,0x00,0x02,0x00,0x10,0x10,0x40,0x02,0x00,0x10,0x21,
-0x00,0xc0,0x20,0x21,0x24,0x06,0x00,0x20,0x0c,0x00,0x08,0xe3,0x30,0x50,0x00,0xff,
-0x86,0x44,0x00,0x0c,0x27,0x85,0x90,0x10,0x3c,0x06,0xb0,0x09,0x00,0x04,0x18,0xc0,
-0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x65,0x18,0x21,0x80,0x64,0x00,0x06,
-0x00,0x50,0x10,0x21,0x34,0xc6,0x01,0x02,0x24,0x85,0x00,0x03,0x28,0x83,0x00,0x00,
-0x00,0xa3,0x20,0x0b,0x00,0x04,0x20,0x83,0x00,0x04,0x20,0x80,0xa4,0xc2,0x00,0x00,
-0x02,0x24,0x20,0x21,0x8c,0x83,0x00,0x04,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x10,
-0xac,0x43,0x00,0x00,0x8c,0x86,0x00,0x08,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x14,
-0xa4,0x46,0x00,0x00,0x8c,0x85,0x00,0x0c,0x8c,0x82,0x00,0x08,0x3c,0x06,0xb0,0x09,
-0x00,0x05,0x2c,0x00,0x00,0x02,0x14,0x02,0x00,0xa2,0x28,0x21,0x34,0xc6,0x01,0x20,
-0xac,0xc5,0x00,0x00,0x8c,0x83,0x00,0x0c,0x3c,0x05,0xb0,0x09,0x34,0xa5,0x01,0x24,
-0x00,0x03,0x1c,0x02,0xa4,0xa3,0x00,0x00,0x92,0x42,0x00,0x0a,0x3c,0x03,0xb0,0x09,
-0x34,0x63,0x01,0x30,0x00,0x02,0x13,0x00,0x24,0x42,0x00,0x04,0x30,0x42,0xff,0xff,
-0xa4,0x62,0x00,0x00,0x86,0x44,0x00,0x0c,0x27,0x83,0x90,0x18,0x8f,0xbf,0x00,0x1c,
-0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,
-0x94,0x44,0x00,0x02,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x3c,0x05,0xb0,0x09,
-0x34,0xa5,0x01,0x32,0xa4,0xa4,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,
-0x27,0xbd,0xff,0xe0,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00,0xaf,0xb0,0x00,0x10,
-0x34,0x42,0x00,0x20,0x00,0xa0,0x80,0x21,0x24,0x63,0x34,0xc0,0x00,0x05,0x2c,0x43,
-0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x18,0xac,0x43,0x00,0x00,0x10,0xa0,0x00,0x05,
-0x00,0x80,0x88,0x21,0x8c,0x82,0x00,0x34,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0xb6,
-0x00,0x00,0x00,0x00,0x32,0x10,0x00,0xff,0x12,0x00,0x00,0x4c,0x00,0x00,0x10,0x21,
-0x24,0x02,0x00,0x08,0x12,0x02,0x00,0xa3,0x2a,0x02,0x00,0x09,0x10,0x40,0x00,0x89,
-0x24,0x02,0x00,0x40,0x24,0x04,0x00,0x02,0x12,0x04,0x00,0x79,0x2a,0x02,0x00,0x03,
-0x10,0x40,0x00,0x69,0x24,0x02,0x00,0x04,0x24,0x02,0x00,0x01,0x12,0x02,0x00,0x5a,
-0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,0x34,0x42,0x00,0x08,0x3c,0x03,0x80,0x00,
-0xa2,0x20,0x00,0x4e,0xac,0x43,0x00,0x00,0x82,0x24,0x00,0x11,0x92,0x27,0x00,0x11,
-0x10,0x80,0x00,0x4e,0x00,0x00,0x00,0x00,0x92,0x26,0x00,0x0a,0x24,0x02,0x00,0x12,
-0x10,0x46,0x00,0x09,0x30,0xc2,0x00,0xff,0x27,0x83,0xb4,0x00,0x00,0x02,0x10,0x80,
-0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0x83,0x00,0x14,
-0x00,0x00,0x00,0x00,0xa6,0x23,0x00,0x0c,0x3c,0x02,0xb0,0x09,0x34,0x42,0x00,0x40,
-0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x03,0xa2,0x23,0x00,0x10,
-0x14,0x60,0x00,0x2b,0x30,0x65,0x00,0x01,0x30,0xc2,0x00,0xff,0x27,0x83,0xb4,0x00,
-0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x82,0x23,0x00,0x12,
-0x90,0x82,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x02,0x11,0x42,0x30,0x42,0x00,0x01,
-0x00,0x62,0x18,0x21,0x00,0x03,0x26,0x00,0x14,0x80,0x00,0x18,0xa2,0x23,0x00,0x12,
-0x00,0x07,0x16,0x00,0x14,0x40,0x00,0x11,0x24,0x02,0x00,0x01,0x96,0x23,0x00,0x0c,
-0x27,0x84,0x90,0x10,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,
-0x00,0x44,0x10,0x21,0x80,0x45,0x00,0x06,0x00,0x03,0x1a,0x00,0x3c,0x02,0xb0,0x00,
-0x00,0x65,0x18,0x21,0x00,0x62,0x18,0x21,0x90,0x64,0x00,0x00,0x90,0x62,0x00,0x04,
-0xa2,0x20,0x00,0x15,0xa3,0x80,0x8b,0xd4,0x24,0x02,0x00,0x01,0x8f,0xbf,0x00,0x18,
-0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x0c,0x00,0x0c,0xcd,
-0x02,0x20,0x20,0x21,0x92,0x27,0x00,0x11,0x08,0x00,0x0d,0x7d,0x00,0x07,0x16,0x00,
-0x0c,0x00,0x0c,0x6e,0x02,0x20,0x20,0x21,0x86,0x23,0x00,0x0c,0x27,0x84,0x90,0x08,
-0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x44,0x20,0x21,
-0x90,0x85,0x00,0x07,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,0xa2,0x25,0x00,0x13,
-0x90,0x83,0x00,0x07,0x08,0x00,0x0d,0x95,0xa0,0x43,0x00,0x02,0x92,0x26,0x00,0x0a,
-0x08,0x00,0x0d,0x5e,0x30,0xc2,0x00,0xff,0x8e,0x22,0x00,0x24,0x00,0x00,0x00,0x00,
-0x10,0x50,0x00,0x07,0xa2,0x20,0x00,0x08,0x24,0x02,0x00,0x07,0xa2,0x22,0x00,0x0a,
-0x92,0x22,0x00,0x27,0xae,0x20,0x00,0x24,0x08,0x00,0x0d,0x51,0xa2,0x22,0x00,0x04,
-0x08,0x00,0x0d,0xaf,0x24,0x02,0x00,0x06,0x16,0x02,0xff,0x9b,0x3c,0x02,0xb0,0x05,
-0x8e,0x23,0x00,0x2c,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x07,0xa2,0x24,0x00,0x08,
-0x24,0x02,0x00,0x03,0xa2,0x22,0x00,0x0a,0x92,0x22,0x00,0x2f,0xae,0x20,0x00,0x2c,
-0x08,0x00,0x0d,0x51,0xa2,0x22,0x00,0x06,0x08,0x00,0x0d,0xbe,0xa2,0x20,0x00,0x0a,
-0x8e,0x22,0x00,0x28,0x24,0x03,0x00,0x01,0x24,0x04,0x00,0x01,0x10,0x44,0x00,0x07,
-0xa2,0x23,0x00,0x08,0x24,0x02,0x00,0x05,0xa2,0x22,0x00,0x0a,0x92,0x22,0x00,0x2b,
-0xae,0x20,0x00,0x28,0x08,0x00,0x0d,0x51,0xa2,0x22,0x00,0x05,0x08,0x00,0x0d,0xca,
-0x24,0x02,0x00,0x04,0x12,0x02,0x00,0x12,0x2a,0x02,0x00,0x41,0x10,0x40,0x00,0x09,
-0x24,0x02,0x00,0x80,0x24,0x02,0x00,0x20,0x16,0x02,0xff,0x7b,0x3c,0x02,0xb0,0x05,
-0x24,0x02,0x00,0x12,0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08,0x08,0x00,0x0d,0x51,
-0xae,0x20,0x00,0x3c,0x16,0x02,0xff,0x74,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x10,
-0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08,0x08,0x00,0x0d,0x51,0xae,0x20,0x00,0x34,
-0x24,0x02,0x00,0x11,0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08,0x08,0x00,0x0d,0x51,
-0xae,0x20,0x00,0x38,0x8e,0x24,0x00,0x30,0x24,0x02,0x00,0x03,0x24,0x03,0x00,0x01,
-0x10,0x83,0x00,0x07,0xa2,0x22,0x00,0x08,0x24,0x02,0x00,0x02,0xa2,0x22,0x00,0x0a,
-0x92,0x22,0x00,0x33,0xae,0x20,0x00,0x30,0x08,0x00,0x0d,0x51,0xa2,0x22,0x00,0x07,
-0x08,0x00,0x0d,0xf0,0xa2,0x24,0x00,0x0a,0x8f,0x84,0xb4,0x40,0xae,0x20,0x00,0x34,
-0x94,0x85,0x00,0x14,0x0c,0x00,0x1b,0x66,0x32,0x10,0x00,0xff,0x08,0x00,0x0d,0x42,
-0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x37,0xf4,
-0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,0x80,0xa2,0x00,0x15,0x3c,0x06,0xb0,0x05,
-0x10,0x40,0x00,0x0a,0x34,0xc6,0x02,0x54,0x83,0x83,0x8b,0xd4,0x00,0x00,0x00,0x00,
-0xac,0x83,0x00,0x24,0x8c,0xc2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x42,
-0x30,0x42,0x00,0x01,0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x28,0x8c,0x82,0x00,0x2c,
-0x3c,0x06,0xb0,0x05,0x34,0xc6,0x04,0x50,0x00,0x02,0x18,0x43,0x30,0x63,0x00,0x01,
-0x10,0x40,0x00,0x04,0x30,0x45,0x00,0x01,0xac,0x83,0x00,0x28,0x03,0xe0,0x00,0x08,
-0xac,0x85,0x00,0x24,0x90,0xc2,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,
-0x30,0x43,0x00,0x02,0x30,0x42,0x00,0x01,0xac,0x83,0x00,0x28,0x03,0xe0,0x00,0x08,
-0xac,0x82,0x00,0x24,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xd8,
-0x34,0x63,0x00,0x20,0x24,0x42,0x38,0x84,0xac,0x62,0x00,0x00,0xaf,0xb1,0x00,0x1c,
-0xaf,0xbf,0x00,0x20,0xaf,0xb0,0x00,0x18,0x90,0xa6,0x00,0x0a,0x27,0x83,0xb4,0x00,
-0x00,0xa0,0x88,0x21,0x00,0x06,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x50,0x00,0x00,
-0x80,0xa5,0x00,0x11,0x92,0x03,0x00,0x12,0x10,0xa0,0x00,0x04,0xa2,0x20,0x00,0x15,
-0x24,0x02,0x00,0x12,0x10,0xc2,0x00,0xda,0x00,0x00,0x00,0x00,0x82,0x22,0x00,0x12,
-0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x67,0x00,0x00,0x00,0x00,0xa2,0x20,0x00,0x12,
-0xa2,0x00,0x00,0x19,0x86,0x23,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0,
-0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x20,0x00,0x43,0x10,0x21,
-0xa0,0x40,0x00,0x00,0x92,0x03,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0xdf,
-0xa2,0x03,0x00,0x16,0x82,0x02,0x00,0x12,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x20,
-0x00,0x00,0x00,0x00,0x92,0x23,0x00,0x08,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x45,
-0x24,0x02,0x00,0x01,0xa2,0x20,0x00,0x04,0x92,0x08,0x00,0x04,0x00,0x00,0x00,0x00,
-0x15,0x00,0x00,0x1e,0x24,0x02,0x00,0x01,0x92,0x07,0x00,0x0a,0xa2,0x02,0x00,0x17,
-0x92,0x02,0x00,0x16,0x30,0xe3,0x00,0xff,0x30,0x42,0x00,0xe4,0x10,0x60,0x00,0x03,
-0xa2,0x02,0x00,0x16,0x34,0x42,0x00,0x01,0xa2,0x02,0x00,0x16,0x11,0x00,0x00,0x05,
-0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16,0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x02,
-0xa2,0x02,0x00,0x16,0x92,0x02,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x08,
-0x00,0x00,0x00,0x00,0x96,0x02,0x00,0x06,0x00,0x00,0x00,0x00,0xa6,0x02,0x00,0x14,
-0x8f,0xbf,0x00,0x20,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,
-0x96,0x02,0x00,0x00,0x08,0x00,0x0e,0x6c,0xa6,0x02,0x00,0x14,0x92,0x07,0x00,0x0a,
-0x00,0x00,0x00,0x00,0x14,0xe0,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x0e,0x58,
-0xa2,0x00,0x00,0x17,0x96,0x04,0x00,0x00,0x96,0x05,0x00,0x06,0x27,0x86,0x90,0x00,
-0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21,
-0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21,
-0x8c,0x66,0x00,0x08,0x8c,0x45,0x00,0x08,0x3c,0x03,0x80,0x00,0x00,0xc3,0x20,0x24,
-0x10,0x80,0x00,0x08,0x00,0xa3,0x10,0x24,0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21,
-0x10,0x80,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0xa6,0x18,0x2b,0x08,0x00,0x0e,0x58,
-0xa2,0x03,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0xa6,0x18,0x2b,0x08,0x00,0x0e,0x8c,
-0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x09,0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x05,
-0x24,0x02,0x00,0x03,0x14,0x62,0xff,0xb8,0x00,0x00,0x00,0x00,0x08,0x00,0x0e,0x52,
-0xa2,0x20,0x00,0x07,0x08,0x00,0x0e,0x52,0xa2,0x20,0x00,0x06,0x08,0x00,0x0e,0x52,
-0xa2,0x20,0x00,0x05,0x82,0x22,0x00,0x10,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x69,
-0x2c,0x62,0x00,0x02,0x10,0x40,0x00,0x49,0x3c,0x02,0xb0,0x09,0x92,0x25,0x00,0x08,
-0x00,0x00,0x00,0x00,0x30,0xa6,0x00,0xff,0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x3b,
-0x2c,0xc2,0x00,0x10,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,
-0x24,0x02,0x00,0x01,0x00,0xc2,0x10,0x04,0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24,
-0xa0,0x83,0x00,0x00,0x86,0x23,0x00,0x0c,0x96,0x26,0x00,0x0c,0x00,0x03,0x10,0xc0,
-0x00,0x43,0x10,0x21,0x00,0x02,0x28,0x80,0x27,0x83,0x90,0x04,0x00,0xa3,0x18,0x21,
-0x8c,0x64,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x04,0x00,0x00,0x00,0x00,
-0x30,0x42,0x00,0x10,0x10,0x40,0x00,0x18,0x24,0x07,0x00,0x01,0x93,0x82,0x8b,0x71,
-0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x0a,0x24,0x05,0x00,0x24,
-0x00,0x06,0x2c,0x00,0x00,0x05,0x2c,0x03,0x0c,0x00,0x1b,0x66,0x02,0x00,0x20,0x21,
-0x92,0x02,0x00,0x16,0xa2,0x00,0x00,0x12,0x30,0x42,0x00,0xe7,0x08,0x00,0x0e,0x49,
-0xa2,0x02,0x00,0x16,0xf0,0xc5,0x00,0x06,0x00,0x00,0x28,0x12,0x27,0x82,0x90,0x00,
-0x00,0xa2,0x28,0x21,0x0c,0x00,0x01,0x49,0x3c,0x04,0x00,0x80,0x96,0x26,0x00,0x0c,
-0x08,0x00,0x0e,0xc9,0x00,0x06,0x2c,0x00,0x27,0x83,0x90,0x10,0x27,0x82,0x90,0x18,
-0x00,0xa2,0x10,0x21,0x00,0xa3,0x18,0x21,0x90,0x44,0x00,0x00,0x90,0x65,0x00,0x05,
-0x93,0x82,0x80,0x10,0x00,0x00,0x30,0x21,0x0c,0x00,0x21,0x9a,0xaf,0xa2,0x00,0x10,
-0x96,0x26,0x00,0x0c,0x08,0x00,0x0e,0xc3,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xcd,
-0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x30,0xa5,0x00,0x0f,
-0x24,0x02,0x00,0x80,0x08,0x00,0x0e,0xb2,0x00,0xa2,0x10,0x07,0x86,0x26,0x00,0x0c,
-0x3c,0x03,0xb0,0x09,0x34,0x42,0x01,0x72,0x34,0x63,0x01,0x78,0x94,0x47,0x00,0x00,
-0x8c,0x65,0x00,0x00,0x00,0x06,0x10,0xc0,0x00,0x46,0x10,0x21,0x3c,0x04,0xb0,0x09,
-0xae,0x25,0x00,0x1c,0x34,0x84,0x01,0x7c,0x27,0x83,0x90,0x04,0x00,0x02,0x10,0x80,
-0x8c,0x85,0x00,0x00,0x00,0x43,0x10,0x21,0x8c,0x43,0x00,0x18,0xae,0x25,0x00,0x20,
-0xa6,0x27,0x00,0x18,0x8c,0x66,0x00,0x08,0x02,0x20,0x20,0x21,0x0c,0x00,0x0f,0x19,
-0x00,0x00,0x28,0x21,0x86,0x25,0x00,0x18,0x8e,0x26,0x00,0x1c,0x8e,0x27,0x00,0x20,
-0x02,0x20,0x20,0x21,0x0c,0x00,0x1c,0x68,0xaf,0xa2,0x00,0x10,0x08,0x00,0x0e,0x49,
-0xa2,0x02,0x00,0x12,0x92,0x22,0x00,0x08,0x08,0x00,0x0e,0x49,0xa2,0x22,0x00,0x09,
-0xa2,0x20,0x00,0x11,0x80,0x82,0x00,0x50,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x03,
-0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,0xac,0x40,0x00,0x00,0x08,0x00,0x0e,0x49,
-0xa0,0x80,0x00,0x50,0x94,0x8a,0x00,0x0c,0x24,0x03,0x00,0x24,0x00,0x80,0x70,0x21,
-0x3c,0x02,0x80,0x00,0x3c,0x04,0xb0,0x03,0x24,0x42,0x3c,0x64,0xf1,0x43,0x00,0x06,
-0x34,0x84,0x00,0x20,0x00,0x00,0x18,0x12,0x00,0xa0,0x68,0x21,0xac,0x82,0x00,0x00,
-0x27,0x85,0x90,0x10,0x27,0x82,0x90,0x0f,0x27,0xbd,0xff,0xf8,0x00,0x62,0x60,0x21,
-0x00,0x65,0x58,0x21,0x00,0x00,0xc0,0x21,0x11,0xa0,0x00,0xcc,0x00,0x00,0x78,0x21,
-0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
-0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x91,0x87,0x00,0x00,0x80,0x48,0x00,0x04,
-0x03,0xa0,0x60,0x21,0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,
-0x00,0x43,0x10,0x21,0x00,0x02,0x48,0x80,0x27,0x83,0x90,0x04,0xa3,0xa7,0x00,0x00,
-0x01,0x23,0x18,0x21,0x8c,0x64,0x00,0x18,0x25,0x02,0xff,0xff,0x00,0x48,0x40,0x0b,
-0x8c,0x83,0x00,0x04,0x2d,0x05,0x00,0x07,0x24,0x02,0x00,0x06,0x30,0x63,0x00,0x08,
-0x14,0x60,0x00,0x35,0x00,0x45,0x40,0x0a,0x93,0xa7,0x00,0x00,0x27,0x82,0x90,0x18,
-0x01,0x22,0x10,0x21,0x30,0xe3,0x00,0xf0,0x38,0x63,0x00,0x50,0x30,0xe5,0x00,0xff,
-0x00,0x05,0x20,0x2b,0x00,0x03,0x18,0x2b,0x00,0x64,0x18,0x24,0x90,0x49,0x00,0x00,
-0x10,0x60,0x00,0x16,0x30,0xe4,0x00,0x0f,0x24,0x02,0x00,0x04,0x10,0xa2,0x00,0x9d,
-0x00,0x00,0x00,0x00,0x11,0xa0,0x00,0x3a,0x2c,0xa2,0x00,0x0c,0x10,0x40,0x00,0x02,
-0x24,0x84,0x00,0x0c,0x00,0xe0,0x20,0x21,0x30,0x84,0x00,0xff,0x00,0x04,0x10,0x40,
-0x27,0x83,0xbb,0x1c,0x00,0x44,0x10,0x21,0x00,0x43,0x10,0x21,0x90,0x47,0x00,0x00,
-0x00,0x00,0x00,0x00,0x2c,0xe3,0x00,0x0c,0xa3,0xa7,0x00,0x00,0x10,0x60,0x00,0x02,
-0x24,0xe2,0x00,0x04,0x00,0xe0,0x10,0x21,0xa3,0xa2,0x00,0x00,0x91,0x65,0x00,0x00,
-0x91,0x82,0x00,0x00,0x30,0xa3,0x00,0xff,0x00,0x62,0x10,0x2b,0x10,0x40,0x00,0x0e,
-0x2c,0x62,0x00,0x0c,0x14,0x40,0x00,0x03,0x00,0x60,0x20,0x21,0x30,0xa2,0x00,0x0f,
-0x24,0x44,0x00,0x0c,0x00,0x04,0x10,0x40,0x00,0x44,0x20,0x21,0x27,0x83,0xbb,0x1c,
-0x00,0x83,0x18,0x21,0x90,0x62,0x00,0x02,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x05,
-0x00,0x09,0x11,0x00,0xa1,0x85,0x00,0x00,0x93,0xa2,0x00,0x00,0x03,0xe0,0x00,0x08,
-0x27,0xbd,0x00,0x08,0x00,0x49,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x23,
-0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x27,0x83,0xb4,0xa8,0x00,0x43,0x10,0x21,
-0x90,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x83,0x00,0x0c,0x14,0x60,0x00,0x06,
-0x00,0x80,0x10,0x21,0x00,0x18,0x10,0x40,0x00,0x4f,0x10,0x21,0x00,0x02,0x11,0x00,
-0x00,0x82,0x10,0x21,0x24,0x42,0x00,0x04,0x08,0x00,0x0f,0x7a,0xa1,0x82,0x00,0x00,
-0x8f,0x8d,0x81,0x5c,0x00,0x00,0x00,0x00,0x01,0xa8,0x10,0x21,0x90,0x43,0x00,0x00,
-0x00,0x00,0x00,0x00,0x10,0x60,0xff,0xd1,0x00,0x00,0x28,0x21,0x00,0x06,0x74,0x82,
-0x30,0xe2,0x00,0xff,0x2c,0x42,0x00,0x0c,0x14,0x40,0x00,0x03,0x00,0xe0,0x10,0x21,
-0x30,0xe2,0x00,0x0f,0x24,0x42,0x00,0x0c,0x30,0x44,0x00,0xff,0xa3,0xa2,0x00,0x00,
-0x24,0x02,0x00,0x0c,0x10,0x82,0x00,0x0d,0x00,0x09,0x11,0x00,0x00,0x49,0x10,0x23,
-0x00,0x02,0x10,0x80,0x00,0x04,0x18,0x40,0x00,0x49,0x10,0x23,0x00,0x64,0x18,0x21,
-0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x27,0x84,0xb4,0xa8,0x00,0x44,0x10,0x21,
-0x90,0x47,0x00,0x00,0x00,0x00,0x00,0x00,0xa3,0xa7,0x00,0x00,0x00,0x0a,0x1c,0x00,
-0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,
-0x27,0x83,0x90,0x04,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x18,0x00,0x00,0x00,0x00,
-0x8c,0x83,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10,0x14,0x60,0x00,0x33,
-0x00,0x06,0x14,0x42,0x00,0x09,0x11,0x00,0x00,0x49,0x10,0x23,0x00,0x02,0x10,0x80,
-0x00,0x49,0x10,0x23,0x27,0x83,0xb5,0x78,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,
-0x90,0x44,0x00,0x04,0x90,0x43,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x64,0xc0,0x24,
-0x93,0xa7,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0xe2,0x00,0x0f,0x10,0x40,0x00,0x0f,
-0x31,0xcf,0x00,0x01,0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,
-0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x84,0x90,0x00,0x00,0x44,0x10,0x21,
-0x84,0x43,0x00,0x06,0x00,0x00,0x00,0x00,0x28,0x63,0x06,0x41,0x14,0x60,0x00,0x04,
-0x30,0xe2,0x00,0xff,0x24,0x07,0x00,0x0f,0xa3,0xa7,0x00,0x00,0x30,0xe2,0x00,0xff,
-0x2c,0x42,0x00,0x0c,0x14,0x40,0x00,0x06,0x00,0xe0,0x10,0x21,0x00,0x18,0x10,0x40,
-0x00,0x4f,0x10,0x21,0x00,0x02,0x11,0x00,0x00,0x47,0x10,0x21,0x24,0x42,0x00,0x04,
-0xa3,0xa2,0x00,0x00,0x00,0x40,0x38,0x21,0x01,0xa8,0x10,0x21,0x90,0x43,0x00,0x00,
-0x24,0xa4,0x00,0x01,0x30,0x85,0xff,0xff,0x00,0xa3,0x18,0x2b,0x14,0x60,0xff,0xad,
-0x30,0xe2,0x00,0xff,0x08,0x00,0x0f,0x67,0x00,0x00,0x00,0x00,0x08,0x00,0x0f,0xc8,
-0x30,0x58,0x00,0x01,0x81,0xc2,0x00,0x48,0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x73,
-0x00,0x00,0x00,0x00,0x08,0x00,0x0f,0x55,0x00,0x00,0x00,0x00,0x00,0x0a,0x1c,0x00,
-0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,
-0x00,0x45,0x10,0x21,0x80,0x48,0x00,0x05,0x91,0x67,0x00,0x00,0x08,0x00,0x0f,0x35,
-0x03,0xa0,0x58,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,
-0x24,0x42,0x40,0x04,0x03,0xe0,0x00,0x08,0xac,0x62,0x00,0x00,0x27,0xbd,0xff,0xc0,
-0xaf,0xb7,0x00,0x34,0xaf,0xb6,0x00,0x30,0xaf,0xb5,0x00,0x2c,0xaf,0xb4,0x00,0x28,
-0xaf,0xb3,0x00,0x24,0xaf,0xb2,0x00,0x20,0xaf,0xbf,0x00,0x3c,0xaf,0xbe,0x00,0x38,
-0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,0x84,0x82,0x00,0x0c,0x27,0x93,0x90,0x04,
-0x3c,0x05,0xb0,0x03,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x80,
-0x00,0x73,0x10,0x21,0x8c,0x5e,0x00,0x18,0x3c,0x02,0x80,0x00,0x34,0xa5,0x00,0x20,
-0x24,0x42,0x40,0x1c,0xac,0xa2,0x00,0x00,0x8f,0xd0,0x00,0x08,0x27,0x95,0x90,0x10,
-0x00,0x75,0x18,0x21,0x00,0x00,0x28,0x21,0x02,0x00,0x30,0x21,0x90,0x71,0x00,0x00,
-0x0c,0x00,0x0f,0x19,0x00,0x80,0xb0,0x21,0x00,0x40,0x90,0x21,0x00,0x10,0x14,0x42,
-0x30,0x54,0x00,0x01,0x02,0x40,0x20,0x21,0x00,0x10,0x14,0x82,0x02,0x80,0x28,0x21,
-0x12,0x51,0x00,0x23,0x00,0x10,0xbf,0xc2,0x86,0xc3,0x00,0x0c,0x30,0x50,0x00,0x01,
-0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x55,0x10,0x21,
-0xa0,0x52,0x00,0x00,0x86,0xc3,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0,
-0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x53,0x30,0x21,0x8c,0xc7,0x00,0x18,
-0x27,0x83,0x90,0x00,0x00,0x43,0x10,0x21,0x8c,0xe3,0x00,0x04,0x84,0x46,0x00,0x06,
-0x00,0x03,0x19,0x42,0x0c,0x00,0x08,0xe3,0x30,0x73,0x00,0x01,0x00,0x40,0x88,0x21,
-0x02,0x40,0x20,0x21,0x02,0x80,0x28,0x21,0x16,0xe0,0x00,0x10,0x02,0x00,0x30,0x21,
-0x86,0xc2,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,
-0x00,0x03,0x18,0x80,0x27,0x82,0x90,0x08,0x00,0x62,0x18,0x21,0xa4,0x71,0x00,0x04,
-0x7b,0xbe,0x01,0xfc,0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c,
-0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,0x86,0xc3,0x00,0x0c,
-0xaf,0xb3,0x00,0x10,0xaf,0xa0,0x00,0x14,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
-0x00,0x02,0x10,0x80,0x00,0x55,0x10,0x21,0x80,0x47,0x00,0x06,0x00,0x00,0x00,0x00,
-0x24,0xe7,0x00,0x02,0x00,0x07,0x17,0xc2,0x00,0xe2,0x38,0x21,0x00,0x07,0x38,0x43,
-0x00,0x07,0x38,0x40,0x0c,0x00,0x09,0x0a,0x03,0xc7,0x38,0x21,0x08,0x00,0x10,0x48,
-0x02,0x22,0x88,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xd0,
-0x34,0x63,0x00,0x20,0x24,0x42,0x41,0xa4,0xaf,0xb2,0x00,0x20,0xac,0x62,0x00,0x00,
-0xaf,0xbf,0x00,0x28,0xaf,0xb3,0x00,0x24,0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,
-0x3c,0x02,0xb0,0x03,0x90,0x83,0x00,0x0a,0x34,0x42,0x01,0x04,0x94,0x45,0x00,0x00,
-0x00,0x03,0x18,0x80,0x27,0x82,0xb4,0x00,0x00,0x62,0x18,0x21,0x30,0xa6,0xff,0xff,
-0x8c,0x71,0x00,0x00,0x80,0x85,0x00,0x12,0x30,0xc9,0x00,0xff,0x00,0x06,0x32,0x02,
-0xa4,0x86,0x00,0x44,0xa4,0x89,0x00,0x46,0x82,0x22,0x00,0x12,0x00,0x80,0x90,0x21,
-0x10,0xa0,0x00,0x1b,0xa0,0x80,0x00,0x15,0x00,0xc5,0x10,0x2a,0x10,0x40,0x00,0x14,
-0x00,0x00,0x00,0x00,0xa2,0x20,0x00,0x19,0x84,0x83,0x00,0x0c,0x00,0x00,0x00,0x00,
-0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x20,
-0x00,0x43,0x10,0x21,0xa0,0x40,0x00,0x00,0xa0,0x80,0x00,0x12,0x92,0x22,0x00,0x16,
-0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xdf,0xa2,0x22,0x00,0x16,0x8f,0xbf,0x00,0x28,
-0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,
-0x0c,0x00,0x10,0x01,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x97,0x00,0x00,0x00,0x00,
-0x28,0x42,0x00,0x02,0x10,0x40,0x01,0x76,0x00,0x00,0x28,0x21,0x94,0x87,0x00,0x0c,
-0x00,0x00,0x00,0x00,0x00,0xe0,0x10,0x21,0x00,0x02,0x14,0x00,0x00,0x02,0x14,0x03,
-0x00,0x07,0x24,0x00,0x00,0x04,0x24,0x03,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,
-0x00,0x04,0x28,0xc0,0x00,0xa4,0x28,0x21,0x27,0x82,0x90,0x20,0x00,0x03,0x18,0x80,
-0x00,0x62,0x18,0x21,0x00,0x05,0x28,0x80,0x27,0x82,0x90,0x08,0x00,0xa2,0x10,0x21,
-0x8c,0x68,0x00,0x00,0x80,0x44,0x00,0x06,0x27,0x82,0x90,0x10,0x00,0x08,0x1d,0x02,
-0x00,0xa2,0x28,0x21,0x38,0x84,0x00,0x00,0x30,0x63,0x00,0x01,0x01,0x24,0x30,0x0b,
-0x80,0xaa,0x00,0x04,0x80,0xa9,0x00,0x05,0x10,0x60,0x00,0x02,0x00,0x08,0x14,0x02,
-0x30,0x46,0x00,0x0f,0x15,0x20,0x00,0x28,0x01,0x49,0x10,0x21,0x15,0x40,0x00,0x11,
-0x30,0xe3,0xff,0xff,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa8,0x00,0xff,
-0x2d,0x02,0x00,0x04,0x10,0x40,0x01,0x46,0x2d,0x02,0x00,0x10,0x3c,0x04,0xb0,0x05,
-0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01,0x01,0x02,0x10,0x04,
-0x00,0x62,0x18,0x25,0xa0,0x83,0x00,0x00,0x96,0x47,0x00,0x0c,0x00,0x00,0x00,0x00,
-0x30,0xe3,0xff,0xff,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x27,0x84,0x90,0x10,
-0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x80,0x45,0x00,0x06,0x00,0x03,0x1a,0x00,
-0x3c,0x04,0xb0,0x00,0x00,0x65,0x18,0x21,0x00,0x64,0x20,0x21,0x94,0x82,0x00,0x00,
-0x82,0x43,0x00,0x10,0x00,0x02,0x14,0x00,0x14,0x60,0x00,0x06,0x00,0x02,0x3c,0x03,
-0x30,0xe2,0x00,0x04,0x14,0x40,0x00,0x04,0x01,0x49,0x10,0x21,0x34,0xe2,0x08,0x00,
-0xa4,0x82,0x00,0x00,0x01,0x49,0x10,0x21,0x00,0x02,0x16,0x00,0x00,0x02,0x16,0x03,
-0x00,0x46,0x10,0x2a,0x10,0x40,0x00,0x7c,0x00,0x00,0x00,0x00,0x82,0x42,0x00,0x10,
-0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0e,0x00,0x00,0x00,0x00,0x86,0x43,0x00,0x0c,
-0x25,0x44,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,
-0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,0xa0,0x44,0x00,0x04,0x92,0x23,0x00,0x16,
-0x02,0x40,0x20,0x21,0x30,0x63,0x00,0xfb,0x08,0x00,0x10,0x9c,0xa2,0x23,0x00,0x16,
-0x86,0x43,0x00,0x0c,0x25,0x24,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
-0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,0xa0,0x44,0x00,0x05,
-0x86,0x45,0x00,0x0c,0x0c,0x00,0x1e,0xea,0x02,0x20,0x20,0x21,0x10,0x40,0x00,0x5a,
-0x00,0x00,0x00,0x00,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa6,0x00,0xff,
-0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x4c,0x2c,0xc2,0x00,0x10,0x3c,0x04,0xb0,0x05,
-0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01,0x00,0xc2,0x10,0x04,
-0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24,0xa0,0x83,0x00,0x00,0x92,0x45,0x00,0x08,
-0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff,0x14,0xa0,0x00,0x33,0x24,0x02,0x00,0x01,
-0xa2,0x40,0x00,0x04,0x92,0x22,0x00,0x04,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x0c,
-0x24,0x02,0x00,0x01,0xa2,0x22,0x00,0x17,0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00,
-0x10,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0x96,0x22,0x00,0x06,0x08,0x00,0x10,0x97,
-0xa6,0x22,0x00,0x14,0x96,0x22,0x00,0x00,0x08,0x00,0x10,0x97,0xa6,0x22,0x00,0x14,
-0x92,0x22,0x00,0x0a,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,0x00,0x00,0x00,0x00,
-0x08,0x00,0x11,0x26,0xa2,0x20,0x00,0x17,0x96,0x24,0x00,0x00,0x96,0x25,0x00,0x06,
-0x27,0x86,0x90,0x00,0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x05,0x10,0xc0,
-0x00,0x45,0x10,0x21,0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x00,0x02,0x10,0x80,
-0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08,0x8c,0x44,0x00,0x08,0x3c,0x03,0x80,0x00,
-0x00,0xa3,0x30,0x24,0x10,0xc0,0x00,0x08,0x00,0x83,0x10,0x24,0x10,0x40,0x00,0x04,
-0x00,0x00,0x18,0x21,0x10,0xc0,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b,
-0x08,0x00,0x11,0x26,0xa2,0x23,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b,
-0x08,0x00,0x11,0x49,0x00,0x00,0x00,0x00,0x10,0xa2,0x00,0x09,0x24,0x02,0x00,0x02,
-0x10,0xa2,0x00,0x05,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xca,0x00,0x00,0x00,0x00,
-0x08,0x00,0x11,0x21,0xa2,0x40,0x00,0x07,0x08,0x00,0x11,0x21,0xa2,0x40,0x00,0x06,
-0x08,0x00,0x11,0x21,0xa2,0x40,0x00,0x05,0x14,0x40,0xff,0xbe,0x3c,0x04,0xb0,0x05,
-0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,
-0x08,0x00,0x11,0x18,0x00,0xa2,0x10,0x07,0x0c,0x00,0x10,0x07,0x02,0x40,0x20,0x21,
-0x08,0x00,0x10,0x97,0x00,0x00,0x00,0x00,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,
-0x30,0xa6,0x00,0xff,0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x99,0x2c,0xc2,0x00,0x10,
-0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01,
-0x00,0xc2,0x10,0x04,0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24,0xa0,0x83,0x00,0x00,
-0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff,0x14,0xa0,0x00,0x80,
-0x24,0x02,0x00,0x01,0xa2,0x40,0x00,0x04,0x86,0x43,0x00,0x0c,0x27,0x93,0x90,0x04,
-0x96,0x47,0x00,0x0c,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x28,0x80,
-0x00,0xb3,0x18,0x21,0x8c,0x64,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x04,
-0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x10,0x10,0x40,0x00,0x64,0x00,0x00,0x30,0x21,
-0x00,0x07,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
-0x00,0x02,0x10,0x80,0x00,0x53,0x10,0x21,0x8c,0x43,0x00,0x18,0x93,0x82,0x8b,0x71,
-0x8c,0x64,0x00,0x04,0x30,0x42,0x00,0x01,0x00,0x04,0x21,0x42,0x14,0x40,0x00,0x4d,
-0x30,0x90,0x00,0x01,0x00,0x07,0x2c,0x00,0x00,0x05,0x2c,0x03,0x0c,0x00,0x1b,0x66,
-0x02,0x20,0x20,0x21,0x96,0x26,0x00,0x06,0x12,0x00,0x00,0x14,0x30,0xc5,0xff,0xff,
-0x02,0x60,0x90,0x21,0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21,0x00,0x02,0x10,0x80,
-0x00,0x52,0x18,0x21,0x92,0x22,0x00,0x0a,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0b,
-0x02,0x20,0x20,0x21,0x8c,0x63,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x62,0x00,0x04,
-0x00,0x00,0x00,0x00,0x00,0x02,0x11,0x42,0x0c,0x00,0x1b,0x66,0x30,0x50,0x00,0x01,
-0x96,0x26,0x00,0x06,0x16,0x00,0xff,0xef,0x30,0xc5,0xff,0xff,0x92,0x22,0x00,0x04,
-0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x0d,0x24,0x02,0x00,0x01,0xa2,0x22,0x00,0x17,
-0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x05,0x00,0x00,0x00,0x00,
-0xa6,0x26,0x00,0x14,0x92,0x22,0x00,0x16,0x08,0x00,0x10,0x96,0x30,0x42,0x00,0xc3,
-0x96,0x22,0x00,0x00,0x08,0x00,0x11,0xbd,0xa6,0x22,0x00,0x14,0x92,0x22,0x00,0x0a,
-0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x11,0xb8,
-0xa2,0x20,0x00,0x17,0x96,0x24,0x00,0x00,0x30,0xc5,0xff,0xff,0x00,0x05,0x18,0xc0,
-0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x00,0x65,0x18,0x21,0x27,0x84,0x90,0x00,
-0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x00,0x03,0x18,0x80,0x8c,0x45,0x00,0x08,
-0x00,0x64,0x18,0x21,0x8c,0x64,0x00,0x08,0x3c,0x02,0x80,0x00,0x00,0xa2,0x38,0x24,
-0x10,0xe0,0x00,0x08,0x00,0x82,0x10,0x24,0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21,
-0x10,0xe0,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b,0x08,0x00,0x11,0xb8,
-0xa2,0x23,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b,0x08,0x00,0x11,0xdc,
-0x00,0x00,0x00,0x00,0x24,0x05,0x00,0x24,0xf0,0xe5,0x00,0x06,0x00,0x00,0x28,0x12,
-0x27,0x82,0x90,0x00,0x00,0xa2,0x28,0x21,0x0c,0x00,0x01,0x49,0x00,0x00,0x20,0x21,
-0x96,0x47,0x00,0x0c,0x08,0x00,0x11,0x9a,0x00,0x07,0x2c,0x00,0x27,0x83,0x90,0x10,
-0x27,0x82,0x90,0x18,0x00,0xa2,0x10,0x21,0x00,0xa3,0x18,0x21,0x90,0x44,0x00,0x00,
-0x90,0x65,0x00,0x05,0x93,0x82,0x80,0x10,0x24,0x07,0x00,0x01,0x0c,0x00,0x21,0x9a,
-0xaf,0xa2,0x00,0x10,0x96,0x47,0x00,0x0c,0x08,0x00,0x11,0x8d,0x00,0x07,0x1c,0x00,
-0x10,0xa2,0x00,0x09,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x05,0x24,0x02,0x00,0x03,
-0x14,0xa2,0xff,0x7d,0x00,0x00,0x00,0x00,0x08,0x00,0x11,0x7e,0xa2,0x40,0x00,0x07,
-0x08,0x00,0x11,0x7e,0xa2,0x40,0x00,0x06,0x08,0x00,0x11,0x7e,0xa2,0x40,0x00,0x05,
-0x14,0x40,0xff,0x71,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,
-0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,0x08,0x00,0x11,0x75,0x00,0xa2,0x10,0x07,
-0x14,0x40,0xfe,0xc3,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,
-0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,0x08,0x00,0x10,0xd0,0x00,0xa2,0x10,0x07,
-0x84,0x83,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
-0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x04,0x00,0x43,0x10,0x21,0x8c,0x47,0x00,0x18,
-0x00,0x00,0x00,0x00,0x8c,0xe6,0x00,0x08,0x0c,0x00,0x0f,0x19,0x00,0x00,0x00,0x00,
-0x02,0x40,0x20,0x21,0x00,0x00,0x28,0x21,0x00,0x00,0x30,0x21,0x00,0x00,0x38,0x21,
-0x0c,0x00,0x1c,0x68,0xaf,0xa2,0x00,0x10,0x00,0x02,0x1e,0x00,0x14,0x60,0xfe,0x6b,
-0xa2,0x22,0x00,0x12,0x92,0x43,0x00,0x08,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x40,
-0x24,0x02,0x00,0x01,0xa2,0x40,0x00,0x04,0x92,0x28,0x00,0x04,0x00,0x00,0x00,0x00,
-0x15,0x00,0x00,0x19,0x24,0x02,0x00,0x01,0x92,0x27,0x00,0x0a,0xa2,0x22,0x00,0x17,
-0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x10,0x00,0x00,0x00,0x00,
-0x96,0x22,0x00,0x06,0x00,0x00,0x00,0x00,0xa6,0x22,0x00,0x14,0x92,0x22,0x00,0x16,
-0x30,0xe3,0x00,0xff,0x30,0x42,0x00,0xc0,0x10,0x60,0x00,0x03,0xa2,0x22,0x00,0x16,
-0x34,0x42,0x00,0x01,0xa2,0x22,0x00,0x16,0x11,0x00,0xfe,0x50,0x00,0x00,0x00,0x00,
-0x92,0x22,0x00,0x16,0x08,0x00,0x10,0x96,0x34,0x42,0x00,0x02,0x96,0x22,0x00,0x00,
-0x08,0x00,0x12,0x3f,0xa6,0x22,0x00,0x14,0x92,0x27,0x00,0x0a,0x00,0x00,0x00,0x00,
-0x14,0xe0,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x12,0x38,0xa2,0x20,0x00,0x17,
-0x96,0x24,0x00,0x00,0x96,0x25,0x00,0x06,0x27,0x86,0x90,0x00,0x00,0x04,0x18,0xc0,
-0x00,0x64,0x18,0x21,0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21,0x00,0x03,0x18,0x80,
-0x00,0x66,0x18,0x21,0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08,
-0x8c,0x44,0x00,0x08,0x3c,0x03,0x80,0x00,0x00,0xa3,0x30,0x24,0x10,0xc0,0x00,0x08,
-0x00,0x83,0x10,0x24,0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21,0x10,0xc0,0x00,0x02,
-0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b,0x08,0x00,0x12,0x38,0xa2,0x23,0x00,0x17,
-0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b,0x08,0x00,0x12,0x67,0x00,0x00,0x00,0x00,
-0x10,0x62,0x00,0x09,0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x05,0x24,0x02,0x00,0x03,
-0x14,0x62,0xff,0xbd,0x00,0x00,0x00,0x00,0x08,0x00,0x12,0x32,0xa2,0x40,0x00,0x07,
-0x08,0x00,0x12,0x32,0xa2,0x40,0x00,0x06,0x08,0x00,0x12,0x32,0xa2,0x40,0x00,0x05,
-0x3c,0x02,0x80,0x00,0x00,0x82,0x30,0x24,0x10,0xc0,0x00,0x08,0x00,0xa2,0x18,0x24,
-0x10,0x60,0x00,0x04,0x00,0x00,0x10,0x21,0x10,0xc0,0x00,0x02,0x24,0x02,0x00,0x01,
-0x00,0xa4,0x10,0x2b,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x10,0x60,0xff,0xfd,
-0x00,0xa4,0x10,0x2b,0x08,0x00,0x12,0x82,0x00,0x00,0x00,0x00,0x30,0x82,0xff,0xff,
-0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,0x27,0x84,0x90,0x10,0x00,0x03,0x18,0x80,
-0x00,0x64,0x18,0x21,0x80,0x66,0x00,0x06,0x00,0x02,0x12,0x00,0x3c,0x03,0xb0,0x00,
-0x00,0x46,0x10,0x21,0x00,0x45,0x10,0x21,0x03,0xe0,0x00,0x08,0x00,0x43,0x10,0x21,
-0x27,0xbd,0xff,0xe0,0x30,0x82,0x00,0x7c,0x30,0x84,0xff,0x00,0xaf,0xbf,0x00,0x1c,
-0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x14,0x40,0x00,0x41,
-0x00,0x04,0x22,0x03,0x24,0x02,0x00,0x04,0x3c,0x10,0xb0,0x03,0x8e,0x10,0x00,0x00,
-0x10,0x82,0x00,0x32,0x24,0x02,0x00,0x08,0x10,0x82,0x00,0x03,0x32,0x02,0x00,0x20,
-0x08,0x00,0x12,0xa8,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x17,0x3c,0x02,0xb0,0x06,
-0x34,0x42,0x80,0x24,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x67,0x00,0xff,
-0x10,0xe0,0x00,0x23,0x00,0x00,0x88,0x21,0x8f,0x85,0x8f,0xe0,0x00,0x40,0x30,0x21,
-0x94,0xa2,0x00,0x08,0x8c,0xc3,0x00,0x00,0x26,0x31,0x00,0x01,0x24,0x42,0x00,0x02,
-0x30,0x42,0x01,0xff,0x34,0x63,0x01,0x00,0x02,0x27,0x20,0x2a,0xa4,0xa2,0x00,0x08,
-0x14,0x80,0xff,0xf7,0xac,0xc3,0x00,0x00,0x84,0xa3,0x00,0x08,0x3c,0x02,0xb0,0x03,
-0x34,0x42,0x00,0x30,0xac,0x43,0x00,0x00,0x27,0x92,0xb4,0x00,0x24,0x11,0x00,0x12,
-0x8e,0x44,0x00,0x00,0x26,0x31,0xff,0xff,0x90,0x82,0x00,0x10,0x00,0x00,0x00,0x00,
-0x10,0x40,0x00,0x03,0x26,0x52,0x00,0x04,0x0c,0x00,0x18,0xd0,0x00,0x00,0x00,0x00,
-0x06,0x21,0xff,0xf7,0x24,0x02,0xff,0xdf,0x02,0x02,0x80,0x24,0x3c,0x01,0xb0,0x03,
-0x0c,0x00,0x13,0x1c,0xac,0x30,0x00,0x00,0x08,0x00,0x12,0xa8,0x00,0x00,0x00,0x00,
-0x8f,0x85,0x8f,0xe0,0x08,0x00,0x12,0xbe,0x00,0x00,0x00,0x00,0x24,0x02,0xff,0x95,
-0x3c,0x03,0xb0,0x03,0x02,0x02,0x80,0x24,0x34,0x63,0x00,0x30,0x3c,0x01,0xb0,0x03,
-0xac,0x30,0x00,0x00,0x0c,0x00,0x12,0xe5,0xac,0x60,0x00,0x00,0x08,0x00,0x12,0xa8,
-0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x50,0x08,0x00,0x12,0xa8,
-0xac,0x46,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4b,0x94,0x3c,0x0b,0xb0,0x03,
-0xad,0x6a,0x00,0x20,0x3c,0x08,0x80,0x01,0x25,0x08,0x00,0x00,0x3c,0x09,0x80,0x01,
-0x25,0x29,0x03,0x50,0x11,0x09,0x00,0x10,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,
-0x25,0x4a,0x4b,0xbc,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0x3c,0x08,0xb0,0x06,
-0x35,0x08,0x80,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8d,0x09,0x00,0x00,
-0x00,0x00,0x00,0x00,0x31,0x29,0x00,0x01,0x00,0x00,0x00,0x00,0x24,0x01,0x00,0x01,
-0x15,0x21,0xff,0xf2,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4b,0xf8,
-0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0x3c,0x02,0xb0,0x03,0x8c,0x43,0x00,0x00,
-0x00,0x00,0x00,0x00,0x34,0x63,0x00,0x40,0x00,0x00,0x00,0x00,0xac,0x43,0x00,0x00,
-0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4c,0x24,0x3c,0x0b,0xb0,0x03,
-0xad,0x6a,0x00,0x20,0x3c,0x02,0x80,0x01,0x24,0x42,0x00,0x00,0x3c,0x03,0x80,0x01,
-0x24,0x63,0x03,0x50,0x3c,0x04,0xb0,0x00,0x8c,0x85,0x00,0x00,0x00,0x00,0x00,0x00,
-0xac,0x45,0x00,0x00,0x24,0x42,0x00,0x04,0x24,0x84,0x00,0x04,0x00,0x43,0x08,0x2a,
-0x14,0x20,0xff,0xf9,0x00,0x00,0x00,0x00,0x0c,0x00,0x13,0x1c,0x00,0x00,0x00,0x00,
-0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4c,0x70,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,
-0x3c,0x02,0x80,0x01,0x24,0x42,0x03,0x50,0x3c,0x03,0x80,0x01,0x24,0x63,0x3f,0x24,
-0xac,0x40,0x00,0x00,0xac,0x40,0x00,0x04,0xac,0x40,0x00,0x08,0xac,0x40,0x00,0x0c,
-0x24,0x42,0x00,0x10,0x00,0x43,0x08,0x2a,0x14,0x20,0xff,0xf9,0x00,0x00,0x00,0x00,
-0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4c,0xb0,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,
-0x3c,0x1c,0x80,0x01,0x27,0x9c,0x7f,0xf0,0x27,0x9d,0x8b,0xe0,0x00,0x00,0x00,0x00,
-0x27,0x9d,0x8f,0xc8,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4c,0xd4,0x3c,0x0b,0xb0,0x03,
-0xad,0x6a,0x00,0x20,0x40,0x80,0x68,0x00,0x40,0x08,0x60,0x00,0x00,0x00,0x00,0x00,
-0x35,0x08,0xff,0x01,0x40,0x88,0x60,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x15,0x62,
-0x00,0x00,0x00,0x00,0x24,0x84,0xf8,0x00,0x30,0x87,0x00,0x03,0x00,0x04,0x30,0x40,
-0x00,0xc7,0x20,0x23,0x3c,0x02,0xb0,0x0a,0x27,0xbd,0xff,0xe0,0x24,0x03,0xff,0xff,
-0x00,0x82,0x20,0x21,0xaf,0xb1,0x00,0x14,0xac,0x83,0x10,0x00,0xaf,0xbf,0x00,0x18,
-0xaf,0xb0,0x00,0x10,0x00,0xa0,0x88,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x10,0x00,
-0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0xc7,0x10,0x23,0x3c,0x03,0xb0,0x0a,
-0x00,0x43,0x10,0x21,0x8c,0x50,0x00,0x00,0x0c,0x00,0x13,0x99,0x02,0x20,0x20,0x21,
-0x02,0x11,0x80,0x24,0x00,0x50,0x80,0x06,0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x18,
-0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x27,0xbd,0xff,0xd8,
-0xaf,0xb2,0x00,0x18,0x00,0xa0,0x90,0x21,0x24,0x05,0xff,0xff,0xaf,0xb3,0x00,0x1c,
-0xaf,0xbf,0x00,0x20,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x00,0xc0,0x98,0x21,
-0x12,0x45,0x00,0x23,0x24,0x84,0xf8,0x00,0x30,0x83,0x00,0x03,0x00,0x04,0x10,0x40,
-0x00,0x40,0x88,0x21,0x00,0x60,0x20,0x21,0x00,0x43,0x10,0x23,0x3c,0x03,0xb0,0x0a,
-0x00,0x43,0x10,0x21,0xac,0x45,0x10,0x00,0x00,0x40,0x18,0x21,0x24,0x05,0x00,0x01,
-0x8c,0x62,0x10,0x00,0x00,0x00,0x00,0x00,0x14,0x45,0xff,0xfd,0x3c,0x02,0xb0,0x0a,
-0x02,0x24,0x88,0x23,0x02,0x22,0x88,0x21,0x8e,0x30,0x00,0x00,0x0c,0x00,0x13,0x99,
-0x02,0x40,0x20,0x21,0x00,0x12,0x18,0x27,0x02,0x03,0x80,0x24,0x00,0x53,0x10,0x04,
-0x02,0x02,0x80,0x25,0xae,0x30,0x00,0x00,0x24,0x03,0x00,0x01,0x8e,0x22,0x10,0x00,
-0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x20,
-0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,
-0x30,0x82,0x00,0x03,0x00,0x04,0x18,0x40,0x00,0x62,0x18,0x23,0x3c,0x04,0xb0,0x0a,
-0x00,0x64,0x18,0x21,0xac,0x66,0x00,0x00,0x24,0x04,0x00,0x01,0x8c,0x62,0x10,0x00,
-0x00,0x00,0x00,0x00,0x14,0x44,0xff,0xfd,0x00,0x00,0x00,0x00,0x08,0x00,0x13,0x87,
-0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x21,0x00,0x64,0x10,0x06,0x30,0x42,0x00,0x01,
-0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01,0x2c,0x62,0x00,0x20,
-0x14,0x40,0xff,0xf9,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,
-0x27,0xbd,0xff,0xe0,0x3c,0x03,0xb0,0x05,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,
-0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x1c,0x00,0x80,0x90,0x21,0x00,0xa0,0x80,0x21,
-0x00,0xc0,0x88,0x21,0x34,0x63,0x02,0x2e,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
-0x30,0x42,0x00,0x01,0x14,0x40,0xff,0xfc,0x24,0x04,0x08,0x24,0x3c,0x05,0x00,0xc0,
-0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0xc0,
-0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x03,0x3c,0x02,0xc0,0x00,0x00,0x10,0x1c,0x00,
-0x34,0x42,0x04,0x00,0x3c,0x04,0xb0,0x05,0x3c,0x05,0xb0,0x05,0x24,0x63,0x16,0x09,
-0x02,0x22,0x10,0x21,0x34,0x84,0x04,0x20,0x34,0xa5,0x04,0x24,0x3c,0x06,0xb0,0x05,
-0xac,0x83,0x00,0x00,0x24,0x07,0x00,0x01,0xac,0xa2,0x00,0x00,0x34,0xc6,0x02,0x28,
-0x24,0x02,0x00,0x20,0xae,0x47,0x00,0x3c,0x24,0x04,0x08,0x24,0xa0,0xc2,0x00,0x00,
-0x3c,0x05,0x00,0xc0,0xa2,0x47,0x00,0x11,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x01,
-0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0xc0,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x01,
-0x8f,0xbf,0x00,0x1c,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,
-0x27,0xbd,0x00,0x20,0x24,0x02,0x00,0x06,0xac,0x82,0x00,0x0c,0xa0,0x80,0x00,0x50,
-0xac,0x80,0x00,0x00,0xac,0x80,0x00,0x04,0xac,0x80,0x00,0x08,0xac,0x80,0x00,0x14,
-0xac,0x80,0x00,0x18,0xac,0x80,0x00,0x1c,0xa4,0x80,0x00,0x20,0xac,0x80,0x00,0x24,
-0xac,0x80,0x00,0x28,0xac,0x80,0x00,0x2c,0xa0,0x80,0x00,0x30,0xa0,0x80,0x00,0x31,
-0xac,0x80,0x00,0x34,0xac,0x80,0x00,0x38,0xa0,0x80,0x00,0x3c,0xac,0x82,0x00,0x10,
-0xa0,0x80,0x00,0x44,0xac,0x80,0x00,0x48,0x03,0xe0,0x00,0x08,0xac,0x80,0x00,0x4c,
-0x3c,0x04,0xb0,0x06,0x34,0x84,0x80,0x00,0x8c,0x83,0x00,0x00,0x3c,0x02,0x12,0x00,
-0x3c,0x05,0xb0,0x03,0x00,0x62,0x18,0x25,0x34,0xa5,0x00,0x8b,0x24,0x02,0xff,0x80,
-0xac,0x83,0x00,0x00,0x03,0xe0,0x00,0x08,0xa0,0xa2,0x00,0x00,0x3c,0x04,0xb0,0x03,
-0x34,0x84,0x00,0x0b,0x24,0x02,0x00,0x22,0x3c,0x05,0xb0,0x01,0x3c,0x06,0x45,0x67,
-0x3c,0x0a,0xb0,0x09,0xa0,0x82,0x00,0x00,0x34,0xa5,0x00,0x04,0x34,0xc6,0x89,0xaa,
-0x35,0x4a,0x00,0x04,0x24,0x02,0x01,0x23,0x3c,0x0b,0xb0,0x09,0x3c,0x07,0x01,0x23,
-0x3c,0x0c,0xb0,0x09,0x3c,0x01,0xb0,0x01,0xac,0x20,0x00,0x00,0x27,0xbd,0xff,0xe0,
-0xac,0xa0,0x00,0x00,0x35,0x6b,0x00,0x08,0x3c,0x01,0xb0,0x09,0xac,0x26,0x00,0x00,
-0x34,0xe7,0x45,0x66,0xa5,0x42,0x00,0x00,0x35,0x8c,0x00,0x0c,0x24,0x02,0xcd,0xef,
-0x3c,0x0d,0xb0,0x09,0x3c,0x08,0xcd,0xef,0x3c,0x0e,0xb0,0x09,0xad,0x67,0x00,0x00,
-0xaf,0xb7,0x00,0x1c,0xa5,0x82,0x00,0x00,0xaf,0xb6,0x00,0x18,0xaf,0xb5,0x00,0x14,
-0xaf,0xb4,0x00,0x10,0xaf,0xb3,0x00,0x0c,0xaf,0xb2,0x00,0x08,0xaf,0xb1,0x00,0x04,
-0xaf,0xb0,0x00,0x00,0x35,0xad,0x00,0x10,0x35,0x08,0x01,0x22,0x35,0xce,0x00,0x14,
-0x24,0x02,0x89,0xab,0x3c,0x0f,0xb0,0x09,0x3c,0x09,0x89,0xab,0x3c,0x10,0xb0,0x09,
-0x3c,0x11,0xb0,0x09,0x3c,0x12,0xb0,0x09,0x3c,0x13,0xb0,0x09,0x3c,0x14,0xb0,0x09,
-0x3c,0x15,0xb0,0x09,0x3c,0x16,0xb0,0x09,0x3c,0x17,0xb0,0x09,0xad,0xa8,0x00,0x00,
-0x24,0x03,0xff,0xff,0xa5,0xc2,0x00,0x00,0x35,0xef,0x00,0x18,0x35,0x29,0xcd,0xee,
-0x36,0x10,0x00,0x1c,0x36,0x31,0x00,0x20,0x36,0x52,0x00,0x24,0x36,0x73,0x00,0x28,
-0x36,0x94,0x00,0x2c,0x36,0xb5,0x00,0x30,0x36,0xd6,0x00,0x34,0x36,0xf7,0x00,0x38,
-0x24,0x02,0x45,0x67,0xad,0xe9,0x00,0x00,0xa6,0x02,0x00,0x00,0xae,0x23,0x00,0x00,
-0x8f,0xb0,0x00,0x00,0xa6,0x43,0x00,0x00,0x8f,0xb1,0x00,0x04,0xae,0x63,0x00,0x00,
-0x8f,0xb2,0x00,0x08,0xa6,0x83,0x00,0x00,0x8f,0xb3,0x00,0x0c,0xae,0xa3,0x00,0x00,
-0x8f,0xb4,0x00,0x10,0xa6,0xc3,0x00,0x00,0x8f,0xb5,0x00,0x14,0xae,0xe3,0x00,0x00,
-0x7b,0xb6,0x00,0xfc,0x3c,0x18,0xb0,0x09,0x37,0x18,0x00,0x3c,0xa7,0x03,0x00,0x00,
-0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,
-0x34,0x63,0x00,0x20,0x24,0x42,0x51,0x48,0xac,0x62,0x00,0x00,0x8c,0x83,0x00,0x34,
-0x34,0x02,0xff,0xff,0x00,0x43,0x10,0x2a,0x14,0x40,0x01,0x04,0x00,0x80,0x28,0x21,
-0x8c,0x86,0x00,0x08,0x24,0x02,0x00,0x03,0x10,0xc2,0x00,0xf7,0x00,0x00,0x00,0x00,
-0x8c,0xa2,0x00,0x2c,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x4f,0x24,0x02,0x00,0x06,
-0x3c,0x03,0xb0,0x05,0x34,0x63,0x04,0x50,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
-0x30,0x42,0x00,0xff,0x14,0x40,0x00,0xdd,0xac,0xa2,0x00,0x2c,0x24,0x02,0x00,0x01,
-0x10,0xc2,0x00,0xdc,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xc2,0x00,0xca,
-0x00,0x00,0x00,0x00,0x8c,0xa7,0x00,0x04,0x24,0x02,0x00,0x02,0x10,0xe2,0x00,0xc0,
-0x00,0x00,0x00,0x00,0x8c,0xa2,0x00,0x14,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x09,
-0x24,0x02,0x00,0x01,0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60,0x90,0x62,0x00,0x00,
-0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x10,0x40,0x00,0x05,0xac,0xa2,0x00,0x14,
-0x24,0x02,0x00,0x01,0xac,0xa2,0x00,0x00,0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x14,
-0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,
-0x04,0x61,0x00,0x19,0x3c,0x02,0xb0,0x03,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2e,
-0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x12,
-0x3c,0x02,0xb0,0x03,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x42,0x90,0x43,0x00,0x00,
-0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x0c,0x3c,0x02,0xb0,0x03,0x80,0xa2,0x00,0x50,
-0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x08,0x3c,0x02,0xb0,0x03,0x14,0xc0,0x00,0x07,
-0x34,0x42,0x00,0x3f,0x24,0x02,0x00,0x0e,0x24,0x03,0x00,0x01,0xac,0xa2,0x00,0x00,
-0x03,0xe0,0x00,0x08,0xa0,0xa3,0x00,0x50,0x34,0x42,0x00,0x3f,0x90,0x44,0x00,0x00,
-0x24,0x03,0x00,0x01,0x10,0x64,0x00,0x7f,0x3c,0x03,0xb0,0x05,0x80,0xa2,0x00,0x31,
-0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0a,0x3c,0x02,0xb0,0x06,0x34,0x42,0x80,0x18,
-0x8c,0x43,0x00,0x00,0x3c,0x04,0xf0,0x00,0x3c,0x02,0x80,0x00,0x00,0x64,0x18,0x24,
-0x10,0x62,0x00,0x03,0x24,0x02,0x00,0x09,0x03,0xe0,0x00,0x08,0xac,0xa2,0x00,0x00,
-0x8c,0xa2,0x00,0x40,0x00,0x00,0x00,0x00,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,
-0x10,0x60,0x00,0x09,0x3c,0x03,0xb0,0x03,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c,
-0x8c,0x43,0x00,0x00,0x3c,0x04,0x00,0x02,0x00,0x64,0x18,0x24,0x14,0x60,0xff,0xf2,
-0x24,0x02,0x00,0x10,0x3c,0x03,0xb0,0x03,0x34,0x63,0x02,0x01,0x90,0x62,0x00,0x00,
-0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x80,0x10,0x40,0x00,0x0e,0x00,0x00,0x00,0x00,
-0x8c,0xa3,0x00,0x0c,0x00,0x00,0x00,0x00,0xac,0xa3,0x00,0x10,0x3c,0x02,0xb0,0x03,
-0x90,0x42,0x02,0x01,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x0f,0xac,0xa2,0x00,0x0c,
-0x90,0xa3,0x00,0x0f,0x24,0x02,0x00,0x0d,0x3c,0x01,0xb0,0x03,0x08,0x00,0x14,0xb2,
-0xa0,0x23,0x02,0x01,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x80,0x90,0x44,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x04,0x1e,0x00,0x00,0x03,0x1e,0x03,0x10,0x60,0x00,0x15,
-0xa0,0xa4,0x00,0x44,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x0b,0x24,0x02,0x00,0x02,
-0x10,0x62,0x00,0x03,0x24,0x03,0x00,0x0d,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
-0x8c,0xa2,0x00,0x0c,0xac,0xa3,0x00,0x00,0x24,0x03,0x00,0x04,0xac,0xa2,0x00,0x10,
-0x03,0xe0,0x00,0x08,0xac,0xa3,0x00,0x0c,0x24,0x02,0x00,0x0d,0xac,0xa2,0x00,0x00,
-0x24,0x03,0x00,0x04,0x24,0x02,0x00,0x06,0xac,0xa3,0x00,0x10,0x03,0xe0,0x00,0x08,
-0xac,0xa2,0x00,0x0c,0x8c,0xa3,0x00,0x38,0x24,0x04,0x00,0x01,0x10,0x64,0x00,0x2d,
-0x24,0x02,0x00,0x02,0x10,0x60,0x00,0x19,0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x10,
-0x24,0x02,0x00,0x04,0x10,0x62,0x00,0x04,0x00,0x00,0x00,0x00,0xac,0xa0,0x00,0x38,
-0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x00,0x10,0xe4,0x00,0x07,0x24,0x02,0x00,0x03,
-0x80,0xa2,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x0b,0xac,0xa3,0x00,0x00,
-0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x38,0x08,0x00,0x15,0x04,0xac,0xa2,0x00,0x00,
-0x10,0xe4,0x00,0x02,0x24,0x02,0x00,0x03,0x24,0x02,0x00,0x0c,0xac,0xa2,0x00,0x00,
-0x24,0x02,0x00,0x04,0x03,0xe0,0x00,0x08,0xac,0xa2,0x00,0x38,0x10,0xe4,0x00,0x0e,
-0x3c,0x03,0xb0,0x06,0x34,0x63,0x80,0x24,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
-0x30,0x42,0x00,0xff,0x10,0x40,0x00,0x06,0xac,0xa2,0x00,0x18,0x24,0x02,0x00,0x02,
-0xac,0xa2,0x00,0x00,0xac,0xa0,0x00,0x18,0x08,0x00,0x15,0x0d,0x24,0x02,0x00,0x01,
-0x08,0x00,0x15,0x1a,0xac,0xa0,0x00,0x00,0x24,0x02,0x00,0x03,0x08,0x00,0x15,0x1a,
-0xac,0xa2,0x00,0x00,0x24,0x03,0x00,0x0b,0xac,0xa2,0x00,0x38,0x03,0xe0,0x00,0x08,
-0xac,0xa3,0x00,0x00,0x34,0x63,0x02,0x2e,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
-0x30,0x42,0x00,0x01,0x14,0x40,0xff,0x7d,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x42,
-0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x60,0xff,0x78,0x00,0x00,0x00,0x00,
-0x10,0xc0,0xff,0x81,0x24,0x02,0x00,0x0e,0x08,0x00,0x14,0xa7,0x00,0x00,0x00,0x00,
-0x80,0xa2,0x00,0x30,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x3e,0x24,0x02,0x00,0x04,
-0x08,0x00,0x14,0xb2,0x00,0x00,0x00,0x00,0x84,0xa2,0x00,0x20,0x00,0x00,0x00,0x00,
-0x10,0x40,0xff,0x75,0x24,0x02,0x00,0x06,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2e,
-0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff,
-0x00,0x60,0x10,0x21,0x14,0x40,0xff,0x2b,0xa4,0xa3,0x00,0x20,0x08,0x00,0x14,0xb2,
-0x24,0x02,0x00,0x06,0x8c,0xa2,0x00,0x1c,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x66,
-0x24,0x02,0x00,0x05,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2c,0x8c,0x62,0x00,0x00,
-0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x10,0x40,0xff,0x1b,0xac,0xa2,0x00,0x1c,
-0x08,0x00,0x14,0xb2,0x24,0x02,0x00,0x05,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x42,0x30,0x42,0x00,0x01,0x14,0x40,0xff,0x56,
-0x24,0x02,0x00,0x06,0x08,0x00,0x14,0x60,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x0a,
-0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x00,0x27,0xbd,0xff,0xd8,0xaf,0xb0,0x00,0x10,
-0x27,0x90,0x86,0x58,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,
-0x0c,0x00,0x29,0xd5,0xaf,0xb1,0x00,0x14,0xaf,0x90,0x8f,0xe0,0x48,0x02,0x00,0x00,
-0x0c,0x00,0x13,0xf0,0x00,0x00,0x00,0x00,0x0c,0x00,0x18,0x1f,0x02,0x00,0x20,0x21,
-0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x3a,0x94,0x43,0x00,0x00,0x00,0x00,0x00,0x00,
-0xa3,0x83,0x8f,0xe4,0x0c,0x00,0x00,0x34,0x00,0x00,0x00,0x00,0x0c,0x00,0x13,0xfb,
-0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x98,0x0c,0x00,0x27,0x59,0x00,0x00,0x00,0x00,
-0x93,0x84,0x80,0x10,0x0c,0x00,0x21,0x3f,0x00,0x00,0x00,0x00,0x27,0x84,0x89,0x18,
-0x0c,0x00,0x06,0xe5,0x00,0x00,0x00,0x00,0x0c,0x00,0x01,0x39,0x00,0x00,0x00,0x00,
-0x27,0x84,0x84,0x40,0x0c,0x00,0x13,0xd9,0x00,0x00,0x00,0x00,0x27,0x82,0x89,0x4c,
-0xaf,0x82,0x84,0x80,0x0c,0x00,0x00,0x5f,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,
-0x34,0x63,0x01,0x08,0x3c,0x04,0xb0,0x09,0x3c,0x05,0xb0,0x09,0x8c,0x66,0x00,0x00,
-0x34,0x84,0x01,0x68,0x34,0xa5,0x01,0x40,0x24,0x02,0xc8,0x80,0x24,0x03,0x00,0x0a,
-0xa4,0x82,0x00,0x00,0xa4,0xa3,0x00,0x00,0x3c,0x04,0xb0,0x03,0x8c,0x82,0x00,0x00,
-0x8f,0x85,0x84,0x40,0xaf,0x86,0x84,0x38,0x34,0x42,0x00,0x20,0xac,0x82,0x00,0x00,
-0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x58,0x8c,0x43,0x00,0x00,0x2c,0xa4,0x00,0x11,
-0x34,0x63,0x01,0x00,0xac,0x43,0x00,0x00,0x10,0x80,0xff,0xfa,0x3c,0x02,0xb0,0x03,
-0x3c,0x03,0x80,0x01,0x00,0x05,0x10,0x80,0x24,0x63,0x02,0x00,0x00,0x43,0x10,0x21,
-0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,
-0x27,0x84,0x84,0x98,0x0c,0x00,0x26,0x8e,0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x40,
-0x0c,0x00,0x14,0x52,0x00,0x00,0x00,0x00,0x93,0x83,0x81,0xf1,0x24,0x02,0x00,0x01,
-0x10,0x62,0x00,0x08,0x00,0x00,0x00,0x00,0x8f,0x85,0x84,0x40,0x8f,0x82,0x84,0x74,
-0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xaf,0x82,0x84,0x74,0x08,0x00,0x15,0x9d,
-0x3c,0x02,0xb0,0x03,0x27,0x84,0x84,0x98,0x0c,0x00,0x27,0x0d,0x00,0x00,0x00,0x00,
-0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x98,0x0c,0x00,0x28,0xdd,
-0x00,0x00,0x00,0x00,0xa3,0x82,0x84,0x71,0x8f,0x82,0x84,0x74,0xaf,0x80,0x84,0x40,
-0x24,0x42,0x00,0x01,0xaf,0x82,0x84,0x74,0x08,0x00,0x15,0x9c,0x00,0x00,0x28,0x21,
-0x27,0x84,0x86,0x58,0x0c,0x00,0x19,0x5b,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,
-0x14,0x40,0x00,0x05,0x3c,0x03,0xb0,0x05,0xaf,0x80,0x84,0x40,0xaf,0x80,0x84,0x44,
-0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00,0x34,0x63,0x04,0x50,0x90,0x62,0x00,0x00,
-0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x6c,0x14,0x40,0x00,0x20,
-0x24,0x02,0x00,0x01,0x8f,0x84,0x84,0x48,0x00,0x00,0x00,0x00,0x10,0x82,0x00,0x20,
-0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
-0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x54,0x14,0x40,0x00,0x15,0x24,0x02,0x00,0x01,
-0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x07,0x00,0x00,0x00,0x00,0x24,0x05,0x00,0x03,
-0x24,0x02,0x00,0x01,0xaf,0x82,0x84,0x44,0xaf,0x85,0x84,0x40,0x08,0x00,0x15,0xb6,
-0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00,
-0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21,
-0xa7,0x83,0x84,0x60,0x14,0x40,0xff,0xf1,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,
-0xaf,0x82,0x84,0x44,0xaf,0x80,0x84,0x40,0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00,
-0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2c,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
-0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x5c,0x14,0x40,0xff,0xf5,0x24,0x02,0x00,0x01,
-0x08,0x00,0x15,0xe1,0x3c,0x03,0xb0,0x09,0x27,0x84,0x86,0x58,0x0c,0x00,0x1a,0xd1,
-0x00,0x00,0x00,0x00,0x83,0x82,0x84,0x70,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xec,
-0x24,0x02,0x00,0x02,0x3c,0x03,0xb0,0x05,0x34,0x63,0x04,0x50,0x90,0x62,0x00,0x00,
-0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x6c,0x14,0x40,0xff,0xe4,
-0x24,0x02,0x00,0x02,0x8f,0x84,0x84,0x48,0x24,0x02,0x00,0x01,0x10,0x82,0x00,0x12,
-0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x04,0x00,0x00,0x00,0x00,0x24,0x05,0x00,0x04,
-0x08,0x00,0x15,0xed,0x24,0x02,0x00,0x02,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2e,
-0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff,
-0x00,0x60,0x10,0x21,0xa7,0x83,0x84,0x60,0x14,0x40,0xff,0xf4,0x00,0x00,0x00,0x00,
-0x08,0x00,0x15,0xfc,0x24,0x02,0x00,0x02,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2c,
-0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x5c,
-0x14,0x40,0xff,0xf7,0x00,0x00,0x00,0x00,0x08,0x00,0x16,0x1d,0x24,0x02,0x00,0x02,
-0x27,0x84,0x89,0x18,0x0c,0x00,0x0b,0x55,0x00,0x00,0x00,0x00,0x8f,0x83,0x84,0x44,
-0xaf,0x82,0x84,0x5c,0x38,0x64,0x00,0x02,0x00,0x04,0x18,0x0a,0xaf,0x83,0x84,0x44,
-0x14,0x40,0xff,0xad,0x24,0x05,0x00,0x05,0x8f,0x82,0x89,0x58,0xaf,0x80,0x84,0x40,
-0x10,0x40,0x00,0x02,0x24,0x04,0x00,0x01,0xaf,0x84,0x84,0x48,0x93,0x82,0x89,0x66,
-0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x6c,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,
-0x34,0x42,0x00,0x08,0x8c,0x43,0x00,0x00,0x3c,0x04,0x20,0x00,0x00,0x64,0x18,0x24,
-0x10,0x60,0xff,0x65,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xa0,
-0x8c,0x43,0x00,0x00,0x3c,0x04,0x80,0x00,0xaf,0x80,0x89,0x40,0x24,0x63,0x00,0x01,
-0xac,0x43,0x00,0x00,0x3c,0x01,0xb0,0x05,0xac,0x24,0x00,0x08,0xaf,0x80,0x89,0x3c,
-0xaf,0x80,0x89,0x44,0xaf,0x80,0x89,0x48,0xaf,0x80,0x89,0x54,0xaf,0x80,0x89,0x4c,
-0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00,0x83,0x82,0x84,0x90,0x00,0x00,0x00,0x00,
-0x10,0x40,0x00,0x02,0x24,0x02,0x00,0x20,0xaf,0x82,0x84,0x5c,0x8f,0x85,0x84,0x5c,
-0x27,0x84,0x89,0x18,0x0c,0x00,0x0d,0x30,0x00,0x00,0x00,0x00,0x00,0x02,0x1e,0x00,
-0xa3,0x82,0x84,0x70,0xaf,0x80,0x84,0x5c,0x10,0x60,0xff,0x8e,0x00,0x00,0x00,0x00,
-0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,
-0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21,0xa7,0x83,0x84,0x60,
-0x10,0x40,0x00,0x04,0x24,0x04,0x00,0x02,0xaf,0x84,0x84,0x48,0x08,0x00,0x15,0xfd,
-0x00,0x00,0x00,0x00,0x08,0x00,0x15,0xee,0x24,0x05,0x00,0x06,0x27,0x84,0x84,0x40,
-0x27,0x85,0x89,0x18,0x0c,0x00,0x0d,0xfd,0x00,0x00,0x00,0x00,0x8f,0x82,0x84,0x64,
-0xaf,0x80,0x84,0x6c,0x14,0x40,0x00,0x19,0x00,0x40,0x18,0x21,0x8f,0x82,0x84,0x68,
-0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x15,0x24,0x02,0x00,0x02,0x8f,0x83,0x84,0x48,
-0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x0b,0x3c,0x02,0x40,0x00,0x8f,0x83,0x84,0x44,
-0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x02,0x24,0x05,0x00,0x03,0x24,0x05,0x00,0x06,
-0xaf,0x85,0x84,0x40,0x24,0x04,0x00,0x03,0xaf,0x84,0x84,0x48,0x08,0x00,0x15,0xb6,
-0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x14,0x3c,0x01,0xb0,0x05,0xac,0x22,0x00,0x00,
-0xaf,0x80,0x84,0x40,0x08,0x00,0x16,0x96,0x24,0x04,0x00,0x03,0x10,0x60,0x00,0x10,
-0x00,0x00,0x00,0x00,0x27,0x85,0x89,0x18,0x27,0x84,0x84,0x40,0x0c,0x00,0x0e,0x21,
-0x00,0x00,0x00,0x00,0x8f,0x83,0x84,0x44,0x24,0x02,0x00,0x01,0xa3,0x80,0x84,0x70,
-0xaf,0x80,0x84,0x48,0x10,0x62,0x00,0x02,0x24,0x05,0x00,0x03,0x24,0x05,0x00,0x04,
-0xaf,0x85,0x84,0x40,0xaf,0x80,0x84,0x64,0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00,
-0x83,0x82,0x84,0x90,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00,
-0x27,0x84,0x89,0x18,0x0c,0x00,0x10,0x69,0x00,0x00,0x00,0x00,0x8f,0x82,0x84,0x44,
-0xa3,0x80,0x84,0x70,0xaf,0x80,0x84,0x40,0xaf,0x80,0x84,0x48,0x14,0x40,0x00,0x03,
-0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0xaf,0x82,0x84,0x44,0xaf,0x80,0x84,0x68,
-0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x40,0x27,0x85,0x89,0x18,
-0x0c,0x00,0x0e,0x21,0x00,0x00,0x00,0x00,0x8f,0x82,0x84,0x44,0xa3,0x80,0x84,0x70,
-0xaf,0x80,0x84,0x40,0xaf,0x80,0x84,0x48,0x14,0x40,0xfe,0xeb,0x00,0x00,0x00,0x00,
-0x24,0x02,0x00,0x02,0xaf,0x82,0x84,0x44,0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00,
-0x27,0x84,0x89,0x18,0x0c,0x00,0x10,0x69,0x00,0x00,0x00,0x00,0x08,0x00,0x16,0xc6,
-0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x98,0x0c,0x00,0x29,0x73,0x00,0x00,0x00,0x00,
-0x08,0x00,0x15,0xc5,0x00,0x00,0x00,0x00,0x0c,0x00,0x24,0x05,0x00,0x00,0x00,0x00,
-0x0c,0x00,0x26,0xff,0x00,0x00,0x00,0x00,0x0c,0x00,0x18,0x11,0x00,0x00,0x00,0x00,
-0x93,0x83,0xbc,0x18,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x2b,0x3c,0x02,0xb0,0x03,
-0x34,0x42,0x01,0x08,0x8c,0x44,0x00,0x00,0x8f,0x83,0xbc,0x10,0x8f,0x82,0xbc,0x14,
-0x00,0x83,0x18,0x23,0x00,0x43,0x10,0x2b,0x10,0x40,0x00,0x23,0x3c,0x02,0xb0,0x03,
-0x24,0x04,0x05,0xa0,0x34,0x42,0x01,0x18,0x8c,0x42,0x00,0x00,0x0c,0x00,0x06,0xd1,
-0x00,0x00,0x00,0x00,0x24,0x04,0x05,0xa4,0x0c,0x00,0x06,0xd1,0x00,0x02,0x84,0x02,
-0x30,0x51,0xff,0xff,0x24,0x04,0x05,0xa8,0x00,0x02,0x94,0x02,0x0c,0x00,0x06,0xd1,
-0x3a,0x10,0xff,0xff,0x3a,0x31,0xff,0xff,0x30,0x42,0xff,0xff,0x2e,0x10,0x00,0x01,
-0x2e,0x31,0x00,0x01,0x3a,0x52,0xff,0xff,0x02,0x11,0x80,0x25,0x2e,0x52,0x00,0x01,
-0x38,0x42,0xff,0xff,0x02,0x12,0x80,0x25,0x2c,0x42,0x00,0x01,0x02,0x02,0x80,0x25,
-0x16,0x00,0x00,0x02,0x24,0x04,0x00,0x02,0x00,0x00,0x20,0x21,0x0c,0x00,0x05,0x6e,
-0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,0x8c,0x43,0x00,0x00,
-0x00,0x00,0x00,0x00,0xaf,0x83,0xbc,0x10,0x0c,0x00,0x01,0xe9,0x00,0x00,0x00,0x00,
-0xaf,0x80,0x84,0x40,0xaf,0x80,0x84,0x74,0x08,0x00,0x15,0x9c,0x00,0x00,0x28,0x21,
-0x27,0x90,0xb4,0x00,0x24,0x11,0x00,0x12,0x8e,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
-0x90,0x82,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x03,0x00,0x00,0x00,0x00,
-0x0c,0x00,0x18,0xd0,0x00,0x00,0x00,0x00,0x26,0x31,0xff,0xff,0x06,0x21,0xff,0xf6,
-0x26,0x10,0x00,0x04,0xaf,0x80,0x84,0x40,0x08,0x00,0x15,0xb7,0x00,0x00,0x28,0x21,
-0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,0x8c,0x44,0x00,0x00,0x8f,0x82,0x84,0x38,
-0x00,0x04,0x19,0xc2,0x00,0x02,0x11,0xc2,0x10,0x62,0xff,0xf6,0x00,0x00,0x00,0x00,
-0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x02,0x90,0x43,0x00,0x00,0x3c,0x12,0xb0,0x05,
-0xaf,0x84,0x84,0x38,0x30,0x63,0x00,0xff,0x00,0x03,0x11,0x40,0x00,0x43,0x10,0x23,
-0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0x02,0x99,0x00,0x00,0x00,0x88,0x21,
-0x36,0x52,0x02,0x2c,0x27,0x90,0xb4,0x00,0x8e,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
-0x90,0x83,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x62,0x00,0x03,0x10,0x40,0x00,0x06,
-0x30,0x62,0x00,0x1c,0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0x8f,0x85,0x84,0x38,
-0x0c,0x00,0x1e,0x94,0x02,0x60,0x30,0x21,0x8e,0x42,0x00,0x00,0x00,0x00,0x00,0x00,
-0x30,0x42,0x00,0xff,0x14,0x40,0xff,0xd7,0x00,0x00,0x00,0x00,0x26,0x31,0x00,0x01,
-0x2a,0x22,0x00,0x13,0x14,0x40,0xff,0xec,0x26,0x10,0x00,0x04,0x08,0x00,0x17,0x21,
-0x00,0x00,0x00,0x00,0x8f,0x84,0x84,0x4c,0x27,0x85,0x89,0x18,0x0c,0x00,0x17,0xa4,
-0x00,0x00,0x00,0x00,0x8f,0x83,0x84,0x4c,0x24,0x02,0x00,0x04,0x14,0x62,0xfe,0xa5,
-0x00,0x00,0x00,0x00,0x08,0x00,0x15,0xee,0x24,0x05,0x00,0x05,0x3c,0x02,0xb0,0x03,
-0x34,0x42,0x00,0x3f,0x90,0x44,0x00,0x00,0x24,0x03,0x00,0x01,0x10,0x64,0x00,0x08,
-0x00,0x00,0x00,0x00,0x27,0x84,0x89,0x18,0x0c,0x00,0x24,0x2c,0x00,0x00,0x00,0x00,
-0x24,0x05,0x00,0x05,0xaf,0x85,0x84,0x40,0x08,0x00,0x15,0xb7,0x00,0x00,0x00,0x00,
-0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x14,0x8c,0x44,0x00,0x00,0x0c,0x00,0x24,0x49,
-0x00,0x00,0x00,0x00,0x08,0x00,0x17,0x65,0x24,0x05,0x00,0x05,0x8f,0x82,0x89,0x4c,
-0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0d,0x00,0x00,0x00,0x00,0x8f,0x84,0xb4,0x40,
-0xaf,0x80,0x89,0x4c,0x94,0x85,0x00,0x14,0x0c,0x00,0x1b,0x66,0x00,0x00,0x00,0x00,
-0x93,0x82,0x8b,0x71,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x02,0x10,0x40,0x00,0x03,
-0x00,0x00,0x00,0x00,0x0c,0x00,0x01,0x57,0x00,0x00,0x20,0x21,0x8f,0x84,0xb4,0x40,
-0x0c,0x00,0x18,0xd0,0x00,0x00,0x00,0x00,0x08,0x00,0x17,0x21,0x00,0x00,0x00,0x00,
-0x3c,0x02,0xff,0x90,0x27,0xbd,0xff,0xe8,0x00,0x80,0x18,0x21,0x34,0x42,0x00,0x01,
-0x27,0x84,0x89,0x18,0x10,0x62,0x00,0x05,0xaf,0xbf,0x00,0x10,0x8f,0xbf,0x00,0x10,
-0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x06,0xe5,
-0x00,0x00,0x00,0x00,0x27,0x84,0x86,0x58,0x0c,0x00,0x18,0x1f,0x00,0x00,0x00,0x00,
-0x27,0x84,0x84,0x40,0x0c,0x00,0x13,0xd9,0x00,0x00,0x00,0x00,0x08,0x00,0x17,0x8b,
-0x00,0x00,0x00,0x00,0x8f,0x82,0x89,0x58,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x05,
-0x00,0x00,0x18,0x21,0x8f,0x82,0x84,0x48,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x02,
-0x00,0x00,0x00,0x00,0x24,0x03,0x00,0x01,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,
-0x27,0xbd,0xff,0xe0,0x3c,0x06,0xb0,0x03,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,
-0x34,0xc6,0x00,0x5f,0xaf,0xbf,0x00,0x18,0x90,0xc3,0x00,0x00,0x3c,0x07,0xb0,0x03,
-0x34,0xe7,0x00,0x5d,0x34,0x63,0x00,0x01,0x3c,0x09,0xb0,0x03,0x24,0x02,0x00,0x01,
-0xa0,0xc3,0x00,0x00,0x00,0x80,0x80,0x21,0xa0,0xe2,0x00,0x00,0x00,0xa0,0x88,0x21,
-0x35,0x29,0x00,0x5e,0x00,0xe0,0x40,0x21,0x24,0x04,0x00,0x01,0x91,0x22,0x00,0x00,
-0x91,0x03,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x83,0x00,0x03,0x30,0x42,0x00,0x01,
-0x14,0x40,0xff,0xfa,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x04,0x12,0x02,0x00,0x2c,
-0x24,0x05,0x0f,0x00,0x24,0x02,0x00,0x06,0x12,0x02,0x00,0x08,0x24,0x05,0x00,0x0f,
-0x3c,0x02,0xb0,0x03,0x34,0x42,0x02,0x00,0xa0,0x50,0x00,0x00,0x8f,0xbf,0x00,0x18,
-0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x24,0x04,0x0c,0x04,
-0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x0f,0x24,0x04,0x0d,0x04,0x24,0x05,0x00,0x0f,
-0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x0f,0x24,0x04,0x08,0x80,0x24,0x05,0x1e,0x00,
-0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x0f,0x24,0x04,0x08,0x8c,0x24,0x05,0x0f,0x00,
-0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x0f,0x24,0x04,0x08,0x24,0x3c,0x05,0x00,0x30,
-0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x02,0x24,0x04,0x08,0x2c,0x3c,0x05,0x00,0x30,
-0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x02,0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0x30,
-0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x02,0x24,0x04,0x08,0x3c,0x3c,0x05,0x00,0x30,
-0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x02,0x08,0x00,0x17,0xc5,0x3c,0x02,0xb0,0x03,
-0x24,0x04,0x08,0x8c,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x04,0x24,0x04,0x08,0x80,
-0x24,0x05,0x1e,0x00,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x04,0x24,0x04,0x0c,0x04,
-0x24,0x05,0x00,0x0f,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x04,0x24,0x04,0x0d,0x04,
-0x24,0x05,0x00,0x0f,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x04,0x24,0x04,0x08,0x24,
-0x3c,0x05,0x00,0x30,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x2c,
-0x3c,0x05,0x00,0x30,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x34,
-0x3c,0x05,0x00,0x30,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x02,0x3c,0x05,0x00,0x30,
-0x24,0x06,0x00,0x03,0x0c,0x00,0x13,0x5f,0x24,0x04,0x08,0x3c,0x02,0x20,0x20,0x21,
-0x24,0x05,0x00,0x14,0x0c,0x00,0x13,0xa4,0x24,0x06,0x01,0x07,0x08,0x00,0x17,0xc5,
-0x3c,0x02,0xb0,0x03,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x73,0x90,0x62,0x00,0x00,
-0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x02,0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00,
-0xa3,0x80,0x81,0x58,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,
-0xa3,0x82,0x81,0x58,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,
-0x3c,0x02,0x80,0x00,0x00,0x80,0x70,0x21,0x34,0x63,0x00,0x20,0x24,0x42,0x60,0x7c,
-0x3c,0x04,0xb0,0x03,0xac,0x62,0x00,0x00,0x34,0x84,0x00,0x30,0xad,0xc0,0x02,0xb8,
-0x8c,0x83,0x00,0x00,0x24,0x02,0x00,0xff,0xa5,0xc0,0x00,0x0a,0x00,0x00,0x30,0x21,
-0xa7,0x82,0x8f,0xf0,0x27,0x88,0x90,0x00,0xa5,0xc3,0x00,0x08,0x3c,0x07,0xb0,0x08,
-0x30,0xc2,0xff,0xff,0x00,0x02,0x20,0xc0,0x24,0xc3,0x00,0x01,0x00,0x82,0x10,0x21,
-0x00,0x60,0x30,0x21,0x00,0x02,0x10,0x80,0x30,0x63,0xff,0xff,0x00,0x48,0x10,0x21,
-0x00,0x87,0x20,0x21,0x28,0xc5,0x00,0xff,0xac,0x83,0x00,0x00,0x14,0xa0,0xff,0xf4,
-0xa4,0x43,0x00,0x00,0x3c,0x02,0xb0,0x08,0x34,0x03,0xff,0xff,0x25,0xc4,0x00,0x0c,
-0x24,0x0a,0x00,0x02,0x34,0x42,0x07,0xf8,0x3c,0x06,0xb0,0x03,0xa7,0x83,0xb3,0xdc,
-0xac,0x43,0x00,0x00,0xaf,0x84,0xb4,0x00,0x34,0xc6,0x00,0x64,0xa0,0x8a,0x00,0x18,
-0x94,0xc5,0x00,0x00,0x8f,0x82,0xb4,0x00,0x25,0xc4,0x00,0x30,0x24,0x08,0x00,0x03,
-0x3c,0x03,0xb0,0x03,0xa0,0x45,0x00,0x21,0x34,0x63,0x00,0x66,0xaf,0x84,0xb4,0x04,
-0xa0,0x88,0x00,0x18,0x94,0x65,0x00,0x00,0x8f,0x82,0xb4,0x04,0x25,0xc4,0x00,0x54,
-0x25,0xc7,0x00,0x78,0xa0,0x45,0x00,0x21,0xaf,0x84,0xb4,0x08,0xa0,0x88,0x00,0x18,
-0x94,0x65,0x00,0x00,0x8f,0x82,0xb4,0x08,0x25,0xc8,0x00,0x9c,0x24,0x09,0x00,0x01,
-0xa0,0x45,0x00,0x21,0xaf,0x87,0xb4,0x0c,0xa0,0xea,0x00,0x18,0x94,0xc4,0x00,0x00,
-0x8f,0x82,0xb4,0x0c,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x62,0xa0,0x44,0x00,0x21,
-0xaf,0x88,0xb4,0x10,0xa1,0x09,0x00,0x18,0x94,0x65,0x00,0x00,0x8f,0x82,0xb4,0x10,
-0x25,0xc4,0x00,0xc0,0x3c,0x06,0xb0,0x03,0xa0,0x45,0x00,0x21,0xaf,0x84,0xb4,0x14,
-0xa0,0x89,0x00,0x18,0x94,0x65,0x00,0x00,0x8f,0x82,0xb4,0x14,0x25,0xc4,0x00,0xe4,
-0x34,0xc6,0x00,0x60,0xa0,0x45,0x00,0x21,0xaf,0x84,0xb4,0x18,0xa0,0x80,0x00,0x18,
-0x94,0xc5,0x00,0x00,0x8f,0x82,0xb4,0x18,0x25,0xc3,0x01,0x08,0x25,0xc7,0x01,0x2c,
-0xa0,0x45,0x00,0x21,0xaf,0x83,0xb4,0x1c,0xa0,0x60,0x00,0x18,0x94,0xc8,0x00,0x00,
-0x8f,0x82,0xb4,0x1c,0x25,0xc4,0x01,0x50,0x25,0xc5,0x01,0x74,0xa0,0x48,0x00,0x21,
-0x25,0xc6,0x01,0x98,0x25,0xc9,0x01,0xbc,0x25,0xca,0x01,0xe0,0x25,0xcb,0x02,0x04,
-0x25,0xcc,0x02,0x28,0x25,0xcd,0x02,0x4c,0x24,0x02,0x00,0x10,0x3c,0x03,0xb0,0x03,
-0xaf,0x87,0xb4,0x20,0x34,0x63,0x00,0x38,0xa0,0xe0,0x00,0x18,0xaf,0x84,0xb4,0x24,
-0xa0,0x80,0x00,0x18,0xaf,0x85,0xb4,0x28,0xa0,0xa0,0x00,0x18,0xaf,0x86,0xb4,0x2c,
-0xa0,0xc0,0x00,0x18,0xaf,0x89,0xb4,0x30,0xa1,0x20,0x00,0x18,0xaf,0x8a,0xb4,0x34,
-0xa1,0x40,0x00,0x18,0xaf,0x8b,0xb4,0x38,0xa1,0x60,0x00,0x18,0xaf,0x8c,0xb4,0x3c,
-0xa1,0x80,0x00,0x18,0xaf,0x8d,0xb4,0x40,0xa1,0xa2,0x00,0x18,0x94,0x64,0x00,0x00,
-0x8f,0x82,0xb4,0x40,0x25,0xc5,0x02,0x70,0x3c,0x03,0xb0,0x03,0xa0,0x44,0x00,0x21,
-0x24,0x02,0x00,0x11,0xaf,0x85,0xb4,0x44,0x34,0x63,0x00,0x6e,0xa0,0xa2,0x00,0x18,
-0x94,0x64,0x00,0x00,0x8f,0x82,0xb4,0x44,0x25,0xc5,0x02,0x94,0x3c,0x03,0xb0,0x03,
-0xa0,0x44,0x00,0x21,0x24,0x02,0x00,0x12,0xaf,0x85,0xb4,0x48,0x34,0x63,0x00,0x6c,
-0xa0,0xa2,0x00,0x18,0x94,0x64,0x00,0x00,0x8f,0x82,0xb4,0x48,0x24,0x05,0xff,0xff,
-0x24,0x07,0x00,0x01,0xa0,0x44,0x00,0x21,0x24,0x06,0x00,0x12,0x27,0x84,0xb4,0x00,
-0x8c,0x82,0x00,0x00,0x24,0xc6,0xff,0xff,0xa0,0x40,0x00,0x04,0x8c,0x83,0x00,0x00,
-0xa4,0x45,0x00,0x00,0xa4,0x45,0x00,0x02,0xa0,0x60,0x00,0x0a,0x8c,0x82,0x00,0x00,
-0xa4,0x65,0x00,0x06,0xa4,0x65,0x00,0x08,0xa0,0x40,0x00,0x10,0x8c,0x83,0x00,0x00,
-0xa4,0x45,0x00,0x0c,0xa4,0x45,0x00,0x0e,0xa0,0x60,0x00,0x12,0x8c,0x82,0x00,0x00,
-0x00,0x00,0x00,0x00,0xa0,0x40,0x00,0x16,0x8c,0x83,0x00,0x00,0xa4,0x45,0x00,0x14,
-0xa0,0x67,0x00,0x17,0x8c,0x82,0x00,0x00,0x24,0x84,0x00,0x04,0xa0,0x40,0x00,0x20,
-0x04,0xc1,0xff,0xe7,0xac,0x40,0x00,0x1c,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
-0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00,0x34,0x42,0x00,0x20,0x24,0x63,0x63,0x40,
-0xac,0x43,0x00,0x00,0x90,0x82,0x00,0x10,0x00,0x80,0x60,0x21,0x10,0x40,0x00,0x56,
-0x00,0x00,0x70,0x21,0x97,0x82,0x8f,0xf0,0x94,0x8a,0x00,0x0c,0x27,0x87,0x90,0x00,
-0x00,0x02,0x40,0xc0,0x01,0x02,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x47,0x10,0x21,
-0x90,0x8b,0x00,0x18,0xa4,0x4a,0x00,0x00,0x94,0x83,0x00,0x0e,0x39,0x64,0x00,0x10,
-0x2c,0x84,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x34,0x85,0x00,0x02,
-0x39,0x63,0x00,0x11,0x00,0x83,0x28,0x0b,0x34,0xa3,0x00,0x08,0x39,0x64,0x00,0x12,
-0x00,0x02,0x10,0x80,0x00,0xa4,0x18,0x0b,0x00,0x47,0x10,0x21,0x94,0x49,0x00,0x04,
-0x34,0x64,0x00,0x20,0x00,0x6b,0x20,0x0b,0x34,0x83,0x00,0x40,0x39,0x62,0x00,0x01,
-0x00,0x82,0x18,0x0b,0x00,0x09,0x30,0xc0,0x34,0x64,0x00,0x80,0x00,0xc9,0x28,0x21,
-0x39,0x62,0x00,0x02,0x00,0x60,0x68,0x21,0x00,0x82,0x68,0x0a,0x00,0x05,0x28,0x80,
-0x3c,0x02,0xb0,0x08,0x00,0xa7,0x28,0x21,0x00,0xc2,0x30,0x21,0x01,0x02,0x40,0x21,
-0x34,0x03,0xff,0xff,0x35,0xa4,0x01,0x00,0x39,0x62,0x00,0x03,0x2d,0x67,0x00,0x13,
-0xad,0x0a,0x00,0x00,0xa4,0xa3,0x00,0x00,0xac,0xc3,0x00,0x00,0xa7,0x89,0x8f,0xf0,
-0x10,0xe0,0x00,0x0f,0x00,0x82,0x68,0x0a,0x3c,0x03,0x80,0x01,0x00,0x0b,0x10,0x80,
-0x24,0x63,0x02,0x44,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x60,
-0x94,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x02,0x74,0x03,
-0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x3a,0x94,0x44,0x00,0x00,0x93,0x83,0x8f,0xe4,
-0x91,0x82,0x00,0x21,0x01,0xc4,0x20,0x21,0x91,0x85,0x00,0x10,0x00,0x04,0x24,0x00,
-0x00,0x62,0x18,0x21,0x00,0x04,0x74,0x03,0x00,0x6e,0x18,0x23,0x00,0x65,0x10,0x2a,
-0x00,0xa2,0x18,0x0a,0x00,0x0d,0x24,0x00,0x3c,0x02,0xb0,0x06,0x24,0x05,0xff,0xff,
-0x00,0x64,0x18,0x25,0x34,0x42,0x80,0x20,0xac,0x43,0x00,0x00,0xa5,0x85,0x00,0x0e,
-0xa1,0x80,0x00,0x10,0xa5,0x85,0x00,0x0c,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
-0x3c,0x03,0xb0,0x03,0x08,0x00,0x19,0x14,0x34,0x63,0x00,0x62,0x3c,0x03,0xb0,0x03,
-0x08,0x00,0x19,0x14,0x34,0x63,0x00,0x64,0x3c,0x03,0xb0,0x03,0x08,0x00,0x19,0x14,
-0x34,0x63,0x00,0x66,0x3c,0x03,0xb0,0x03,0x08,0x00,0x19,0x14,0x34,0x63,0x00,0x38,
-0x3c,0x03,0xb0,0x03,0x08,0x00,0x19,0x14,0x34,0x63,0x00,0x6e,0x3c,0x03,0xb0,0x03,
-0x08,0x00,0x19,0x14,0x34,0x63,0x00,0x6c,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,
-0x34,0x63,0x00,0x20,0x24,0x42,0x65,0x08,0x00,0x05,0x28,0x40,0xac,0x62,0x00,0x00,
-0x00,0xa6,0x28,0x21,0x2c,0xe2,0x00,0x10,0x14,0x80,0x00,0x06,0x00,0x00,0x18,0x21,
-0x10,0x40,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0xe0,0x18,0x21,0x03,0xe0,0x00,0x08,
-0x00,0x60,0x10,0x21,0x24,0x02,0x00,0x20,0x10,0xe2,0x00,0x06,0x2c,0xe4,0x00,0x10,
-0x24,0xa2,0x00,0x01,0x10,0x80,0xff,0xf9,0x00,0x02,0x11,0x00,0x08,0x00,0x19,0x4f,
-0x00,0x47,0x18,0x21,0x08,0x00,0x19,0x4f,0x24,0xa3,0x00,0x50,0x27,0xbd,0xff,0xc8,
-0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x30,
-0xaf,0xb7,0x00,0x2c,0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24,0xaf,0xb4,0x00,0x20,
-0xaf,0xb0,0x00,0x10,0x00,0x80,0x88,0x21,0x84,0x84,0x00,0x08,0x3c,0x05,0xb0,0x03,
-0x3c,0x02,0x80,0x00,0x34,0xa5,0x00,0x20,0x24,0x42,0x65,0x6c,0x3c,0x03,0xb0,0x06,
-0x00,0x04,0x20,0x80,0xac,0xa2,0x00,0x00,0x00,0x83,0x20,0x21,0x3c,0x06,0xb0,0x06,
-0x8c,0x82,0x00,0x00,0x34,0xc6,0x80,0x24,0x8c,0x88,0x00,0x00,0x8c,0xc4,0x00,0x00,
-0x96,0x25,0x00,0x08,0x30,0x52,0xff,0xff,0x00,0x08,0x44,0x02,0x34,0x84,0x01,0x00,
-0x3c,0x02,0xb0,0x00,0x00,0x08,0x18,0xc0,0x00,0x12,0x3a,0x00,0xac,0xc4,0x00,0x00,
-0x00,0xe2,0x38,0x21,0xae,0x32,0x02,0xb8,0x00,0x68,0x18,0x21,0x24,0xa5,0x00,0x02,
-0x8c,0xf6,0x00,0x00,0x30,0xa5,0x01,0xff,0x8c,0xf4,0x00,0x04,0x27,0x86,0x90,0x00,
-0x00,0x03,0x18,0x80,0x00,0x12,0x98,0xc0,0xa6,0x25,0x00,0x08,0x00,0x66,0x18,0x21,
-0x02,0x72,0x10,0x21,0x94,0x65,0x00,0x00,0x00,0x02,0x48,0x80,0x01,0x26,0x30,0x21,
-0x24,0x02,0xff,0xff,0x00,0x14,0x1a,0x02,0x27,0x84,0x90,0x10,0xa4,0xc2,0x00,0x02,
-0x30,0x63,0x00,0x1f,0x24,0x02,0x00,0x10,0x01,0x24,0x20,0x21,0xa4,0xc8,0x00,0x04,
-0x8c,0xf0,0x00,0x08,0xa6,0x23,0x00,0x06,0xa6,0x25,0x00,0x0a,0xa0,0x82,0x00,0x06,
-0x86,0x25,0x00,0x06,0x27,0x82,0x90,0x04,0x01,0x22,0x10,0x21,0x24,0x03,0x00,0x13,
-0x10,0xa3,0x00,0xee,0xac,0x47,0x00,0x18,0x3c,0x03,0xb0,0x03,0x34,0x63,0x01,0x00,
-0xa6,0x20,0x00,0x02,0x3c,0x02,0xb0,0x03,0x90,0x64,0x00,0x00,0x34,0x42,0x01,0x08,
-0x8c,0x45,0x00,0x00,0x00,0x10,0x1b,0xc2,0x00,0x04,0x20,0x82,0x30,0x63,0x00,0x01,
-0xac,0xc5,0x00,0x08,0x10,0x60,0x00,0xc7,0x30,0x97,0x00,0x01,0x00,0x10,0x16,0x82,
-0x30,0x46,0x00,0x01,0x00,0x10,0x12,0x02,0x00,0x10,0x19,0xc2,0x00,0x10,0x26,0x02,
-0x00,0x10,0x2e,0x42,0x30,0x48,0x00,0x7f,0x24,0x02,0x00,0x01,0x30,0x75,0x00,0x01,
-0x30,0x84,0x00,0x01,0x10,0xc2,0x00,0xb3,0x30,0xa3,0x00,0x01,0x00,0x60,0x28,0x21,
-0x0c,0x00,0x19,0x42,0x01,0x00,0x38,0x21,0x02,0x72,0x18,0x21,0x00,0x03,0x18,0x80,
-0x2c,0x46,0x00,0x54,0x27,0x85,0x90,0x10,0x27,0x84,0x90,0x08,0x00,0x06,0x10,0x0a,
-0x00,0x65,0x28,0x21,0x26,0xa6,0x00,0x02,0x00,0x64,0x18,0x21,0xa0,0xa2,0x00,0x02,
-0xa0,0x66,0x00,0x06,0xa0,0x62,0x00,0x07,0xa0,0xa2,0x00,0x01,0x02,0x72,0x28,0x21,
-0x00,0x05,0x28,0x80,0x27,0x82,0x90,0x04,0x00,0xa2,0x58,0x21,0x8d,0x64,0x00,0x18,
-0x00,0x10,0x15,0xc2,0x30,0x42,0x00,0x01,0x8c,0x83,0x00,0x0c,0x27,0x84,0x90,0x20,
-0x00,0xa4,0x48,0x21,0xa6,0x22,0x00,0x00,0xa6,0x36,0x00,0x04,0x8d,0x26,0x00,0x00,
-0x00,0x03,0x19,0x42,0x3c,0x02,0xff,0xef,0x34,0x42,0xff,0xff,0x30,0x63,0x00,0x01,
-0x00,0xc2,0x40,0x24,0x00,0x03,0x1d,0x00,0x01,0x03,0x40,0x25,0x00,0x08,0x15,0x02,
-0x00,0x14,0x19,0x82,0x00,0x14,0x25,0x82,0x00,0x10,0x34,0x42,0x00,0x10,0x3c,0x82,
-0x00,0x10,0x2c,0x02,0x30,0x42,0x00,0x01,0x30,0xcd,0x00,0x01,0x30,0x6c,0x00,0x01,
-0x30,0xe6,0x00,0x01,0x30,0x8a,0x00,0x03,0x32,0x94,0x00,0x07,0x30,0xa5,0x00,0x01,
-0xad,0x28,0x00,0x00,0x10,0x40,0x00,0x0b,0x32,0x07,0x00,0x7f,0x8d,0x64,0x00,0x18,
-0x3c,0x03,0xff,0xf0,0x34,0x63,0xff,0xff,0x8c,0x82,0x00,0x0c,0x01,0x03,0x18,0x24,
-0x00,0x02,0x13,0x82,0x30,0x42,0x00,0x0f,0x00,0x02,0x14,0x00,0x00,0x62,0x18,0x25,
-0xad,0x23,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xc2,0x00,0x6a,0x00,0x00,0x00,0x00,
-0x15,0x80,0x00,0x03,0x00,0x00,0x00,0x00,0x15,0x40,0x00,0x5b,0x24,0x02,0x00,0x01,
-0x96,0x22,0x00,0x04,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x04,0xa6,0x22,0x00,0x04,
-0x00,0xa0,0x20,0x21,0x0c,0x00,0x19,0x42,0x01,0xa0,0x28,0x21,0x02,0x72,0x18,0x21,
-0x00,0x03,0x40,0x80,0x2c,0x45,0x00,0x54,0x27,0x84,0x90,0x10,0x01,0x04,0x20,0x21,
-0x00,0x05,0x10,0x0a,0xa0,0x82,0x00,0x00,0xa0,0x80,0x00,0x04,0xa0,0x80,0x00,0x05,
-0x96,0x23,0x00,0x04,0x27,0x82,0x90,0x00,0x01,0x02,0x10,0x21,0xa4,0x43,0x00,0x06,
-0x27,0x82,0x90,0x04,0x92,0x26,0x00,0x01,0x01,0x02,0x10,0x21,0x8c,0x45,0x00,0x18,
-0x27,0x83,0x90,0x20,0x01,0x03,0x18,0x21,0xa0,0x60,0x00,0x00,0xa0,0x86,0x00,0x07,
-0x94,0xa2,0x00,0x10,0x24,0x03,0x00,0x04,0x30,0x42,0x00,0x0f,0x10,0x43,0x00,0x36,
-0x24,0xa5,0x00,0x10,0x94,0xa3,0x00,0x16,0x27,0x87,0x90,0x18,0x01,0x07,0x10,0x21,
-0xa4,0x43,0x00,0x02,0x94,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,
-0x14,0x40,0x00,0x24,0x02,0x72,0x20,0x21,0x94,0xa2,0x00,0x00,0x24,0x03,0x00,0xa4,
-0x30,0x42,0x00,0xff,0x10,0x43,0x00,0x1f,0x00,0x00,0x00,0x00,0x94,0xa2,0x00,0x00,
-0x24,0x03,0x00,0x88,0x30,0x42,0x00,0x88,0x10,0x43,0x00,0x14,0x02,0x72,0x18,0x21,
-0x27,0x84,0x90,0x20,0x00,0x03,0x18,0x80,0x00,0x64,0x18,0x21,0x8c,0x62,0x00,0x00,
-0x3c,0x04,0x00,0x80,0x00,0x44,0x10,0x25,0xac,0x62,0x00,0x00,0x02,0x72,0x10,0x21,
-0x00,0x02,0x10,0x80,0x00,0x47,0x10,0x21,0xa0,0x54,0x00,0x00,0x8f,0xbf,0x00,0x30,
-0x7b,0xb6,0x01,0x7c,0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,
-0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0x94,0xa2,0x00,0x18,
-0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x60,0x10,0x40,0xff,0xe9,0x02,0x72,0x18,0x21,
-0x02,0x72,0x20,0x21,0x27,0x82,0x90,0x20,0x00,0x04,0x20,0x80,0x00,0x82,0x20,0x21,
-0x8c,0x83,0x00,0x00,0x3c,0x02,0xff,0x7f,0x34,0x42,0xff,0xff,0x00,0x62,0x18,0x24,
-0x08,0x00,0x1a,0x37,0xac,0x83,0x00,0x00,0x27,0x87,0x90,0x18,0x01,0x07,0x10,0x21,
-0x08,0x00,0x1a,0x21,0xa4,0x40,0x00,0x02,0x11,0x42,0x00,0x07,0x00,0x00,0x00,0x00,
-0x2d,0x42,0x00,0x02,0x14,0x40,0xff,0xa7,0x00,0xa0,0x20,0x21,0x96,0x22,0x00,0x04,
-0x08,0x00,0x19,0xff,0x24,0x42,0x00,0x0c,0x96,0x22,0x00,0x04,0x08,0x00,0x19,0xff,
-0x24,0x42,0x00,0x08,0x16,0xe6,0xff,0x96,0x3c,0x02,0xff,0xfb,0x8d,0x63,0x00,0x18,
-0x34,0x42,0xff,0xff,0x02,0x02,0x10,0x24,0xac,0x62,0x00,0x08,0x08,0x00,0x19,0xf8,
-0x00,0x00,0x30,0x21,0x16,0xe6,0xff,0x4e,0x00,0x60,0x28,0x21,0x3c,0x02,0xfb,0xff,
-0x34,0x42,0xff,0xff,0x02,0x02,0x10,0x24,0xac,0xe2,0x00,0x08,0x08,0x00,0x19,0xb7,
-0x00,0x00,0x30,0x21,0x93,0x87,0xbb,0x14,0x00,0x10,0x1e,0x42,0x00,0x10,0x26,0x82,
-0x27,0x82,0x90,0x08,0x2c,0xe5,0x00,0x0c,0x01,0x22,0x48,0x21,0x30,0x63,0x00,0x01,
-0x30,0x86,0x00,0x01,0x14,0xa0,0x00,0x06,0x00,0xe0,0x40,0x21,0x00,0x03,0x10,0x40,
-0x00,0x46,0x10,0x21,0x00,0x02,0x11,0x00,0x00,0xe2,0x10,0x21,0x24,0x48,0x00,0x04,
-0x02,0x72,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x84,0x90,0x10,0x27,0x83,0x90,0x08,
-0x00,0x44,0x20,0x21,0x00,0x43,0x10,0x21,0xa1,0x28,0x00,0x07,0xa0,0x40,0x00,0x06,
-0xa0,0x80,0x00,0x02,0x08,0x00,0x19,0xc7,0xa0,0x80,0x00,0x01,0x24,0x02,0x00,0x01,
-0xa6,0x22,0x00,0x02,0x0c,0x00,0x01,0xc2,0x00,0xe0,0x20,0x21,0x08,0x00,0x1a,0x3b,
-0x00,0x00,0x00,0x00,0x30,0xa7,0xff,0xff,0x00,0x07,0x18,0xc0,0x00,0x67,0x18,0x21,
-0x3c,0x06,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x6a,0x44,0x27,0x85,0x90,0x10,
-0x00,0x03,0x18,0x80,0x34,0xc6,0x00,0x20,0x00,0x65,0x18,0x21,0xac,0xc2,0x00,0x00,
-0x80,0x62,0x00,0x07,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x29,0x00,0x80,0x28,0x21,
-0x90,0x82,0x00,0x16,0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x02,0x30,0x43,0x00,0x01,
-0x14,0x60,0x00,0x02,0xa0,0x82,0x00,0x16,0xa0,0x80,0x00,0x17,0x90,0xa2,0x00,0x04,
-0x3c,0x03,0xb0,0x03,0x27,0x86,0x90,0x00,0x14,0x40,0x00,0x06,0x34,0x63,0x00,0x20,
-0x24,0x02,0x00,0x01,0xa0,0xa2,0x00,0x04,0xa4,0xa7,0x00,0x02,0x03,0xe0,0x00,0x08,
-0xa4,0xa7,0x00,0x00,0x94,0xa4,0x00,0x02,0x3c,0x02,0x80,0x01,0x24,0x42,0x82,0x6c,
-0xac,0x62,0x00,0x00,0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,
-0x00,0x66,0x18,0x21,0x94,0x62,0x00,0x04,0xa4,0x67,0x00,0x02,0x3c,0x03,0xb0,0x08,
-0x00,0x02,0x20,0xc0,0x00,0x82,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21,
-0x00,0x83,0x20,0x21,0xa4,0x47,0x00,0x00,0xac,0x87,0x00,0x00,0x90,0xa2,0x00,0x04,
-0xa4,0xa7,0x00,0x02,0x24,0x42,0x00,0x01,0x03,0xe0,0x00,0x08,0xa0,0xa2,0x00,0x04,
-0x90,0x82,0x00,0x16,0x24,0x85,0x00,0x06,0x34,0x42,0x00,0x01,0x30,0x43,0x00,0x02,
-0x14,0x60,0xff,0xda,0xa0,0x82,0x00,0x16,0x24,0x02,0x00,0x01,0x08,0x00,0x1a,0xa7,
-0xa0,0x82,0x00,0x17,0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x00,0x80,0x38,0x21,
-0x84,0x84,0x00,0x02,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x3c,0x0a,0xb0,0x06,
-0x34,0x63,0x00,0x20,0x24,0x42,0x6b,0x44,0x3c,0x0b,0xb0,0x08,0x27,0x89,0x90,0x00,
-0x34,0x0c,0xff,0xff,0x35,0x4a,0x80,0x20,0x10,0x80,0x00,0x30,0xac,0x62,0x00,0x00,
-0x97,0x82,0x8f,0xf0,0x94,0xe6,0x02,0xba,0x00,0x02,0x18,0xc0,0x00,0x6b,0x28,0x21,
-0xac,0xa6,0x00,0x00,0x8c,0xe4,0x02,0xb8,0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x80,
-0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x21,
-0x94,0x48,0x00,0x04,0x00,0x69,0x18,0x21,0xa4,0x66,0x00,0x00,0x00,0x08,0x28,0xc0,
-0x00,0xab,0x10,0x21,0xac,0x4c,0x00,0x00,0x8c,0xe4,0x02,0xb8,0x27,0x82,0x90,0x04,
-0x00,0xa8,0x28,0x21,0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,
-0x00,0x62,0x10,0x21,0x8c,0x46,0x00,0x18,0x27,0x84,0x90,0x10,0x00,0x64,0x18,0x21,
-0x8c,0xc2,0x00,0x00,0x80,0x67,0x00,0x06,0x00,0x05,0x28,0x80,0x30,0x42,0xff,0xff,
-0x00,0x47,0x10,0x21,0x30,0x43,0x00,0xff,0x00,0x03,0x18,0x2b,0x00,0x02,0x12,0x02,
-0x00,0x43,0x10,0x21,0x3c,0x04,0x00,0x04,0x00,0xa9,0x28,0x21,0x00,0x44,0x10,0x25,
-0xa4,0xac,0x00,0x00,0xad,0x42,0x00,0x00,0xa7,0x88,0x8f,0xf0,0x8f,0xbf,0x00,0x10,
-0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x84,0xe3,0x00,0x06,
-0x27,0x82,0xb4,0x00,0x94,0xe5,0x02,0xba,0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,
-0x8c,0x64,0x00,0x00,0x0c,0x00,0x1a,0x91,0x00,0x00,0x00,0x00,0x08,0x00,0x1b,0x0b,
-0x00,0x00,0x00,0x00,0x94,0x88,0x00,0x00,0x00,0x80,0x58,0x21,0x27,0x8a,0x90,0x00,
-0x00,0x08,0x18,0xc0,0x00,0x68,0x18,0x21,0x3c,0x04,0xb0,0x03,0x00,0x03,0x18,0x80,
-0x3c,0x02,0x80,0x00,0x00,0x6a,0x18,0x21,0x34,0x84,0x00,0x20,0x24,0x42,0x6c,0x64,
-0x30,0xa5,0xff,0xff,0xac,0x82,0x00,0x00,0x94,0x67,0x00,0x02,0x11,0x05,0x00,0x35,
-0x24,0x04,0x00,0x01,0x91,0x66,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x86,0x10,0x2a,
-0x10,0x40,0x00,0x10,0x00,0xc0,0x48,0x21,0x3c,0x0d,0xb0,0x03,0x01,0x40,0x60,0x21,
-0x35,0xad,0x00,0x20,0x10,0xe5,0x00,0x0d,0x24,0x84,0x00,0x01,0x00,0x07,0x10,0xc0,
-0x00,0x47,0x10,0x21,0x00,0x02,0x10,0x80,0x01,0x20,0x30,0x21,0x00,0x4a,0x10,0x21,
-0x00,0x86,0x18,0x2a,0x00,0xe0,0x40,0x21,0x94,0x47,0x00,0x02,0x14,0x60,0xff,0xf5,
-0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x10,0x21,0x00,0x08,0x20,0xc0,
-0x00,0x88,0x20,0x21,0x24,0xc2,0xff,0xff,0x00,0x04,0x20,0x80,0xa1,0x62,0x00,0x04,
-0x00,0x8c,0x20,0x21,0x94,0x83,0x00,0x04,0x00,0x07,0x10,0xc0,0x00,0x47,0x10,0x21,
-0x00,0x02,0x10,0x80,0x00,0x4c,0x10,0x21,0x00,0x03,0x28,0xc0,0x94,0x46,0x00,0x02,
-0x00,0xa3,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x6c,0x18,0x21,0xa4,0x66,0x00,0x00,
-0xa4,0x86,0x00,0x02,0x95,0x64,0x00,0x02,0x3c,0x03,0xb0,0x08,0x3c,0x02,0x80,0x01,
-0x00,0xa3,0x28,0x21,0x24,0x42,0x82,0x6c,0xad,0xa2,0x00,0x00,0x10,0x87,0x00,0x03,
-0xac,0xa6,0x00,0x00,0x03,0xe0,0x00,0x08,0x24,0x02,0x00,0x01,0x08,0x00,0x1b,0x59,
-0xa5,0x68,0x00,0x02,0x91,0x62,0x00,0x04,0xa5,0x67,0x00,0x00,0x24,0x42,0xff,0xff,
-0x30,0x43,0x00,0xff,0x14,0x60,0xff,0xf7,0xa1,0x62,0x00,0x04,0x24,0x02,0xff,0xff,
-0x08,0x00,0x1b,0x59,0xa5,0x62,0x00,0x02,0x00,0x05,0x40,0xc0,0x01,0x05,0x30,0x21,
-0x27,0xbd,0xff,0xd8,0x00,0x06,0x30,0x80,0x27,0x82,0x90,0x04,0xaf,0xb2,0x00,0x18,
-0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,0xaf,0xb0,0x00,0x10,
-0x00,0xc2,0x10,0x21,0x8c,0x47,0x00,0x18,0x00,0xa0,0x90,0x21,0x3c,0x02,0x80,0x00,
-0x3c,0x05,0xb0,0x03,0x34,0xa5,0x00,0x20,0x24,0x42,0x6d,0x98,0xac,0xa2,0x00,0x00,
-0x27,0x83,0x90,0x10,0x00,0xc3,0x30,0x21,0x8c,0xe2,0x00,0x00,0x80,0xc5,0x00,0x06,
-0x00,0x80,0x88,0x21,0x30,0x42,0xff,0xff,0x00,0x45,0x10,0x21,0x30,0x43,0x00,0xff,
-0x10,0x60,0x00,0x02,0x00,0x02,0x12,0x02,0x24,0x42,0x00,0x01,0x30,0x53,0x00,0xff,
-0x01,0x12,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,
-0x80,0x44,0x00,0x07,0x00,0x00,0x00,0x00,0x10,0x80,0x00,0x4b,0x26,0x24,0x00,0x06,
-0x32,0x50,0xff,0xff,0x02,0x20,0x20,0x21,0x0c,0x00,0x1b,0x19,0x02,0x00,0x28,0x21,
-0x92,0x22,0x00,0x10,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x2e,0x3c,0x03,0xb0,0x08,
-0x3c,0x09,0x80,0x01,0x27,0x88,0x90,0x00,0xa6,0x32,0x00,0x0c,0x00,0x10,0x20,0xc0,
-0x00,0x90,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x88,0x20,0x21,0x94,0x82,0x00,0x04,
-0x3c,0x03,0xb0,0x08,0x3c,0x07,0xb0,0x03,0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21,
-0x00,0x02,0x10,0x80,0x00,0x48,0x10,0x21,0x00,0xa3,0x28,0x21,0x25,0x26,0x82,0x6c,
-0x34,0x03,0xff,0xff,0x34,0xe7,0x00,0x20,0xac,0xe6,0x00,0x00,0xa4,0x83,0x00,0x02,
-0xa4,0x43,0x00,0x00,0xac,0xa3,0x00,0x00,0x92,0x22,0x00,0x10,0x92,0x23,0x00,0x0a,
-0xa6,0x32,0x00,0x0e,0x02,0x62,0x10,0x21,0x14,0x60,0x00,0x05,0xa2,0x22,0x00,0x10,
-0x92,0x22,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfe,0xa2,0x22,0x00,0x16,
-0x92,0x22,0x00,0x04,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,
-0x92,0x22,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfd,0xa2,0x22,0x00,0x16,
-0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,
-0x27,0xbd,0x00,0x28,0x96,0x22,0x00,0x0e,0x27,0x88,0x90,0x00,0x00,0x02,0x20,0xc0,
-0x00,0x82,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x88,0x20,0x21,0x94,0x82,0x00,0x04,
-0x3c,0x06,0xb0,0x03,0x3c,0x09,0x80,0x01,0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21,
-0x00,0x02,0x10,0x80,0x00,0xa3,0x28,0x21,0x00,0x48,0x10,0x21,0x34,0xc6,0x00,0x20,
-0x25,0x23,0x82,0x6c,0xac,0xc3,0x00,0x00,0xa4,0x50,0x00,0x00,0xac,0xb0,0x00,0x00,
-0x08,0x00,0x1b,0x97,0xa4,0x90,0x00,0x02,0x08,0x00,0x1b,0x8e,0x32,0x50,0xff,0xff,
-0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x6f,0x60,0x34,0x63,0x00,0x20,
-0xac,0x62,0x00,0x00,0x90,0x82,0x00,0x04,0x97,0xaa,0x00,0x12,0x00,0x80,0x60,0x21,
-0x30,0xa8,0xff,0xff,0x00,0x4a,0x20,0x23,0x34,0x09,0xff,0xff,0x30,0xcf,0xff,0xff,
-0x30,0xee,0xff,0xff,0x11,0x09,0x00,0x73,0xa1,0x84,0x00,0x04,0x00,0x0e,0xc0,0xc0,
-0x00,0x08,0x10,0xc0,0x00,0x48,0x10,0x21,0x03,0x0e,0x20,0x21,0x27,0x8d,0x90,0x00,
-0x00,0x04,0x20,0x80,0x00,0x02,0x10,0x80,0x00,0x4d,0x10,0x21,0x00,0x8d,0x20,0x21,
-0x94,0x86,0x00,0x02,0x94,0x43,0x00,0x04,0x3c,0x19,0x80,0x01,0xa4,0x46,0x00,0x02,
-0x00,0x03,0x28,0xc0,0x00,0xa3,0x18,0x21,0x94,0x87,0x00,0x02,0x3c,0x02,0xb0,0x08,
-0x00,0x03,0x18,0x80,0x00,0xa2,0x28,0x21,0x00,0x6d,0x18,0x21,0x27,0x22,0x82,0x6c,
-0x3c,0x01,0xb0,0x03,0xac,0x22,0x00,0x20,0xa4,0x66,0x00,0x00,0x10,0xe9,0x00,0x57,
-0xac,0xa6,0x00,0x00,0x01,0xe0,0x30,0x21,0x11,0x40,0x00,0x1d,0x00,0x00,0x48,0x21,
-0x01,0x40,0x38,0x21,0x27,0x8b,0x90,0x04,0x27,0x8a,0x90,0x10,0x00,0x06,0x40,0xc0,
-0x01,0x06,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x6b,0x10,0x21,0x8c,0x44,0x00,0x18,
-0x00,0x6a,0x18,0x21,0x80,0x65,0x00,0x06,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,
-0x30,0x42,0xff,0xff,0x00,0x45,0x10,0x21,0x30,0x44,0x00,0xff,0x00,0x02,0x12,0x02,
-0x01,0x22,0x18,0x21,0x24,0x62,0x00,0x01,0x14,0x80,0x00,0x02,0x30,0x49,0x00,0xff,
-0x30,0x69,0x00,0xff,0x01,0x06,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x4d,0x10,0x21,
-0x24,0xe7,0xff,0xff,0x94,0x46,0x00,0x02,0x14,0xe0,0xff,0xe9,0x00,0x06,0x40,0xc0,
-0x91,0x82,0x00,0x10,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x20,0x3c,0x06,0xb0,0x03,
-0xa5,0x8f,0x00,0x0c,0x03,0x0e,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x8d,0x20,0x21,
-0x94,0x82,0x00,0x04,0x3c,0x03,0xb0,0x08,0x3c,0x07,0xb0,0x03,0x00,0x02,0x28,0xc0,
-0x00,0xa2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x4d,0x10,0x21,0x00,0xa3,0x28,0x21,
-0x27,0x26,0x82,0x6c,0x34,0x03,0xff,0xff,0x34,0xe7,0x00,0x20,0xac,0xe6,0x00,0x00,
-0xa4,0x83,0x00,0x02,0xa4,0x43,0x00,0x00,0xac,0xa3,0x00,0x00,0x91,0x82,0x00,0x10,
-0x91,0x83,0x00,0x04,0xa5,0x8e,0x00,0x0e,0x01,0x22,0x10,0x21,0x14,0x60,0x00,0x05,
-0xa1,0x82,0x00,0x10,0x91,0x82,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfd,
-0xa1,0x82,0x00,0x16,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x95,0x82,0x00,0x0e,
-0x3c,0x03,0xb0,0x08,0x00,0x02,0x20,0xc0,0x00,0x82,0x20,0x21,0x00,0x04,0x20,0x80,
-0x00,0x8d,0x20,0x21,0x94,0x82,0x00,0x04,0x34,0xc6,0x00,0x20,0x27,0x27,0x82,0x6c,
-0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0xa3,0x28,0x21,
-0x00,0x4d,0x10,0x21,0xac,0xc7,0x00,0x00,0xa4,0x8f,0x00,0x02,0xa4,0x4f,0x00,0x00,
-0xac,0xaf,0x00,0x00,0x08,0x00,0x1c,0x26,0x03,0x0e,0x20,0x21,0x08,0x00,0x1c,0x01,
-0xa5,0x88,0x00,0x02,0x00,0x0e,0xc0,0xc0,0x03,0x0e,0x10,0x21,0x00,0x02,0x10,0x80,
-0x27,0x8d,0x90,0x00,0x00,0x4d,0x10,0x21,0x94,0x43,0x00,0x02,0x30,0x84,0x00,0xff,
-0x14,0x80,0x00,0x05,0xa5,0x83,0x00,0x00,0x24,0x02,0xff,0xff,0x3c,0x19,0x80,0x01,
-0x08,0x00,0x1c,0x01,0xa5,0x82,0x00,0x02,0x08,0x00,0x1c,0x01,0x3c,0x19,0x80,0x01,
-0x3c,0x08,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0x78,0x35,0x08,0x00,0x20,
-0x24,0x42,0x71,0xa0,0xaf,0xb2,0x00,0x68,0xaf,0xb1,0x00,0x64,0xaf,0xb0,0x00,0x60,
-0xad,0x02,0x00,0x00,0xaf,0xbf,0x00,0x84,0xaf,0xbe,0x00,0x80,0xaf,0xb7,0x00,0x7c,
-0xaf,0xb6,0x00,0x78,0xaf,0xb5,0x00,0x74,0xaf,0xb4,0x00,0x70,0xaf,0xb3,0x00,0x6c,
-0xaf,0xa4,0x00,0x88,0x90,0x83,0x00,0x0a,0x27,0x82,0xb4,0x00,0xaf,0xa6,0x00,0x90,
-0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,0x8c,0x63,0x00,0x00,0xaf,0xa7,0x00,0x94,
-0x27,0x86,0x90,0x04,0xaf,0xa3,0x00,0x1c,0x94,0x63,0x00,0x14,0x30,0xb1,0xff,0xff,
-0x24,0x08,0x00,0x01,0x00,0x03,0x20,0xc0,0xaf,0xa3,0x00,0x18,0x00,0x83,0x18,0x21,
-0xaf,0xa4,0x00,0x54,0x00,0x03,0x18,0x80,0x27,0x84,0x90,0x10,0x00,0x64,0x20,0x21,
-0x80,0x82,0x00,0x06,0x00,0x66,0x18,0x21,0x8c,0x66,0x00,0x18,0x24,0x42,0x00,0x02,
-0x00,0x02,0x1f,0xc2,0x8c,0xc4,0x00,0x08,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,
-0x00,0x02,0x10,0x40,0x00,0x04,0x2f,0xc2,0x00,0x04,0x1c,0x82,0x00,0xc2,0x38,0x21,
-0x00,0x04,0x24,0x42,0x8f,0xa2,0x00,0x1c,0x30,0x63,0x00,0x01,0x30,0x84,0x00,0x01,
-0xaf,0xa5,0x00,0x3c,0xaf,0xa3,0x00,0x34,0xaf,0xa4,0x00,0x38,0xaf,0xa0,0x00,0x40,
-0xaf,0xa0,0x00,0x44,0xaf,0xa0,0x00,0x50,0xaf,0xa8,0x00,0x20,0x80,0x42,0x00,0x12,
-0x8f,0xb2,0x00,0x18,0xaf,0xa2,0x00,0x28,0x8c,0xd0,0x00,0x0c,0x14,0xa0,0x01,0xe4,
-0x00,0x60,0x30,0x21,0x00,0x10,0x10,0x82,0x30,0x45,0x00,0x07,0x10,0xa0,0x00,0x11,
-0xaf,0xa0,0x00,0x30,0x8f,0xa4,0x00,0x98,0x27,0x82,0x80,0x1c,0x00,0x04,0x18,0x40,
-0x00,0x62,0x18,0x21,0x24,0xa2,0x00,0x06,0x8f,0xa5,0x00,0x20,0x94,0x64,0x00,0x00,
-0x00,0x45,0x10,0x04,0x00,0x44,0x00,0x1a,0x14,0x80,0x00,0x02,0x00,0x00,0x00,0x00,
-0x00,0x07,0x00,0x0d,0x00,0x00,0x10,0x12,0x24,0x42,0x00,0x20,0x30,0x42,0xff,0xfc,
-0xaf,0xa2,0x00,0x30,0x8f,0xa3,0x00,0x18,0x8f,0xa4,0x00,0x28,0x34,0x02,0xff,0xff,
-0xaf,0xa0,0x00,0x2c,0xaf,0xa2,0x00,0x48,0xaf,0xa3,0x00,0x4c,0x00,0x60,0xf0,0x21,
-0x00,0x00,0xb8,0x21,0x18,0x80,0x00,0x48,0xaf,0xa0,0x00,0x24,0x00,0x11,0x89,0x02,
-0xaf,0xb1,0x00,0x58,0x00,0x80,0xa8,0x21,0x00,0x12,0x10,0xc0,0x00,0x52,0x18,0x21,
-0x00,0x03,0x80,0x80,0x27,0x85,0x90,0x00,0x02,0x40,0x20,0x21,0x00,0x40,0xa0,0x21,
-0x02,0x05,0x10,0x21,0x94,0x56,0x00,0x02,0x0c,0x00,0x12,0x8b,0x00,0x00,0x28,0x21,
-0x90,0x42,0x00,0x00,0x24,0x03,0x00,0x08,0x30,0x42,0x00,0x0c,0x10,0x43,0x01,0x9e,
-0x24,0x04,0x00,0x01,0x24,0x02,0x00,0x01,0x10,0x82,0x01,0x7c,0x3c,0x02,0xb0,0x03,
-0x8f,0xa6,0x00,0x88,0x34,0x42,0x01,0x04,0x84,0xc5,0x00,0x0c,0x02,0x92,0x18,0x21,
-0x94,0x46,0x00,0x00,0x00,0x05,0x20,0xc0,0x00,0x85,0x20,0x21,0x00,0x03,0x18,0x80,
-0x27,0x82,0x90,0x10,0x27,0x85,0x90,0x08,0x00,0x65,0x28,0x21,0x00,0x62,0x18,0x21,
-0x80,0x71,0x00,0x05,0x80,0x73,0x00,0x04,0x8f,0xa3,0x00,0x88,0x30,0xd0,0xff,0xff,
-0x00,0x10,0x3a,0x03,0x32,0x08,0x00,0xff,0x27,0x82,0x90,0x20,0x00,0x04,0x20,0x80,
-0x80,0xa6,0x00,0x06,0x00,0x82,0x20,0x21,0xa4,0x67,0x00,0x44,0xa4,0x68,0x00,0x46,
-0x8c,0x84,0x00,0x00,0x38,0xc6,0x00,0x00,0x01,0x00,0x80,0x21,0x00,0x04,0x15,0x02,
-0x30,0x42,0x00,0x01,0x10,0x40,0x00,0x03,0x00,0xe6,0x80,0x0a,0x00,0x04,0x14,0x02,
-0x30,0x50,0x00,0x0f,0x12,0x20,0x01,0x50,0x02,0x40,0x20,0x21,0x02,0x71,0x10,0x21,
-0x00,0x50,0x10,0x2a,0x14,0x40,0x00,0xed,0x02,0x92,0x10,0x21,0x93,0x82,0x8b,0x71,
-0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0xe0,0x02,0x92,0x28,0x21,
-0x26,0xe2,0x00,0x01,0x30,0x57,0xff,0xff,0x02,0x40,0xf0,0x21,0x26,0xb5,0xff,0xff,
-0x16,0xa0,0xff,0xbd,0x02,0xc0,0x90,0x21,0x16,0xe0,0x00,0xd0,0x00,0x00,0x00,0x00,
-0x8f,0xa3,0x00,0x98,0x00,0x00,0x00,0x00,0x2c,0x62,0x00,0x10,0x10,0x40,0x00,0x2e,
-0x00,0x00,0x00,0x00,0x8f,0xa4,0x00,0x24,0x00,0x00,0x00,0x00,0x18,0x80,0x00,0x2a,
-0x24,0x03,0x00,0x01,0x8f,0xa5,0x00,0x1c,0x27,0x84,0x90,0x04,0x94,0xb2,0x00,0x14,
-0xa0,0xa3,0x00,0x12,0x8f,0xa6,0x00,0x3c,0x00,0x12,0x10,0xc0,0x00,0x52,0x10,0x21,
-0x00,0x02,0x80,0x80,0x27,0x82,0x90,0x10,0x02,0x02,0x10,0x21,0x80,0x43,0x00,0x06,
-0x02,0x04,0x20,0x21,0x8c,0x85,0x00,0x18,0x24,0x63,0x00,0x02,0x00,0x03,0x17,0xc2,
-0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x43,0x00,0x03,0x18,0x40,0x14,0xc0,0x00,0x0e,
-0x00,0xa3,0x38,0x21,0x27,0x82,0x90,0x00,0x02,0x02,0x10,0x21,0x94,0x43,0x00,0x06,
-0x8f,0xa8,0x00,0x1c,0x24,0x02,0x00,0x01,0xa5,0x03,0x00,0x1a,0x7b,0xbe,0x04,0x3c,
-0x7b,0xb6,0x03,0xfc,0x7b,0xb4,0x03,0xbc,0x7b,0xb2,0x03,0x7c,0x7b,0xb0,0x03,0x3c,
-0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x88,0x8f,0xa4,0x00,0x98,0x8f,0xa5,0x00,0x38,
-0x8f,0xa6,0x00,0x34,0xaf,0xa0,0x00,0x10,0x0c,0x00,0x09,0x0a,0xaf,0xa0,0x00,0x14,
-0x08,0x00,0x1d,0x2d,0x00,0x00,0x00,0x00,0x8f,0xa3,0x00,0x44,0x93,0x82,0x81,0x58,
-0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x61,0x30,0x69,0x00,0x03,0x8f,0xa4,0x00,0x24,
-0x8f,0xa5,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x85,0x10,0x2a,0x10,0x40,0x00,0x8f,
-0x00,0x00,0x00,0x00,0x8f,0xa6,0x00,0x1c,0x00,0x00,0x00,0x00,0x90,0xc4,0x00,0x04,
-0x00,0x00,0x00,0x00,0x30,0x83,0x00,0xff,0x00,0xa3,0x10,0x2a,0x10,0x40,0x00,0x87,
-0x00,0x00,0x00,0x00,0x8f,0xa8,0x00,0x24,0x00,0x00,0x00,0x00,0x11,0x00,0x00,0x83,
-0x00,0x65,0x10,0x23,0x00,0xa8,0x18,0x23,0x00,0x62,0x10,0x2a,0x14,0x40,0x00,0x7d,
-0x30,0x63,0x00,0xff,0x00,0x85,0x10,0x23,0x30,0x42,0x00,0xff,0xaf,0xa2,0x00,0x50,
-0x8f,0xa2,0x00,0x50,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x73,0x00,0x00,0xa8,0x21,
-0x27,0x8c,0x90,0x00,0x3c,0x0b,0x80,0xff,0x24,0x10,0x00,0x04,0x27,0x91,0x90,0x04,
-0x35,0x6b,0xff,0xff,0x3c,0x0d,0x7f,0x00,0x27,0x8e,0x90,0x10,0x01,0x80,0x78,0x21,
-0x00,0x12,0x30,0xc0,0x00,0xd2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x4c,0x10,0x21,
-0x94,0x42,0x00,0x06,0x8f,0xa3,0x00,0x2c,0x8f,0xa4,0x00,0x30,0xaf,0xa2,0x00,0x44,
-0x8f,0xa5,0x00,0x44,0x30,0x49,0x00,0x03,0x02,0x09,0x10,0x23,0x30,0x42,0x00,0x03,
-0x00,0xa2,0x10,0x21,0x8f,0xa8,0x00,0x30,0x24,0x42,0x00,0x04,0x30,0x42,0xff,0xff,
-0x00,0x64,0x38,0x21,0x01,0x02,0x28,0x23,0x00,0x62,0x18,0x21,0x00,0x48,0x10,0x2b,
-0x10,0x40,0x00,0x52,0x00,0x00,0x20,0x21,0x30,0xe7,0xff,0xff,0x30,0xa4,0xff,0xff,
-0xaf,0xa7,0x00,0x2c,0x00,0xd2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x51,0x18,0x21,
-0x8c,0x65,0x00,0x18,0x00,0x04,0x25,0x40,0x00,0x8d,0x20,0x24,0x8c,0xa8,0x00,0x04,
-0x00,0x4e,0x18,0x21,0x00,0x4f,0x50,0x21,0x01,0x0b,0x40,0x24,0x01,0x04,0x40,0x25,
-0xac,0xa8,0x00,0x04,0x8f,0xa4,0x00,0x98,0x8f,0xa2,0x00,0x50,0x26,0xb5,0x00,0x01,
-0xa0,0x64,0x00,0x00,0x8c,0xa4,0x00,0x08,0x00,0x00,0x00,0x00,0x04,0x81,0x00,0x0c,
-0x02,0xa2,0x30,0x2a,0x80,0x62,0x00,0x06,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02,
-0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40,
-0x00,0xa2,0x38,0x21,0x8f,0xa5,0x00,0x40,0x00,0x00,0x00,0x00,0xa4,0xe5,0x00,0x00,
-0x95,0x52,0x00,0x02,0x14,0xc0,0xff,0xc7,0x00,0x12,0x30,0xc0,0x8f,0xa4,0x00,0x24,
-0x8f,0xa5,0x00,0x50,0x8f,0xa6,0x00,0x1c,0x8f,0xa3,0x00,0x2c,0x00,0x85,0x80,0x21,
-0xa0,0xd0,0x00,0x12,0x00,0x09,0x10,0x23,0x30,0x42,0x00,0x03,0x8f,0xa8,0x00,0x88,
-0x00,0x62,0x10,0x23,0xa4,0xc2,0x00,0x1a,0x85,0x03,0x00,0x0c,0x00,0x00,0x00,0x00,
-0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x04,
-0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x83,0x00,0x04,
-0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10,0x14,0x60,0xff,0x74,0x02,0x00,0x10,0x21,
-0x8f,0xa3,0x00,0x54,0x8f,0xa4,0x00,0x18,0x8f,0xa5,0x00,0x24,0x00,0x64,0x10,0x21,
-0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x18,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x00,
-0x10,0xa0,0x00,0x03,0x00,0x00,0x30,0x21,0x08,0x00,0x1d,0x33,0x02,0x00,0x10,0x21,
-0x93,0x82,0x80,0x10,0x00,0x00,0x28,0x21,0x00,0x00,0x38,0x21,0x0c,0x00,0x21,0x9a,
-0xaf,0xa2,0x00,0x10,0x08,0x00,0x1d,0x33,0x02,0x00,0x10,0x21,0x30,0x63,0xff,0xff,
-0x08,0x00,0x1d,0x85,0xaf,0xa3,0x00,0x2c,0x8f,0xa8,0x00,0x44,0x08,0x00,0x1d,0xa7,
-0x31,0x09,0x00,0x03,0x08,0x00,0x1d,0x60,0xaf,0xa3,0x00,0x50,0x8f,0xa6,0x00,0x44,
-0xaf,0xa0,0x00,0x50,0x08,0x00,0x1d,0xa7,0x30,0xc9,0x00,0x03,0x8f,0xa5,0x00,0x48,
-0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x1c,0x03,0xc0,0x38,0x21,0x0c,0x00,0x1b,0xd8,
-0xaf,0xb7,0x00,0x10,0x08,0x00,0x1d,0x10,0x00,0x00,0x00,0x00,0x00,0x05,0x28,0x80,
-0x27,0x82,0x90,0x00,0x00,0xa2,0x28,0x21,0x00,0x00,0x20,0x21,0x0c,0x00,0x01,0x49,
-0x00,0x00,0x00,0x00,0x08,0x00,0x1d,0x09,0x26,0xe2,0x00,0x01,0x00,0x02,0x80,0x80,
-0x27,0x83,0x90,0x10,0x8f,0xa4,0x00,0x1c,0x02,0x03,0x18,0x21,0x26,0x31,0x00,0x01,
-0x02,0x40,0x28,0x21,0x0c,0x00,0x1e,0xea,0xa0,0x71,0x00,0x05,0x14,0x40,0xff,0x13,
-0x00,0x00,0x00,0x00,0x16,0xe0,0x00,0x4d,0x03,0xc0,0x38,0x21,0x8f,0xa4,0x00,0x24,
-0x8f,0xa5,0x00,0x20,0x24,0x02,0x00,0x01,0x24,0x84,0x00,0x01,0xaf,0xb2,0x00,0x48,
-0xaf,0xb6,0x00,0x4c,0x02,0xc0,0xf0,0x21,0x10,0xa2,0x00,0x41,0xaf,0xa4,0x00,0x24,
-0x27,0x82,0x90,0x00,0x02,0x02,0x10,0x21,0x94,0x42,0x00,0x06,0x8f,0xa4,0x00,0x30,
-0xaf,0xa0,0x00,0x20,0xaf,0xa2,0x00,0x44,0x30,0x49,0x00,0x03,0x8f,0xa8,0x00,0x44,
-0x00,0x09,0x10,0x23,0x30,0x42,0x00,0x03,0x01,0x02,0x10,0x21,0x24,0x42,0x00,0x04,
-0x30,0x42,0xff,0xff,0x00,0x44,0x18,0x2b,0x10,0x60,0x00,0x2b,0x00,0x00,0x00,0x00,
-0x8f,0xa5,0x00,0x2c,0x00,0x82,0x10,0x23,0x00,0xa4,0x18,0x21,0x30,0x63,0xff,0xff,
-0x30,0x44,0xff,0xff,0xaf,0xa3,0x00,0x2c,0x02,0x92,0x28,0x21,0x00,0x05,0x28,0x80,
-0x27,0x82,0x90,0x04,0x00,0xa2,0x10,0x21,0x8c,0x46,0x00,0x18,0x3c,0x03,0x80,0xff,
-0x3c,0x02,0x7f,0x00,0x8c,0xc8,0x00,0x04,0x00,0x04,0x25,0x40,0x34,0x63,0xff,0xff,
-0x00,0x82,0x20,0x24,0x01,0x03,0x40,0x24,0x01,0x04,0x40,0x25,0xac,0xc8,0x00,0x04,
-0x8f,0xa8,0x00,0x98,0x27,0x82,0x90,0x10,0x00,0xa2,0x10,0x21,0xa0,0x48,0x00,0x00,
-0x8c,0xc4,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x04,0x27,0xc2,0x10,0x80,0xfe,0xdb,
-0xaf,0xa4,0x00,0x3c,0x80,0x42,0x00,0x06,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02,
-0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40,
-0x00,0xc2,0x38,0x21,0x8f,0xa2,0x00,0x40,0x00,0x00,0x00,0x00,0xa4,0xe2,0x00,0x00,
-0x08,0x00,0x1d,0x0c,0x26,0xb5,0xff,0xff,0x8f,0xa6,0x00,0x2c,0x00,0x00,0x20,0x21,
-0x00,0xc2,0x10,0x21,0x30,0x42,0xff,0xff,0x08,0x00,0x1e,0x1a,0xaf,0xa2,0x00,0x2c,
-0x8f,0xa6,0x00,0x1c,0x08,0x00,0x1e,0x04,0xa4,0xd2,0x00,0x14,0x8f,0xa5,0x00,0x48,
-0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x1c,0x0c,0x00,0x1b,0xd8,0xaf,0xb7,0x00,0x10,
-0x08,0x00,0x1d,0xfb,0x00,0x00,0xb8,0x21,0x0c,0x00,0x12,0x8b,0x00,0x00,0x28,0x21,
-0x00,0x40,0x18,0x21,0x94,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x42,0x08,0x00,
-0xa4,0x62,0x00,0x00,0x08,0x00,0x1d,0x00,0x02,0x71,0x10,0x21,0x02,0x92,0x18,0x21,
-0x00,0x03,0x80,0x80,0x27,0x82,0x90,0x04,0x02,0x02,0x10,0x21,0x8c,0x44,0x00,0x18,
-0x00,0x00,0x00,0x00,0x8c,0x83,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10,
-0x10,0x60,0x00,0x09,0x24,0x06,0x00,0x01,0x93,0x82,0x8b,0x71,0x00,0x00,0x00,0x00,
-0x30,0x42,0x00,0x01,0x10,0x40,0xfe,0xa2,0x3c,0x04,0x00,0x80,0x27,0x85,0x90,0x00,
-0x08,0x00,0x1d,0xeb,0x02,0x05,0x28,0x21,0x27,0x83,0x90,0x18,0x27,0x82,0x90,0x10,
-0x02,0x03,0x18,0x21,0x02,0x02,0x10,0x21,0x90,0x64,0x00,0x00,0x90,0x45,0x00,0x05,
-0x93,0x83,0x80,0x10,0x00,0x00,0x38,0x21,0x0c,0x00,0x21,0x9a,0xaf,0xa3,0x00,0x10,
-0x08,0x00,0x1e,0x62,0x00,0x00,0x00,0x00,0x27,0x82,0x90,0x18,0x02,0x02,0x10,0x21,
-0x94,0x43,0x00,0x02,0x8f,0xa6,0x00,0x58,0x00,0x03,0x19,0x02,0x00,0x66,0x18,0x23,
-0x30,0x63,0x0f,0xff,0x28,0x62,0x00,0x20,0x10,0x40,0x00,0x06,0x28,0x62,0x00,0x40,
-0x8f,0xa8,0x00,0x90,0x00,0x00,0x00,0x00,0x00,0x68,0x10,0x06,0x08,0x00,0x1c,0xd9,
-0x30,0x44,0x00,0x01,0x10,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0x8f,0xa4,0x00,0x94,
-0x08,0x00,0x1e,0x83,0x00,0x64,0x10,0x06,0x08,0x00,0x1c,0xd9,0x00,0x00,0x20,0x21,
-0x8f,0xa4,0x00,0x98,0x8f,0xa5,0x00,0x38,0xaf,0xa0,0x00,0x10,0x0c,0x00,0x09,0x0a,
-0xaf,0xa8,0x00,0x14,0x30,0x42,0xff,0xff,0x08,0x00,0x1c,0xa9,0xaf,0xa2,0x00,0x40,
-0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00,0x27,0xbd,0xff,0xe0,0x34,0x42,0x00,0x20,
-0x24,0x63,0x7a,0x50,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x18,
-0xac,0x43,0x00,0x00,0x90,0x82,0x00,0x0a,0x00,0x80,0x80,0x21,0x14,0x40,0x00,0x45,
-0x00,0x00,0x88,0x21,0x92,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x3c,
-0x00,0x00,0x00,0x00,0x12,0x20,0x00,0x18,0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16,
-0x92,0x05,0x00,0x0a,0x30,0x42,0x00,0xfc,0x10,0xa0,0x00,0x03,0xa2,0x02,0x00,0x16,
-0x34,0x42,0x00,0x01,0xa2,0x02,0x00,0x16,0x92,0x04,0x00,0x04,0x00,0x00,0x00,0x00,
-0x30,0x83,0x00,0xff,0x10,0x60,0x00,0x05,0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16,
-0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x02,0xa2,0x02,0x00,0x16,0x10,0x60,0x00,0x0a,
-0x00,0x00,0x00,0x00,0x14,0xa0,0x00,0x08,0x00,0x00,0x00,0x00,0x96,0x02,0x00,0x00,
-0xa2,0x00,0x00,0x17,0xa6,0x02,0x00,0x14,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,
-0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x14,0x80,0x00,0x05,0x24,0x02,0x00,0x01,
-0x96,0x03,0x00,0x06,0xa2,0x02,0x00,0x17,0x08,0x00,0x1e,0xbe,0xa6,0x03,0x00,0x14,
-0x96,0x04,0x00,0x00,0x96,0x05,0x00,0x06,0x27,0x86,0x90,0x00,0x00,0x04,0x10,0xc0,
-0x00,0x05,0x18,0xc0,0x00,0x44,0x10,0x21,0x00,0x65,0x18,0x21,0x00,0x02,0x10,0x80,
-0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08,
-0x8c,0x44,0x00,0x08,0x0c,0x00,0x12,0x7c,0x00,0x00,0x00,0x00,0x30,0x43,0x00,0xff,
-0x10,0x60,0x00,0x04,0xa2,0x02,0x00,0x17,0x96,0x02,0x00,0x06,0x08,0x00,0x1e,0xbe,
-0xa6,0x02,0x00,0x14,0x96,0x02,0x00,0x00,0x08,0x00,0x1e,0xbe,0xa6,0x02,0x00,0x14,
-0x96,0x05,0x00,0x00,0x0c,0x00,0x1e,0xea,0x02,0x00,0x20,0x21,0x08,0x00,0x1e,0xa5,
-0x02,0x22,0x88,0x21,0x94,0x85,0x00,0x06,0x0c,0x00,0x1e,0xea,0x00,0x00,0x00,0x00,
-0x08,0x00,0x1e,0xa1,0x00,0x40,0x88,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,
-0x34,0x63,0x00,0x20,0x24,0x42,0x7b,0xa8,0x27,0xbd,0xff,0xf0,0xac,0x62,0x00,0x00,
-0x00,0x00,0x10,0x21,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x10,0x3c,0x03,0xb0,0x03,
-0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x7b,0xcc,0xac,0x62,0x00,0x00,
-0x90,0x89,0x00,0x0a,0x00,0x80,0x30,0x21,0x11,0x20,0x00,0x05,0x00,0xa0,0x50,0x21,
-0x90,0x82,0x00,0x17,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x1b,0x00,0x00,0x00,0x00,
-0x90,0xc7,0x00,0x04,0x00,0x00,0x00,0x00,0x10,0xe0,0x00,0x1b,0x00,0x00,0x00,0x00,
-0x94,0xc8,0x00,0x00,0x27,0x83,0x90,0x00,0x93,0x85,0x8b,0x70,0x00,0x08,0x10,0xc0,
-0x00,0x48,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x08,
-0x00,0xe5,0x28,0x2b,0x10,0xa0,0x00,0x06,0x01,0x44,0x18,0x23,0x8f,0x82,0x8b,0x88,
-0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x2b,0x10,0x40,0x00,0x05,0x00,0x00,0x00,0x00,
-0x24,0x03,0x00,0x10,0xa4,0xc8,0x00,0x14,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,
-0x11,0x20,0x00,0x05,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x06,0x24,0x03,0x00,0x08,
-0x08,0x00,0x1f,0x16,0xa4,0xc2,0x00,0x14,0x08,0x00,0x1f,0x16,0x00,0x00,0x18,0x21,
-0x27,0xbd,0xff,0xc8,0xaf,0xb5,0x00,0x2c,0xaf,0xb4,0x00,0x28,0xaf,0xb3,0x00,0x24,
-0xaf,0xb0,0x00,0x18,0xaf,0xbf,0x00,0x30,0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c,
-0x94,0x91,0x00,0x06,0x00,0x80,0xa0,0x21,0x3c,0x02,0x80,0x00,0x3c,0x04,0xb0,0x03,
-0x00,0x11,0xa8,0xc0,0x34,0x84,0x00,0x20,0x24,0x42,0x7c,0x80,0x02,0xb1,0x48,0x21,
-0xac,0x82,0x00,0x00,0x00,0x09,0x48,0x80,0x24,0x03,0x00,0x01,0x27,0x82,0x90,0x10,
-0xa2,0x83,0x00,0x12,0x01,0x22,0x10,0x21,0x27,0x84,0x90,0x04,0x01,0x24,0x20,0x21,
-0x80,0x48,0x00,0x06,0x8c,0x8a,0x00,0x18,0x27,0x83,0x90,0x20,0x01,0x23,0x48,0x21,
-0x8d,0x24,0x00,0x00,0x25,0x08,0x00,0x02,0x8d,0x42,0x00,0x00,0x8d,0x49,0x00,0x04,
-0x00,0x08,0x17,0xc2,0x8d,0x43,0x00,0x08,0x01,0x02,0x40,0x21,0x00,0x04,0x25,0xc2,
-0x00,0x08,0x40,0x43,0x30,0x84,0x00,0x01,0x00,0x03,0x1f,0xc2,0x00,0x08,0x40,0x40,
-0x00,0xe0,0x80,0x21,0x00,0x64,0x18,0x24,0x00,0x09,0x49,0x42,0x01,0x48,0x10,0x21,
-0x00,0xa0,0x98,0x21,0x00,0xa0,0x20,0x21,0x00,0x40,0x38,0x21,0x02,0x00,0x28,0x21,
-0x14,0x60,0x00,0x19,0x31,0x29,0x00,0x01,0x94,0x42,0x00,0x00,0x02,0xb1,0x88,0x21,
-0x02,0x00,0x28,0x21,0x00,0x11,0x88,0x80,0x27,0x90,0x90,0x00,0x02,0x30,0x80,0x21,
-0x96,0x03,0x00,0x06,0x30,0x52,0xff,0xff,0x02,0x60,0x20,0x21,0x00,0x60,0x30,0x21,
-0xa6,0x83,0x00,0x1a,0x27,0x82,0x90,0x08,0x0c,0x00,0x08,0xe3,0x02,0x22,0x88,0x21,
-0x00,0x52,0x10,0x21,0x96,0x03,0x00,0x06,0xa6,0x22,0x00,0x04,0x8f,0xbf,0x00,0x30,
-0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x00,0x60,0x10,0x21,
-0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0xaf,0xa9,0x00,0x10,0x0c,0x00,0x09,0x0a,
-0xaf,0xa0,0x00,0x14,0x08,0x00,0x1f,0x54,0x02,0xb1,0x88,0x21,0x27,0xbd,0xff,0xc0,
-0xaf,0xbe,0x00,0x38,0xaf,0xb7,0x00,0x34,0xaf,0xb6,0x00,0x30,0xaf,0xb5,0x00,0x2c,
-0xaf,0xb3,0x00,0x24,0xaf,0xb1,0x00,0x1c,0xaf,0xbf,0x00,0x3c,0xaf,0xb4,0x00,0x28,
-0xaf,0xb2,0x00,0x20,0xaf,0xb0,0x00,0x18,0x94,0x90,0x00,0x00,0x3c,0x08,0xb0,0x03,
-0x35,0x08,0x00,0x20,0x00,0x10,0x10,0xc0,0x00,0x50,0x18,0x21,0x00,0x40,0x88,0x21,
-0x3c,0x02,0x80,0x00,0x00,0x03,0x48,0x80,0x24,0x42,0x7d,0xbc,0x00,0x80,0x98,0x21,
-0x27,0x84,0x90,0x10,0x01,0x24,0x20,0x21,0x93,0xb7,0x00,0x53,0xad,0x02,0x00,0x00,
-0x80,0x83,0x00,0x06,0x27,0x82,0x90,0x04,0x01,0x22,0x10,0x21,0x8c,0x44,0x00,0x18,
-0x24,0x63,0x00,0x02,0x00,0x03,0x17,0xc2,0x8c,0x88,0x00,0x08,0x00,0x62,0x18,0x21,
-0x00,0x03,0x18,0x43,0x00,0x03,0x18,0x40,0xaf,0xa7,0x00,0x4c,0x2c,0xa2,0x00,0x10,
-0x00,0xa0,0xa8,0x21,0x00,0x83,0x50,0x21,0x00,0x08,0x47,0xc2,0x00,0xc0,0x58,0x21,
-0x00,0x00,0xb0,0x21,0x8c,0x92,0x00,0x0c,0x14,0x40,0x00,0x13,0x00,0x00,0xf0,0x21,
-0x92,0x67,0x00,0x04,0x24,0x14,0x00,0x01,0x12,0x87,0x00,0x10,0x02,0x30,0x10,0x21,
-0x27,0x83,0x90,0x18,0x01,0x23,0x18,0x21,0x80,0x64,0x00,0x00,0x27,0x83,0xb5,0x70,
-0x00,0x04,0x11,0x00,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23,
-0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x04,0x00,0x00,0x00,0x00,
-0x10,0x80,0x00,0x23,0x00,0x00,0x00,0x00,0x02,0x30,0x10,0x21,0x00,0x02,0x80,0x80,
-0x24,0x04,0x00,0x01,0x27,0x83,0x90,0x20,0xa2,0x64,0x00,0x12,0x02,0x03,0x18,0x21,
-0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x15,0xc2,0x30,0x42,0x00,0x01,
-0x01,0x02,0x10,0x24,0x14,0x40,0x00,0x0e,0x02,0xa0,0x20,0x21,0x27,0x82,0x90,0x00,
-0x02,0x02,0x10,0x21,0x94,0x43,0x00,0x06,0x00,0x00,0x00,0x00,0xa6,0x63,0x00,0x1a,
-0x94,0x42,0x00,0x06,0x7b,0xbe,0x01,0xfc,0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c,
-0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,
-0x8f,0xa5,0x00,0x4c,0x01,0x60,0x30,0x21,0x01,0x40,0x38,0x21,0xaf,0xa0,0x00,0x10,
-0x0c,0x00,0x09,0x0a,0xaf,0xa0,0x00,0x14,0x08,0x00,0x1f,0xbb,0x00,0x00,0x00,0x00,
-0x27,0x83,0x90,0x20,0x01,0x23,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x02,0x15,0xc2,0x30,0x42,0x00,0x01,0x01,0x02,0x10,0x24,0x14,0x40,0x00,0xaf,
-0x00,0xa0,0x20,0x21,0x32,0x4f,0x00,0x03,0x00,0x12,0x10,0x82,0x25,0xe3,0x00,0x0d,
-0x30,0x45,0x00,0x07,0x00,0x74,0x78,0x04,0x10,0xa0,0x00,0x0e,0x00,0x00,0x90,0x21,
-0x27,0x82,0x80,0x1c,0x00,0x15,0x18,0x40,0x00,0x62,0x18,0x21,0x94,0x64,0x00,0x00,
-0x24,0xa2,0x00,0x06,0x00,0x54,0x10,0x04,0x00,0x44,0x00,0x1a,0x14,0x80,0x00,0x02,
-0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d,0x00,0x00,0x10,0x12,0x24,0x42,0x00,0x20,
-0x30,0x52,0xff,0xfc,0x02,0x30,0x10,0x21,0x27,0x83,0x90,0x10,0x00,0x02,0x10,0x80,
-0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x03,0x00,0x00,0x00,0x00,0x30,0x83,0x00,0xff,
-0x2c,0x62,0x00,0x0c,0x14,0x40,0x00,0x04,0x2c,0x62,0x00,0x19,0x30,0x82,0x00,0x0f,
-0x24,0x43,0x00,0x0c,0x2c,0x62,0x00,0x19,0x10,0x40,0x00,0x19,0x24,0x0e,0x00,0x20,
-0x24,0x62,0xff,0xe9,0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0x15,0x24,0x0e,0x00,0x10,
-0x24,0x62,0xff,0xeb,0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0x11,0x24,0x0e,0x00,0x08,
-0x24,0x02,0x00,0x14,0x10,0x62,0x00,0x0e,0x24,0x0e,0x00,0x02,0x24,0x62,0xff,0xef,
-0x2c,0x42,0x00,0x03,0x14,0x40,0x00,0x0a,0x24,0x0e,0x00,0x10,0x24,0x62,0xff,0xf1,
-0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0x06,0x24,0x0e,0x00,0x08,0x24,0x62,0xff,0xf3,
-0x2c,0x42,0x00,0x02,0x24,0x0e,0x00,0x04,0x24,0x03,0x00,0x02,0x00,0x62,0x70,0x0a,
-0x30,0xe2,0x00,0xff,0x00,0x00,0x48,0x21,0x00,0x00,0x68,0x21,0x10,0x40,0x00,0x6d,
-0x00,0x00,0x58,0x21,0x3c,0x14,0x80,0xff,0x27,0x99,0x90,0x00,0x01,0xf2,0xc0,0x23,
-0x36,0x94,0xff,0xff,0x01,0xc9,0x10,0x2a,0x14,0x40,0x00,0x64,0x24,0x03,0x00,0x04,
-0x00,0x10,0x28,0xc0,0x00,0xb0,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x59,0x10,0x21,
-0x94,0x56,0x00,0x06,0x00,0x00,0x00,0x00,0x32,0xcc,0x00,0x03,0x00,0x6c,0x10,0x23,
-0x30,0x42,0x00,0x03,0x02,0xc2,0x10,0x21,0x24,0x42,0x00,0x04,0x30,0x51,0xff,0xff,
-0x02,0x32,0x18,0x2b,0x10,0x60,0x00,0x4d,0x01,0xf1,0x10,0x23,0x02,0x51,0x10,0x23,
-0x01,0x78,0x18,0x2b,0x10,0x60,0x00,0x34,0x30,0x44,0xff,0xff,0x29,0x22,0x00,0x40,
-0x10,0x40,0x00,0x31,0x01,0x72,0x18,0x21,0x25,0x22,0x00,0x01,0x00,0x02,0x16,0x00,
-0x00,0x02,0x4e,0x03,0x00,0xb0,0x10,0x21,0x00,0x02,0x30,0x80,0x27,0x82,0x90,0x04,
-0x30,0x6b,0xff,0xff,0x00,0xc2,0x18,0x21,0x8c,0x67,0x00,0x18,0x00,0x04,0x25,0x40,
-0x3c,0x03,0x7f,0x00,0x8c,0xe2,0x00,0x04,0x00,0x83,0x20,0x24,0x27,0x83,0x90,0x10,
-0x00,0x54,0x10,0x24,0x00,0xc3,0x28,0x21,0x00,0x44,0x10,0x25,0xac,0xe2,0x00,0x04,
-0x16,0xe0,0x00,0x02,0xa0,0xb5,0x00,0x00,0xa0,0xb5,0x00,0x03,0x27,0x84,0x90,0x20,
-0x00,0xc4,0x18,0x21,0x8c,0x62,0x00,0x00,0x8c,0xe8,0x00,0x08,0x00,0x02,0x15,0xc2,
-0x00,0x08,0x47,0xc2,0x30,0x42,0x00,0x01,0x01,0x02,0x10,0x24,0x10,0x40,0x00,0x0a,
-0x00,0x00,0x00,0x00,0x80,0xa2,0x00,0x06,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02,
-0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40,
-0x00,0xe2,0x50,0x21,0xa5,0x5e,0x00,0x00,0x92,0x62,0x00,0x04,0x25,0xad,0x00,0x01,
-0x27,0x84,0x90,0x00,0x00,0xc4,0x18,0x21,0x01,0xa2,0x10,0x2a,0x94,0x70,0x00,0x02,
-0x14,0x40,0xff,0xb8,0x00,0x00,0x00,0x00,0x96,0x63,0x00,0x14,0x00,0x0c,0x10,0x23,
-0xa2,0x69,0x00,0x12,0x30,0x42,0x00,0x03,0x01,0x62,0x10,0x23,0x00,0x03,0x80,0xc0,
-0x8f,0xa5,0x00,0x4c,0x30,0x4b,0xff,0xff,0x02,0x03,0x80,0x21,0x27,0x82,0x90,0x08,
-0x00,0x10,0x80,0x80,0xa6,0x6b,0x00,0x1a,0x02,0xa0,0x20,0x21,0x01,0x60,0x30,0x21,
-0x01,0x60,0x88,0x21,0x0c,0x00,0x08,0xe3,0x02,0x02,0x80,0x21,0x00,0x5e,0x10,0x21,
-0xa6,0x02,0x00,0x04,0x08,0x00,0x1f,0xc1,0x02,0x20,0x10,0x21,0x01,0x62,0x10,0x2b,
-0x10,0x40,0xff,0xe9,0x00,0x00,0x20,0x21,0x29,0x22,0x00,0x40,0x10,0x40,0xff,0xe6,
-0x01,0x71,0x18,0x21,0x08,0x00,0x20,0x37,0x25,0x22,0x00,0x01,0x08,0x00,0x20,0x66,
-0x32,0xcc,0x00,0x03,0x08,0x00,0x20,0x66,0x00,0x00,0x60,0x21,0x8f,0xa5,0x00,0x4c,
-0x01,0x40,0x38,0x21,0xaf,0xa0,0x00,0x10,0x0c,0x00,0x09,0x0a,0xaf,0xb4,0x00,0x14,
-0x92,0x67,0x00,0x04,0x08,0x00,0x1f,0xd9,0x30,0x5e,0xff,0xff,0x30,0x84,0xff,0xff,
-0x00,0x04,0x30,0xc0,0x00,0xc4,0x20,0x21,0x00,0x04,0x20,0x80,0x27,0x82,0x90,0x00,
-0x3c,0x03,0xb0,0x08,0x30,0xa5,0xff,0xff,0x00,0x82,0x20,0x21,0x00,0xc3,0x30,0x21,
-0xac,0xc5,0x00,0x00,0x03,0xe0,0x00,0x08,0xa4,0x85,0x00,0x00,0x30,0x84,0xff,0xff,
-0x00,0x04,0x30,0xc0,0x00,0xc4,0x30,0x21,0x27,0x88,0x90,0x00,0x00,0x06,0x30,0x80,
-0x00,0xc8,0x30,0x21,0x94,0xc3,0x00,0x04,0x3c,0x02,0xb0,0x08,0x3c,0x07,0xb0,0x03,
-0x00,0x03,0x20,0xc0,0x00,0x83,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x82,0x20,0x21,
-0x3c,0x02,0x80,0x01,0x30,0xa5,0xff,0xff,0x00,0x68,0x18,0x21,0x34,0xe7,0x00,0x20,
-0x24,0x42,0x82,0x6c,0xac,0xe2,0x00,0x00,0xa4,0xc5,0x00,0x02,0xa4,0x65,0x00,0x00,
-0x03,0xe0,0x00,0x08,0xac,0x85,0x00,0x00,0x30,0x84,0xff,0xff,0x00,0x04,0x10,0xc0,
-0x00,0x44,0x10,0x21,0x27,0x89,0x90,0x00,0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x21,
-0x97,0x83,0x8f,0xf0,0x94,0x4a,0x00,0x04,0x3c,0x02,0xb0,0x08,0x00,0x03,0x38,0xc0,
-0x00,0x0a,0x40,0xc0,0x00,0xe3,0x18,0x21,0x01,0x0a,0x28,0x21,0x00,0xe2,0x38,0x21,
-0x01,0x02,0x40,0x21,0x00,0x03,0x18,0x80,0x00,0x05,0x28,0x80,0x3c,0x06,0xb0,0x03,
-0x3c,0x02,0x80,0x01,0x00,0xa9,0x28,0x21,0x00,0x69,0x18,0x21,0x34,0xc6,0x00,0x20,
-0x34,0x09,0xff,0xff,0x24,0x42,0x82,0xc8,0xac,0xc2,0x00,0x00,0xa4,0x64,0x00,0x00,
-0xac,0xe4,0x00,0x00,0xa4,0xa9,0x00,0x00,0xad,0x09,0x00,0x00,0xa7,0x8a,0x8f,0xf0,
-0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,
-0x34,0x63,0x00,0x20,0x24,0x42,0x83,0x48,0x3c,0x04,0xb0,0x03,0xac,0x62,0x00,0x00,
-0x34,0x84,0x01,0x10,0x8c,0x82,0x00,0x00,0x97,0x83,0x81,0x60,0x30,0x42,0xff,0xff,
-0x10,0x62,0x00,0x16,0x24,0x0a,0x00,0x01,0xa7,0x82,0x81,0x60,0xaf,0x80,0xb4,0x50,
-0x00,0x40,0x28,0x21,0x24,0x06,0x00,0x01,0x27,0x84,0xb4,0x54,0x25,0x43,0xff,0xff,
-0x00,0x66,0x10,0x04,0x00,0xa2,0x10,0x24,0x14,0x40,0x00,0x07,0x00,0x00,0x00,0x00,
-0x8c,0x83,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x66,0x10,0x04,0x00,0xa2,0x10,0x24,
-0x38,0x42,0x00,0x00,0x01,0x42,0x18,0x0a,0x25,0x4a,0x00,0x01,0x2d,0x42,0x00,0x14,
-0xac,0x83,0x00,0x00,0x14,0x40,0xff,0xf1,0x24,0x84,0x00,0x04,0x3c,0x0b,0xb0,0x03,
-0x00,0x00,0x50,0x21,0x3c,0x0c,0x80,0x00,0x27,0x89,0xb4,0xa0,0x35,0x6b,0x01,0x20,
-0x8d,0x68,0x00,0x00,0x8d,0x23,0x00,0x04,0x01,0x0c,0x10,0x24,0x00,0x02,0x17,0xc2,
-0x11,0x03,0x00,0x37,0xa1,0x22,0x00,0xdc,0xa1,0x20,0x00,0xd5,0xa1,0x20,0x00,0xd6,
-0x01,0x20,0x30,0x21,0x00,0x00,0x38,0x21,0x00,0x00,0x28,0x21,0x01,0x20,0x20,0x21,
-0x00,0xa8,0x10,0x06,0x30,0x42,0x00,0x01,0x10,0xe0,0x00,0x10,0xa0,0x82,0x00,0x0a,
-0x90,0x82,0x00,0x07,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x31,0x24,0xa2,0xff,0xff,
-0xa0,0x82,0x00,0x08,0x90,0x82,0x00,0x0a,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x09,
-0x00,0x00,0x00,0x00,0x90,0x83,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0x40,
-0x00,0x43,0x10,0x21,0x00,0x46,0x10,0x21,0xa0,0x45,0x00,0x09,0x90,0x82,0x00,0x0a,
-0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x07,0x00,0x00,0x00,0x00,0x14,0xe0,0x00,0x04,
-0x00,0x00,0x00,0x00,0xa0,0xc5,0x00,0xd5,0x24,0x07,0x00,0x01,0xa0,0x85,0x00,0x08,
-0xa0,0xc5,0x00,0xd6,0x24,0xa5,0x00,0x01,0x2c,0xa2,0x00,0x1c,0x14,0x40,0xff,0xe0,
-0x24,0x84,0x00,0x03,0x90,0xc4,0x00,0xd5,0x00,0x00,0x28,0x21,0x00,0xa4,0x10,0x2b,
-0x10,0x40,0x00,0x0b,0x00,0x00,0x00,0x00,0x00,0xc0,0x18,0x21,0xa0,0x64,0x00,0x08,
-0x90,0xc2,0x00,0xd5,0x24,0xa5,0x00,0x01,0xa0,0x62,0x00,0x09,0x90,0xc4,0x00,0xd5,
-0x00,0x00,0x00,0x00,0x00,0xa4,0x10,0x2b,0x14,0x40,0xff,0xf8,0x24,0x63,0x00,0x03,
-0x25,0x4a,0x00,0x01,0x2d,0x42,0x00,0x08,0xad,0x28,0x00,0x04,0x25,0x6b,0x00,0x04,
-0x14,0x40,0xff,0xbf,0x25,0x29,0x00,0xec,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
-0x90,0x82,0x00,0x05,0x08,0x00,0x21,0x0d,0xa0,0x82,0x00,0x08,0x97,0x85,0x8b,0x7a,
-0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x63,0x00,0x20,
-0x24,0x42,0x84,0xfc,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x62,0x00,0x00,
-0x30,0x90,0x00,0xff,0x00,0x05,0x28,0x42,0x00,0x00,0x48,0x21,0x27,0x8f,0xb4,0xa4,
-0x00,0x00,0x50,0x21,0x00,0x00,0x58,0x21,0x27,0x98,0xb5,0x84,0x27,0x99,0xb5,0x80,
-0x27,0x8e,0xb5,0x7e,0x27,0x8c,0xb4,0xa8,0x27,0x8d,0xb5,0x00,0x27,0x88,0xb5,0x78,
-0x00,0x0a,0x18,0x80,0x01,0x6f,0x10,0x21,0xac,0x40,0x00,0x00,0xac,0x45,0x00,0x58,
-0x00,0x6e,0x20,0x21,0x00,0x78,0x10,0x21,0xa1,0x00,0xff,0xfc,0xad,0x00,0x00,0x00,
-0xa1,0x00,0x00,0x04,0xa1,0x00,0x00,0x05,0xad,0x00,0xff,0xf8,0x00,0x79,0x18,0x21,
-0x24,0x06,0x00,0x01,0x24,0xc6,0xff,0xff,0xa0,0x80,0x00,0x00,0xa4,0x60,0x00,0x00,
-0xac,0x40,0x00,0x00,0x24,0x63,0x00,0x02,0x24,0x42,0x00,0x04,0x04,0xc1,0xff,0xf9,
-0x24,0x84,0x00,0x01,0x00,0x0a,0x10,0x80,0x00,0x4d,0x20,0x21,0x00,0x00,0x30,0x21,
-0x00,0x4c,0x18,0x21,0x27,0x87,0x81,0x64,0x8c,0xe2,0x00,0x00,0x24,0xe7,0x00,0x04,
-0xac,0x82,0x00,0x00,0xa0,0x66,0x00,0x00,0xa0,0x66,0x00,0x01,0x24,0xc6,0x00,0x01,
-0x28,0xc2,0x00,0x1c,0xa0,0x60,0x00,0x02,0x24,0x84,0x00,0x04,0x14,0x40,0xff,0xf6,
-0x24,0x63,0x00,0x03,0x25,0x29,0x00,0x01,0x29,0x22,0x00,0x08,0x25,0x4a,0x00,0x3b,
-0x25,0x08,0x00,0xec,0x14,0x40,0xff,0xd6,0x25,0x6b,0x00,0xec,0xa7,0x80,0x81,0x60,
-0x00,0x00,0x48,0x21,0x27,0x83,0xb4,0x50,0xac,0x69,0x00,0x00,0x25,0x29,0x00,0x01,
-0x29,0x22,0x00,0x0c,0x14,0x40,0xff,0xfc,0x24,0x63,0x00,0x04,0x0c,0x00,0x20,0xd2,
-0x00,0x00,0x00,0x00,0x2e,0x04,0x00,0x14,0x27,0x83,0xb4,0xa0,0x24,0x09,0x00,0x07,
-0x10,0x80,0x00,0x0a,0x00,0x00,0x00,0x00,0x90,0x62,0x00,0xd5,0x25,0x29,0xff,0xff,
-0xa0,0x62,0x00,0x00,0x05,0x21,0xff,0xfa,0x24,0x63,0x00,0xec,0x8f,0xbf,0x00,0x14,
-0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x90,0x62,0x00,0xd6,
-0x08,0x00,0x21,0x90,0x25,0x29,0xff,0xff,0x30,0x84,0x00,0xff,0x00,0x04,0x11,0x00,
-0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,
-0x27,0x83,0xb4,0xa0,0x00,0x43,0x60,0x21,0x3c,0x04,0xb0,0x03,0x3c,0x02,0x80,0x01,
-0x34,0x84,0x00,0x20,0x24,0x42,0x86,0x68,0x30,0xc6,0x00,0xff,0x93,0xaa,0x00,0x13,
-0x30,0xa5,0x00,0xff,0x30,0xe7,0x00,0xff,0xac,0x82,0x00,0x00,0x10,0xc0,0x00,0xe8,
-0x25,0x8f,0x00,0xd0,0x91,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x42,0xff,0xfc,
-0x2c,0x43,0x00,0x18,0x10,0x60,0x00,0xc7,0x3c,0x03,0x80,0x01,0x00,0x02,0x10,0x80,
-0x24,0x63,0x02,0x90,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x30,0x14,0x40,0x00,0x1c,
-0x00,0x00,0x00,0x00,0x10,0xa0,0x00,0x17,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,
-0x10,0xa2,0x00,0x11,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x0c,
-0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x06,0x00,0x00,0x00,0x00,
-0x8d,0x82,0x00,0xd0,0x00,0x00,0x00,0x00,0x24,0x42,0xff,0xe0,0x03,0xe0,0x00,0x08,
-0xad,0x82,0x00,0xd0,0x8d,0x82,0x00,0xd0,0x08,0x00,0x21,0xcb,0x24,0x42,0xff,0xe8,
-0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x21,0xcb,
-0x24,0x42,0x00,0x01,0x8d,0x82,0x00,0xd0,0x08,0x00,0x21,0xcb,0x24,0x42,0x00,0x02,
-0x10,0xa0,0xff,0xf9,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x0a,
-0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xe9,0x00,0x00,0x00,0x00,
-0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0xe6,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,
-0x08,0x00,0x21,0xcb,0x24,0x42,0xff,0xd0,0x8d,0x82,0x00,0xd0,0x08,0x00,0x21,0xcb,
-0x24,0x42,0xff,0xfc,0x10,0xa0,0xff,0xeb,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,
-0x10,0xa2,0xff,0xe5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xe0,
-0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xdb,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,
-0x08,0x00,0x21,0xcb,0x24,0x42,0xff,0xf8,0x2d,0x42,0x00,0x19,0x14,0x40,0xff,0xc5,
-0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xdb,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,
-0x10,0xa2,0xff,0xd5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xd0,
-0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0xf1,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,
-0x08,0x00,0x21,0xcb,0x24,0x42,0xff,0xf0,0x2d,0x42,0x00,0x1b,0x10,0x40,0xff,0xf1,
-0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xcb,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,
-0x10,0xa2,0xff,0xc5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x14,0xa2,0xff,0xb5,
-0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x21,0xcb,0x24,0x42,0xff,0xf4,
-0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xe3,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xbd,
-0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xb5,0x24,0x02,0x00,0x02,
-0x10,0xa2,0xff,0xd6,0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xc6,0x24,0x02,0x00,0x03,
-0x2d,0x42,0x00,0x23,0x10,0x40,0xff,0xd7,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xae,
-0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xa9,0x24,0x02,0x00,0x02,
-0x14,0xa2,0xff,0xb7,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x03,0x00,0x00,0x00,0x00,
-0x2d,0x42,0x00,0x25,0x10,0x40,0xff,0xcb,0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xd8,
-0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x16,0x14,0x40,0x00,0x0e,0x00,0x00,0x00,0x00,
-0x10,0xa0,0xff,0xa0,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x9a,
-0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x95,0x24,0x02,0x00,0x03,
-0x14,0xa2,0xff,0xb6,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x21,0xcb,
-0x24,0x42,0xff,0xfa,0x10,0xa0,0xff,0x93,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,
-0x10,0xa2,0xff,0x8d,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x88,
-0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xf3,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x17,
-0x14,0x40,0xff,0xac,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x34,0x00,0x00,0x00,0x00,
-0x2d,0x42,0x00,0x19,0x10,0x40,0xff,0xe2,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0x81,
-0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x7b,0x00,0x00,0x00,0x00,
-0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x76,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x97,
-0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xc8,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x51,
-0x2d,0x42,0x00,0x1b,0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xde,0x00,0x00,0x00,0x00,
-0x10,0xa0,0xff,0x70,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x6a,
-0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x65,0x24,0x02,0x00,0x03,
-0x10,0xa2,0xff,0x96,0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xc8,0x00,0x00,0x00,0x00,
-0x2d,0x42,0x00,0x23,0x14,0x40,0xff,0xf2,0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xf9,
-0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xf7,0x2d,0x42,0x00,0x25,0x08,0x00,0x22,0x2d,
-0x2d,0x42,0x00,0x27,0x10,0xa0,0xff,0x5b,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,
-0x10,0xa2,0xff,0x55,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x50,
-0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0x71,0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xe6,
-0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x27,0x14,0x40,0xff,0xad,0x00,0x00,0x00,0x00,
-0x08,0x00,0x22,0x79,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x2a,0x14,0x40,0xff,0xd8,
-0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xe9,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x2c,
-0x14,0x40,0xff,0x78,0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xbd,0x00,0x00,0x00,0x00,
-0x91,0x86,0x00,0x00,0x91,0x83,0x00,0xd4,0x25,0x8d,0x00,0x5c,0x30,0xc4,0x00,0xff,
-0x00,0x04,0x10,0x40,0x00,0x44,0x10,0x21,0x00,0x04,0x48,0x80,0x01,0x82,0x58,0x21,
-0x01,0x89,0x40,0x21,0x25,0x78,0x00,0x08,0x10,0x60,0x00,0x37,0x25,0x0e,0x00,0x60,
-0x2c,0xa2,0x00,0x03,0x14,0x40,0x00,0x25,0x00,0x00,0x00,0x00,0x91,0x82,0x00,0xdd,
-0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x1e,0x00,0x00,0x00,0x00,0x27,0x87,0x81,0x64,
-0x01,0x27,0x10,0x21,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0xad,0x03,0x00,0x60,
-0x91,0x62,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x40,0x30,0x21,0xa1,0x82,0x00,0x00,
-0x30,0xc2,0x00,0xff,0x00,0x02,0x10,0x80,0x00,0x47,0x10,0x21,0x8c,0x43,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x03,0x18,0x42,0xad,0xa3,0x00,0x00,0x91,0x84,0x00,0x00,
-0x8d,0xc5,0x00,0x00,0x00,0x04,0x20,0x80,0x00,0x87,0x10,0x21,0x8c,0x43,0x00,0x00,
-0x00,0x05,0x28,0x40,0x00,0x8c,0x20,0x21,0x00,0x03,0x18,0x80,0x00,0xa3,0x10,0x2b,
-0x00,0x62,0x28,0x0a,0xac,0x85,0x00,0x60,0x03,0xe0,0x00,0x08,0xa1,0x80,0x00,0xd4,
-0x27,0x87,0x81,0x64,0x08,0x00,0x22,0xb0,0xa1,0x80,0x00,0xdd,0x27,0x82,0x81,0xd4,
-0x8d,0x83,0x00,0xd8,0x00,0x82,0x10,0x21,0x90,0x44,0x00,0x00,0x24,0x63,0x00,0x01,
-0x00,0x64,0x20,0x2b,0x14,0x80,0xff,0x02,0xad,0x83,0x00,0xd8,0x8d,0x02,0x00,0x60,
-0xa1,0x80,0x00,0xd4,0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,
-0x03,0xe0,0x00,0x08,0xad,0x82,0x00,0x5c,0x10,0xe0,0x00,0x1d,0x24,0x83,0xff,0xfc,
-0x2c,0x62,0x00,0x18,0x10,0x40,0x01,0x10,0x00,0x03,0x10,0x80,0x3c,0x03,0x80,0x01,
-0x24,0x63,0x02,0xf0,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x30,0x14,0x40,0x00,0x65,
-0x00,0x00,0x00,0x00,0x10,0xa0,0x00,0x60,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,
-0x10,0xa2,0x00,0x5a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x08,
-0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x51,0x00,0x00,0x00,0x00,
-0x8d,0x82,0x00,0xd0,0x00,0x00,0x00,0x00,0x24,0x42,0xff,0xe0,0xad,0x82,0x00,0xd0,
-0x8d,0xe3,0x00,0x00,0x8d,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21,
-0xad,0xa2,0x00,0x00,0xad,0xe0,0x00,0x00,0x8d,0xa3,0x00,0x00,0x8d,0xc4,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x83,0x10,0x2a,0x10,0x40,0x00,0x22,0x00,0x00,0x00,0x00,
-0x93,0x05,0x00,0x01,0x91,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x45,0x00,0x05,
-0x24,0x02,0x00,0x01,0xa1,0x85,0x00,0x00,0xa1,0x82,0x00,0xd4,0x03,0xe0,0x00,0x08,
-0xad,0x80,0x00,0xd8,0x91,0x82,0x00,0xdd,0x24,0x03,0x00,0x01,0x10,0x43,0x00,0x05,
-0x00,0x00,0x00,0x00,0xa1,0x83,0x00,0xd4,0xad,0x80,0x00,0xd8,0x03,0xe0,0x00,0x08,
-0xa1,0x83,0x00,0xdd,0x00,0x04,0x17,0xc2,0x00,0x82,0x10,0x21,0x00,0x02,0x10,0x43,
-0xad,0xa2,0x00,0x00,0x91,0x83,0x00,0x00,0x27,0x82,0x81,0x64,0x8d,0xc5,0x00,0x00,
-0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,0x8c,0x64,0x00,0x00,0x00,0x05,0x28,0x40,
-0x00,0x04,0x18,0x80,0x00,0xa3,0x10,0x2b,0x00,0x62,0x28,0x0a,0x08,0x00,0x22,0xc2,
-0xad,0xc5,0x00,0x00,0x97,0x82,0x8b,0x7c,0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x2a,
-0x10,0x40,0xfe,0xab,0x00,0x00,0x00,0x00,0x91,0x82,0x00,0xdd,0x00,0x00,0x00,0x00,
-0x14,0x40,0x00,0x15,0x00,0x00,0x00,0x00,0x91,0x83,0x00,0x00,0x27,0x82,0x81,0x64,
-0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x6c,0x18,0x21,
-0xac,0x64,0x00,0x60,0x93,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x10,0x80,
-0x01,0x82,0x10,0x21,0x24,0x4e,0x00,0x60,0xa1,0x85,0x00,0x00,0x8d,0xc2,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,
-0x03,0xe0,0x00,0x08,0xad,0xa2,0x00,0x00,0x08,0x00,0x23,0x37,0xa1,0x80,0x00,0xdd,
-0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0xf3,0x24,0x42,0xff,0xe8,0x8d,0x82,0x00,0xd0,
-0x08,0x00,0x22,0xf3,0x24,0x42,0x00,0x01,0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0xf3,
-0x24,0x42,0x00,0x02,0x10,0xa0,0xff,0xf9,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,
-0x10,0xa2,0x00,0x0a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xa0,
-0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x9d,0x00,0x00,0x00,0x00,
-0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0xf3,0x24,0x42,0xff,0xd0,0x8d,0x82,0x00,0xd0,
-0x08,0x00,0x22,0xf3,0x24,0x42,0xff,0xfc,0x10,0xa0,0xff,0xeb,0x00,0x00,0x00,0x00,
-0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xe5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,
-0x10,0xa2,0xff,0x93,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xdd,0x00,0x00,0x00,0x00,
-0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0xf3,0x24,0x42,0xff,0xf8,0x2d,0x42,0x00,0x19,
-0x14,0x40,0xff,0x7c,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xdb,0x00,0x00,0x00,0x00,
-0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xd5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,
-0x10,0xa2,0xff,0x83,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0xf1,0x00,0x00,0x00,0x00,
-0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0xf3,0x24,0x42,0xff,0xf0,0x2d,0x42,0x00,0x1b,
-0x10,0x40,0xff,0xf1,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xcb,0x00,0x00,0x00,0x00,
-0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xc5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,
-0x14,0xa2,0xff,0x6c,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0xf3,
-0x24,0x42,0xff,0xf4,0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xe3,0x00,0x00,0x00,0x00,
-0x10,0xa0,0xff,0xbd,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x68,
-0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xd6,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0xee,
-0x24,0x02,0x00,0x03,0x2d,0x42,0x00,0x23,0x10,0x40,0xff,0xd7,0x00,0x00,0x00,0x00,
-0x10,0xa0,0xff,0xae,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x5c,
-0x24,0x02,0x00,0x02,0x14,0xa2,0xff,0xb7,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0x74,
-0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x25,0x10,0x40,0xff,0xcb,0x00,0x00,0x00,0x00,
-0x08,0x00,0x23,0x49,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x16,0x14,0x40,0x00,0x0e,
-0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xa0,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,
-0x10,0xa2,0xff,0x9a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x48,
-0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xb6,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,
-0x08,0x00,0x22,0xf3,0x24,0x42,0xff,0xfa,0x10,0xa0,0xff,0x93,0x00,0x00,0x00,0x00,
-0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x8d,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,
-0x10,0xa2,0xff,0x3b,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0x64,0x00,0x00,0x00,0x00,
-0x2d,0x42,0x00,0x17,0x14,0x40,0xff,0xac,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0xa5,
-0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x19,0x10,0x40,0xff,0xe2,0x00,0x00,0x00,0x00,
-0x10,0xa0,0xff,0x81,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x7b,
-0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x29,0x24,0x02,0x00,0x03,
-0x10,0xa2,0xff,0x97,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0xf0,0x00,0x00,0x00,0x00,
-0x08,0x00,0x23,0xc2,0x2d,0x42,0x00,0x1b,0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xde,
-0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0x70,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,
-0x10,0xa2,0xff,0x6a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x18,
-0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x96,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0xf0,
-0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x23,0x14,0x40,0xff,0xf2,0x00,0x00,0x00,0x00,
-0x08,0x00,0x23,0x6a,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0x68,0x2d,0x42,0x00,0x25,
-0x08,0x00,0x23,0x9e,0x2d,0x42,0x00,0x27,0x10,0xa0,0xff,0x5b,0x00,0x00,0x00,0x00,
-0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x55,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,
-0x10,0xa2,0xff,0x03,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0x71,0x00,0x00,0x00,0x00,
-0x08,0x00,0x23,0x57,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x27,0x14,0x40,0xff,0xad,
-0x00,0x00,0x00,0x00,0x08,0x00,0x23,0xea,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x2a,
-0x14,0x40,0xff,0xd8,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0x5a,0x00,0x00,0x00,0x00,
-0x2d,0x42,0x00,0x2c,0x14,0x40,0xff,0x78,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0xe5,
-0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe8,0x3c,0x02,0xb0,0x03,0xaf,0xbf,0x00,0x14,
-0xaf,0xb0,0x00,0x10,0x34,0x42,0x01,0x18,0x3c,0x03,0xb0,0x03,0x8c,0x50,0x00,0x00,
-0x34,0x63,0x01,0x2c,0x90,0x62,0x00,0x00,0x32,0x05,0x00,0x01,0xa3,0x82,0x80,0x10,
-0x14,0xa0,0x00,0x14,0x30,0x44,0x00,0xff,0x32,0x02,0x01,0x00,0x14,0x40,0x00,0x09,
-0x00,0x00,0x00,0x00,0x32,0x02,0x08,0x00,0x10,0x40,0x00,0x02,0x24,0x02,0x00,0x01,
-0xa3,0x82,0xbc,0x18,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,
-0x27,0xbd,0x00,0x18,0x0c,0x00,0x05,0x37,0x00,0x00,0x00,0x00,0x26,0x02,0xff,0x00,
-0xa3,0x80,0xbc,0x18,0x3c,0x01,0xb0,0x03,0xac,0x22,0x01,0x18,0x08,0x00,0x24,0x16,
-0x32,0x02,0x08,0x00,0x0c,0x00,0x21,0x3f,0x00,0x00,0x00,0x00,0x26,0x02,0xff,0xff,
-0x3c,0x01,0xb0,0x03,0xac,0x22,0x01,0x18,0x08,0x00,0x24,0x13,0x32,0x02,0x01,0x00,
-0x27,0xbd,0xff,0xe0,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,0xaf,0xbf,0x00,0x18,
-0x8c,0x43,0x00,0x00,0x3c,0x02,0x00,0x40,0x24,0x07,0x0f,0xff,0x00,0x03,0x33,0x02,
-0x00,0x03,0x2d,0x02,0x00,0x03,0x43,0x02,0x30,0x69,0x0f,0xff,0x00,0x62,0x18,0x24,
-0x30,0xa5,0x00,0x03,0x30,0xc6,0x00,0xff,0x10,0x60,0x00,0x08,0x31,0x08,0x00,0xff,
-0x01,0x00,0x30,0x21,0x0c,0x00,0x24,0xdf,0xaf,0xa9,0x00,0x10,0x8f,0xbf,0x00,0x18,
-0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x0c,0x00,0x25,0x31,
-0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0xd4,0x08,0x00,0x24,0x3f,
-0xac,0x62,0x00,0x00,0x27,0xbd,0xff,0xc0,0x3c,0x02,0xb0,0x03,0xaf,0xbe,0x00,0x38,
-0xaf,0xb5,0x00,0x2c,0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,0xaf,0xbf,0x00,0x3c,
-0xaf,0xb7,0x00,0x34,0xaf,0xb6,0x00,0x30,0xaf,0xb4,0x00,0x28,0xaf,0xb3,0x00,0x24,
-0xaf,0xb2,0x00,0x20,0x34,0x42,0x00,0x3f,0x90,0x43,0x00,0x00,0x00,0x80,0x80,0x21,
-0x00,0x00,0xf0,0x21,0x00,0x00,0x88,0x21,0x10,0x60,0x00,0x76,0x00,0x00,0xa8,0x21,
-0x3c,0x01,0xb0,0x03,0xa0,0x20,0x00,0x3f,0x00,0x10,0x12,0x02,0x24,0x04,0x06,0x14,
-0x0c,0x00,0x06,0xd1,0x30,0x54,0x00,0x0f,0x24,0x04,0x06,0x14,0x0c,0x00,0x06,0xd1,
-0xaf,0xa2,0x00,0x10,0x3c,0x03,0x00,0xff,0x34,0x63,0xff,0xff,0x32,0x10,0x00,0x7f,
-0x00,0x43,0x10,0x24,0x00,0x10,0x86,0x00,0x02,0x02,0x80,0x25,0x02,0x00,0x28,0x21,
-0x24,0x04,0x06,0x14,0x3c,0x13,0xbf,0xff,0x0c,0x00,0x06,0xbf,0x3c,0x16,0xb0,0x03,
-0x00,0x00,0x90,0x21,0x3c,0x17,0x40,0x00,0x36,0x73,0xff,0xff,0x36,0xd6,0x00,0x3e,
-0x0c,0x00,0x06,0xd1,0x24,0x04,0x04,0x00,0x00,0x57,0x10,0x25,0x00,0x40,0x28,0x21,
-0x0c,0x00,0x06,0xbf,0x24,0x04,0x04,0x00,0x00,0x00,0x80,0x21,0x0c,0x00,0x25,0xf9,
-0x00,0x00,0x00,0x00,0x26,0x03,0x00,0x01,0x10,0x40,0x00,0x46,0x30,0x70,0x00,0xff,
-0x12,0x00,0xff,0xfa,0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xd1,0x24,0x04,0x04,0x00,
-0x00,0x53,0x10,0x24,0x00,0x40,0x28,0x21,0x0c,0x00,0x06,0xbf,0x24,0x04,0x04,0x00,
-0x24,0x02,0x00,0x01,0x12,0x82,0x00,0x37,0x00,0x00,0x00,0x00,0x12,0x80,0x00,0x35,
-0x00,0x00,0x00,0x00,0x32,0x31,0x00,0x7f,0x12,0x20,0x00,0x04,0x24,0x03,0x00,0x04,
-0x27,0xc2,0x00,0x01,0x30,0x5e,0x00,0xff,0x02,0xb1,0xa8,0x21,0x12,0x43,0x00,0x2a,
-0x3c,0x03,0xb0,0x03,0x02,0x43,0x10,0x21,0xa0,0x51,0x00,0x34,0x26,0x42,0x00,0x01,
-0x30,0x52,0x00,0xff,0x2e,0x43,0x00,0x05,0x14,0x60,0xff,0xd9,0x00,0x00,0x00,0x00,
-0x8f,0xa5,0x00,0x10,0x0c,0x00,0x06,0xbf,0x24,0x04,0x06,0x14,0x12,0xa0,0x00,0x0e,
-0x3c,0x02,0xb0,0x03,0x13,0xc0,0x00,0x0d,0x34,0x42,0x00,0x3c,0x00,0x15,0x10,0x40,
-0x00,0x55,0x10,0x21,0x00,0x02,0x10,0xc0,0x00,0x55,0x10,0x21,0x00,0x02,0xa8,0x80,
-0x02,0xbe,0x00,0x1b,0x17,0xc0,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d,
-0x00,0x00,0xa8,0x12,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x3c,0x3c,0x03,0xb0,0x03,
-0x3c,0x04,0xb0,0x03,0xa4,0x55,0x00,0x00,0x34,0x63,0x00,0x1c,0x34,0x84,0x00,0x1d,
-0x24,0x02,0x00,0x01,0xa0,0x60,0x00,0x00,0xa0,0x82,0x00,0x00,0x7b,0xbe,0x01,0xfc,
-0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,
-0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,0xa2,0xd1,0x00,0x00,0x08,0x00,0x24,0x98,
-0x26,0x42,0x00,0x01,0x0c,0x00,0x06,0xd1,0x24,0x04,0x04,0xfc,0x08,0x00,0x24,0x8d,
-0x00,0x40,0x88,0x21,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x3c,0x3c,0x04,0xb0,0x03,
-0x3c,0x05,0xb0,0x03,0xa4,0x60,0x00,0x00,0x34,0x84,0x00,0x1c,0x34,0xa5,0x00,0x1d,
-0x24,0x02,0x00,0x02,0x24,0x03,0x00,0x01,0xa0,0x82,0x00,0x00,0x08,0x00,0x24,0xb7,
-0xa0,0xa3,0x00,0x00,0x0c,0x00,0x17,0x99,0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x8b,
-0x00,0x10,0x12,0x02,0x3c,0x02,0xb0,0x03,0x3c,0x04,0xb0,0x03,0x34,0x42,0x00,0x3c,
-0x34,0x84,0x00,0x14,0x24,0x03,0x00,0x01,0xa4,0x40,0x00,0x00,0x3c,0x01,0xb0,0x03,
-0xa0,0x23,0x00,0x3f,0x08,0x00,0x24,0xb7,0xac,0x90,0x00,0x00,0x27,0xbd,0xff,0xd8,
-0xaf,0xb0,0x00,0x10,0x30,0xd0,0x00,0xff,0x2e,0x02,0x00,0x2e,0xaf,0xb2,0x00,0x18,
-0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,0x30,0xb1,0x00,0xff,
-0x14,0x40,0x00,0x06,0x00,0x80,0x90,0x21,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,
-0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x2e,0x13,0x00,0x10,
-0x24,0x05,0x00,0x14,0x0c,0x00,0x13,0xa4,0x24,0x06,0x01,0x07,0x12,0x60,0x00,0x38,
-0x02,0x00,0x30,0x21,0x8f,0xa2,0x00,0x38,0x30,0xc3,0x00,0x3f,0x3c,0x04,0xb0,0x09,
-0x00,0x02,0x14,0x00,0x00,0x43,0x30,0x25,0x34,0x84,0x01,0x60,0x90,0x82,0x00,0x00,
-0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xfd,0x24,0x02,0x00,0x01,0x12,0x22,0x00,0x2a,
-0x2a,0x22,0x00,0x02,0x14,0x40,0x00,0x24,0x24,0x02,0x00,0x02,0x12,0x22,0x00,0x20,
-0x24,0x02,0x00,0x03,0x12,0x22,0x00,0x19,0x00,0x00,0x00,0x00,0x16,0x60,0xff,0xe2,
-0x24,0x02,0x00,0x01,0x12,0x22,0x00,0x13,0x2a,0x22,0x00,0x02,0x14,0x40,0x00,0x0d,
-0x24,0x02,0x00,0x02,0x12,0x22,0x00,0x09,0x24,0x02,0x00,0x03,0x16,0x22,0xff,0xda,
-0x00,0x00,0x00,0x00,0x24,0x04,0x08,0x4c,0x24,0x05,0xff,0xff,0x0c,0x00,0x13,0x5f,
-0x3c,0x06,0x0c,0xb8,0x08,0x00,0x24,0xea,0x00,0x00,0x00,0x00,0x08,0x00,0x25,0x12,
-0x24,0x04,0x08,0x48,0x16,0x20,0xff,0xd0,0x00,0x00,0x00,0x00,0x08,0x00,0x25,0x12,
-0x24,0x04,0x08,0x40,0x08,0x00,0x25,0x12,0x24,0x04,0x08,0x44,0x24,0x04,0x08,0x4c,
-0x0c,0x00,0x13,0x5f,0x24,0x05,0xff,0xff,0x08,0x00,0x25,0x07,0x00,0x00,0x00,0x00,
-0x08,0x00,0x25,0x20,0x24,0x04,0x08,0x48,0x16,0x20,0xff,0xe0,0x00,0x00,0x00,0x00,
-0x08,0x00,0x25,0x20,0x24,0x04,0x08,0x40,0x08,0x00,0x25,0x20,0x24,0x04,0x08,0x44,
-0x02,0x40,0x20,0x21,0x0c,0x00,0x25,0x71,0x02,0x20,0x28,0x21,0x08,0x00,0x24,0xf5,
-0x00,0x40,0x30,0x21,0x27,0xbd,0xff,0xd8,0x2c,0xc2,0x00,0x2e,0xaf,0xb2,0x00,0x18,
-0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,
-0x00,0xc0,0x80,0x21,0x30,0xb1,0x00,0xff,0x00,0x80,0x90,0x21,0x14,0x40,0x00,0x07,
-0x00,0x00,0x18,0x21,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,
-0x00,0x60,0x10,0x21,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x2e,0x13,0x00,0x10,
-0x24,0x05,0x00,0x14,0x0c,0x00,0x13,0xa4,0x24,0x06,0x01,0x07,0x12,0x60,0x00,0x24,
-0x02,0x00,0x30,0x21,0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60,0x90,0x62,0x00,0x00,
-0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xfd,0x30,0xc5,0x00,0x3f,0x0c,0x00,0x25,0xae,
-0x02,0x20,0x20,0x21,0x16,0x60,0x00,0x0a,0x00,0x40,0x80,0x21,0x24,0x02,0x00,0x01,
-0x12,0x22,0x00,0x15,0x2a,0x22,0x00,0x02,0x14,0x40,0x00,0x0f,0x24,0x02,0x00,0x02,
-0x12,0x22,0x00,0x0b,0x24,0x02,0x00,0x03,0x12,0x22,0x00,0x03,0x00,0x00,0x00,0x00,
-0x08,0x00,0x25,0x3d,0x02,0x00,0x18,0x21,0x24,0x04,0x08,0x4c,0x24,0x05,0xff,0xff,
-0x0c,0x00,0x13,0x5f,0x3c,0x06,0x0c,0xb8,0x08,0x00,0x25,0x3d,0x02,0x00,0x18,0x21,
-0x08,0x00,0x25,0x5f,0x24,0x04,0x08,0x48,0x16,0x20,0xff,0xf5,0x00,0x00,0x00,0x00,
-0x08,0x00,0x25,0x5f,0x24,0x04,0x08,0x40,0x08,0x00,0x25,0x5f,0x24,0x04,0x08,0x44,
-0x02,0x40,0x20,0x21,0x0c,0x00,0x25,0x71,0x02,0x20,0x28,0x21,0x08,0x00,0x25,0x49,
-0x00,0x40,0x30,0x21,0x27,0xbd,0xff,0xe8,0x2c,0xc2,0x00,0x1f,0xaf,0xb0,0x00,0x10,
-0xaf,0xbf,0x00,0x14,0x00,0xc0,0x80,0x21,0x14,0x40,0x00,0x1d,0x30,0xa5,0x00,0xff,
-0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x18,0x28,0xa2,0x00,0x02,0x14,0x40,0x00,0x12,
-0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x0e,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x07,
-0x24,0x04,0x08,0x4c,0x26,0x10,0xff,0xe2,0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x14,
-0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x24,0x05,0xff,0xff,
-0x0c,0x00,0x13,0x5f,0x3c,0x06,0x0d,0xf8,0x08,0x00,0x25,0x82,0x26,0x10,0xff,0xe2,
-0x08,0x00,0x25,0x87,0x24,0x04,0x08,0x48,0x14,0xa0,0xff,0xf2,0x24,0x04,0x08,0x40,
-0x08,0x00,0x25,0x88,0x24,0x05,0xff,0xff,0x08,0x00,0x25,0x87,0x24,0x04,0x08,0x44,
-0x2c,0xc2,0x00,0x10,0x14,0x40,0xff,0xec,0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x14,
-0x28,0xa2,0x00,0x02,0x14,0x40,0x00,0x0e,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x0a,
-0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x03,0x24,0x04,0x08,0x4c,0x08,0x00,0x25,0x82,
-0x26,0x10,0xff,0xf1,0x24,0x05,0xff,0xff,0x0c,0x00,0x13,0x5f,0x3c,0x06,0x0d,0xb8,
-0x08,0x00,0x25,0x82,0x26,0x10,0xff,0xf1,0x08,0x00,0x25,0xa1,0x24,0x04,0x08,0x48,
-0x14,0xa0,0xff,0xf6,0x24,0x04,0x08,0x40,0x08,0x00,0x25,0xa2,0x24,0x05,0xff,0xff,
-0x08,0x00,0x25,0xa1,0x24,0x04,0x08,0x44,0x27,0xbd,0xff,0xe8,0x30,0x84,0x00,0xff,
-0x24,0x02,0x00,0x01,0x10,0x82,0x00,0x39,0xaf,0xbf,0x00,0x10,0x28,0x82,0x00,0x02,
-0x14,0x40,0x00,0x27,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x17,
-0x00,0xa0,0x30,0x21,0x24,0x02,0x00,0x03,0x10,0x82,0x00,0x05,0x24,0x04,0x08,0x3c,
-0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,
-0x0c,0x00,0x13,0x5f,0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x3c,0x3c,0x05,0x80,0x00,
-0x0c,0x00,0x13,0x5f,0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x3c,0x3c,0x05,0x80,0x00,
-0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x01,0x24,0x04,0x08,0xac,0x0c,0x00,0x13,0x41,
-0x24,0x05,0x0f,0xff,0x08,0x00,0x25,0xbc,0x00,0x00,0x00,0x00,0x24,0x04,0x08,0x34,
-0x0c,0x00,0x13,0x5f,0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x34,0x3c,0x05,0x80,0x00,
-0x0c,0x00,0x13,0x5f,0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x34,0x3c,0x05,0x80,0x00,
-0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x01,0x08,0x00,0x25,0xcb,0x24,0x04,0x08,0xa8,
-0x14,0x80,0xff,0xdf,0x00,0xa0,0x30,0x21,0x24,0x04,0x08,0x24,0x0c,0x00,0x13,0x5f,
-0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x24,0x3c,0x05,0x80,0x00,0x0c,0x00,0x13,0x5f,
-0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x24,0x3c,0x05,0x80,0x00,0x0c,0x00,0x13,0x5f,
-0x24,0x06,0x00,0x01,0x08,0x00,0x25,0xcb,0x24,0x04,0x08,0xa0,0x00,0xa0,0x30,0x21,
-0x24,0x04,0x08,0x2c,0x0c,0x00,0x13,0x5f,0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x2c,
-0x3c,0x05,0x80,0x00,0x0c,0x00,0x13,0x5f,0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x2c,
-0x3c,0x05,0x80,0x00,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x01,0x08,0x00,0x25,0xcb,
-0x24,0x04,0x08,0xa4,0x3c,0x05,0x00,0x14,0x3c,0x02,0xb0,0x05,0x34,0x42,0x04,0x20,
-0x3c,0x06,0xc0,0x00,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0x34,0xa5,0x17,0x09,
-0xac,0x45,0x00,0x00,0x34,0xc6,0x05,0x07,0x34,0x63,0x04,0x24,0x34,0x84,0x02,0x28,
-0x3c,0x07,0xb0,0x05,0x24,0x02,0x00,0x20,0xac,0x66,0x00,0x00,0x34,0xe7,0x04,0x50,
-0xa0,0x82,0x00,0x00,0x90,0xe2,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x03,
-0x10,0x40,0xff,0xfc,0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
-0x93,0x85,0x81,0xf1,0x24,0x02,0x00,0x01,0x14,0xa2,0x00,0x53,0x00,0x80,0x40,0x21,
-0x8c,0x89,0x00,0x04,0x3c,0x02,0xb0,0x01,0x01,0x22,0x30,0x21,0x8c,0xc3,0x00,0x04,
-0x3c,0x02,0x01,0x00,0x00,0x62,0x10,0x24,0x10,0x40,0x00,0x4b,0x30,0x62,0x00,0x08,
-0x10,0x45,0x00,0x59,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x38,0x24,0x03,0x00,0xb4,
-0x30,0x44,0x00,0xff,0x10,0x83,0x00,0x61,0x24,0x02,0x00,0xc4,0x10,0x82,0x00,0x54,
-0x24,0x02,0x00,0x94,0x10,0x82,0x00,0x45,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x38,
-0x00,0x00,0x00,0x00,0x30,0x47,0xff,0xff,0x30,0xe3,0x40,0xff,0x24,0x02,0x40,0x88,
-0x14,0x62,0x00,0x39,0x30,0xe3,0x03,0x00,0x24,0x02,0x03,0x00,0x10,0x62,0x00,0x38,
-0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x56,0x00,0x00,0x00,0x00,0x30,0x47,0xff,0xff,
-0x30,0xe2,0x00,0x80,0x14,0x40,0x00,0x30,0x3c,0x02,0xb0,0x01,0x01,0x22,0x30,0x21,
-0x94,0xc3,0x00,0x60,0x24,0x02,0x00,0x08,0x14,0x43,0x00,0x3b,0x00,0x00,0x00,0x00,
-0x90,0xc2,0x00,0x62,0x24,0x03,0x00,0x04,0x00,0x02,0x39,0x02,0x10,0xe3,0x00,0x15,
-0x24,0x02,0x00,0x06,0x14,0xe2,0x00,0x34,0x00,0x00,0x00,0x00,0x8d,0x05,0x01,0xac,
-0x94,0xc4,0x00,0x66,0x27,0x82,0x89,0x68,0x00,0x05,0x28,0x80,0x30,0x87,0xff,0xff,
-0x00,0xa2,0x28,0x21,0x00,0x07,0x1a,0x00,0x8c,0xa4,0x00,0x00,0x00,0x07,0x12,0x02,
-0x00,0x43,0x10,0x25,0x24,0x42,0x00,0x5e,0x24,0x03,0xc0,0x00,0x30,0x47,0xff,0xff,
-0x00,0x83,0x20,0x24,0x00,0x87,0x20,0x25,0xac,0xa4,0x00,0x00,0x08,0x00,0x26,0x76,
-0xad,0x07,0x00,0x10,0x8d,0x05,0x01,0xac,0x94,0xc4,0x00,0x64,0x27,0x82,0x89,0x68,
-0x00,0x05,0x28,0x80,0x30,0x87,0xff,0xff,0x00,0xa2,0x28,0x21,0x00,0x07,0x1a,0x00,
-0x8c,0xa4,0x00,0x00,0x00,0x07,0x12,0x02,0x00,0x43,0x10,0x25,0x24,0x42,0x00,0x36,
-0x3c,0x03,0xff,0xff,0x30,0x47,0xff,0xff,0x00,0x83,0x20,0x24,0x00,0x87,0x20,0x25,
-0xac,0xa4,0x00,0x00,0xad,0x07,0x00,0x10,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
-0x94,0xc2,0x00,0x50,0x08,0x00,0x26,0x34,0x30,0x47,0xff,0xff,0x8d,0x04,0x01,0xac,
-0x27,0x83,0x89,0x68,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x00,
-0x3c,0x03,0xff,0xff,0x00,0x43,0x10,0x24,0x34,0x42,0x00,0x2e,0xac,0x82,0x00,0x00,
-0x24,0x03,0x00,0x2e,0xad,0x03,0x00,0x10,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
-0x8d,0x04,0x01,0xac,0x27,0x83,0x89,0x68,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,
-0x8c,0x82,0x00,0x00,0x3c,0x03,0xff,0xff,0x00,0x43,0x10,0x24,0x34,0x42,0x00,0x0e,
-0x24,0x03,0x00,0x0e,0x08,0x00,0x26,0x75,0xac,0x82,0x00,0x00,0x8d,0x04,0x01,0xac,
-0x27,0x83,0x89,0x68,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x00,
-0x3c,0x03,0xff,0xff,0x00,0x43,0x10,0x24,0x34,0x42,0x00,0x14,0x24,0x03,0x00,0x14,
-0x08,0x00,0x26,0x75,0xac,0x82,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
-0x30,0xc6,0x00,0xff,0x00,0x06,0x48,0x40,0x01,0x26,0x10,0x21,0x00,0x02,0x10,0x80,
-0x27,0x8b,0xbc,0x30,0x27,0x83,0xbc,0x36,0x00,0x4b,0x40,0x21,0x00,0x43,0x10,0x21,
-0x94,0x47,0x00,0x00,0x30,0xa2,0x3f,0xff,0x10,0xe2,0x00,0x29,0x30,0x8a,0xff,0xff,
-0x95,0x02,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x02,0x11,0x82,0x30,0x42,0x00,0x01,
-0x10,0x43,0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x26,0x10,0x21,0x00,0x02,0x10,0x80,
-0x00,0x4b,0x30,0x21,0x94,0xc4,0x00,0x02,0x27,0x83,0xbc,0x36,0x27,0x85,0xbc,0x34,
-0x00,0x45,0x28,0x21,0x30,0x84,0xff,0xdf,0x00,0x43,0x10,0x21,0xa4,0xc4,0x00,0x02,
-0xa4,0x40,0x00,0x00,0xa4,0xa0,0x00,0x00,0x94,0xc3,0x00,0x02,0x3c,0x04,0xb0,0x01,
-0x01,0x44,0x20,0x21,0x30,0x63,0xff,0xbf,0xa4,0xc3,0x00,0x02,0xa0,0xc0,0x00,0x00,
-0x8c,0x82,0x00,0x04,0x24,0x03,0xf0,0xff,0x00,0x43,0x10,0x24,0x03,0xe0,0x00,0x08,
-0xac,0x82,0x00,0x04,0x24,0x02,0xc0,0x00,0x91,0x04,0x00,0x01,0x00,0xa2,0x10,0x24,
-0x00,0x47,0x28,0x25,0x3c,0x03,0xb0,0x01,0x24,0x02,0x00,0x02,0x14,0x82,0xff,0xe2,
-0x01,0x43,0x18,0x21,0xac,0x65,0x00,0x00,0x08,0x00,0x26,0xa3,0x01,0x26,0x10,0x21,
-0x08,0x00,0x26,0xa3,0x01,0x26,0x10,0x21,0x93,0x83,0x81,0xf1,0x24,0x02,0x00,0x01,
-0x14,0x62,0x00,0x0d,0x3c,0x02,0xb0,0x01,0x8c,0x84,0x00,0x04,0x3c,0x06,0xb0,0x09,
-0x00,0x82,0x20,0x21,0x8c,0x85,0x00,0x08,0x8c,0x83,0x00,0x04,0x3c,0x02,0x01,0x00,
-0x34,0xc6,0x01,0x00,0x00,0x62,0x18,0x24,0x14,0x60,0x00,0x05,0x30,0xa5,0x20,0x00,
-0x24,0x02,0x00,0x06,0xa0,0xc2,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
-0x3c,0x03,0xb0,0x09,0x10,0xa0,0xff,0xfc,0x34,0x63,0x01,0x00,0x24,0x02,0x00,0x0e,
-0x08,0x00,0x26,0xd6,0xa0,0x62,0x00,0x00,0x3c,0x02,0xb0,0x01,0x30,0xa5,0xff,0xff,
-0x00,0xa2,0x28,0x21,0x8c,0xa3,0x00,0x00,0x3c,0x02,0x10,0x00,0x00,0x80,0x30,0x21,
-0x00,0x62,0x18,0x24,0x8c,0xa2,0x00,0x04,0x10,0x60,0x00,0x04,0x00,0x00,0x00,0x00,
-0x30,0x42,0x80,0x00,0x10,0x40,0x00,0x13,0x00,0x00,0x00,0x00,0x8c,0xc2,0x01,0xa8,
-0x00,0x00,0x00,0x00,0x24,0x44,0x00,0x01,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x40,
-0x00,0x83,0x10,0x0a,0x93,0x83,0x81,0xf0,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,
-0x00,0x82,0x20,0x23,0x24,0x63,0xff,0xff,0xac,0xc4,0x01,0xa8,0xa3,0x83,0x81,0xf0,
-0x8c,0xc4,0x01,0xac,0x8c,0xc2,0x01,0xa8,0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x26,
-0x00,0x02,0x10,0x2b,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,
-0x34,0x63,0x00,0x73,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,
-0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0xa3,0x80,0x81,0xf1,0x03,0xe0,0x00,0x08,
-0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0xa3,0x82,0x81,0xf1,0x03,0xe0,0x00,0x08,
-0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x04,0x3c,0x05,0xb0,0x01,0x00,0x80,0x50,0x21,
-0x00,0x45,0x10,0x21,0x8c,0x43,0x00,0x04,0x24,0x02,0x00,0x05,0x00,0x03,0x1a,0x02,
-0x30,0x69,0x00,0x0f,0x11,0x22,0x00,0x0b,0x24,0x02,0x00,0x07,0x11,0x22,0x00,0x09,
-0x24,0x02,0x00,0x0a,0x11,0x22,0x00,0x07,0x24,0x02,0x00,0x0b,0x11,0x22,0x00,0x05,
-0x24,0x02,0x00,0x01,0x93,0x83,0x81,0xf0,0x3c,0x04,0xb0,0x06,0x10,0x62,0x00,0x03,
-0x34,0x84,0x80,0x18,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x02,0x14,0x40,0xff,0xfa,0x00,0x00,0x00,0x00,
-0x8d,0x43,0x01,0xa8,0x27,0x82,0x89,0x68,0x00,0x03,0x18,0x80,0x00,0x6a,0x20,0x21,
-0x8c,0x87,0x00,0xa8,0x00,0x62,0x18,0x21,0x8c,0x68,0x00,0x00,0x00,0xe5,0x28,0x21,
-0x8c,0xa9,0x00,0x00,0x3c,0x02,0xff,0xff,0x27,0x83,0x8a,0x68,0x01,0x22,0x10,0x24,
-0x00,0x48,0x10,0x25,0xac,0xa2,0x00,0x00,0x8d,0x44,0x01,0xa8,0x00,0x07,0x30,0xc2,
-0x3c,0x02,0x00,0x80,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,0x00,0x06,0x32,0x00,
-0x8c,0xa9,0x00,0x04,0x00,0xc2,0x30,0x25,0x8c,0x82,0x00,0x00,0x3c,0x03,0x80,0x00,
-0x01,0x22,0x10,0x25,0x00,0x43,0x10,0x25,0xac,0xa2,0x00,0x04,0xaf,0x87,0xbc,0x20,
-0x8c,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0xaf,0x82,0xbc,0x28,0x8c,0xa3,0x00,0x04,
-0x3c,0x01,0xb0,0x07,0xac,0x26,0x80,0x18,0x8d,0x42,0x01,0xa8,0xaf,0x83,0xbc,0x24,
-0x93,0x85,0x81,0xf0,0x24,0x44,0x00,0x01,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x40,
-0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x24,0xa5,0xff,0xff,
-0x00,0x82,0x20,0x23,0xad,0x44,0x01,0xa8,0xa3,0x85,0x81,0xf0,0x08,0x00,0x27,0x21,
-0x00,0x00,0x00,0x00,0x3c,0x05,0xb0,0x03,0x3c,0x02,0x80,0x01,0x34,0xa5,0x00,0x20,
-0x24,0x42,0x9d,0x64,0xac,0xa2,0x00,0x00,0x24,0x02,0x00,0x02,0x24,0x03,0x00,0x20,
-0xac,0x82,0x00,0x64,0x3c,0x02,0x80,0x01,0xac,0x83,0x00,0x60,0xac,0x80,0x00,0x00,
-0xac,0x80,0x00,0x04,0xac,0x80,0x00,0x08,0xac,0x80,0x00,0x4c,0xac,0x80,0x00,0x50,
-0xac,0x80,0x00,0x54,0xac,0x80,0x00,0x0c,0xac,0x80,0x00,0x58,0xa0,0x80,0x00,0x5c,
-0x24,0x42,0x9e,0x28,0x24,0x83,0x00,0x68,0x24,0x05,0x00,0x0f,0x24,0xa5,0xff,0xff,
-0xac,0x62,0x00,0x00,0x04,0xa1,0xff,0xfd,0x24,0x63,0x00,0x04,0x3c,0x02,0x80,0x01,
-0x24,0x42,0x9f,0x10,0xac,0x82,0x00,0x78,0x3c,0x03,0x80,0x01,0x3c,0x02,0x80,0x01,
-0x24,0x63,0xa0,0x9c,0x24,0x42,0xa0,0x08,0xac,0x83,0x00,0x88,0xac,0x82,0x00,0x98,
-0x3c,0x03,0x80,0x01,0x3c,0x02,0x80,0x01,0x24,0x63,0xa1,0x44,0x24,0x42,0xa2,0x5c,
-0xac,0x83,0x00,0xa0,0xac,0x82,0x00,0xa4,0xa0,0x80,0x01,0xba,0xac,0x80,0x01,0xa8,
-0xac,0x80,0x01,0xac,0xac,0x80,0x01,0xb0,0xac,0x80,0x01,0xb4,0xa0,0x80,0x01,0xb8,
-0x03,0xe0,0x00,0x08,0xa0,0x80,0x01,0xb9,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,
-0x34,0x63,0x00,0x20,0x24,0x42,0x9e,0x28,0x03,0xe0,0x00,0x08,0xac,0x62,0x00,0x00,
-0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x34,0x42,0x00,0x20,0x24,0x63,0x9e,0x40,
-0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x11,
-0x00,0x80,0x28,0x21,0x8c,0x82,0x00,0x14,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0d,
-0x00,0x00,0x00,0x00,0x8c,0x84,0x00,0x10,0x8c,0xa3,0x00,0x14,0x8c,0xa2,0x00,0x04,
-0x00,0x83,0x20,0x21,0x00,0x44,0x10,0x21,0x30,0x43,0x00,0xff,0x00,0x03,0x18,0x2b,
-0x00,0x02,0x12,0x02,0x00,0x43,0x10,0x21,0x00,0x02,0x12,0x00,0x30,0x42,0x3f,0xff,
-0xac,0xa2,0x00,0x04,0xac,0xa0,0x00,0x00,0xac,0xa0,0x00,0x4c,0xac,0xa0,0x00,0x50,
-0xac,0xa0,0x00,0x54,0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x0c,0x3c,0x03,0xb0,0x03,
-0x3c,0x02,0x80,0x01,0x34,0x63,0x00,0x20,0x24,0x42,0x9e,0xbc,0xac,0x62,0x00,0x00,
-0x8c,0x86,0x00,0x04,0x3c,0x02,0xb0,0x01,0x24,0x03,0x00,0x01,0x00,0xc2,0x10,0x21,
-0x8c,0x45,0x00,0x00,0xac,0x83,0x00,0x4c,0x00,0x05,0x14,0x02,0x30,0xa3,0x3f,0xff,
-0x30,0x42,0x00,0xff,0xac,0x83,0x00,0x10,0xac,0x82,0x00,0x14,0x8c,0x83,0x00,0x14,
-0xac,0x85,0x00,0x40,0x00,0xc3,0x30,0x21,0x03,0xe0,0x00,0x08,0xac,0x86,0x00,0x08,
-0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,
-0x24,0x63,0x9f,0x10,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,
-0x8c,0x82,0x00,0x4c,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0a,0x00,0x80,0x80,0x21,
-0xae,0x00,0x00,0x00,0xae,0x00,0x00,0x4c,0xae,0x00,0x00,0x50,0xae,0x00,0x00,0x54,
-0xae,0x00,0x00,0x0c,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,
-0x27,0xbd,0x00,0x18,0x0c,0x00,0x27,0xaf,0x00,0x00,0x00,0x00,0x08,0x00,0x27,0xd1,
-0xae,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,
-0x34,0x42,0x00,0x20,0x24,0x63,0x9f,0x74,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,
-0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x4c,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x16,
-0x00,0x80,0x80,0x21,0x8e,0x03,0x00,0x08,0x3c,0x02,0xb0,0x01,0x8e,0x04,0x00,0x44,
-0x00,0x62,0x18,0x21,0x90,0x65,0x00,0x00,0x24,0x02,0x00,0x01,0xae,0x02,0x00,0x50,
-0x30,0xa3,0x00,0xff,0x00,0x03,0x10,0x82,0x00,0x04,0x23,0x02,0x30,0x84,0x00,0x0f,
-0x30,0x42,0x00,0x03,0x00,0x03,0x19,0x02,0xae,0x04,0x00,0x34,0xae,0x02,0x00,0x2c,
-0xae,0x03,0x00,0x30,0xa2,0x05,0x00,0x48,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,
-0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x27,0xaf,0x00,0x00,0x00,0x00,
-0x08,0x00,0x27,0xe9,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,
-0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xa0,0x08,0xaf,0xb0,0x00,0x10,
-0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x50,0x00,0x00,0x00,0x00,
-0x10,0x40,0x00,0x16,0x00,0x80,0x80,0x21,0x92,0x03,0x00,0x44,0x8e,0x02,0x00,0x40,
-0x83,0x85,0x8b,0xd4,0x92,0x04,0x00,0x41,0x30,0x63,0x00,0x01,0x00,0x02,0x16,0x02,
-0xae,0x04,0x00,0x14,0x00,0x00,0x30,0x21,0xae,0x02,0x00,0x18,0x10,0xa0,0x00,0x04,
-0xae,0x03,0x00,0x3c,0x10,0x60,0x00,0x03,0x24,0x02,0x00,0x01,0x24,0x06,0x00,0x01,
-0x24,0x02,0x00,0x01,0xa3,0x86,0x8b,0xd4,0x8f,0xbf,0x00,0x14,0xae,0x02,0x00,0x54,
-0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x27,0xdd,
-0x00,0x00,0x00,0x00,0x08,0x00,0x28,0x0e,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,
-0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xa0,0x9c,
-0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x50,
-0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x1b,0x00,0x80,0x80,0x21,0x3c,0x02,0xb0,0x03,
-0x8c,0x42,0x00,0x00,0x92,0x04,0x00,0x44,0x8e,0x03,0x00,0x40,0x83,0x86,0x8b,0xd4,
-0x92,0x05,0x00,0x41,0x30,0x42,0x08,0x00,0x30,0x84,0x00,0x01,0x00,0x02,0x12,0xc2,
-0x00,0x03,0x1e,0x02,0x00,0x82,0x20,0x25,0xae,0x05,0x00,0x14,0x00,0x00,0x38,0x21,
-0xae,0x03,0x00,0x18,0x10,0xc0,0x00,0x04,0xae,0x04,0x00,0x3c,0x10,0x80,0x00,0x03,
-0x24,0x02,0x00,0x01,0x24,0x07,0x00,0x01,0x24,0x02,0x00,0x01,0xa3,0x87,0x8b,0xd4,
-0x8f,0xbf,0x00,0x14,0xae,0x02,0x00,0x54,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,
-0x27,0xbd,0x00,0x18,0x0c,0x00,0x27,0xdd,0x00,0x00,0x00,0x00,0x08,0x00,0x28,0x33,
-0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,
-0x34,0x42,0x00,0x20,0x24,0x63,0xa1,0x44,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,
-0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x54,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x37,
-0x00,0x80,0x80,0x21,0x8e,0x04,0x00,0x04,0x8e,0x03,0x00,0x44,0x3c,0x02,0x80,0x00,
-0x3c,0x05,0xb0,0x01,0x34,0x42,0x00,0x10,0x00,0x85,0x20,0x21,0x00,0x62,0x18,0x25,
-0xac,0x83,0x00,0x04,0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac,0x02,0x00,0x20,0x21,
-0x00,0x45,0x10,0x21,0x8c,0x46,0x00,0x00,0x00,0x03,0x18,0x80,0x27,0x82,0x89,0x68,
-0x00,0x62,0x18,0x21,0xac,0x66,0x00,0x00,0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac,
-0x00,0x45,0x10,0x21,0x8c,0x46,0x00,0x04,0x00,0x03,0x18,0x80,0x27,0x82,0x8a,0x68,
-0x00,0x62,0x18,0x21,0x0c,0x00,0x26,0x10,0xac,0x66,0x00,0x00,0x8e,0x03,0x01,0xac,
-0x8e,0x07,0x00,0x04,0x3c,0x06,0xb0,0x03,0x24,0x65,0x00,0x01,0x28,0xa4,0x00,0x00,
-0x24,0x62,0x00,0x40,0x00,0xa4,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,
-0x00,0x03,0x18,0x80,0x00,0xa2,0x28,0x23,0x00,0x70,0x18,0x21,0xae,0x05,0x01,0xac,
-0xac,0x67,0x00,0xa8,0x34,0xc6,0x00,0x30,0x8c,0xc3,0x00,0x00,0x93,0x82,0x81,0xf0,
-0x02,0x00,0x20,0x21,0x24,0x63,0x00,0x01,0x24,0x42,0x00,0x01,0xac,0xc3,0x00,0x00,
-0xa3,0x82,0x81,0xf0,0x0c,0x00,0x27,0x90,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x14,
-0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x28,0x27,
-0x00,0x00,0x00,0x00,0x08,0x00,0x28,0x5d,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,
-0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xa2,0x5c,
-0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x54,
-0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x37,0x00,0x80,0x80,0x21,0x8e,0x04,0x00,0x04,
-0x8e,0x03,0x00,0x44,0x3c,0x02,0x80,0x00,0x3c,0x05,0xb0,0x01,0x34,0x42,0x00,0x10,
-0x00,0x85,0x20,0x21,0x00,0x62,0x18,0x25,0xac,0x83,0x00,0x04,0x8e,0x02,0x00,0x04,
-0x8e,0x03,0x01,0xac,0x02,0x00,0x20,0x21,0x00,0x45,0x10,0x21,0x8c,0x46,0x00,0x00,
-0x00,0x03,0x18,0x80,0x27,0x82,0x89,0x68,0x00,0x62,0x18,0x21,0xac,0x66,0x00,0x00,
-0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac,0x00,0x45,0x10,0x21,0x8c,0x46,0x00,0x04,
-0x00,0x03,0x18,0x80,0x27,0x82,0x8a,0x68,0x00,0x62,0x18,0x21,0x0c,0x00,0x26,0x10,
-0xac,0x66,0x00,0x00,0x8e,0x03,0x01,0xac,0x8e,0x07,0x00,0x04,0x3c,0x06,0xb0,0x03,
-0x24,0x65,0x00,0x01,0x28,0xa4,0x00,0x00,0x24,0x62,0x00,0x40,0x00,0xa4,0x10,0x0a,
-0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x00,0x03,0x18,0x80,0x00,0xa2,0x28,0x23,
-0x00,0x70,0x18,0x21,0xae,0x05,0x01,0xac,0xac,0x67,0x00,0xa8,0x34,0xc6,0x00,0x30,
-0x8c,0xc3,0x00,0x00,0x93,0x82,0x81,0xf0,0x02,0x00,0x20,0x21,0x24,0x63,0x00,0x01,
-0x24,0x42,0x00,0x01,0xac,0xc3,0x00,0x00,0xa3,0x82,0x81,0xf0,0x0c,0x00,0x27,0x90,
-0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,
-0x27,0xbd,0x00,0x18,0x0c,0x00,0x28,0x27,0x00,0x00,0x00,0x00,0x08,0x00,0x28,0xa3,
-0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x34,0x42,0x00,0x20,
-0x24,0x63,0xa3,0x74,0x27,0xbd,0xff,0xe0,0xac,0x43,0x00,0x00,0x3c,0x02,0x80,0x01,
-0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x1c,
-0x00,0x80,0x80,0x21,0x24,0x52,0x9e,0x28,0x00,0x00,0x88,0x21,0x3c,0x03,0xb0,0x09,
-0x34,0x63,0x00,0x06,0x8e,0x06,0x00,0x04,0x90,0x62,0x00,0x00,0x00,0x06,0x22,0x02,
-0x00,0x44,0x10,0x23,0x24,0x44,0x00,0x40,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x7f,
-0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x24,0x84,0xff,0xff,
-0x10,0x44,0x00,0x68,0x00,0x00,0x28,0x21,0x3c,0x02,0xb0,0x01,0x00,0xc2,0x10,0x21,
-0x8c,0x44,0x00,0x04,0x3c,0x03,0x7c,0x00,0x34,0x63,0x00,0xf0,0x00,0x83,0x18,0x24,
-0xae,0x04,0x00,0x44,0x8c,0x44,0x00,0x00,0x10,0x60,0x00,0x69,0x00,0x00,0x38,0x21,
-0x3c,0x09,0xb0,0x03,0x3c,0x06,0x7c,0x00,0x35,0x29,0x00,0x99,0x3c,0x0a,0xb0,0x01,
-0x24,0x08,0x00,0x40,0x34,0xc6,0x00,0xf0,0x3c,0x0b,0xff,0xff,0x3c,0x0c,0x28,0x38,
-0x16,0x20,0x00,0x06,0x24,0xa5,0x00,0x01,0x93,0x82,0x81,0xf6,0x24,0x11,0x00,0x01,
-0x24,0x42,0x00,0x01,0xa1,0x22,0x00,0x00,0xa3,0x82,0x81,0xf6,0x8e,0x02,0x00,0x04,
-0x24,0x07,0x00,0x01,0x24,0x42,0x01,0x00,0x30,0x42,0x3f,0xff,0xae,0x02,0x00,0x04,
-0x00,0x4a,0x10,0x21,0x8c,0x43,0x00,0x04,0x00,0x00,0x00,0x00,0xae,0x03,0x00,0x44,
-0x8c,0x44,0x00,0x00,0x10,0xa8,0x00,0x2d,0x00,0x66,0x18,0x24,0x14,0x60,0xff,0xec,
-0x00,0x8b,0x10,0x24,0x14,0x4c,0xff,0xea,0x24,0x02,0x00,0x01,0x10,0xe2,0x00,0x2f,
-0x3c,0x03,0xb0,0x09,0x8e,0x02,0x00,0x44,0x8e,0x04,0x00,0x60,0x00,0x02,0x1e,0x42,
-0x00,0x02,0x12,0x02,0x30,0x42,0x00,0x0f,0x30,0x63,0x00,0x01,0xae,0x02,0x00,0x00,
-0x10,0x44,0x00,0x1a,0xae,0x03,0x00,0x58,0x8e,0x02,0x00,0x64,0x8e,0x04,0x00,0x58,
-0x00,0x00,0x00,0x00,0x10,0x82,0x00,0x05,0x00,0x00,0x00,0x00,0xae,0x00,0x00,0x4c,
-0xae,0x00,0x00,0x50,0xae,0x00,0x00,0x54,0xae,0x00,0x00,0x0c,0x8e,0x03,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x03,0x10,0x80,0x00,0x50,0x10,0x21,0x8c,0x42,0x00,0x68,
-0x00,0x00,0x00,0x00,0x10,0x52,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x40,0xf8,0x09,
-0x02,0x00,0x20,0x21,0x8e,0x04,0x00,0x58,0x8e,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
-0xae,0x03,0x00,0x60,0x08,0x00,0x28,0xeb,0xae,0x04,0x00,0x64,0x8e,0x02,0x00,0x64,
-0x00,0x00,0x00,0x00,0x14,0x62,0xff,0xe5,0x00,0x00,0x00,0x00,0x7a,0x02,0x0d,0x7c,
-0x8f,0xbf,0x00,0x1c,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x00,0x43,0x10,0x26,
-0x00,0x02,0x10,0x2b,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x34,0x63,0x00,0x06,
-0x8e,0x04,0x00,0x04,0x90,0x62,0x00,0x00,0x00,0x04,0x22,0x02,0x00,0x44,0x10,0x23,
-0x24,0x44,0x00,0x40,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x7f,0x00,0x83,0x10,0x0a,
-0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x00,0x82,0x20,0x23,0x14,0x87,0xff,0xc5,
-0x00,0x00,0x00,0x00,0x8e,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x62,0x00,0x03,
-0x14,0x40,0x00,0x05,0x24,0x02,0x00,0x0d,0x10,0x62,0x00,0x03,0x24,0x02,0x00,0x01,
-0x08,0x00,0x29,0x4b,0xa2,0x02,0x00,0x5c,0x08,0x00,0x29,0x4b,0xa2,0x00,0x00,0x5c,
-0x3c,0x02,0xff,0xff,0x00,0x82,0x10,0x24,0x3c,0x03,0x28,0x38,0x14,0x43,0xff,0x94,
-0x24,0x02,0x00,0x01,0x08,0x00,0x29,0x23,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,
-0x3c,0x03,0x80,0x01,0x34,0x42,0x00,0x20,0x24,0x63,0xa5,0xcc,0xac,0x43,0x00,0x00,
-0x8c,0x83,0x01,0xa8,0x8c,0x82,0x01,0xac,0x00,0x80,0x40,0x21,0x10,0x62,0x00,0x20,
-0x00,0x00,0x20,0x21,0x93,0x82,0x81,0xf1,0x00,0x03,0x28,0x80,0x3c,0x07,0xb0,0x06,
-0x00,0xa8,0x18,0x21,0x24,0x04,0x00,0x01,0x8c,0x66,0x00,0xa8,0x10,0x44,0x00,0x1c,
-0x34,0xe7,0x80,0x18,0x3c,0x05,0xb0,0x01,0xaf,0x86,0xbc,0x20,0x00,0xc5,0x28,0x21,
-0x8c,0xa3,0x00,0x00,0x00,0x06,0x20,0xc2,0x3c,0x02,0x00,0x80,0x00,0x04,0x22,0x00,
-0x00,0x82,0x20,0x25,0xaf,0x83,0xbc,0x28,0x8c,0xa2,0x00,0x04,0xac,0xe4,0x00,0x00,
-0x8d,0x03,0x01,0xa8,0xaf,0x82,0xbc,0x24,0x24,0x64,0x00,0x01,0x04,0x80,0x00,0x0a,
-0x00,0x80,0x10,0x21,0x00,0x02,0x11,0x83,0x8d,0x03,0x01,0xac,0x00,0x02,0x11,0x80,
-0x00,0x82,0x10,0x23,0x00,0x43,0x18,0x26,0xad,0x02,0x01,0xa8,0x00,0x03,0x20,0x2b,
-0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x08,0x00,0x29,0x95,0x24,0x62,0x00,0x40,
-0x27,0x82,0x89,0x68,0x00,0x06,0x20,0xc2,0x00,0x04,0x22,0x00,0x00,0xa2,0x48,0x21,
-0x3c,0x02,0x00,0x80,0x00,0x82,0x58,0x25,0x93,0x82,0x81,0xf0,0x3c,0x0a,0xb0,0x06,
-0x3c,0x03,0xb0,0x01,0x2c,0x42,0x00,0x02,0x00,0xc3,0x38,0x21,0x35,0x4a,0x80,0x18,
-0x14,0x40,0xff,0xef,0x00,0x00,0x20,0x21,0x8c,0xe5,0x00,0x00,0x8d,0x23,0x00,0x00,
-0x24,0x02,0xc0,0x00,0x00,0xa2,0x10,0x24,0x00,0x43,0x10,0x25,0xac,0xe2,0x00,0x00,
-0x8d,0x04,0x01,0xa8,0x27,0x83,0x8a,0x68,0x8c,0xe5,0x00,0x04,0x00,0x04,0x20,0x80,
-0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x00,0x3c,0x03,0x80,0x00,0x00,0xa2,0x10,0x25,
-0x00,0x43,0x10,0x25,0xac,0xe2,0x00,0x04,0xaf,0x86,0xbc,0x20,0x8c,0xe2,0x00,0x00,
-0x93,0x85,0x81,0xf0,0xaf,0x82,0xbc,0x28,0x8c,0xe3,0x00,0x04,0xad,0x4b,0x00,0x00,
-0x8d,0x02,0x01,0xa8,0xaf,0x83,0xbc,0x24,0x24,0xa5,0xff,0xff,0x24,0x44,0x00,0x01,
-0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x40,0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83,
-0x00,0x02,0x11,0x80,0x00,0x82,0x20,0x23,0xad,0x04,0x01,0xa8,0xa3,0x85,0x81,0xf0,
-0x79,0x02,0x0d,0x7c,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x26,0x08,0x00,0x29,0x9c,
-0x00,0x02,0x20,0x2b,0x3c,0x04,0xb0,0x03,0x3c,0x06,0xb0,0x07,0x3c,0x02,0x80,0x01,
-0x34,0xc6,0x00,0x18,0x34,0x84,0x00,0x20,0x24,0x42,0xa7,0x54,0x24,0x03,0xff,0x83,
-0xac,0x82,0x00,0x00,0xa0,0xc3,0x00,0x00,0x90,0xc4,0x00,0x00,0x27,0xbd,0xff,0xf8,
-0x3c,0x03,0xb0,0x07,0x24,0x02,0xff,0x82,0xa3,0xa4,0x00,0x00,0xa0,0x62,0x00,0x00,
-0x90,0x64,0x00,0x00,0x3c,0x02,0xb0,0x07,0x34,0x42,0x00,0x08,0xa3,0xa4,0x00,0x01,
-0xa0,0x40,0x00,0x00,0x90,0x43,0x00,0x00,0x24,0x02,0x00,0x03,0x3c,0x05,0xb0,0x07,
-0xa3,0xa3,0x00,0x00,0xa0,0xc2,0x00,0x00,0x90,0xc4,0x00,0x00,0x34,0xa5,0x00,0x10,
-0x24,0x02,0x00,0x06,0x3c,0x03,0xb0,0x07,0xa3,0xa4,0x00,0x00,0x34,0x63,0x00,0x38,
-0xa0,0xa2,0x00,0x00,0x90,0x64,0x00,0x00,0x3c,0x02,0xb0,0x07,0x34,0x42,0x00,0x20,
-0xa3,0xa4,0x00,0x00,0xa0,0xa0,0x00,0x00,0x90,0xa3,0x00,0x00,0xaf,0x82,0xbf,0x30,
-0xa3,0xa3,0x00,0x00,0xa0,0x40,0x00,0x00,0x90,0x43,0x00,0x00,0x03,0xe0,0x00,0x08,
-0x27,0xbd,0x00,0x08,};
-
-u8 Rtl8192PciEFwDataArray[DataArrayLengthPciE] = {
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00,
-0x02,0xe9,0x01,0x74,0x02,0xab,0x01,0xc7,0x01,0x55,0x00,0xe4,0x00,0xab,0x00,0x72,
-0x00,0x55,0x00,0x4c,0x00,0x4c,0x00,0x4c,0x00,0x4c,0x00,0x4c,0x02,0x76,0x01,0x3b,
-0x00,0xd2,0x00,0x9e,0x00,0x69,0x00,0x4f,0x00,0x46,0x00,0x3f,0x01,0x3b,0x00,0x9e,
-0x00,0x69,0x00,0x4f,0x00,0x35,0x00,0x27,0x00,0x23,0x00,0x20,0x01,0x2f,0x00,0x98,
-0x00,0x65,0x00,0x4c,0x00,0x33,0x00,0x26,0x00,0x22,0x00,0x1e,0x00,0x98,0x00,0x4c,
-0x00,0x33,0x00,0x26,0x00,0x19,0x00,0x13,0x00,0x11,0x00,0x0f,0x02,0x39,0x01,0x1c,
-0x00,0xbd,0x00,0x8e,0x00,0x5f,0x00,0x47,0x00,0x3f,0x00,0x39,0x01,0x1c,0x00,0x8e,
-0x00,0x5f,0x00,0x47,0x00,0x2f,0x00,0x23,0x00,0x20,0x00,0x1c,0x01,0x11,0x00,0x89,
-0x00,0x5b,0x00,0x44,0x00,0x2e,0x00,0x22,0x00,0x1e,0x00,0x1b,0x00,0x89,0x00,0x44,
-0x00,0x2e,0x00,0x22,0x00,0x17,0x00,0x11,0x00,0x0f,0x00,0x0e,0x02,0xab,0x02,0xab,
-0x02,0x66,0x02,0x66,0x07,0x06,0x06,0x06,0x05,0x06,0x07,0x08,0x04,0x06,0x07,0x08,
-0x09,0x0a,0x0b,0x0b,0x49,0x6e,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0x4c,
-0x42,0x4d,0x4f,0x44,0x00,0x00,0x00,0x00,0x54,0x4c,0x42,0x4c,0x5f,0x64,0x61,0x74,
-0x61,0x00,0x54,0x4c,0x42,0x53,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x64,0x45,0x4c,
-0x5f,0x64,0x61,0x74,0x61,0x00,0x41,0x64,0x45,0x53,0x00,0x00,0x00,0x00,0x00,0x00,
-0x45,0x78,0x63,0x43,0x6f,0x64,0x65,0x36,0x00,0x00,0x45,0x78,0x63,0x43,0x6f,0x64,
-0x65,0x37,0x00,0x00,0x53,0x79,0x73,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x70,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x52,0x49,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x43,0x70,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4f,0x76,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x0b,0x63,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x2c,
-0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0x60,
-0x00,0x00,0x00,0x90,0x00,0x00,0x00,0xc0,0x00,0x00,0x01,0x20,0x00,0x00,0x01,0x80,
-0x00,0x00,0x01,0xb0,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0x9c,
-0x00,0x00,0x00,0xd0,0x00,0x00,0x01,0x38,0x00,0x00,0x01,0xa0,0x00,0x00,0x01,0xd4,
-0x00,0x00,0x02,0x08,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0xd0,0x00,0x00,0x01,0x38,
-0x00,0x00,0x01,0xa0,0x00,0x00,0x02,0x6f,0x00,0x00,0x03,0x40,0x00,0x00,0x03,0xa8,
-0x00,0x00,0x04,0x10,0x01,0x01,0x01,0x02,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,
-0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x02,0x03,0x03,0x04,0x05,0x06,0x07,0x08,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x07,0x6c,0x80,0x00,0x07,0x80,
-0x80,0x00,0x07,0x80,0x80,0x00,0x07,0x70,0x80,0x00,0x07,0x70,0x80,0x00,0x07,0x94,
-0x80,0x00,0x56,0xb0,0x80,0x00,0x57,0x08,0x80,0x00,0x57,0x30,0x80,0x00,0x58,0x28,
-0x80,0x00,0x58,0xe0,0x80,0x00,0x59,0x88,0x80,0x00,0x59,0xfc,0x80,0x00,0x5b,0x08,
-0x80,0x00,0x5b,0x40,0x80,0x00,0x5b,0x54,0x80,0x00,0x5b,0x68,0x80,0x00,0x5c,0x50,
-0x80,0x00,0x5c,0x90,0x80,0x00,0x5d,0x44,0x80,0x00,0x5d,0x6c,0x80,0x00,0x56,0x70,
-0x80,0x00,0x5d,0xbc,0x80,0x00,0x64,0x48,0x80,0x00,0x64,0xc0,0x80,0x00,0x64,0xcc,
-0x80,0x00,0x64,0xd8,0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60,
-0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60,
-0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60,
-0x80,0x00,0x64,0x60,0x80,0x00,0x64,0xe4,0x80,0x00,0x64,0xf0,0x80,0x00,0x64,0xfc,
-0x80,0x00,0x87,0xa4,0x80,0x00,0x87,0xa4,0x80,0x00,0x87,0xa4,0x80,0x00,0x87,0xd8,
-0x80,0x00,0x88,0x18,0x80,0x00,0x88,0x50,0x80,0x00,0x88,0x80,0x80,0x00,0x88,0xb0,
-0x80,0x00,0x88,0xc4,0x80,0x00,0x89,0x2c,0x80,0x00,0x89,0x40,0x80,0x00,0x89,0x7c,
-0x80,0x00,0x89,0x84,0x80,0x00,0x89,0xc0,0x80,0x00,0x89,0xd4,0x80,0x00,0x89,0xdc,
-0x80,0x00,0x89,0xe4,0x80,0x00,0x89,0xe4,0x80,0x00,0x89,0xe4,0x80,0x00,0x89,0xe4,
-0x80,0x00,0x8a,0x14,0x80,0x00,0x8a,0x28,0x80,0x00,0x8a,0x3c,0x80,0x00,0x86,0xe8,
-0x80,0x00,0x8d,0x68,0x80,0x00,0x8d,0x68,0x80,0x00,0x8d,0x68,0x80,0x00,0x8d,0x9c,
-0x80,0x00,0x8d,0xdc,0x80,0x00,0x8e,0x14,0x80,0x00,0x8e,0x44,0x80,0x00,0x8e,0x74,
-0x80,0x00,0x8e,0x88,0x80,0x00,0x8e,0xf0,0x80,0x00,0x8f,0x04,0x80,0x00,0x8f,0x40,
-0x80,0x00,0x8f,0x48,0x80,0x00,0x8f,0x84,0x80,0x00,0x8f,0x98,0x80,0x00,0x8f,0xa0,
-0x80,0x00,0x8f,0xa8,0x80,0x00,0x8f,0xa8,0x80,0x00,0x8f,0xa8,0x80,0x00,0x8f,0xa8,
-0x80,0x00,0x8f,0xd8,0x80,0x00,0x8f,0xec,0x80,0x00,0x90,0x00,0x80,0x00,0x8b,0x88,
-};
-
 u32 Rtl8192PciEPHY_REGArray[PHY_REGArrayLengthPciE] = {0x0,};
 
 u32 Rtl8192PciEPHY_REG_1T2RArray[PHY_REG_1T2RArrayLengthPciE] = {
index 5d6d304c9c01c70f4a5d7b5da88eab9cf3de05e5..b4bfafe5c4a1b48c7f4678b543d23a8fbbd61255 100644 (file)
@@ -1555,7 +1555,7 @@ static bool SetRFPowerState8190(struct net_device *dev,
 
                default:
                        bResult = false;
-                       RT_TRACE(COMP_ERR, "SetRFPowerState8190(): unknow state"
+                       RT_TRACE(COMP_ERR, "SetRFPowerState8190(): unknown state"
                                 " to set: 0x%X!!!\n", eRFPowerState);
                        break;
                }
index c01abc23213efd36255531bda0cef2f753514cfe..fa087b654ebc8df7982c36dc4b0767d056f356b4 100644 (file)
@@ -2926,8 +2926,7 @@ static int rtl8192_pci_probe(struct pci_dev *pdev,
 
        dev->netdev_ops = &rtl8192_netdev_ops;
 
-       dev->wireless_handlers = (struct iw_handler_def *)
-                                &r8192_wx_handlers_def;
+       dev->wireless_handlers = &r8192_wx_handlers_def;
        dev->ethtool_ops = &rtl819x_ethtool_ops;
 
        dev->type = ARPHRD_ETHER;
index 35fc1164effd17f38f2a42e068820cafa873961d..d1438c2f8980e35b92351c7e0126886d3718075c 100644 (file)
@@ -582,7 +582,6 @@ struct r8192_priv {
 
        struct rt_firmware                      *pFirmware;
        enum rtl819x_loopback LoopbackMode;
-       enum firmware_source firmware_source;
 
        struct timer_list                       watch_dog_timer;
        struct timer_list                       fsync_timer;
index 498995d833e7287013fb9a8a13c49376248ab4b8..de7609716435dbb760532d612d4747468235cb83 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/string.h>
 #include "rtl_core.h"
+#include "rtl_wx.h"
 
 #define RATE_COUNT 12
 static u32 rtl8192_rates[] = {
@@ -1213,7 +1214,7 @@ static iw_handler r8192_wx_handlers[] = {
 };
 
 /*
- * the following rule need to be follwing,
+ * the following rule need to be following,
  * Odd : get (world access),
  * even : set (root access)
  * */
@@ -1320,7 +1321,7 @@ static struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev)
        return wstats;
 }
 
-struct iw_handler_def  r8192_wx_handlers_def = {
+const struct iw_handler_def r8192_wx_handlers_def = {
        .standard = r8192_wx_handlers,
        .num_standard = ARRAY_SIZE(r8192_wx_handlers),
        .private = r8192_private_handler,
index 6a51a25ec87d6bac198cb3128bb7bafe34c3a7d9..58398517f5b397822109fd82ca4f91205952e040 100644 (file)
@@ -24,8 +24,7 @@ struct net_device;
 struct iw_handler_def;
 struct iw_statistics;
 
-extern struct iw_handler_def r8192_wx_handlers_def;
-struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev);
+extern const struct iw_handler_def r8192_wx_handlers_def;
 u16 rtl8192_11n_user_show_rates(struct net_device *dev);
 
 #endif
index adc6cc7ca3d6f2070dae8448a3d3b9f61c2a2d20..48a142b82d9048c635411f4f67b03f2f26a19963 100644 (file)
@@ -109,9 +109,9 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst,
        BAReq->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT);
 
        tag = (u8 *)skb_put(skb, 9);
-       *tag ++= ACT_CAT_BA;
-       *tag ++= type;
-       *tag ++= pBA->DialogToken;
+       *tag++ = ACT_CAT_BA;
+       *tag++ = type;
+       *tag++ = pBA->DialogToken;
 
        if (ACT_ADDBARSP == type) {
                RT_TRACE(COMP_DBG, "====>to send ADDBARSP\n");
@@ -175,8 +175,8 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst,
 
        tag = (u8 *)skb_put(skb, 6);
 
-       *tag ++= ACT_CAT_BA;
-       *tag ++= ACT_DELBA;
+       *tag++ = ACT_CAT_BA;
+       *tag++ = ACT_DELBA;
 
        tmp = DelbaParamSet.shortData;
        memcpy(tag, (u8 *)&tmp, 2);
@@ -230,8 +230,8 @@ static void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst,
        if (skb)
                softmac_mgmt_xmit(skb, ieee);
        else
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in func"
-                            "tion %s()\n", __func__);
+               RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function"
+                            " %s()\n", __func__);
        return ;
 }
 
index 29608e5488a44dd6c45346a76d169f9b2d4cddb1..52b297724fb1e40bd6e9ee07fe0be7e40c2914d8 100644 (file)
@@ -79,7 +79,7 @@ static void RxPktPendingTimeout(unsigned long data)
 
                if (index > REORDER_WIN_SIZE) {
                        RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket():"
-                                    " Rx Reorer struct buffer full!!\n");
+                                    " Rx Reorder struct buffer full!!\n");
                        spin_unlock_irqrestore(&(ieee->reorder_spinlock),
                                               flags);
                        return;
index 6c8a8e12b2b508ff2ec121162b3123a7633e7803..7413816dd92ba00dd65238ba099f36647d577e30 100644 (file)
@@ -712,7 +712,7 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
 
                if (index > REORDER_WIN_SIZE) {
                        RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket():"
-                                    " Rx Reorer struct buffer full!!\n");
+                                    " Rx Reorder struct buffer full!!\n");
                        spin_unlock_irqrestore(&(ieee->reorder_spinlock),
                                               flags);
                        return;
index 4bf72bc1ba7bb324127b77a368a0d8cccb1483ab..d65cba428941dbab4ff927cfb008064b08b0cd3a 100644 (file)
@@ -543,7 +543,7 @@ void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh)
                                goto out; /* scan completed */
                } while (!ieee->active_channel_map[ch]);
 
-               /* this fuction can be called in two situations
+               /* this function can be called in two situations
                 * 1- We have switched to ad-hoc mode and we are
                 *    performing a complete syncro scan before conclude
                 *    there are no interesting cell and to create a
index 40b14a2d1cdb29bb44b7bc1eb36e3d1910f95f50..08e1bc90555abb5d61abfae924807daef7b0d971 100644 (file)
@@ -32,7 +32,7 @@ void PHY_SetRF8256Bandwidth(struct net_device *dev , HT_CHANNEL_WIDTH Bandwidth)
        for(eRFPath = 0; eRFPath <RF90_PATH_MAX; eRFPath++)
        {
                if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath))
-                               continue;
+                       continue;
 
                switch (Bandwidth)
                {
@@ -125,7 +125,7 @@ void phy_RF8256_Config_ParaFile(struct net_device *dev)
        for(eRFPath = (RF90_RADIO_PATH_E)RF90_PATH_A; eRFPath <priv->NumTotalRFPath; eRFPath++)
        {
                if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath))
-                               continue;
+                       continue;
 
                pPhyReg = &priv->PHYRegDef[eRFPath];
 
@@ -249,7 +249,7 @@ void PHY_SetRF8256CCKTxPower(struct net_device *dev, u8 powerlevel)
                if(priv->CustomerID == RT_CID_819x_Netcore)
                        TxAGC = 0x22;
                else
-               TxAGC += priv->CckPwEnl;
+                       TxAGC += priv->CckPwEnl;
        }
 
        if(TxAGC > 0x24)
index 07fb5e4e50fa7cc7e89e5c30592d31783c234ccb..435f3594dabeb341016f5d6dcda64ee996d850de 100644 (file)
@@ -19,14 +19,6 @@ config 8723AU_AP_MODE
        will never be used as an AP, or the target system has limited memory,
        "Y" should be selected.
 
-config 8723AU_P2P
-       bool "Realtek RTL8723AU Peer-to-peer mode"
-       default y
-       ---help---
-       This option enables peer-to-peer mode for the r8723au driver. Unless you
-       know that peer-to-peer (P2P) mode will never be used, or the target system has
-       limited memory, "Y" should be selected.
-
 config 8723AU_BT_COEXIST
        bool "Realtek RTL8723AU BlueTooth Coexistence"
        default y
index 11c6dd4864621532bc36a7170638e2caf6789539..bbf503dd437a2713efc5b65b78f88bd451c7dae4 100644 (file)
@@ -8,7 +8,6 @@ r8723au-y :=                            \
                core/rtw_led.o          \
                core/rtw_mlme.o         \
                core/rtw_mlme_ext.o     \
-               core/rtw_p2p.o          \
                core/rtw_pwrctrl.o      \
                core/rtw_recv.o         \
                core/rtw_security.o     \
index a357e98cb83e02a54e3182e3d4fe5cece5f54e4c..9b31412b75216aff3982d187d097943c1d0b2057 100644 (file)
@@ -21,7 +21,6 @@
 
 #ifdef CONFIG_8723AU_AP_MODE
 
-extern unsigned char RTW_WPA_OUI23A[];
 extern unsigned char WMM_OUI23A[];
 extern unsigned char WPS_OUI23A[];
 extern unsigned char P2P_OUI23A[];
@@ -74,12 +73,13 @@ static void update_BCNTIM(struct rtw_adapter *padapter)
        struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network;
        unsigned char *pie = pnetwork_mlmeext->IEs;
        u8 *p, *dst_ie, *premainder_ie = NULL, *pbackup_remainder_ie = NULL;
-       u16 tim_bitmap_le;
+       __le16 tim_bitmap_le;
        uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen;
 
        tim_bitmap_le = cpu_to_le16(pstapriv->tim_bitmap);
 
-       p = rtw_get_ie23a(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen, pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_);
+       p = rtw_get_ie23a(pie + _FIXED_IE_LENGTH_, WLAN_EID_TIM, &tim_ielen,
+                         pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_);
        if (p != NULL && tim_ielen>0) {
                tim_ielen += 2;
 
@@ -98,12 +98,16 @@ static void update_BCNTIM(struct rtw_adapter *padapter)
                offset = _FIXED_IE_LENGTH_;
 
                /* get ssid_ie len */
-               p = rtw_get_ie23a(pie + _BEACON_IE_OFFSET_, _SSID_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_));
+               p = rtw_get_ie23a(pie + _BEACON_IE_OFFSET_, WLAN_EID_SSID,
+                                 &tmp_len, (pnetwork_mlmeext->IELength -
+                                            _BEACON_IE_OFFSET_));
                if (p != NULL)
                        offset += tmp_len+2;
 
                /*  get supported rates len */
-               p = rtw_get_ie23a(pie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_));
+               p = rtw_get_ie23a(pie + _BEACON_IE_OFFSET_, WLAN_EID_SUPP_RATES,
+                                 &tmp_len, (pnetwork_mlmeext->IELength -
+                                            _BEACON_IE_OFFSET_));
                if (p !=  NULL)
                        offset += tmp_len+2;
 
@@ -124,7 +128,7 @@ static void update_BCNTIM(struct rtw_adapter *padapter)
                        memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen);
        }
 
-       *dst_ie++= _TIM_IE_;
+       *dst_ie++= WLAN_EID_TIM;
 
        if ((pstapriv->tim_bitmap&0xff00) && (pstapriv->tim_bitmap&0x00fc))
                tim_ielen = 5;
@@ -248,7 +252,7 @@ void        expire_timeout_chk23a(struct rtw_adapter *padapter)
 
                                        /* to update bcn with tim_bitmap for this station */
                                        pstapriv->tim_bitmap |= CHKBIT(psta->aid);
-                                       update_beacon23a(padapter, _TIM_IE_, NULL, false);
+                                       update_beacon23a(padapter, WLAN_EID_TIM, NULL, false);
 
                                        if (!pmlmeext->active_keep_alive_check)
                                                continue;
@@ -357,7 +361,7 @@ void add_RATid23a(struct rtw_adapter *padapter, struct sta_info *psta, u8 rssi_l
        unsigned int tx_ra_bitmap = 0;
        struct ht_priv *psta_ht = NULL;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct wlan_bssid_ex *pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network;
+       struct wlan_bssid_ex *pcur_network = &pmlmepriv->cur_network.network;
 
        if (psta)
                psta_ht = &psta->htpriv;
@@ -374,9 +378,9 @@ void add_RATid23a(struct rtw_adapter *padapter, struct sta_info *psta, u8 rssi_l
                        tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value23a(psta->bssrateset[i]&0x7f);
        }
        /* n mode ra_bitmap */
-       if (psta_ht->ht_option)
-       {
-               rtw23a_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
+       if (psta_ht->ht_option) {
+               rf_type = rtl8723a_get_rf_type(padapter);
+
                if (rf_type == RF_2T2R)
                        limit = 16;/*  2R */
                else
@@ -455,7 +459,7 @@ static void update_bmc_sta(struct rtw_adapter *padapter)
        int i, supportRateNum = 0;
        unsigned int tx_ra_bitmap = 0;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct wlan_bssid_ex *pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network;
+       struct wlan_bssid_ex *pcur_network = &pmlmepriv->cur_network.network;
        struct sta_info *psta = rtw_get_bcmc_stainfo23a(padapter);
 
        if (psta)
@@ -523,8 +527,6 @@ static void update_bmc_sta(struct rtw_adapter *padapter)
                psta->raid = raid;
                psta->init_rate = init_rate;
 
-               rtw_stassoc_hw_rpt23a(padapter, psta);
-
                spin_lock_bh(&psta->lock);
                psta->state = _FW_LINKED;
                spin_unlock_bh(&psta->lock);
@@ -632,9 +634,8 @@ static void update_hw_ht_param(struct rtw_adapter *padapter)
 
        min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2;
 
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing));
-
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len));
+       rtl8723a_set_ampdu_min_space(padapter, min_MPDU_spacing);
+       rtl8723a_set_ampdu_factor(padapter, max_AMPDU_len);
 
        /*  Config SM Power Save setting */
        pmlmeinfo->SM_PS = (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & 0x0C) >> 2;
@@ -644,22 +645,18 @@ static void update_hw_ht_param(struct rtw_adapter *padapter)
 
 static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf)
 {
-       u8 *p;
+       const u8 *p;
        u8 val8, cur_channel, cur_bwmode, cur_ch_offset;
        u16 bcn_interval;
        u32 acparm;
-       int ie_len;
        struct registry_priv *pregpriv = &padapter->registrypriv;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct security_priv* psecuritypriv = &padapter->securitypriv;
-       struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network;
+       struct wlan_bssid_ex *pnetwork = &pmlmepriv->cur_network.network;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network;
        struct HT_info_element *pht_info = NULL;
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-#endif /* CONFIG_8723AU_P2P */
 
        bcn_interval = (u16)pnetwork->Configuration.BeaconPeriod;
        cur_channel = pnetwork->Configuration.DSConfig;
@@ -695,27 +692,28 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf)
        Set_MSR23a(padapter, _HW_STATE_AP_);
 
        /* Set BSSID REG */
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, pnetwork->MacAddress);
+       hw_var_set_bssid(padapter, pnetwork->MacAddress);
 
        /* Set EDCA param reg */
        acparm = 0x002F3217; /*  VO */
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acparm));
+       rtl8723a_set_ac_param_vo(padapter, acparm);
        acparm = 0x005E4317; /*  VI */
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acparm));
+       rtl8723a_set_ac_param_vi(padapter, acparm);
        acparm = 0x005ea42b;
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acparm));
+       rtl8723a_set_ac_param_be(padapter, acparm);
        acparm = 0x0000A444; /*  BK */
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acparm));
+       rtl8723a_set_ac_param_bk(padapter, acparm);
 
        /* Set Security */
-       val8 = (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)? 0xcc: 0xcf;
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8));
+       val8 = (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) ?
+               0xcc: 0xcf;
+       rtl8723a_set_sec_cfg(padapter, val8);
 
        /* Beacon Control related register */
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&bcn_interval));
+       rtl8723a_set_beacon_interval(padapter, bcn_interval);
 
        UpdateBrateTbl23a(padapter, pnetwork->SupportedRates);
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_BASIC_RATE, pnetwork->SupportedRates);
+       HalSetBrateCfg23a(padapter, pnetwork->SupportedRates);
 
        if (!pmlmepriv->cur_network.join_res) {
                /* setting only at  first time */
@@ -723,21 +721,25 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf)
                /* disable dynamic functions, such as high power, DIG */
 
                /* turn on all dynamic functions */
-               Switch_DM_Func23a(padapter, DYNAMIC_ALL_FUNC_ENABLE, true);
+               rtl8723a_odm_support_ability_set(padapter,
+                                                DYNAMIC_ALL_FUNC_ENABLE);
        }
        /* set channel, bwmode */
-       p = rtw_get_ie23a((pnetwork->IEs + sizeof(struct ndis_802_11_fixed_ies)),
-                         _HT_ADD_INFO_IE_, &ie_len, (pnetwork->IELength -
-                         sizeof(struct ndis_802_11_fixed_ies)));
-       if (p && ie_len) {
-               pht_info = (struct HT_info_element *)(p+2);
-
-               if ((pregpriv->cbw40_enable) && (pht_info->infos[0] & BIT(2))) {
+       p = cfg80211_find_ie(WLAN_EID_HT_OPERATION,
+                            pnetwork->IEs +
+                            sizeof(struct ndis_802_11_fixed_ies),
+                            pnetwork->IELength -
+                            sizeof(struct ndis_802_11_fixed_ies));
+       if (p && p[1]) {
+               pht_info = (struct HT_info_element *)(p + 2);
+
+               if (pregpriv->cbw40_enable && pht_info->infos[0] & BIT(2)) {
                        /* switch to the 40M Hz mode */
                        cur_bwmode = HT_CHANNEL_WIDTH_40;
                        switch (pht_info->infos[0] & 0x3) {
                        case 1:
-                               /* pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; */
+                               /* pmlmeext->cur_ch_offset =
+                                  HAL_PRIME_CHNL_OFFSET_LOWER; */
                                cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
                                break;
                        case 3:
@@ -764,19 +766,13 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf)
        update_wireless_mode23a(padapter);
 
        /* udpate capability after cur_wireless_mode updated */
-       update_capinfo23a(padapter, rtw_get_capability23a((struct wlan_bssid_ex *)pnetwork));
+       update_capinfo23a(padapter, rtw_get_capability23a(pnetwork));
 
        /* let pnetwork_mlmeext == pnetwork_mlme. */
        memcpy(pnetwork_mlmeext, pnetwork, pnetwork->Length);
 
-#ifdef CONFIG_8723AU_P2P
-       memcpy(pwdinfo->p2p_group_ssid, pnetwork->Ssid.ssid,
-              pnetwork->Ssid.ssid_len);
-       pwdinfo->p2p_group_ssid_len = pnetwork->Ssid.ssid_len;
-#endif /* CONFIG_8723AU_P2P */
-
        if (pmlmeext->bstart_bss) {
-               update_beacon23a(padapter, _TIM_IE_, NULL, false);
+               update_beacon23a(padapter, WLAN_EID_TIM, NULL, false);
 
                /* issue beacon frame */
                if (send_beacon23a(padapter) == _FAIL)
@@ -787,19 +783,20 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf)
        update_bmc_sta(padapter);
 }
 
-int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf,  int len)
+int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf,
+                            unsigned int len)
 {
        int ret = _SUCCESS;
        u8 *p;
        u8 *pHT_caps_ie = NULL;
        u8 *pHT_info_ie = NULL;
        struct sta_info *psta = NULL;
+       __le16 *pbeacon;
        u16 cap, ht_cap = false;
        uint ie_len = 0;
        int group_cipher, pairwise_cipher;
        u8 channel, network_type, supportRate[NDIS_802_11_LENGTH_RATES_EX];
        int supportRateNum = 0;
-       u8 OUI1[] = {0x00, 0x50, 0xf2, 0x01};
        u8 WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01};
        struct registry_priv *pregistrypriv = &padapter->registrypriv;
        struct security_priv *psecuritypriv = &padapter->securitypriv;
@@ -823,7 +820,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf,  int len)
        if (!check_fwstate(pmlmepriv, WIFI_AP_STATE))
                return _FAIL;
 
-       if (len>MAX_IE_SZ)
+       if (len > MAX_IE_SZ)
                return _FAIL;
 
        pbss_network->IELength = len;
@@ -841,14 +838,14 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf,  int len)
 
        /* beacon interval */
        /* ie + 8;  8: TimeStamp, 2: Beacon Interval 2:Capability */
-       p = rtw_get_beacon_interval23a_from_ie(ie);
-       pbss_network->Configuration.BeaconPeriod = get_unaligned_le16(p);
+       pbeacon = rtw_get_beacon_interval23a_from_ie(ie);
+       pbss_network->Configuration.BeaconPeriod = get_unaligned_le16(pbeacon);
 
        /* capability */
        cap = get_unaligned_le16(ie);
 
        /* SSID */
-       p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _SSID_IE_, &ie_len,
+       p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_SSID, &ie_len,
                          (pbss_network->IELength -_BEACON_IE_OFFSET_));
        if (p && ie_len > 0) {
                memset(&pbss_network->Ssid, 0, sizeof(struct cfg80211_ssid));
@@ -859,7 +856,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf,  int len)
        /* chnnel */
        channel = 0;
        pbss_network->Configuration.Length = 0;
-       p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _DSSET_IE_, &ie_len,
+       p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_DS_PARAMS, &ie_len,
                          (pbss_network->IELength - _BEACON_IE_OFFSET_));
        if (p && ie_len > 0)
                channel = *(p + 2);
@@ -868,7 +865,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf,  int len)
 
        memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX);
        /*  get supported rates */
-       p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &ie_len,
+       p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_SUPP_RATES, &ie_len,
                          (pbss_network->IELength - _BEACON_IE_OFFSET_));
        if (p) {
                memcpy(supportRate, p+2, ie_len);
@@ -876,7 +873,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf,  int len)
        }
 
        /* get ext_supported rates */
-       p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_,
+       p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_EXT_SUPP_RATES,
                          &ie_len, pbss_network->IELength - _BEACON_IE_OFFSET_);
        if (p) {
                memcpy(supportRate+supportRateNum, p+2, ie_len);
@@ -889,7 +886,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf,  int len)
        rtw_set_supported_rate23a(pbss_network->SupportedRates, network_type);
 
        /* parsing ERP_IE */
-       p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &ie_len,
+       p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_ERP_INFO, &ie_len,
                          (pbss_network->IELength - _BEACON_IE_OFFSET_));
        if (p && ie_len > 0)
                ERP_IE_handler23a(padapter, (struct ndis_802_11_var_ies *)p);
@@ -906,7 +903,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf,  int len)
        group_cipher = 0; pairwise_cipher = 0;
        psecuritypriv->wpa2_group_cipher = _NO_PRIVACY_;
        psecuritypriv->wpa2_pairwise_cipher = _NO_PRIVACY_;
-       p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _RSN_IE_2_, &ie_len,
+       p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_RSN, &ie_len,
                          (pbss_network->IELength - _BEACON_IE_OFFSET_));
        if (p && ie_len > 0) {
                if (rtw_parse_wpa2_ie23a(p, ie_len+2, &group_cipher,
@@ -928,10 +925,10 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf,  int len)
        psecuritypriv->wpa_group_cipher = _NO_PRIVACY_;
        psecuritypriv->wpa_pairwise_cipher = _NO_PRIVACY_;
        for (p = ie + _BEACON_IE_OFFSET_; ;p += (ie_len + 2)) {
-               p = rtw_get_ie23a(p, _SSN_IE_1_, &ie_len,
+               p = rtw_get_ie23a(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len,
                                  (pbss_network->IELength - _BEACON_IE_OFFSET_ -
                                  (ie_len + 2)));
-               if ((p) && (!memcmp(p+2, OUI1, 4))) {
+               if ((p) && (!memcmp(p+2, RTW_WPA_OUI23A_TYPE, 4))) {
                        if (rtw_parse_wpa_ie23a(p, ie_len+2, &group_cipher,
                                                &pairwise_cipher, NULL) == _SUCCESS) {
                                psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
@@ -956,7 +953,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf,  int len)
        pmlmepriv->qospriv.qos_option = 0;
        if (pregistrypriv->wmm_enable) {
                for (p = ie + _BEACON_IE_OFFSET_; ;p += (ie_len + 2)) {
-                       p = rtw_get_ie23a(p, _VENDOR_SPECIFIC_IE_, &ie_len,
+                       p = rtw_get_ie23a(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len,
                                          (pbss_network->IELength -
                                          _BEACON_IE_OFFSET_ - (ie_len + 2)));
                        if ((p) && !memcmp(p+2, WMM_PARA_IE, 6)) {
@@ -978,7 +975,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf,  int len)
                }
        }
        /* parsing HT_CAP_IE */
-       p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _HT_CAPABILITY_IE_, &ie_len,
+       p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_CAPABILITY, &ie_len,
                          (pbss_network->IELength - _BEACON_IE_OFFSET_));
        if (p && ie_len > 0) {
                u8 rf_type;
@@ -990,7 +987,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf,  int len)
                ht_cap = true;
                network_type |= WIRELESS_11_24N;
 
-               rtw23a_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
+               rf_type = rtl8723a_get_rf_type(padapter);
 
                if ((psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_CCMP) ||
                    (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP))
@@ -1010,7 +1007,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf,  int len)
        }
 
        /* parsing HT_INFO_IE */
-       p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, &ie_len,
+       p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_OPERATION, &ie_len,
                          (pbss_network->IELength - _BEACON_IE_OFFSET_));
        if (p && ie_len > 0)
                pHT_info_ie = p;
@@ -1050,7 +1047,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf,  int len)
                HT_info_handler23a(padapter, (struct ndis_802_11_var_ies *)pHT_info_ie);
        }
 
-       pbss_network->Length = get_wlan_bssid_ex_sz((struct wlan_bssid_ex  *)pbss_network);
+       pbss_network->Length = get_wlan_bssid_ex_sz(pbss_network);
 
        /* issue beacon to start bss network */
        start_bss_network(padapter, (u8*)pbss_network);
@@ -1200,7 +1197,7 @@ static void update_bcn_erpinfo_ie(struct rtw_adapter *padapter)
                return;
 
        /* parsing ERP_IE */
-       p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &len, (pnetwork->IELength - _BEACON_IE_OFFSET_));
+       p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_ERP_INFO, &len, (pnetwork->IELength - _BEACON_IE_OFFSET_));
        if (p && len>0)
        {
                struct ndis_802_11_var_ies * pIE = (struct ndis_802_11_var_ies *)p;
@@ -1306,26 +1303,16 @@ static void update_bcn_vendor_spec_ie(struct rtw_adapter *padapter, u8*oui)
 {
        DBG_8723A("%s\n", __func__);
 
-       if (!memcmp(RTW_WPA_OUI23A, oui, 4))
-       {
+       if (!memcmp(RTW_WPA_OUI23A_TYPE, oui, 4))
                update_bcn_wpa_ie(padapter);
-       }
        else if (!memcmp(WMM_OUI23A, oui, 4))
-       {
                update_bcn_wmm_ie(padapter);
-       }
        else if (!memcmp(WPS_OUI23A, oui, 4))
-       {
                update_bcn_wps_ie(padapter);
-       }
        else if (!memcmp(P2P_OUI23A, oui, 4))
-       {
                update_bcn_p2p_ie(padapter);
-       }
        else
-       {
                DBG_8723A("unknown OUI type!\n");
-       }
 }
 
 void update_beacon23a(struct rtw_adapter *padapter, u8 ie_id, u8 *oui, u8 tx)
@@ -1350,50 +1337,37 @@ void update_beacon23a(struct rtw_adapter *padapter, u8 ie_id, u8 *oui, u8 tx)
 
        switch (ie_id)
        {
-               case 0xFF:
-
-                       update_bcn_fixed_ie(padapter);/* 8: TimeStamp, 2: Beacon Interval 2:Capability */
-
-                       break;
-
-               case _TIM_IE_:
-
-                       update_BCNTIM(padapter);
-
-                       break;
-
-               case _ERPINFO_IE_:
-
-                       update_bcn_erpinfo_ie(padapter);
-
-                       break;
-
-               case _HT_CAPABILITY_IE_:
-
-                       update_bcn_htcap_ie(padapter);
-
-                       break;
-
-               case _RSN_IE_2_:
-
-                       update_bcn_rsn_ie(padapter);
-
-                       break;
+       case 0xFF:
+               /* 8: TimeStamp, 2: Beacon Interval 2:Capability */
+               update_bcn_fixed_ie(padapter);
+               break;
 
-               case _HT_ADD_INFO_IE_:
+       case WLAN_EID_TIM:
+               update_BCNTIM(padapter);
+               break;
 
-                       update_bcn_htinfo_ie(padapter);
+       case WLAN_EID_ERP_INFO:
+               update_bcn_erpinfo_ie(padapter);
+               break;
 
-                       break;
+       case WLAN_EID_HT_CAPABILITY:
+               update_bcn_htcap_ie(padapter);
+               break;
 
-               case _VENDOR_SPECIFIC_IE_:
+       case WLAN_EID_RSN:
+               update_bcn_rsn_ie(padapter);
+               break;
 
-                       update_bcn_vendor_spec_ie(padapter, oui);
+       case WLAN_EID_HT_OPERATION:
+               update_bcn_htinfo_ie(padapter);
+               break;
 
-                       break;
+       case WLAN_EID_VENDOR_SPECIFIC:
+               update_bcn_vendor_spec_ie(padapter, oui);
+               break;
 
-               default:
-                       break;
+       default:
+               break;
        }
 
        pmlmepriv->update_bcn = true;
@@ -1465,8 +1439,9 @@ static int rtw_ht_operation_update(struct rtw_adapter *padapter)
        if (pmlmepriv->num_sta_no_ht ||
            (pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT))
                new_op_mode = OP_MODE_MIXED;
-       else if ((phtpriv_ap->ht_cap.cap_info & IEEE80211_HT_CAP_SUP_WIDTH_20_40)
-                && pmlmepriv->num_sta_ht_20mhz)
+       else if ((le16_to_cpu(phtpriv_ap->ht_cap.cap_info) &
+                 IEEE80211_HT_CAP_SUP_WIDTH_20_40) &&
+                pmlmepriv->num_sta_ht_20mhz)
                new_op_mode = OP_MODE_20MHZ_HT_STA_ASSOCED;
        else if (pmlmepriv->olbc_ht)
                new_op_mode = OP_MODE_MAY_BE_LEGACY_STAS;
@@ -1562,7 +1537,7 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info
                        if (pmlmepriv->num_sta_non_erp == 1)
                        {
                                beacon_updated = true;
-                               update_beacon23a(padapter, _ERPINFO_IE_, NULL, true);
+                               update_beacon23a(padapter, WLAN_EID_ERP_INFO, NULL, true);
                        }
                }
 
@@ -1578,7 +1553,7 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info
                        if (pmlmepriv->num_sta_non_erp == 0)
                        {
                                beacon_updated = true;
-                               update_beacon23a(padapter, _ERPINFO_IE_, NULL, true);
+                               update_beacon23a(padapter, WLAN_EID_ERP_INFO, NULL, true);
                        }
                }
 
@@ -1669,8 +1644,8 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info
 
        if (rtw_ht_operation_update(padapter) > 0)
        {
-               update_beacon23a(padapter, _HT_CAPABILITY_IE_, NULL, false);
-               update_beacon23a(padapter, _HT_ADD_INFO_IE_, NULL, true);
+               update_beacon23a(padapter, WLAN_EID_HT_CAPABILITY, NULL, false);
+               update_beacon23a(padapter, WLAN_EID_HT_OPERATION, NULL, true);
        }
 
        /* update associcated stations cap. */
@@ -1705,7 +1680,8 @@ u8 bss_cap_update_on_sta_leave23a(struct rtw_adapter *padapter, struct sta_info
                if (pmlmepriv->num_sta_non_erp == 0)
                {
                        beacon_updated = true;
-                       update_beacon23a(padapter, _ERPINFO_IE_, NULL, true);
+                       update_beacon23a(padapter, WLAN_EID_ERP_INFO,
+                                        NULL, true);
                }
        }
 
@@ -1737,8 +1713,8 @@ u8 bss_cap_update_on_sta_leave23a(struct rtw_adapter *padapter, struct sta_info
 
        if (rtw_ht_operation_update(padapter) > 0)
        {
-               update_beacon23a(padapter, _HT_CAPABILITY_IE_, NULL, false);
-               update_beacon23a(padapter, _HT_ADD_INFO_IE_, NULL, true);
+               update_beacon23a(padapter, WLAN_EID_HT_CAPABILITY, NULL, false);
+               update_beacon23a(padapter, WLAN_EID_HT_OPERATION, NULL, true);
        }
 
        /* update associcated stations cap. */
index 5e3088a01800d554115fb64e6011f15e5b4ce085..5b3ac69011470a872f02819f429ac4887c72b518 100644 (file)
@@ -17,8 +17,8 @@
 #include <osdep_service.h>
 #include <drv_types.h>
 #include <recv_osdep.h>
-#include <cmd_osdep.h>
 #include <mlme_osdep.h>
+#include <rtl8723a_cmd.h>
 
 #ifdef CONFIG_8723AU_BT_COEXIST
 #include <rtl8723a_hal.h>
@@ -175,13 +175,6 @@ int rtw_init_cmd_priv23a(struct cmd_priv *pcmdpriv)
 {
        int res = _SUCCESS;
 
-       sema_init(&pcmdpriv->cmd_queue_sema, 0);
-       sema_init(&pcmdpriv->terminate_cmdthread_sema, 0);
-
-       _rtw_init_queue23a(&pcmdpriv->cmd_queue);
-
-       pcmdpriv->cmd_seq = 1;
-
        pcmdpriv->cmd_allocated_buf = kzalloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ,
                                              GFP_KERNEL);
 
@@ -208,6 +201,11 @@ int rtw_init_cmd_priv23a(struct cmd_priv *pcmdpriv)
        pcmdpriv->cmd_done_cnt = 0;
        pcmdpriv->rsp_cnt = 0;
 
+
+       pcmdpriv->wq = alloc_workqueue("rtl8723au", 0, 1);
+       if (!pcmdpriv->wq)
+               res = _FAIL;
+
 exit:
 
        return res;
@@ -216,10 +214,9 @@ exit:
 /* forward definition */
 
 static void c2h_wk_callback(struct work_struct *work);
-int _rtw_init_evt_priv23a(struct evt_priv *pevtpriv)
-{
-       int res = _SUCCESS;
 
+u32 rtw_init_evt_priv23a(struct evt_priv *pevtpriv)
+{
        /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */
        atomic_set(&pevtpriv->event_seq, 0);
        pevtpriv->evt_done_cnt = 0;
@@ -228,15 +225,13 @@ int _rtw_init_evt_priv23a(struct evt_priv *pevtpriv)
        pevtpriv->c2h_wk_alive = false;
        pevtpriv->c2h_queue = rtw_cbuf_alloc23a(C2H_QUEUE_MAX_LEN + 1);
 
-       return res;
+       return _SUCCESS;
 }
 
-void _rtw_free_evt_priv23a (struct evt_priv *pevtpriv)
+void rtw_free_evt_priv23a(struct evt_priv *pevtpriv)
 {
-       RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_,
-                ("+_rtw_free_evt_priv23a\n"));
        cancel_work_sync(&pevtpriv->c2h_wk);
-       while(pevtpriv->c2h_wk_alive)
+       while (pevtpriv->c2h_wk_alive)
                msleep(10);
 
        while (!rtw_cbuf_empty23a(pevtpriv->c2h_queue)) {
@@ -246,68 +241,19 @@ void _rtw_free_evt_priv23a (struct evt_priv *pevtpriv)
                        kfree(c2h);
                }
        }
-
-       RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_,
-                ("-_rtw_free_evt_priv23a\n"));
 }
 
-void _rtw_free_cmd_priv23a(struct cmd_priv *pcmdpriv)
+void rtw_free_cmd_priv23a(struct cmd_priv *pcmdpriv)
 {
+       RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_,
+                ("rtw_free_cmd_priv23a\n"));
+
        if (pcmdpriv) {
                kfree(pcmdpriv->cmd_allocated_buf);
                kfree(pcmdpriv->rsp_allocated_buf);
        }
 }
 
-/*
-Calling Context:
-rtw_enqueue_cmd23a can only be called between kernel thread,
-since only spin_lock is used.
-
-ISR/Call-Back functions can't call this sub-function.
-*/
-
-int _rtw_enqueue_cmd23a(struct rtw_queue *queue, struct cmd_obj *obj)
-{
-       unsigned long irqL;
-
-       if (obj == NULL)
-               goto exit;
-
-       spin_lock_irqsave(&queue->lock, irqL);
-
-       list_add_tail(&obj->list, &queue->queue);
-
-       spin_unlock_irqrestore(&queue->lock, irqL);
-
-exit:
-
-       return _SUCCESS;
-}
-
-u32 rtw_init_evt_priv23a(struct evt_priv *pevtpriv)
-{
-       int res;
-
-       res = _rtw_init_evt_priv23a(pevtpriv);
-
-       return res;
-}
-
-void rtw_free_evt_priv23a(struct evt_priv *pevtpriv)
-{
-       RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_,
-                ("rtw_free_evt_priv23a\n"));
-       _rtw_free_evt_priv23a(pevtpriv);
-}
-
-void rtw_free_cmd_priv23a(struct cmd_priv *pcmdpriv)
-{
-       RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_,
-                ("rtw_free_cmd_priv23a\n"));
-       _rtw_free_cmd_priv23a(pcmdpriv);
-}
-
 static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
 {
        struct drvextra_cmd_parm *pdrvextra_cmd_parm;
@@ -329,21 +275,21 @@ static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
        if (cmd_obj->cmdcode == GEN_CMD_CODE(_SetChannelPlan))
                bAllow = true;
 
-       if ((pcmdpriv->padapter->hw_init_completed == false &&
-            bAllow == false) || pcmdpriv->cmdthd_running == false)
+       if (pcmdpriv->padapter->hw_init_completed == false && bAllow == false)
                return _FAIL;
        return _SUCCESS;
 }
 
-u32 rtw_enqueue_cmd23a(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
+static void rtw_cmd_work(struct work_struct *work);
+
+int rtw_enqueue_cmd23a(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
 {
        int res = _FAIL;
-       struct rtw_adapter *padapter = pcmdpriv->padapter;
 
        if (!cmd_obj)
                goto exit;
 
-       cmd_obj->padapter = padapter;
+       cmd_obj->padapter = pcmdpriv->padapter;
 
        res = rtw_cmd_filter(pcmdpriv, cmd_obj);
        if (res == _FAIL) {
@@ -351,32 +297,18 @@ u32 rtw_enqueue_cmd23a(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
                goto exit;
        }
 
-       res = _rtw_enqueue_cmd23a(&pcmdpriv->cmd_queue, cmd_obj);
+       INIT_WORK(&cmd_obj->work, rtw_cmd_work);
 
-       if (res == _SUCCESS)
-               up(&pcmdpriv->cmd_queue_sema);
+       res = queue_work(pcmdpriv->wq, &cmd_obj->work);
 
+       if (!res) {
+               printk(KERN_ERR "%s: Call to queue_work() failed\n", __func__);
+               res = _FAIL;
+       } else
+               res = _SUCCESS;
 exit:
-       return res;
-}
-
-static struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv)
-{
-       struct cmd_obj *obj;
-       struct rtw_queue *queue = &pcmdpriv->cmd_queue;
-       unsigned long irqL;
-
-       spin_lock_irqsave(&queue->lock, irqL);
-       if (list_empty(&queue->queue))
-               obj = NULL;
-       else {
-               obj = container_of((&queue->queue)->next, struct cmd_obj, list);
-               list_del_init(&obj->list);
-       }
-
-       spin_unlock_irqrestore(&queue->lock, irqL);
 
-       return obj;
+       return res;
 }
 
 void rtw_cmd_clr_isr23a(struct cmd_priv *pcmdpriv)
@@ -403,116 +335,65 @@ void rtw_free_cmd_obj23a(struct cmd_obj *pcmd)
        kfree(pcmd);
 }
 
-int rtw_cmd_thread23a(void *context)
+static void rtw_cmd_work(struct work_struct *work)
 {
-       u8 ret;
-       struct cmd_obj *pcmd;
-       u8 *pcmdbuf, *prspbuf;
-       u8 (*cmd_hdl)(struct rtw_adapter *padapter, u8* pbuf);
+       u8 (*cmd_hdl)(struct rtw_adapter *padapter, const u8 *pbuf);
        void (*pcmd_callback)(struct rtw_adapter *dev, struct cmd_obj *pcmd);
-       struct rtw_adapter *padapter = (struct rtw_adapter *)context;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-
-       allow_signal(SIGTERM);
+       struct cmd_priv *pcmdpriv;
+       struct cmd_obj *pcmd = container_of(work, struct cmd_obj, work);
+       u8 *pcmdbuf;
 
+       pcmdpriv = &pcmd->padapter->cmdpriv;
        pcmdbuf = pcmdpriv->cmd_buf;
-       prspbuf = pcmdpriv->rsp_buf;
-
-       pcmdpriv->cmdthd_running = true;
-       up(&pcmdpriv->terminate_cmdthread_sema);
-
-       RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_,
-                ("start r871x rtw_cmd_thread23a !!!!\n"));
-
-       while(1) {
-               if (down_interruptible(&pcmdpriv->cmd_queue_sema))
-                       break;
-_next:
-               if ((padapter->bDriverStopped == true) ||
-                   (padapter->bSurpriseRemoved == true)) {
-                       DBG_8723A("%s: DriverStopped(%d) SurpriseRemoved(%d) "
-                                 "break at line %d\n", __func__,
-                                 padapter->bDriverStopped,
-                                 padapter->bSurpriseRemoved, __LINE__);
-                       break;
-               }
 
-               if (!(pcmd = rtw_dequeue_cmd(pcmdpriv)))
-                       continue;
-
-               if (rtw_cmd_filter(pcmdpriv, pcmd) == _FAIL) {
-                       pcmd->res = H2C_DROPPED;
-                       goto post_process;
-               }
-
-               pcmdpriv->cmd_issued_cnt++;
-
-               pcmd->cmdsz = ALIGN(pcmd->cmdsz, 4);
+       if (rtw_cmd_filter(pcmdpriv, pcmd) == _FAIL) {
+               pcmd->res = H2C_DROPPED;
+               goto post_process;
+       }
 
-               memcpy(pcmdbuf, pcmd->parmbuf, pcmd->cmdsz);
+       pcmdpriv->cmd_issued_cnt++;
 
-               if (pcmd->cmdcode < (sizeof(wlancmds)/sizeof(struct cmd_hdl))) {
-                       cmd_hdl = wlancmds[pcmd->cmdcode].h2cfuns;
+       pcmd->cmdsz = ALIGN(pcmd->cmdsz, 4);
 
-                       if (cmd_hdl) {
-                               ret = cmd_hdl(pcmd->padapter, pcmdbuf);
-                               pcmd->res = ret;
-                       }
+       memcpy(pcmdbuf, pcmd->parmbuf, pcmd->cmdsz);
 
-                       pcmdpriv->cmd_seq++;
-               } else
-                       pcmd->res = H2C_PARAMETERS_ERROR;
+       if (pcmd->cmdcode < (sizeof(wlancmds)/sizeof(struct cmd_hdl))) {
+               cmd_hdl = wlancmds[pcmd->cmdcode].h2cfuns;
 
-               cmd_hdl = NULL;
+               if (cmd_hdl)
+                       pcmd->res = cmd_hdl(pcmd->padapter, pcmdbuf);
+               else
+                       pcmd->res = H2C_DROPPED;
+       } else
+               pcmd->res = H2C_PARAMETERS_ERROR;
 
 post_process:
-               /* call callback function for post-processed */
-               if (pcmd->cmdcode < (sizeof(rtw_cmd_callback) /
-                                    sizeof(struct _cmd_callback))) {
-                       pcmd_callback =
-                               rtw_cmd_callback[pcmd->cmdcode].callback;
-                       if (!pcmd_callback) {
-                               RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_,
-                                        ("mlme_cmd_hdl(): pcmd_callback = "
-                                         "0x%p, cmdcode = 0x%x\n",
-                                         pcmd_callback, pcmd->cmdcode));
-                               rtw_free_cmd_obj23a(pcmd);
-                       } else {
-                               /* todo: !!! fill rsp_buf to pcmd->rsp
-                                  if (pcmd->rsp!= NULL) */
-                               /* need conider that free cmd_obj in
-                                  rtw_cmd_callback */
-                               pcmd_callback(pcmd->padapter, pcmd);
-                       }
-               } else {
-                       RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
-                                ("%s: cmdcode = 0x%x callback not defined!\n",
-                                 __func__, pcmd->cmdcode));
+       /* call callback function for post-processed */
+       if (pcmd->cmdcode < (sizeof(rtw_cmd_callback) /
+                            sizeof(struct _cmd_callback))) {
+               pcmd_callback = rtw_cmd_callback[pcmd->cmdcode].callback;
+               if (!pcmd_callback) {
+                       RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_,
+                                ("mlme_cmd_hdl(): pcmd_callback = 0x%p, "
+                                 "cmdcode = 0x%x\n",
+                                 pcmd_callback, pcmd->cmdcode));
                        rtw_free_cmd_obj23a(pcmd);
+               } else {
+                       /* todo: !!! fill rsp_buf to pcmd->rsp
+                          if (pcmd->rsp!= NULL) */
+                       /* need conider that free cmd_obj in
+                          rtw_cmd_callback */
+                       pcmd_callback(pcmd->padapter, pcmd);
                }
-
-               if (signal_pending (current))
-                       flush_signals(current);
-
-               goto _next;
-
-       }
-       pcmdpriv->cmdthd_running = false;
-
-       /*  free all cmd_obj resources */
-       do {
-               pcmd = rtw_dequeue_cmd(pcmdpriv);
-               if (!pcmd)
-                       break;
-
+       } else {
+               RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
+                        ("%s: cmdcode = 0x%x callback not defined!\n",
+                         __func__, pcmd->cmdcode));
                rtw_free_cmd_obj23a(pcmd);
-       } while(1);
-
-       up(&pcmdpriv->terminate_cmdthread_sema);
-
-       complete_and_exit(NULL, 0);
+       }
 }
 
+
 u8 rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter,
                         struct cfg80211_ssid *ssid, int ssid_num,
                         struct rtw_ieee80211_channel *ch, int ch_num)
@@ -526,12 +407,6 @@ u8 rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter,
        if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
                rtw_lps_ctrl_wk_cmd23a(padapter, LPS_CTRL_SCAN, 1);
 
-#ifdef CONFIG_8723AU_P2P
-       if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
-               p2p_ps_wk_cmd23a(padapter, P2P_PS_SCAN, 1);
-       }
-#endif /* CONFIG_8723AU_P2P */
-
        ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
        if (!ph2c)
                return _FAIL;
@@ -542,7 +417,7 @@ u8 rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter,
                return _FAIL;
        }
 
-       rtw_free_network_queue23a(padapter, false);
+       rtw_free_network_queue23a(padapter);
 
        RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_,
                 ("%s: flush network queue\n", __func__));
@@ -639,10 +514,9 @@ u8 rtw_createbss_cmd23a(struct rtw_adapter  *padapter)
                goto exit;
        }
 
-       INIT_LIST_HEAD(&pcmd->list);
        pcmd->cmdcode = _CreateBss_CMD_;
        pcmd->parmbuf = (unsigned char *)pdev_network;
-       pcmd->cmdsz = get_wlan_bssid_ex_sz((struct wlan_bssid_ex*)pdev_network);
+       pcmd->cmdsz = get_wlan_bssid_ex_sz(pdev_network);
        pcmd->rsp = NULL;
        pcmd->rspsz = 0;
 
@@ -656,10 +530,9 @@ exit:
 }
 
 u8 rtw_joinbss_cmd23a(struct rtw_adapter *padapter,
-                     struct wlan_network * pnetwork)
+                     struct wlan_network *pnetwork)
 {
        u8 *auth, res = _SUCCESS;
-       uint t_len = 0;
        struct wlan_bssid_ex *psecnetwork;
        struct cmd_obj *pcmd;
        struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
@@ -693,8 +566,6 @@ u8 rtw_joinbss_cmd23a(struct rtw_adapter *padapter,
                          "fail!!!\n"));
                goto exit;
        }
-       /* for IEs is fix buf size */
-       t_len = sizeof(struct wlan_bssid_ex);
 
        /* for hidden ap to set fw_state here */
        if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE)) {
@@ -712,7 +583,7 @@ u8 rtw_joinbss_cmd23a(struct rtw_adapter *padapter,
                }
        }
 
-       psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss;
+       psecnetwork = &psecuritypriv->sec_bss;
        if (!psecnetwork) {
                if (pcmd)
                        kfree(pcmd);
@@ -725,7 +596,7 @@ u8 rtw_joinbss_cmd23a(struct rtw_adapter *padapter,
                goto exit;
        }
 
-       memset(psecnetwork, 0, t_len);
+       memset(psecnetwork, 0, sizeof(struct wlan_bssid_ex));
 
        memcpy(psecnetwork, &pnetwork->network,
               get_wlan_bssid_ex_sz(&pnetwork->network));
@@ -813,7 +684,6 @@ u8 rtw_joinbss_cmd23a(struct rtw_adapter *padapter,
        /* get cmdsz before endian conversion */
        pcmd->cmdsz = get_wlan_bssid_ex_sz(psecnetwork);
 
-       INIT_LIST_HEAD(&pcmd->list);
        pcmd->cmdcode = _JoinBss_CMD_;/* GEN_CMD_CODE(_JoinBss) */
        pcmd->parmbuf = (unsigned char *)psecnetwork;
        pcmd->rsp = NULL;
@@ -1213,7 +1083,7 @@ static void traffic_status_watchdog(struct rtw_adapter *padapter)
        pmlmepriv->LinkDetectInfo.bHigherBusyTxTraffic = bHigherBusyTxTraffic;
 }
 
-void dynamic_chk_wk_hdl(struct rtw_adapter *padapter, u8 *pbuf, int sz)
+static void dynamic_chk_wk_hdl(struct rtw_adapter *padapter, u8 *pbuf, int sz)
 {
        struct mlme_priv *pmlmepriv;
 
@@ -1240,7 +1110,7 @@ void dynamic_chk_wk_hdl(struct rtw_adapter *padapter, u8 *pbuf, int sz)
 #endif
 }
 
-void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type)
+static void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type)
 {
        struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -1269,8 +1139,7 @@ void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type)
                        mstatus = 1;/* connect */
                        /*  Reset LPS Setting */
                        padapter->pwrctrlpriv.LpsIdleCount = 0;
-                       rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_JOINBSSRPT,
-                                            (u8 *)&mstatus);
+                       rtl8723a_set_FwJoinBssReport_cmd(padapter, 1);
 #ifdef CONFIG_8723AU_BT_COEXIST
                        BT_WifiMediaStatusNotify(padapter, mstatus);
 #endif
@@ -1284,8 +1153,7 @@ void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type)
                        {
                                LPS_Leave23a(padapter);
                        }
-                       rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_JOINBSSRPT,
-                                            (u8 *)&mstatus);
+                       rtl8723a_set_FwJoinBssReport_cmd(padapter, 0);
                        break;
                case LPS_CTRL_SPECIAL_PACKET:
                        pwrpriv->DelayLPSLastTimeStamp = jiffies;
@@ -1355,48 +1223,6 @@ static void power_saving_wk_hdl(struct rtw_adapter *padapter, u8 *pbuf, int sz)
         rtw_ps_processor23a(padapter);
 }
 
-#ifdef CONFIG_8723AU_P2P
-u8 p2p_protocol_wk_cmd23a(struct rtw_adapter*padapter, int intCmdType)
-{
-       struct cmd_obj *ph2c;
-       struct drvextra_cmd_parm *pdrvextra_cmd_parm;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-       u8 res = _SUCCESS;
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-       {
-               return res;
-       }
-
-       ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
-       if (!ph2c) {
-               res = _FAIL;
-               goto exit;
-       }
-
-       pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm),
-                                    GFP_ATOMIC);
-       if (!pdrvextra_cmd_parm) {
-               kfree(ph2c);
-               res = _FAIL;
-               goto exit;
-       }
-
-       pdrvextra_cmd_parm->ec_id = P2P_PROTO_WK_CID;
-       pdrvextra_cmd_parm->type_size = intCmdType; /* As the command tppe. */
-       pdrvextra_cmd_parm->pbuf = NULL;            /* Must be NULL here */
-
-       init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm,
-                                  GEN_CMD_CODE(_Set_Drv_Extra));
-
-       res = rtw_enqueue_cmd23a(pcmdpriv, ph2c);
-exit:
-
-       return res;
-}
-#endif /* CONFIG_8723AU_P2P */
-
 u8 rtw_ps_cmd23a(struct rtw_adapter*padapter)
 {
        struct cmd_obj *ppscmd;
@@ -1443,11 +1269,11 @@ static void rtw_chk_hi_queue_hdl(struct rtw_adapter *padapter)
                return;
 
        if (psta_bmc->sleepq_len == 0) {
-               u8 val = 0;
+               bool val;
 
-               rtw23a_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &val);
+               val = rtl8723a_chk_hi_queue_empty(padapter);
 
-               while(val == false) {
+               while (val == false) {
                        msleep(100);
 
                        cnt++;
@@ -1455,15 +1281,14 @@ static void rtw_chk_hi_queue_hdl(struct rtw_adapter *padapter)
                        if (cnt>10)
                                break;
 
-                       rtw23a_hal_get_hwreg(padapter,
-                                            HW_VAR_CHK_HI_QUEUE_EMPTY, &val);
+                       val = rtl8723a_chk_hi_queue_empty(padapter);
                }
 
                if (cnt <= 10) {
                        pstapriv->tim_bitmap &= ~BIT(0);
                        pstapriv->sta_dz_bitmap &= ~BIT(0);
 
-                       update_beacon23a(padapter, _TIM_IE_, NULL, false);
+                       update_beacon23a(padapter, WLAN_EID_TIM, NULL, false);
                } else /* re check again */
                        rtw_chk_hi_queue_cmd23a(padapter);
        }
@@ -1586,7 +1411,9 @@ static void c2h_wk_callback(struct work_struct *work)
                        /* This C2H event is read, clear it */
                        c2h_evt_clear23a(adapter);
                } else if ((c2h_evt = (struct c2h_evt_hdr *)
-                           kmalloc(16, GFP_ATOMIC))) {
+                           kmalloc(16, GFP_KERNEL))) {
+                       if (!c2h_evt)
+                               continue;
                        /* This C2H event is not read, read & clear now */
                        if (c2h_evt_read23a(adapter, (u8*)c2h_evt) != _SUCCESS)
                                continue;
@@ -1614,9 +1441,9 @@ static void c2h_wk_callback(struct work_struct *work)
        evtpriv->c2h_wk_alive = false;
 }
 
-u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
+u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
-       struct drvextra_cmd_parm *pdrvextra_cmd;
+       const struct drvextra_cmd_parm *pdrvextra_cmd;
 
        if (!pbuf)
                return H2C_PARAMETERS_ERROR;
@@ -1636,16 +1463,6 @@ u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
        case LPS_CTRL_WK_CID:
                lps_ctrl_wk_hdl(padapter, (u8)pdrvextra_cmd->type_size);
                break;
-#ifdef CONFIG_8723AU_P2P
-       case P2P_PS_WK_CID:
-               p2p_ps_wk_hdl23a(padapter, pdrvextra_cmd->type_size);
-               break;
-       case P2P_PROTO_WK_CID:
-               /*      Commented by Albert 2011/07/01 */
-               /*      I used the type_size as the type command */
-               p2p_protocol_wk_hdl23a(padapter, pdrvextra_cmd->type_size);
-               break;
-#endif /*  CONFIG_8723AU_P2P */
 #ifdef CONFIG_8723AU_AP_MODE
        case CHECK_HIQ_WK_CID:
                rtw_chk_hi_queue_hdl(padapter);
@@ -1662,7 +1479,11 @@ u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
 
        if (pdrvextra_cmd->pbuf && (pdrvextra_cmd->type_size > 0)) {
                kfree(pdrvextra_cmd->pbuf);
-               pdrvextra_cmd->pbuf = NULL;
+               /*
+                * No need to set pdrvextra_cmd->pbuf = NULL as we were
+                * operating on a copy of the original pcmd->parmbuf
+                * created in rtw_cmd_work().
+                */
        }
 
        return H2C_SUCCESS;
@@ -1868,9 +1689,3 @@ void rtw_setassocsta_cmdrsp_callback23a(struct rtw_adapter *padapter,
 exit:
        rtw_free_cmd_obj23a(pcmd);
 }
-
-void rtw_getrttbl_cmd_cmdrsp_callback(struct rtw_adapter *padapter,
-                                     struct cmd_obj *pcmd)
-{
-       rtw_free_cmd_obj23a(pcmd);
-}
index a48ab25a7d8a251cd93a30cb04349a09ce3cdf1b..b56055eb433be2983790f23756b5f79b3c92185a 100644 (file)
@@ -131,7 +131,7 @@ u8 *rtw_set_fixed_ie23a(unsigned char *pbuf, unsigned int len,
 }
 
 /*  rtw_set_ie23a will update frame length */
-u8 *rtw_set_ie23a(u8 *pbuf, int index, uint len, u8 *source, uint *frlen)
+u8 *rtw_set_ie23a(u8 *pbuf, int index, uint len, const u8 *source, uint *frlen)
 {
 
        *pbuf = (u8)index;
@@ -413,7 +413,7 @@ int rtw_generate_ie23a(struct registry_priv *pregistrypriv)
        ie += 2;
 
        /* SSID */
-       ie = rtw_set_ie23a(ie, _SSID_IE_, pdev_network->Ssid.ssid_len,
+       ie = rtw_set_ie23a(ie, WLAN_EID_SSID, pdev_network->Ssid.ssid_len,
                        pdev_network->Ssid.ssid, &sz);
 
        /* supported rates */
@@ -431,25 +431,25 @@ int rtw_generate_ie23a(struct registry_priv *pregistrypriv)
        rateLen = rtw_get_rateset_len23a(pdev_network->SupportedRates);
 
        if (rateLen > 8) {
-               ie = rtw_set_ie23a(ie, _SUPPORTEDRATES_IE_, 8,
+               ie = rtw_set_ie23a(ie, WLAN_EID_SUPP_RATES, 8,
                                pdev_network->SupportedRates, &sz);
                /* ie = rtw_set_ie23a(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); */
        } else {
-               ie = rtw_set_ie23a(ie, _SUPPORTEDRATES_IE_, rateLen,
+               ie = rtw_set_ie23a(ie, WLAN_EID_SUPP_RATES, rateLen,
                                pdev_network->SupportedRates, &sz);
        }
 
        /* DS parameter set */
-       ie = rtw_set_ie23a(ie, _DSSET_IE_, 1,
+       ie = rtw_set_ie23a(ie, WLAN_EID_DS_PARAMS, 1,
                           (u8 *)&pdev_network->Configuration.DSConfig, &sz);
 
        /* IBSS Parameter Set */
 
-       ie = rtw_set_ie23a(ie, _IBSS_PARA_IE_, 2,
+       ie = rtw_set_ie23a(ie, WLAN_EID_IBSS_PARAMS, 2,
                           (u8 *)&pdev_network->Configuration.ATIMWindow, &sz);
 
        if (rateLen > 8) {
-               ie = rtw_set_ie23a(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8),
+               ie = rtw_set_ie23a(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8),
                                (pdev_network->SupportedRates + 8), &sz);
        }
 
@@ -460,60 +460,7 @@ int rtw_generate_ie23a(struct registry_priv *pregistrypriv)
        return sz;
 }
 
-unsigned char *rtw_get_wpa_ie23a(unsigned char *pie, int *wpa_ie_len, int limit)
-{
-       int len;
-       u16 val16;
-       unsigned char wpa_oui_type[] = {0x00, 0x50, 0xf2, 0x01};
-       u8 *pbuf = pie;
-       int limit_new = limit;
-
-       while(1) {
-               pbuf = rtw_get_ie23a(pbuf, _WPA_IE_ID_, &len, limit_new);
-
-               if (pbuf) {
-                       /* check if oui matches... */
-                       if (memcmp((pbuf + 2), wpa_oui_type,
-                                  sizeof(wpa_oui_type))) {
-                               goto check_next_ie;
-                       }
-
-                       /* check version... */
-                       memcpy((u8 *)&val16, (pbuf + 6), sizeof(val16));
-
-                       val16 = le16_to_cpu(val16);
-                       if (val16 != 0x0001)
-                               goto check_next_ie;
-
-                       *wpa_ie_len = *(pbuf + 1);
-
-                       return pbuf;
-               } else {
-                       *wpa_ie_len = 0;
-                       return NULL;
-               }
-
-check_next_ie:
-
-               limit_new = limit - (pbuf - pie) - 2 - len;
-
-               if (limit_new <= 0)
-                       break;
-
-               pbuf += (2 + len);
-       }
-
-       *wpa_ie_len = 0;
-
-       return NULL;
-}
-
-unsigned char *rtw_get_wpa2_ie23a(unsigned char *pie, int *rsn_ie_len, int limit)
-{
-       return rtw_get_ie23a(pie, _WPA2_IE_ID_, rsn_ie_len, limit);
-}
-
-int rtw_get_wpa_cipher_suite23a(u8 *s)
+int rtw_get_wpa_cipher_suite23a(const u8 *s)
 {
        if (!memcmp(s, WPA_CIPHER_SUITE_NONE23A, WPA_SELECTOR_LEN))
                return WPA_CIPHER_NONE;
@@ -529,7 +476,7 @@ int rtw_get_wpa_cipher_suite23a(u8 *s)
        return 0;
 }
 
-int rtw_get_wpa2_cipher_suite23a(u8 *s)
+int rtw_get_wpa2_cipher_suite23a(const u8 *s)
 {
        if (!memcmp(s, RSN_CIPHER_SUITE_NONE23A, RSN_SELECTOR_LEN))
                return WPA_CIPHER_NONE;
@@ -545,22 +492,19 @@ int rtw_get_wpa2_cipher_suite23a(u8 *s)
        return 0;
 }
 
-int rtw_parse_wpa_ie23a(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x)
+int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x)
 {
        int i, ret = _SUCCESS;
        int left, count;
-       u8 *pos;
-       u8 SUITE_1X[4] = {0x00, 0x50, 0xf2, 1};
+       const u8 *pos;
 
        if (wpa_ie_len <= 0) {
                /* No WPA IE - fail silently */
                return _FAIL;
        }
 
-       if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie+1) != (u8)(wpa_ie_len - 2)) ||
-           memcmp(wpa_ie + 2, RTW_WPA_OUI23A_TYPE, WPA_SELECTOR_LEN)) {
+       if (wpa_ie[1] != (u8)(wpa_ie_len - 2))
                return _FAIL;
-       }
 
        pos = wpa_ie;
 
@@ -612,7 +556,7 @@ int rtw_parse_wpa_ie23a(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pair
        if (is_8021x) {
                if (left >= 6) {
                        pos += 2;
-                       if (!memcmp(pos, SUITE_1X, 4)) {
+                       if (!memcmp(pos, RTW_WPA_OUI23A_TYPE, 4)) {
                                RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
                                         ("%s : there has 802.1x auth\n",
                                          __func__));
@@ -624,12 +568,12 @@ int rtw_parse_wpa_ie23a(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pair
        return ret;
 }
 
-int rtw_parse_wpa2_ie23a(u8* rsn_ie, int rsn_ie_len, int *group_cipher,
+int rtw_parse_wpa2_ie23a(const u8* rsn_ie, int rsn_ie_len, int *group_cipher,
                      int *pairwise_cipher, int *is_8021x)
 {
        int i, ret = _SUCCESS;
        int left, count;
-       u8 *pos;
+       const u8 *pos;
        u8 SUITE_1X[4] = {0x00, 0x0f, 0xac, 0x01};
 
        if (rsn_ie_len <= 0) {
@@ -705,11 +649,9 @@ int rtw_get_sec_ie23a(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len,
                   u8 *wpa_ie, u16 *wpa_len)
 {
        u8 authmode, sec_idx, i;
-       u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01};
        uint cnt;
 
 
-
        /* Search required WPA or WPA2 IE and copy to sec_ie[ ] */
 
        cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_);
@@ -719,8 +661,8 @@ int rtw_get_sec_ie23a(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len,
        while(cnt < in_len) {
                authmode = in_ie[cnt];
 
-               if ((authmode == _WPA_IE_ID_) &&
-                   !memcmp(&in_ie[cnt+2], &wpa_oui[0], 4)) {
+               if ((authmode == WLAN_EID_VENDOR_SPECIFIC) &&
+                   !memcmp(&in_ie[cnt+2], RTW_WPA_OUI23A_TYPE, 4)) {
                                RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
                                         ("\n rtw_get_wpa_ie23a: sec_idx =%d "
                                          "in_ie[cnt+1]+2 =%d\n",
@@ -788,7 +730,8 @@ u8 rtw_is_wps_ie23a(u8 *ie_ptr, uint *wps_ielen)
 
        eid = ie_ptr[0];
 
-       if ((eid == _WPA_IE_ID_) && !memcmp(&ie_ptr[2], wps_oui, 4)) {
+       if ((eid == WLAN_EID_VENDOR_SPECIFIC) &&
+           !memcmp(&ie_ptr[2], wps_oui, 4)) {
                /* DBG_8723A("==> found WPS_IE.....\n"); */
                *wps_ielen = ie_ptr[1] + 2;
                match = true;
@@ -824,7 +767,8 @@ u8 *rtw_get_wps_ie23a(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen)
        while (cnt < in_len) {
                eid = in_ie[cnt];
 
-               if ((eid == _WPA_IE_ID_) && !memcmp(&in_ie[cnt+2], wps_oui, 4)) {
+               if ((eid == WLAN_EID_VENDOR_SPECIFIC) &&
+                   !memcmp(&in_ie[cnt+2], wps_oui, 4)) {
                        wpsie_ptr = &in_ie[cnt];
 
                        if (wps_ie)
@@ -866,7 +810,7 @@ u8 *rtw_get_wps_attr23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id,
        if (len_attr)
                *len_attr = 0;
 
-       if ((wps_ie[0] != _VENDOR_SPECIFIC_IE_) ||
+       if ((wps_ie[0] != WLAN_EID_VENDOR_SPECIFIC) ||
            memcmp(wps_ie + 2, wps_oui, 4)) {
                return attr_ptr;
        }
@@ -937,237 +881,6 @@ u8 *rtw_get_wps_attr_content23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id,
        return NULL;
 }
 
-static int
-rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen,
-                                    struct rtw_ieee802_11_elems *elems,
-                                    int show_errors)
-{
-       unsigned int oui;
-
-       /* first 3 bytes in vendor specific information element are the IEEE
-        * OUI of the vendor. The following byte is used a vendor specific
-        * sub-type. */
-       if (elen < 4) {
-               if (show_errors) {
-                       DBG_8723A("short vendor specific "
-                                  "information element ignored (len =%lu)\n",
-                                  (unsigned long) elen);
-               }
-               return -1;
-       }
-
-       oui = RTW_GET_BE24(pos);
-       switch (oui) {
-       case WLAN_OUI_MICROSOFT:
-               /* Microsoft/Wi-Fi information elements are further typed and
-                * subtyped */
-               switch (pos[3]) {
-               case 1:
-                       /* Microsoft OUI (00:50:F2) with OUI Type 1:
-                        * real WPA information element */
-                       elems->wpa_ie = pos;
-                       elems->wpa_ie_len = elen;
-                       break;
-               case WME_OUI_TYPE: /* this is a Wi-Fi WME info. element */
-                       if (elen < 5) {
-                               DBG_8723A("short WME "
-                                          "information element ignored "
-                                          "(len =%lu)\n",
-                                          (unsigned long) elen);
-                               return -1;
-                       }
-                       switch (pos[4]) {
-                       case WME_OUI_SUBTYPE_INFORMATION_ELEMENT:
-                       case WME_OUI_SUBTYPE_PARAMETER_ELEMENT:
-                               elems->wme = pos;
-                               elems->wme_len = elen;
-                               break;
-                       case WME_OUI_SUBTYPE_TSPEC_ELEMENT:
-                               elems->wme_tspec = pos;
-                               elems->wme_tspec_len = elen;
-                               break;
-                       default:
-                               DBG_8723A("unknown WME "
-                                          "information element ignored "
-                                          "(subtype =%d len =%lu)\n",
-                                          pos[4], (unsigned long) elen);
-                               return -1;
-                       }
-                       break;
-               case 4:
-                       /* Wi-Fi Protected Setup (WPS) IE */
-                       elems->wps_ie = pos;
-                       elems->wps_ie_len = elen;
-                       break;
-               default:
-                       DBG_8723A("Unknown Microsoft "
-                                  "information element ignored "
-                                  "(type =%d len =%lu)\n",
-                                  pos[3], (unsigned long) elen);
-                       return -1;
-               }
-               break;
-
-       case OUI_BROADCOM:
-               switch (pos[3]) {
-               case VENDOR_HT_CAPAB_OUI_TYPE:
-                       elems->vendor_ht_cap = pos;
-                       elems->vendor_ht_cap_len = elen;
-                       break;
-               default:
-                       DBG_8723A("Unknown Broadcom "
-                                  "information element ignored "
-                                  "(type =%d len =%lu)\n",
-                                  pos[3], (unsigned long) elen);
-                       return -1;
-               }
-               break;
-
-       default:
-               DBG_8723A("unknown vendor specific information "
-                          "element ignored (vendor OUI %02x:%02x:%02x "
-                          "len =%lu)\n",
-                          pos[0], pos[1], pos[2], (unsigned long) elen);
-               return -1;
-       }
-
-       return 0;
-}
-
-/**
- * ieee802_11_parse_elems - Parse information elements in management frames
- * @start: Pointer to the start of IEs
- * @len: Length of IE buffer in octets
- * @elems: Data structure for parsed elements
- * @show_errors: Whether to show parsing errors in debug log
- * Returns: Parsing result
- */
-enum parse_res rtw_ieee802_11_parse_elems23a(u8 *start, uint len,
-                               struct rtw_ieee802_11_elems *elems,
-                               int show_errors)
-{
-       uint left = len;
-       u8 *pos = start;
-       int unknown = 0;
-
-       memset(elems, 0, sizeof(*elems));
-
-       while (left >= 2) {
-               u8 id, elen;
-
-               id = *pos++;
-               elen = *pos++;
-               left -= 2;
-
-               if (elen > left) {
-                       if (show_errors) {
-                               DBG_8723A("IEEE 802.11 element "
-                                          "parse failed (id =%d elen =%d "
-                                          "left =%lu)\n",
-                                          id, elen, (unsigned long) left);
-                       }
-                       return ParseFailed;
-               }
-
-               switch (id) {
-               case WLAN_EID_SSID:
-                       elems->ssid = pos;
-                       elems->ssid_len = elen;
-                       break;
-               case WLAN_EID_SUPP_RATES:
-                       elems->supp_rates = pos;
-                       elems->supp_rates_len = elen;
-                       break;
-               case WLAN_EID_FH_PARAMS:
-                       elems->fh_params = pos;
-                       elems->fh_params_len = elen;
-                       break;
-               case WLAN_EID_DS_PARAMS:
-                       elems->ds_params = pos;
-                       elems->ds_params_len = elen;
-                       break;
-               case WLAN_EID_CF_PARAMS:
-                       elems->cf_params = pos;
-                       elems->cf_params_len = elen;
-                       break;
-               case WLAN_EID_TIM:
-                       elems->tim = pos;
-                       elems->tim_len = elen;
-                       break;
-               case WLAN_EID_IBSS_PARAMS:
-                       elems->ibss_params = pos;
-                       elems->ibss_params_len = elen;
-                       break;
-               case WLAN_EID_CHALLENGE:
-                       elems->challenge = pos;
-                       elems->challenge_len = elen;
-                       break;
-               case WLAN_EID_ERP_INFO:
-                       elems->erp_info = pos;
-                       elems->erp_info_len = elen;
-                       break;
-               case WLAN_EID_EXT_SUPP_RATES:
-                       elems->ext_supp_rates = pos;
-                       elems->ext_supp_rates_len = elen;
-                       break;
-               case WLAN_EID_VENDOR_SPECIFIC:
-                       if (rtw_ieee802_11_parse_vendor_specific(pos, elen,
-                                                                elems,
-                                                                show_errors))
-                               unknown++;
-                       break;
-               case WLAN_EID_RSN:
-                       elems->rsn_ie = pos;
-                       elems->rsn_ie_len = elen;
-                       break;
-               case WLAN_EID_PWR_CAPABILITY:
-                       elems->power_cap = pos;
-                       elems->power_cap_len = elen;
-                       break;
-               case WLAN_EID_SUPPORTED_CHANNELS:
-                       elems->supp_channels = pos;
-                       elems->supp_channels_len = elen;
-                       break;
-               case WLAN_EID_MOBILITY_DOMAIN:
-                       elems->mdie = pos;
-                       elems->mdie_len = elen;
-                       break;
-               case WLAN_EID_FAST_BSS_TRANSITION:
-                       elems->ftie = pos;
-                       elems->ftie_len = elen;
-                       break;
-               case WLAN_EID_TIMEOUT_INTERVAL:
-                       elems->timeout_int = pos;
-                       elems->timeout_int_len = elen;
-                       break;
-               case WLAN_EID_HT_CAPABILITY:
-                       elems->ht_capabilities = pos;
-                       elems->ht_capabilities_len = elen;
-                       break;
-               case WLAN_EID_HT_OPERATION:
-                       elems->ht_operation = pos;
-                       elems->ht_operation_len = elen;
-                       break;
-               default:
-                       unknown++;
-                       if (!show_errors)
-                               break;
-                       DBG_8723A("IEEE 802.11 element parse "
-                                  "ignored unknown element (id =%d elen =%d)\n",
-                                  id, elen);
-                       break;
-               }
-
-               left -= elen;
-               pos += elen;
-       }
-
-       if (left)
-               return ParseFailed;
-
-       return unknown ? ParseUnknown : ParseOK;
-}
-
 static u8 key_char2num(u8 ch)
 {
        if ((ch >= '0') && (ch <= '9'))
@@ -1214,387 +927,26 @@ void rtw_macaddr_cfg23a(u8 *mac_addr)
                  MAC_ARG(mac_addr));
 }
 
-void dump_ies23a(u8 *buf, u32 buf_len) {
-       u8* pos = (u8*)buf;
-       u8 id, len;
-
-       while (pos-buf <= buf_len) {
-               id = *pos;
-               len = *(pos + 1);
-
-               DBG_8723A("%s ID:%u, LEN:%u\n", __func__, id, len);
-#ifdef CONFIG_8723AU_P2P
-               dump_p2p_ie23a(pos, len);
-#endif
-               dump_wps_ie23a(pos, len);
-
-               pos += (2 + len);
-       }
-}
-
-void dump_wps_ie23a(u8 *ie, u32 ie_len) {
-       u8* pos = (u8*)ie;
-       u16 id;
-       u16 len;
-
-       u8 *wps_ie;
-       uint wps_ielen;
-
-       wps_ie = rtw_get_wps_ie23a(ie, ie_len, NULL, &wps_ielen);
-       if (wps_ie != ie || wps_ielen == 0)
-               return;
-
-       pos+= 6;
-       while (pos-ie < ie_len) {
-               id = get_unaligned_be16(pos);
-               len = get_unaligned_be16(pos + 2);
-
-               DBG_8723A("%s ID:0x%04x, LEN:%u\n", __func__, id, len);
-
-               pos += (4 + len);
-       }
-}
-
-#ifdef CONFIG_8723AU_P2P
-void dump_p2p_ie23a(u8 *ie, u32 ie_len) {
-       u8* pos = (u8*)ie;
-       u8 id;
-       u16 len;
-
-       u8 *p2p_ie;
-       uint p2p_ielen;
-
-       p2p_ie = rtw_get_p2p_ie23a(ie, ie_len, NULL, &p2p_ielen);
-       if (p2p_ie != ie || p2p_ielen == 0)
-               return;
-
-       pos += 6;
-       while (pos-ie < ie_len) {
-               id = *pos;
-               len = get_unaligned_le16(pos+1);
-
-               DBG_8723A("%s ID:%u, LEN:%u\n", __func__, id, len);
-
-               pos+= (3+len);
-       }
-}
-
-/**
- * rtw_get_p2p_ie23a - Search P2P IE from a series of IEs
- * @in_ie: Address of IEs to search
- * @in_len: Length limit from in_ie
- * @p2p_ie: If not NULL and P2P IE is found, P2P IE will be copied to the
- *          buf starting from p2p_ie
- * @p2p_ielen: If not NULL and P2P IE is found, will set to the length of
- *             the entire P2P IE
- *
- * Returns: The address of the P2P IE found, or NULL
- */
-u8 *rtw_get_p2p_ie23a(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen)
-{
-       uint cnt = 0;
-       u8 *p2p_ie_ptr;
-       u8 eid, p2p_oui[4]={0x50, 0x6F, 0x9A, 0x09};
-
-       if (p2p_ielen)
-               *p2p_ielen = 0;
-
-       while (cnt<in_len) {
-               eid = in_ie[cnt];
-               if ((in_len < 0) || (cnt > MAX_IE_SZ)) {
-                       dump_stack();
-                       return NULL;
-               }
-               if ((eid == _VENDOR_SPECIFIC_IE_) &&
-                   !memcmp(&in_ie[cnt + 2], p2p_oui, 4)) {
-                       p2p_ie_ptr = in_ie + cnt;
-
-                       if (p2p_ie != NULL) {
-                               memcpy(p2p_ie, &in_ie[cnt],
-                                      in_ie[cnt + 1] + 2);
-                       }
-
-                       if (p2p_ielen != NULL) {
-                               *p2p_ielen = in_ie[cnt + 1] + 2;
-                       }
-
-                       return p2p_ie_ptr;
-
-                       break;
-               } else {
-                       cnt += in_ie[cnt + 1] + 2; /* goto next */
-               }
-       }
-
-       return NULL;
-}
-
-/**
- * rtw_get_p2p_attr23a - Search a specific P2P attribute from a given P2P IE
- * @p2p_ie: Address of P2P IE to search
- * @p2p_ielen: Length limit from p2p_ie
- * @target_attr_id: The attribute ID of P2P attribute to search
- * @buf_attr: If not NULL and the P2P attribute is found, P2P attribute will
- *            be copied to the buf starting from buf_attr
- * @len_attr: If not NULL and the P2P attribute is found, will set to the
- *            length of the entire P2P attribute
- *
- * Returns: the address of the specific WPS attribute found, or NULL
- */
-u8 *rtw_get_p2p_attr23a(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id,
-                    u8 *buf_attr, u32 *len_attr)
-{
-       u8 *attr_ptr = NULL;
-       u8 *target_attr_ptr = NULL;
-       u8 p2p_oui[4]={0x50, 0x6F, 0x9A, 0x09};
-
-       if (len_attr)
-               *len_attr = 0;
-
-       if (!p2p_ie || (p2p_ie[0] != _VENDOR_SPECIFIC_IE_) ||
-           memcmp(p2p_ie + 2, p2p_oui, 4)) {
-               return attr_ptr;
-       }
-
-       /*  6 = 1(Element ID) + 1(Length) + 3 (OUI) + 1(OUI Type) */
-       attr_ptr = p2p_ie + 6; /* goto first attr */
-
-       while (attr_ptr - p2p_ie < p2p_ielen) {
-               /*  3 = 1(Attribute ID) + 2(Length) */
-               u8 attr_id = *attr_ptr;
-               u16 attr_data_len = get_unaligned_le16(attr_ptr + 1);
-               u16 attr_len = attr_data_len + 3;
-
-               /* DBG_8723A("%s attr_ptr:%p, id:%u, length:%u\n", __func__, attr_ptr, attr_id, attr_data_len); */
-               if (attr_id == target_attr_id) {
-                       target_attr_ptr = attr_ptr;
-
-                       if (buf_attr)
-                               memcpy(buf_attr, attr_ptr, attr_len);
-
-                       if (len_attr)
-                               *len_attr = attr_len;
-
-                       break;
-               } else {
-                       attr_ptr += attr_len; /* goto next */
-               }
-       }
-
-       return target_attr_ptr;
-}
-
-/**
- * rtw_get_p2p_attr23a_content - Search a specific P2P attribute content from
- * a given P2P IE
- * @p2p_ie: Address of P2P IE to search
- * @p2p_ielen: Length limit from p2p_ie
- * @target_attr_id: The attribute ID of P2P attribute to search
- * @buf_content: If not NULL and the P2P attribute is found, P2P attribute
- *               content will be copied to the buf starting from buf_content
- * @len_content: If not NULL and the P2P attribute is found, will set to the
- *               length of the P2P attribute content
- *
- * Returns: the address of the specific P2P attribute content found, or NULL
- */
-u8 *rtw_get_p2p_attr23a_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id,
-                            u8 *buf_content, uint *len_content)
-{
-       u8 *attr_ptr;
-       u32 attr_len;
-
-       if (len_content)
-               *len_content = 0;
-
-       attr_ptr = rtw_get_p2p_attr23a(p2p_ie, p2p_ielen, target_attr_id,
-                                   NULL, &attr_len);
-
-       if (attr_ptr && attr_len) {
-               if (buf_content)
-                       memcpy(buf_content, attr_ptr + 3, attr_len - 3);
-
-               if (len_content)
-                       *len_content = attr_len - 3;
-
-               return attr_ptr+3;
-       }
-
-       return NULL;
-}
-
-u32 rtw_set_p2p_attr_content23a(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_attr)
-{
-       u32 a_len;
-
-       *pbuf = attr_id;
-
-       /* u16*)(pbuf + 1) = cpu_to_le16(attr_len); */
-       put_unaligned_le16(attr_len, pbuf + 1);
-
-       if (pdata_attr)
-               memcpy(pbuf + 3, pdata_attr, attr_len);
-
-       a_len = attr_len + 3;
-
-       return a_len;
-}
-
-static uint rtw_p2p_attr_remove(u8 *ie, uint ielen_ori, u8 attr_id)
-{
-       u8 *target_attr;
-       u32 target_attr_len;
-       uint ielen = ielen_ori;
-
-       while(1) {
-               target_attr = rtw_get_p2p_attr23a(ie, ielen, attr_id, NULL,
-                                            &target_attr_len);
-               if (target_attr && target_attr_len) {
-                       u8 *next_attr = target_attr+target_attr_len;
-                       uint remain_len = ielen-(next_attr-ie);
-                       /* dump_ies23a(ie, ielen); */
-
-                       memset(target_attr, 0, target_attr_len);
-                       memcpy(target_attr, next_attr, remain_len);
-                       memset(target_attr+remain_len, 0, target_attr_len);
-                       *(ie + 1) -= target_attr_len;
-                       ielen -= target_attr_len;
-               } else {
-                       /* if (index>0) */
-                       /*      dump_ies23a(ie, ielen); */
-                       break;
-               }
-       }
-
-       return ielen;
-}
-
-void rtw_wlan_bssid_ex_remove_p2p_attr23a(struct wlan_bssid_ex *bss_ex, u8 attr_id)
-{
-       u8 *p2p_ie;
-       uint p2p_ielen, p2p_ielen_ori;
-
-       if ((p2p_ie = rtw_get_p2p_ie23a(bss_ex->IEs + _FIXED_IE_LENGTH_,
-                                    bss_ex->IELength - _FIXED_IE_LENGTH_,
-                                    NULL, &p2p_ielen_ori))) {
-               p2p_ielen = rtw_p2p_attr_remove(p2p_ie, p2p_ielen_ori, attr_id);
-               if (p2p_ielen != p2p_ielen_ori) {
-                       u8 *next_ie_ori = p2p_ie+p2p_ielen_ori;
-                       u8 *next_ie = p2p_ie+p2p_ielen;
-                       uint remain_len;
-                       remain_len = bss_ex->IELength-(next_ie_ori-bss_ex->IEs);
-
-                       memcpy(next_ie, next_ie_ori, remain_len);
-                       memset(next_ie+remain_len, 0, p2p_ielen_ori-p2p_ielen);
-                       bss_ex->IELength -= p2p_ielen_ori-p2p_ielen;
-               }
-       }
-}
-
-#endif /* CONFIG_8723AU_P2P */
-
-#ifdef CONFIG_8723AU_P2P
-int rtw_get_wfd_ie(u8 *in_ie, int in_len, u8 *wfd_ie, uint *wfd_ielen)
-{
-       int match;
-       const u8 *ie;
-
-       match = 0;
-
-       if (in_len < 0)
-               return match;
-
-       ie = cfg80211_find_vendor_ie(0x506F9A, 0x0A, in_ie, in_len);
-       if (ie && (ie[1] <= (MAX_WFD_IE_LEN - 2))) {
-               if (wfd_ie) {
-                       *wfd_ielen = ie[1] + 2;
-                       memcpy(wfd_ie, ie, ie[1] + 2);
-               } else
-                       if (wfd_ielen)
-                               *wfd_ielen = 0;
-
-               match = 1;
-       }
-
-       return match;
-}
-
-/*     attr_content: The output buffer, contains the "body field" of
-       WFD attribute. */
-/*     attr_contentlen: The data length of the "body field" of WFD
-       attribute. */
-int rtw_get_wfd_attr_content(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id,
-                            u8 *attr_content, uint *attr_contentlen)
-{
-       int match;
-       uint cnt = 0;
-       u8 attr_id, wfd_oui[4] = {0x50, 0x6F, 0x9A, 0x0A};
-
-       match = false;
-
-       if ((wfd_ie[0] != _VENDOR_SPECIFIC_IE_) ||
-           memcmp(wfd_ie + 2, wfd_oui, 4)) {
-               return match;
-       }
-
-       /*      1 (WFD IE) + 1 (Length) + 3 (OUI) + 1 (OUI Type) */
-       cnt = 6;
-       while (cnt < wfd_ielen) {
-               u16 attrlen = get_unaligned_be16(wfd_ie + cnt + 1);
-
-               attr_id = wfd_ie[cnt];
-               if (attr_id == target_attr_id) {
-                       /*      3 -> 1 byte for attribute ID field, 2
-                               bytes for length field */
-                       if (attr_content)
-                               memcpy(attr_content, &wfd_ie[cnt + 3], attrlen);
-
-                       if (attr_contentlen)
-                               *attr_contentlen = attrlen;
-
-                       cnt += attrlen + 3;
-
-                       match = true;
-                       break;
-               } else {
-                       cnt += attrlen + 3; /* goto next */
-               }
-       }
-
-       return match;
-}
-#endif /*  CONFIG_8723AU_P2P */
-
-/* Baron adds to avoid FreeBSD warning */
-int ieee80211_is_empty_essid23a(const char *essid, int essid_len)
-{
-       /* Single white space is for Linksys APs */
-       if (essid_len == 1 && essid[0] == ' ')
-               return 1;
-
-       /* Otherwise, if the entire essid is 0, we assume it is hidden */
-       while (essid_len) {
-               essid_len--;
-               if (essid[essid_len] != '\0')
-                       return 0;
-       }
-
-       return 1;
-}
-
 static int rtw_get_cipher_info(struct wlan_network *pnetwork)
 {
-       u32 wpa_ielen;
-       unsigned char *pbuf;
+       const u8 *pbuf;
        int group_cipher = 0, pairwise_cipher = 0, is8021x = 0;
        int ret = _FAIL;
-       int r;
-       pbuf = rtw_get_wpa_ie23a(&pnetwork->network.IEs[12], &wpa_ielen,
-                             pnetwork->network.IELength - 12);
+       int r, offset, plen;
+       char *pie;
+
+       offset = offsetof(struct ieee80211_mgmt, u.beacon.variable) -
+               offsetof(struct ieee80211_mgmt, u);
+       pie = &pnetwork->network.IEs[offset];
+       plen = pnetwork->network.IELength - offset;
 
-       if (pbuf && (wpa_ielen > 0)) {
+       pbuf = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
+                                      WLAN_OUI_TYPE_MICROSOFT_WPA, pie, plen);
+
+       if (pbuf && pbuf[1] > 0) {
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                        ("rtw_get_cipher_info: wpa_ielen: %d", wpa_ielen));
-               r = rtw_parse_wpa_ie23a(pbuf, wpa_ielen + 2, &group_cipher,
+                        ("rtw_get_cipher_info: wpa_ielen: %d", pbuf[1]));
+               r = rtw_parse_wpa_ie23a(pbuf, pbuf[1] + 2, &group_cipher,
                                     &pairwise_cipher, &is8021x);
                if (r == _SUCCESS) {
                        pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher;
@@ -1608,13 +960,12 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork)
                        ret = _SUCCESS;
                }
        } else {
-               pbuf = rtw_get_wpa2_ie23a(&pnetwork->network.IEs[12], &wpa_ielen,
-                                      pnetwork->network.IELength - 12);
+               pbuf = cfg80211_find_ie(WLAN_EID_RSN, pie, plen);
 
-               if (pbuf && (wpa_ielen > 0)) {
+               if (pbuf && pbuf[1] > 0) {
                        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
                                 ("get RSN IE\n"));
-                       r = rtw_parse_wpa2_ie23a(pbuf, wpa_ielen + 2,
+                       r = rtw_parse_wpa2_ie23a(pbuf, pbuf[1] + 2,
                                              &group_cipher, &pairwise_cipher,
                                              &is8021x);
                        if (r == _SUCCESS) {
@@ -1650,8 +1001,8 @@ void rtw_get_bcn_info23a(struct wlan_network *pnetwork)
        unsigned int            len;
        unsigned char           *p;
 
-       memcpy(&cap, rtw_get_capability23a_from_ie(pnetwork->network.IEs), 2);
-       cap = le16_to_cpu(cap);
+       cap = get_unaligned_le16(
+               rtw_get_capability23a_from_ie(pnetwork->network.IEs));
        if (cap & WLAN_CAPABILITY_PRIVACY) {
                bencrypt = 1;
                pnetwork->network.Privacy = 1;
@@ -1690,8 +1041,8 @@ void rtw_get_bcn_info23a(struct wlan_network *pnetwork)
        /* get bwmode and ch_offset */
        /* parsing HT_CAP_IE */
        p = rtw_get_ie23a(pnetwork->network.IEs + _FIXED_IE_LENGTH_,
-                      _HT_CAPABILITY_IE_, &len,
-                      pnetwork->network.IELength - _FIXED_IE_LENGTH_);
+                         WLAN_EID_HT_CAPABILITY, &len,
+                         pnetwork->network.IELength - _FIXED_IE_LENGTH_);
        if (p && len > 0) {
                pht_cap = (struct ieee80211_ht_cap *)(p + 2);
                pnetwork->BcnInfo.ht_cap_info = pht_cap->cap_info;
@@ -1700,7 +1051,7 @@ void rtw_get_bcn_info23a(struct wlan_network *pnetwork)
        }
        /* parsing HT_INFO_IE */
        p = rtw_get_ie23a(pnetwork->network.IEs + _FIXED_IE_LENGTH_,
-                      _HT_ADD_INFO_IE_, &len,
+                      WLAN_EID_HT_OPERATION, &len,
                       pnetwork->network.IELength - _FIXED_IE_LENGTH_);
        if (p && len > 0) {
                pht_info = (struct HT_info_element *)(p + 2);
index 1cae8d7659b98af4244866bfe4b3a318fe57d225..01022113950af9081d9341c8220b6e085dd7f330 100644 (file)
@@ -44,10 +44,9 @@ jackson@realtek.com.tw
 u8 _rtw_read823a(struct rtw_adapter *adapter, u32 addr)
 {
        u8 r_val;
-       struct io_priv *pio_priv = &adapter->iopriv;
-       struct intf_hdl *pintfhdl = &pio_priv->intf;
+       struct _io_ops *io_ops = &adapter->io_ops;
 
-       r_val = pintfhdl->io_ops._read8(pintfhdl, addr);
+       r_val = io_ops->_read8(adapter, addr);
 
        return r_val;
 }
@@ -55,10 +54,9 @@ u8 _rtw_read823a(struct rtw_adapter *adapter, u32 addr)
 u16 _rtw_read1623a(struct rtw_adapter *adapter, u32 addr)
 {
        u16 r_val;
-       struct io_priv *pio_priv = &adapter->iopriv;
-       struct intf_hdl *pintfhdl = &pio_priv->intf;
+       struct _io_ops *io_ops = &adapter->io_ops;
 
-       r_val = pintfhdl->io_ops._read16(pintfhdl, addr);
+       r_val = io_ops->_read16(adapter, addr);
 
        return le16_to_cpu(r_val);
 }
@@ -66,95 +64,57 @@ u16 _rtw_read1623a(struct rtw_adapter *adapter, u32 addr)
 u32 _rtw_read3223a(struct rtw_adapter *adapter, u32 addr)
 {
        u32 r_val;
-       struct io_priv *pio_priv = &adapter->iopriv;
-       struct intf_hdl *pintfhdl = &pio_priv->intf;
+       struct _io_ops *io_ops = &adapter->io_ops;
 
-       r_val = pintfhdl->io_ops._read32(pintfhdl, addr);
+       r_val = io_ops->_read32(adapter, addr);
 
        return le32_to_cpu(r_val);
 }
 
 int _rtw_write823a(struct rtw_adapter *adapter, u32 addr, u8 val)
 {
-       struct io_priv *pio_priv = &adapter->iopriv;
-       struct intf_hdl         *pintfhdl = &pio_priv->intf;
+       struct _io_ops *io_ops = &adapter->io_ops;
        int ret;
 
-       ret = pintfhdl->io_ops._write8(pintfhdl, addr, val);
+       ret = io_ops->_write8(adapter, addr, val);
 
        return RTW_STATUS_CODE23a(ret);
 }
 
 int _rtw_write1623a(struct rtw_adapter *adapter, u32 addr, u16 val)
 {
-       struct io_priv *pio_priv = &adapter->iopriv;
-       struct intf_hdl         *pintfhdl = &pio_priv->intf;
+       struct _io_ops *io_ops = &adapter->io_ops;
        int ret;
 
        val = cpu_to_le16(val);
-       ret = pintfhdl->io_ops._write16(pintfhdl, addr, val);
+       ret = io_ops->_write16(adapter, addr, val);
 
        return RTW_STATUS_CODE23a(ret);
 }
+
 int _rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val)
 {
-       struct io_priv *pio_priv = &adapter->iopriv;
-       struct intf_hdl *pintfhdl = &pio_priv->intf;
+       struct _io_ops *io_ops = &adapter->io_ops;
        int ret;
 
        val = cpu_to_le32(val);
-       ret = pintfhdl->io_ops._write32(pintfhdl, addr, val);
+       ret = io_ops->_write32(adapter, addr, val);
 
        return RTW_STATUS_CODE23a(ret);
 }
 
 int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr , u32 length , u8 *pdata)
 {
-       struct io_priv *pio_priv = &adapter->iopriv;
-        struct intf_hdl *pintfhdl = (struct intf_hdl*)&pio_priv->intf;
-       int ret;
-
-       ret = pintfhdl->io_ops._writeN(pintfhdl, addr, length, pdata);
-
-       return RTW_STATUS_CODE23a(ret);
-}
-int _rtw_write823a_async23a(struct rtw_adapter *adapter, u32 addr, u8 val)
-{
-       struct io_priv *pio_priv = &adapter->iopriv;
-       struct intf_hdl *pintfhdl = &pio_priv->intf;
+       struct _io_ops *io_ops = &adapter->io_ops;
        int ret;
 
-       ret = pintfhdl->io_ops._write8_async(pintfhdl, addr, val);
+       ret = io_ops->_writeN(adapter, addr, length, pdata);
 
        return RTW_STATUS_CODE23a(ret);
 }
-int _rtw_write1623a_async(struct rtw_adapter *adapter, u32 addr, u16 val)
-{
-       struct io_priv *pio_priv = &adapter->iopriv;
-       struct intf_hdl *pintfhdl = &pio_priv->intf;
-       int ret;
-
-       val = cpu_to_le16(val);
-       ret = pintfhdl->io_ops._write16_async(pintfhdl, addr, val);
-
-       return RTW_STATUS_CODE23a(ret);
-}
-int _rtw_write3223a_async23a(struct rtw_adapter *adapter, u32 addr, u32 val)
-{
-       struct io_priv *pio_priv = &adapter->iopriv;
-       struct intf_hdl *pintfhdl = &pio_priv->intf;
-       int ret;
-
-       val = cpu_to_le32(val);
-       ret = pintfhdl->io_ops._write32_async(pintfhdl, addr, val);
-
-       return RTW_STATUS_CODE23a(ret);
-}
-
 void _rtw_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
 {
-       struct io_priv *pio_priv = &adapter->iopriv;
-       struct intf_hdl *pintfhdl = &pio_priv->intf;
+       struct _io_ops *io_ops = &adapter->io_ops;
 
        if ((adapter->bDriverStopped == true) ||
            (adapter->bSurpriseRemoved == true)) {
@@ -165,22 +125,20 @@ void _rtw_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
             return;
        }
 
-       pintfhdl->io_ops._read_mem(pintfhdl, addr, cnt, pmem);
+       io_ops->_read_mem(adapter, addr, cnt, pmem);
 }
 
 void _rtw_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
 {
-       struct io_priv *pio_priv = &adapter->iopriv;
-       struct intf_hdl *pintfhdl = &pio_priv->intf;
+       struct _io_ops *io_ops = &adapter->io_ops;
 
-       pintfhdl->io_ops._write_mem(pintfhdl, addr, cnt, pmem);
+       io_ops->_write_mem(adapter, addr, cnt, pmem);
 }
 
 void _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt,
-                   struct recv_buf *rbuf)
+                      struct recv_buf *rbuf)
 {
-       struct io_priv *pio_priv = &adapter->iopriv;
-       struct intf_hdl *pintfhdl = &pio_priv->intf;
+       struct _io_ops *io_ops = &adapter->io_ops;
 
        if ((adapter->bDriverStopped == true) ||
            (adapter->bSurpriseRemoved == true)) {
@@ -191,76 +149,38 @@ void _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt,
             return;
        }
 
-       pintfhdl->io_ops._read_port(pintfhdl, addr, cnt, rbuf);
+       io_ops->_read_port(adapter, addr, cnt, rbuf);
 }
 
 void _rtw_read_port23a_cancel(struct rtw_adapter *adapter)
 {
-       void (*_read_port_cancel)(struct intf_hdl *pintfhdl);
-       struct io_priv *pio_priv = &adapter->iopriv;
-       struct intf_hdl *pintfhdl = &pio_priv->intf;
+       void (*_read_port_cancel)(struct rtw_adapter *adapter);
+       struct _io_ops *io_ops = &adapter->io_ops;
 
-       _read_port_cancel = pintfhdl->io_ops._read_port_cancel;
+       _read_port_cancel = io_ops->_read_port_cancel;
 
        if (_read_port_cancel)
-               _read_port_cancel(pintfhdl);
+               _read_port_cancel(adapter);
 }
 
 u32 _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt,
                    struct xmit_buf *xbuf)
 {
-       struct io_priv *pio_priv = &adapter->iopriv;
-       struct intf_hdl *pintfhdl = &pio_priv->intf;
+       struct _io_ops *io_ops = &adapter->io_ops;
        u32 ret = _SUCCESS;
 
-       ret = pintfhdl->io_ops._write_port(pintfhdl, addr, cnt, xbuf);
-
-       return ret;
-}
-
-u32 _rtw_write_port23a_and_wait23a(struct rtw_adapter *adapter, u32 addr, u32 cnt,
-                            struct xmit_buf *pxmitbuf, int timeout_ms)
-{
-       int ret = _SUCCESS;
-       struct submit_ctx sctx;
-
-       rtw_sctx_init23a(&sctx, timeout_ms);
-       pxmitbuf->sctx = &sctx;
-
-       ret = _rtw_write_port23a(adapter, addr, cnt, pxmitbuf);
-
-       if (ret == _SUCCESS)
-               ret = rtw_sctx_wait23a(&sctx);
+       ret = io_ops->_write_port(adapter, addr, cnt, xbuf);
 
        return ret;
 }
 
 void _rtw_write_port23a_cancel(struct rtw_adapter *adapter)
 {
-       void (*_write_port_cancel)(struct intf_hdl *pintfhdl);
-       struct io_priv *pio_priv = &adapter->iopriv;
-       struct intf_hdl *pintfhdl = &pio_priv->intf;
+       void (*_write_port_cancel)(struct rtw_adapter *adapter);
+       struct _io_ops *io_ops = &adapter->io_ops;
 
-       _write_port_cancel = pintfhdl->io_ops._write_port_cancel;
+       _write_port_cancel = io_ops->_write_port_cancel;
 
        if (_write_port_cancel)
-               _write_port_cancel(pintfhdl);
-}
-
-int rtw_init_io_priv23a(struct rtw_adapter *padapter,
-                    void (*set_intf_ops)(struct _io_ops *pops))
-{
-       struct io_priv  *piopriv = &padapter->iopriv;
-       struct intf_hdl *pintf = &piopriv->intf;
-
-       if (set_intf_ops == NULL)
-               return _FAIL;
-
-       piopriv->padapter = padapter;
-       pintf->padapter = padapter;
-       pintf->pintf_dev = adapter_to_dvobj(padapter);
-
-       set_intf_ops(&pintf->io_ops);
-
-       return _SUCCESS;
+               _write_port_cancel(adapter);
 }
index 30d7185e5637d719b1b27593a39282f4e14b202d..b03266bc1f3c63803efc41a27e00800948c6984a 100644 (file)
@@ -54,7 +54,7 @@ u8 rtw_do_join23a(struct rtw_adapter *padapter)
                /* we try to issue sitesurvey firstly */
 
                if (pmlmepriv->LinkDetectInfo.bBusyTraffic == false ||
-                   rtw_to_roaming(padapter) > 0) {
+                   padapter->mlmepriv.to_roaming > 0) {
                        RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
                                 ("rtw_do_join23a(): site survey if scanned_queue "
                                  "is empty\n."));
@@ -130,7 +130,7 @@ u8 rtw_do_join23a(struct rtw_adapter *padapter)
                                   queue */
                                /* we try to issue sitesurvey firstly */
                                if (pmlmepriv->LinkDetectInfo.bBusyTraffic ==
-                                   false || rtw_to_roaming(padapter) > 0) {
+                                   false || padapter->mlmepriv.to_roaming > 0){
                                        /* DBG_8723A("rtw_do_join23a() when   no "
                                           "desired bss in scanning queue\n");
                                        */
@@ -280,27 +280,26 @@ exit:
 }
 
 u8 rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter* padapter,
-       enum ndis_802_11_net_infra networktype)
+                                        enum ndis_802_11_net_infra networktype)
 {
-       struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
-       struct  wlan_network    *cur_network = &pmlmepriv->cur_network;
-       enum ndis_802_11_net_infra* pold_state = &cur_network->network.InfrastructureMode;
-
+       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+       struct wlan_network *cur_network = &pmlmepriv->cur_network;
+       enum ndis_802_11_net_infra* pold_state;
 
+       pold_state = &cur_network->network.InfrastructureMode;
 
        RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_,
-                ("+rtw_set_802_11_infrastructure_mode23a: old =%d new =%d fw_state = 0x%08x\n",
+                ("+rtw_set_802_11_infrastructure_mode23a: old =%d new =%d "
+                 "fw_state = 0x%08x\n",
                  *pold_state, networktype, get_fwstate(pmlmepriv)));
 
-       if (*pold_state != networktype)
-       {
+       if (*pold_state != networktype) {
                spin_lock_bh(&pmlmepriv->lock);
 
-               RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, (" change mode!"));
-               /* DBG_8723A("change mode, old_mode =%d, new_mode =%d, fw_state = 0x%x\n", *pold_state, networktype, get_fwstate(pmlmepriv)); */
+               RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
+                        (" change mode!"));
 
-               if (*pold_state == Ndis802_11APMode)
-               {
+               if (*pold_state == Ndis802_11APMode) {
                        /* change to other mode from Ndis802_11APMode */
                        cur_network->join_res = -1;
 
@@ -309,18 +308,21 @@ u8 rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter* padapter,
 #endif
                }
 
-               if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) ||(*pold_state == Ndis802_11IBSS))
+               if (check_fwstate(pmlmepriv, _FW_LINKED) ||
+                   *pold_state == Ndis802_11IBSS)
                        rtw_disassoc_cmd23a(padapter, 0, true);
 
-               if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) ||
-                       (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true))
+               if (check_fwstate(pmlmepriv, _FW_LINKED) ||
+                   check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))
                        rtw_free_assoc_resources23a(padapter, 1);
 
-               if ((*pold_state == Ndis802_11Infrastructure) ||(*pold_state == Ndis802_11IBSS))
-              {
-                       if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
-                       {
-                               rtw_indicate_disconnect23a(padapter); /* will clr Linked_state; before this function, we must have chked whether  issue dis-assoc_cmd or not */
+               if (*pold_state == Ndis802_11Infrastructure ||
+                   *pold_state == Ndis802_11IBSS) {
+                       if (check_fwstate(pmlmepriv, _FW_LINKED)) {
+                               /* will clr Linked_state; before this function,
+                                  we must have chked whether issue
+                                  dis-assoc_cmd or not */
+                               rtw_indicate_disconnect23a(padapter);
                        }
               }
 
@@ -330,38 +332,36 @@ u8 rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter* padapter,
 
                switch (networktype)
                {
-                       case Ndis802_11IBSS:
-                               set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
-                               break;
+               case Ndis802_11IBSS:
+                       set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
+                       break;
 
-                       case Ndis802_11Infrastructure:
-                               set_fwstate(pmlmepriv, WIFI_STATION_STATE);
-                               break;
+               case Ndis802_11Infrastructure:
+                       set_fwstate(pmlmepriv, WIFI_STATION_STATE);
+                       break;
 
-                       case Ndis802_11APMode:
-                               set_fwstate(pmlmepriv, WIFI_AP_STATE);
+               case Ndis802_11APMode:
+                       set_fwstate(pmlmepriv, WIFI_AP_STATE);
 #ifdef CONFIG_8723AU_AP_MODE
-                               start_ap_mode23a(padapter);
-                               /* rtw_indicate_connect23a(padapter); */
+                       start_ap_mode23a(padapter);
+                       /* rtw_indicate_connect23a(padapter); */
 #endif
+                       break;
 
-                               break;
-
-                       case Ndis802_11AutoUnknown:
-                       case Ndis802_11InfrastructureMax:
-                               break;
+               case Ndis802_11AutoUnknown:
+               case Ndis802_11InfrastructureMax:
+                       break;
                }
 
                /* SecClearAllKeys(adapter); */
 
-               /* RT_TRACE(COMP_OID_SET, DBG_LOUD, ("set_infrastructure: fw_state:%x after changing mode\n", */
-               /*                                                                      get_fwstate(pmlmepriv))); */
+               /* RT_TRACE(COMP_OID_SET, DBG_LOUD,
+                  ("set_infrastructure: fw_state:%x after changing mode\n", */
+               /* get_fwstate(pmlmepriv))); */
 
                spin_unlock_bh(&pmlmepriv->lock);
        }
 
-
-
        return true;
 }
 
@@ -539,7 +539,7 @@ exit:
 u16 rtw_get_cur_max_rate23a(struct rtw_adapter *adapter)
 {
        int i = 0;
-       u8 *p;
+       const u8 *p;
        u16 rate = 0, max_rate = 0;
        struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
@@ -550,16 +550,16 @@ u16 rtw_get_cur_max_rate23a(struct rtw_adapter *adapter)
        u8 rf_type = 0;
        u8 bw_40MHz = 0, short_GI_20 = 0, short_GI_40 = 0;
        u16 mcs_rate = 0;
-       u32 ht_ielen = 0;
 
        if (!check_fwstate(pmlmepriv, _FW_LINKED) &&
            !check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))
                return 0;
 
        if (pmlmeext->cur_wireless_mode & (WIRELESS_11_24N|WIRELESS_11_5N)) {
-               p = rtw_get_ie23a(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_,
-                              &ht_ielen, pcur_bss->IELength - 12);
-               if (p && ht_ielen > 0) {
+               p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY,
+                                    &pcur_bss->IEs[12],
+                                    pcur_bss->IELength - 12);
+               if (p && p[1] > 0) {
                        pht_capie = (struct ieee80211_ht_cap *)(p + 2);
 
                        memcpy(&mcs_rate, &pht_capie->mcs, 2);
@@ -577,8 +577,7 @@ u16 rtw_get_cur_max_rate23a(struct rtw_adapter *adapter)
                        short_GI_20 = (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info&IEEE80211_HT_CAP_SGI_20) ? 1:0;
                        short_GI_40 = (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info&IEEE80211_HT_CAP_SGI_40) ? 1:0;
 
-                       rtw23a_hal_get_hwreg(adapter, HW_VAR_RF_TYPE,
-                                         (u8 *)(&rf_type));
+                       rf_type = rtl8723a_get_rf_type(adapter);
                        max_rate = rtw_mcs_rate23a(rf_type, bw_40MHz &
                                                pregistrypriv->cbw40_enable,
                                                short_GI_20, short_GI_40,
index 6cee78785bdc671e09c14829002f958e5c63a6fe..8d64cb02ee8e8865df3e589f60ab973639fcdd73 100644 (file)
@@ -45,7 +45,7 @@ static void rtw_init_mlme_timer(struct rtw_adapter *padapter)
                    rtw_set_scan_deny_timer_hdl, (unsigned long)padapter);
 }
 
-int _rtw_init_mlme_priv23a(struct rtw_adapter *padapter)
+int rtw_init_mlme_priv23a(struct rtw_adapter *padapter)
 {
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        int res = _SUCCESS;
@@ -53,8 +53,11 @@ int _rtw_init_mlme_priv23a(struct rtw_adapter *padapter)
        pmlmepriv->nic_hdl = padapter;
 
        pmlmepriv->fw_state = 0;
-       pmlmepriv->cur_network.network.InfrastructureMode = Ndis802_11AutoUnknown;
-       pmlmepriv->scan_mode=SCAN_ACTIVE;/*  1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */
+       pmlmepriv->cur_network.network.InfrastructureMode =
+               Ndis802_11AutoUnknown;
+       /*  1: active, 0: pasive. Maybe someday we should rename this
+           varable to "active_mode" (Jeff) */
+       pmlmepriv->scan_mode = SCAN_ACTIVE;
 
        spin_lock_init(&pmlmepriv->lock);
        _rtw_init_queue23a(&pmlmepriv->scanned_queue);
@@ -72,11 +75,10 @@ int _rtw_init_mlme_priv23a(struct rtw_adapter *padapter)
 #ifdef CONFIG_8723AU_AP_MODE
 static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen)
 {
-       if(*ppie)
-       {
+       if (*ppie) {
                kfree(*ppie);
                *plen = 0;
-               *ppie=NULL;
+               *ppie = NULL;
        }
 }
 #endif
@@ -86,30 +88,45 @@ void rtw23a_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv)
 #ifdef CONFIG_8723AU_AP_MODE
        kfree(pmlmepriv->assoc_req);
        kfree(pmlmepriv->assoc_rsp);
-       rtw_free_mlme_ie_data(&pmlmepriv->wps_beacon_ie, &pmlmepriv->wps_beacon_ie_len);
-       rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_req_ie, &pmlmepriv->wps_probe_req_ie_len);
-       rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_resp_ie, &pmlmepriv->wps_probe_resp_ie_len);
-       rtw_free_mlme_ie_data(&pmlmepriv->wps_assoc_resp_ie, &pmlmepriv->wps_assoc_resp_ie_len);
-
-       rtw_free_mlme_ie_data(&pmlmepriv->p2p_beacon_ie, &pmlmepriv->p2p_beacon_ie_len);
-       rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_req_ie, &pmlmepriv->p2p_probe_req_ie_len);
-       rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_resp_ie, &pmlmepriv->p2p_probe_resp_ie_len);
-       rtw_free_mlme_ie_data(&pmlmepriv->p2p_go_probe_resp_ie, &pmlmepriv->p2p_go_probe_resp_ie_len);
-       rtw_free_mlme_ie_data(&pmlmepriv->p2p_assoc_req_ie, &pmlmepriv->p2p_assoc_req_ie_len);
-
-       rtw_free_mlme_ie_data(&pmlmepriv->wfd_beacon_ie, &pmlmepriv->wfd_beacon_ie_len);
-       rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_req_ie, &pmlmepriv->wfd_probe_req_ie_len);
-       rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_resp_ie, &pmlmepriv->wfd_probe_resp_ie_len);
-       rtw_free_mlme_ie_data(&pmlmepriv->wfd_go_probe_resp_ie, &pmlmepriv->wfd_go_probe_resp_ie_len);
-       rtw_free_mlme_ie_data(&pmlmepriv->wfd_assoc_req_ie, &pmlmepriv->wfd_assoc_req_ie_len);
+       rtw_free_mlme_ie_data(&pmlmepriv->wps_beacon_ie,
+                             &pmlmepriv->wps_beacon_ie_len);
+       rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_req_ie,
+                             &pmlmepriv->wps_probe_req_ie_len);
+       rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_resp_ie,
+                             &pmlmepriv->wps_probe_resp_ie_len);
+       rtw_free_mlme_ie_data(&pmlmepriv->wps_assoc_resp_ie,
+                             &pmlmepriv->wps_assoc_resp_ie_len);
+
+       rtw_free_mlme_ie_data(&pmlmepriv->p2p_beacon_ie,
+                             &pmlmepriv->p2p_beacon_ie_len);
+       rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_req_ie,
+                             &pmlmepriv->p2p_probe_req_ie_len);
+       rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_resp_ie,
+                             &pmlmepriv->p2p_probe_resp_ie_len);
+       rtw_free_mlme_ie_data(&pmlmepriv->p2p_go_probe_resp_ie,
+                             &pmlmepriv->p2p_go_probe_resp_ie_len);
+       rtw_free_mlme_ie_data(&pmlmepriv->p2p_assoc_req_ie,
+                             &pmlmepriv->p2p_assoc_req_ie_len);
+
+       rtw_free_mlme_ie_data(&pmlmepriv->wfd_beacon_ie,
+                             &pmlmepriv->wfd_beacon_ie_len);
+       rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_req_ie,
+                             &pmlmepriv->wfd_probe_req_ie_len);
+       rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_resp_ie,
+                             &pmlmepriv->wfd_probe_resp_ie_len);
+       rtw_free_mlme_ie_data(&pmlmepriv->wfd_go_probe_resp_ie,
+                             &pmlmepriv->wfd_go_probe_resp_ie_len);
+       rtw_free_mlme_ie_data(&pmlmepriv->wfd_assoc_req_ie,
+                             &pmlmepriv->wfd_assoc_req_ie_len);
 #endif
 }
 
-void _rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv)
+void rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv)
 {
+       RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
+                ("rtw_free_mlme_priv23a\n"));
 
        rtw23a_free_mlme_priv_ie_data(pmlmepriv);
-
 }
 
 struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv)
@@ -129,48 +146,27 @@ struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv)
        return pnetwork;
 }
 
-void _rtw_free_network23a(struct mlme_priv *pmlmepriv,
-                      struct wlan_network *pnetwork, u8 isfreeall)
+static void _rtw_free_network23a(struct mlme_priv *pmlmepriv,
+                                struct wlan_network *pnetwork)
 {
-       u32 lifetime = SCANQUEUE_LIFETIME;
-
        if (!pnetwork)
                return;
 
        if (pnetwork->fixed == true)
                return;
 
-       if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) ||
-           (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true))
-               lifetime = 1;
-
-       list_del_init(&pnetwork->list);
-
-       kfree(pnetwork);
-}
-
-void _rtw_free_network23a_nolock23a(struct mlme_priv *pmlmepriv,
-                             struct wlan_network *pnetwork)
-{
-
-       if (pnetwork == NULL)
-               return;
-
-       if (pnetwork->fixed == true)
-               return;
-
        list_del_init(&pnetwork->list);
 
        kfree(pnetwork);
 }
 
 /*
      return the wlan_network with the matching addr
+ return the wlan_network with the matching addr
 
      Shall be calle under atomic context... to avoid possible racing condition...
+ Shall be calle under atomic context... to avoid possible racing condition...
 */
 struct wlan_network *
-_rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr)
+rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr)
 {
        struct list_head *phead, *plist;
        struct wlan_network *pnetwork = NULL;
@@ -194,7 +190,7 @@ _rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr)
                plist = plist->next;
         }
 
-       if(plist == phead)
+       if (plist == phead)
                pnetwork = NULL;
 
        /* spin_unlock_bh(&scanned_queue->lock); */
@@ -204,11 +200,11 @@ exit:
        return pnetwork;
 }
 
-void _rtw_free_network23a_queue23a(struct rtw_adapter *padapter, u8 isfreeall)
+void rtw_free_network_queue23a(struct rtw_adapter *padapter)
 {
        struct list_head *phead, *plist, *ptmp;
        struct wlan_network *pnetwork;
-       struct mlme_privpmlmepriv = &padapter->mlmepriv;
+       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct rtw_queue *scanned_queue = &pmlmepriv->scanned_queue;
 
        spin_lock_bh(&scanned_queue->lock);
@@ -218,24 +214,25 @@ void _rtw_free_network23a_queue23a(struct rtw_adapter *padapter, u8 isfreeall)
        list_for_each_safe(plist, ptmp, phead) {
                pnetwork = container_of(plist, struct wlan_network, list);
 
-               _rtw_free_network23a(pmlmepriv,pnetwork, isfreeall);
+               _rtw_free_network23a(pmlmepriv, pnetwork);
        }
 
        spin_unlock_bh(&scanned_queue->lock);
-
 }
 
-int rtw_if_up23a(struct rtw_adapter *padapter) {
-
+int rtw_if_up23a(struct rtw_adapter *padapter)
+{
        int res;
 
-       if(padapter->bDriverStopped || padapter->bSurpriseRemoved ||
-               (check_fwstate(&padapter->mlmepriv, _FW_LINKED)== false)) {
-               RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_if_up23a:bDriverStopped(%d) OR bSurpriseRemoved(%d)", padapter->bDriverStopped, padapter->bSurpriseRemoved));
-               res=false;
-       }
-       else
-               res=  true;
+       if (padapter->bDriverStopped || padapter->bSurpriseRemoved ||
+           check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false) {
+               RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
+                        ("rtw_if_up23a:bDriverStopped(%d) OR "
+                         "bSurpriseRemoved(%d)", padapter->bDriverStopped,
+                         padapter->bSurpriseRemoved));
+               res = false;
+       } else
+               res =  true;
 
        return res;
 }
@@ -247,115 +244,114 @@ void rtw_generate_random_ibss23a(u8* pibss)
        pibss[0] = 0x02;  /* in ad-hoc mode bit1 must set to 1 */
        pibss[1] = 0x11;
        pibss[2] = 0x87;
-       pibss[3] = (u8)(curtime & 0xff) ;/* p[0]; */
-       pibss[4] = (u8)((curtime>>8) & 0xff) ;/* p[1]; */
-       pibss[5] = (u8)((curtime>>16) & 0xff) ;/* p[2]; */
+       pibss[3] = curtime & 0xff;/* p[0]; */
+       pibss[4] = (curtime >> 8) & 0xff;/* p[1]; */
+       pibss[5] = (curtime >> 16) & 0xff;/* p[2]; */
 
        return;
 }
 
-u8 *rtw_get_capability23a_from_ie(u8 *ie)
+void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming)
 {
-       return ie + 8 + 2;
+       if (to_roaming == 0)
+               adapter->mlmepriv.to_join = false;
+       adapter->mlmepriv.to_roaming = to_roaming;
 }
 
-u16 rtw_get_capability23a(struct wlan_bssid_ex *bss)
+static void _rtw_roaming(struct rtw_adapter *padapter,
+                        struct wlan_network *tgt_network)
 {
-       u16     val;
-
-       memcpy((u8 *)&val, rtw_get_capability23a_from_ie(bss->IEs), 2);
-
-       return le16_to_cpu(val);
-}
+       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+       struct wlan_network *pnetwork;
+       int do_join_r;
 
-u8 *rtw_get_timestampe_from_ie23a(u8 *ie)
-{
-       return ie + 0;
-}
+       if (tgt_network)
+               pnetwork = tgt_network;
+       else
+               pnetwork = &pmlmepriv->cur_network;
 
-u8 *rtw_get_beacon_interval23a_from_ie(u8 *ie)
-{
-       return ie + 8;
-}
+       if (padapter->mlmepriv.to_roaming > 0) {
+               DBG_8723A("roaming from %s("MAC_FMT"), length:%d\n",
+                         pnetwork->network.Ssid.ssid,
+                         MAC_ARG(pnetwork->network.MacAddress),
+                         pnetwork->network.Ssid.ssid_len);
+               memcpy(&pmlmepriv->assoc_ssid, &pnetwork->network.Ssid,
+                      sizeof(struct cfg80211_ssid));
 
-int    rtw_init_mlme_priv23a (struct rtw_adapter *padapter)/* struct   mlme_priv *pmlmepriv) */
-{
-       int     res;
+               pmlmepriv->assoc_by_bssid = false;
 
-       res = _rtw_init_mlme_priv23a(padapter);/*  (pmlmepriv); */
+               while (1) {
+                       do_join_r = rtw_do_join23a(padapter);
+                       if (do_join_r == _SUCCESS)
+                               break;
+                       else {
+                               DBG_8723A("roaming do_join return %d\n",
+                                         do_join_r);
+                               pmlmepriv->to_roaming--;
 
-       return res;
+                               if (padapter->mlmepriv.to_roaming > 0)
+                                       continue;
+                               else {
+                                       DBG_8723A("%s(%d) -to roaming fail, "
+                                                 "indicate_disconnect\n",
+                                                 __func__, __LINE__);
+                                       rtw_indicate_disconnect23a(padapter);
+                                       break;
+                               }
+                       }
+               }
+       }
 }
 
-void rtw_free_mlme_priv23a (struct mlme_priv *pmlmepriv)
+void rtw23a_roaming(struct rtw_adapter *padapter,
+                   struct wlan_network *tgt_network)
 {
+       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
-       RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_mlme_priv23a\n"));
-       _rtw_free_mlme_priv23a(pmlmepriv);
-
+       spin_lock_bh(&pmlmepriv->lock);
+       _rtw_roaming(padapter, tgt_network);
+       spin_unlock_bh(&pmlmepriv->lock);
 }
 
-void rtw_free_network(struct mlme_priv *pmlmepriv, struct      wlan_network *pnetwork, u8 is_freeall);
-void rtw_free_network(struct mlme_priv *pmlmepriv, struct      wlan_network *pnetwork, u8 is_freeall)/* struct wlan_network *pnetwork, _queue  *free_queue) */
+__le16 *rtw_get_capability23a_from_ie(u8 *ie)
 {
-
-       RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                ("rtw_free_network ==> ssid = %s\n\n" ,
-                 pnetwork->network.Ssid.ssid));
-       _rtw_free_network23a(pmlmepriv, pnetwork, is_freeall);
-
+       return (__le16 *)(ie + 8 + 2);
 }
 
-void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork);
-void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork)
+u16 rtw_get_capability23a(struct wlan_bssid_ex *bss)
 {
+       u16 val;
 
-       /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_network ==> ssid = %s\n\n" , pnetwork->network.Ssid.ssid)); */
-       _rtw_free_network23a_nolock23a(pmlmepriv, pnetwork);
+       memcpy(&val, rtw_get_capability23a_from_ie(bss->IEs), 2);
 
+       return le16_to_cpu(val);
 }
 
-void rtw_free_network_queue23a(struct rtw_adapter* dev, u8 isfreeall)
+__le16 *rtw_get_beacon_interval23a_from_ie(u8 *ie)
 {
-
-       _rtw_free_network23a_queue23a(dev, isfreeall);
-
+       return (__le16 *)(ie + 8);
 }
 
-/*
-       return the wlan_network with the matching addr
-
-       Shall be calle under atomic context... to avoid possible racing condition...
-*/
-struct wlan_network *
-rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr)
+static void rtw_free_network_nolock(struct mlme_priv *pmlmepriv,
+                                   struct wlan_network *pnetwork)
 {
-       struct wlan_network *pnetwork;
-
-       pnetwork = _rtw_find_network23a(scanned_queue, addr);
-
-       return pnetwork;
+       _rtw_free_network23a(pmlmepriv, pnetwork);
 }
 
-int rtw_is_same_ibss23a(struct rtw_adapter *adapter, struct wlan_network *pnetwork)
+int rtw_is_same_ibss23a(struct rtw_adapter *adapter,
+                       struct wlan_network *pnetwork)
 {
        int ret = true;
        struct security_priv *psecuritypriv = &adapter->securitypriv;
 
-       if ((psecuritypriv->dot11PrivacyAlgrthm != _NO_PRIVACY_) &&
-                   (pnetwork->network.Privacy == 0))
-       {
+       if (psecuritypriv->dot11PrivacyAlgrthm != _NO_PRIVACY_ &&
+           pnetwork->network.Privacy == 0)
                ret = false;
-       }
-       else if ((psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_) &&
-                (pnetwork->network.Privacy == 1))
-       {
+       else if (psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_ &&
+                pnetwork->network.Privacy == 1)
                ret = false;
-       }
        else
-       {
                ret = true;
-       }
 
        return ret;
 }
@@ -363,21 +359,16 @@ int rtw_is_same_ibss23a(struct rtw_adapter *adapter, struct wlan_network *pnetwo
 inline int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b);
 inline int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b)
 {
-       /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("(%s,%d)(%s,%d)\n", */
-       /*              a->Ssid.Ssid, a->Ssid.SsidLength, b->Ssid.Ssid, b->Ssid.SsidLength)); */
        return (a->Ssid.ssid_len == b->Ssid.ssid_len) &&
                !memcmp(a->Ssid.ssid, b->Ssid.ssid, a->Ssid.ssid_len);
 }
 
 int is_same_network23a(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst)
 {
-        u16 s_cap, d_cap;
-
-       memcpy((u8 *)&s_cap, rtw_get_capability23a_from_ie(src->IEs), 2);
-       memcpy((u8 *)&d_cap, rtw_get_capability23a_from_ie(dst->IEs), 2);
+       u16 s_cap, d_cap;
 
-       s_cap = le16_to_cpu(s_cap);
-       d_cap = le16_to_cpu(d_cap);
+       s_cap = get_unaligned_le16(rtw_get_capability23a_from_ie(src->IEs));
+       d_cap = get_unaligned_le16(rtw_get_capability23a_from_ie(dst->IEs));
 
        return ((src->Ssid.ssid_len == dst->Ssid.ssid_len) &&
                /*      (src->Configuration.DSConfig == dst->Configuration.DSConfig) && */
@@ -389,10 +380,10 @@ int is_same_network23a(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst)
                 (d_cap & WLAN_CAPABILITY_ESS)));
 }
 
-struct wlan_network *rtw_get_oldest_wlan_network23a(struct rtw_queue *scanned_queue)
+struct wlan_network *
+rtw_get_oldest_wlan_network23a(struct rtw_queue *scanned_queue)
 {
        struct list_head *plist, *phead;
-
        struct wlan_network *pwlan;
        struct wlan_network *oldest = NULL;
 
@@ -412,7 +403,7 @@ struct wlan_network *rtw_get_oldest_wlan_network23a(struct rtw_queue *scanned_qu
 }
 
 void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src,
-       struct rtw_adapter * padapter, bool update_ie)
+                      struct rtw_adapter *padapter, bool update_ie)
 {
        u8 ss_ori = dst->PhyInfo.SignalStrength;
        u8 sq_ori = dst->PhyInfo.SignalQuality;
@@ -426,30 +417,35 @@ void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src,
        u8 sq_final;
        long rssi_final;
 
-       DBG_8723A("%s %s(%pM, ch%u) ss_ori:%3u, sq_ori:%3u, rssi_ori:%3ld, ss_smp:%3u, sq_smp:%3u, rssi_smp:%3ld\n",
+       DBG_8723A("%s %s(%pM, ch%u) ss_ori:%3u, sq_ori:%3u, rssi_ori:%3ld, "
+                 "ss_smp:%3u, sq_smp:%3u, rssi_smp:%3ld\n",
                  __func__, src->Ssid.ssid, src->MacAddress,
                  src->Configuration.DSConfig, ss_ori, sq_ori, rssi_ori,
                  ss_smp, sq_smp, rssi_smp
        );
 
        /* The rule below is 1/5 for sample value, 4/5 for history value */
-       if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && is_same_network23a(&padapter->mlmepriv.cur_network.network, src)) {
+       if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) &&
+           is_same_network23a(&padapter->mlmepriv.cur_network.network, src)) {
                /* Take the recvpriv's value for the connected AP*/
                ss_final = padapter->recvpriv.signal_strength;
                sq_final = padapter->recvpriv.signal_qual;
-               /* the rssi value here is undecorated, and will be used for antenna diversity */
+               /* the rssi value here is undecorated, and will be
+                  used for antenna diversity */
                if (sq_smp != 101) /* from the right channel */
                        rssi_final = (src->Rssi+dst->Rssi*4)/5;
                else
                        rssi_final = rssi_ori;
-       }
-       else {
+       } else {
                if (sq_smp != 101) { /* from the right channel */
-                       ss_final = ((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5;
-                       sq_final = ((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5;
-                       rssi_final = (src->Rssi+dst->Rssi*4)/5;
+                       ss_final = ((u32)src->PhyInfo.SignalStrength +
+                                   (u32)dst->PhyInfo.SignalStrength * 4) / 5;
+                       sq_final = ((u32)src->PhyInfo.SignalQuality +
+                                   (u32)dst->PhyInfo.SignalQuality * 4) / 5;
+                       rssi_final = src->Rssi+dst->Rssi * 4 / 5;
                } else {
-                       /* bss info not receving from the right channel, use the original RX signal infos */
+                       /* bss info not receving from the right channel, use
+                          the original RX signal infos */
                        ss_final = dst->PhyInfo.SignalStrength;
                        sq_final = dst->PhyInfo.SignalQuality;
                        rssi_final = dst->Rssi;
@@ -458,35 +454,32 @@ void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src,
        }
 
        if (update_ie)
-               memcpy((u8 *)dst, (u8 *)src, get_wlan_bssid_ex_sz(src));
+               memcpy(dst, src, get_wlan_bssid_ex_sz(src));
 
        dst->PhyInfo.SignalStrength = ss_final;
        dst->PhyInfo.SignalQuality = sq_final;
        dst->Rssi = rssi_final;
 
-       DBG_8723A("%s %s(%pM), SignalStrength:%u, SignalQuality:%u, RawRSSI:%ld\n",
-                 __func__, dst->Ssid.ssid, dst->MacAddress,
+       DBG_8723A("%s %s(%pM), SignalStrength:%u, SignalQuality:%u, "
+                 "RawRSSI:%ld\n",  __func__, dst->Ssid.ssid, dst->MacAddress,
                  dst->PhyInfo.SignalStrength,
                  dst->PhyInfo.SignalQuality, dst->Rssi);
-
 }
 
-static void update_current_network(struct rtw_adapter *adapter, struct wlan_bssid_ex *pnetwork)
+static void update_current_network(struct rtw_adapter *adapter,
+                                  struct wlan_bssid_ex *pnetwork)
 {
-       struct  mlme_priv *pmlmepriv = &adapter->mlmepriv;
-
-       if ((check_fwstate(pmlmepriv, _FW_LINKED)== true) && (is_same_network23a(&pmlmepriv->cur_network.network, pnetwork)))
-       {
-               /* RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,"Same Network\n"); */
+       struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
 
-               /* if(pmlmepriv->cur_network.network.IELength<= pnetwork->IELength) */
-               {
-                       update_network23a(&pmlmepriv->cur_network.network, pnetwork,adapter, true);
-                       rtw_update_protection23a(adapter, (pmlmepriv->cur_network.network.IEs) + sizeof (struct ndis_802_11_fixed_ies),
-                                                                       pmlmepriv->cur_network.network.IELength);
-               }
+       if (check_fwstate(pmlmepriv, _FW_LINKED) &&
+           is_same_network23a(&pmlmepriv->cur_network.network, pnetwork)) {
+               update_network23a(&pmlmepriv->cur_network.network,
+                                 pnetwork,adapter, true);
+               rtw_update_protection23a(adapter,
+                                        pmlmepriv->cur_network.network.IEs +
+                                        sizeof (struct ndis_802_11_fixed_ies),
+                                        pmlmepriv->cur_network.network.IELength);
        }
-
 }
 
 /*
@@ -494,7 +487,8 @@ static void update_current_network(struct rtw_adapter *adapter, struct wlan_bssi
 Caller must hold pmlmepriv->lock first.
 
 */
-void rtw_update_scanned_network23a(struct rtw_adapter *adapter, struct wlan_bssid_ex *target)
+void rtw_update_scanned_network23a(struct rtw_adapter *adapter,
+                                  struct wlan_bssid_ex *target)
 {
        struct list_head *plist, *phead;
        struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
@@ -561,19 +555,20 @@ void rtw_update_scanned_network23a(struct rtw_adapter *adapter, struct wlan_bssi
 
                /* target.reserved == 1, means that scanned network is
                 * a bcn frame. */
-               if ((pnetwork->network.IELength>target->IELength) &&
-                   (target->reserved == 1))
+               if (pnetwork->network.IELength > target->IELength &&
+                   target->reserved == 1)
                        update_ie = false;
 
-               update_network23a(&pnetwork->network, target,adapter, update_ie);
+               update_network23a(&pnetwork->network, target,adapter,
+                                 update_ie);
        }
 
 exit:
        spin_unlock_bh(&queue->lock);
-
 }
 
-void rtw_add_network(struct rtw_adapter *adapter, struct wlan_bssid_ex *pnetwork)
+static void rtw_add_network(struct rtw_adapter *adapter,
+                           struct wlan_bssid_ex *pnetwork)
 {
        update_current_network(adapter, pnetwork);
        rtw_update_scanned_network23a(adapter, pnetwork);
@@ -585,7 +580,8 @@ void rtw_add_network(struct rtw_adapter *adapter, struct wlan_bssid_ex *pnetwork
 /*                        (3) WMM */
 /*                        (4) HT */
 /*                      (5) others */
-int rtw_is_desired_network(struct rtw_adapter *adapter, struct wlan_network *pnetwork)
+static int rtw_is_desired_network(struct rtw_adapter *adapter,
+                                 struct wlan_network *pnetwork)
 {
        struct security_priv *psecuritypriv = &adapter->securitypriv;
        struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
@@ -600,31 +596,31 @@ int rtw_is_desired_network(struct rtw_adapter *adapter, struct wlan_network *pne
        desired_encmode = psecuritypriv->ndisencryptstatus;
        privacy = pnetwork->network.Privacy;
 
-       if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS))
-       {
-               if (rtw_get_wps_ie23a(pnetwork->network.IEs+_FIXED_IE_LENGTH_, pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen)!= NULL)
-               {
+       if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) {
+               if (rtw_get_wps_ie23a(pnetwork->network.IEs + _FIXED_IE_LENGTH_,
+                                     pnetwork->network.IELength -
+                                     _FIXED_IE_LENGTH_, NULL, &wps_ielen))
                        return true;
-               }
                else
-               {
                        return false;
-               }
        }
-       if (adapter->registrypriv.wifi_spec == 1) /* for  correct flow of 8021X  to do.... */
-       {
-               if ((desired_encmode == Ndis802_11EncryptionDisabled) && (privacy != 0))
+       if (adapter->registrypriv.wifi_spec == 1) {
+               /* for  correct flow of 8021X  to do.... */
+               if (desired_encmode == Ndis802_11EncryptionDisabled &&
+                   privacy != 0)
                    bselected = false;
        }
 
-       if ((desired_encmode != Ndis802_11EncryptionDisabled) && (privacy == 0)) {
-               DBG_8723A("desired_encmode: %d, privacy: %d\n", desired_encmode, privacy);
+       if (desired_encmode != Ndis802_11EncryptionDisabled &&
+           privacy == 0) {
+               DBG_8723A("desired_encmode: %d, privacy: %d\n",
+                         desired_encmode, privacy);
                bselected = false;
        }
 
-       if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)
-       {
-               if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode)
+       if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
+               if (pnetwork->network.InfrastructureMode !=
+                   pmlmepriv->cur_network.network.InfrastructureMode)
                        bselected = false;
        }
 
@@ -632,15 +628,14 @@ int rtw_is_desired_network(struct rtw_adapter *adapter, struct wlan_network *pne
 }
 
 /* TODO: Perry : For Power Management */
-void rtw_atimdone_event_callback23a(struct rtw_adapter *adapter , u8 *pbuf)
+void rtw_atimdone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf)
 {
-
        RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("receive atimdone_evet\n"));
 
        return;
 }
 
-void rtw_survey_event_cb23a(struct rtw_adapter *adapter, u8 *pbuf)
+void rtw_survey_event_cb23a(struct rtw_adapter *adapter, u8 *pbuf)
 {
        u32 len;
        struct wlan_bssid_ex *pnetwork;
@@ -648,31 +643,36 @@ void rtw_survey_event_cb23a(struct rtw_adapter    *adapter, u8 *pbuf)
 
        pnetwork = (struct wlan_bssid_ex *)pbuf;
 
-       RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("rtw_survey_event_cb23a, ssid=%s\n",  pnetwork->Ssid.ssid));
+       RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,
+                ("rtw_survey_event_cb23a, ssid=%s\n", pnetwork->Ssid.ssid));
 
        len = get_wlan_bssid_ex_sz(pnetwork);
-       if(len > (sizeof(struct wlan_bssid_ex)))
-       {
-               RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("\n ****rtw_survey_event_cb23a: return a wrong bss ***\n"));
+       if (len > (sizeof(struct wlan_bssid_ex))) {
+               RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,
+                        ("\n ****rtw_survey_event_cb23a: return a wrong "
+                         "bss ***\n"));
                return;
        }
 
        spin_lock_bh(&pmlmepriv->lock);
 
        /*  update IBSS_network 's timestamp */
-       if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true)
-       {
-               /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,"rtw_survey_event_cb23a : WIFI_ADHOC_MASTER_STATE\n\n"); */
+       if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
+               /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
+                  "rtw_survey_event_cb23a : WIFI_ADHOC_MASTER_STATE\n\n"); */
                if (ether_addr_equal(pmlmepriv->cur_network.network.MacAddress,
                                     pnetwork->MacAddress)) {
-                       struct wlan_network* ibss_wlan = NULL;
+                       struct wlan_network* ibss_wlan;
 
-                       memcpy(pmlmepriv->cur_network.network.IEs, pnetwork->IEs, 8);
+                       memcpy(pmlmepriv->cur_network.network.IEs,
+                              pnetwork->IEs, 8);
                        spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-                       ibss_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue,  pnetwork->MacAddress);
-                       if (ibss_wlan)
-                       {
-                               memcpy(ibss_wlan->network.IEs , pnetwork->IEs, 8);
+                       ibss_wlan = rtw_find_network23a(
+                               &pmlmepriv->scanned_queue,
+                               pnetwork->MacAddress);
+                       if (ibss_wlan) {
+                               memcpy(ibss_wlan->network.IEs,
+                                      pnetwork->IEs, 8);
                                spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
                                goto exit;
                        }
@@ -681,8 +681,7 @@ void rtw_survey_event_cb23a(struct rtw_adapter      *adapter, u8 *pbuf)
        }
 
        /*  lock pmlmepriv->lock when you accessing network_q */
-       if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == false)
-       {
+       if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == false) {
                if (pnetwork->Ssid.ssid[0] == 0)
                        pnetwork->Ssid.ssid_len = 0;
 
@@ -696,10 +695,12 @@ exit:
        return;
 }
 
-void rtw_surveydone_event_callback23a(struct rtw_adapter       *adapter, u8 *pbuf)
+void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf)
 {
        struct  mlme_priv *pmlmepriv = &adapter->mlmepriv;
        struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv;
+       struct wlan_bssid_ex *pdev_network;
+       u8 *pibss;
 
        spin_lock_bh(&pmlmepriv->lock);
 
@@ -709,47 +710,62 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter  *adapter, u8 *pbuf)
                pmlmepriv->wps_probe_req_ie = NULL;
        }
 
-       RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_surveydone_event_callback23a: fw_state:%x\n\n", get_fwstate(pmlmepriv)));
+       RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
+                ("rtw_surveydone_event_callback23a: fw_state:%x\n\n",
+                 get_fwstate(pmlmepriv)));
 
        if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) {
                del_timer_sync(&pmlmepriv->scan_to_timer);
 
                _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
        } else {
-
-               RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("nic status =%x, survey done event comes too late!\n", get_fwstate(pmlmepriv)));
+               RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
+                        ("nic status =%x, survey done event comes too late!\n",
+                         get_fwstate(pmlmepriv)));
        }
 
        rtw_set_signal_stat_timer(&adapter->recvpriv);
 
        if (pmlmepriv->to_join == true) {
-               if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) {
+               if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
                        if (check_fwstate(pmlmepriv, _FW_LINKED) == false) {
                                set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
 
-                               if (rtw_select_and_join_from_scanned_queue23a(pmlmepriv) == _SUCCESS) {
+                               if (rtw_select_and_join_from_scanned_queue23a(
+                                           pmlmepriv) == _SUCCESS) {
                                        mod_timer(&pmlmepriv->assoc_timer,
                                                  jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT));
                                } else {
-                                       struct wlan_bssid_ex *pdev_network = &adapter->registrypriv.dev_network;
-                                       u8 *pibss = adapter->registrypriv.dev_network.MacAddress;
+                                       pdev_network = &adapter->registrypriv.dev_network;
+                                       pibss = adapter->registrypriv.dev_network.MacAddress;
 
-                                       _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
+                                       _clr_fwstate_(pmlmepriv,
+                                                     _FW_UNDER_SURVEY);
 
-                                       RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("switching to adhoc master\n"));
+                                       RT_TRACE(_module_rtl871x_mlme_c_,
+                                                _drv_err_,
+                                                ("switching to adhoc "
+                                                 "master\n"));
 
-                                       memset(&pdev_network->Ssid, 0, sizeof(struct cfg80211_ssid));
-                                       memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct cfg80211_ssid));
+                                       memset(&pdev_network->Ssid, 0,
+                                              sizeof(struct cfg80211_ssid));
+                                       memcpy(&pdev_network->Ssid,
+                                              &pmlmepriv->assoc_ssid,
+                                              sizeof(struct cfg80211_ssid));
 
-                                       rtw_update_registrypriv_dev_network23a(adapter);
+                                       rtw_update_registrypriv_dev_network23a(
+                                               adapter);
                                        rtw_generate_random_ibss23a(pibss);
 
-                                       pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;
+                                       pmlmepriv->fw_state =
+                                               WIFI_ADHOC_MASTER_STATE;
 
-                                       if (rtw_createbss_cmd23a(adapter)!= _SUCCESS)
-                                       {
-                                       RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error =>rtw_createbss_cmd23a status FAIL\n"));
-                                       }
+                                       if (rtw_createbss_cmd23a(adapter) !=
+                                           _SUCCESS)
+                                       RT_TRACE(_module_rtl871x_mlme_c_,
+                                                _drv_err_,
+                                                ("Error =>rtw_createbss_cmd23a"
+                                                 " status FAIL\n"));
 
                                        pmlmepriv->to_join = false;
                                }
@@ -758,27 +774,32 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter  *adapter, u8 *pbuf)
                        int ret;
                        set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
                        pmlmepriv->to_join = false;
-                       ret = rtw_select_and_join_from_scanned_queue23a(pmlmepriv);
+                       ret = rtw_select_and_join_from_scanned_queue23a(
+                               pmlmepriv);
                        if (ret == _SUCCESS) {
                                unsigned long e;
                                e = msecs_to_jiffies(MAX_JOIN_TIMEOUT);
                                mod_timer(&pmlmepriv->assoc_timer, jiffies + e);
-                       } else if (ret == 2)/* there is no need to wait for join */
-                       {
+                       } else if (ret == 2) {/* there is no need to wait */
                                _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
                                rtw_indicate_connect23a(adapter);
                        } else {
-                               DBG_8723A("try_to_join, but select scanning queue fail, to_roaming:%d\n", rtw_to_roaming(adapter));
-                               if (rtw_to_roaming(adapter) != 0) {
-                                       if (--pmlmepriv->to_roaming == 0
-                                               || _SUCCESS != rtw_sitesurvey_cmd23a(adapter, &pmlmepriv->assoc_ssid, 1, NULL, 0)
-                                       ) {
+                               DBG_8723A("try_to_join, but select scanning "
+                                         "queue fail, to_roaming:%d\n",
+                                         adapter->mlmepriv.to_roaming);
+                               if (adapter->mlmepriv.to_roaming) {
+                                       if (--pmlmepriv->to_roaming == 0 ||
+                                           rtw_sitesurvey_cmd23a(
+                                                   adapter,
+                                                   &pmlmepriv->assoc_ssid, 1,
+                                                   NULL, 0) != _SUCCESS) {
                                                rtw_set_roaming(adapter, 0);
-                                               rtw_free_assoc_resources23a(adapter, 1);
-                                               rtw_indicate_disconnect23a(adapter);
-                                       } else {
+                                               rtw_free_assoc_resources23a(
+                                                       adapter, 1);
+                                               rtw_indicate_disconnect23a(
+                                                       adapter);
+                                       } else
                                                pmlmepriv->to_join = true;
-                                       }
                                }
                                _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
                        }
@@ -787,18 +808,12 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter  *adapter, u8 *pbuf)
 
        spin_unlock_bh(&pmlmepriv->lock);
 
-#ifdef CONFIG_8723AU_P2P
-       if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
-               p2p_ps_wk_cmd23a(adapter, P2P_PS_SCAN_DONE, 0);
-#endif /*  CONFIG_8723AU_P2P */
-
        rtw_os_xmit_schedule23a(adapter);
 
-       if(pmlmeext->sitesurvey_res.bss_cnt == 0)
+       if (pmlmeext->sitesurvey_res.bss_cnt == 0)
                rtw_hal_sreset_reset23a(adapter);
 
        rtw_cfg80211_surveydone_event_callback(adapter);
-
 }
 
 void rtw_dummy_event_callback23a(struct rtw_adapter *adapter , u8 *pbuf)
@@ -809,7 +824,7 @@ void rtw23a_fwdbg_event_callback(struct rtw_adapter *adapter , u8 *pbuf)
 {
 }
 
-static void free_scanqueue(struct      mlme_priv *pmlmepriv)
+static void free_scanqueue(struct mlme_priv *pmlmepriv)
 {
        struct wlan_network *pnetwork;
        struct rtw_queue *scan_queue = &pmlmepriv->scanned_queue;
@@ -827,42 +842,38 @@ static void free_scanqueue(struct mlme_priv *pmlmepriv)
         }
 
        spin_unlock_bh(&scan_queue->lock);
-
 }
 
 /*
-*rtw_free_assoc_resources23a: the caller has to lock pmlmepriv->lock
-*/
-void rtw_free_assoc_resources23a(struct rtw_adapter *adapter, int lock_scanned_queue)
+ *rtw_free_assoc_resources23a: the caller has to lock pmlmepriv->lock
+ */
+void rtw_free_assoc_resources23a(struct rtw_adapter *adapter,
+                                int lock_scanned_queue)
 {
-       struct wlan_network* pwlan = NULL;
-       struct  mlme_priv *pmlmepriv = &adapter->mlmepriv;
-       struct  sta_priv *pstapriv = &adapter->stapriv;
+       struct wlan_network* pwlan;
+       struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+       struct sta_priv *pstapriv = &adapter->stapriv;
        struct wlan_network *tgt_network = &pmlmepriv->cur_network;
+       struct sta_info* psta;
 
-       RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_free_assoc_resources23a\n"));
-       RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("tgt_network->network.MacAddress="MAC_FMT" ssid=%s\n",
-               MAC_ARG(tgt_network->network.MacAddress), tgt_network->network.Ssid.ssid));
-
-       if(check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_AP_STATE))
-       {
-               struct sta_info* psta;
-
-               psta = rtw_get_stainfo23a(&adapter->stapriv, tgt_network->network.MacAddress);
+       RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_,
+                ("+rtw_free_assoc_resources23a\n"));
+       RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
+                ("tgt_network->network.MacAddress="MAC_FMT" ssid=%s\n",
+                 MAC_ARG(tgt_network->network.MacAddress),
+                 tgt_network->network.Ssid.ssid));
 
-               {
-                       spin_lock_bh(&pstapriv->sta_hash_lock);
-                       rtw_free_stainfo23a(adapter,  psta);
-               }
+       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_AP_STATE)) {
+               psta = rtw_get_stainfo23a(&adapter->stapriv,
+                                         tgt_network->network.MacAddress);
 
+               spin_lock_bh(&pstapriv->sta_hash_lock);
+               rtw_free_stainfo23a(adapter,  psta);
                spin_unlock_bh(&pstapriv->sta_hash_lock);
-
        }
 
-       if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE))
-       {
-               struct sta_info* psta;
-
+       if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE |
+                         WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) {
                rtw_free_all_stainfo23a(adapter);
 
                psta = rtw_get_bcmc_stainfo23a(adapter);
@@ -873,23 +884,25 @@ void rtw_free_assoc_resources23a(struct rtw_adapter *adapter, int lock_scanned_q
                rtw_init_bcmc_stainfo23a(adapter);
        }
 
-       if(lock_scanned_queue)
+       if (lock_scanned_queue)
                spin_lock_bh(&pmlmepriv->scanned_queue.lock);
 
-       pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress);
-       if(pwlan)
+       pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue,
+                                   tgt_network->network.MacAddress);
+       if (pwlan)
                pwlan->fixed = false;
        else
-               RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("rtw_free_assoc_resources23a : pwlan== NULL\n\n"));
+               RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,
+                        ("rtw_free_assoc_resources23a : pwlan== NULL\n"));
 
-       if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) && (adapter->stapriv.asoc_sta_count == 1))
+       if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) &&
+           adapter->stapriv.asoc_sta_count == 1)
                rtw_free_network_nolock(pmlmepriv, pwlan);
 
-       if(lock_scanned_queue)
+       if (lock_scanned_queue)
                spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
 
        pmlmepriv->key_mask = 0;
-
 }
 
 /*
@@ -897,46 +910,54 @@ void rtw_free_assoc_resources23a(struct rtw_adapter *adapter, int lock_scanned_q
 */
 void rtw_indicate_connect23a(struct rtw_adapter *padapter)
 {
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
+       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
-       RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_connect23a\n"));
+       RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
+                ("+rtw_indicate_connect23a\n"));
 
        pmlmepriv->to_join = false;
 
-       if(!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) {
+       if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) {
                set_fwstate(pmlmepriv, _FW_LINKED);
 
                rtw_led_control(padapter, LED_CTL_LINK);
 
-               rtw_os_indicate_connect23a(padapter);
+               rtw_cfg80211_indicate_connect(padapter);
+
+               netif_carrier_on(padapter->pnetdev);
+
+               if (padapter->pid[2] != 0)
+                       kill_pid(find_vpid(padapter->pid[2]), SIGALRM, 1);
        }
 
        rtw_set_roaming(padapter, 0);
 
        rtw_set_scan_deny(padapter, 3000);
 
-       RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("-rtw_indicate_connect23a: fw_state=0x%08x\n", get_fwstate(pmlmepriv)));
-
+       RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
+                ("-rtw_indicate_connect23a: fw_state=0x%08x\n",
+                 get_fwstate(pmlmepriv)));
 }
 
 /*
-*rtw_indicate_disconnect23a: the caller has to lock pmlmepriv->lock
-*/
+ *rtw_indicate_disconnect23a: the caller has to lock pmlmepriv->lock
+ */
 void rtw_indicate_disconnect23a(struct rtw_adapter *padapter)
 {
        struct  mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
-       RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_disconnect23a\n"));
+       RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
+                ("+rtw_indicate_disconnect23a\n"));
 
        _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING|WIFI_UNDER_WPS);
 
         /* DBG_8723A("clear wps when %s\n", __func__); */
 
-       if (rtw_to_roaming(padapter) > 0)
+       if (padapter->mlmepriv.to_roaming > 0)
                _clr_fwstate_(pmlmepriv, _FW_LINKED);
 
        if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) ||
-           (rtw_to_roaming(padapter) <= 0)) {
+           padapter->mlmepriv.to_roaming <= 0) {
                rtw_os_indicate_disconnect23a(padapter);
 
                /* set ips_deny_time to avoid enter IPS before LPS leave */
@@ -951,17 +972,7 @@ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter)
 
        }
 
-#ifdef CONFIG_8723AU_P2P
-       p2p_ps_wk_cmd23a(padapter, P2P_PS_DISABLE, 1);
-#endif /*  CONFIG_8723AU_P2P */
-
        rtw_lps_ctrl_wk_cmd23a(padapter, LPS_CTRL_DISCONNECT, 1);
-
-}
-
-inline void rtw_indicate_scan_done23a(struct rtw_adapter *padapter, bool aborted)
-{
-       rtw_os_indicate_scan_done23a(padapter, aborted);
 }
 
 void rtw_scan_abort23a(struct rtw_adapter *adapter)
@@ -974,36 +985,39 @@ void rtw_scan_abort23a(struct rtw_adapter *adapter)
        pmlmeext->scan_abort = true;
        while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) &&
               jiffies_to_msecs(jiffies - start) <= 200) {
-
                if (adapter->bDriverStopped || adapter->bSurpriseRemoved)
                        break;
 
-               DBG_8723A(FUNC_NDEV_FMT"fw_state = _FW_UNDER_SURVEY!\n", FUNC_NDEV_ARG(adapter->pnetdev));
+               DBG_8723A(FUNC_NDEV_FMT "fw_state = _FW_UNDER_SURVEY!\n",
+                         FUNC_NDEV_ARG(adapter->pnetdev));
                msleep(20);
        }
 
        if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) {
                if (!adapter->bDriverStopped && !adapter->bSurpriseRemoved)
-                       DBG_8723A(FUNC_NDEV_FMT"waiting for scan_abort time out!\n", FUNC_NDEV_ARG(adapter->pnetdev));
-               rtw_indicate_scan_done23a(adapter, true);
+                       DBG_8723A(FUNC_NDEV_FMT "waiting for scan_abort time "
+                                 "out!\n", FUNC_NDEV_ARG(adapter->pnetdev));
+               rtw_cfg80211_indicate_scan_done(wdev_to_priv(adapter->rtw_wdev),
+                                               true);
        }
        pmlmeext->scan_abort = false;
 }
 
-static struct sta_info *rtw_joinbss_update_stainfo(struct rtw_adapter *padapter, struct wlan_network *pnetwork)
+static struct sta_info *
+rtw_joinbss_update_stainfo(struct rtw_adapter *padapter,
+                          struct wlan_network *pnetwork)
 {
        int i;
-       struct sta_info *bmc_sta, *psta = NULL;
+       struct sta_info *bmc_sta, *psta;
        struct recv_reorder_ctrl *preorder_ctrl;
        struct sta_priv *pstapriv = &padapter->stapriv;
 
        psta = rtw_get_stainfo23a(pstapriv, pnetwork->network.MacAddress);
-       if (psta == NULL) {
-               psta = rtw_alloc_stainfo23a(pstapriv, pnetwork->network.MacAddress);
-       }
+       if (!psta)
+               psta = rtw_alloc_stainfo23a(pstapriv,
+                                           pnetwork->network.MacAddress);
 
-       if (psta) /* update ptarget_sta */
-       {
+       if (psta) { /* update ptarget_sta */
                DBG_8723A("%s\n", __func__);
 
                psta->aid  = pnetwork->join_res;
@@ -1013,57 +1027,63 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct rtw_adapter *padapter,
                rtw_hal_set_odm_var23a(padapter, HAL_ODM_STA_INFO, psta, true);
 
                /* security related */
-               if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)
-               {
+               if (padapter->securitypriv.dot11AuthAlgrthm ==
+                   dot11AuthAlgrthm_8021X) {
                        padapter->securitypriv.binstallGrpkey = false;
                        padapter->securitypriv.busetkipkey = false;
                        padapter->securitypriv.bgrpkey_handshake = false;
 
                        psta->ieee8021x_blocked = true;
-                       psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm;
+                       psta->dot118021XPrivacy =
+                               padapter->securitypriv.dot11PrivacyAlgrthm;
 
-                       memset((u8 *)&psta->dot118021x_UncstKey, 0, sizeof (union Keytype));
+                       memset(&psta->dot118021x_UncstKey, 0,
+                              sizeof (union Keytype));
 
-                       memset((u8 *)&psta->dot11tkiprxmickey, 0, sizeof (union Keytype));
-                       memset((u8 *)&psta->dot11tkiptxmickey, 0, sizeof (union Keytype));
+                       memset(&psta->dot11tkiprxmickey, 0,
+                              sizeof (union Keytype));
+                       memset(&psta->dot11tkiptxmickey, 0,
+                              sizeof (union Keytype));
 
-                       memset((u8 *)&psta->dot11txpn, 0, sizeof (union pn48));
-                       memset((u8 *)&psta->dot11rxpn, 0, sizeof (union pn48));
+                       memset(&psta->dot11txpn, 0, sizeof (union pn48));
+                       memset(&psta->dot11rxpn, 0, sizeof (union pn48));
                }
 
                /*      Commented by Albert 2012/07/21 */
                /*      When doing the WPS, the wps_ie_len won't equal to 0 */
-               /*      And the Wi-Fi driver shouldn't allow the data packet to be tramsmitted. */
-               if (padapter->securitypriv.wps_ie_len != 0)
-               {
+               /*      And the Wi-Fi driver shouldn't allow the data packet
+                       to be tramsmitted. */
+               if (padapter->securitypriv.wps_ie_len != 0) {
                        psta->ieee8021x_blocked = true;
                        padapter->securitypriv.wps_ie_len = 0;
                }
 
-               /* for A-MPDU Rx reordering buffer control for bmc_sta & sta_info */
-               /* if A-MPDU Rx is enabled, reseting  rx_ordering_ctrl wstart_b(indicate_seq) to default value = 0xffff */
+               /* for A-MPDU Rx reordering buffer control for bmc_sta &
+                * sta_info */
+               /* if A-MPDU Rx is enabled, reseting
+                  rx_ordering_ctrl wstart_b(indicate_seq) to default
+                  value = 0xffff */
                /* todo: check if AP can send A-MPDU packets */
-               for (i = 0; i < 16 ; i++)
-               {
+               for (i = 0; i < 16 ; i++) {
                        /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */
                        preorder_ctrl = &psta->recvreorder_ctrl[i];
                        preorder_ctrl->enable = false;
                        preorder_ctrl->indicate_seq = 0xffff;
                        preorder_ctrl->wend_b = 0xffff;
-                       preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */
+                       /* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */
+                       preorder_ctrl->wsize_b = 64;
                }
 
                bmc_sta = rtw_get_bcmc_stainfo23a(padapter);
-               if (bmc_sta)
-               {
-                       for (i = 0; i < 16 ; i++)
-                       {
-                               /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */
+               if (bmc_sta) {
+                       for (i = 0; i < 16 ; i++) {
                                preorder_ctrl = &bmc_sta->recvreorder_ctrl[i];
                                preorder_ctrl->enable = false;
                                preorder_ctrl->indicate_seq = 0xffff;
                                preorder_ctrl->wend_b = 0xffff;
-                               preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */
+                               /* max_ampdu_sz; ex. 32(kbytes) ->
+                                  wsize_b = 32 */
+                               preorder_ctrl->wsize_b = 64;
                        }
                }
 
@@ -1077,29 +1097,41 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct rtw_adapter *padapter,
 
 /* pnetwork : returns from rtw23a_joinbss_event_cb */
 /* ptarget_wlan: found from scanned_queue */
-static void rtw_joinbss_update_network23a(struct rtw_adapter *padapter, struct wlan_network *ptarget_wlan, struct wlan_network  *pnetwork)
+static void
+rtw_joinbss_update_network23a(struct rtw_adapter *padapter,
+                             struct wlan_network *ptarget_wlan,
+                             struct wlan_network  *pnetwork)
 {
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct wlan_network *cur_network = &pmlmepriv->cur_network;
 
        DBG_8723A("%s\n", __func__);
 
-       RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\nfw_state:%x, BSSID:"MAC_FMT"\n"
-               , get_fwstate(pmlmepriv), MAC_ARG(pnetwork->network.MacAddress)));
+       RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
+                ("\nfw_state:%x, BSSID:"MAC_FMT"\n", get_fwstate(pmlmepriv),
+                 MAC_ARG(pnetwork->network.MacAddress)));
 
        /*  why not use ptarget_wlan?? */
-       memcpy(&cur_network->network, &pnetwork->network, pnetwork->network.Length);
+       memcpy(&cur_network->network, &pnetwork->network,
+              pnetwork->network.Length);
        /*  some IEs in pnetwork is wrong, so we should use ptarget_wlan IEs */
        cur_network->network.IELength = ptarget_wlan->network.IELength;
-       memcpy(&cur_network->network.IEs[0], &ptarget_wlan->network.IEs[0], MAX_IE_SZ);
+       memcpy(&cur_network->network.IEs[0], &ptarget_wlan->network.IEs[0],
+              MAX_IE_SZ);
 
        cur_network->aid = pnetwork->join_res;
 
        rtw_set_signal_stat_timer(&padapter->recvpriv);
-       padapter->recvpriv.signal_strength = ptarget_wlan->network.PhyInfo.SignalStrength;
-       padapter->recvpriv.signal_qual = ptarget_wlan->network.PhyInfo.SignalQuality;
-       /* the ptarget_wlan->network.Rssi is raw data, we use ptarget_wlan->network.PhyInfo.SignalStrength instead (has scaled) */
-       padapter->recvpriv.rssi = translate_percentage_to_dbm(ptarget_wlan->network.PhyInfo.SignalStrength);
+       padapter->recvpriv.signal_strength =
+               ptarget_wlan->network.PhyInfo.SignalStrength;
+       padapter->recvpriv.signal_qual =
+               ptarget_wlan->network.PhyInfo.SignalQuality;
+       /*
+        * the ptarget_wlan->network.Rssi is raw data, we use
+        * ptarget_wlan->network.PhyInfo.SignalStrength instead (has scaled)
+        */
+       padapter->recvpriv.rssi = translate_percentage_to_dbm(
+               ptarget_wlan->network.PhyInfo.SignalStrength);
        DBG_8723A("%s signal_strength:%3u, rssi:%3d, signal_qual:%3u\n",
                  __func__, padapter->recvpriv.signal_strength,
                  padapter->recvpriv.rssi, padapter->recvpriv.signal_qual);
@@ -1118,40 +1150,51 @@ static void rtw_joinbss_update_network23a(struct rtw_adapter *padapter, struct w
                break;
        default:
                pmlmepriv->fw_state = WIFI_NULL_STATE;
-               RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Invalid network_mode\n"));
+               RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
+                        ("Invalid network_mode\n"));
                break;
        }
 
-       rtw_update_protection23a(padapter, (cur_network->network.IEs) + sizeof (struct ndis_802_11_fixed_ies),
-                                                                       (cur_network->network.IELength));
+       rtw_update_protection23a(padapter, cur_network->network.IEs +
+                                sizeof (struct ndis_802_11_fixed_ies),
+                                cur_network->network.IELength);
 
-       rtw_update_ht_cap23a(padapter, cur_network->network.IEs, cur_network->network.IELength);
+       rtw_update_ht_cap23a(padapter, cur_network->network.IEs,
+                            cur_network->network.IELength);
 }
 
-/* Notes: the fucntion could be > passive_level (the same context as Rx tasklet) */
-/* pnetwork : returns from rtw23a_joinbss_event_cb */
-/* ptarget_wlan: found from scanned_queue */
-/* if join_res > 0, for (fw_state==WIFI_STATION_STATE), we check if  "ptarget_sta" & "ptarget_wlan" exist. */
-/* if join_res > 0, for (fw_state==WIFI_ADHOC_STATE), we only check if "ptarget_wlan" exist. */
-/* if join_res > 0, update "cur_network->network" from "pnetwork->network" if (ptarget_wlan !=NULL). */
+/*
+ * Notes:
+ * the fucntion could be > passive_level (the same context as Rx tasklet)
+ * pnetwork : returns from rtw23a_joinbss_event_cb
+ * ptarget_wlan: found from scanned_queue
+ * if join_res > 0, for (fw_state==WIFI_STATION_STATE),
+ * we check if  "ptarget_sta" & "ptarget_wlan" exist.
+ * if join_res > 0, for (fw_state==WIFI_ADHOC_STATE),
+ * we only check if "ptarget_wlan" exist.
+ * if join_res > 0, update "cur_network->network" from "pnetwork->network"
+ * if (ptarget_wlan !=NULL).
+ */
 
 void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf)
 {
-       static u8 retry=0;
-       struct sta_info *ptarget_sta= NULL, *pcur_sta = NULL;
-       struct  sta_priv *pstapriv = &adapter->stapriv;
-       struct  mlme_priv *pmlmepriv = &adapter->mlmepriv;
-       struct wlan_network     *pnetwork       = (struct wlan_network *)pbuf;
+       struct sta_info *ptarget_sta, *pcur_sta;
+       struct sta_priv *pstapriv = &adapter->stapriv;
+       struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+       struct wlan_network *pnetwork = (struct wlan_network *)pbuf;
        struct wlan_network *cur_network = &pmlmepriv->cur_network;
-       struct wlan_network     *pcur_wlan = NULL, *ptarget_wlan = NULL;
-       unsigned int            the_same_macaddr = false;
+       struct wlan_network *pcur_wlan, *ptarget_wlan = NULL;
+       bool the_same_macaddr;
 
-       RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("joinbss event call back received with res=%d\n", pnetwork->join_res));
+       RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,
+                ("joinbss event call back received with res=%d\n",
+                 pnetwork->join_res));
 
        rtw_get_encrypt_decrypt_from_registrypriv23a(adapter);
 
        if (pmlmepriv->assoc_ssid.ssid_len == 0) {
-               RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("@@@@@   joinbss event call back  for Any SSid\n"));
+               RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,
+                        ("@@@@@   joinbss event call back  for Any SSid\n"));
        } else {
                RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,
                         ("@@@@@   rtw23a_joinbss_event_cb for SSid:%s\n",
@@ -1165,93 +1208,102 @@ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf)
                the_same_macaddr = false;
 
        pnetwork->network.Length = get_wlan_bssid_ex_sz(&pnetwork->network);
-       if(pnetwork->network.Length > sizeof(struct wlan_bssid_ex))
-       {
-               RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("\n\n ***joinbss_evt_callback return a wrong bss ***\n\n"));
+       if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) {
+               RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,
+                        ("\n\n ***joinbss_evt_callback return a wrong bss "
+                         "***\n\n"));
                return;
        }
 
        spin_lock_bh(&pmlmepriv->lock);
 
-       RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("\n rtw23a_joinbss_event_cb !! _enter_critical\n"));
+       RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,
+                ("\n rtw23a_joinbss_event_cb !! _enter_critical\n"));
 
-       if(pnetwork->join_res > 0)
-       {
+       if (pnetwork->join_res > 0) {
                spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-               retry = 0;
-               if (check_fwstate(pmlmepriv,_FW_UNDER_LINKING))
-               {
+               if (check_fwstate(pmlmepriv,_FW_UNDER_LINKING)) {
                        /* s1. find ptarget_wlan */
-                       if(check_fwstate(pmlmepriv, _FW_LINKED))
-                       {
-                               if(the_same_macaddr == true)
-                               {
+                       if (check_fwstate(pmlmepriv, _FW_LINKED)) {
+                               if (the_same_macaddr == true) {
                                        ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, cur_network->network.MacAddress);
-                               }
-                               else
-                               {
+                               } else {
                                        pcur_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, cur_network->network.MacAddress);
-                                       if(pcur_wlan)   pcur_wlan->fixed = false;
+                                       if (pcur_wlan)
+                                               pcur_wlan->fixed = false;
 
                                        pcur_sta = rtw_get_stainfo23a(pstapriv, cur_network->network.MacAddress);
-                                       if(pcur_sta) {
+                                       if (pcur_sta) {
                                                spin_lock_bh(&pstapriv->sta_hash_lock);
-                                               rtw_free_stainfo23a(adapter,  pcur_sta);
+                                               rtw_free_stainfo23a(adapter,
+                                                                   pcur_sta);
                                                spin_unlock_bh(&pstapriv->sta_hash_lock);
                                        }
 
                                        ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress);
-                                       if(check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) {
-                                               if(ptarget_wlan)        ptarget_wlan->fixed = true;
+                                       if (check_fwstate(pmlmepriv,
+                                                         WIFI_STATION_STATE)) {
+                                               if (ptarget_wlan)
+                                                       ptarget_wlan->fixed =
+                                                               true;
                                        }
                                }
 
-                       }
-                       else
-                       {
-                               ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress);
-                               if(check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) {
-                                       if(ptarget_wlan)        ptarget_wlan->fixed = true;
+                       } else {
+                               ptarget_wlan = rtw_find_network23a(
+                                       &pmlmepriv->scanned_queue,
+                                       pnetwork->network.MacAddress);
+                               if (check_fwstate(pmlmepriv,
+                                                 WIFI_STATION_STATE)) {
+                                       if (ptarget_wlan)
+                                               ptarget_wlan->fixed = true;
                                }
                        }
 
                        /* s2. update cur_network */
-                       if(ptarget_wlan)
-                       {
-                               rtw_joinbss_update_network23a(adapter, ptarget_wlan, pnetwork);
-                       }
-                       else
-                       {
-                               RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("Can't find ptarget_wlan when joinbss_event callback\n"));
+                       if (ptarget_wlan)
+                               rtw_joinbss_update_network23a(adapter,
+                                                             ptarget_wlan,
+                                                             pnetwork);
+                       else {
+                               RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,
+                                        ("Can't find ptarget_wlan when "
+                                         "joinbss_event callback\n"));
                                spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
                                goto ignore_joinbss_callback;
                        }
 
-                       /* s3. find ptarget_sta & update ptarget_sta after update cur_network only for station mode */
-                       if(check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)
-                       {
-                               ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork);
-                               if(ptarget_sta==NULL)
-                               {
-                                       RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("Can't update stainfo when joinbss_event callback\n"));
+                       /* s3. find ptarget_sta & update ptarget_sta after
+                          update cur_network only for station mode */
+                       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
+                               ptarget_sta = rtw_joinbss_update_stainfo(
+                                       adapter, pnetwork);
+                               if (!ptarget_sta) {
+                                       RT_TRACE(_module_rtl871x_mlme_c_,
+                                                _drv_err_,
+                                                ("Can't update stainfo when "
+                                                 "joinbss_event callback\n"));
                                        spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
                                        goto ignore_joinbss_callback;
                                }
                        }
 
                        /* s4. indicate connect */
-                       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)
-                       {
+                       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
                                rtw_indicate_connect23a(adapter);
-                       } else {
-                                       /* adhoc mode will rtw_indicate_connect23a when rtw_stassoc_event_callback23a */
-                               RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("adhoc mode, fw_state:%x", get_fwstate(pmlmepriv)));
+                       else {
+                               /* adhoc mode will rtw_indicate_connect23a
+                                  when rtw_stassoc_event_callback23a */
+                               RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,
+                                        ("adhoc mode, fw_state:%x",
+                                         get_fwstate(pmlmepriv)));
                        }
 
                        /* s5. Cancle assoc_timer */
                        del_timer_sync(&pmlmepriv->assoc_timer);
 
-                       RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("Cancle assoc_timer\n"));
+                       RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,
+                                ("Cancle assoc_timer\n"));
                } else {
                        RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
                                 ("rtw23a_joinbss_event_cb err: fw_state:%x",
@@ -1260,20 +1312,19 @@ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf)
                        goto ignore_joinbss_callback;
                }
                spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
-       } else if(pnetwork->join_res == -4) {
+       } else if (pnetwork->join_res == -4) {
                rtw_reset_securitypriv23a(adapter);
                mod_timer(&pmlmepriv->assoc_timer,
                          jiffies + msecs_to_jiffies(1));
 
                /* rtw_free_assoc_resources23a(adapter, 1); */
 
-               if((check_fwstate(pmlmepriv, _FW_UNDER_LINKING))) {
+               if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) {
                        RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                                ("fail! clear _FW_UNDER_LINKING ^^^fw_state=%x\n",
-                                get_fwstate(pmlmepriv)));
+                                ("fail! clear _FW_UNDER_LINKING ^^^fw_state="
+                                 "%x\n", get_fwstate(pmlmepriv)));
                        _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
                }
-
        } else {
                /* if join_res < 0 (join fails), then try again */
                mod_timer(&pmlmepriv->assoc_timer,
@@ -1288,46 +1339,31 @@ ignore_joinbss_callback:
 
 void rtw23a_joinbss_event_cb(struct rtw_adapter *adapter, u8 *pbuf)
 {
-       struct wlan_network     *pnetwork       = (struct wlan_network *)pbuf;
+       struct wlan_network *pnetwork = (struct wlan_network *)pbuf;
 
        mlmeext_joinbss_event_callback23a(adapter, pnetwork->join_res);
 
        rtw_os_xmit_schedule23a(adapter);
-
-}
-
-/* FOR AP , AD-HOC mode */
-void rtw_stassoc_hw_rpt23a(struct rtw_adapter *adapter, struct sta_info *psta)
-{
-       u16 media_status;
-
-       if (psta == NULL)       return;
-
-       media_status = (psta->mac_id<<8)|1; /*   MACID|OPMODE:1 connect */
-       rtw_hal_set_hwreg23a(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status);
 }
 
 void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf)
 {
        struct sta_info *psta;
        struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
-       struct stassoc_event    *pstassoc       = (struct stassoc_event*)pbuf;
+       struct stassoc_event *pstassoc = (struct stassoc_event*)pbuf;
        struct wlan_network *cur_network = &pmlmepriv->cur_network;
-       struct wlan_network     *ptarget_wlan = NULL;
+       struct wlan_network *ptarget_wlan;
 
-       if(rtw_access_ctrl23a(adapter, pstassoc->macaddr) == false)
+       if (rtw_access_ctrl23a(adapter, pstassoc->macaddr) == false)
                return;
 
 #ifdef CONFIG_8723AU_AP_MODE
-       if(check_fwstate(pmlmepriv, WIFI_AP_STATE))
-       {
+       if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
                psta = rtw_get_stainfo23a(&adapter->stapriv, pstassoc->macaddr);
                if (psta) {
                        /* bss_cap_update_on_sta_join23a(adapter, psta); */
                        /* sta_info_update23a(adapter, psta); */
                        ap_sta_info_defer_update23a(adapter, psta);
-
-                       rtw_stassoc_hw_rpt23a(adapter,psta);
                }
                return;
        }
@@ -1336,13 +1372,19 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf)
        psta = rtw_get_stainfo23a(&adapter->stapriv, pstassoc->macaddr);
        if (psta != NULL) {
                /* the sta have been in sta_info_queue => do nothing */
-               RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("Error: rtw_stassoc_event_callback23a: sta has been in sta_hash_queue\n"));
-               return; /* between drv has received this event before and  fw have not yet to set key to CAM_ENTRY) */
+               RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,
+                        ("Error: rtw_stassoc_event_callback23a: sta has "
+                         "been in sta_hash_queue\n"));
+               /* between drv has received this event before and
+                  fw have not yet to set key to CAM_ENTRY) */
+               return;
        }
 
        psta = rtw_alloc_stainfo23a(&adapter->stapriv, pstassoc->macaddr);
-       if (psta == NULL) {
-               RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("Can't alloc sta_info when rtw_stassoc_event_callback23a\n"));
+       if (!psta) {
+               RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,
+                        ("Can't alloc sta_info when "
+                         "rtw_stassoc_event_callback23a\n"));
                return;
        }
 
@@ -1352,25 +1394,25 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf)
        /* psta->aid = (uint)pstassoc->cam_id; */
        DBG_8723A("%s\n",__func__);
        /* for ad-hoc mode */
-       rtw_hal_set_odm_var23a(adapter,HAL_ODM_STA_INFO,psta,true);
-
-       rtw_stassoc_hw_rpt23a(adapter,psta);
+       rtw_hal_set_odm_var23a(adapter, HAL_ODM_STA_INFO, psta, true);
 
-       if(adapter->securitypriv.dot11AuthAlgrthm==dot11AuthAlgrthm_8021X)
-               psta->dot118021XPrivacy = adapter->securitypriv.dot11PrivacyAlgrthm;
+       if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)
+               psta->dot118021XPrivacy =
+                       adapter->securitypriv.dot11PrivacyAlgrthm;
 
        psta->ieee8021x_blocked = false;
 
        spin_lock_bh(&pmlmepriv->lock);
 
-       if ( (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)==true ) ||
-               (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)==true ) )
-       {
-               if(adapter->stapriv.asoc_sta_count== 2)
-               {
+       if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) ||
+           check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
+               if (adapter->stapriv.asoc_sta_count == 2) {
                        spin_lock_bh(&pmlmepriv->scanned_queue.lock);
-                       ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, cur_network->network.MacAddress);
-                       if(ptarget_wlan)        ptarget_wlan->fixed = true;
+                       ptarget_wlan =
+                               rtw_find_network23a(&pmlmepriv->scanned_queue,
+                                                   cur_network->network.MacAddress);
+                       if (ptarget_wlan)
+                               ptarget_wlan->fixed = true;
                        spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
                        /*  a sta + bc/mc_stainfo (not Ibss_stainfo) */
                        rtw_indicate_connect23a(adapter);
@@ -1384,47 +1426,40 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf)
 
 void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf)
 {
-       int mac_id=-1;
+       int mac_id;
        struct sta_info *psta;
-       struct wlan_network* pwlan = NULL;
-       struct wlan_bssid_ex    *pdev_network=NULL;
-       u8* pibss = NULL;
-       struct  mlme_priv *pmlmepriv = &adapter->mlmepriv;
-       struct  stadel_event *pstadel   = (struct stadel_event*)pbuf;
-       struct  sta_priv *pstapriv = &adapter->stapriv;
+       struct wlan_network* pwlan;
+       struct wlan_bssid_ex *pdev_network;
+       u8 *pibss;
+       struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+       struct stadel_event *pstadel = (struct stadel_event *)pbuf;
+       struct sta_priv *pstapriv = &adapter->stapriv;
        struct wlan_network *tgt_network = &pmlmepriv->cur_network;
 
        psta = rtw_get_stainfo23a(&adapter->stapriv, pstadel->macaddr);
-       if(psta)
+       if (psta)
                mac_id = psta->mac_id;
        else
                mac_id = pstadel->mac_id;
 
-       DBG_8723A("%s(mac_id=%d)=" MAC_FMT "\n", __func__, mac_id, MAC_ARG(pstadel->macaddr));
-
-       if(mac_id>=0) {
-               u16 media_status;
-               media_status = (mac_id<<8)|0; /*   MACID|OPMODE:0 means disconnect */
-               /* for STA,AP,ADHOC mode, report disconnect stauts to FW */
-               rtw_hal_set_hwreg23a(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status);
-       }
+       DBG_8723A("%s(mac_id=%d)=" MAC_FMT "\n", __func__, mac_id,
+                 MAC_ARG(pstadel->macaddr));
 
         if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
-        {
                return;
-        }
 
        mlmeext_sta_del_event_callback23a(adapter);
 
        spin_lock_bh(&pmlmepriv->lock);
 
-       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
-       {
-               if (rtw_to_roaming(adapter) > 0)
-                       pmlmepriv->to_roaming--; /* this stadel_event is caused by roaming, decrease to_roaming */
-               else if (rtw_to_roaming(adapter) == 0)
+       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
+               if (adapter->mlmepriv.to_roaming > 0) {
+                       /* this stadel_event is caused by roaming,
+                          decrease to_roaming */
+                       pmlmepriv->to_roaming--;
+               } else if (adapter->mlmepriv.to_roaming == 0)
                        rtw_set_roaming(adapter, adapter->registrypriv.max_roaming_times);
-               if (*((unsigned short *)(pstadel->rsvd)) != WLAN_REASON_EXPIRATION_CHK)
+               if (*((u16 *)pstadel->rsvd) != WLAN_REASON_EXPIRATION_CHK)
                        rtw_set_roaming(adapter, 0); /* don't roam */
 
                rtw_free_uc_swdec_pending_queue23a(adapter);
@@ -1433,32 +1468,33 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf)
                rtw_indicate_disconnect23a(adapter);
                spin_lock_bh(&pmlmepriv->scanned_queue.lock);
                /*  remove the network entry in scanned_queue */
-               pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress);
+               pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue,
+                                           tgt_network->network.MacAddress);
                if (pwlan) {
                        pwlan->fixed = false;
                        rtw_free_network_nolock(pmlmepriv, pwlan);
                }
                spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
 
-               _rtw23a_roaming(adapter, tgt_network);
+               _rtw_roaming(adapter, tgt_network);
        }
 
        if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) ||
-             check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))
-       {
+           check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
 
                spin_lock_bh(&pstapriv->sta_hash_lock);
                rtw_free_stainfo23a(adapter,  psta);
                spin_unlock_bh(&pstapriv->sta_hash_lock);
 
-               if (adapter->stapriv.asoc_sta_count == 1) /* a sta + bc/mc_stainfo (not Ibss_stainfo) */
-               {
+               /* a sta + bc/mc_stainfo (not Ibss_stainfo) */
+               if (adapter->stapriv.asoc_sta_count == 1) {
                        spin_lock_bh(&pmlmepriv->scanned_queue.lock);
                        /* free old ibss network */
-                       /* pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, pstadel->macaddr); */
-                       pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress);
-                       if (pwlan)
-                       {
+                       /* pwlan = rtw_find_network23a(
+                          &pmlmepriv->scanned_queue, pstadel->macaddr); */
+                       pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue,
+                                                   tgt_network->network.MacAddress);
+                       if (pwlan) {
                                pwlan->fixed = false;
                                rtw_free_network_nolock(pmlmepriv, pwlan);
                        }
@@ -1467,7 +1503,8 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf)
                        pdev_network = &adapter->registrypriv.dev_network;
                        pibss = adapter->registrypriv.dev_network.MacAddress;
 
-                       memcpy(pdev_network, &tgt_network->network, get_wlan_bssid_ex_sz(&tgt_network->network));
+                       memcpy(pdev_network, &tgt_network->network,
+                              get_wlan_bssid_ex_sz(&tgt_network->network));
 
                        memset(&pdev_network->Ssid, 0,
                               sizeof(struct cfg80211_ssid));
@@ -1478,32 +1515,28 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf)
 
                        rtw_generate_random_ibss23a(pibss);
 
-                       if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))
-                       {
+                       if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
                                set_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
                                _clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE);
                        }
 
-                       if (rtw_createbss_cmd23a(adapter)!= _SUCCESS)
-                       {
-
-                               RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("***Error =>stadel_event_callback: rtw_createbss_cmd23a status FAIL***\n "));
-
+                       if (rtw_createbss_cmd23a(adapter) != _SUCCESS) {
+                               RT_TRACE(_module_rtl871x_ioctl_set_c_,
+                                        _drv_err_,
+                                        ("***Error =>stadel_event_callback: "
+                                         "rtw_createbss_cmd23a status "
+                                         "FAIL***\n"));
                        }
-
                }
-
        }
 
        spin_unlock_bh(&pmlmepriv->lock);
-
 }
 
 void rtw_cpwm_event_callback23a(struct rtw_adapter *padapter, u8 *pbuf)
 {
-
-       RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("+rtw_cpwm_event_callback23a !!!\n"));
-
+       RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
+                ("+rtw_cpwm_event_callback23a !!!\n"));
 }
 
 /*
@@ -1518,23 +1551,28 @@ void rtw23a_join_to_handler (unsigned long data)
 
        DBG_8723A("%s, fw_state=%x\n", __func__, get_fwstate(pmlmepriv));
 
-       if(adapter->bDriverStopped ||adapter->bSurpriseRemoved)
+       if (adapter->bDriverStopped ||adapter->bSurpriseRemoved)
                return;
 
        spin_lock_bh(&pmlmepriv->lock);
 
-       if (rtw_to_roaming(adapter) > 0) { /* join timeout caused by roaming */
-               while(1) {
+       if (adapter->mlmepriv.to_roaming > 0) {
+               /* join timeout caused by roaming */
+               while (1) {
                        pmlmepriv->to_roaming--;
-                       if (rtw_to_roaming(adapter) != 0) { /* try another */
+                       if (adapter->mlmepriv.to_roaming != 0) {
+                               /* try another */
                                DBG_8723A("%s try another roaming\n", __func__);
-                               if (_SUCCESS!= (do_join_r = rtw_do_join23a(adapter))) {
-                                       DBG_8723A("%s roaming do_join return %d\n", __func__ , do_join_r);
+                               do_join_r = rtw_do_join23a(adapter);
+                               if (do_join_r != _SUCCESS) {
+                                       DBG_8723A("%s roaming do_join return "
+                                                 "%d\n", __func__ , do_join_r);
                                        continue;
                                }
                                break;
                        } else {
-                               DBG_8723A("%s We've try roaming but fail\n", __func__);
+                               DBG_8723A("%s We've try roaming but fail\n",
+                                         __func__);
                                rtw_indicate_disconnect23a(adapter);
                                break;
                        }
@@ -1543,7 +1581,8 @@ void rtw23a_join_to_handler (unsigned long data)
                rtw_indicate_disconnect23a(adapter);
                free_scanqueue(pmlmepriv);/*  */
 
-               /* indicate disconnect for the case that join_timeout and check_fwstate != FW_LINKED */
+               /* indicate disconnect for the case that join_timeout and
+                  check_fwstate != FW_LINKED */
                rtw_cfg80211_indicate_disconnect(adapter);
        }
 
@@ -1560,7 +1599,8 @@ void rtw_scan_timeout_handler23a(unsigned long data)
        struct rtw_adapter *adapter = (struct rtw_adapter *)data;
        struct  mlme_priv *pmlmepriv = &adapter->mlmepriv;
 
-       DBG_8723A(FUNC_ADPT_FMT" fw_state =%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv));
+       DBG_8723A(FUNC_ADPT_FMT" fw_state =%x\n", FUNC_ADPT_ARG(adapter),
+                 get_fwstate(pmlmepriv));
 
        spin_lock_bh(&pmlmepriv->lock);
 
@@ -1568,7 +1608,7 @@ void rtw_scan_timeout_handler23a(unsigned long data)
 
        spin_unlock_bh(&pmlmepriv->lock);
 
-       rtw_indicate_scan_done23a(adapter, true);
+       rtw_cfg80211_indicate_scan_done(wdev_to_priv(adapter->rtw_wdev), true);
 }
 
 static void rtw_auto_scan_handler(struct rtw_adapter *padapter)
@@ -1581,7 +1621,8 @@ static void rtw_auto_scan_handler(struct rtw_adapter *padapter)
                if (pmlmepriv->scan_interval == 0) {
                        DBG_8723A("%s\n", __func__);
                        rtw_set_802_11_bssid23a_list_scan(padapter, NULL, 0);
-                       pmlmepriv->scan_interval = SCAN_INTERVAL;/*  30*2 sec = 60sec */
+                       /*  30*2 sec = 60sec */
+                       pmlmepriv->scan_interval = SCAN_INTERVAL;
                }
        }
 }
@@ -1594,7 +1635,8 @@ void rtw_dynamic_check_timer_handler(unsigned long data)
        if (adapter->hw_init_completed == false)
                goto out;
 
-       if ((adapter->bDriverStopped == true)||(adapter->bSurpriseRemoved == true))
+       if (adapter->bDriverStopped == true ||
+           adapter->bSurpriseRemoved == true)
                goto out;
 
        if (adapter->net_closed == true)
@@ -1602,16 +1644,9 @@ void rtw_dynamic_check_timer_handler(unsigned long data)
 
        rtw_dynamic_chk_wk_cmd23a(adapter);
 
-       if (pregistrypriv->wifi_spec == 1)
-       {
-#ifdef CONFIG_8723AU_P2P
-               struct wifidirect_info *pwdinfo = &adapter->wdinfo;
-               if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-#endif
-               {
-                       /* auto site survey */
-                       rtw_auto_scan_handler(adapter);
-               }
+       if (pregistrypriv->wifi_spec == 1) {
+               /* auto site survey */
+               rtw_auto_scan_handler(adapter);
        }
 out:
        mod_timer(&adapter->mlmepriv.dynamic_chk_timer,
@@ -1628,8 +1663,6 @@ void rtw_clear_scan_deny(struct rtw_adapter *adapter)
 {
        struct mlme_priv *mlmepriv = &adapter->mlmepriv;
        atomic_set(&mlmepriv->set_scan_deny, 0);
-       if (0)
-       DBG_8723A(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter));
 }
 
 void rtw_set_scan_deny_timer_hdl(unsigned long data)
@@ -1642,12 +1675,9 @@ void rtw_set_scan_deny(struct rtw_adapter *adapter, u32 ms)
 {
        struct mlme_priv *mlmepriv = &adapter->mlmepriv;
 
-       if (0)
-       DBG_8723A(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter));
        atomic_set(&mlmepriv->set_scan_deny, 1);
        mod_timer(&mlmepriv->set_scan_deny_timer,
                  jiffies + msecs_to_jiffies(ms));
-
 }
 
 #if defined(IEEE80211_SCAN_RESULT_EXPIRE)
@@ -1657,15 +1687,19 @@ void rtw_set_scan_deny(struct rtw_adapter *adapter, u32 ms)
 #endif
 
 /*
-* Select a new join candidate from the original @param candidate and @param competitor
+* Select a new join candidate from the original @param candidate and
+*     @param competitor
 * @return true: candidate is updated
 * @return false: candidate is not updated
 */
-static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv
-       , struct wlan_network **candidate, struct wlan_network *competitor)
+static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv,
+                                   struct wlan_network **candidate,
+                                   struct wlan_network *competitor)
 {
        int updated = false;
-       struct rtw_adapter *adapter = container_of(pmlmepriv, struct rtw_adapter, mlmepriv);
+       struct rtw_adapter *adapter;
+
+       adapter = container_of(pmlmepriv, struct rtw_adapter, mlmepriv);
 
        /* check bssid, if needed */
        if (pmlmepriv->assoc_by_bssid == true) {
@@ -1684,10 +1718,10 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv
                        goto exit;
        }
 
-       if (rtw_is_desired_network(adapter, competitor)  == false)
+       if (rtw_is_desired_network(adapter, competitor) == false)
                goto exit;
 
-       if (rtw_to_roaming(adapter) > 0) {
+       if (adapter->mlmepriv.to_roaming > 0) {
                unsigned int passed;
 
                passed = jiffies_to_msecs(jiffies - competitor->last_scanned);
@@ -1697,19 +1731,21 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv
                        goto exit;
        }
 
-       if (*candidate == NULL ||(*candidate)->network.Rssi<competitor->network.Rssi) {
+       if (!*candidate ||
+           (*candidate)->network.Rssi<competitor->network.Rssi) {
                *candidate = competitor;
                updated = true;
        }
 
        if (updated) {
-               DBG_8723A("[by_bssid:%u][assoc_ssid:%s][to_roaming:%u] new candidate: %s("MAC_FMT") rssi:%d\n",
-                       pmlmepriv->assoc_by_bssid,
-                       pmlmepriv->assoc_ssid.ssid,
-                       rtw_to_roaming(adapter),
-                       (*candidate)->network.Ssid.ssid,
-                       MAC_ARG((*candidate)->network.MacAddress),
-                       (int)(*candidate)->network.Rssi);
+               DBG_8723A("[by_bssid:%u][assoc_ssid:%s][to_roaming:%u] "
+                         "new candidate: %s("MAC_FMT") rssi:%d\n",
+                         pmlmepriv->assoc_by_bssid,
+                         pmlmepriv->assoc_ssid.ssid,
+                         adapter->mlmepriv.to_roaming,
+                         (*candidate)->network.Ssid.ssid,
+                         MAC_ARG((*candidate)->network.MacAddress),
+                         (int)(*candidate)->network.Rssi);
        }
 
 exit:
@@ -1732,8 +1768,8 @@ int rtw_select_and_join_from_scanned_queue23a(struct mlme_priv *pmlmepriv)
        struct list_head *phead, *plist, *ptmp;
        struct rtw_adapter *adapter;
        struct rtw_queue *queue = &pmlmepriv->scanned_queue;
-       struct  wlan_network    *pnetwork = NULL;
-       struct  wlan_network    *candidate = NULL;
+       struct wlan_network *pnetwork;
+       struct wlan_network *candidate = NULL;
 
        spin_lock_bh(&pmlmepriv->scanned_queue.lock);
        phead = get_list_head(queue);
@@ -1764,7 +1800,7 @@ int rtw_select_and_join_from_scanned_queue23a(struct mlme_priv *pmlmepriv)
        }
 
        /*  check for situation of  _FW_LINKED */
-       if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
+       if (check_fwstate(pmlmepriv, _FW_LINKED)) {
                DBG_8723A("%s: _FW_LINKED while ask_for_joinbss!!!\n",
                          __func__);
 
@@ -1782,7 +1818,7 @@ exit:
 }
 
 int rtw_set_auth23a(struct rtw_adapter * adapter,
-                struct security_priv *psecuritypriv)
+                   struct security_priv *psecuritypriv)
 {
        struct cmd_obj* pcmd;
        struct setauth_parm *psetauthparm;
@@ -1811,8 +1847,6 @@ int rtw_set_auth23a(struct rtw_adapter * adapter,
        pcmd->rsp = NULL;
        pcmd->rspsz = 0;
 
-       INIT_LIST_HEAD(&pcmd->list);
-
        RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,
                 ("after enqueue set_auth_cmd, auth_mode=%x\n",
                  psecuritypriv->dot11AuthAlgrthm));
@@ -1825,7 +1859,7 @@ exit:
 }
 
 int rtw_set_key23a(struct rtw_adapter *adapter,
-               struct security_priv *psecuritypriv, int keyid, u8 set_tx)
+                  struct security_priv *psecuritypriv, int keyid, u8 set_tx)
 {
        u8 keylen;
        struct cmd_obj *pcmd;
@@ -1850,9 +1884,9 @@ int rtw_set_key23a(struct rtw_adapter *adapter,
                psetkeyparm->algorithm = (unsigned char)
                        psecuritypriv->dot118021XGrpPrivacy;
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("\n rtw_set_key23a: psetkeyparm->algorithm = (unsigned "
-                         "char)psecuritypriv->dot118021XGrpPrivacy =%d\n",
-                         psetkeyparm->algorithm));
+                        ("\n rtw_set_key23a: psetkeyparm->algorithm = "
+                         "(unsigned char)psecuritypriv->dot118021XGrpPrivacy "
+                         "=%d\n", psetkeyparm->algorithm));
        } else {
                psetkeyparm->algorithm = (u8)psecuritypriv->dot11PrivacyAlgrthm;
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
@@ -1897,8 +1931,8 @@ int rtw_set_key23a(struct rtw_adapter *adapter,
                break;
        default:
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("\n rtw_set_key23a:psecuritypriv->dot11PrivacyAlgrthm = "
-                         "%x (must be 1 or 2 or 4 or 5)\n",
+                        ("\n rtw_set_key23a:psecuritypriv->dot11PrivacyAlgrthm"
+                         " = %x (must be 1 or 2 or 4 or 5)\n",
                          psecuritypriv->dot11PrivacyAlgrthm));
                res = _FAIL;
                kfree(pcmd);
@@ -1912,8 +1946,6 @@ int rtw_set_key23a(struct rtw_adapter *adapter,
        pcmd->rsp = NULL;
        pcmd->rspsz = 0;
 
-       INIT_LIST_HEAD(&pcmd->list);
-
        /* sema_init(&pcmd->cmd_sem, 0); */
 
        res = rtw_enqueue_cmd23a(pcmdpriv, pcmd);
@@ -1931,7 +1963,7 @@ int rtw_restruct_wmm_ie23a(struct rtw_adapter *adapter, u8 *in_ie,
        unsigned int i, j;
 
        i = 12; /* after the fixed IE */
-       while(i < in_len) {
+       while (i < in_len) {
                ielength = initial_out_len;
 
                /* WMM element ID and OUI */
@@ -1982,11 +2014,11 @@ static int SecIsInPMKIDList(struct rtw_adapter *Adapter, u8 *bssid)
                        i++;
                        /* continue; */
                }
-       } while(i < NUM_PMKID_CACHE);
+       } while (i < NUM_PMKID_CACHE);
 
-       if (i == NUM_PMKID_CACHE) {
+       if (i == NUM_PMKID_CACHE)
                i = -1;/*  Could not find. */
-       else {
+       else {
                /*  There is one Pre-Authentication Key for
                    the specific BSSID. */
        }
@@ -2023,8 +2055,9 @@ static int rtw_append_pmkid(struct rtw_adapter *Adapter, int iEntry,
        }
        return ie_len;
 }
+
 int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie,
-                       uint in_len)
+                          uint in_len)
 {
        u8 authmode;
        uint ielength;
@@ -2035,41 +2068,39 @@ int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie,
        uint ndissecuritytype = psecuritypriv->ndisencryptstatus;
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_,
-                ("+rtw_restruct_sec_ie23a: ndisauthmode=%d ndissecuritytype=%d\n",
-                 ndisauthmode, ndissecuritytype));
+                ("+rtw_restruct_sec_ie23a: ndisauthmode=%d "
+                 "ndissecuritytype=%d\n", ndisauthmode, ndissecuritytype));
 
        /* copy fixed ie only */
        memcpy(out_ie, in_ie, 12);
        ielength = 12;
-       if ((ndisauthmode==Ndis802_11AuthModeWPA) ||
-           (ndisauthmode==Ndis802_11AuthModeWPAPSK))
-               authmode=_WPA_IE_ID_;
-       if ((ndisauthmode==Ndis802_11AuthModeWPA2) ||
-           (ndisauthmode==Ndis802_11AuthModeWPA2PSK))
-               authmode=_WPA2_IE_ID_;
+       if (ndisauthmode == Ndis802_11AuthModeWPA ||
+           ndisauthmode == Ndis802_11AuthModeWPAPSK)
+               authmode = WLAN_EID_VENDOR_SPECIFIC;
+       if (ndisauthmode == Ndis802_11AuthModeWPA2 ||
+           ndisauthmode == Ndis802_11AuthModeWPA2PSK)
+               authmode = _WPA2_IE_ID_;
 
        if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) {
                memcpy(out_ie + ielength, psecuritypriv->wps_ie,
                       psecuritypriv->wps_ie_len);
 
                ielength += psecuritypriv->wps_ie_len;
-       } else if ((authmode==_WPA_IE_ID_) || (authmode==_WPA2_IE_ID_)) {
+       } else if (authmode == WLAN_EID_VENDOR_SPECIFIC ||
+                  authmode == _WPA2_IE_ID_) {
                /* copy RSN or SSN */
                memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0],
                       psecuritypriv->supplicant_ie[1] + 2);
                ielength += psecuritypriv->supplicant_ie[1] + 2;
-               rtw_report_sec_ie23a(adapter, authmode,
-                                 psecuritypriv->supplicant_ie);
        }
 
        iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid);
-       if (iEntry < 0) {
+       if (iEntry < 0)
                return ielength;
-       } else {
-               if (authmode == _WPA2_IE_ID_) {
-                       ielength=rtw_append_pmkid(adapter, iEntry,
-                                                 out_ie, ielength);
-               }
+       else {
+               if (authmode == _WPA2_IE_ID_)
+                       ielength = rtw_append_pmkid(adapter, iEntry,
+                                                   out_ie, ielength);
        }
 
        return ielength;
@@ -2157,12 +2188,11 @@ void rtw_update_registrypriv_dev_network23a(struct rtw_adapter* adapter)
        pdev_network->IELength = sz;
 
        pdev_network->Length =
-               get_wlan_bssid_ex_sz((struct wlan_bssid_ex *)pdev_network);
+               get_wlan_bssid_ex_sz(pdev_network);
 
        /* notes: translate IELength & Length after assign the
           Length to cmdsz in createbss_cmd(); */
        /* pdev_network->IELength = cpu_to_le32(sz); */
-
 }
 
 void rtw_get_encrypt_decrypt_from_registrypriv23a(struct rtw_adapter* adapter)
@@ -2193,22 +2223,20 @@ void rtw_joinbss_reset23a(struct rtw_adapter *padapter)
                        threshold = 1;
                else
                        threshold = 0;
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_RXDMA_AGG_PG_TH,
-                                 (u8 *)(&threshold));
-       } else {
+       } else
                threshold = 1;
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_RXDMA_AGG_PG_TH,
-                                 (u8 *)(&threshold));
-       }
+
+       rtl8723a_set_rxdma_agg_pg_th(padapter, threshold);
 }
 
 /* the fucntion is >= passive_level */
 unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie,
-                                  u8 *out_ie, uint in_len, uint *pout_len)
+                                     u8 *out_ie, uint in_len, uint *pout_len)
 {
-       u32 ielen, out_len;
+       u32 out_len;
        int max_rx_ampdu_factor;
-       unsigned char *p, *pframe;
+       unsigned char *pframe;
+       const u8 *p;
        struct ieee80211_ht_cap ht_capie;
        unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -2217,14 +2245,14 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie,
 
        phtpriv->ht_option = false;
 
-       p = rtw_get_ie23a(in_ie + 12, _HT_CAPABILITY_IE_, &ielen, in_len - 12);
+       p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, in_ie + 12, in_len -12);
 
-       if (p && ielen > 0) {
+       if (p && p[1] > 0) {
                u32 rx_packet_offset, max_recvbuf_sz;
                if (pqospriv->qos_option == 0) {
                        out_len = *pout_len;
                        pframe = rtw_set_ie23a(out_ie + out_len,
-                                           _VENDOR_SPECIFIC_IE_,
+                                           WLAN_EID_VENDOR_SPECIFIC,
                                            _WMM_IE_Length_, WMM_IE, pout_len);
 
                        pqospriv->qos_option = 1;
@@ -2254,17 +2282,19 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie,
                        ht_capie.ampdu_params_info |=
                                (IEEE80211_HT_AMPDU_PARM_DENSITY & 0x00);
 
-               pframe = rtw_set_ie23a(out_ie + out_len, _HT_CAPABILITY_IE_,
+               pframe = rtw_set_ie23a(out_ie + out_len, WLAN_EID_HT_CAPABILITY,
                                    sizeof(struct ieee80211_ht_cap),
                                    (unsigned char*)&ht_capie, pout_len);
 
                phtpriv->ht_option = true;
 
-               p = rtw_get_ie23a(in_ie + 12, _HT_ADD_INFO_IE_, &ielen, in_len-12);
-               if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) {
+               p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, in_ie + 12,
+                                    in_len -12);
+               if (p && (p[1] == sizeof(struct ieee80211_ht_addt_info))) {
                        out_len = *pout_len;
-                       pframe = rtw_set_ie23a(out_ie + out_len, _HT_ADD_INFO_IE_,
-                                           ielen, p + 2 , pout_len);
+                       pframe = rtw_set_ie23a(out_ie + out_len,
+                                              WLAN_EID_HT_OPERATION,
+                                              p[1], p + 2 , pout_len);
                }
        }
 
@@ -2274,18 +2304,14 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie,
 /* the fucntion is > passive_level (in critical_section) */
 void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len)
 {
-       u8 *p, max_ampdu_sz;
-       int len;
-       /* struct sta_info *bmc_sta, *psta; */
+       u8 max_ampdu_sz;
+       const u8 *p;
        struct ieee80211_ht_cap *pht_capie;
        struct ieee80211_ht_addt_info *pht_addtinfo;
-       /* struct recv_reorder_ctrl *preorder_ctrl; */
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-       struct ht_priv          *phtpriv = &pmlmepriv->htpriv;
-       /* struct recv_priv *precvpriv = &padapter->recvpriv; */
+       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+       struct ht_priv *phtpriv = &pmlmepriv->htpriv;
        struct registry_priv *pregistrypriv = &padapter->registrypriv;
-       /* struct wlan_network *pcur_network = &pmlmepriv->cur_network;; */
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
+       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
 
        if (!phtpriv->ht_option)
@@ -2296,51 +2322,51 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len)
 
        DBG_8723A("+rtw_update_ht_cap23a()\n");
 
+       /* Adjust pie + ie_len for our searches */
+       pie += sizeof (struct ndis_802_11_fixed_ies);
+       ie_len -= sizeof (struct ndis_802_11_fixed_ies);
+
        /* maybe needs check if ap supports rx ampdu. */
-       if ((phtpriv->ampdu_enable == false) && (pregistrypriv->ampdu_enable == 1)) {
+       if (phtpriv->ampdu_enable == false &&
+           pregistrypriv->ampdu_enable == 1) {
                if (pregistrypriv->wifi_spec == 1)
                        phtpriv->ampdu_enable = false;
                else
                        phtpriv->ampdu_enable = true;
-       } else if (pregistrypriv->ampdu_enable == 2) {
+       } else if (pregistrypriv->ampdu_enable == 2)
                phtpriv->ampdu_enable = true;
-       }
 
        /* check Max Rx A-MPDU Size */
-       len = 0;
-       p = rtw_get_ie23a(pie+sizeof (struct ndis_802_11_fixed_ies), _HT_CAPABILITY_IE_, &len, ie_len-sizeof (struct ndis_802_11_fixed_ies));
-       if (p && len > 0) {
-               pht_capie = (struct ieee80211_ht_cap *)(p+2);
-               max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_FACTOR);
-               max_ampdu_sz = 1 << (max_ampdu_sz+3); /*  max_ampdu_sz (kbytes); */
-
-               /* DBG_8723A("rtw_update_ht_cap23a(): max_ampdu_sz =%d\n", max_ampdu_sz); */
-               phtpriv->rx_ampdu_maxlen = max_ampdu_sz;
+       p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, pie, ie_len);
+
+       if (p && p[1] > 0) {
+               pht_capie = (struct ieee80211_ht_cap *)(p + 2);
+               max_ampdu_sz = pht_capie->ampdu_params_info &
+                       IEEE80211_HT_AMPDU_PARM_FACTOR;
+               /*  max_ampdu_sz (kbytes); */
+               max_ampdu_sz = 1 << (max_ampdu_sz + 3);
 
+               phtpriv->rx_ampdu_maxlen = max_ampdu_sz;
        }
 
-       len = 0;
-       p = rtw_get_ie23a(pie+sizeof (struct ndis_802_11_fixed_ies), _HT_ADD_INFO_IE_, &len, ie_len-sizeof (struct ndis_802_11_fixed_ies));
-       if (p && len>0)
-       {
-               pht_addtinfo = (struct ieee80211_ht_addt_info *)(p+2);
+       p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, pie, ie_len);
+       if (p && p[1] > 0) {
+               pht_addtinfo = (struct ieee80211_ht_addt_info *)(p + 2);
                /* todo: */
        }
 
        /* update cur_bwmode & cur_ch_offset */
-       if ((pregistrypriv->cbw40_enable) &&
-               (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & BIT(1)) &&
-               (pmlmeinfo->HT_info.infos[0] & BIT(2)))
-       {
+       if (pregistrypriv->cbw40_enable &&
+           pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & BIT(1) &&
+           pmlmeinfo->HT_info.infos[0] & BIT(2)) {
                int i;
-               u8      rf_type;
+               u8 rf_type;
 
-               padapter->HalFunc.GetHwRegHandler(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
+               rf_type = rtl8723a_get_rf_type(padapter);
 
                /* update the MCS rates */
-               for (i = 0; i < 16; i++)
-               {
-                       if ((rf_type == RF_1T1R) || (rf_type == RF_1T2R))
+               for (i = 0; i < 16; i++) {
+                       if (rf_type == RF_1T1R || rf_type == RF_1T2R)
                                pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_1R23A[i];
                        else
                                pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_2R23A[i];
@@ -2349,24 +2375,26 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len)
                pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_40;
                switch ((pmlmeinfo->HT_info.infos[0] & 0x3))
                {
-                       case HT_EXTCHNL_OFFSET_UPPER:
-                               pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
-                               break;
+               case HT_EXTCHNL_OFFSET_UPPER:
+                       pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
+                       break;
 
-                       case HT_EXTCHNL_OFFSET_LOWER:
-                               pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER;
-                               break;
+               case HT_EXTCHNL_OFFSET_LOWER:
+                       pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER;
+                       break;
 
-                       default:
-                               pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
-                               break;
+               default:
+                       pmlmeext->cur_ch_offset =
+                               HAL_PRIME_CHNL_OFFSET_DONT_CARE;
+                       break;
                }
        }
 
        /*  */
        /*  Config SM Power Save setting */
        /*  */
-       pmlmeinfo->SM_PS = (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & 0x0C) >> 2;
+       pmlmeinfo->SM_PS = (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info &
+                           0x0C) >> 2;
        if (pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC)
                DBG_8723A("%s(): WLAN_HT_CAP_SM_PS_STATIC\n", __func__);
 
@@ -2376,124 +2404,65 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len)
        pmlmeinfo->HT_protection = pmlmeinfo->HT_info.infos[1] & 0x3;
 }
 
-void rtw_issue_addbareq_cmd23a(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe)
+void rtw_issue_addbareq_cmd23a(struct rtw_adapter *padapter,
+                              struct xmit_frame *pxmitframe)
 {
        u8 issued;
        int priority;
-       struct sta_info *psta = NULL;
+       struct sta_info *psta;
        struct ht_priv  *phtpriv;
        struct pkt_attrib *pattrib = &pxmitframe->attrib;
        s32 bmcst = is_multicast_ether_addr(pattrib->ra);
 
-       if (bmcst || (padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod<100))
+       if (bmcst || padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod < 100)
                return;
 
        priority = pattrib->priority;
 
        if (pattrib->psta)
                psta = pattrib->psta;
-       else
-       {
+       else {
                DBG_8723A("%s, call rtw_get_stainfo23a()\n", __func__);
                psta = rtw_get_stainfo23a(&padapter->stapriv, pattrib->ra);
        }
 
-       if (psta == NULL)
-       {
+       if (!psta) {
                DBG_8723A("%s, psta == NUL\n", __func__);
                return;
        }
 
-       if (!(psta->state &_FW_LINKED))
-       {
-               DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state);
+       if (!(psta->state &_FW_LINKED)) {
+               DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n",
+                         __func__, psta->state);
                return;
        }
 
        phtpriv = &psta->htpriv;
 
-       if ((phtpriv->ht_option == true) && (phtpriv->ampdu_enable == true))
-       {
+       if (phtpriv->ht_option == true && phtpriv->ampdu_enable == true) {
                issued = (phtpriv->agg_enable_bitmap>>priority)&0x1;
                issued |= (phtpriv->candidate_tid_bitmap>>priority)&0x1;
 
-               if (0 == issued)
-               {
-                       DBG_8723A("rtw_issue_addbareq_cmd23a, p =%d\n", priority);
-                       psta->htpriv.candidate_tid_bitmap |= CHKBIT((u8)priority);
-                       rtw_addbareq_cmd23a(padapter, (u8) priority, pattrib->ra);
-               }
-       }
-}
-
-inline void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming)
-{
-       if (to_roaming == 0)
-               adapter->mlmepriv.to_join = false;
-       adapter->mlmepriv.to_roaming = to_roaming;
-}
-
-inline u8 rtw_to_roaming(struct rtw_adapter *adapter)
-{
-       return adapter->mlmepriv.to_roaming;
-}
-
-void rtw23a_roaming(struct rtw_adapter *padapter, struct wlan_network *tgt_network)
-{
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-
-       spin_lock_bh(&pmlmepriv->lock);
-       _rtw23a_roaming(padapter, tgt_network);
-       spin_unlock_bh(&pmlmepriv->lock);
-}
-void _rtw23a_roaming(struct rtw_adapter *padapter, struct wlan_network *tgt_network)
-{
-       struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
-       struct wlan_network *pnetwork;
-       int do_join_r;
-
-       if (tgt_network != NULL)
-               pnetwork = tgt_network;
-       else
-               pnetwork = &pmlmepriv->cur_network;
-
-       if (0 < rtw_to_roaming(padapter)) {
-               DBG_8723A("roaming from %s("MAC_FMT"), length:%d\n",
-                         pnetwork->network.Ssid.ssid,
-                         MAC_ARG(pnetwork->network.MacAddress),
-                         pnetwork->network.Ssid.ssid_len);
-               memcpy(&pmlmepriv->assoc_ssid, &pnetwork->network.Ssid,
-                      sizeof(struct cfg80211_ssid));
-
-               pmlmepriv->assoc_by_bssid = false;
-
-               while(1) {
-                       if (_SUCCESS == (do_join_r = rtw_do_join23a(padapter))) {
-                               break;
-                       } else {
-                               DBG_8723A("roaming do_join return %d\n", do_join_r);
-                               pmlmepriv->to_roaming--;
-
-                               if (0 < rtw_to_roaming(padapter)) {
-                                       continue;
-                               } else {
-                                       DBG_8723A("%s(%d) -to roaming fail, indicate_disconnect\n", __func__, __LINE__);
-                                       rtw_indicate_disconnect23a(padapter);
-                                       break;
-                               }
-                       }
+               if (issued == 0) {
+                       DBG_8723A("rtw_issue_addbareq_cmd23a, p =%d\n",
+                                 priority);
+                       psta->htpriv.candidate_tid_bitmap |=
+                               CHKBIT((u8)priority);
+                       rtw_addbareq_cmd23a(padapter, (u8) priority,
+                                           pattrib->ra);
                }
        }
 }
 
 int rtw_linked_check(struct rtw_adapter *padapter)
 {
-       if ((check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE)) ||
-           (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE))) {
+       if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) ||
+           check_fwstate(&padapter->mlmepriv,
+                         WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) {
                if (padapter->stapriv.asoc_sta_count > 2)
                        return true;
        } else {        /* Station mode */
-               if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == true)
+               if (check_fwstate(&padapter->mlmepriv, _FW_LINKED))
                        return true;
        }
        return false;
index 1f3e8a0aece4603a7b26a9b704290ef198f13caa..eb7b98e2e5be6eff5b22112acc7fc8acf6a3d103 100644 (file)
 #include <wlan_bssdef.h>
 #include <mlme_osdep.h>
 #include <recv_osdep.h>
-#include <ethernet.h>
 #include <linux/ieee80211.h>
 
 #ifdef CONFIG_8723AU_BT_COEXIST
 #include <rtl8723a_hal.h>
 #endif
 
+static int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+static int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+static int OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+static int OnProbeRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+static int DoReserved23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+static int OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+static int OnAtim23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+static int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+static int OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+static int OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+static int OnDeAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+static int OnAction23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+
+static int on_action_spct23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+static int OnAction23a_qos(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+static int OnAction23a_dls(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+static int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+static int on_action_public23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+static int OnAction23a_ht(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+static int OnAction23a_wmm(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+static int OnAction23a_p2p(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+
 static struct mlme_handler mlme_sta_tbl[]={
        {"OnAssocReq23a",               &OnAssocReq23a},
        {"OnAssocRsp23a",               &OnAssocRsp23a},
@@ -66,7 +87,6 @@ static u8     null_addr[ETH_ALEN]= {0, 0, 0, 0, 0, 0};
 /**************************************************
 OUI definitions for the vendor specific IE
 ***************************************************/
-unsigned char  RTW_WPA_OUI23A[] = {0x00, 0x50, 0xf2, 0x01};
 unsigned char WMM_OUI23A[] = {0x00, 0x50, 0xf2, 0x02};
 unsigned char  WPS_OUI23A[] = {0x00, 0x50, 0xf2, 0x04};
 unsigned char  P2P_OUI23A[] = {0x50, 0x6F, 0x9A, 0x09};
@@ -229,6 +249,17 @@ static struct fwevent wlanevents[] =
 };
 
 
+static void rtw_correct_TSF(struct rtw_adapter *padapter)
+{
+       hw_var_set_correct_tsf(padapter);
+}
+
+static void
+rtw_update_TSF(struct mlme_ext_priv *pmlmeext, struct ieee80211_mgmt *mgmt)
+{
+       pmlmeext->TSFValue = get_unaligned_le64(&mgmt->u.beacon.timestamp);
+}
+
 /*
  * Search the @param channel_num in given @param channel_set
  * @ch_set: the given channel set
@@ -388,96 +419,88 @@ static void init_channel_list(struct rtw_adapter *padapter,
        channel_list->reg_classes = cla;
 }
 
-static u8 init_channel_set(struct rtw_adapter* padapter, u8 ChannelPlan,
-                          struct rt_channel_info *channel_set)
+static u8 init_channel_set(struct rtw_adapter* padapter, u8 cplan,
+                          struct rt_channel_info *c_set)
 {
-       u8      index, chanset_size = 0;
-       u8      b5GBand = false, b2_4GBand = false;
-       u8      Index2G = 0, Index5G = 0;
+       u8 i, ch_size = 0;
+       u8 b5GBand = false, b2_4GBand = false;
+       u8 Index2G = 0, Index5G = 0;
 
-       memset(channel_set, 0, sizeof(struct rt_channel_info)*MAX_CHANNEL_NUM);
+       memset(c_set, 0, sizeof(struct rt_channel_info) * MAX_CHANNEL_NUM);
 
-       if (ChannelPlan >= RT_CHANNEL_DOMAIN_MAX &&
-           ChannelPlan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) {
-               DBG_8723A("ChannelPlan ID %x error !!!!!\n", ChannelPlan);
-               return chanset_size;
+       if (cplan >= RT_CHANNEL_DOMAIN_MAX &&
+           cplan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) {
+               DBG_8723A("ChannelPlan ID %x error !!!!!\n", cplan);
+               return ch_size;
        }
 
        if (padapter->registrypriv.wireless_mode & WIRELESS_11G) {
                b2_4GBand = true;
-               if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == ChannelPlan)
+               if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == cplan)
                        Index2G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index2G;
                else
-                       Index2G = RTW_ChannelPlanMap[ChannelPlan].Index2G;
+                       Index2G = RTW_ChannelPlanMap[cplan].Index2G;
        }
 
        if (padapter->registrypriv.wireless_mode & WIRELESS_11A) {
                b5GBand = true;
-               if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == ChannelPlan)
+               if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == cplan)
                        Index5G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index5G;
                else
-                       Index5G = RTW_ChannelPlanMap[ChannelPlan].Index5G;
+                       Index5G = RTW_ChannelPlanMap[cplan].Index5G;
        }
 
        if (b2_4GBand) {
-               for (index = 0; index<RTW_ChannelPlan2G[Index2G].Len; index++) {
-                       channel_set[chanset_size].ChannelNum =
-                               RTW_ChannelPlan2G[Index2G].Channel[index];
+               for (i = 0; i < RTW_ChannelPlan2G[Index2G].Len; i++) {
+                       c_set[ch_size].ChannelNum =
+                               RTW_ChannelPlan2G[Index2G].Channel[i];
 
-                       if ((RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN == ChannelPlan) ||
+                       if ((RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN == cplan) ||
                            /* Channel 1~11 is active, and 12~14 is passive */
-                           (RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G == ChannelPlan)){
-                               if (channel_set[chanset_size].ChannelNum >= 1 &&
-                                   channel_set[chanset_size].ChannelNum <= 11)
-                                       channel_set[chanset_size].ScanType =
-                                               SCAN_ACTIVE;
-                               else if ((channel_set[chanset_size].ChannelNum >= 12 &&
-                                         channel_set[chanset_size].ChannelNum  <= 14))
-                                       channel_set[chanset_size].ScanType =
-                                               SCAN_PASSIVE;
-                       } else if (RT_CHANNEL_DOMAIN_WORLD_WIDE_13 ==
-                                  ChannelPlan ||
-                                  RT_CHANNEL_DOMAIN_WORLD_WIDE_5G ==
-                                  ChannelPlan ||
+                           RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G == cplan) {
+                               if (c_set[ch_size].ChannelNum >= 1 &&
+                                   c_set[ch_size].ChannelNum <= 11)
+                                       c_set[ch_size].ScanType = SCAN_ACTIVE;
+                               else if (c_set[ch_size].ChannelNum >= 12 &&
+                                        c_set[ch_size].ChannelNum  <= 14)
+                                       c_set[ch_size].ScanType = SCAN_PASSIVE;
+                       } else if (RT_CHANNEL_DOMAIN_WORLD_WIDE_13 == cplan ||
+                                  RT_CHANNEL_DOMAIN_WORLD_WIDE_5G == cplan ||
                                   RT_CHANNEL_DOMAIN_2G_WORLD == Index2G) {
                                /*  channel 12~13, passive scan */
-                               if (channel_set[chanset_size].ChannelNum <= 11)
-                                       channel_set[chanset_size].ScanType =
-                                               SCAN_ACTIVE;
+                               if (c_set[ch_size].ChannelNum <= 11)
+                                       c_set[ch_size].ScanType = SCAN_ACTIVE;
                                else
-                                       channel_set[chanset_size].ScanType =
-                                               SCAN_PASSIVE;
+                                       c_set[ch_size].ScanType = SCAN_PASSIVE;
                        } else
-                               channel_set[chanset_size].ScanType =
-                                       SCAN_ACTIVE;
+                               c_set[ch_size].ScanType = SCAN_ACTIVE;
 
-                       chanset_size++;
+                       ch_size++;
                }
        }
 
        if (b5GBand) {
-               for (index = 0;index<RTW_ChannelPlan5G[Index5G].Len;index++) {
-                       if (RTW_ChannelPlan5G[Index5G].Channel[index] <= 48 ||
-                           RTW_ChannelPlan5G[Index5G].Channel[index] >= 149) {
-                               channel_set[chanset_size].ChannelNum =
-                                       RTW_ChannelPlan5G[Index5G].Channel[index];
-                               if (RT_CHANNEL_DOMAIN_WORLD_WIDE_5G ==
-                                   ChannelPlan) {
+               for (i = 0; i < RTW_ChannelPlan5G[Index5G].Len; i++) {
+                       if (RTW_ChannelPlan5G[Index5G].Channel[i] <= 48 ||
+                           RTW_ChannelPlan5G[Index5G].Channel[i] >= 149) {
+                               c_set[ch_size].ChannelNum =
+                                       RTW_ChannelPlan5G[Index5G].Channel[i];
+                               if (RT_CHANNEL_DOMAIN_WORLD_WIDE_5G == cplan) {
                                        /* passive scan for all 5G channels */
-                                       channel_set[chanset_size].ScanType =
+                                       c_set[ch_size].ScanType =
                                                SCAN_PASSIVE;
                                } else
-                                       channel_set[chanset_size].ScanType =
+                                       c_set[ch_size].ScanType =
                                                SCAN_ACTIVE;
                                DBG_8723A("%s(): channel_set[%d].ChannelNum = "
-                                         "%d\n", __func__, chanset_size,
-                                         channel_set[chanset_size].ChannelNum);
-                               chanset_size++;
+                                         "%d\n", __func__, ch_size,
+                                         c_set[ch_size].ChannelNum);
+                               ch_size++;
                        }
                }
        }
 
-       return chanset_size;
+       return ch_size;
 }
 
 int init_mlme_ext_priv23a(struct rtw_adapter* padapter)
@@ -547,28 +570,28 @@ _mgt_dispatcher23a(struct rtw_adapter *padapter, struct mlme_handler *ptable,
 void mgt_dispatcher23a(struct rtw_adapter *padapter,
                    struct recv_frame *precv_frame)
 {
-       int index;
        struct mlme_handler *ptable;
 #ifdef CONFIG_8723AU_AP_MODE
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 #endif /* CONFIG_8723AU_AP_MODE */
        struct sk_buff *skb = precv_frame->pkt;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       u16 stype;
+       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
        struct sta_info *psta;
+       u16 stype;
+       int index;
 
-       if (!ieee80211_is_mgmt(hdr->frame_control))
+       if (!ieee80211_is_mgmt(mgmt->frame_control))
                return;
 
        /* receive the frames that ra(a1) is my address or ra(a1) is
           bc address. */
-       if (!ether_addr_equal(hdr->addr1, myid(&padapter->eeprompriv)) &&
-           !is_broadcast_ether_addr(hdr->addr1))
+       if (!ether_addr_equal(mgmt->da, myid(&padapter->eeprompriv)) &&
+           !is_broadcast_ether_addr(mgmt->da))
                return;
 
        ptable = mlme_sta_tbl;
 
-       stype = le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_STYPE;
+       stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
        index = stype >> 4;
 
        if (index > 13) {
@@ -579,10 +602,10 @@ void mgt_dispatcher23a(struct rtw_adapter *padapter,
        }
        ptable += index;
 
-       psta = rtw_get_stainfo23a(&padapter->stapriv, hdr->addr2);
+       psta = rtw_get_stainfo23a(&padapter->stapriv, mgmt->sa);
 
        if (psta) {
-               if (ieee80211_has_retry(hdr->frame_control)) {
+               if (ieee80211_has_retry(mgmt->frame_control)) {
                        if (precv_frame->attrib.seq_num ==
                            psta->RxMgmtFrameSeqNum) {
                                /* drop the duplicate management frame */
@@ -623,8 +646,6 @@ void mgt_dispatcher23a(struct rtw_adapter *padapter,
                break;
        default:
                _mgt_dispatcher23a(padapter, ptable, precv_frame);
-               if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)
-                       rtw_hostapd_mlme_rx23a(padapter, precv_frame);
                break;
        }
 #else
@@ -632,186 +653,63 @@ void mgt_dispatcher23a(struct rtw_adapter *padapter,
 #endif
 }
 
-#ifdef CONFIG_8723AU_P2P
-static u32 p2p_listen_state_process(struct rtw_adapter *padapter,
-                                   unsigned char *da)
-{
-       bool response = true;
-
-       if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled == false ||
-           padapter->mlmepriv.wps_probe_resp_ie == NULL ||
-           padapter->mlmepriv.p2p_probe_resp_ie == NULL) {
-               DBG_8723A("DON'T issue_probersp23a_p2p23a: p2p_enabled:%d, "
-                         "wps_probe_resp_ie:%p, p2p_probe_resp_ie:%p\n",
-                         wdev_to_priv(padapter->rtw_wdev)->p2p_enabled,
-                         padapter->mlmepriv.wps_probe_resp_ie,
-                         padapter->mlmepriv.p2p_probe_resp_ie);
-               response = false;
-       }
-
-       if (response == true)
-               issue_probersp23a_p2p23a(padapter, da);
-
-       return _SUCCESS;
-}
-#endif /* CONFIG_8723AU_P2P */
-
 /****************************************************************************
 
 Following are the callback functions for each subtype of the management frames
 
 *****************************************************************************/
 
-unsigned int OnProbeReq23a(struct rtw_adapter *padapter,
-                          struct recv_frame *precv_frame)
+static int
+OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
-       unsigned int    ielen;
-       unsigned char   *p;
+       const u8 *ie;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct wlan_bssid_ex *cur = &pmlmeinfo->network;
        struct sk_buff *skb = precv_frame->pkt;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       u8 *pframe = skb->data;
-       uint len = skb->len;
-       u8 is_valid_p2p_probereq = false;
-
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       u8 wifi_test_chk_rate = 1;
-
-       if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) &&
-           !rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE) &&
-           !rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT) &&
-           !rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH) &&
-           !rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN)) {
-               /*      mcs_rate = 0 -> CCK 1M rate */
-               /*      mcs_rate = 1 -> CCK 2M rate */
-               /*      mcs_rate = 2 -> CCK 5.5M rate */
-               /*      mcs_rate = 3 -> CCK 11M rate */
-               /*      In the P2P mode, the driver should not support
-                       the CCK rate */
-
-               /*      IOT issue: Google Nexus7 use 1M rate to send
-                       p2p_probe_req after GO nego completed and Nexus7
-                       is client */
-               if (wifi_test_chk_rate == 1) {
-                       if ((is_valid_p2p_probereq =
-                            process_probe_req_p2p_ie23a(pwdinfo, pframe,
-                                                        len)) == true) {
-                               if (rtw_p2p_chk_role(pwdinfo,
-                                                    P2P_ROLE_DEVICE)) {
-                                       u8 *sa = ieee80211_get_SA(hdr);
-                                       p2p_listen_state_process(padapter, sa);
-                                       return _SUCCESS;
-                               }
-
-                               if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-                                       goto _continue;
-                               }
-                       }
-               }
-       }
+       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
+       int len = skb->len;
 
-_continue:
-#endif /* CONFIG_8723AU_P2P */
-
-       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
+       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
                return _SUCCESS;
-       }
 
-       if (check_fwstate(pmlmepriv, _FW_LINKED) == false &&
-               check_fwstate(pmlmepriv,
-                             WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE) == false) {
+       if (!check_fwstate(pmlmepriv, _FW_LINKED) &&
+           !check_fwstate(pmlmepriv,
+                          WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE))
                return _SUCCESS;
-       }
 
-       p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) +
-                         _PROBEREQ_IE_OFFSET_, _SSID_IE_, (int *)&ielen,
-                         len - sizeof(struct ieee80211_hdr_3addr) -
-                         _PROBEREQ_IE_OFFSET_);
+       if (unlikely(!ieee80211_is_probe_req(mgmt->frame_control))) {
+               printk(KERN_WARNING "%s: Received non probe request frame\n",
+                      __func__);
+               return _FAIL;
+       }
 
-       /* check (wildcard) SSID */
-       if (p) {
-               if (is_valid_p2p_probereq == true) {
-                       goto _issue_probersp23a;
-               }
+       len -= offsetof(struct ieee80211_mgmt, u.probe_req.variable);
 
-               if ((ielen != 0 &&
-                    memcmp((void *)(p+2), cur->Ssid.ssid,
-                           cur->Ssid.ssid_len)) ||
-                   (ielen == 0 && pmlmeinfo->hidden_ssid_mode)) {
-                       return _SUCCESS;
-               }
+       ie = cfg80211_find_ie(WLAN_EID_SSID, mgmt->u.probe_req.variable, len);
 
-_issue_probersp23a:
+       /* check (wildcard) SSID */
+       if (!ie)
+               goto out;
 
-               if (check_fwstate(pmlmepriv, _FW_LINKED) == true &&
-                   pmlmepriv->cur_network.join_res == true) {
-                       /* DBG_8723A("+issue_probersp23a during ap mode\n"); */
-                       issue_probersp23a(padapter, ieee80211_get_SA(hdr),
-                                         is_valid_p2p_probereq);
-               }
+       if ((ie[1] && memcmp(ie + 2, cur->Ssid.ssid, cur->Ssid.ssid_len)) ||
+           (ie[1] == 0 && pmlmeinfo->hidden_ssid_mode)) {
+               return _SUCCESS;
        }
 
+       if (check_fwstate(pmlmepriv, _FW_LINKED) &&
+           pmlmepriv->cur_network.join_res)
+               issue_probersp23a(padapter, mgmt->sa, false);
+
+out:
        return _SUCCESS;
 }
 
-unsigned int OnProbeRsp23a(struct rtw_adapter *padapter,
-                          struct recv_frame *precv_frame)
+static int
+OnProbeRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-#ifdef CONFIG_8723AU_P2P
-       struct sk_buff *skb = precv_frame->pkt;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-#endif
-
-#ifdef CONFIG_8723AU_P2P
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) {
-               if (pwdinfo->tx_prov_disc_info.benable == true) {
-                       if (ether_addr_equal(pwdinfo->tx_prov_disc_info.peerIFAddr,
-                                   hdr->addr2)) {
-                               if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) {
-                                       pwdinfo->tx_prov_disc_info.benable = false;
-                                       issue_p2p_provision_request23a(padapter,
-                                                                                               pwdinfo->tx_prov_disc_info.ssid.ssid,
-                                                                                               pwdinfo->tx_prov_disc_info.ssid.ssid_len,
-                                                                                               pwdinfo->tx_prov_disc_info.peerDevAddr);
-                               }
-                               else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO))
-                               {
-                                       pwdinfo->tx_prov_disc_info.benable = false;
-                                       issue_p2p_provision_request23a(padapter,
-                                                                                               NULL,
-                                                                                               0,
-                                                                                               pwdinfo->tx_prov_disc_info.peerDevAddr);
-                               }
-                       }
-               }
-               return _SUCCESS;
-       } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) {
-               if (pwdinfo->nego_req_info.benable == true) {
-                       DBG_8723A("[%s] P2P State is GONEGO ING!\n", __func__);
-                       if (ether_addr_equal(pwdinfo->nego_req_info.peerDevAddr,
-                                            hdr->addr2)) {
-                               pwdinfo->nego_req_info.benable = false;
-                               issue_p2p_GO_request23a(padapter, pwdinfo->nego_req_info.peerDevAddr);
-                       }
-               }
-       } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_INVITE_REQ)) {
-               if (pwdinfo->invitereq_info.benable == true) {
-                       DBG_8723A("[%s] P2P_STATE_TX_INVITE_REQ!\n", __func__);
-                       if (ether_addr_equal(
-                                   pwdinfo->invitereq_info.peer_macaddr,
-                                   hdr->addr2)) {
-                               pwdinfo->invitereq_info.benable = false;
-                               issue_p2p_invitation_request23a(padapter, pwdinfo->invitereq_info.peer_macaddr);
-                       }
-               }
-       }
-#endif
 
        if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) {
                report_survey_event23a(padapter, precv_frame);
@@ -821,30 +719,30 @@ unsigned int OnProbeRsp23a(struct rtw_adapter *padapter,
        return _SUCCESS;
 }
 
-unsigned int OnBeacon23a(struct rtw_adapter *padapter,
-                        struct recv_frame *precv_frame)
+static int
+OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
        int cam_idx;
        struct sta_info *psta;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
+       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct sta_priv *pstapriv = &padapter->stapriv;
        struct sk_buff *skb = precv_frame->pkt;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
        u8 *pframe = skb->data;
-       uint len = skb->len;
+       int pkt_len = skb->len;
        struct wlan_bssid_ex *pbss;
        int ret = _SUCCESS;
-       u8 *p = NULL;
+       u8 *p, *pie;
+       int pie_len;
        u32 ielen = 0;
 
-       p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) +
-                         _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ielen,
-                         len - sizeof(struct ieee80211_hdr_3addr) -
-                         _BEACON_IE_OFFSET_);
-       if ((p != NULL) && (ielen > 0)) {
-               if ((*(p + 1 + ielen) == 0x2D) && (*(p + 2 + ielen) != 0x2D)) {
+       pie = mgmt->u.beacon.variable;
+       pie_len = pkt_len - offsetof(struct ieee80211_mgmt, u.beacon.variable);
+       p = rtw_get_ie23a(pie, WLAN_EID_EXT_SUPP_RATES, &ielen, pie_len);
+       if (p && ielen > 0) {
+               if (p[1 + ielen] == 0x2D && p[2 + ielen] != 0x2D) {
                        /* Invalid value 0x2D is detected in Extended Supported
                         * Rates (ESR) IE. Try to fix the IE length to avoid
                         * failed Beacon parsing.
@@ -852,8 +750,8 @@ unsigned int OnBeacon23a(struct rtw_adapter *padapter,
                        DBG_8723A("[WIFIDBG] Error in ESR IE is detected in "
                                  "Beacon of BSSID: %pM. Fix the length of "
                                  "ESR IE to avoid failed Beacon parsing.\n",
-                                 hdr->addr3);
-                       *(p + 1) = ielen - 1;
+                                 mgmt->bssid);
+                       p[1] = ielen - 1;
                }
        }
 
@@ -862,129 +760,130 @@ unsigned int OnBeacon23a(struct rtw_adapter *padapter,
                return _SUCCESS;
        }
 
-       if (ether_addr_equal(hdr->addr3, get_my_bssid23a(&pmlmeinfo->network))){
-               if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) {
-                       /* we should update current network before auth,
-                          or some IE is wrong */
-                       pbss = (struct wlan_bssid_ex *)
-                               kmalloc(sizeof(struct wlan_bssid_ex),
-                                       GFP_ATOMIC);
-                       if (pbss) {
-                               if (collect_bss_info23a(padapter, precv_frame,
-                                                       pbss) == _SUCCESS) {
-                                       update_network23a(&pmlmepriv->cur_network.network, pbss, padapter, true);
-                                       rtw_get_bcn_info23a(&pmlmepriv->cur_network);
-                               }
-                               kfree(pbss);
-                       }
+       if (!ether_addr_equal(mgmt->bssid,
+                             get_my_bssid23a(&pmlmeinfo->network)))
+               goto out;
 
-                       /* check the vendor of the assoc AP */
-                       pmlmeinfo->assoc_AP_vendor = check_assoc_AP23a(pframe + sizeof(struct ieee80211_hdr_3addr), len-sizeof(struct ieee80211_hdr_3addr));
+       if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) {
+               /* we should update current network before auth,
+                  or some IE is wrong */
+               pbss = (struct wlan_bssid_ex *)
+                       kmalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC);
+               if (pbss) {
+                       if (collect_bss_info23a(padapter, precv_frame, pbss) ==
+                           _SUCCESS) {
+                               update_network23a(
+                                       &pmlmepriv->cur_network.network, pbss,
+                                       padapter, true);
+                               rtw_get_bcn_info23a(&pmlmepriv->cur_network);
+                       }
+                       kfree(pbss);
+               }
 
-                       /* update TSF Value */
-                       update_TSF23a(pmlmeext, pframe, len);
+               /* check the vendor of the assoc AP */
+               pmlmeinfo->assoc_AP_vendor =
+                       check_assoc_AP23a((u8 *)&mgmt->u.beacon, pkt_len -
+                                         offsetof(struct ieee80211_mgmt, u));
 
-                       /* start auth */
-                       start_clnt_auth23a(padapter);
+               /* update TSF Value */
+               rtw_update_TSF(pmlmeext, mgmt);
 
-                       return _SUCCESS;
-               }
+               /* start auth */
+               start_clnt_auth23a(padapter);
 
-               if (((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) &&
-                   (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) {
-                       psta = rtw_get_stainfo23a(pstapriv, hdr->addr2);
-                       if (psta) {
-                               ret = rtw_check_bcn_info23a(padapter, pframe,
-                                                           len);
-                               if (!ret) {
-                                       DBG_8723A_LEVEL(_drv_always_,
-                                                       "ap has changed, "
-                                                       "disconnect now\n");
-                                       receive_disconnect23a(padapter, pmlmeinfo->network.MacAddress, 65535);
-                                       return _SUCCESS;
-                               }
-                               /* update WMM, ERP in the beacon */
-                               /* todo: the timer is used instead of
-                                  the number of the beacon received */
-                               if ((sta_rx_pkts(psta) & 0xf) == 0) {
-                                       /* DBG_8723A("update_bcn_info\n"); */
-                                       update_beacon23a_info(padapter, pframe,
-                                                             len, psta);
-                               }
+               return _SUCCESS;
+       }
 
-#ifdef CONFIG_8723AU_P2P
-                               process_p2p_ps_ie23a(padapter, (pframe + sizeof(struct ieee80211_hdr_3addr)), (len - sizeof(struct ieee80211_hdr_3addr)));
-#endif /* CONFIG_8723AU_P2P */
+       if (((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) &&
+           (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) {
+               psta = rtw_get_stainfo23a(pstapriv, mgmt->sa);
+               if (psta) {
+                       ret = rtw_check_bcn_info23a(padapter, mgmt, pkt_len);
+                       if (!ret) {
+                               DBG_8723A_LEVEL(_drv_always_, "ap has changed, "
+                                               "disconnect now\n");
+                               receive_disconnect23a(padapter, pmlmeinfo->network.MacAddress, 65535);
+                               return _SUCCESS;
+                       }
+                       /* update WMM, ERP in the beacon */
+                       /* todo: the timer is used instead of
+                          the number of the beacon received */
+                       if ((sta_rx_pkts(psta) & 0xf) == 0) {
+                               /* DBG_8723A("update_bcn_info\n"); */
+                               update_beacon23a_info(padapter, pframe,
+                                                     pkt_len, psta);
+                       }
+               }
+       } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) {
+               psta = rtw_get_stainfo23a(pstapriv, mgmt->sa);
+               if (psta) {
+                       /* update WMM, ERP in the beacon */
+                       /* todo: the timer is used instead of the
+                          number of the beacon received */
+                       if ((sta_rx_pkts(psta) & 0xf) == 0) {
+                               /* DBG_8723A("update_bcn_info\n"); */
+                               update_beacon23a_info(padapter, pframe,
+                                                     pkt_len, psta);
+                       }
+               } else {
+                       /* allocate a new CAM entry for IBSS station */
+                       cam_idx = allocate_fw_sta_entry23a(padapter);
+                       if (cam_idx == NUM_STA)
+                               goto out;
+
+                       /* get supported rate */
+                       if (update_sta_support_rate23a(padapter, pie, pie_len,
+                                                      cam_idx) == _FAIL) {
+                               pmlmeinfo->FW_sta_info[cam_idx].status = 0;
+                               goto out;
                        }
-               } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) {
-                       psta = rtw_get_stainfo23a(pstapriv, hdr->addr2);
-                       if (psta) {
-                               /* update WMM, ERP in the beacon */
-                               /* todo: the timer is used instead of the
-                                  number of the beacon received */
-                               if ((sta_rx_pkts(psta) & 0xf) == 0) {
-                                       /* DBG_8723A("update_bcn_info\n"); */
-                                       update_beacon23a_info(padapter, pframe,
-                                                             len, psta);
-                               }
-                       } else {
-                               /* allocate a new CAM entry for IBSS station */
-                               cam_idx = allocate_fw_sta_entry23a(padapter);
-                               if (cam_idx == NUM_STA)
-                                       goto _END_ONBEACON_;
-
-                               /* get supported rate */
-                               if (update_sta_support_rate23a(padapter, (pframe + sizeof(struct ieee80211_hdr_3addr) + _BEACON_IE_OFFSET_), (len - sizeof(struct ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_), cam_idx) == _FAIL) {
-                                       pmlmeinfo->FW_sta_info[cam_idx].status = 0;
-                                       goto _END_ONBEACON_;
-                               }
 
-                               /* update TSF Value */
-                               update_TSF23a(pmlmeext, pframe, len);
+                       /* update TSF Value */
+                       rtw_update_TSF(pmlmeext, mgmt);
 
-                               /* report sta add event */
-                               report_add_sta_event23a(padapter, hdr->addr2,
-                                                       cam_idx);
-                       }
+                       /* report sta add event */
+                       report_add_sta_event23a(padapter, mgmt->sa,
+                                               cam_idx);
                }
        }
 
-_END_ONBEACON_:
+out:
 
        return _SUCCESS;
 }
 
-unsigned int OnAuth23a(struct rtw_adapter *padapter,
-                      struct recv_frame *precv_frame)
+static int
+OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
 #ifdef CONFIG_8723AU_AP_MODE
-       unsigned int    auth_mode, seq, ie_len;
-       unsigned char   *sa, *p;
-       u16     algorithm;
-       int     status;
        static struct sta_info stat;
-       struct  sta_info        *pstat = NULL;
-       struct  sta_priv *pstapriv = &padapter->stapriv;
+       struct sta_info *pstat = NULL;
+       struct sta_priv *pstapriv = &padapter->stapriv;
        struct security_priv *psecuritypriv = &padapter->securitypriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
+       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct sk_buff *skb = precv_frame->pkt;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       u8 *pframe = skb->data;
-       uint len = skb->len;
+       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
+       u8 *pframe;
+       const u8 *p;
+       unsigned char *sa;
+       u16 auth_mode, seq, algorithm;
+       int status, len = skb->len;
 
-       if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE)
+       if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE)
                return _FAIL;
 
        DBG_8723A("+OnAuth23a\n");
 
-       sa = hdr->addr2;
+       sa = mgmt->sa;
 
        auth_mode = psecuritypriv->dot11AuthAlgrthm;
-       seq = cpu_to_le16(*(u16*)((unsigned long)pframe +
-                                 sizeof(struct ieee80211_hdr_3addr) + 2));
-       algorithm = cpu_to_le16(*(u16*)((unsigned long)pframe +
-                                       sizeof(struct ieee80211_hdr_3addr)));
+
+       pframe = mgmt->u.auth.variable;
+       len = skb->len - offsetof(struct ieee80211_mgmt, u.auth.variable);
+
+       seq = le16_to_cpu(mgmt->u.auth.auth_transaction);
+       algorithm = le16_to_cpu(mgmt->u.auth.auth_alg);
 
        DBG_8723A("auth alg =%x, seq =%X\n", algorithm, seq);
 
@@ -995,8 +894,8 @@ unsigned int OnAuth23a(struct rtw_adapter *padapter,
 
        /*  rx a shared-key auth but shared not enabled, or */
        /*  rx a open-system auth but shared-key is enabled */
-       if ((algorithm > 0 && auth_mode == 0) ||
-           (algorithm == 0 && auth_mode == 1)) {
+       if ((algorithm != WLAN_AUTH_OPEN && auth_mode == 0) ||
+           (algorithm == WLAN_AUTH_OPEN && auth_mode == 1)) {
                DBG_8723A("auth rejected due to bad alg [alg =%d, auth_mib "
                          "=%d] %02X%02X%02X%02X%02X%02X\n",
                          algorithm, auth_mode,
@@ -1035,8 +934,7 @@ unsigned int OnAuth23a(struct rtw_adapter *padapter,
                if (!list_empty(&pstat->asoc_list)) {
                        list_del_init(&pstat->asoc_list);
                        pstapriv->asoc_list_cnt--;
-                       if (pstat->expire_to > 0)
-                       {
+                       if (pstat->expire_to > 0) {
                                /* TODO: STA re_auth within expire_to */
                        }
                }
@@ -1064,7 +962,7 @@ unsigned int OnAuth23a(struct rtw_adapter *padapter,
                goto auth_fail;
        }
 
-       if (algorithm == 0 && (auth_mode == 0 || auth_mode == 2)) {
+       if (algorithm == WLAN_AUTH_OPEN && (auth_mode == 0 || auth_mode == 2)) {
                if (seq == 1) {
                        pstat->state &= ~WIFI_FW_AUTH_NULL;
                        pstat->state |= WIFI_FW_AUTH_SUCCESS;
@@ -1088,22 +986,16 @@ unsigned int OnAuth23a(struct rtw_adapter *padapter,
                        /* checking for challenging txt... */
                        DBG_8723A("checking for challenging txt...\n");
 
-                       p = rtw_get_ie23a(pframe +
-                                         sizeof(struct ieee80211_hdr_3addr) +
-                                         4 + _AUTH_IE_OFFSET_, _CHLGETXT_IE_,
-                                         (int *)&ie_len, len -
-                                         sizeof(struct ieee80211_hdr_3addr) -
-                                         _AUTH_IE_OFFSET_ - 4);
-
-                       if ((p == NULL) || (ie_len<= 0)) {
+                       p = cfg80211_find_ie(WLAN_EID_CHALLENGE, pframe, len);
+                       if (!p || p[1] <= 0) {
                                DBG_8723A("auth rejected because challenge "
                                          "failure!(1)\n");
                                status = WLAN_STATUS_CHALLENGE_FAIL;
                                goto auth_fail;
                        }
 
-                       if (!memcmp((void *)(p + 2), pstat->chg_txt, 128)) {
-                               pstat->state &= (~WIFI_FW_AUTH_STATE);
+                       if (!memcmp(p + 2, pstat->chg_txt, 128)) {
+                               pstat->state &= ~WIFI_FW_AUTH_STATE;
                                pstat->state |= WIFI_FW_AUTH_SUCCESS;
                                /*  challenging txt is correct... */
                                pstat->expire_to =  pstapriv->assoc_to;
@@ -1125,7 +1017,7 @@ unsigned int OnAuth23a(struct rtw_adapter *padapter,
        /*  Now, we are going to issue_auth23a... */
        pstat->auth_seq = seq + 1;
 
-       issue_auth23a(padapter, pstat, (unsigned short)WLAN_STATUS_SUCCESS);
+       issue_auth23a(padapter, pstat, WLAN_STATUS_SUCCESS);
 
        if (pstat->state & WIFI_FW_AUTH_SUCCESS)
                pstat->auth_seq = 0;
@@ -1148,40 +1040,39 @@ auth_fail:
        return _FAIL;
 }
 
-unsigned int OnAuth23aClient23a(struct rtw_adapter *padapter,
-                               struct recv_frame *precv_frame)
+static int
+OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
-       unsigned int    seq, len, status, algthm, offset;
-       unsigned char   *p;
-       unsigned int    go2asoc = 0;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
+       unsigned int seq, status, algthm;
+       unsigned int go2asoc = 0;
+       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct sk_buff *skb = precv_frame->pkt;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       u8 *pframe = skb->data;
-       uint pkt_len = skb->len;
+       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
+       const u8 *p;
+       u8 *pie;
+       int plen = skb->len;
 
        DBG_8723A("%s\n", __func__);
 
        /* check A1 matches or not */
-       if (!ether_addr_equal(myid(&padapter->eeprompriv),
-                             ieee80211_get_DA(hdr)))
+       if (!ether_addr_equal(myid(&padapter->eeprompriv), mgmt->da))
                return _SUCCESS;
 
        if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE))
                return _SUCCESS;
 
-       offset = ieee80211_has_protected(hdr->frame_control) ? 4: 0;
+       pie = mgmt->u.auth.variable;
+       plen -= offsetof(struct ieee80211_mgmt, u.auth.variable);
 
-       algthm  = le16_to_cpu(*(unsigned short *)((unsigned long)pframe + sizeof(struct ieee80211_hdr_3addr) + offset));
-       seq     = le16_to_cpu(*(unsigned short *)((unsigned long)pframe + sizeof(struct ieee80211_hdr_3addr) + offset + 2));
-       status  = le16_to_cpu(*(unsigned short *)((unsigned long)pframe + sizeof(struct ieee80211_hdr_3addr) + offset + 4));
+       algthm = le16_to_cpu(mgmt->u.auth.auth_alg);
+       seq = le16_to_cpu(mgmt->u.auth.auth_transaction);
+       status = le16_to_cpu(mgmt->u.auth.status_code);
 
-       if (status != 0)
-       {
+       if (status) {
                DBG_8723A("clnt auth fail, status: %d\n", status);
-               if (status == 13)/*  pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */
-               {
+               /*  pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */
+               if (status == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) {
                        if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)
                                pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open;
                        else
@@ -1193,53 +1084,39 @@ unsigned int OnAuth23aClient23a(struct rtw_adapter *padapter,
                goto authclnt_fail;
        }
 
-       if (seq == 2)
-       {
-               if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)
-               {
-                        /*  legendary shared system */
-                       p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, (int *)&len,
-                               pkt_len - sizeof(struct ieee80211_hdr_3addr) - _AUTH_IE_OFFSET_);
+       if (seq == 2) {
+               if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) {
+                       /*  legendary shared system */
+                       p = cfg80211_find_ie(WLAN_EID_CHALLENGE, pie, plen);
 
-                       if (p == NULL)
-                       {
+                       if (!p) {
                                /* DBG_8723A("marc: no challenge text?\n"); */
                                goto authclnt_fail;
                        }
 
-                       memcpy((void *)(pmlmeinfo->chg_txt), (void *)(p + 2), len);
+                       memcpy((void *)(pmlmeinfo->chg_txt), p + 2, p[1]);
                        pmlmeinfo->auth_seq = 3;
                        issue_auth23a(padapter, NULL, 0);
                        set_link_timer(pmlmeext, REAUTH_TO);
 
                        return _SUCCESS;
-               }
-               else
-               {
+               } else {
                        /*  open system */
                        go2asoc = 1;
                }
-       }
-       else if (seq == 4)
-       {
+       } else if (seq == 4) {
                if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)
-               {
                        go2asoc = 1;
-               }
                else
-               {
                        goto authclnt_fail;
-               }
-       }
-       else
-       {
+       } else {
                /*  this is also illegal */
-               /* DBG_8723A("marc: clnt auth failed due to illegal seq =%x\n", seq); */
+               /* DBG_8723A("marc: clnt auth failed due to illegal seq =%x\n",
+                  seq); */
                goto authclnt_fail;
        }
 
-       if (go2asoc)
-       {
+       if (go2asoc) {
                DBG_8723A_LEVEL(_drv_always_, "auth success, start assoc\n");
                start_clnt_assoc23a(padapter);
                return _SUCCESS;
@@ -1252,19 +1129,153 @@ authclnt_fail:
        return _FAIL;
 }
 
-unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
+#ifdef CONFIG_8723AU_AP_MODE
+static int rtw_validate_vendor_specific_ies(const u8 *pos, int elen)
+{
+       unsigned int oui;
+
+       /* first 3 bytes in vendor specific information element are the IEEE
+        * OUI of the vendor. The following byte is used a vendor specific
+        * sub-type. */
+       if (elen < 4) {
+               DBG_8723A("short vendor specific information element "
+                         "ignored (len =%i)\n", elen);
+               return -EINVAL;
+       }
+
+       oui = RTW_GET_BE24(pos);
+       switch (oui) {
+       case WLAN_OUI_MICROSOFT:
+               /* Microsoft/Wi-Fi information elements are further typed and
+                * subtyped */
+               switch (pos[3]) {
+               case 1:
+                       /* Microsoft OUI (00:50:F2) with OUI Type 1:
+                        * real WPA information element */
+                       break;
+               case WME_OUI_TYPE: /* this is a Wi-Fi WME info. element */
+                       if (elen < 5) {
+                               DBG_8723A("short WME information element "
+                                         "ignored (len =%i)\n", elen);
+                               return -EINVAL;
+                       }
+                       switch (pos[4]) {
+                       case WME_OUI_SUBTYPE_INFORMATION_ELEMENT:
+                       case WME_OUI_SUBTYPE_PARAMETER_ELEMENT:
+                               break;
+                       case WME_OUI_SUBTYPE_TSPEC_ELEMENT:
+                               break;
+                       default:
+                               DBG_8723A("unknown WME information element "
+                                         "ignored (subtype =%d len =%i)\n",
+                                          pos[4], elen);
+                               return -EINVAL;
+                       }
+                       break;
+               case 4:
+                       /* Wi-Fi Protected Setup (WPS) IE */
+                       break;
+               default:
+                       DBG_8723A("Unknown Microsoft information element "
+                                 "ignored (type =%d len =%i)\n",
+                                 pos[3], elen);
+                       return -EINVAL;
+               }
+               break;
+
+       case OUI_BROADCOM:
+               switch (pos[3]) {
+               case VENDOR_HT_CAPAB_OUI_TYPE:
+                       break;
+               default:
+                       DBG_8723A("Unknown Broadcom information element "
+                                 "ignored (type =%d len =%i)\n", pos[3], elen);
+                       return -EINVAL;
+               }
+               break;
+
+       default:
+               DBG_8723A("unknown vendor specific information element "
+                         "ignored (vendor OUI %02x:%02x:%02x len =%i)\n",
+                          pos[0], pos[1], pos[2], elen);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static int rtw_validate_frame_ies(const u8 *start, uint len)
+{
+       const u8 *pos = start;
+       int left = len;
+       int unknown = 0;
+
+       while (left >= 2) {
+               u8 id, elen;
+
+               id = *pos++;
+               elen = *pos++;
+               left -= 2;
+
+               if (elen > left) {
+                       DBG_8723A("%s: IEEE 802.11 failed (id =%d elen =%d "
+                                 "left =%i)\n", __func__, id, elen, left);
+                       return -EINVAL;
+               }
+
+               switch (id) {
+               case WLAN_EID_SSID:
+               case WLAN_EID_SUPP_RATES:
+               case WLAN_EID_FH_PARAMS:
+               case WLAN_EID_DS_PARAMS:
+               case WLAN_EID_CF_PARAMS:
+               case WLAN_EID_TIM:
+               case WLAN_EID_IBSS_PARAMS:
+               case WLAN_EID_CHALLENGE:
+               case WLAN_EID_ERP_INFO:
+               case WLAN_EID_EXT_SUPP_RATES:
+               case WLAN_EID_VENDOR_SPECIFIC:
+               if (rtw_validate_vendor_specific_ies(pos, elen))
+                       unknown++;
+                       break;
+               case WLAN_EID_RSN:
+               case WLAN_EID_PWR_CAPABILITY:
+               case WLAN_EID_SUPPORTED_CHANNELS:
+               case WLAN_EID_MOBILITY_DOMAIN:
+               case WLAN_EID_FAST_BSS_TRANSITION:
+               case WLAN_EID_TIMEOUT_INTERVAL:
+               case WLAN_EID_HT_CAPABILITY:
+               case WLAN_EID_HT_OPERATION:
+               default:
+                       unknown++;
+                       DBG_8723A("%s IEEE 802.11 ignored unknown element "
+                                 "(id =%d elen =%d)\n", __func__, id, elen);
+                       break;
+               }
+
+               left -= elen;
+               pos += elen;
+       }
+
+       if (left)
+               return -EINVAL;
+
+       return 0;
+}
+#endif
+
+static int
+OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
 #ifdef CONFIG_8723AU_AP_MODE
        u16 capab_info, listen_interval;
-       struct rtw_ieee802_11_elems elems;
        struct sta_info *pstat;
-       unsigned char           reassoc, *p, *pos, *wpa_ie;
+       unsigned char reassoc;
        unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01};
-       int             i, ie_len, wpa_ie_len, left;
-       unsigned char           supportRate[16];
-       int                                     supportRateNum;
-       unsigned short          status = WLAN_STATUS_SUCCESS;
-       unsigned short ie_offset;
+       int i, wpa_ie_len, left;
+       unsigned char supportRate[16];
+       int supportRateNum;
+       unsigned short status = WLAN_STATUS_SUCCESS;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct security_priv *psecuritypriv = &padapter->securitypriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
@@ -1272,69 +1283,56 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec
        struct wlan_bssid_ex *cur = &pmlmeinfo->network;
        struct sta_priv *pstapriv = &padapter->stapriv;
        struct sk_buff *skb = precv_frame->pkt;
+       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
+       const u8 *pos, *p, *wpa_ie, *wps_ie;
        u8 *pframe = skb->data;
        uint pkt_len = skb->len;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       u16 frame_control;
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       u8 p2p_status_code = P2P_STATUS_SUCCESS;
-       u8 *p2pie;
-       u32 p2pielen = 0;
-       u8      wfd_ie[MAX_WFD_IE_LEN] = { 0x00 };
-       u32     wfd_ielen = 0;
-#endif /* CONFIG_8723AU_P2P */
+       int r;
 
-       if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE)
+       if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE)
                return _FAIL;
 
-       frame_control = hdr->frame_control;
-       if (ieee80211_is_assoc_req(frame_control)) {
+       left = pkt_len - sizeof(struct ieee80211_hdr_3addr);
+       if (ieee80211_is_assoc_req(mgmt->frame_control)) {
                reassoc = 0;
-               ie_offset = _ASOCREQ_IE_OFFSET_;
+               pos = mgmt->u.assoc_req.variable;
+               left -= offsetof(struct ieee80211_mgmt, u.assoc_req.variable);
        } else { /*  WIFI_REASSOCREQ */
                reassoc = 1;
-               ie_offset = _REASOCREQ_IE_OFFSET_;
+               pos = mgmt->u.reassoc_req.variable;
+               left -= offsetof(struct ieee80211_mgmt, u.reassoc_req.variable);
        }
 
-       if (pkt_len < sizeof(struct ieee80211_hdr_3addr) + ie_offset) {
-               DBG_8723A("handle_assoc(reassoc =%d) - too short payload (len =%lu)"
-                      "\n", reassoc, (unsigned long)pkt_len);
+       if (left < 0) {
+               DBG_8723A("handle_assoc(reassoc =%d) - too short payload "
+                         "(len =%lu)\n", reassoc, (unsigned long)pkt_len);
                return _FAIL;
        }
 
-       pstat = rtw_get_stainfo23a(pstapriv, hdr->addr2);
+       pstat = rtw_get_stainfo23a(pstapriv, mgmt->sa);
        if (!pstat) {
                status = WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA;
                goto asoc_class2_error;
        }
 
-       capab_info = get_unaligned_le16(pframe + sizeof(struct ieee80211_hdr_3addr));
-       /* capab_info = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr))); */
-       /* listen_interval = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr)+2)); */
-       listen_interval = get_unaligned_le16(pframe + sizeof(struct ieee80211_hdr_3addr)+2);
-
-       left = pkt_len - (sizeof(struct ieee80211_hdr_3addr) + ie_offset);
-       pos = pframe + (sizeof(struct ieee80211_hdr_3addr) + ie_offset);
+       /* These two are located at the same offsets whether it's an
+        * assoc_req or a reassoc_req */
+       capab_info = get_unaligned_le16(&mgmt->u.assoc_req.capab_info);
+       listen_interval =
+               get_unaligned_le16(&mgmt->u.assoc_req.listen_interval);
 
        DBG_8723A("%s\n", __func__);
 
        /*  check if this stat has been successfully authenticated/assocated */
-       if (!((pstat->state) & WIFI_FW_AUTH_SUCCESS))
-       {
-               if (!((pstat->state) & WIFI_FW_ASSOC_SUCCESS))
-               {
+       if (!(pstat->state & WIFI_FW_AUTH_SUCCESS)) {
+               if (!(pstat->state & WIFI_FW_ASSOC_SUCCESS)) {
                        status = WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA;
                        goto asoc_class2_error;
-               }
-               else
-               {
+               } else {
                        pstat->state &= (~WIFI_FW_ASSOC_SUCCESS);
                        pstat->state |= WIFI_FW_ASSOC_STATE;
                }
-       }
-       else
-       {
+       } else {
                pstat->state &= (~WIFI_FW_AUTH_SUCCESS);
                pstat->state |= WIFI_FW_ASSOC_STATE;
        }
@@ -1342,41 +1340,40 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec
        pstat->capability = capab_info;
 
        /* now parse all ieee802_11 ie to point to elems */
-       if (rtw_ieee802_11_parse_elems23a(pos, left, &elems, 1) == ParseFailed ||
-           !elems.ssid) {
+
+       if (rtw_validate_frame_ies(pos, left)) {
                DBG_8723A("STA " MAC_FMT " sent invalid association request\n",
-                      MAC_ARG(pstat->hwaddr));
+                         MAC_ARG(pstat->hwaddr));
                status = WLAN_STATUS_UNSPECIFIED_FAILURE;
                goto OnAssocReq23aFail;
        }
 
        /*  now we should check all the fields... */
        /*  checking SSID */
-       p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, _SSID_IE_, &ie_len,
-               pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset);
-       if (p == NULL)
-       {
-               status = WLAN_STATUS_UNSPECIFIED_FAILURE;
-       }
-
-       if (ie_len == 0) /*  broadcast ssid, however it is not allowed in assocreq */
+       p = cfg80211_find_ie(WLAN_EID_SSID, pos, left);
+       if (!p || p[1] == 0) {
+               /*  broadcast ssid, however it is not allowed in assocreq */
+               DBG_8723A("STA " MAC_FMT " sent invalid association request "
+                         "lacking an SSID\n", MAC_ARG(pstat->hwaddr));
                status = WLAN_STATUS_UNSPECIFIED_FAILURE;
-       else {
+               goto OnAssocReq23aFail;
+       } else {
                /*  check if ssid match */
-               if (memcmp((void *)(p+2), cur->Ssid.ssid, cur->Ssid.ssid_len))
+               if (memcmp(p + 2, cur->Ssid.ssid, cur->Ssid.ssid_len))
                        status = WLAN_STATUS_UNSPECIFIED_FAILURE;
 
-               if (ie_len != cur->Ssid.ssid_len)
+               if (p[1] != cur->Ssid.ssid_len)
                        status = WLAN_STATUS_UNSPECIFIED_FAILURE;
        }
 
-       if (WLAN_STATUS_SUCCESS != status)
+       if (status != WLAN_STATUS_SUCCESS)
                goto OnAssocReq23aFail;
 
        /*  check if the supported rate is ok */
-       p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, _SUPPORTEDRATES_IE_, &ie_len, pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset);
-       if (p == NULL) {
-               DBG_8723A("Rx a sta assoc-req which supported rate is empty!\n");
+       p = cfg80211_find_ie(WLAN_EID_SUPP_RATES, pos, left);
+       if (!p) {
+               DBG_8723A("Rx a sta assoc-req which supported rate is "
+                         "empty!\n");
                /*  use our own rate set as statoin used */
                /* memcpy(supportRate, AP_BSSRATE, AP_BSSRATE_LEN); */
                /* supportRateNum = AP_BSSRATE_LEN; */
@@ -1384,17 +1381,14 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec
                status = WLAN_STATUS_UNSPECIFIED_FAILURE;
                goto OnAssocReq23aFail;
        } else {
-               memcpy(supportRate, p+2, ie_len);
-               supportRateNum = ie_len;
-
-               p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, _EXT_SUPPORTEDRATES_IE_, &ie_len,
-                               pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset);
-               if (p !=  NULL) {
-
-                       if (supportRateNum<= sizeof(supportRate))
-                       {
-                               memcpy(supportRate+supportRateNum, p+2, ie_len);
-                               supportRateNum += ie_len;
+               memcpy(supportRate, p + 2, p[1]);
+               supportRateNum = p[1];
+
+               p = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, pos, left);
+               if (p) {
+                       if (supportRateNum <= sizeof(supportRate)) {
+                               memcpy(supportRate+supportRateNum, p + 2, p[1]);
+                               supportRateNum += p[1];
                        }
                }
        }
@@ -1415,90 +1409,97 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec
        pstat->wpa_pairwise_cipher = 0;
        pstat->wpa2_pairwise_cipher = 0;
        memset(pstat->wpa_ie, 0, sizeof(pstat->wpa_ie));
-       if ((psecuritypriv->wpa_psk & BIT(1)) && elems.rsn_ie) {
 
+       wpa_ie = cfg80211_find_ie(WLAN_EID_RSN, pos, left);
+       if (!wpa_ie)
+               wpa_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
+                                                WLAN_OUI_TYPE_MICROSOFT_WPA,
+                                                pos, left);
+       if (wpa_ie) {
                int group_cipher = 0, pairwise_cipher = 0;
 
-               wpa_ie = elems.rsn_ie;
-               wpa_ie_len = elems.rsn_ie_len;
-
-               if (rtw_parse_wpa2_ie23a(wpa_ie-2, wpa_ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) {
-                       pstat->dot8021xalg = 1;/* psk,  todo:802.1x */
-                       pstat->wpa_psk |= BIT(1);
-
-                       pstat->wpa2_group_cipher = group_cipher&psecuritypriv->wpa2_group_cipher;
-                       pstat->wpa2_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa2_pairwise_cipher;
-
-                       if (!pstat->wpa2_group_cipher)
-                               status = WLAN_REASON_INVALID_GROUP_CIPHER;
-
-                       if (!pstat->wpa2_pairwise_cipher)
-                               status = WLAN_REASON_INVALID_PAIRWISE_CIPHER;
+               wpa_ie_len = wpa_ie[1];
+               if (psecuritypriv->wpa_psk & BIT(1)) {
+                       r = rtw_parse_wpa2_ie23a(wpa_ie, wpa_ie_len + 2,
+                                                &group_cipher,
+                                                &pairwise_cipher, NULL);
+                       if (r == _SUCCESS) {
+                               pstat->dot8021xalg = 1;/* psk,  todo:802.1x */
+                               pstat->wpa_psk |= BIT(1);
+
+                               pstat->wpa2_group_cipher = group_cipher &
+                                       psecuritypriv->wpa2_group_cipher;
+                               pstat->wpa2_pairwise_cipher = pairwise_cipher &
+                                       psecuritypriv->wpa2_pairwise_cipher;
+                       } else
+                               status = WLAN_STATUS_INVALID_IE;
+               } else if (psecuritypriv->wpa_psk & BIT(0)) {
+                       r = rtw_parse_wpa_ie23a(wpa_ie, wpa_ie_len + 2,
+                                               &group_cipher, &pairwise_cipher,
+                                               NULL);
+                       if (r == _SUCCESS) {
+                               pstat->dot8021xalg = 1;/* psk,  todo:802.1x */
+                               pstat->wpa_psk |= BIT(0);
+
+                               pstat->wpa_group_cipher = group_cipher &
+                                       psecuritypriv->wpa_group_cipher;
+                               pstat->wpa_pairwise_cipher = pairwise_cipher &
+                                       psecuritypriv->wpa_pairwise_cipher;
+                       } else
+                               status = WLAN_STATUS_INVALID_IE;
                } else {
-                       status = WLAN_STATUS_INVALID_IE;
+                       wpa_ie = NULL;
+                       wpa_ie_len = 0;
                }
-
-       } else if ((psecuritypriv->wpa_psk & BIT(0)) && elems.wpa_ie) {
-
-               int group_cipher = 0, pairwise_cipher = 0;
-
-               wpa_ie = elems.wpa_ie;
-               wpa_ie_len = elems.wpa_ie_len;
-
-               if (rtw_parse_wpa_ie23a(wpa_ie-2, wpa_ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) {
-                       pstat->dot8021xalg = 1;/* psk,  todo:802.1x */
-                       pstat->wpa_psk |= BIT(0);
-
-                       pstat->wpa_group_cipher = group_cipher&psecuritypriv->wpa_group_cipher;
-                       pstat->wpa_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa_pairwise_cipher;
-
+               if (wpa_ie && status == WLAN_STATUS_SUCCESS) {
                        if (!pstat->wpa_group_cipher)
                                status = WLAN_STATUS_INVALID_GROUP_CIPHER;
 
                        if (!pstat->wpa_pairwise_cipher)
                                status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER;
-
-               } else {
-                       status = WLAN_STATUS_INVALID_IE;
                }
-
-       } else {
-               wpa_ie = NULL;
-               wpa_ie_len = 0;
        }
 
-       if (WLAN_STATUS_SUCCESS != status)
+       if (status != WLAN_STATUS_SUCCESS)
                goto OnAssocReq23aFail;
 
        pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS);
-       if (wpa_ie == NULL) {
-               if (elems.wps_ie) {
-                       DBG_8723A("STA included WPS IE in "
-                                  "(Re)Association Request - assume WPS is "
-                                  "used\n");
+
+       wps_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
+                                        WLAN_OUI_TYPE_MICROSOFT_WPS,
+                                        pos, left);
+
+       if (!wpa_ie) {
+               if (wps_ie) {
+                       DBG_8723A("STA included WPS IE in (Re)Association "
+                                 "Request - assume WPS is used\n");
                        pstat->flags |= WLAN_STA_WPS;
                } else {
-                       DBG_8723A("STA did not include WPA/RSN IE "
-                                  "in (Re)Association Request - possible WPS "
-                                  "use\n");
+                       DBG_8723A("STA did not include WPA/RSN IE in (Re)"
+                                  "Association Request - possible WPS use\n");
                        pstat->flags |= WLAN_STA_MAYBE_WPS;
                }
 
-               /*  AP support WPA/RSN, and sta is going to do WPS, but AP is not ready */
+               /*  AP support WPA/RSN, and sta is going to do WPS, but AP
+                   is not ready */
                /*  that the selected registrar of AP is _FLASE */
-               if ((psecuritypriv->wpa_psk > 0) &&
-                   (pstat->flags & (WLAN_STA_WPS|WLAN_STA_MAYBE_WPS))) {
+               if (psecuritypriv->wpa_psk > 0 &&
+                   pstat->flags & (WLAN_STA_WPS|WLAN_STA_MAYBE_WPS)) {
                        if (pmlmepriv->wps_beacon_ie) {
                                u8 selected_registrar = 0;
 
-                               rtw_get_wps_attr_content23a(pmlmepriv->wps_beacon_ie, pmlmepriv->wps_beacon_ie_len,
-                                                        WPS_ATTR_SELECTED_REGISTRAR, &selected_registrar, NULL);
+                               rtw_get_wps_attr_content23a(
+                                       pmlmepriv->wps_beacon_ie,
+                                       pmlmepriv->wps_beacon_ie_len,
+                                       WPS_ATTR_SELECTED_REGISTRAR,
+                                       &selected_registrar, NULL);
 
                                if (!selected_registrar) {
-                                       DBG_8723A("selected_registrar is false , or AP is not ready to do WPS\n");
+                                       DBG_8723A("selected_registrar is false,"
+                                                 "or AP is not ready to do "
+                                                 "WPS\n");
 
                                        status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
-
                                        goto OnAssocReq23aFail;
                                }
                        }
@@ -1508,26 +1509,26 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec
 
                if (psecuritypriv->wpa_psk == 0) {
                        DBG_8723A("STA " MAC_FMT ": WPA/RSN IE in association "
-                       "request, but AP don't support WPA/RSN\n", MAC_ARG(pstat->hwaddr));
+                       "request, but AP don't support WPA/RSN\n",
+                                 MAC_ARG(pstat->hwaddr));
 
                        status = WLAN_STATUS_INVALID_IE;
 
                        goto OnAssocReq23aFail;
                }
 
-               if (elems.wps_ie) {
-                       DBG_8723A("STA included WPS IE in "
-                                  "(Re)Association Request - WPS is "
-                                  "used\n");
+               if (wps_ie) {
+                       DBG_8723A("STA included WPS IE in (Re)Association "
+                                 "Request - WPS is used\n");
                        pstat->flags |= WLAN_STA_WPS;
                        copy_len = 0;
                } else {
-                       copy_len = ((wpa_ie_len+2) > sizeof(pstat->wpa_ie)) ? (sizeof(pstat->wpa_ie)):(wpa_ie_len+2);
+                       copy_len = ((wpa_ie_len + 2) > sizeof(pstat->wpa_ie)) ?
+                               sizeof(pstat->wpa_ie) : (wpa_ie_len + 2);
                }
 
-               if (copy_len>0)
-                       memcpy(pstat->wpa_ie, wpa_ie-2, copy_len);
-
+               if (copy_len > 0)
+                       memcpy(pstat->wpa_ie, wpa_ie - 2, copy_len);
        }
 
        /*  check if there is WMM IE & support WWM-PS */
@@ -1539,45 +1540,45 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec
        pstat->uapsd_vi = 0;
        pstat->uapsd_be = 0;
        pstat->uapsd_bk = 0;
-       if (pmlmepriv->qospriv.qos_option)
-       {
-               p = pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset; ie_len = 0;
-               for (;;)
-               {
-                       p = rtw_get_ie23a(p, _VENDOR_SPECIFIC_IE_, &ie_len, pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset);
-                       if (p != NULL) {
-                               if (!memcmp(p+2, WMM_IE, 6)) {
-
+       if (pmlmepriv->qospriv.qos_option) {
+               const u8 *end = pos + left;
+               p = pos;
+
+               for (;;) {
+                       left = end - p;
+                       p = cfg80211_find_ie(WLAN_EID_VENDOR_SPECIFIC, p, left);
+                       if (p) {
+                               if (!memcmp(p + 2, WMM_IE, 6)) {
                                        pstat->flags |= WLAN_STA_WME;
 
                                        pstat->qos_option = 1;
-                                       pstat->qos_info = *(p+8);
+                                       pstat->qos_info = *(p + 8);
 
-                                       pstat->max_sp_len = (pstat->qos_info>>5)&0x3;
+                                       pstat->max_sp_len =
+                                               (pstat->qos_info >> 5) & 0x3;
 
-                                       if ((pstat->qos_info&0xf) != 0xf)
+                                       if ((pstat->qos_info & 0xf) != 0xf)
                                                pstat->has_legacy_ac = true;
                                        else
                                                pstat->has_legacy_ac = false;
 
-                                       if (pstat->qos_info&0xf)
-                                       {
-                                               if (pstat->qos_info&BIT(0))
+                                       if (pstat->qos_info & 0xf) {
+                                               if (pstat->qos_info & BIT(0))
                                                        pstat->uapsd_vo = BIT(0)|BIT(1);
                                                else
                                                        pstat->uapsd_vo = 0;
 
-                                               if (pstat->qos_info&BIT(1))
+                                               if (pstat->qos_info & BIT(1))
                                                        pstat->uapsd_vi = BIT(0)|BIT(1);
                                                else
                                                        pstat->uapsd_vi = 0;
 
-                                               if (pstat->qos_info&BIT(2))
+                                               if (pstat->qos_info & BIT(2))
                                                        pstat->uapsd_bk = BIT(0)|BIT(1);
                                                else
                                                        pstat->uapsd_bk = 0;
 
-                                               if (pstat->qos_info&BIT(3))
+                                               if (pstat->qos_info & BIT(3))
                                                        pstat->uapsd_be = BIT(0)|BIT(1);
                                                else
                                                        pstat->uapsd_be = 0;
@@ -1586,45 +1587,42 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec
 
                                        break;
                                }
-                       }
-                       else {
+                       } else {
                                break;
                        }
-                       p = p + ie_len + 2;
+                       p = p + p[1] + 2;
                }
        }
 
        /* save HT capabilities in the sta object */
        memset(&pstat->htpriv.ht_cap, 0, sizeof(struct ieee80211_ht_cap));
-       if (elems.ht_capabilities && elems.ht_capabilities_len >= sizeof(struct ieee80211_ht_cap))
-       {
+       p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, pos, left);
+
+       if (p && p[1] >= sizeof(struct ieee80211_ht_cap)) {
                pstat->flags |= WLAN_STA_HT;
 
                pstat->flags |= WLAN_STA_WME;
 
-               memcpy(&pstat->htpriv.ht_cap, elems.ht_capabilities, sizeof(struct ieee80211_ht_cap));
-
+               memcpy(&pstat->htpriv.ht_cap, p + 2,
+                      sizeof(struct ieee80211_ht_cap));
        } else
                pstat->flags &= ~WLAN_STA_HT;
 
-       if ((pmlmepriv->htpriv.ht_option == false) && (pstat->flags&WLAN_STA_HT))
-       {
+       if (pmlmepriv->htpriv.ht_option == false && pstat->flags & WLAN_STA_HT){
                status = WLAN_STATUS_UNSPECIFIED_FAILURE;
                goto OnAssocReq23aFail;
        }
 
-       if ((pstat->flags & WLAN_STA_HT) &&
-                   ((pstat->wpa2_pairwise_cipher&WPA_CIPHER_TKIP) ||
-                     (pstat->wpa_pairwise_cipher&WPA_CIPHER_TKIP)))
-       {
-               DBG_8723A("HT: " MAC_FMT " tried to "
-                                  "use TKIP with HT association\n", MAC_ARG(pstat->hwaddr));
+       if (pstat->flags & WLAN_STA_HT &&
+           (pstat->wpa2_pairwise_cipher & WPA_CIPHER_TKIP ||
+            pstat->wpa_pairwise_cipher & WPA_CIPHER_TKIP)) {
+               DBG_8723A("HT: " MAC_FMT " tried to use TKIP with HT "
+                         "association\n", MAC_ARG(pstat->hwaddr));
 
                /* status = WLAN_STATUS_CIPHER_REJECTED_PER_POLICY; */
                /* goto OnAssocReq23aFail; */
        }
 
-       /*  */
        pstat->flags |= WLAN_STA_NONERP;
        for (i = 0; i < pstat->bssratelen; i++) {
                if ((pstat->bssrateset[i] & 0x7f) > 22) {
@@ -1641,39 +1639,6 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec
        if (status != WLAN_STATUS_SUCCESS)
                goto OnAssocReq23aFail;
 
-#ifdef CONFIG_8723AU_P2P
-       pstat->is_p2p_device = false;
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO))
-       {
-               if ((p2pie = rtw_get_p2p_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset, NULL, &p2pielen)))
-               {
-                       pstat->is_p2p_device = true;
-                       if ((p2p_status_code = (u8)process_assoc_req_p2p_ie23a(pwdinfo, pframe, pkt_len, pstat))>0)
-                       {
-                               pstat->p2p_status_code = p2p_status_code;
-                               status = WLAN_STATUS_CAPS_UNSUPPORTED;
-                               goto OnAssocReq23aFail;
-                       }
-               }
-#ifdef CONFIG_8723AU_P2P
-               if (rtw_get_wfd_ie(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset, wfd_ie, &wfd_ielen))
-               {
-                       u8      attr_content[ 10 ] = { 0x00 };
-                       u32     attr_contentlen = 0;
-
-                       DBG_8723A("[%s] WFD IE Found!!\n", __func__);
-                       rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen);
-                       if (attr_contentlen)
-                       {
-                               pwdinfo->wfd_info->peer_rtsp_ctrlport = get_unaligned_be16(attr_content + 2);
-                               DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport);
-                       }
-               }
-#endif
-       }
-       pstat->p2p_status_code = p2p_status_code;
-#endif /* CONFIG_8723AU_P2P */
-
        /* TODO: identify_proprietary_vendor_ie(); */
        /*  Realtek proprietary IE */
        /*  identify if this is Broadcom sta */
@@ -1699,14 +1664,13 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec
                        status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
 
                        goto OnAssocReq23aFail;
-
                } else {
                        pstapriv->sta_aid[pstat->aid - 1] = pstat;
                        DBG_8723A("allocate new AID = (%d)\n", pstat->aid);
                }
        }
 
-       pstat->state &= (~WIFI_FW_ASSOC_STATE);
+       pstat->state &= ~WIFI_FW_ASSOC_STATE;
        pstat->state |= WIFI_FW_ASSOC_SUCCESS;
 
        spin_lock_bh(&pstapriv->auth_list_lock);
@@ -1725,18 +1689,20 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec
        spin_unlock_bh(&pstapriv->asoc_list_lock);
 
        /*  now the station is qualified to join our BSS... */
-       if (pstat && (pstat->state & WIFI_FW_ASSOC_SUCCESS) &&
-           (WLAN_STATUS_SUCCESS == status)) {
+       if (pstat && pstat->state & WIFI_FW_ASSOC_SUCCESS &&
+           status == WLAN_STATUS_SUCCESS) {
 #ifdef CONFIG_8723AU_AP_MODE
                /* 1 bss_cap_update & sta_info_update23a */
                bss_cap_update_on_sta_join23a(padapter, pstat);
                sta_info_update23a(padapter, pstat);
 
                /* issue assoc rsp before notify station join event. */
-               if (ieee80211_is_assoc_req(frame_control))
-                       issue_asocrsp23a(padapter, status, pstat, WIFI_ASSOCRSP);
+               if (ieee80211_is_assoc_req(mgmt->frame_control))
+                       issue_asocrsp23a(padapter, status, pstat,
+                                        WIFI_ASSOCRSP);
                else
-                       issue_asocrsp23a(padapter, status, pstat, WIFI_REASSOCRSP);
+                       issue_asocrsp23a(padapter, status, pstat,
+                                        WIFI_REASSOCRSP);
 
                /* 2 - report to upper layer */
                DBG_8723A("indicate_sta_join_event to upper layer - hostapd\n");
@@ -1752,16 +1718,15 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec
 asoc_class2_error:
 
 #ifdef CONFIG_8723AU_AP_MODE
-       issue_deauth23a(padapter, hdr->addr2, status);
+       issue_deauth23a(padapter, mgmt->sa, status);
 #endif
-
        return _FAIL;
 
 OnAssocReq23aFail:
 
 #ifdef CONFIG_8723AU_AP_MODE
        pstat->aid = 0;
-       if (ieee80211_is_assoc_req(frame_control))
+       if (ieee80211_is_assoc_req(mgmt->frame_control))
                issue_asocrsp23a(padapter, status, pstat, WIFI_ASSOCRSP);
        else
                issue_asocrsp23a(padapter, status, pstat, WIFI_REASSOCRSP);
@@ -1772,25 +1737,24 @@ OnAssocReq23aFail:
        return _FAIL;
 }
 
-unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
+static int
+OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
-       uint i;
-       int res;
-       unsigned short  status;
        struct ndis_802_11_var_ies *pIE;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct sk_buff *skb = precv_frame->pkt;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+       struct ieee80211_mgmt *pmgmt = (struct ieee80211_mgmt *) skb->data;
+       int res, i;
+       unsigned short status;
        u8 *pframe = skb->data;
-       uint pkt_len = skb->len;
+       int pkt_len = skb->len;
 
        DBG_8723A("%s\n", __func__);
 
        /* check A1 matches or not */
-       if (!ether_addr_equal(myid(&padapter->eeprompriv),
-                             ieee80211_get_DA(hdr)))
+       if (!ether_addr_equal(myid(&padapter->eeprompriv), pmgmt->da))
                return _SUCCESS;
 
        if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE)))
@@ -1802,8 +1766,8 @@ unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *prec
        del_timer_sync(&pmlmeext->link_timer);
 
        /* status */
-       if ((status = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr) + 2))) > 0)
-       {
+       status = le16_to_cpu(pmgmt->u.assoc_resp.status_code);
+       if (status > 0) {
                DBG_8723A("assoc reject, status code: %d\n", status);
                pmlmeinfo->state = WIFI_FW_NULL_STATE;
                res = -4;
@@ -1811,42 +1775,37 @@ unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *prec
        }
 
        /* get capabilities */
-       pmlmeinfo->capability = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr)));
+       pmlmeinfo->capability = le16_to_cpu(pmgmt->u.assoc_resp.capab_info);
 
        /* set slot time */
        pmlmeinfo->slotTime = (pmlmeinfo->capability & BIT(10))? 9: 20;
 
        /* AID */
-       res = pmlmeinfo->aid = (int)(le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr) + 4))&0x3fff);
+       res = pmlmeinfo->aid = le16_to_cpu(pmgmt->u.assoc_resp.aid) & 0x3fff;
 
        /* following are moved to join event callback function */
        /* to handle HT, WMM, rate adaptive, update MAC reg */
        /* for not to handle the synchronous IO in the tasklet */
-       for (i = (6 + sizeof(struct ieee80211_hdr_3addr)); i < pkt_len;) {
+       for (i = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable);
+            i < pkt_len;) {
                pIE = (struct ndis_802_11_var_ies *)(pframe + i);
 
                switch (pIE->ElementID)
                {
-               case _VENDOR_SPECIFIC_IE_:
+               case WLAN_EID_VENDOR_SPECIFIC:
                        if (!memcmp(pIE->data, WMM_PARA_OUI23A, 6))/* WMM */
-                                       WMM_param_handler23a(padapter, pIE);
-#if defined(CONFIG_8723AU_P2P)
-                       else if (!memcmp(pIE->data, WFD_OUI23A, 4)) { /* WFD */
-                               DBG_8723A("[%s] Found WFD IE\n", __func__);
-                               WFD_info_handler(padapter, pIE);
-                       }
-#endif
+                               WMM_param_handler23a(padapter, pIE);
                        break;
 
-               case _HT_CAPABILITY_IE_:        /* HT caps */
+               case WLAN_EID_HT_CAPABILITY:    /* HT caps */
                        HT_caps_handler23a(padapter, pIE);
                        break;
 
-               case _HT_EXTRA_INFO_IE_:        /* HT info */
+               case WLAN_EID_HT_OPERATION:     /* HT info */
                        HT_info_handler23a(padapter, pIE);
                        break;
 
-               case _ERPINFO_IE_:
+               case WLAN_EID_ERP_INFO:
                        ERP_IE_handler23a(padapter, pIE);
 
                default:
@@ -1856,7 +1815,7 @@ unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *prec
                i += (pIE->Length + 2);
        }
 
-       pmlmeinfo->state &= (~WIFI_FW_ASSOC_STATE);
+       pmlmeinfo->state &= ~WIFI_FW_ASSOC_STATE;
        pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS;
 
        /* Update Basic Rate Table for spec, 2010-12-28 , by thomas */
@@ -1879,32 +1838,21 @@ report_assoc_result:
        return _SUCCESS;
 }
 
-unsigned int OnDeAuth23a(struct rtw_adapter *padapter,
-                        struct recv_frame *precv_frame)
+static int
+OnDeAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
-       unsigned short  reason;
+       unsigned short reason;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
+       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct sk_buff *skb = precv_frame->pkt;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       u8 *pframe = skb->data;
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-#endif /* CONFIG_8723AU_P2P */
+       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
 
-       /* check A3 */
-       if (!ether_addr_equal(hdr->addr3, get_my_bssid23a(&pmlmeinfo->network)))
+       if (!ether_addr_equal(mgmt->bssid,
+                             get_my_bssid23a(&pmlmeinfo->network)))
                return _SUCCESS;
 
-#ifdef CONFIG_8723AU_P2P
-       if (pwdinfo->rx_invitereq_info.scan_op_ch_only) {
-               mod_timer(&pwdinfo->reset_ch_sitesurvey,
-                         jiffies + msecs_to_jiffies(10));
-       }
-#endif /* CONFIG_8723AU_P2P */
-
-       reason = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr)));
+       reason = le16_to_cpu(mgmt->u.deauth.reason_code);
 
        DBG_8723A("%s Reason code(%d)\n", __func__, reason);
 
@@ -1914,9 +1862,9 @@ unsigned int OnDeAuth23a(struct rtw_adapter *padapter,
                struct sta_priv *pstapriv = &padapter->stapriv;
 
                DBG_8723A_LEVEL(_drv_always_, "ap recv deauth reason code(%d) "
-                               "sta:%pM\n", reason, hdr->addr2);
+                               "sta:%pM\n", reason, mgmt->sa);
 
-               psta = rtw_get_stainfo23a(pstapriv, hdr->addr2);
+               psta = rtw_get_stainfo23a(pstapriv, mgmt->sa);
                if (psta) {
                        u8 updated = 0;
 
@@ -1933,46 +1881,34 @@ unsigned int OnDeAuth23a(struct rtw_adapter *padapter,
                }
 
                return _SUCCESS;
-       }
-       else
+       } else
 #endif
        {
                DBG_8723A_LEVEL(_drv_always_, "sta recv deauth reason code(%d) "
-                               "sta:%pM\n", reason, hdr->addr3);
+                               "sta:%pM\n", reason, mgmt->bssid);
 
-               receive_disconnect23a(padapter, hdr->addr3, reason);
+               receive_disconnect23a(padapter, mgmt->bssid, reason);
        }
        pmlmepriv->LinkDetectInfo.bBusyTraffic = false;
+
        return _SUCCESS;
 }
 
-unsigned int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
+static int
+OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
        unsigned short  reason;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
+       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct sk_buff *skb = precv_frame->pkt;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       u8 *pframe = skb->data;
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-#endif /* CONFIG_8723AU_P2P */
+       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
 
-       /* check A3 */
-       if (!ether_addr_equal(hdr->addr3, get_my_bssid23a(&pmlmeinfo->network)))
+       if (!ether_addr_equal(mgmt->bssid,
+                             get_my_bssid23a(&pmlmeinfo->network)))
                return _SUCCESS;
 
-#ifdef CONFIG_8723AU_P2P
-       if (pwdinfo->rx_invitereq_info.scan_op_ch_only)
-       {
-               mod_timer(&pwdinfo->reset_ch_sitesurvey,
-                         jiffies + msecs_to_jiffies(10));
-       }
-#endif /* CONFIG_8723AU_P2P */
-
-       reason = le16_to_cpu(*(unsigned short *)
-                            (pframe + sizeof(struct ieee80211_hdr_3addr)));
+       reason = le16_to_cpu(mgmt->u.disassoc.reason_code);
 
         DBG_8723A("%s Reason code(%d)\n", __func__, reason);
 
@@ -1982,9 +1918,9 @@ unsigned int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *prec
                struct sta_priv *pstapriv = &padapter->stapriv;
 
                DBG_8723A_LEVEL(_drv_always_, "ap recv disassoc reason code(%d)"
-                               " sta:%pM\n", reason, hdr->addr2);
+                               " sta:%pM\n", reason, mgmt->sa);
 
-               psta = rtw_get_stainfo23a(pstapriv, hdr->addr2);
+               psta = rtw_get_stainfo23a(pstapriv, mgmt->sa);
                if (psta) {
                        u8 updated = 0;
 
@@ -1993,7 +1929,7 @@ unsigned int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *prec
                                list_del_init(&psta->asoc_list);
                                pstapriv->asoc_list_cnt--;
                                updated = ap_free_sta23a(padapter, psta,
-                                                     false, reason);
+                                                        false, reason);
                        }
                        spin_unlock_bh(&pstapriv->asoc_list_lock);
 
@@ -2001,57 +1937,59 @@ unsigned int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *prec
                }
 
                return _SUCCESS;
-       }
-       else
+       } else
 #endif
        {
                DBG_8723A_LEVEL(_drv_always_, "ap recv disassoc reason "
-                               "code(%d) sta:%pM\n", reason, hdr->addr3);
+                               "code(%d) sta:%pM\n", reason, mgmt->bssid);
 
-               receive_disconnect23a(padapter, hdr->addr3, reason);
+               receive_disconnect23a(padapter, mgmt->bssid, reason);
        }
        pmlmepriv->LinkDetectInfo.bBusyTraffic = false;
        return _SUCCESS;
 }
 
-unsigned int OnAtim23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
+static int
+OnAtim23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
        DBG_8723A("%s\n", __func__);
        return _SUCCESS;
 }
 
-unsigned int on_action_spct23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
+static int
+on_action_spct23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
        return _FAIL;
 }
 
-unsigned int OnAction23a_qos(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
+static int
+OnAction23a_qos(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
        return _SUCCESS;
 }
 
-unsigned int OnAction23a_dls(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
+static int
+OnAction23a_dls(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
        return _SUCCESS;
 }
 
-unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
+static int OnAction23a_back23a(struct rtw_adapter *padapter,
+                              struct recv_frame *precv_frame)
 {
        u8 *addr;
        struct sta_info *psta = NULL;
        struct recv_reorder_ctrl *preorder_ctrl;
-       unsigned char           *frame_body;
-       unsigned char           category, action;
-       unsigned short  tid, status, reason_code = 0;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
+       unsigned char category, action;
+       unsigned short tid, status, capab, params, reason_code = 0;
+       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct sk_buff *skb = precv_frame->pkt;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       u8 *pframe = skb->data;
+       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
        struct sta_priv *pstapriv = &padapter->stapriv;
 
        /* check RA matches or not */
-       if (!ether_addr_equal(myid(&padapter->eeprompriv), hdr->addr1))
+       if (!ether_addr_equal(myid(&padapter->eeprompriv), mgmt->da))
                return _SUCCESS;
 
        DBG_8723A("%s\n", __func__);
@@ -2060,24 +1998,24 @@ unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame
                if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS))
                        return _SUCCESS;
 
-       addr = hdr->addr2;
+       addr = mgmt->sa;
        psta = rtw_get_stainfo23a(pstapriv, addr);
 
        if (!psta)
                return _SUCCESS;
 
-       frame_body = (unsigned char *)
-               (pframe + sizeof(struct ieee80211_hdr_3addr));
-
-       category = frame_body[0];
+       category = mgmt->u.action.category;
        if (category == WLAN_CATEGORY_BACK) { /*  representing Block Ack */
                if (!pmlmeinfo->HT_enable)
                        return _SUCCESS;
-               action = frame_body[1];
+               /* action_code is located in the same place for all
+                  action events, so pick any */
+               action = mgmt->u.action.u.wme_action.action_code;
                DBG_8723A("%s, action =%d\n", __func__, action);
                switch (action) {
                case WLAN_ACTION_ADDBA_REQ: /* ADDBA request */
-                       memcpy(&pmlmeinfo->ADDBA_req, &frame_body[2],
+                       memcpy(&pmlmeinfo->ADDBA_req,
+                              &mgmt->u.action.u.addba_req.dialog_token,
                               sizeof(struct ADDBA_request));
                        process_addba_req23a(padapter,
                                             (u8 *)&pmlmeinfo->ADDBA_req, addr);
@@ -2091,8 +2029,11 @@ unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame
                        }
                        break;
                case WLAN_ACTION_ADDBA_RESP: /* ADDBA response */
-                       status = get_unaligned_le16(&frame_body[3]);
-                       tid = ((frame_body[5] >> 2) & 0x7);
+                       status = get_unaligned_le16(
+                               &mgmt->u.action.u.addba_resp.status);
+                       capab = get_unaligned_le16(
+                               &mgmt->u.action.u.addba_resp.capab);
+                       tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2;
                        if (status == 0) {      /* successful */
                                DBG_8723A("agg_enable for TID =%d\n", tid);
                                psta->htpriv.agg_enable_bitmap |= 1 << tid;
@@ -2103,22 +2044,21 @@ unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame
                        break;
 
                case WLAN_ACTION_DELBA: /* DELBA */
-                       if ((frame_body[3] & BIT(3)) == 0) {
-                               psta->htpriv.agg_enable_bitmap &=
-                                       ~(1 << ((frame_body[3] >> 4) & 0xf));
-                               psta->htpriv.candidate_tid_bitmap &=
-                                       ~(1 << ((frame_body[3] >> 4) & 0xf));
-
-                               /* reason_code = frame_body[4] | (frame_body[5] << 8); */
-                               reason_code = get_unaligned_le16(&frame_body[4]);
-                       } else if ((frame_body[3] & BIT(3)) == BIT(3)) {
-                               tid = (frame_body[3] >> 4) & 0x0F;
+                       params = get_unaligned_le16(
+                               &mgmt->u.action.u.delba.params);
+                       tid = params >> 12;
 
-                               preorder_ctrl =  &psta->recvreorder_ctrl[tid];
+                       if (params & IEEE80211_DELBA_PARAM_INITIATOR_MASK) {
+                               preorder_ctrl = &psta->recvreorder_ctrl[tid];
                                preorder_ctrl->enable = false;
                                preorder_ctrl->indicate_seq = 0xffff;
+                       } else {
+                               psta->htpriv.agg_enable_bitmap &= ~(1 << tid);
+                               psta->htpriv.candidate_tid_bitmap &=
+                                       ~(1 << tid);
                        }
-
+                       reason_code = get_unaligned_le16(
+                               &mgmt->u.action.u.delba.reason_code);
                        DBG_8723A("%s(): DELBA: %x(%x)\n", __func__,
                                  pmlmeinfo->agg_enable_bitmap, reason_code);
                        /* todo: how to notify the host while receiving
@@ -2131,2930 +2071,166 @@ unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame
        return _SUCCESS;
 }
 
-#ifdef CONFIG_8723AU_P2P
-
-static int get_reg_classes_full_count(struct p2p_channels channel_list) {
-       int cnt = 0;
-       int i;
-
-       for (i = 0; i < channel_list.reg_classes; i++)
-               cnt += channel_list.reg_class[i].channels;
-
-       return cnt;
-}
-
-void issue_p2p_GO_request23a(struct rtw_adapter *padapter, u8* raddr)
+static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token)
 {
-       unsigned char category = WLAN_CATEGORY_PUBLIC;
-       u8                      action = P2P_PUB_ACTION_ACTION;
-       u32                     p2poui = cpu_to_be32(P2POUI);
-       u8                      oui_subtype = P2P_GO_NEGO_REQ;
-       u8                      wpsie[ 255 ] = { 0x00 }, p2pie[ 255 ] = { 0x00 };
-       u8                      wpsielen = 0, p2pielen = 0;
-       u16                     len_channellist_attr = 0;
-#ifdef CONFIG_8723AU_P2P
-       u32                                     wfdielen = 0;
-#endif /* CONFIG_8723AU_P2P */
-
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr    *pwlanhdr;
-       unsigned short                          *fctrl;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL)
-               return;
-
-       DBG_8723A("[%s] In\n", __func__);
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib23a(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *fctrl = 0;
-
-       ether_addr_copy(pwlanhdr->addr1, raddr);
-       ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv));
-       ether_addr_copy(pwlanhdr->addr3, myid(&padapter->eeprompriv));
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *)&p2poui,
-                                    &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pwdinfo->negotiation_dialog_token = 1;  /*Initialize the dialog value*/
-       pframe = rtw_set_fixed_ie23a(pframe, 1,
-                                    &pwdinfo->negotiation_dialog_token,
-                                    &pattrib->pktlen);
-
-       /*      WPS Section */
-       wpsielen = 0;
-       /*      WPS OUI */
-       *(u32*) (wpsie) = cpu_to_be32(WPSOUI);
-       wpsielen += 4;
-
-       /*      WPS version */
-       /*      Type: */
-       *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001);
-       wpsielen += 2;
-
-       /*      Value: */
-       wpsie[wpsielen++] = WPS_VERSION_1;      /*      Version 1.0 */
-
-       /*      Device Password ID */
-       /*      Type: */
-       *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002);
-       wpsielen += 2;
-
-       /*      Value: */
-
-       if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PEER_DISPLAY_PIN)
-       {
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_DPID_USER_SPEC);
-       }
-       else if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_SELF_DISPLAY_PIN)
-       {
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_DPID_REGISTRAR_SPEC);
-       }
-       else if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PBC)
-       {
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_DPID_PBC);
-       }
-
-       wpsielen += 2;
-
-       pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *) wpsie, &pattrib->pktlen);
-
-       /*      P2P IE Section. */
-
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[p2pielen++] = 0x50;
-       p2pie[p2pielen++] = 0x6F;
-       p2pie[p2pielen++] = 0x9A;
-       p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-       /*      Commented by Albert 20110306 */
-       /*      According to the P2P Specification, the group negoitation request frame should contain 9 P2P attributes */
-       /*      1. P2P Capability */
-       /*      2. Group Owner Intent */
-       /*      3. Configuration Timeout */
-       /*      4. Listen Channel */
-       /*      5. Extended Listen Timing */
-       /*      6. Intended P2P Interface Address */
-       /*      7. Channel List */
-       /*      8. P2P Device Info */
-       /*      9. Operating Channel */
-
-       /*      P2P Capability */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CAPABILITY;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Device Capability Bitmap, 1 byte */
-       p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT;
-
-       /*      Group Capability Bitmap, 1 byte */
-       if (pwdinfo->persistent_supported)
-       {
-               p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | P2P_GRPCAP_PERSISTENT_GROUP;
-       }
-       else
-       {
-               p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN;
-       }
-
-       /*      Group Owner Intent */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_GO_INTENT;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0001);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Todo the tie breaker bit. */
-       p2pie[p2pielen++] = ((pwdinfo->intent << 1) | BIT(0));
-
-       /*      Configuration Timeout */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002);
-       p2pielen += 2;
-
-       /*      Value: */
-       p2pie[p2pielen++] = 200;        /*      2 seconds needed to be the P2P GO */
-       p2pie[p2pielen++] = 200;        /*      2 seconds needed to be the P2P Client */
-
-       /*      Listen Channel */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_LISTEN_CH;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Country String */
-       p2pie[p2pielen++] = 'X';
-       p2pie[p2pielen++] = 'X';
-
-       /*      The third byte should be set to 0x04. */
-       /*      Described in the "Operating Channel Attribute" section. */
-       p2pie[p2pielen++] = 0x04;
-
-       /*      Operating Class */
-       p2pie[p2pielen++] = 0x51;       /*      Copy from SD7 */
-
-       /*      Channel Number */
-       p2pie[p2pielen++] = pwdinfo->listen_channel;    /*      listening channel number */
-
-       /*      Extended Listen Timing ATTR */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0004);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Availability Period */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF);
-       p2pielen += 2;
-
-       /*      Availability Interval */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF);
-       p2pielen += 2;
-
-       /*      Intended P2P Interface Address */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_INTENTED_IF_ADDR;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN);
-       p2pielen += 2;
-
-       /*      Value: */
-       memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN);
-       p2pielen += ETH_ALEN;
-
-       /*      Channel List */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CH_LIST;
-
-       /*  Length: */
-       /*  Country String(3) */
-       /*  + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */
-       /*  + number of channels in all classes */
-       len_channellist_attr = 3
-          + (1 + 1) * (u16)(pmlmeext->channel_list.reg_classes)
-          + get_reg_classes_full_count(pmlmeext->channel_list);
-
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(len_channellist_attr);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Country String */
-       p2pie[p2pielen++] = 'X';
-       p2pie[p2pielen++] = 'X';
-
-       /*      The third byte should be set to 0x04. */
-       /*      Described in the "Operating Channel Attribute" section. */
-       p2pie[p2pielen++] = 0x04;
-
-       /*      Channel Entry List */
-
-       {
-               int i, j;
-               for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) {
-                       /*      Operating Class */
-                       p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class;
+       struct rtw_adapter *adapter = recv_frame->adapter;
+       struct mlme_ext_priv *mlmeext = &adapter->mlmeextpriv;
+       struct sk_buff *skb = recv_frame->pkt;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+       u16 seq_ctrl;
 
-                       /*      Number of Channels */
-                       p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels;
+       seq_ctrl = ((recv_frame->attrib.seq_num&0xffff) << 4) |
+               (recv_frame->attrib.frag_num & 0xf);
 
-                       /*      Channel List */
-                       for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) {
-                               p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i];
+       if (ieee80211_has_retry(hdr->frame_control)) {
+               if (token >= 0) {
+                       if ((seq_ctrl == mlmeext->action_public_rxseq) &&
+                           (token == mlmeext->action_public_dialog_token)) {
+                               DBG_8723A(FUNC_ADPT_FMT" seq_ctrl = 0x%x, "
+                                         "rxseq = 0x%x, token:%d\n",
+                                         FUNC_ADPT_ARG(adapter), seq_ctrl,
+                                         mlmeext->action_public_rxseq, token);
+                               return _FAIL;
+                       }
+               } else {
+                       if (seq_ctrl == mlmeext->action_public_rxseq) {
+                               DBG_8723A(FUNC_ADPT_FMT" seq_ctrl = 0x%x, "
+                                         "rxseq = 0x%x\n",
+                                         FUNC_ADPT_ARG(adapter), seq_ctrl,
+                                         mlmeext->action_public_rxseq);
+                               return _FAIL;
                        }
                }
        }
 
-       /*      Device Info */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */
-       /*      + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      P2P Device Address */
-       memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN);
-       p2pielen += ETH_ALEN;
+       mlmeext->action_public_rxseq = seq_ctrl;
 
-       /*      Config Method */
-       /*      This field should be big endian. Noted by P2P specification. */
+       if (token >= 0)
+               mlmeext->action_public_dialog_token = token;
 
-       *(u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm);
+       return _SUCCESS;
+}
 
-       p2pielen += 2;
+static unsigned int on_action_public23a_p2p(struct recv_frame *precv_frame)
+{
+       struct sk_buff *skb = precv_frame->pkt;
+       u8 *pframe = skb->data;
+       u8 *frame_body;
+       u8 dialogToken = 0;
 
-       /*      Primary Device Type */
-       /*      Category ID */
-       *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA);
-       p2pielen += 2;
+       frame_body = (unsigned char *)
+               (pframe + sizeof(struct ieee80211_hdr_3addr));
 
-       /*      OUI */
-       *(u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI);
-       p2pielen += 4;
+       dialogToken = frame_body[7];
 
-       /*      Sub Category ID */
-       *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER);
-       p2pielen += 2;
+       if (rtw_action_public_decache(precv_frame, dialogToken) == _FAIL)
+               return _FAIL;
 
-       /*      Number of Secondary Device Types */
-       p2pie[p2pielen++] = 0x00;       /*      No Secondary Device Type List */
+       return _SUCCESS;
+}
 
-       /*      Device Name */
-       /*      Type: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME);
-       p2pielen += 2;
+static unsigned int on_action_public23a_vendor(struct recv_frame *precv_frame)
+{
+       unsigned int ret = _FAIL;
+       struct sk_buff *skb = precv_frame->pkt;
+       u8 *pframe = skb->data;
+       u8 *frame_body = pframe + sizeof(struct ieee80211_hdr_3addr);
 
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len);
-       p2pielen += 2;
+       if (!memcmp(frame_body + 2, P2P_OUI23A, 4)) {
+               ret = on_action_public23a_p2p(precv_frame);
+       }
 
-       /*      Value: */
-       memcpy(p2pie + p2pielen, pwdinfo->device_name,
-              pwdinfo->device_name_len);
-       p2pielen += pwdinfo->device_name_len;
+       return ret;
+}
 
-       /*      Operating Channel */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH;
+static unsigned int
+on_action_public23a_default(struct recv_frame *precv_frame, u8 action)
+{
+       unsigned int ret = _FAIL;
+       struct sk_buff *skb = precv_frame->pkt;
+       u8 *pframe = skb->data;
+       uint frame_len = skb->len;
+       u8 *frame_body = pframe + sizeof(struct ieee80211_hdr_3addr);
+       u8 token;
+       struct rtw_adapter *adapter = precv_frame->adapter;
+       int cnt = 0;
+       char msg[64];
 
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005);
-       p2pielen += 2;
+       token = frame_body[2];
 
-       /*      Value: */
-       /*      Country String */
-       p2pie[p2pielen++] = 'X';
-       p2pie[p2pielen++] = 'X';
+       if (rtw_action_public_decache(precv_frame, token) == _FAIL)
+               goto exit;
 
-       /*      The third byte should be set to 0x04. */
-       /*      Described in the "Operating Channel Attribute" section. */
-       p2pie[p2pielen++] = 0x04;
+       cnt += sprintf((msg+cnt), "%s(token:%u)",
+                      action_public_str23a(action), token);
+       rtw_cfg80211_rx_action(adapter, pframe, frame_len, msg);
 
-       /*      Operating Class */
-       if (pwdinfo->operating_channel <= 14)
-       {
-               /*      Operating Class */
-               p2pie[p2pielen++] = 0x51;
-       }
-       else if ((pwdinfo->operating_channel >= 36) && (pwdinfo->operating_channel <= 48))
-       {
-               /*      Operating Class */
-               p2pie[p2pielen++] = 0x73;
-       }
-       else
-       {
-               /*      Operating Class */
-               p2pie[p2pielen++] = 0x7c;
-       }
+       ret = _SUCCESS;
 
-       /*      Channel Number */
-       p2pie[p2pielen++] = pwdinfo->operating_channel; /*      operating channel number */
+exit:
+       return ret;
+}
 
-       pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *) p2pie, &pattrib->pktlen);
+static int on_action_public23a(struct rtw_adapter *padapter,
+                              struct recv_frame *precv_frame)
+{
+       unsigned int ret = _FAIL;
+       struct sk_buff *skb = precv_frame->pkt;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+       u8 *pframe = skb->data;
+       u8 *frame_body = pframe + sizeof(struct ieee80211_hdr_3addr);
+       u8 category, action;
 
-#ifdef CONFIG_8723AU_P2P
-       wfdielen = build_nego_req_wfd_ie(pwdinfo, pframe);
-       pframe += wfdielen;
-       pattrib->pktlen += wfdielen;
-#endif /* CONFIG_8723AU_P2P */
+       /* check RA matches or not */
+       if (!ether_addr_equal(myid(&padapter->eeprompriv), hdr->addr1))
+               goto exit;
 
-       pattrib->last_txcmdsz = pattrib->pktlen;
+       category = frame_body[0];
+       if (category != WLAN_CATEGORY_PUBLIC)
+               goto exit;
 
-       dump_mgntframe23a(padapter, pmgntframe);
+       action = frame_body[1];
+       switch (action) {
+       case ACT_PUBLIC_VENDOR:
+               ret = on_action_public23a_vendor(precv_frame);
+               break;
+       default:
+               ret = on_action_public23a_default(precv_frame, action);
+               break;
+       }
 
-       return;
+exit:
+       return ret;
 }
 
-static void issue_p2p_GO_response(struct rtw_adapter *padapter, u8* raddr, u8* frame_body, uint len, u8 result)
-{
-
-       unsigned char category = WLAN_CATEGORY_PUBLIC;
-       u8 action = P2P_PUB_ACTION_ACTION;
-       u32 p2poui = cpu_to_be32(P2POUI);
-       u8 oui_subtype = P2P_GO_NEGO_RESP;
-       u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 };
-       u8 p2pielen = 0;
-       uint wpsielen = 0;
-       u16 wps_devicepassword_id = 0x0000;
-       uint wps_devicepassword_id_len = 0;
-       u16 len_channellist_attr = 0;
-       int i, j;
-       struct xmit_frame *pmgntframe;
-       struct pkt_attrib *pattrib;
-       unsigned char *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       unsigned short *fctrl;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-#ifdef CONFIG_8723AU_P2P
-       u32 wfdielen = 0;
-#endif /* CONFIG_8723AU_P2P */
-
-       if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL)
-               return;
-
-       DBG_8723A("[%s] In, result = %d\n", __func__,  result);
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib23a(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *fctrl = 0;
-
-       ether_addr_copy(pwlanhdr->addr1, raddr);
-       ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv));
-       ether_addr_copy(pwlanhdr->addr3, myid(&padapter->eeprompriv));
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *) &p2poui,
-                                    &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       /*      The Dialog Token of provisioning discovery request frame. */
-       pwdinfo->negotiation_dialog_token = frame_body[7];
-       pframe = rtw_set_fixed_ie23a(pframe, 1,
-                                    &pwdinfo->negotiation_dialog_token,
-                                    &pattrib->pktlen);
-
-       /*      Commented by Albert 20110328 */
-       /*      Try to get the device password ID from the WPS IE of group
-               negotiation request frame */
-       /*      WiFi Direct test plan 5.1.15 */
-       rtw_get_wps_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_,
-                         len - _PUBLIC_ACTION_IE_OFFSET_, wpsie, &wpsielen);
-       rtw_get_wps_attr_content23a(wpsie, wpsielen, WPS_ATTR_DEVICE_PWID,
-                                   (u8 *)&wps_devicepassword_id,
-                                   &wps_devicepassword_id_len);
-       wps_devicepassword_id = be16_to_cpu(wps_devicepassword_id);
-
-       memset(wpsie, 0x00, 255);
-       wpsielen = 0;
-
-       /*      WPS Section */
-       wpsielen = 0;
-       /*      WPS OUI */
-       *(u32*) (wpsie) = cpu_to_be32(WPSOUI);
-       wpsielen += 4;
-
-       /*      WPS version */
-       /*      Type: */
-       *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001);
-       wpsielen += 2;
-
-       /*      Value: */
-       wpsie[wpsielen++] = WPS_VERSION_1;      /*      Version 1.0 */
-
-       /*      Device Password ID */
-       /*      Type: */
-       *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002);
-       wpsielen += 2;
-
-       /*      Value: */
-       if (wps_devicepassword_id == WPS_DPID_USER_SPEC) {
-               *(u16*) (wpsie + wpsielen) =
-                       cpu_to_be16(WPS_DPID_REGISTRAR_SPEC);
-       } else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC) {
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_DPID_USER_SPEC);
-       } else {
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_DPID_PBC);
-       }
-       wpsielen += 2;
-
-       /*      Commented by Kurt 20120113 */
-       /*      If some device wants to do p2p handshake without sending prov_disc_req */
-       /*      We have to get peer_req_cm from here. */
-       if (!memcmp(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "000", 3)) {
-               if (wps_devicepassword_id == WPS_DPID_USER_SPEC) {
-                       memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3);
-               } else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC) {
-                       memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pad", 3);
-               } else {
-                       memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pbc", 3);
-               }
-       }
-
-       pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen,
-                              (unsigned char *) wpsie, &pattrib->pktlen);
-
-       /*      P2P IE Section. */
-
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[p2pielen++] = 0x50;
-       p2pie[p2pielen++] = 0x6F;
-       p2pie[p2pielen++] = 0x9A;
-       p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-       /*      Commented by Albert 20100908 */
-       /*      According to the P2P Specification, the group negoitation
-               response frame should contain 9 P2P attributes */
-       /*      1. Status */
-       /*      2. P2P Capability */
-       /*      3. Group Owner Intent */
-       /*      4. Configuration Timeout */
-       /*      5. Operating Channel */
-       /*      6. Intended P2P Interface Address */
-       /*      7. Channel List */
-       /*      8. Device Info */
-       /*      9. Group ID     (Only GO) */
-
-       /*      ToDo: */
-
-       /*      P2P Status */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_STATUS;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0001);
-       p2pielen += 2;
-
-       /*      Value: */
-       p2pie[p2pielen++] = result;
-
-       /*      P2P Capability */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CAPABILITY;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Device Capability Bitmap, 1 byte */
-
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) {
-               /*      Commented by Albert 2011/03/08 */
-               /*      According to the P2P specification */
-               /*      if the sending device will be client, the P2P
-                       Capability should be reserved of group negotation
-                       response frame */
-               p2pie[p2pielen++] = 0;
-       } else {
-               /*      Be group owner or meet the error case */
-               p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT;
-       }
-
-       /*      Group Capability Bitmap, 1 byte */
-       if (pwdinfo->persistent_supported) {
-               p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN |
-                       P2P_GRPCAP_PERSISTENT_GROUP;
-       } else {
-               p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN;
-       }
-
-       /*      Group Owner Intent */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_GO_INTENT;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0001);
-       p2pielen += 2;
-
-       /*      Value: */
-       if (pwdinfo->peer_intent & 0x01) {
-               /*      Peer's tie breaker bit is 1, our tie breaker
-                       bit should be 0 */
-               p2pie[p2pielen++] = (pwdinfo->intent << 1);
-       } else {
-               /* Peer's tie breaker bit is 0, our tie breaker bit
-                  should be 1 */
-               p2pie[p2pielen++] = ((pwdinfo->intent << 1) | BIT(0));
-       }
-
-       /*      Configuration Timeout */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      2 seconds needed to be the P2P GO */
-       p2pie[p2pielen++] = 200;
-       /*      2 seconds needed to be the P2P Client */
-       p2pie[p2pielen++] = 200;
-
-       /*      Operating Channel */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Country String */
-       p2pie[p2pielen++] = 'X';
-       p2pie[p2pielen++] = 'X';
-
-       /*      The third byte should be set to 0x04. */
-       /*      Described in the "Operating Channel Attribute" section. */
-       p2pie[p2pielen++] = 0x04;
-
-       /*      Operating Class */
-       if (pwdinfo->operating_channel <= 14) {
-               /*      Operating Class */
-               p2pie[p2pielen++] = 0x51;
-       } else if ((pwdinfo->operating_channel >= 36) &&
-                  (pwdinfo->operating_channel <= 48)) {
-               /*      Operating Class */
-               p2pie[p2pielen++] = 0x73;
-       } else {
-               /*      Operating Class */
-               p2pie[p2pielen++] = 0x7c;
-       }
-
-       /*      Channel Number */
-       /*      operating channel number */
-       p2pie[p2pielen++] = pwdinfo->operating_channel;
-
-       /*      Intended P2P Interface Address */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_INTENTED_IF_ADDR;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN);
-       p2pielen += 2;
-
-       /*      Value: */
-       memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN);
-       p2pielen += ETH_ALEN;
-
-       /*      Channel List */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CH_LIST;
-
-       /*  Country String(3) */
-       /*  + (Operating Class (1) + Number of Channels(1)) *
-           Operation Classes (?) */
-       /*  + number of channels in all classes */
-       len_channellist_attr = 3 +
-               (1 + 1) * (u16)pmlmeext->channel_list.reg_classes +
-               get_reg_classes_full_count(pmlmeext->channel_list);
-
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(len_channellist_attr);
-
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Country String */
-       p2pie[p2pielen++] = 'X';
-       p2pie[p2pielen++] = 'X';
-
-       /*      The third byte should be set to 0x04. */
-       /*      Described in the "Operating Channel Attribute" section. */
-       p2pie[p2pielen++] = 0x04;
-
-       /*      Channel Entry List */
-
-       for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) {
-               /*      Operating Class */
-               p2pie[p2pielen++] =
-                       pmlmeext->channel_list.reg_class[j].reg_class;
-
-               /*      Number of Channels */
-               p2pie[p2pielen++] =
-                       pmlmeext->channel_list.reg_class[j].channels;
-
-               /*      Channel List */
-               for (i = 0;
-                    i < pmlmeext->channel_list.reg_class[j].channels; i++) {
-                       p2pie[p2pielen++] =
-                               pmlmeext->channel_list.reg_class[j].channel[i];
-               }
-       }
-
-       /*      Device Info */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      21 -> P2P Device Address (6bytes) + Config Methods (2bytes) +
-               Primary Device Type (8bytes) */
-       /*      + NumofSecondDevType (1byte) + WPS Device Name ID field
-               (2bytes) + WPS Device Name Len field (2bytes) */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      P2P Device Address */
-       memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN);
-       p2pielen += ETH_ALEN;
-
-       /*      Config Method */
-       /*      This field should be big endian. Noted by P2P specification. */
-
-       *(u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm);
-
-       p2pielen += 2;
-
-       /*      Primary Device Type */
-       /*      Category ID */
-       *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA);
-       p2pielen += 2;
-
-       /*      OUI */
-       *(u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI);
-       p2pielen += 4;
-
-       /*      Sub Category ID */
-       *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER);
-       p2pielen += 2;
-
-       /*      Number of Secondary Device Types */
-       p2pie[p2pielen++] = 0x00;       /*      No Secondary Device Type List */
-
-       /*      Device Name */
-       /*      Type: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME);
-       p2pielen += 2;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len);
-       p2pielen += 2;
-
-       /*      Value: */
-       memcpy(p2pie + p2pielen, pwdinfo->device_name,
-              pwdinfo->device_name_len);
-       p2pielen += pwdinfo->device_name_len;
-
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO))
-       {
-               /*      Group ID Attribute */
-               /*      Type: */
-               p2pie[p2pielen++] = P2P_ATTR_GROUP_ID;
-
-               /*      Length: */
-               *(u16*) (p2pie + p2pielen) =
-                       cpu_to_le16(ETH_ALEN + pwdinfo->nego_ssidlen);
-               p2pielen += 2;
-
-               /*      Value: */
-               /*      p2P Device Address */
-               memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN);
-               p2pielen += ETH_ALEN;
-
-               /*      SSID */
-               memcpy(p2pie + p2pielen, pwdinfo->nego_ssid,
-                      pwdinfo->nego_ssidlen);
-               p2pielen += pwdinfo->nego_ssidlen;
-
-       }
-
-       pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen,
-                              (unsigned char *) p2pie, &pattrib->pktlen);
-
-#ifdef CONFIG_8723AU_P2P
-       wfdielen = build_nego_resp_wfd_ie(pwdinfo, pframe);
-       pframe += wfdielen;
-       pattrib->pktlen += wfdielen;
-#endif /* CONFIG_8723AU_P2P */
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe23a(padapter, pmgntframe);
-
-       return;
-}
-
-static void issue_p2p_GO_confirm(struct rtw_adapter *padapter, u8* raddr,
-                                u8 result)
-{
-
-       unsigned char category = WLAN_CATEGORY_PUBLIC;
-       u8 action = P2P_PUB_ACTION_ACTION;
-       u32 p2poui = cpu_to_be32(P2POUI);
-       u8 oui_subtype = P2P_GO_NEGO_CONF;
-       u8 p2pie[ 255 ] = { 0x00 };
-       u8 p2pielen = 0;
-       struct xmit_frame *pmgntframe;
-       struct pkt_attrib *pattrib;
-       unsigned char *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       unsigned short *fctrl;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-#ifdef CONFIG_8723AU_P2P
-       u32 wfdielen = 0;
-#endif /* CONFIG_8723AU_P2P */
-
-       if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL)
-               return;
-
-       DBG_8723A("[%s] In\n", __func__);
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib23a(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *fctrl = 0;
-
-       ether_addr_copy(pwlanhdr->addr1, raddr);
-       ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv));
-       ether_addr_copy(pwlanhdr->addr3, myid(&padapter->eeprompriv));
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *)&p2poui,
-                                    &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1,
-                                    &pwdinfo->negotiation_dialog_token,
-                                 &pattrib->pktlen);
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[p2pielen++] = 0x50;
-       p2pie[p2pielen++] = 0x6F;
-       p2pie[p2pielen++] = 0x9A;
-       p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-       /*      Commented by Albert 20110306 */
-       /*      According to the P2P Specification, the group negoitation
-               request frame should contain 5 P2P attributes */
-       /*      1. Status */
-       /*      2. P2P Capability */
-       /*      3. Operating Channel */
-       /*      4. Channel List */
-       /*      5. Group ID     (if this WiFi is GO) */
-
-       /*      P2P Status */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_STATUS;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0001);
-       p2pielen += 2;
-
-       /*      Value: */
-       p2pie[p2pielen++] = result;
-
-       /*      P2P Capability */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CAPABILITY;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Device Capability Bitmap, 1 byte */
-       p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT;
-
-       /*      Group Capability Bitmap, 1 byte */
-       if (pwdinfo->persistent_supported) {
-               p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN |
-                       P2P_GRPCAP_PERSISTENT_GROUP;
-       } else {
-               p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN;
-       }
-
-       /*      Operating Channel */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Country String */
-       p2pie[p2pielen++] = 'X';
-       p2pie[p2pielen++] = 'X';
-
-       /*      The third byte should be set to 0x04. */
-       /*      Described in the "Operating Channel Attribute" section. */
-       p2pie[p2pielen++] = 0x04;
-
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) {
-               if (pwdinfo->peer_operating_ch <= 14) {
-                       /*      Operating Class */
-                       p2pie[p2pielen++] = 0x51;
-               } else if ((pwdinfo->peer_operating_ch >= 36) &&
-                        (pwdinfo->peer_operating_ch <= 48)) {
-                       /*      Operating Class */
-                       p2pie[p2pielen++] = 0x73;
-               } else {
-                       /*      Operating Class */
-                       p2pie[p2pielen++] = 0x7c;
-               }
-
-               p2pie[p2pielen++] = pwdinfo->peer_operating_ch;
-       } else {
-               if (pwdinfo->operating_channel <= 14) {
-                       /*      Operating Class */
-                       p2pie[p2pielen++] = 0x51;
-               }
-               else if ((pwdinfo->operating_channel >= 36) &&
-                        (pwdinfo->operating_channel <= 48)) {
-                       /*      Operating Class */
-                       p2pie[p2pielen++] = 0x73;
-               } else {
-                       /*      Operating Class */
-                       p2pie[p2pielen++] = 0x7c;
-               }
-
-               /*      Channel Number */
-               /*      Use the listen channel as the operating channel */
-               p2pie[p2pielen++] = pwdinfo->operating_channel;
-       }
-
-       /*      Channel List */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CH_LIST;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) =
-               cpu_to_le16(pwdinfo->channel_list_attr_len);
-       p2pielen += 2;
-
-       /*      Value: */
-       memcpy(p2pie + p2pielen, pwdinfo->channel_list_attr,
-              pwdinfo->channel_list_attr_len);
-       p2pielen += pwdinfo->channel_list_attr_len;
-
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-               /*      Group ID Attribute */
-               /*      Type: */
-               p2pie[p2pielen++] = P2P_ATTR_GROUP_ID;
-
-               /*      Length: */
-               *(u16*) (p2pie + p2pielen) =
-                       cpu_to_le16(ETH_ALEN + pwdinfo->nego_ssidlen);
-               p2pielen += 2;
-
-               /*      Value: */
-               /*      p2P Device Address */
-               memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN);
-               p2pielen += ETH_ALEN;
-
-               /*      SSID */
-               memcpy(p2pie + p2pielen, pwdinfo->nego_ssid,
-                      pwdinfo->nego_ssidlen);
-               p2pielen += pwdinfo->nego_ssidlen;
-       }
-
-       pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen,
-                              (unsigned char *)p2pie, &pattrib->pktlen);
-
-#ifdef CONFIG_8723AU_P2P
-       wfdielen = build_nego_confirm_wfd_ie(pwdinfo, pframe);
-       pframe += wfdielen;
-       pattrib->pktlen += wfdielen;
-#endif /* CONFIG_8723AU_P2P */
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe23a(padapter, pmgntframe);
-
-       return;
-}
-
-void issue_p2p_invitation_request23a(struct rtw_adapter *padapter, u8* raddr)
-{
-       unsigned char category = WLAN_CATEGORY_PUBLIC;
-       u8 action = P2P_PUB_ACTION_ACTION;
-       u32 p2poui = cpu_to_be32(P2POUI);
-       u8 oui_subtype = P2P_INVIT_REQ;
-       u8 p2pie[ 255 ] = { 0x00 };
-       u8 p2pielen = 0;
-       u8 dialogToken = 3;
-       u16 len_channellist_attr = 0;
-#ifdef CONFIG_8723AU_P2P
-       u32 wfdielen = 0;
-#endif /* CONFIG_8723AU_P2P */
-       int i, j;
-       struct xmit_frame *pmgntframe;
-       struct pkt_attrib *pattrib;
-       unsigned char *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       unsigned short *fctrl;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib23a(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *fctrl = 0;
-
-       ether_addr_copy(pwlanhdr->addr1, raddr);
-       ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv));
-       ether_addr_copy(pwlanhdr->addr3, raddr);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *) &p2poui,
-                                    &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen);
-
-       /*      P2P IE Section. */
-
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[p2pielen++] = 0x50;
-       p2pie[p2pielen++] = 0x6F;
-       p2pie[p2pielen++] = 0x9A;
-       p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-       /*      Commented by Albert 20101011 */
-       /*      According to the P2P Specification, the P2P Invitation
-               request frame should contain 7 P2P attributes */
-       /*      1. Configuration Timeout */
-       /*      2. Invitation Flags */
-       /*      3. Operating Channel    (Only GO) */
-       /*      4. P2P Group BSSID      (Should be included if I am the GO) */
-       /*      5. Channel List */
-       /*      6. P2P Group ID */
-       /*      7. P2P Device Info */
-
-       /*      Configuration Timeout */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      2 seconds needed to be the P2P GO */
-       p2pie[p2pielen++] = 200;
-       /*      2 seconds needed to be the P2P Client */
-       p2pie[p2pielen++] = 200;
-
-       /*      Invitation Flags */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_INVITATION_FLAGS;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0001);
-       p2pielen += 2;
-
-       /*      Value: */
-       p2pie[p2pielen++] = P2P_INVITATION_FLAGS_PERSISTENT;
-
-       /*      Operating Channel */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Country String */
-       p2pie[p2pielen++] = 'X';
-       p2pie[p2pielen++] = 'X';
-
-       /*      The third byte should be set to 0x04. */
-       /*      Described in the "Operating Channel Attribute" section. */
-       p2pie[p2pielen++] = 0x04;
-
-       /*      Operating Class */
-       if (pwdinfo->invitereq_info.operating_ch <= 14)
-               p2pie[p2pielen++] = 0x51;
-       else if ((pwdinfo->invitereq_info.operating_ch >= 36) &&
-                (pwdinfo->invitereq_info.operating_ch <= 48))
-               p2pie[p2pielen++] = 0x73;
-       else
-               p2pie[p2pielen++] = 0x7c;
-
-       /*      Channel Number */
-       /*      operating channel number */
-       p2pie[p2pielen++] = pwdinfo->invitereq_info.operating_ch;
-
-       if (ether_addr_equal(myid(&padapter->eeprompriv),
-                            pwdinfo->invitereq_info.go_bssid)) {
-               /*      P2P Group BSSID */
-               /*      Type: */
-               p2pie[p2pielen++] = P2P_ATTR_GROUP_BSSID;
-
-               /*      Length: */
-               *(u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN);
-               p2pielen += 2;
-
-               /*      Value: */
-               /*      P2P Device Address for GO */
-               memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_bssid,
-                      ETH_ALEN);
-               p2pielen += ETH_ALEN;
-       }
-
-       /*      Channel List */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CH_LIST;
-
-       /*      Length: */
-       /*  Country String(3) */
-       /*  + (Operating Class (1) + Number of Channels(1)) *
-           Operation Classes (?) */
-       /*  + number of channels in all classes */
-       len_channellist_attr = 3 +
-               (1 + 1) * (u16)pmlmeext->channel_list.reg_classes +
-               get_reg_classes_full_count(pmlmeext->channel_list);
-
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(len_channellist_attr);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Country String */
-       p2pie[p2pielen++] = 'X';
-       p2pie[p2pielen++] = 'X';
-
-       /*      The third byte should be set to 0x04. */
-       /*      Described in the "Operating Channel Attribute" section. */
-       p2pie[p2pielen++] = 0x04;
-
-       /*      Channel Entry List */
-       for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) {
-               /*      Operating Class */
-               p2pie[p2pielen++] =
-                       pmlmeext->channel_list.reg_class[j].reg_class;
-
-               /*      Number of Channels */
-               p2pie[p2pielen++] =
-                       pmlmeext->channel_list.reg_class[j].channels;
-
-               /*      Channel List */
-               for (i = 0;
-                    i < pmlmeext->channel_list.reg_class[j].channels; i++) {
-                       p2pie[p2pielen++] =
-                               pmlmeext->channel_list.reg_class[j].channel[i];
-               }
-       }
-
-       /*      P2P Group ID */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_GROUP_ID;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) =
-               cpu_to_le16(6 + pwdinfo->invitereq_info.ssidlen);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      P2P Device Address for GO */
-       memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_bssid, ETH_ALEN);
-       p2pielen += ETH_ALEN;
-
-       /*      SSID */
-       memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_ssid,
-              pwdinfo->invitereq_info.ssidlen);
-       p2pielen += pwdinfo->invitereq_info.ssidlen;
-
-       /*      Device Info */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      21 -> P2P Device Address (6bytes) + Config Methods (2bytes) +
-               Primary Device Type (8bytes) */
-       /*      + NumofSecondDevType (1byte) + WPS Device Name ID field
-               (2bytes) + WPS Device Name Len field (2bytes) */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      P2P Device Address */
-       memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN);
-       p2pielen += ETH_ALEN;
-
-       /*      Config Method */
-       /*      This field should be big endian. Noted by P2P specification. */
-       *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY);
-       p2pielen += 2;
-
-       /*      Primary Device Type */
-       /*      Category ID */
-       *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA);
-       p2pielen += 2;
-
-       /*      OUI */
-       *(u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI);
-       p2pielen += 4;
-
-       /*      Sub Category ID */
-       *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER);
-       p2pielen += 2;
-
-       /*      Number of Secondary Device Types */
-       p2pie[p2pielen++] = 0x00;       /*      No Secondary Device Type List */
-
-       /*      Device Name */
-       /*      Type: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME);
-       p2pielen += 2;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len);
-       p2pielen += 2;
-
-       /*      Value: */
-       memcpy(p2pie + p2pielen, pwdinfo->device_name,
-              pwdinfo->device_name_len);
-       p2pielen += pwdinfo->device_name_len;
-
-       pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen,
-                              (unsigned char *) p2pie, &pattrib->pktlen);
-
-#ifdef CONFIG_8723AU_P2P
-       wfdielen = build_invitation_req_wfd_ie(pwdinfo, pframe);
-       pframe += wfdielen;
-       pattrib->pktlen += wfdielen;
-#endif /* CONFIG_8723AU_P2P */
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe23a(padapter, pmgntframe);
-
-       return;
-}
-
-void issue_p2p_invitation_response23a(struct rtw_adapter *padapter, u8 *raddr,
-                                     u8 dialogToken, u8 status_code)
-{
-       unsigned char category = WLAN_CATEGORY_PUBLIC;
-       u8 action = P2P_PUB_ACTION_ACTION;
-       u32 p2poui = cpu_to_be32(P2POUI);
-       u8 oui_subtype = P2P_INVIT_RESP;
-       u8 p2pie[ 255 ] = { 0x00 };
-       u8 p2pielen = 0;
-       u16 len_channellist_attr = 0;
-#ifdef CONFIG_8723AU_P2P
-       u32 wfdielen = 0;
-#endif /* CONFIG_8723AU_P2P */
-       int i, j;
-
-       struct xmit_frame *pmgntframe;
-       struct pkt_attrib *pattrib;
-       unsigned char *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       unsigned short *fctrl;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib23a(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *fctrl = 0;
-
-       ether_addr_copy(pwlanhdr->addr1, raddr);
-       ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv));
-       ether_addr_copy(pwlanhdr->addr3, raddr);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *)&p2poui,
-                                    &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen);
-
-       /*      P2P IE Section. */
-
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[p2pielen++] = 0x50;
-       p2pie[p2pielen++] = 0x6F;
-       p2pie[p2pielen++] = 0x9A;
-       p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-       /*      Commented by Albert 20101005 */
-       /*      According to the P2P Specification, the P2P Invitation
-               response frame should contain 5 P2P attributes */
-       /*      1. Status */
-       /*      2. Configuration Timeout */
-       /*      3. Operating Channel    (Only GO) */
-       /*      4. P2P Group BSSID      (Only GO) */
-       /*      5. Channel List */
-
-       /*      P2P Status */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_STATUS;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0001);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      When status code is P2P_STATUS_FAIL_INFO_UNAVAILABLE. */
-       /*      Sent the event receiving the P2P Invitation Req frame
-               to DMP UI. */
-       /*      DMP had to compare the MAC address to find out the profile. */
-       /*      So, the WiFi driver will send the
-               P2P_STATUS_FAIL_INFO_UNAVAILABLE to NB. */
-       /*      If the UI found the corresponding profile, the WiFi driver
-               sends the P2P Invitation Req */
-       /*      to NB to rebuild the persistent group. */
-       p2pie[p2pielen++] = status_code;
-
-       /*      Configuration Timeout */
-       /*      Type: */
-       p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT;
-
-       /*      Length: */
-       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      2 seconds needed to be the P2P GO */
-       p2pie[p2pielen++] = 200;
-       /*      2 seconds needed to be the P2P Client */
-       p2pie[p2pielen++] = 200;
-
-       if (status_code == P2P_STATUS_SUCCESS) {
-               if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-                       /* The P2P Invitation request frame asks this
-                          Wi-Fi device to be the P2P GO */
-                       /* In this case, the P2P Invitation response
-                          frame should carry the two more P2P attributes. */
-                       /* First one is operating channel attribute. */
-                       /* Second one is P2P Group BSSID attribute. */
-
-                       /* Operating Channel */
-                       /* Type: */
-                       p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH;
-
-                       /* Length: */
-                       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005);
-                       p2pielen += 2;
-
-                       /* Value: */
-                       /* Country String */
-                       p2pie[p2pielen++] = 'X';
-                       p2pie[p2pielen++] = 'X';
-
-                       /* The third byte should be set to 0x04. */
-                       /* Described in the "Operating Channel Attribute"
-                          section. */
-                       p2pie[p2pielen++] = 0x04;
-
-                       /* Operating Class */
-                       /*      Copy from SD7 */
-                       p2pie[p2pielen++] = 0x51;
-
-                       /* Channel Number */
-                       /*      operating channel number */
-                       p2pie[p2pielen++] = pwdinfo->operating_channel;
-
-                       /*      P2P Group BSSID */
-                       /*      Type: */
-                       p2pie[p2pielen++] = P2P_ATTR_GROUP_BSSID;
-
-                       /*      Length: */
-                       *(u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN);
-                       p2pielen += 2;
-
-                       /*      Value: */
-                       /*      P2P Device Address for GO */
-                       memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv),
-                              ETH_ALEN);
-                       p2pielen += ETH_ALEN;
-               }
-
-               /*      Channel List */
-               /*      Type: */
-               p2pie[p2pielen++] = P2P_ATTR_CH_LIST;
-
-               /*      Length: */
-               /*  Country String(3) */
-               /*  + (Operating Class (1) + Number of Channels(1)) *
-                   Operation Classes (?) */
-               /*  + number of channels in all classes */
-               len_channellist_attr = 3 +
-                       (1 + 1) * (u16)pmlmeext->channel_list.reg_classes +
-                       get_reg_classes_full_count(pmlmeext->channel_list);
-
-               *(u16*) (p2pie + p2pielen) = cpu_to_le16(len_channellist_attr);
-               p2pielen += 2;
-
-               /*      Value: */
-               /*      Country String */
-               p2pie[p2pielen++] = 'X';
-               p2pie[p2pielen++] = 'X';
-
-               /* The third byte should be set to 0x04. */
-               /* Described in the "Operating Channel Attribute" section. */
-               p2pie[p2pielen++] = 0x04;
-
-               /*      Channel Entry List */
-               for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) {
-                       /*      Operating Class */
-                       p2pie[p2pielen++] =
-                               pmlmeext->channel_list.reg_class[j].reg_class;
-
-                       /*      Number of Channels */
-                       p2pie[p2pielen++] =
-                               pmlmeext->channel_list.reg_class[j].channels;
-
-                       /*      Channel List */
-                       for (i = 0;
-                            i < pmlmeext->channel_list.reg_class[j].channels;
-                            i++) {
-                               p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i];
-                       }
-               }
-       }
-
-       pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen,
-                              (unsigned char *)p2pie, &pattrib->pktlen);
-
-#ifdef CONFIG_8723AU_P2P
-       wfdielen = build_invitation_resp_wfd_ie(pwdinfo, pframe);
-       pframe += wfdielen;
-       pattrib->pktlen += wfdielen;
-#endif /* CONFIG_8723AU_P2P */
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe23a(padapter, pmgntframe);
-
-       return;
-}
-
-void issue_p2p_provision_request23a(struct rtw_adapter *padapter, u8 *pssid,
-                                   u8 ussidlen, u8 *pdev_raddr)
-{
-       unsigned char category = WLAN_CATEGORY_PUBLIC;
-       u8 action = P2P_PUB_ACTION_ACTION;
-       u8 dialogToken = 1;
-       u32 p2poui = cpu_to_be32(P2POUI);
-       u8 oui_subtype = P2P_PROVISION_DISC_REQ;
-       u8 wpsie[100] = { 0x00 };
-       u8 wpsielen = 0;
-       u32 p2pielen = 0;
-#ifdef CONFIG_8723AU_P2P
-       u32 wfdielen = 0;
-#endif /* CONFIG_8723AU_P2P */
-       struct xmit_frame *pmgntframe;
-       struct pkt_attrib *pattrib;
-       unsigned char *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       unsigned short *fctrl;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL)
-               return;
-
-       DBG_8723A("[%s] In\n", __func__);
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib23a(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *fctrl = 0;
-
-       ether_addr_copy(pwlanhdr->addr1, pdev_raddr);
-       ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv));
-       ether_addr_copy(pwlanhdr->addr3, pdev_raddr);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *)&p2poui,
-                                    &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen);
-
-       p2pielen = build_prov_disc_request_p2p_ie23a(pwdinfo, pframe, pssid,
-                                                    ussidlen, pdev_raddr);
-
-       pframe += p2pielen;
-       pattrib->pktlen += p2pielen;
-
-       wpsielen = 0;
-       /*      WPS OUI */
-       *(u32*) (wpsie) = cpu_to_be32(WPSOUI);
-       wpsielen += 4;
-
-       /*      WPS version */
-       /*      Type: */
-       *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001);
-       wpsielen += 2;
-
-       /*      Value: */
-       wpsie[wpsielen++] = WPS_VERSION_1;      /*      Version 1.0 */
-
-       /*      Config Method */
-       /*      Type: */
-       *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002);
-       wpsielen += 2;
-
-       /*      Value: */
-       *(u16*) (wpsie + wpsielen) = cpu_to_be16(pwdinfo->tx_prov_disc_info.wps_config_method_request);
-       wpsielen += 2;
-
-       pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen,
-                              (unsigned char *) wpsie, &pattrib->pktlen);
-
-#ifdef CONFIG_8723AU_P2P
-       wfdielen = build_provdisc_req_wfd_ie(pwdinfo, pframe);
-       pframe += wfdielen;
-       pattrib->pktlen += wfdielen;
-#endif /* CONFIG_8723AU_P2P */
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe23a(padapter, pmgntframe);
-
-       return;
-}
-
-static u8 is_matched_in_profilelist(u8 *peermacaddr,
-                                   struct profile_info *profileinfo)
-{
-       u8 i, match_result = 0;
-
-       DBG_8723A("[%s] peermac = %.2X %.2X %.2X %.2X %.2X %.2X\n", __func__,
-                 peermacaddr[0], peermacaddr[1], peermacaddr[2],
-                 peermacaddr[3], peermacaddr[4], peermacaddr[5]);
-
-       for (i = 0; i < P2P_MAX_PERSISTENT_GROUP_NUM; i++, profileinfo++) {
-              DBG_8723A("[%s] profileinfo_mac = %.2X %.2X %.2X %.2X %.2X "
-                        "%.2X\n", __func__, profileinfo->peermac[0],
-                        profileinfo->peermac[1], profileinfo->peermac[2],
-                        profileinfo->peermac[3], profileinfo->peermac[4],
-                        profileinfo->peermac[5]);
-               if (ether_addr_equal(peermacaddr, profileinfo->peermac)) {
-                       match_result = 1;
-                       DBG_8723A("[%s] Match!\n", __func__);
-                       break;
-               }
-       }
-
-       return match_result;
-}
-
-void issue_probersp23a_p2p23a(struct rtw_adapter *padapter, unsigned char *da)
-{
-       struct xmit_frame *pmgntframe;
-       struct pkt_attrib *pattrib;
-       unsigned char *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       unsigned short *fctrl;
-       unsigned char *mac;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       u16 beacon_interval = 100;
-       u16 capInfo = 0;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       u8 wpsie[255] = { 0x00 };
-       u32 wpsielen = 0, p2pielen = 0;
-#ifdef CONFIG_8723AU_P2P
-       u32 wfdielen = 0;
-#endif /* CONFIG_8723AU_P2P */
-       struct cfg80211_wifidirect_info *pcfg80211_wdinfo =
-               &padapter->cfg80211_wdinfo;
-       struct ieee80211_channel *ieee_ch =
-               &pcfg80211_wdinfo->remain_on_ch_channel;
-       u8 listen_channel =
-               (u8)ieee80211_frequency_to_channel(ieee_ch->center_freq);
-
-       /* DBG_8723A("%s\n", __func__); */
-
-       if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL)
-       {
-               return;
-       }
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib23a(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       mac = myid(&padapter->eeprompriv);
-
-       fctrl = &pwlanhdr->frame_control;
-       *fctrl = 0;
-       ether_addr_copy(pwlanhdr->addr1, da);
-       ether_addr_copy(pwlanhdr->addr2, mac);
-
-       /*      Use the device address for BSSID field. */
-       ether_addr_copy(pwlanhdr->addr3, mac);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(fctrl, WIFI_PROBERSP);
-
-       pattrib->hdrlen = sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = pattrib->hdrlen;
-       pframe += pattrib->hdrlen;
-
-       /* timestamp will be inserted by hardware */
-       pframe += 8;
-       pattrib->pktlen += 8;
-
-       /*  beacon interval: 2 bytes */
-       memcpy(pframe, (unsigned char *) &beacon_interval, 2);
-       pframe += 2;
-       pattrib->pktlen += 2;
-
-       /*      capability info: 2 bytes */
-       /*      ESS and IBSS bits must be 0 (defined in the 3.1.2.1.1 of
-               WiFi Direct Spec) */
-       capInfo |= cap_ShortPremble;
-       capInfo |= cap_ShortSlot;
-
-       memcpy(pframe, (unsigned char *) &capInfo, 2);
-       pframe += 2;
-       pattrib->pktlen += 2;
-
-       /*  SSID */
-       pframe = rtw_set_ie23a(pframe, _SSID_IE_, 7, pwdinfo->p2p_wildcard_ssid,
-                              &pattrib->pktlen);
-
-       /*  supported rates... */
-       /*      Use the OFDM rate in the P2P probe response frame.
-               (6(B), 9(B), 12, 18, 24, 36, 48, 54) */
-       pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, 8,
-                              pwdinfo->support_rate, &pattrib->pktlen);
-
-       /*  DS parameter set */
-       if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled &&
-           listen_channel != 0) {
-               pframe = rtw_set_ie23a(pframe, _DSSET_IE_, 1, (unsigned char *)
-                                      &listen_channel, &pattrib->pktlen);
-       } else {
-               pframe = rtw_set_ie23a(pframe, _DSSET_IE_, 1, (unsigned char *)
-                                      &pwdinfo->listen_channel,
-                                      &pattrib->pktlen);
-       }
-
-       if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) {
-               if (pmlmepriv->wps_probe_resp_ie &&
-                   pmlmepriv->p2p_probe_resp_ie) {
-                       /* WPS IE */
-                       memcpy(pframe, pmlmepriv->wps_probe_resp_ie,
-                              pmlmepriv->wps_probe_resp_ie_len);
-                       pattrib->pktlen += pmlmepriv->wps_probe_resp_ie_len;
-                       pframe += pmlmepriv->wps_probe_resp_ie_len;
-
-                       /* P2P IE */
-                       memcpy(pframe, pmlmepriv->p2p_probe_resp_ie,
-                              pmlmepriv->p2p_probe_resp_ie_len);
-                       pattrib->pktlen += pmlmepriv->p2p_probe_resp_ie_len;
-                       pframe += pmlmepriv->p2p_probe_resp_ie_len;
-               }
-       } else {
-
-               /*      Todo: WPS IE */
-               /*      Noted by Albert 20100907 */
-               /*      According to the WPS specification, all the WPS
-                       attribute is presented by Big Endian. */
-
-               wpsielen = 0;
-               /*      WPS OUI */
-               *(u32*) (wpsie) = cpu_to_be32(WPSOUI);
-               wpsielen += 4;
-
-               /*      WPS version */
-               /*      Type: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1);
-               wpsielen += 2;
-
-               /*      Length: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001);
-               wpsielen += 2;
-
-               /*      Value: */
-               wpsie[wpsielen++] = WPS_VERSION_1;      /*      Version 1.0 */
-
-               /*      WiFi Simple Config State */
-               /*      Type: */
-               *(u16*) (wpsie + wpsielen) =
-                       cpu_to_be16(WPS_ATTR_SIMPLE_CONF_STATE);
-               wpsielen += 2;
-
-               /*      Length: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001);
-               wpsielen += 2;
-
-               /*      Value: */
-               wpsie[wpsielen++] = WPS_WSC_STATE_NOT_CONFIG;
-
-               /*      Response Type */
-               /*      Type: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_RESP_TYPE);
-               wpsielen += 2;
-
-               /*      Length: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001);
-               wpsielen += 2;
-
-               /*      Value: */
-               wpsie[wpsielen++] = WPS_RESPONSE_TYPE_8021X;
-
-               /*      UUID-E */
-               /*      Type: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_UUID_E);
-               wpsielen += 2;
-
-               /*      Length: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0010);
-               wpsielen += 2;
-
-               /*      Value: */
-               memcpy(wpsie + wpsielen, myid(&padapter->eeprompriv), ETH_ALEN);
-               wpsielen += 0x10;
-
-               /*      Manufacturer */
-               /*      Type: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MANUFACTURER);
-               wpsielen += 2;
-
-               /*      Length: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0007);
-               wpsielen += 2;
-
-               /*      Value: */
-               memcpy(wpsie + wpsielen, "Realtek", 7);
-               wpsielen += 7;
-
-               /*      Model Name */
-               /*      Type: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MODEL_NAME);
-               wpsielen += 2;
-
-               /*      Length: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0006);
-               wpsielen += 2;
-
-               /*      Value: */
-               memcpy(wpsie + wpsielen, "8192CU", 6);
-               wpsielen += 6;
-
-               /*      Model Number */
-               /*      Type: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MODEL_NUMBER);
-               wpsielen += 2;
-
-               /*      Length: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001);
-               wpsielen += 2;
-
-               /*      Value: */
-               wpsie[ wpsielen++ ] = 0x31;             /*      character 1 */
-
-               /*      Serial Number */
-               /*      Type: */
-               *(u16*) (wpsie + wpsielen) =
-                       cpu_to_be16(WPS_ATTR_SERIAL_NUMBER);
-               wpsielen += 2;
-
-               /*      Length: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(ETH_ALEN);
-               wpsielen += 2;
-
-               /*      Value: */
-               memcpy(wpsie + wpsielen, "123456", ETH_ALEN);
-               wpsielen += ETH_ALEN;
-
-               /*      Primary Device Type */
-               /*      Type: */
-               *(u16*) (wpsie + wpsielen) =
-                       cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE);
-               wpsielen += 2;
-
-               /*      Length: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0008);
-               wpsielen += 2;
-
-               /*      Value: */
-               /*      Category ID */
-               *(u16*) (wpsie + wpsielen) =
-                       cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA);
-               wpsielen += 2;
-
-               /*      OUI */
-               *(u32*) (wpsie + wpsielen) = cpu_to_be32(WPSOUI);
-               wpsielen += 4;
-
-               /*      Sub Category ID */
-               *(u16*) (wpsie + wpsielen) =
-                       cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER);
-               wpsielen += 2;
-
-               /*      Device Name */
-               /*      Type: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME);
-               wpsielen += 2;
-
-               /*      Length: */
-               *(u16*) (wpsie + wpsielen) =
-                       cpu_to_be16(pwdinfo->device_name_len);
-               wpsielen += 2;
-
-               /*      Value: */
-               if (pwdinfo->device_name_len) {
-                       memcpy(wpsie + wpsielen, pwdinfo->device_name,
-                              pwdinfo->device_name_len);
-                       wpsielen += pwdinfo->device_name_len;
-               }
-
-               /*      Config Method */
-               /*      Type: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD);
-               wpsielen += 2;
-
-               /*      Length: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002);
-               wpsielen += 2;
-
-               /*      Value: */
-               *(u16*) (wpsie + wpsielen) =
-                       cpu_to_be16(pwdinfo->supported_wps_cm);
-               wpsielen += 2;
-
-               pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen,
-                                      (unsigned char *)wpsie,
-                                      &pattrib->pktlen);
-
-               p2pielen = build_probe_resp_p2p_ie23a(pwdinfo, pframe);
-               pframe += p2pielen;
-               pattrib->pktlen += p2pielen;
-       }
-
-#ifdef CONFIG_8723AU_P2P
-       if (pwdinfo->wfd_info->wfd_enable) {
-               wfdielen = build_probe_resp_wfd_ie(pwdinfo, pframe, 0);
-               pframe += wfdielen;
-               pattrib->pktlen += wfdielen;
-       } else if (pmlmepriv->wfd_probe_resp_ie &&
-                pmlmepriv->wfd_probe_resp_ie_len > 0) {
-               /* WFD IE */
-               memcpy(pframe, pmlmepriv->wfd_probe_resp_ie,
-                      pmlmepriv->wfd_probe_resp_ie_len);
-               pattrib->pktlen += pmlmepriv->wfd_probe_resp_ie_len;
-               pframe += pmlmepriv->wfd_probe_resp_ie_len;
-       }
-#endif /* CONFIG_8723AU_P2P */
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe23a(padapter, pmgntframe);
-
-       return;
-}
-
-static int _issue23a_probereq_p2p(struct rtw_adapter *padapter, u8 *da,
-                                 int wait_ack)
-{
-       int ret = _FAIL;
-       struct xmit_frame *pmgntframe;
-       struct pkt_attrib *pattrib;
-       unsigned char *pframe;
-       struct ieee80211_hdr *pwlanhdr;
-       unsigned short *fctrl;
-       unsigned char *mac;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       u8      bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-       u8 wpsie[255] = {0x00}, p2pie[255] = {0x00};
-       u16 wpsielen = 0, p2pielen = 0;
-#ifdef CONFIG_8723AU_P2P
-       u32 wfdielen = 0;
-#endif /* CONFIG_8723AU_P2P */
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-       if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL)
-               goto exit;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib23a(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       mac = myid(&padapter->eeprompriv);
-
-       fctrl = &pwlanhdr->frame_control;
-       *fctrl = 0;
-
-       if (da) {
-               ether_addr_copy(pwlanhdr->addr1, da);
-               ether_addr_copy(pwlanhdr->addr3, da);
-       } else {
-               if ((pwdinfo->p2p_info.scan_op_ch_only) ||
-                   (pwdinfo->rx_invitereq_info.scan_op_ch_only)) {
-                       /*      This two flags will be set when this is
-                               only the P2P client mode. */
-                       ether_addr_copy(pwlanhdr->addr1,
-                                       pwdinfo->p2p_peer_interface_addr);
-                       ether_addr_copy(pwlanhdr->addr3,
-                                       pwdinfo->p2p_peer_interface_addr);
-               } else {
-                       /*      broadcast probe request frame */
-                       ether_addr_copy(pwlanhdr->addr1, bc_addr);
-                       ether_addr_copy(pwlanhdr->addr3, bc_addr);
-               }
-       }
-       ether_addr_copy(pwlanhdr->addr2, mac);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_PROBEREQ);
-
-       pframe += sizeof (struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof (struct ieee80211_hdr_3addr);
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) {
-               pframe = rtw_set_ie23a(pframe, _SSID_IE_,
-                                   pwdinfo->tx_prov_disc_info.ssid.ssid_len,
-                                   pwdinfo->tx_prov_disc_info.ssid.ssid,
-                                   &pattrib->pktlen);
-       } else {
-               pframe = rtw_set_ie23a(pframe, _SSID_IE_,
-                                      P2P_WILDCARD_SSID_LEN,
-                                      pwdinfo->p2p_wildcard_ssid,
-                                      &pattrib->pktlen);
-       }
-       /*      Use the OFDM rate in the P2P probe request frame.
-               (6(B), 9(B), 12(B), 24(B), 36, 48, 54) */
-       pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, 8,
-                              pwdinfo->support_rate, &pattrib->pktlen);
-
-       if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) {
-               if (pmlmepriv->wps_probe_req_ie &&
-                   pmlmepriv->p2p_probe_req_ie) {
-                       /* WPS IE */
-                       memcpy(pframe, pmlmepriv->wps_probe_req_ie,
-                              pmlmepriv->wps_probe_req_ie_len);
-                       pattrib->pktlen += pmlmepriv->wps_probe_req_ie_len;
-                       pframe += pmlmepriv->wps_probe_req_ie_len;
-
-                       /* P2P IE */
-                       memcpy(pframe, pmlmepriv->p2p_probe_req_ie,
-                              pmlmepriv->p2p_probe_req_ie_len);
-                       pattrib->pktlen += pmlmepriv->p2p_probe_req_ie_len;
-                       pframe += pmlmepriv->p2p_probe_req_ie_len;
-               }
-       } else {
-
-               /*      WPS IE */
-               /*      Noted by Albert 20110221 */
-               /*      According to the WPS specification, all the WPS
-                       attribute is presented by Big Endian. */
-
-               wpsielen = 0;
-               /*      WPS OUI */
-               *(u32*) (wpsie) = cpu_to_be32(WPSOUI);
-               wpsielen += 4;
-
-               /*      WPS version */
-               /*      Type: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1);
-               wpsielen += 2;
-
-               /*      Length: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001);
-               wpsielen += 2;
-
-               /*      Value: */
-               wpsie[wpsielen++] = WPS_VERSION_1;      /*      Version 1.0 */
-
-               if (pmlmepriv->wps_probe_req_ie == NULL) {
-                       /*      UUID-E */
-                       /*      Type: */
-                       *(u16*) (wpsie + wpsielen) =
-                               cpu_to_be16(WPS_ATTR_UUID_E);
-                       wpsielen += 2;
-
-                       /*      Length: */
-                       *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0010);
-                       wpsielen += 2;
-
-                       /*      Value: */
-                       memcpy(wpsie + wpsielen, myid(&padapter->eeprompriv),
-                              ETH_ALEN);
-                       wpsielen += 0x10;
-
-                       /*      Config Method */
-                       /*      Type: */
-                       *(u16*) (wpsie + wpsielen) =
-                               cpu_to_be16(WPS_ATTR_CONF_METHOD);
-                       wpsielen += 2;
-
-                       /*      Length: */
-                       *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002);
-                       wpsielen += 2;
-
-                       /*      Value: */
-                       *(u16*) (wpsie + wpsielen) =
-                               cpu_to_be16(pwdinfo->supported_wps_cm);
-                       wpsielen += 2;
-               }
-
-               /*      Device Name */
-               /*      Type: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME);
-               wpsielen += 2;
-
-               /*      Length: */
-               *(u16*) (wpsie + wpsielen) =
-                       cpu_to_be16(pwdinfo->device_name_len);
-               wpsielen += 2;
-
-               /*      Value: */
-               memcpy(wpsie + wpsielen, pwdinfo->device_name,
-                      pwdinfo->device_name_len);
-               wpsielen += pwdinfo->device_name_len;
-
-               /*      Primary Device Type */
-               /*      Type: */
-               *(u16*) (wpsie + wpsielen) =
-                       cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE);
-               wpsielen += 2;
-
-               /*      Length: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0008);
-               wpsielen += 2;
-
-               /*      Value: */
-               /*      Category ID */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_PDT_CID_RTK_WIDI);
-               wpsielen += 2;
-
-               /*      OUI */
-               *(u32*) (wpsie + wpsielen) = cpu_to_be32(WPSOUI);
-               wpsielen += 4;
-
-               /*      Sub Category ID */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_PDT_SCID_RTK_DMP);
-               wpsielen += 2;
-
-               /*      Device Password ID */
-               /*      Type: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID);
-               wpsielen += 2;
-
-               /*      Length: */
-               *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002);
-               wpsielen += 2;
-
-               /*      Value: */
-               /*      Registrar-specified */
-               *(u16*) (wpsie + wpsielen) =
-                       cpu_to_be16(WPS_DPID_REGISTRAR_SPEC);
-               wpsielen += 2;
-
-               pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen,
-                                      (unsigned char *)wpsie,
-                                      &pattrib->pktlen);
-
-               /*      P2P OUI */
-               p2pielen = 0;
-               p2pie[p2pielen++] = 0x50;
-               p2pie[p2pielen++] = 0x6F;
-               p2pie[p2pielen++] = 0x9A;
-               p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-               /*      Commented by Albert 20110221 */
-               /*      According to the P2P Specification, the probe request
-                       frame should contain 5 P2P attributes */
-               /*      1. P2P Capability */
-               /*      2. P2P Device ID if this probe request wants to
-                       find the specific P2P device */
-               /*      3. Listen Channel */
-               /*      4. Extended Listen Timing */
-               /*      5. Operating Channel if this WiFi is working as
-                       the group owner now */
-
-               /*      P2P Capability */
-               /*      Type: */
-               p2pie[p2pielen++] = P2P_ATTR_CAPABILITY;
-
-               /*      Length: */
-               *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002);
-               p2pielen += 2;
-
-               /*      Value: */
-               /*      Device Capability Bitmap, 1 byte */
-               p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT;
-
-               /*      Group Capability Bitmap, 1 byte */
-               if (pwdinfo->persistent_supported)
-                       p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP |
-                               DMP_P2P_GRPCAP_SUPPORT;
-               else
-                       p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT;
-
-               /*      Listen Channel */
-               /*      Type: */
-               p2pie[p2pielen++] = P2P_ATTR_LISTEN_CH;
-
-               /*      Length: */
-               *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005);
-               p2pielen += 2;
-
-               /*      Value: */
-               /*      Country String */
-               p2pie[p2pielen++] = 'X';
-               p2pie[p2pielen++] = 'X';
-
-               /* The third byte should be set to 0x04. */
-               /* Described in the "Operating Channel Attribute" section. */
-               p2pie[p2pielen++] = 0x04;
-
-               /*      Operating Class */
-               p2pie[p2pielen++] = 0x51;       /*      Copy from SD7 */
-
-               /*      Channel Number */
-               /*      listen channel */
-               p2pie[p2pielen++] = pwdinfo->listen_channel;
-
-               /*      Extended Listen Timing */
-               /*      Type: */
-               p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING;
-
-               /*      Length: */
-               *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0004);
-               p2pielen += 2;
-
-               /*      Value: */
-               /*      Availability Period */
-               *(u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF);
-               p2pielen += 2;
-
-               /*      Availability Interval */
-               *(u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF);
-               p2pielen += 2;
-
-               if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-                       /* Operating Channel (if this WiFi is working as
-                          the group owner now) */
-                       /* Type: */
-                       p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH;
-
-                       /*      Length: */
-                       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005);
-                       p2pielen += 2;
-
-                       /*      Value: */
-                       /*      Country String */
-                       p2pie[p2pielen++] = 'X';
-                       p2pie[p2pielen++] = 'X';
-
-                       /* The third byte should be set to 0x04. */
-                       /* Described in the "Operating Channel Attribute"
-                          section. */
-                       p2pie[p2pielen++] = 0x04;
-
-                       /*      Operating Class */
-                       p2pie[p2pielen++] = 0x51;       /*      Copy from SD7 */
-
-                       /*      Channel Number */
-                       /*      operating channel number */
-                       p2pie[p2pielen++] = pwdinfo->operating_channel;
-               }
-
-               pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen,
-                                      (unsigned char *)p2pie,
-                                      &pattrib->pktlen);
-
-               if (pmlmepriv->wps_probe_req_ie) {
-                       /* WPS IE */
-                       memcpy(pframe, pmlmepriv->wps_probe_req_ie,
-                              pmlmepriv->wps_probe_req_ie_len);
-                       pattrib->pktlen += pmlmepriv->wps_probe_req_ie_len;
-                       pframe += pmlmepriv->wps_probe_req_ie_len;
-               }
-       }
-
-#ifdef CONFIG_8723AU_P2P
-       if (pwdinfo->wfd_info->wfd_enable) {
-               wfdielen = build_probe_req_wfd_ie(pwdinfo, pframe);
-               pframe += wfdielen;
-               pattrib->pktlen += wfdielen;
-       } else if (pmlmepriv->wfd_probe_req_ie &&
-                  pmlmepriv->wfd_probe_req_ie_len>0) {
-               /* WFD IE */
-               memcpy(pframe, pmlmepriv->wfd_probe_req_ie,
-                      pmlmepriv->wfd_probe_req_ie_len);
-               pattrib->pktlen += pmlmepriv->wfd_probe_req_ie_len;
-               pframe += pmlmepriv->wfd_probe_req_ie_len;
-       }
-#endif /* CONFIG_8723AU_P2P */
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                ("issuing probe_req, tx_len =%d\n", pattrib->last_txcmdsz));
-
-       if (wait_ack) {
-               ret = dump_mgntframe23a_and_wait_ack23a(padapter, pmgntframe);
-       } else {
-               dump_mgntframe23a(padapter, pmgntframe);
-               ret = _SUCCESS;
-       }
-
-exit:
-       return ret;
-}
-
-inline void issue23a_probereq_p2p(struct rtw_adapter *adapter, u8 *da)
-{
-       _issue23a_probereq_p2p(adapter, da, false);
-}
-
-int issue23a_probereq_p2p_ex(struct rtw_adapter *adapter, u8 *da,
-                            int try_cnt, int wait_ms)
-{
-       int ret;
-       int i = 0;
-       unsigned long start = jiffies;
-
-       do {
-               ret = _issue23a_probereq_p2p(adapter, da,
-                                            wait_ms > 0 ? true : false);
-
-               i++;
-
-               if (adapter->bDriverStopped || adapter->bSurpriseRemoved)
-                       break;
-
-               if (i < try_cnt && wait_ms > 0 && ret == _FAIL)
-                       msleep(wait_ms);
-
-       } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0)));
-
-       if (ret != _FAIL) {
-               ret = _SUCCESS;
-               goto exit;
-       }
-
-       if (try_cnt && wait_ms) {
-               if (da)
-                       DBG_8723A(FUNC_ADPT_FMT" to "MAC_FMT", ch:%u%s, %d/%d "
-                                 "in %u ms\n", FUNC_ADPT_ARG(adapter),
-                                 MAC_ARG(da), rtw_get_oper_ch23a(adapter),
-                                 ret == _SUCCESS?", acked":"", i, try_cnt,
-                                 jiffies_to_msecs(jiffies - start));
-               else
-                       DBG_8723A(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n",
-                                 FUNC_ADPT_ARG(adapter),
-                                 rtw_get_oper_ch23a(adapter),
-                                 ret == _SUCCESS?", acked":"", i, try_cnt,
-                                 jiffies_to_msecs(jiffies - start));
-       }
-exit:
-       return ret;
-}
-
-#endif /* CONFIG_8723AU_P2P */
-
-static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token)
-{
-       struct rtw_adapter *adapter = recv_frame->adapter;
-       struct mlme_ext_priv *mlmeext = &adapter->mlmeextpriv;
-       struct sk_buff *skb = recv_frame->pkt;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       u16 seq_ctrl;
-
-       seq_ctrl = ((recv_frame->attrib.seq_num&0xffff) << 4) |
-               (recv_frame->attrib.frag_num & 0xf);
-
-       if (ieee80211_has_retry(hdr->frame_control)) {
-               if (token >= 0) {
-                       if ((seq_ctrl == mlmeext->action_public_rxseq) &&
-                           (token == mlmeext->action_public_dialog_token)) {
-                               DBG_8723A(FUNC_ADPT_FMT" seq_ctrl = 0x%x, "
-                                         "rxseq = 0x%x, token:%d\n",
-                                         FUNC_ADPT_ARG(adapter), seq_ctrl,
-                                         mlmeext->action_public_rxseq, token);
-                               return _FAIL;
-                       }
-               } else {
-                       if (seq_ctrl == mlmeext->action_public_rxseq) {
-                               DBG_8723A(FUNC_ADPT_FMT" seq_ctrl = 0x%x, "
-                                         "rxseq = 0x%x\n",
-                                         FUNC_ADPT_ARG(adapter), seq_ctrl,
-                                         mlmeext->action_public_rxseq);
-                               return _FAIL;
-                       }
-               }
-       }
-
-       mlmeext->action_public_rxseq = seq_ctrl;
-
-       if (token >= 0)
-               mlmeext->action_public_dialog_token = token;
-
-       return _SUCCESS;
-}
-
-static unsigned int on_action_public23a_p2p(struct recv_frame *precv_frame)
-{
-       struct sk_buff *skb = precv_frame->pkt;
-       u8 *pframe = skb->data;
-       u8 *frame_body;
-       u8 dialogToken = 0;
-#ifdef CONFIG_8723AU_P2P
-       struct rtw_adapter *padapter = precv_frame->adapter;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       uint len = skb->len;
-       u8 *p2p_ie;
-       u32     p2p_ielen;
-       struct  wifidirect_info *pwdinfo = &padapter->wdinfo;
-       u8      result = P2P_STATUS_SUCCESS;
-#endif /* CONFIG_8723AU_P2P */
-
-       frame_body = (unsigned char *)
-               (pframe + sizeof(struct ieee80211_hdr_3addr));
-
-       dialogToken = frame_body[7];
-
-       if (rtw_action_public_decache(precv_frame, dialogToken) == _FAIL)
-               return _FAIL;
-
-#ifdef CONFIG_8723AU_P2P
-       del_timer_sync(&pwdinfo->reset_ch_sitesurvey);
-       if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) {
-               rtw_cfg80211_rx_p2p_action_public(padapter, pframe, len);
-       } else {
-               /*      Do nothing if the driver doesn't enable the P2P function. */
-               if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE))
-                       return _SUCCESS;
-
-               len -= sizeof(struct ieee80211_hdr_3addr);
-
-               switch (frame_body[ 6 ])/* OUI Subtype */
-               {
-                       case P2P_GO_NEGO_REQ:
-                               DBG_8723A("[%s] Got GO Nego Req Frame\n", __func__);
-                               memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info));
-
-                               if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ))
-                               {
-                                       rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo));
-                               }
-
-                               if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL))
-                               {
-                                       /*      Commented by Albert 20110526 */
-                                       /*      In this case, this means the previous nego fail doesn't be reset yet. */
-                                       del_timer_sync(&pwdinfo->restore_p2p_state_timer);
-                                       /*      Restore the previous p2p state */
-                                       rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo));
-                                       DBG_8723A("[%s] Restore the previous p2p state to %d\n", __func__, rtw_p2p_state(pwdinfo));
-                               }
-
-                               /*      Commented by Kurt 20110902 */
-                               /* Add if statement to avoid receiving duplicate prov disc req. such that pre_p2p_state would be covered. */
-                               if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING))
-                                       rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo));
-
-                               /*      Commented by Kurt 20120113 */
-                               /*      Get peer_dev_addr here if peer doesn't issue prov_disc frame. */
-                               if (is_zero_ether_addr(pwdinfo->rx_prov_disc_info.peerDevAddr))
-                                       ether_addr_copy(pwdinfo->rx_prov_disc_info.peerDevAddr, hdr->addr2);
-
-                               result = process_p2p_group_negotation_req23a(pwdinfo, frame_body, len);
-                               issue_p2p_GO_response(padapter, hdr->addr2,
-                                                     frame_body, len, result);
-
-                               /*      Commented by Albert 20110718 */
-                               /*      No matter negotiating or negotiation failure, the driver should set up the restore P2P state timer. */
-                               mod_timer(&pwdinfo->restore_p2p_state_timer,
-                                         jiffies + msecs_to_jiffies(5000));
-                               break;
-
-                       case P2P_GO_NEGO_RESP:
-                               DBG_8723A("[%s] Got GO Nego Resp Frame\n", __func__);
-
-                               if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING))
-                               {
-                                       /*      Commented by Albert 20110425 */
-                                       /*      The restore timer is enabled when issuing the nego request frame of rtw_p2p_connect function. */
-                                       del_timer_sync(&pwdinfo->restore_p2p_state_timer);
-                                       pwdinfo->nego_req_info.benable = false;
-                                       result = process_p2p_group_negotation_resp23a(pwdinfo, frame_body, len);
-                                       issue_p2p_GO_confirm(pwdinfo->padapter,
-                                                            hdr->addr2,
-                                                            result);
-                                       if (result == P2P_STATUS_SUCCESS) {
-                                               if (rtw_p2p_role(pwdinfo) ==
-                                                   P2P_ROLE_CLIENT) {
-                                                       pwdinfo->p2p_info.operation_ch[ 0 ] = pwdinfo->peer_operating_ch;
-                                                       pwdinfo->p2p_info.scan_op_ch_only = 1;
-                                                       mod_timer(&pwdinfo->reset_ch_sitesurvey2, jiffies + msecs_to_jiffies(P2P_RESET_SCAN_CH));
-                                               }
-                                       }
-
-                                       /*      Reset the dialog token for group negotiation frames. */
-                                       pwdinfo->negotiation_dialog_token = 1;
-
-                                       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL))
-                                       {
-                                               mod_timer(&pwdinfo->restore_p2p_state_timer, jiffies + msecs_to_jiffies(5000));
-                                       }
-                               } else {
-                                       DBG_8723A("[%s] Skipped GO Nego Resp Frame (p2p_state != P2P_STATE_GONEGO_ING)\n", __func__);
-                               }
-
-                               break;
-
-                       case P2P_GO_NEGO_CONF:
-
-                               DBG_8723A("[%s] Got GO Nego Confirm Frame\n", __func__);
-                               result = process_p2p_group_negotation_confirm23a(pwdinfo, frame_body, len);
-                               if (P2P_STATUS_SUCCESS == result)
-                               {
-                                       if (rtw_p2p_role(pwdinfo) == P2P_ROLE_CLIENT)
-                                       {
-                                               pwdinfo->p2p_info.operation_ch[ 0 ] = pwdinfo->peer_operating_ch;
-                                               pwdinfo->p2p_info.scan_op_ch_only = 1;
-                                               mod_timer(&pwdinfo->reset_ch_sitesurvey2, jiffies + msecs_to_jiffies(P2P_RESET_SCAN_CH));
-                                       }
-                               }
-                               break;
-
-                       case P2P_INVIT_REQ:
-                               /*      Added by Albert 2010/10/05 */
-                               /*      Received the P2P Invite Request frame. */
-
-                               DBG_8723A("[%s] Got invite request frame!\n", __func__);
-                               if ((p2p_ie = rtw_get_p2p_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &p2p_ielen)))
-                               {
-                                       /*      Parse the necessary information from the P2P Invitation Request frame. */
-                                       /*      For example: The MAC address of sending this P2P Invitation Request frame. */
-                                       u32     attr_contentlen = 0;
-                                       u8      status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE;
-                                       struct group_id_info group_id;
-                                       u8      invitation_flag = 0;
-
-                                       rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_INVITATION_FLAGS, &invitation_flag, &attr_contentlen);
-                                       if (attr_contentlen)
-                                       {
-
-                                               rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_BSSID, pwdinfo->p2p_peer_interface_addr, &attr_contentlen);
-                                               /*      Commented by Albert 20120510 */
-                                               /*      Copy to the pwdinfo->p2p_peer_interface_addr. */
-                                               /*      So that the WFD UI (or Sigma) can get the peer interface address by using the following command. */
-                                               /*      #> iwpriv wlan0 p2p_get peer_ifa */
-                                               /*      After having the peer interface address, the sigma can find the correct conf file for wpa_supplicant. */
-
-                                               if (attr_contentlen)
-                                               {
-                                                       DBG_8723A("[%s] GO's BSSID = %.2X %.2X %.2X %.2X %.2X %.2X\n", __func__,
-                                                                       pwdinfo->p2p_peer_interface_addr[0], pwdinfo->p2p_peer_interface_addr[1],
-                                                                       pwdinfo->p2p_peer_interface_addr[2], pwdinfo->p2p_peer_interface_addr[3],
-                                                                       pwdinfo->p2p_peer_interface_addr[4], pwdinfo->p2p_peer_interface_addr[5]);
-                                               }
-
-                                               if (invitation_flag & P2P_INVITATION_FLAGS_PERSISTENT)
-                                               {
-                                                       /*      Re-invoke the persistent group. */
-
-                                                       memset(&group_id, 0x00, sizeof(struct group_id_info));
-                                                       rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, (u8*) &group_id, &attr_contentlen);
-                                                       if (attr_contentlen) {
-                                                               if (ether_addr_equal(group_id.go_device_addr, myid(&padapter->eeprompriv))) {
-                                                                       /*      The p2p device sending this p2p invitation request wants this Wi-Fi device to be the persistent GO. */
-                                                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_GO);
-                                                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-                                                                       status_code = P2P_STATUS_SUCCESS;
-                                                               }
-                                                               else
-                                                               {
-                                                                       /*      The p2p device sending this p2p invitation request wants to be the persistent GO. */
-                                                                       if (is_matched_in_profilelist(pwdinfo->p2p_peer_interface_addr, &pwdinfo->profileinfo[ 0 ]))
-                                                                       {
-                                                                               u8 operatingch_info[5] = { 0x00 };
-                                                                               if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen))
-                                                                               {
-                                                                                       if (rtw_ch_set_search_ch23a(padapter->mlmeextpriv.channel_set, (u32)operatingch_info[4]))
-                                                                                       {
-                                                                                               /*      The operating channel is acceptable for this device. */
-                                                                                               pwdinfo->rx_invitereq_info.operation_ch[0]= operatingch_info[4];
-                                                                                               pwdinfo->rx_invitereq_info.scan_op_ch_only = 1;
-                                                                                               mod_timer(&pwdinfo->reset_ch_sitesurvey, jiffies + msecs_to_jiffies(P2P_RESET_SCAN_CH));
-                                                                                               rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_MATCH);
-                                                                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                                                                                               status_code = P2P_STATUS_SUCCESS;
-                                                                                               }
-                                                                                       else
-                                                                                       {
-                                                                                               /*      The operating channel isn't supported by this device. */
-                                                                                               rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH);
-                                                                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-                                                                                               status_code = P2P_STATUS_FAIL_NO_COMMON_CH;
-                                                                                               mod_timer(&pwdinfo->restore_p2p_state_timer, jiffies + msecs_to_jiffies(3000));
-                                                                                       }
-                                                                               }
-                                                                               else {
-                                                                                       /*      Commented by Albert 20121130 */
-                                                                                       /*      Intel will use the different P2P IE to store the operating channel information */
-                                                                                       /*      Workaround for Intel WiDi 3.5 */
-                                                                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_MATCH);
-                                                                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                                                                                       status_code = P2P_STATUS_SUCCESS;
-                                                                               }
-                                                                       }
-                                                                       else
-                                                                       {
-                                                                               rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH);
-
-                                                                               status_code = P2P_STATUS_FAIL_UNKNOWN_P2PGROUP;
-                                                                       }
-                                                               }
-                                                       }
-                                                       else
-                                                       {
-                                                               DBG_8723A("[%s] P2P Group ID Attribute NOT FOUND!\n", __func__);
-                                                               status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE;
-                                                       }
-                                               }
-                                               else
-                                               {
-                                                       /*      Received the invitation to join a P2P group. */
-
-                                                       memset(&group_id, 0x00, sizeof(struct group_id_info));
-                                                       rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, (u8*) &group_id, &attr_contentlen);
-                                                       if (attr_contentlen)
-                                                       {
-                                                               if (ether_addr_equal(group_id.go_device_addr, myid(&padapter->eeprompriv))) {
-                                                                       /*      In this case, the GO can't be myself. */
-                                                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH);
-                                                                       status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE;
-                                                               }
-                                                               else
-                                                               {
-                                                                       /*      The p2p device sending this p2p invitation request wants to join an existing P2P group */
-                                                                       /*      Commented by Albert 2012/06/28 */
-                                                                       /*      In this case, this Wi-Fi device should use the iwpriv command to get the peer device address. */
-                                                                       /*      The peer device address should be the destination address for the provisioning discovery request. */
-                                                                       /*      Then, this Wi-Fi device should use the iwpriv command to get the peer interface address. */
-                                                                       /*      The peer interface address should be the address for WPS mac address */
-                                                                       ether_addr_copy(pwdinfo->p2p_peer_device_addr, group_id.go_device_addr);
-                                                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                                                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_JOIN);
-                                                                       status_code = P2P_STATUS_SUCCESS;
-                                                               }
-                                                       }
-                                                       else
-                                                       {
-                                                               DBG_8723A("[%s] P2P Group ID Attribute NOT FOUND!\n", __func__);
-                                                               status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE;
-                                                       }
-                                               }
-                                       }
-                                       else
-                                       {
-                                               DBG_8723A("[%s] P2P Invitation Flags Attribute NOT FOUND!\n", __func__);
-                                               status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE;
-                                       }
-
-                                       DBG_8723A("[%s] status_code = %d\n", __func__, status_code);
-
-                                       pwdinfo->inviteresp_info.token = frame_body[ 7 ];
-                                       issue_p2p_invitation_response23a(padapter, hdr->addr2, pwdinfo->inviteresp_info.token, status_code);
-                               }
-                               break;
-
-                       case P2P_INVIT_RESP:
-                       {
-                               u8      attr_content = 0x00;
-                               u32     attr_contentlen = 0;
-
-                               DBG_8723A("[%s] Got invite response frame!\n", __func__);
-                               del_timer_sync(&pwdinfo->restore_p2p_state_timer);
-                               if ((p2p_ie = rtw_get_p2p_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &p2p_ielen)))
-                               {
-                                       rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen);
-
-                                       if (attr_contentlen == 1)
-                                       {
-                                               DBG_8723A("[%s] Status = %d\n", __func__, attr_content);
-                                               pwdinfo->invitereq_info.benable = false;
-
-                                               if (attr_content == P2P_STATUS_SUCCESS)
-                                               {
-                                                       if (ether_addr_equal(pwdinfo->invitereq_info.go_bssid, myid(&padapter->eeprompriv))) {
-                                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-                                                       }
-                                                       else
-                                                       {
-                                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                                                       }
-                                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_OK);
-                                               }
-                                               else
-                                               {
-                                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-                                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL);
-                                               }
-                                       }
-                                       else
-                                       {
-                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-                                               rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL);
-                                       }
-                               }
-                               else
-                               {
-                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL);
-                               }
-
-                               if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL)) {
-                                       mod_timer(&pwdinfo->restore_p2p_state_timer, jiffies + msecs_to_jiffies(5000));
-                               }
-                               break;
-                       }
-                       case P2P_DEVDISC_REQ:
-
-                               process_p2p_devdisc_req23a(pwdinfo, pframe, len);
-
-                               break;
-
-                       case P2P_DEVDISC_RESP:
-
-                               process_p2p_devdisc_resp23a(pwdinfo, pframe, len);
-
-                               break;
-
-                       case P2P_PROVISION_DISC_REQ:
-                               DBG_8723A("[%s] Got Provisioning Discovery Request Frame\n", __func__);
-                               process_p2p_provdisc_req23a(pwdinfo, pframe, len);
-                               ether_addr_copy(pwdinfo->rx_prov_disc_info.peerDevAddr, hdr->addr2);
-
-                               /* 20110902 Kurt */
-                               /* Add the following statement to avoid receiving duplicate prov disc req. such that pre_p2p_state would be covered. */
-                               if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ))
-                                       rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo));
-
-                               rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ);
-                               mod_timer(&pwdinfo->restore_p2p_state_timer,
-                                         jiffies + msecs_to_jiffies(P2P_PROVISION_TIMEOUT));
-                               break;
-
-                       case P2P_PROVISION_DISC_RESP:
-                               /*      Commented by Albert 20110707 */
-                               /*      Should we check the pwdinfo->tx_prov_disc_info.bsent flag here?? */
-                               DBG_8723A("[%s] Got Provisioning Discovery Response Frame\n", __func__);
-                               /*      Commented by Albert 20110426 */
-                               /*      The restore timer is enabled when issuing the provisioing request frame in rtw_p2p_prov_disc function. */
-                               del_timer_sync(&pwdinfo->restore_p2p_state_timer);
-                               rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_RSP);
-                               process_p2p_provdisc_resp23a(pwdinfo, pframe);
-                               mod_timer(&pwdinfo->restore_p2p_state_timer,
-                                         jiffies + msecs_to_jiffies(P2P_PROVISION_TIMEOUT));
-                               break;
-
-               }
-       }
-#endif /* CONFIG_8723AU_P2P */
-
-       return _SUCCESS;
-}
-
-static unsigned int on_action_public23a_vendor(struct recv_frame *precv_frame)
-{
-       unsigned int ret = _FAIL;
-       struct sk_buff *skb = precv_frame->pkt;
-       u8 *pframe = skb->data;
-       u8 *frame_body = pframe + sizeof(struct ieee80211_hdr_3addr);
-
-       if (!memcmp(frame_body + 2, P2P_OUI23A, 4)) {
-               ret = on_action_public23a_p2p(precv_frame);
-       }
-
-       return ret;
-}
-
-static unsigned int
-on_action_public23a_default(struct recv_frame *precv_frame, u8 action)
-{
-       unsigned int ret = _FAIL;
-       struct sk_buff *skb = precv_frame->pkt;
-       u8 *pframe = skb->data;
-       uint frame_len = skb->len;
-       u8 *frame_body = pframe + sizeof(struct ieee80211_hdr_3addr);
-       u8 token;
-       struct rtw_adapter *adapter = precv_frame->adapter;
-       int cnt = 0;
-       char msg[64];
-
-       token = frame_body[2];
-
-       if (rtw_action_public_decache(precv_frame, token) == _FAIL)
-               goto exit;
-
-       cnt += sprintf((msg+cnt), "%s(token:%u)",
-                      action_public_str23a(action), token);
-       rtw_cfg80211_rx_action(adapter, pframe, frame_len, msg);
-
-       ret = _SUCCESS;
-
-exit:
-       return ret;
-}
-
-unsigned int on_action_public23a(struct rtw_adapter *padapter,
-                                struct recv_frame *precv_frame)
-{
-       unsigned int ret = _FAIL;
-       struct sk_buff *skb = precv_frame->pkt;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       u8 *pframe = skb->data;
-       u8 *frame_body = pframe + sizeof(struct ieee80211_hdr_3addr);
-       u8 category, action;
-
-       /* check RA matches or not */
-       if (!ether_addr_equal(myid(&padapter->eeprompriv), hdr->addr1))
-               goto exit;
-
-       category = frame_body[0];
-       if (category != WLAN_CATEGORY_PUBLIC)
-               goto exit;
-
-       action = frame_body[1];
-       switch (action) {
-       case ACT_PUBLIC_VENDOR:
-               ret = on_action_public23a_vendor(precv_frame);
-               break;
-       default:
-               ret = on_action_public23a_default(precv_frame, action);
-               break;
-       }
-
-exit:
-       return ret;
-}
-
-unsigned int OnAction23a_ht(struct rtw_adapter *padapter,
-                           struct recv_frame *precv_frame)
-{
-       return _SUCCESS;
-}
-
-unsigned int OnAction23a_wmm(struct rtw_adapter *padapter,
-                            struct recv_frame *precv_frame)
+static int
+OnAction23a_ht(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
        return _SUCCESS;
-}
-
-unsigned int OnAction23a_p2p(struct rtw_adapter *padapter,
-                            struct recv_frame *precv_frame)
-{
-#ifdef CONFIG_8723AU_P2P
-       u8 *frame_body;
-       u8 category, OUI_Subtype, dialogToken = 0;
-       struct sk_buff *skb = precv_frame->pkt;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       u8 *pframe = skb->data;
-       uint len = skb->len;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       DBG_8723A("%s\n", __func__);
-
-       /* check RA matches or not */
-       if (!ether_addr_equal(myid(&padapter->eeprompriv), hdr->addr1))
-               return _SUCCESS;
-
-       frame_body = (unsigned char *)
-               (pframe + sizeof(struct ieee80211_hdr_3addr));
-
-       category = frame_body[0];
-       if (category != WLAN_CATEGORY_VENDOR_SPECIFIC)
-               return _SUCCESS;
-
-       if (cpu_to_be32(*((u32*) (frame_body + 1))) != P2POUI)
-               return _SUCCESS;
-
-       if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) {
-               rtw_cfg80211_rx_action_p2p(padapter, pframe, len);
-               return _SUCCESS;
-       } else {
-               len -= sizeof(struct ieee80211_hdr_3addr);
-               OUI_Subtype = frame_body[5];
-               dialogToken = frame_body[6];
-
-               switch (OUI_Subtype)
-               {
-               case P2P_NOTICE_OF_ABSENCE:
-                       break;
-
-               case P2P_PRESENCE_REQUEST:
-                       process_p2p_presence_req23a(pwdinfo, pframe, len);
-                       break;
-
-               case P2P_PRESENCE_RESPONSE:
-                       break;
-
-               case P2P_GO_DISC_REQUEST:
-                       break;
+}
 
-               default:
-                       break;
-               }
-       }
-#endif /* CONFIG_8723AU_P2P */
+static int
+OnAction23a_wmm(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
+{
+       return _SUCCESS;
+}
 
+static int
+OnAction23a_p2p(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
+{
        return _SUCCESS;
 }
 
-unsigned int OnAction23a(struct rtw_adapter *padapter,
-                        struct recv_frame *precv_frame)
+static int
+OnAction23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
        int i;
-       unsigned char   category;
+       u8 category;
        struct action_handler *ptable;
-       unsigned char   *frame_body;
        struct sk_buff *skb = precv_frame->pkt;
-       u8 *pframe = skb->data;
-
-       frame_body = (unsigned char *)
-               (pframe + sizeof(struct ieee80211_hdr_3addr));
+       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
 
-       category = frame_body[0];
+       category = mgmt->u.action.category;
 
        for (i = 0;
             i < sizeof(OnAction23a_tbl) / sizeof(struct action_handler); i++) {
@@ -5067,8 +2243,8 @@ unsigned int OnAction23a(struct rtw_adapter *padapter,
        return _SUCCESS;
 }
 
-unsigned int DoReserved23a(struct rtw_adapter *padapter,
-                       struct recv_frame *precv_frame)
+static int DoReserved23a(struct rtw_adapter *padapter,
+                        struct recv_frame *precv_frame)
 {
        return _SUCCESS;
 }
@@ -5259,7 +2435,7 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms)
        struct pkt_attrib *pattrib;
        unsigned char *pframe;
        struct ieee80211_hdr *pwlanhdr;
-       unsigned short *fctrl;
+       __le16 *fctrl;
        unsigned int rate_len;
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -5267,9 +2443,6 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms)
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct wlan_bssid_ex *cur_network = &pmlmeinfo->network;
        u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-#endif /* CONFIG_8723AU_P2P */
        u8 *wps_ie;
        u32 wps_ielen;
        u8 sr = 0;
@@ -5311,119 +2484,7 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms)
 
        if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) {
                /* DBG_8723A("ie len =%d\n", cur_network->IELength); */
-#ifdef CONFIG_8723AU_P2P
-               /*  for P2P : Primary Device Type & Device Name */
-               u32 insert_len = 0;
-               wps_ie = rtw_get_wps_ie23a(cur_network->IEs + _FIXED_IE_LENGTH_,
-                                          cur_network->IELength -
-                                          _FIXED_IE_LENGTH_, NULL, &wps_ielen);
-
-               if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && wps_ie &&
-                   wps_ielen > 0) {
-                       uint wps_offset, remainder_ielen;
-                       u8 *premainder_ie, *pframe_wscie;
-
-                       wps_offset = (uint)(wps_ie - cur_network->IEs);
-
-                       premainder_ie = wps_ie + wps_ielen;
-
-                       remainder_ielen = cur_network->IELength - wps_offset -
-                               wps_ielen;
-
-                       if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) {
-                               if (pmlmepriv->wps_beacon_ie &&
-                                   pmlmepriv->wps_beacon_ie_len>0) {
-                                       memcpy(pframe, cur_network->IEs,
-                                              wps_offset);
-                                       pframe += wps_offset;
-                                       pattrib->pktlen += wps_offset;
-
-                                       memcpy(pframe, pmlmepriv->wps_beacon_ie,
-                                              pmlmepriv->wps_beacon_ie_len);
-                                       pframe += pmlmepriv->wps_beacon_ie_len;
-                                       pattrib->pktlen +=
-                                               pmlmepriv->wps_beacon_ie_len;
-
-                                       /* copy remainder_ie to pframe */
-                                       memcpy(pframe, premainder_ie,
-                                              remainder_ielen);
-                                       pframe += remainder_ielen;
-                                       pattrib->pktlen += remainder_ielen;
-                               } else {
-                                       memcpy(pframe, cur_network->IEs,
-                                              cur_network->IELength);
-                                       pframe += cur_network->IELength;
-                                       pattrib->pktlen +=
-                                               cur_network->IELength;
-                               }
-                       } else {
-                               pframe_wscie = pframe + wps_offset;
-                               memcpy(pframe, cur_network->IEs,
-                                      wps_offset + wps_ielen);
-                               pframe += (wps_offset + wps_ielen);
-                               pattrib->pktlen += (wps_offset + wps_ielen);
-
-                               /* now pframe is end of wsc ie, insert Primary
-                                  Device Type & Device Name */
-                               /*      Primary Device Type */
-                               /*      Type: */
-                               *(u16*) (pframe + insert_len) =
-                                       cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE);
-                               insert_len += 2;
-
-                               /*      Length: */
-                               *(u16*) (pframe + insert_len) =
-                                       cpu_to_be16(0x0008);
-                               insert_len += 2;
-
-                               /*      Value: */
-                               /*      Category ID */
-                               *(u16*) (pframe + insert_len) =
-                                       cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA);
-                               insert_len += 2;
-
-                               /*      OUI */
-                               *(u32*) (pframe + insert_len) =
-                                       cpu_to_be32(WPSOUI);
-                               insert_len += 4;
-
-                               /*      Sub Category ID */
-                               *(u16*) (pframe + insert_len) =
-                                       cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER);
-                               insert_len += 2;
-
-                               /*      Device Name */
-                               /*      Type: */
-                               *(u16*) (pframe + insert_len) =
-                                       cpu_to_be16(WPS_ATTR_DEVICE_NAME);
-                               insert_len += 2;
-
-                               /*      Length: */
-                               *(u16*) (pframe + insert_len) =
-                                       cpu_to_be16(pwdinfo->device_name_len);
-                               insert_len += 2;
-
-                               /*      Value: */
-                               memcpy(pframe + insert_len,
-                                      pwdinfo->device_name,
-                                      pwdinfo->device_name_len);
-                               insert_len += pwdinfo->device_name_len;
-
-                               /* update wsc ie length */
-                               *(pframe_wscie+1) = (wps_ielen -2) + insert_len;
-
-                               /* pframe move to end */
-                               pframe+= insert_len;
-                               pattrib->pktlen += insert_len;
-
-                               /* copy remainder_ie to pframe */
-                               memcpy(pframe, premainder_ie, remainder_ielen);
-                               pframe += remainder_ielen;
-                               pattrib->pktlen += remainder_ielen;
-                       }
-               } else
-#endif /* CONFIG_8723AU_P2P */
-                       memcpy(pframe, cur_network->IEs, cur_network->IELength);
+               memcpy(pframe, cur_network->IEs, cur_network->IELength);
                len_diff = update_hidden_ssid(pframe + _BEACON_IE_OFFSET_,
                                              cur_network->IELength -
                                              _BEACON_IE_OFFSET_,
@@ -5447,36 +2508,6 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms)
                else
                        _clr_fwstate_(pmlmepriv, WIFI_UNDER_WPS);
 
-#ifdef CONFIG_8723AU_P2P
-               if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-                       u32 len;
-                       if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) {
-                               len = pmlmepriv->p2p_beacon_ie_len;
-                               if (pmlmepriv->p2p_beacon_ie && len > 0)
-                                       memcpy(pframe,
-                                              pmlmepriv->p2p_beacon_ie, len);
-                       } else
-                               len = build_beacon_p2p_ie23a(pwdinfo, pframe);
-
-                       pframe += len;
-                       pattrib->pktlen += len;
-
-                       if (true == pwdinfo->wfd_info->wfd_enable) {
-                               len = build_beacon_wfd_ie(pwdinfo, pframe);
-                       } else {
-                               len = 0;
-                               if (pmlmepriv->wfd_beacon_ie &&
-                                   pmlmepriv->wfd_beacon_ie_len>0) {
-                                       len = pmlmepriv->wfd_beacon_ie_len;
-                                       memcpy(pframe,
-                                              pmlmepriv->wfd_beacon_ie, len);
-                               }
-                       }
-                       pframe += len;
-                       pattrib->pktlen += len;
-               }
-#endif /* CONFIG_8723AU_P2P */
-
                goto _issue_bcn;
        }
 
@@ -5503,17 +2534,18 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms)
        pattrib->pktlen += 2;
 
        /*  SSID */
-       pframe = rtw_set_ie23a(pframe, _SSID_IE_, cur_network->Ssid.ssid_len,
+       pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID,
+                              cur_network->Ssid.ssid_len,
                               cur_network->Ssid.ssid, &pattrib->pktlen);
 
        /*  supported rates... */
        rate_len = rtw_get_rateset_len23a(cur_network->SupportedRates);
-       pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_,
+       pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES,
                               ((rate_len > 8)? 8: rate_len),
                               cur_network->SupportedRates, &pattrib->pktlen);
 
        /*  DS parameter set */
-       pframe = rtw_set_ie23a(pframe, _DSSET_IE_, 1, (unsigned char *)
+       pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)
                               &cur_network->Configuration.DSConfig,
                               &pattrib->pktlen);
 
@@ -5524,18 +2556,18 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms)
                /*  IBSS Parameter Set... */
                /* ATIMWindow = cur->Configuration.ATIMWindow; */
                ATIMWindow = 0;
-               pframe = rtw_set_ie23a(pframe, _IBSS_PARA_IE_, 2,
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_IBSS_PARAMS, 2,
                                       (unsigned char *)&ATIMWindow,
                                       &pattrib->pktlen);
 
                /* ERP IE */
-               pframe = rtw_set_ie23a(pframe, _ERPINFO_IE_, 1,
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_ERP_INFO, 1,
                                       &erpinfo, &pattrib->pktlen);
        }
 
        /*  EXTERNDED SUPPORTED RATE */
        if (rate_len > 8)
-               pframe = rtw_set_ie23a(pframe, _EXT_SUPPORTEDRATES_IE_,
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_EXT_SUPP_RATES,
                                       rate_len - 8,
                                       cur_network->SupportedRates + 8,
                                       &pattrib->pktlen);
@@ -5571,7 +2603,7 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da,
        struct pkt_attrib *pattrib;
        unsigned char *pframe;
        struct ieee80211_hdr *pwlanhdr;
-       unsigned short *fctrl;
+       __le16 *fctrl;
        unsigned char *mac, *bssid;
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
 #ifdef CONFIG_8723AU_AP_MODE
@@ -5582,22 +2614,17 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da,
        int ssid_ielen_diff;
        u8 buf[MAX_IE_SZ];
        u8 *ies;
-#endif
-#if defined(CONFIG_8723AU_AP_MODE) || defined(CONFIG_8723AU_P2P)
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 #endif
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct wlan_bssid_ex *cur_network = &pmlmeinfo->network;
        unsigned int rate_len;
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-#endif /* CONFIG_8723AU_P2P */
 
        /* DBG_8723A("%s\n", __func__); */
 
-       if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL)
-       {
+       pmgntframe = alloc_mgtxmitframe23a(pxmitpriv);
+       if (!pmgntframe) {
                DBG_8723A("%s, alloc mgnt frame fail\n", __func__);
                return;
        }
@@ -5608,7 +2635,7 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da,
 
        memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
 
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
+       pframe = (u8 *)pmgntframe->buf_addr + TXDESC_OFFSET;
        pwlanhdr = (struct ieee80211_hdr *)pframe;
 
        mac = myid(&padapter->eeprompriv);
@@ -5640,8 +2667,7 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da,
                                            &wps_ielen);
 
                /* inerset & update wps_probe_resp_ie */
-               if ((pmlmepriv->wps_probe_resp_ie != NULL) && pwps_ie &&
-                   (wps_ielen > 0)) {
+               if (pmlmepriv->wps_probe_resp_ie && pwps_ie && wps_ielen > 0) {
                        uint wps_offset, remainder_ielen;
                        u8 *premainder_ie;
 
@@ -5658,14 +2684,14 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da,
 
                        /* to get ie data len */
                        wps_ielen = (uint)pmlmepriv->wps_probe_resp_ie[1];
-                       if ((wps_offset+wps_ielen+2)<= MAX_IE_SZ) {
+                       if (wps_offset + wps_ielen + 2 <= MAX_IE_SZ) {
                                memcpy(pframe, pmlmepriv->wps_probe_resp_ie,
                                       wps_ielen+2);
                                pframe += wps_ielen+2;
                                pattrib->pktlen += wps_ielen+2;
                        }
 
-                       if ((wps_offset+wps_ielen+2+remainder_ielen) <=
+                       if (wps_offset + wps_ielen + 2 + remainder_ielen <=
                            MAX_IE_SZ) {
                                memcpy(pframe, premainder_ie, remainder_ielen);
                                pframe += remainder_ielen;
@@ -5681,9 +2707,9 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da,
                ies = pmgntframe->buf_addr + TXDESC_OFFSET +
                        sizeof(struct ieee80211_hdr_3addr);
 
-               ssid_ie = rtw_get_ie23a(ies+_FIXED_IE_LENGTH_, _SSID_IE_,
+               ssid_ie = rtw_get_ie23a(ies + _FIXED_IE_LENGTH_, WLAN_EID_SSID,
                                        &ssid_ielen,
-                                       (pframe-ies)-_FIXED_IE_LENGTH_);
+                                       pframe - ies - _FIXED_IE_LENGTH_);
 
                ssid_ielen_diff = cur_network->Ssid.ssid_len - ssid_ielen;
 
@@ -5691,20 +2717,19 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da,
                        uint remainder_ielen;
                        u8 *remainder_ie;
                        remainder_ie = ssid_ie + 2;
-                       remainder_ielen = (pframe-remainder_ie);
+                       remainder_ielen = pframe - remainder_ie;
 
                        DBG_8723A_LEVEL(_drv_warning_, FUNC_ADPT_FMT
                                        " remainder_ielen > MAX_IE_SZ\n",
                                        FUNC_ADPT_ARG(padapter));
-                       if (remainder_ielen > MAX_IE_SZ) {
+                       if (remainder_ielen > MAX_IE_SZ)
                                remainder_ielen = MAX_IE_SZ;
-                       }
 
                        memcpy(buf, remainder_ie, remainder_ielen);
-                       memcpy(remainder_ie+ssid_ielen_diff, buf,
+                       memcpy(remainder_ie + ssid_ielen_diff, buf,
                               remainder_ielen);
-                       *(ssid_ie+1) = cur_network->Ssid.ssid_len;
-                       memcpy(ssid_ie+2, cur_network->Ssid.ssid,
+                       *(ssid_ie + 1) = cur_network->Ssid.ssid_len;
+                       memcpy(ssid_ie + 2, cur_network->Ssid.ssid,
                               cur_network->Ssid.ssid_len);
 
                        pframe += ssid_ielen_diff;
@@ -5737,40 +2762,42 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da,
                /* below for ad-hoc mode */
 
                /*  SSID */
-               pframe = rtw_set_ie23a(pframe, _SSID_IE_,
-                                   cur_network->Ssid.ssid_len,
-                                   cur_network->Ssid.ssid, &pattrib->pktlen);
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID,
+                                      cur_network->Ssid.ssid_len,
+                                      cur_network->Ssid.ssid,
+                                      &pattrib->pktlen);
 
                /*  supported rates... */
                rate_len = rtw_get_rateset_len23a(cur_network->SupportedRates);
-               pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_,
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES,
                                       ((rate_len > 8)? 8: rate_len),
                                       cur_network->SupportedRates,
                                       &pattrib->pktlen);
 
                /*  DS parameter set */
-               pframe = rtw_set_ie23a(pframe, _DSSET_IE_, 1, (unsigned char *)
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1,
+                                      (unsigned char *)
                                       &cur_network->Configuration.DSConfig,
                                       &pattrib->pktlen);
 
-               if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) {
+               if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) {
                        u8 erpinfo = 0;
                        u32 ATIMWindow;
                        /*  IBSS Parameter Set... */
                        /* ATIMWindow = cur->Configuration.ATIMWindow; */
                        ATIMWindow = 0;
-                       pframe = rtw_set_ie23a(pframe, _IBSS_PARA_IE_, 2,
+                       pframe = rtw_set_ie23a(pframe, WLAN_EID_IBSS_PARAMS, 2,
                                               (unsigned char *)&ATIMWindow,
                                               &pattrib->pktlen);
 
                        /* ERP IE */
-                       pframe = rtw_set_ie23a(pframe, _ERPINFO_IE_, 1,
+                       pframe = rtw_set_ie23a(pframe, WLAN_EID_ERP_INFO, 1,
                                               &erpinfo, &pattrib->pktlen);
                }
 
                /*  EXTERNDED SUPPORTED RATE */
                if (rate_len > 8)
-                       pframe = rtw_set_ie23a(pframe, _EXT_SUPPORTEDRATES_IE_,
+                       pframe = rtw_set_ie23a(pframe, WLAN_EID_EXT_SUPP_RATES,
                                               rate_len - 8,
                                               cur_network->SupportedRates + 8,
                                               &pattrib->pktlen);
@@ -5778,38 +2805,6 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da,
                /* todo:HT for adhoc */
        }
 
-#ifdef CONFIG_8723AU_P2P
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && is_valid_p2p_probereq) {
-               u32 len;
-               if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) {
-                       /* if pwdinfo->role == P2P_ROLE_DEVICE will call
-                          issue_probersp23a_p2p23a() */
-                       len = pmlmepriv->p2p_go_probe_resp_ie_len;
-                       if (pmlmepriv->p2p_go_probe_resp_ie && len>0)
-                               memcpy(pframe, pmlmepriv->p2p_go_probe_resp_ie,
-                                      len);
-               } else
-                       len = build_probe_resp_p2p_ie23a(pwdinfo, pframe);
-
-               pframe += len;
-               pattrib->pktlen += len;
-
-               if (true == pwdinfo->wfd_info->wfd_enable) {
-                       len = build_probe_resp_wfd_ie(pwdinfo, pframe, 0);
-               } else {
-                       len = 0;
-                       if (pmlmepriv->wfd_probe_resp_ie &&
-                           pmlmepriv->wfd_probe_resp_ie_len > 0) {
-                               len = pmlmepriv->wfd_probe_resp_ie_len;
-                               memcpy(pframe, pmlmepriv->wfd_probe_resp_ie,
-                                      len);
-                       }
-               }
-               pframe += len;
-               pattrib->pktlen += len;
-       }
-#endif /* CONFIG_8723AU_P2P */
-
        pattrib->last_txcmdsz = pattrib->pktlen;
 
        dump_mgntframe23a(padapter, pmgntframe);
@@ -5825,7 +2820,7 @@ static int _issue_probereq23a(struct rtw_adapter *padapter,
        struct pkt_attrib               *pattrib;
        unsigned char                   *pframe;
        struct ieee80211_hdr    *pwlanhdr;
-       unsigned short          *fctrl;
+       __le16          *fctrl;
        unsigned char                   *mac;
        unsigned char                   bssrate[NumRates];
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
@@ -5851,7 +2846,7 @@ static int _issue_probereq23a(struct rtw_adapter *padapter,
 
        mac = myid(&padapter->eeprompriv);
 
-       fctrl = &pwlanhdr->frame_control;
+               fctrl = &pwlanhdr->frame_control;
        *fctrl = 0;
 
        if (da) {
@@ -5874,22 +2869,22 @@ static int _issue_probereq23a(struct rtw_adapter *padapter,
        pattrib->pktlen = sizeof (struct ieee80211_hdr_3addr);
 
        if (pssid)
-               pframe = rtw_set_ie23a(pframe, _SSID_IE_, pssid->ssid_len,
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, pssid->ssid_len,
                                       pssid->ssid, &pattrib->pktlen);
        else
-               pframe = rtw_set_ie23a(pframe, _SSID_IE_, 0, NULL,
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, 0, NULL,
                                       &pattrib->pktlen);
 
        get_rate_set23a(padapter, bssrate, &bssrate_len);
 
        if (bssrate_len > 8) {
-               pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, 8,
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, 8,
                                       bssrate, &pattrib->pktlen);
-               pframe = rtw_set_ie23a(pframe, _EXT_SUPPORTEDRATES_IE_,
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_EXT_SUPP_RATES,
                                       (bssrate_len - 8), (bssrate + 8),
                                       &pattrib->pktlen);
        } else {
-               pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_,
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES,
                                       bssrate_len, bssrate, &pattrib->pktlen);
        }
 
@@ -5976,7 +2971,7 @@ void issue_auth23a(struct rtw_adapter *padapter, struct sta_info *psta,
        struct pkt_attrib *pattrib;
        unsigned char *pframe;
        struct ieee80211_hdr *pwlanhdr;
-       unsigned short *fctrl;
+       __le16 *fctrl;
        unsigned int val32;
        unsigned short val16;
        int use_shared_key = 0;
@@ -6045,7 +3040,7 @@ void issue_auth23a(struct rtw_adapter *padapter, struct sta_info *psta,
                /*  added challenging text... */
                if ((psta->auth_seq == 2) &&
                    (psta->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1))
-                       pframe = rtw_set_ie23a(pframe, _CHLGETXT_IE_, 128,
+                       pframe = rtw_set_ie23a(pframe, WLAN_EID_CHALLENGE, 128,
                                               psta->chg_txt, &pattrib->pktlen);
 #endif
        } else {
@@ -6104,7 +3099,7 @@ void issue_auth23a(struct rtw_adapter *padapter, struct sta_info *psta,
                if ((pmlmeinfo->auth_seq == 3) &&
                    (pmlmeinfo->state & WIFI_FW_AUTH_STATE) &&
                    (use_shared_key == 1)) {
-                       pframe = rtw_set_ie23a(pframe, _CHLGETXT_IE_, 128,
+                       pframe = rtw_set_ie23a(pframe, WLAN_EID_CHALLENGE, 128,
                                               pmlmeinfo->chg_txt,
                                               &pattrib->pktlen);
 
@@ -6136,22 +3131,20 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status,
        struct xmit_frame *pmgntframe;
        struct ieee80211_hdr *pwlanhdr;
        struct pkt_attrib *pattrib;
-       unsigned char *pbuf, *pframe;
+       unsigned char *pframe;
        unsigned short val;
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network;
+       const u8 *p;
        u8 *ie = pnetwork->IEs;
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       u32 wfdielen = 0;
-#endif /* CONFIG_8723AU_P2P */
 
        DBG_8723A("%s\n", __func__);
 
-       if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL)
+       pmgntframe = alloc_mgtxmitframe23a(pxmitpriv);
+       if (!pmgntframe)
                return;
 
        /* update attribute */
@@ -6171,7 +3164,7 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status,
 
        SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
        pmlmeext->mgnt_seq++;
-       if ((pkt_type == WIFI_ASSOCRSP) || (pkt_type == WIFI_REASSOCRSP))
+       if (pkt_type == WIFI_ASSOCRSP || pkt_type == WIFI_REASSOCRSP)
                SetFrameSubType(pwlanhdr, pkt_type);
        else
                return;
@@ -6196,69 +3189,70 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status,
                                     &pattrib->pktlen);
 
        if (pstat->bssratelen <= 8) {
-               pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_,
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES,
                                       pstat->bssratelen, pstat->bssrateset,
                                       &pattrib->pktlen);
        } else {
-               pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, 8,
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, 8,
                                       pstat->bssrateset, &pattrib->pktlen);
-               pframe = rtw_set_ie23a(pframe, _EXT_SUPPORTEDRATES_IE_,
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_EXT_SUPP_RATES,
                                       pstat->bssratelen - 8,
                                       pstat->bssrateset + 8, &pattrib->pktlen);
        }
 
-       if ((pstat->flags & WLAN_STA_HT) && (pmlmepriv->htpriv.ht_option)) {
-               uint ie_len = 0;
-
+       if (pstat->flags & WLAN_STA_HT && pmlmepriv->htpriv.ht_option) {
                /* FILL HT CAP INFO IE */
                /* p = hostapd_eid_ht_capabilities_info(hapd, p); */
-               pbuf = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_,
-                                    _HT_CAPABILITY_IE_, &ie_len,
-                                    pnetwork->IELength - _BEACON_IE_OFFSET_);
-               if (pbuf && ie_len>0) {
-                       memcpy(pframe, pbuf, ie_len + 2);
-                       pframe += (ie_len + 2);
-                       pattrib->pktlen += (ie_len + 2);
+               p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY,
+                                    ie + _BEACON_IE_OFFSET_,
+                                    pnetwork->IELength -_BEACON_IE_OFFSET_);
+               if (p && p[1]) {
+                       memcpy(pframe, p, p[1] + 2);
+                       pframe += (p[1] + 2);
+                       pattrib->pktlen += (p[1] + 2);
                }
 
                /* FILL HT ADD INFO IE */
                /* p = hostapd_eid_ht_operation(hapd, p); */
-               pbuf = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_,
-                                    &ie_len,
+               p = cfg80211_find_ie(WLAN_EID_HT_OPERATION,
+                                    ie + _BEACON_IE_OFFSET_,
                                     pnetwork->IELength - _BEACON_IE_OFFSET_);
-               if (pbuf && ie_len > 0) {
-                       memcpy(pframe, pbuf, ie_len + 2);
-                       pframe += (ie_len + 2);
-                       pattrib->pktlen += (ie_len + 2);
+               if (p && p[1] > 0) {
+                       memcpy(pframe, p, p[1] + 2);
+                       pframe += (p[1] + 2);
+                       pattrib->pktlen += (p[1] + 2);
                }
        }
 
        /* FILL WMM IE */
-       if ((pstat->flags & WLAN_STA_WME) && pmlmepriv->qospriv.qos_option) {
-               uint ie_len = 0;
+       if (pstat->flags & WLAN_STA_WME && pmlmepriv->qospriv.qos_option) {
                unsigned char WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02,
                                               0x01, 0x01};
-
-               for (pbuf = ie + _BEACON_IE_OFFSET_; ; pbuf += (ie_len + 2)) {
-                       pbuf = rtw_get_ie23a(pbuf, _VENDOR_SPECIFIC_IE_,
-                                            &ie_len, (pnetwork->IELength -
-                                                      _BEACON_IE_OFFSET_ -
-                                                      (ie_len + 2)));
-                       if (pbuf && !memcmp(pbuf + 2, WMM_PARA_IE, 6)) {
-                               memcpy(pframe, pbuf, ie_len + 2);
+               int ie_len = 0;
+
+               for (p = ie + _BEACON_IE_OFFSET_; ; p += (ie_len + 2)) {
+                       p = cfg80211_find_ie(WLAN_EID_VENDOR_SPECIFIC, p,
+                                            pnetwork->IELength -
+                                            _BEACON_IE_OFFSET_ - (ie_len + 2));
+                       if (p)
+                               ie_len = p[1];
+                       else
+                               ie_len = 0;
+                       if (p && !memcmp(p + 2, WMM_PARA_IE, 6)) {
+                               memcpy(pframe, p, ie_len + 2);
                                pframe += (ie_len + 2);
                                pattrib->pktlen += (ie_len + 2);
 
                                break;
                        }
 
-                       if ((!pbuf) || (ie_len == 0))
+                       if (!p || ie_len == 0)
                                break;
                }
        }
 
        if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) {
-               pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, 6,
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, 6,
                                       REALTEK_96B_IE23A, &pattrib->pktlen);
        }
 
@@ -6272,15 +3266,6 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status,
                pattrib->pktlen += pmlmepriv->wps_assoc_resp_ie_len;
        }
 
-#ifdef CONFIG_8723AU_P2P
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) &&
-           pwdinfo->wfd_info->wfd_enable) {
-               wfdielen = build_assoc_resp_wfd_ie(pwdinfo, pframe);
-               pframe += wfdielen;
-               pattrib->pktlen += wfdielen;
-       }
-#endif /* CONFIG_8723AU_P2P */
-
        pattrib->last_txcmdsz = pattrib->pktlen;
 
        dump_mgntframe23a(padapter, pmgntframe);
@@ -6292,11 +3277,11 @@ void issue_assocreq23a(struct rtw_adapter *padapter)
        int ret = _FAIL;
        struct xmit_frame *pmgntframe;
        struct pkt_attrib *pattrib;
-       unsigned char *pframe, *p;
+       unsigned char *pframe;
+       const u8 *p;
        struct ieee80211_hdr *pwlanhdr;
-       unsigned short *fctrl;
-       unsigned short val16;
-       unsigned int i, j, ie_len, index = 0;
+       __le16 *fctrl;
+       unsigned int i, j, index = 0;
        unsigned char rf_type, bssrate[NumRates], sta_bssrate[NumRates];
        struct ndis_802_11_var_ies *pIE;
        struct registry_priv *pregpriv = &padapter->registrypriv;
@@ -6304,15 +3289,11 @@ void issue_assocreq23a(struct rtw_adapter *padapter)
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
-       int bssrate_len = 0, sta_bssrate_len = 0;
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       u8 p2pie[255] = { 0x00 };
-       u16 p2pielen = 0;
-       u32 wfdielen = 0;
-#endif /* CONFIG_8723AU_P2P */
+       int bssrate_len = 0, sta_bssrate_len = 0, pie_len;
+       u8 * pie;
 
-       if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL)
+       pmgntframe = alloc_mgtxmitframe23a(pxmitpriv);
+       if (!pmgntframe)
                goto exit;
 
        /* update attribute */
@@ -6321,7 +3302,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter)
 
        memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
 
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
+       pframe = (u8 *)pmgntframe->buf_addr + TXDESC_OFFSET;
        pwlanhdr = (struct ieee80211_hdr *)pframe;
 
        fctrl = &pwlanhdr->frame_control;
@@ -6338,21 +3319,20 @@ void issue_assocreq23a(struct rtw_adapter *padapter)
        pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
 
        /* caps */
-       memcpy(pframe, rtw_get_capability23a_from_ie(pmlmeinfo->network.IEs),
-              2);
+       memcpy(pframe,
+              rtw_get_capability23a_from_ie(pmlmeinfo->network.IEs), 2);
 
        pframe += 2;
        pattrib->pktlen += 2;
 
        /* listen interval */
        /* todo: listen interval for power saving */
-       val16 = cpu_to_le16(3);
-       memcpy(pframe, (unsigned char *)&val16, 2);
+       put_unaligned_le16(3, pframe);
        pframe += 2;
        pattrib->pktlen += 2;
 
        /* SSID */
-       pframe = rtw_set_ie23a(pframe, _SSID_IE_,
+       pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID,
                               pmlmeinfo->network.Ssid.ssid_len,
                               pmlmeinfo->network.Ssid.ssid, &pattrib->pktlen);
 
@@ -6387,7 +3367,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter)
                             Handlink WSG-4000 AP */
                        if ((pmlmeinfo->network.SupportedRates[i] |
                             IEEE80211_BASIC_RATE_MASK) ==
-                           (sta_bssrate[j]|IEEE80211_BASIC_RATE_MASK)) {
+                           (sta_bssrate[j] | IEEE80211_BASIC_RATE_MASK)) {
                                /* DBG_8723A("match i = %d, j =%d\n", i, j); */
                                break;
                        }
@@ -6414,33 +3394,31 @@ void issue_assocreq23a(struct rtw_adapter *padapter)
        }
 
        if (bssrate_len > 8) {
-               pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, 8,
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, 8,
                                       bssrate, &pattrib->pktlen);
-               pframe = rtw_set_ie23a(pframe, _EXT_SUPPORTEDRATES_IE_,
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_EXT_SUPP_RATES,
                                       (bssrate_len - 8), (bssrate + 8),
                                       &pattrib->pktlen);
        } else
-               pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_,
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES,
                                       bssrate_len, bssrate, &pattrib->pktlen);
 
        /* RSN */
-       p = rtw_get_ie23a((pmlmeinfo->network.IEs +
-                          sizeof(struct ndis_802_11_fixed_ies)), _RSN_IE_2_,
-                         &ie_len, (pmlmeinfo->network.IELength -
-                                   sizeof(struct ndis_802_11_fixed_ies)));
+       pie = pmlmeinfo->network.IEs + sizeof(struct ndis_802_11_fixed_ies);
+       pie_len = pmlmeinfo->network.IELength -
+               sizeof(struct ndis_802_11_fixed_ies);
+
+       p = cfg80211_find_ie(WLAN_EID_RSN, pie, pie_len);
        if (p)
-               pframe = rtw_set_ie23a(pframe, _RSN_IE_2_, ie_len, (p + 2),
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_RSN, p[1], p + 2,
                                       &pattrib->pktlen);
 
        /* HT caps */
        if (padapter->mlmepriv.htpriv.ht_option == true) {
-               p = rtw_get_ie23a((pmlmeinfo->network.IEs +
-                                  sizeof(struct ndis_802_11_fixed_ies)),
-                                 _HT_CAPABILITY_IE_, &ie_len,
-                                 (pmlmeinfo->network.IELength -
-                                  sizeof(struct ndis_802_11_fixed_ies)));
-               if ((p != NULL) && (!(is_ap_in_tkip23a(padapter)))) {
-                       memcpy(&pmlmeinfo->HT_caps, (p + 2),
+               p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, pie, pie_len);
+
+               if (p && !is_ap_in_tkip23a(padapter)) {
+                       memcpy(&pmlmeinfo->HT_caps, p + 2,
                               sizeof(struct HT_caps_element));
 
                        /* to disable 40M Hz support while gd_bw_40MHz_en = 0 */
@@ -6454,15 +3432,13 @@ void issue_assocreq23a(struct rtw_adapter *padapter)
                        pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |=
                                0x000c;
 
-                       rtw23a_hal_get_hwreg(padapter, HW_VAR_RF_TYPE,
-                                            (u8 *)(&rf_type));
+                       rf_type = rtl8723a_get_rf_type(padapter);
                        /* switch (pregpriv->rf_config) */
-                       switch (rf_type)
-                       {
+                       switch (rf_type) {
                        case RF_1T1R:
-
+                               /* RX STBC One spatial stream */
                                if (pregpriv->rx_stbc)
-                                       pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x0100);/* RX STBC One spatial stream */
+                                       pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x0100);
 
                                memcpy(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_rate_1R23A, 16);
                                break;
@@ -6470,18 +3446,17 @@ void issue_assocreq23a(struct rtw_adapter *padapter)
                        case RF_2T2R:
                        case RF_1T2R:
                        default:
-
                                /* enable for 2.4/5 GHz */
-                               if ((pregpriv->rx_stbc == 0x3) ||
-                                   ((pmlmeext->cur_wireless_mode &
-                                     WIRELESS_11_24N) &&
+                               if (pregpriv->rx_stbc == 0x3 ||
+                                   (pmlmeext->cur_wireless_mode &
+                                    WIRELESS_11_24N &&
                                     /* enable for 2.4GHz */
-                                    (pregpriv->rx_stbc == 0x1)) ||
-                                   ((pmlmeext->cur_wireless_mode &
-                                     WIRELESS_11_5N) &&
-                                    (pregpriv->rx_stbc == 0x2)) ||
+                                    pregpriv->rx_stbc == 0x1) ||
+                                   (pmlmeext->cur_wireless_mode &
+                                    WIRELESS_11_5N &&
+                                    pregpriv->rx_stbc == 0x2) ||
                                    /* enable for 5GHz */
-                                   (pregpriv->wifi_spec == 1)) {
+                                   pregpriv->wifi_spec == 1) {
                                        DBG_8723A("declare supporting RX "
                                                  "STBC\n");
                                        pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x0200);/* RX STBC two spatial stream */
@@ -6500,9 +3475,8 @@ void issue_assocreq23a(struct rtw_adapter *padapter)
                        }
 #endif
 
-                       pframe = rtw_set_ie23a(pframe, _HT_CAPABILITY_IE_,
-                                              ie_len,
-                                              (u8 *)&pmlmeinfo->HT_caps,
+                       pframe = rtw_set_ie23a(pframe, WLAN_EID_HT_CAPABILITY,
+                                              p[1], (u8 *)&pmlmeinfo->HT_caps,
                                               &pattrib->pktlen);
                }
        }
@@ -6515,8 +3489,8 @@ void issue_assocreq23a(struct rtw_adapter *padapter)
 
                switch (pIE->ElementID)
                {
-               case _VENDOR_SPECIFIC_IE_:
-                       if (!memcmp(pIE->data, RTW_WPA_OUI23A, 4) ||
+               case WLAN_EID_VENDOR_SPECIFIC:
+                       if (!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4) ||
                            !memcmp(pIE->data, WMM_OUI23A, 4) ||
                            !memcmp(pIE->data, WPS_OUI23A, 4)) {
                                if (!padapter->registrypriv.wifi_spec) {
@@ -6528,7 +3502,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter)
                                                pIE->Length = 14;
                                }
                                pframe = rtw_set_ie23a(pframe,
-                                                      _VENDOR_SPECIFIC_IE_,
+                                                      WLAN_EID_VENDOR_SPECIFIC,
                                                       pIE->Length, pIE->data,
                                                       &pattrib->pktlen);
                        }
@@ -6538,198 +3512,13 @@ void issue_assocreq23a(struct rtw_adapter *padapter)
                        break;
                }
 
-               i += (pIE->Length + 2);
+               i += pIE->Length + 2;
        }
 
        if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK)
-               pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, 6,
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, 6,
                                       REALTEK_96B_IE23A, &pattrib->pktlen);
 
-#ifdef CONFIG_8723AU_P2P
-
-       if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) {
-               if (pmlmepriv->p2p_assoc_req_ie &&
-                   pmlmepriv->p2p_assoc_req_ie_len>0) {
-                       memcpy(pframe, pmlmepriv->p2p_assoc_req_ie,
-                              pmlmepriv->p2p_assoc_req_ie_len);
-                       pframe += pmlmepriv->p2p_assoc_req_ie_len;
-                       pattrib->pktlen += pmlmepriv->p2p_assoc_req_ie_len;
-               }
-       } else {
-               if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) &&
-                   !rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE)) {
-                       /*      Should add the P2P IE in the association
-                               request frame. */
-                       /*      P2P OUI */
-
-                       p2pielen = 0;
-                       p2pie[p2pielen++] = 0x50;
-                       p2pie[p2pielen++] = 0x6F;
-                       p2pie[p2pielen++] = 0x9A;
-                       p2pie[p2pielen++] = 0x09;       /*      WFA P2P v1.0 */
-
-                       /*      Commented by Albert 20101109 */
-                       /*      According to the P2P Specification, the
-                               association request frame should contain
-                               3 P2P attributes */
-                       /*      1. P2P Capability */
-                       /*      2. Extended Listen Timing */
-                       /*      3. Device Info */
-                       /*      Commented by Albert 20110516 */
-                       /*      4. P2P Interface */
-
-                       /*      P2P Capability */
-                       /*      Type: */
-                       p2pie[p2pielen++] = P2P_ATTR_CAPABILITY;
-
-                       /*      Length: */
-                       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002);
-                       p2pielen += 2;
-
-                       /*      Value: */
-                       /*      Device Capability Bitmap, 1 byte */
-                       p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT;
-
-                       /*      Group Capability Bitmap, 1 byte */
-                       if (pwdinfo->persistent_supported)
-                               p2pie[p2pielen++] =
-                                       P2P_GRPCAP_PERSISTENT_GROUP |
-                                       DMP_P2P_GRPCAP_SUPPORT;
-                       else
-                               p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT;
-
-                       /*      Extended Listen Timing */
-                       /*      Type: */
-                       p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING;
-
-                       /*      Length: */
-                       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0004);
-                       p2pielen += 2;
-
-                       /*      Value: */
-                       /*      Availability Period */
-                       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF);
-                       p2pielen += 2;
-
-                       /*      Availability Interval */
-                       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF);
-                       p2pielen += 2;
-
-                       /*      Device Info */
-                       /*      Type: */
-                       p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO;
-
-                       /*      Length: */
-                       /*      21 -> P2P Device Address (6bytes) + Config
-                               Methods (2bytes) + Primary Device
-                               Type (8bytes) */
-                       /*      + NumofSecondDevType (1byte) + WPS Device
-                               Name ID field (2bytes) + WPS Device Name
-                               Len field (2bytes) */
-                       *(u16*) (p2pie + p2pielen) =
-                               cpu_to_le16(21 + pwdinfo->device_name_len);
-                       p2pielen += 2;
-
-                       /*      Value: */
-                       /*      P2P Device Address */
-                       memcpy(p2pie + p2pielen,
-                              myid(&padapter->eeprompriv), ETH_ALEN);
-                       p2pielen += ETH_ALEN;
-
-                       /*      Config Method */
-                       /*      This field should be big endian.
-                               Noted by P2P specification. */
-                       if ((pwdinfo->ui_got_wps_info ==
-                            P2P_GOT_WPSINFO_PEER_DISPLAY_PIN) ||
-                           (pwdinfo->ui_got_wps_info ==
-                            P2P_GOT_WPSINFO_SELF_DISPLAY_PIN))
-                               *(u16*) (p2pie + p2pielen) =
-                                       cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY);
-                       else
-                               *(u16*) (p2pie + p2pielen) =
-                                       cpu_to_be16(WPS_CONFIG_METHOD_PBC);
-
-                       p2pielen += 2;
-
-                       /*      Primary Device Type */
-                       /*      Category ID */
-                       *(u16*) (p2pie + p2pielen) =
-                               cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA);
-                       p2pielen += 2;
-
-                       /*      OUI */
-                       *(u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI);
-                       p2pielen += 4;
-
-                       /*      Sub Category ID */
-                       *(u16*) (p2pie + p2pielen) =
-                               cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER);
-                       p2pielen += 2;
-
-                       /*      Number of Secondary Device Types */
-                       /*      No Secondary Device Type List */
-                       p2pie[p2pielen++] = 0x00;
-
-                       /*      Device Name */
-                       /*      Type: */
-                       *(u16*) (p2pie + p2pielen) =
-                               cpu_to_be16(WPS_ATTR_DEVICE_NAME);
-                       p2pielen += 2;
-
-                       /*      Length: */
-                       *(u16*) (p2pie + p2pielen) =
-                               cpu_to_be16(pwdinfo->device_name_len);
-                       p2pielen += 2;
-
-                       /*      Value: */
-                       memcpy(p2pie + p2pielen, pwdinfo->device_name,
-                              pwdinfo->device_name_len);
-                       p2pielen += pwdinfo->device_name_len;
-
-                       /*      P2P Interface */
-                       /*      Type: */
-                       p2pie[p2pielen++] = P2P_ATTR_INTERFACE;
-
-                       /*      Length: */
-                       *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x000D);
-                       p2pielen += 2;
-
-                       /*      Value: */
-                       memcpy(p2pie + p2pielen, pwdinfo->device_addr,
-                              ETH_ALEN);       /* P2P Device Address */
-                       p2pielen += ETH_ALEN;
-
-                       /* P2P Interface Address Count */
-                       p2pie[p2pielen++] = 1;
-
-                       memcpy(p2pie + p2pielen, pwdinfo->device_addr,
-                              ETH_ALEN);       /* P2P Interface Address List */
-                       p2pielen += ETH_ALEN;
-
-                       pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_,
-                                              p2pielen, (unsigned char *)p2pie,
-                                              &pattrib->pktlen);
-
-                       /* wfdielen = build_assoc_req_wfd_ie(pwdinfo, pframe);*/
-                       /* pframe += wfdielen; */
-                       /* pattrib->pktlen += wfdielen; */
-               }
-       }
-
-       if (true == pwdinfo->wfd_info->wfd_enable) {
-               wfdielen = build_assoc_req_wfd_ie(pwdinfo, pframe);
-               pframe += wfdielen;
-               pattrib->pktlen += wfdielen;
-       } else if (pmlmepriv->wfd_assoc_req_ie != NULL &&
-                  pmlmepriv->wfd_assoc_req_ie_len > 0) {
-               /* WFD IE */
-               memcpy(pframe, pmlmepriv->wfd_assoc_req_ie,
-                      pmlmepriv->wfd_assoc_req_ie_len);
-               pattrib->pktlen += pmlmepriv->wfd_assoc_req_ie_len;
-               pframe += pmlmepriv->wfd_assoc_req_ie_len;
-       }
-#endif /* CONFIG_8723AU_P2P */
-
        pattrib->last_txcmdsz = pattrib->pktlen;
        dump_mgntframe23a(padapter, pmgntframe);
 
@@ -6741,8 +3530,7 @@ exit:
                kfree(pmlmepriv->assoc_req);
                pmlmepriv->assoc_req = kmalloc(pattrib->pktlen, GFP_ATOMIC);
                if (pmlmepriv->assoc_req) {
-                       memcpy(pmlmepriv->assoc_req, pwlanhdr,
-                              pattrib->pktlen);
+                       memcpy(pmlmepriv->assoc_req, pwlanhdr, pattrib->pktlen);
                        pmlmepriv->assoc_req_len = pattrib->pktlen;
                }
        } else
@@ -6760,7 +3548,7 @@ static int _issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da,
        struct pkt_attrib *pattrib;
        unsigned char *pframe;
        struct ieee80211_hdr *pwlanhdr;
-       unsigned short *fctrl;
+       __le16 *fctrl;
        struct xmit_priv *pxmitpriv;
        struct mlme_ext_priv *pmlmeext;
        struct mlme_ext_info *pmlmeinfo;
@@ -6883,7 +3671,8 @@ static int _issue_qos_nulldata23a(struct rtw_adapter *padapter,
        struct pkt_attrib *pattrib;
        unsigned char *pframe;
        struct ieee80211_hdr *pwlanhdr;
-       unsigned short *fctrl, *qc;
+       __le16 *fctrl;
+       u16 *qc;
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
@@ -7009,25 +3798,14 @@ static int _issue_deauth23a(struct rtw_adapter *padapter, unsigned char *da,
        struct pkt_attrib *pattrib;
        unsigned char *pframe;
        struct ieee80211_hdr *pwlanhdr;
-       unsigned short *fctrl;
+       __le16 *fctrl;
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        int ret = _FAIL;
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-#endif /* CONFIG_8723AU_P2P */
 
        /* DBG_8723A("%s to "MAC_FMT"\n", __func__, MAC_ARG(da)); */
 
-#ifdef CONFIG_8723AU_P2P
-       if (!(rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) &&
-           (pwdinfo->rx_invitereq_info.scan_op_ch_only)) {
-               mod_timer(&pwdinfo->reset_ch_sitesurvey,
-                         jiffies + msecs_to_jiffies(10));
-       }
-#endif /* CONFIG_8723AU_P2P */
-
        if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL)
                goto exit;
 
@@ -7131,7 +3909,7 @@ void issue_action_spct_ch_switch23a(struct rtw_adapter *padapter,
        struct pkt_attrib *pattrib;
        unsigned char *pframe;
        struct ieee80211_hdr *pwlanhdr;
-       unsigned short *fctrl;
+       __le16 *fctrl;
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        u8 category, action;
@@ -7183,7 +3961,8 @@ void issue_action_spct_ch_switch23a(struct rtw_adapter *padapter,
        dump_mgntframe23a(padapter, pmgntframe);
 }
 
-void issue_action_BA23a(struct rtw_adapter *padapter, unsigned char *raddr,
+void issue_action_BA23a(struct rtw_adapter *padapter,
+                       const unsigned char *raddr,
                        unsigned char action, unsigned short status)
 {
        u8 category = WLAN_CATEGORY_BACK;
@@ -7197,7 +3976,7 @@ void issue_action_BA23a(struct rtw_adapter *padapter, unsigned char *raddr,
        struct pkt_attrib *pattrib;
        u8 *pframe;
        struct ieee80211_hdr *pwlanhdr;
-       u16 *fctrl;
+       __le16 *fctrl;
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
@@ -7373,24 +4152,26 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter)
 {
        struct list_head *plist, *phead, *ptmp;
        unsigned char category, action;
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                           *pframe;
-       struct ieee80211_hdr    *pwlanhdr;
-       unsigned short                  *fctrl;
-       struct  wlan_network    *pnetwork = NULL;
+       struct xmit_frame *pmgntframe;
+       struct pkt_attrib *pattrib;
+       u8 *pframe;
+       struct ieee80211_hdr *pwlanhdr;
+       __le16 *fctrl;
+       struct wlan_network *pnetwork;
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct rtw_queue        *queue  = &pmlmepriv->scanned_queue;
+       struct rtw_queue *queue = &pmlmepriv->scanned_queue;
        u8 InfoContent[16] = {0};
        u8 ICS[8][15];
+       int i;
 
-       if ((pmlmepriv->num_FortyMHzIntolerant == 0) || (pmlmepriv->num_sta_no_ht == 0))
+       if (pmlmepriv->num_FortyMHzIntolerant == 0 ||
+           pmlmepriv->num_sta_no_ht == 0)
                return;
 
-       if (true == pmlmeinfo->bwmode_updated)
+       if (pmlmeinfo->bwmode_updated)
                return;
 
        DBG_8723A("%s\n", __func__);
@@ -7398,10 +4179,9 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter)
        category = WLAN_CATEGORY_PUBLIC;
        action = ACT_PUBLIC_BSSCOEXIST;
 
-       if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL)
-       {
+       pmgntframe = alloc_mgtxmitframe23a(pxmitpriv);
+       if (!pmgntframe)
                return;
-       }
 
        /* update attribute */
        pattrib = &pmgntframe->attrib;
@@ -7409,7 +4189,7 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter)
 
        memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
 
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
+       pframe = (u8 *)pmgntframe->buf_addr + TXDESC_OFFSET;
        pwlanhdr = (struct ieee80211_hdr *)pframe;
 
        fctrl = &pwlanhdr->frame_control;
@@ -7429,85 +4209,74 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter)
        pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen);
        pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen);
 
-       /*  */
-       if (pmlmepriv->num_FortyMHzIntolerant>0)
-       {
-               u8 iedata = 0;
-
-               iedata |= BIT(2);/* 20 MHz BSS Width Request */
-
-               pframe = rtw_set_ie23a(pframe, EID_BSSCoexistence,  1, &iedata, &pattrib->pktlen);
+       if (pmlmepriv->num_FortyMHzIntolerant > 0) {
+               u8 iedata = BIT(2);/* 20 MHz BSS Width Request */
 
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_BSS_COEX_2040, 1,
+                                      &iedata, &pattrib->pktlen);
        }
 
-       /*  */
-       memset(ICS, 0, sizeof(ICS));
-       if (pmlmepriv->num_sta_no_ht>0)
-       {
-               int i;
+       if (pmlmepriv->num_sta_no_ht <= 0)
+               goto out;
 
-               spin_lock_bh(&pmlmepriv->scanned_queue.lock);
+       memset(ICS, 0, sizeof(ICS));
 
-               phead = get_list_head(queue);
-               plist = phead->next;
+       spin_lock_bh(&pmlmepriv->scanned_queue.lock);
 
-               list_for_each_safe(plist, ptmp, phead) {
-                       int len;
-                       u8 *p;
-                       struct wlan_bssid_ex *pbss_network;
+       phead = get_list_head(queue);
+       plist = phead->next;
 
-                       pnetwork = container_of(plist, struct wlan_network,
-                                               list);
+       list_for_each_safe(plist, ptmp, phead) {
+               const u8 *p;
+               struct wlan_bssid_ex *pbss_network;
 
-                       pbss_network = &pnetwork->network;
+               pnetwork = container_of(plist, struct wlan_network, list);
 
-                       p = rtw_get_ie23a(pbss_network->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, pbss_network->IELength - _FIXED_IE_LENGTH_);
-                       if ((p == NULL) || (len == 0))/* non-HT */
-                       {
-                               if ((pbss_network->Configuration.DSConfig<= 0) || (pbss_network->Configuration.DSConfig>14))
-                                       continue;
+               pbss_network = &pnetwork->network;
 
-                               ICS[0][pbss_network->Configuration.DSConfig]= 1;
+               p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY,
+                                    pbss_network->IEs + _FIXED_IE_LENGTH_,
+                                    pbss_network->IELength -_FIXED_IE_LENGTH_);
+               if (!p || !p[1]) { /* non-HT */
+                       if (pbss_network->Configuration.DSConfig <= 0 ||
+                           pbss_network->Configuration.DSConfig > 14)
+                               continue;
 
-                               if (ICS[0][0] == 0)
-                                       ICS[0][0] = 1;
-                       }
+                       ICS[0][pbss_network->Configuration.DSConfig] = 1;
 
+                       if (ICS[0][0] == 0)
+                               ICS[0][0] = 1;
                }
 
-               spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
+       }
 
-               for (i = 0;i<8;i++)
-               {
-                       if (ICS[i][0] == 1)
-                       {
-                               int j, k = 0;
+       spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
 
-                               InfoContent[k] = i;
-                               /* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */
-                               k++;
+       for (i = 0; i < 8;i++) {
+               if (ICS[i][0] == 1) {
+                       int j, k = 0;
 
-                               for (j = 1;j<= 14;j++)
-                               {
-                                       if (ICS[i][j]== 1)
-                                       {
-                                               if (k<16)
-                                               {
-                                                       InfoContent[k] = j; /* channel number */
-                                                       /* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */
-                                                       k++;
-                                               }
+                       InfoContent[k] = i;
+                       /* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */
+                       k++;
+
+                       for (j = 1; j <= 14; j++) {
+                               if (ICS[i][j] == 1) {
+                                       if (k < 16) {
+                                               /* channel number */
+                                               InfoContent[k] = j;
+                                               k++;
                                        }
                                }
-
-                               pframe = rtw_set_ie23a(pframe, EID_BSSIntolerantChlReport, k, InfoContent, &pattrib->pktlen);
-
                        }
 
+                       pframe = rtw_set_ie23a(pframe,
+                                              EID_BSSIntolerantChlReport, k,
+                                              InfoContent, &pattrib->pktlen);
                }
-
        }
 
+out:
        pattrib->last_txcmdsz = pattrib->pktlen;
 
        dump_mgntframe23a(padapter, pmgntframe);
@@ -7555,21 +4324,21 @@ unsigned int send_delba23a(struct rtw_adapter *padapter, u8 initiator, u8 *addr)
 
 unsigned int send_beacon23a(struct rtw_adapter *padapter)
 {
-       u8      bxmitok = false;
+       bool    bxmitok;
        int     issue = 0;
        int poll = 0;
        unsigned long start = jiffies;
        unsigned int passing_time;
 
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_BCN_VALID, NULL);
+       rtl8723a_bcn_valid(padapter);
        do {
                issue_beacon23a(padapter, 100);
                issue++;
                do {
                        yield();
-                       rtw23a_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, (u8 *)(&bxmitok));
+                       bxmitok = rtl8723a_get_bcn_valid(padapter);
                        poll++;
-               } while ((poll%10)!= 0 && false == bxmitok &&
+               } while ((poll % 10) != 0 && bxmitok == false &&
                         !padapter->bSurpriseRemoved &&
                         !padapter->bDriverStopped);
 
@@ -7615,46 +4384,22 @@ bool IsLegal5GChannel(struct rtw_adapter *Adapter, u8 channel)
 
 void site_survey23a(struct rtw_adapter *padapter)
 {
-       unsigned char survey_channel = 0, val8;
+       unsigned char survey_channel = 0;
        enum rt_scan_type ScanType = SCAN_PASSIVE;
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
-       u32 initialgain = 0;
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       if ((pwdinfo->rx_invitereq_info.scan_op_ch_only) ||
-           (pwdinfo->p2p_info.scan_op_ch_only)) {
-               if (pwdinfo->rx_invitereq_info.scan_op_ch_only)
-                       survey_channel = pwdinfo->rx_invitereq_info.operation_ch[pmlmeext->sitesurvey_res.channel_idx];
-               else
-                       survey_channel = pwdinfo->p2p_info.operation_ch[pmlmeext->sitesurvey_res.channel_idx];
-               ScanType = SCAN_ACTIVE;
-       } else if (rtw_p2p_findphase_ex_is_social(pwdinfo)) {
-               /* The driver is in the find phase, it should go through the social channel. */
-               int ch_set_idx;
-               survey_channel = pwdinfo->social_chan[pmlmeext->sitesurvey_res.channel_idx];
-               ch_set_idx = rtw_ch_set_search_ch23a(pmlmeext->channel_set, survey_channel);
-               if (ch_set_idx >= 0)
-                       ScanType = pmlmeext->channel_set[ch_set_idx].ScanType;
-               else
-                       ScanType = SCAN_ACTIVE;
-       } else
-#endif /* CONFIG_8723AU_P2P */
-       {
-               struct rtw_ieee80211_channel *ch;
-               if (pmlmeext->sitesurvey_res.channel_idx < pmlmeext->sitesurvey_res.ch_num) {
-                       ch = &pmlmeext->sitesurvey_res.ch[pmlmeext->sitesurvey_res.channel_idx];
-                       survey_channel = ch->hw_value;
-                       ScanType = (ch->flags & IEEE80211_CHAN_NO_IR) ? SCAN_PASSIVE : SCAN_ACTIVE;
-}
+       struct rtw_ieee80211_channel *ch;
+
+       if (pmlmeext->sitesurvey_res.channel_idx <
+           pmlmeext->sitesurvey_res.ch_num) {
+               ch = &pmlmeext->sitesurvey_res.ch[pmlmeext->sitesurvey_res.channel_idx];
+               survey_channel = ch->hw_value;
+               ScanType = (ch->flags & IEEE80211_CHAN_NO_IR) ?
+                       SCAN_PASSIVE : SCAN_ACTIVE;
        }
 
        if (survey_channel != 0) {
                /* PAUSE 4-AC Queue when site_survey23a */
-               /* rtw23a_hal_get_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */
-               /* val8 |= 0x0f; */
-               /* rtw_hal_set_hwreg23a(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */
                if (pmlmeext->sitesurvey_res.channel_idx == 0)
                        set_channel_bwmode23a(padapter, survey_channel,
                                              HAL_PRIME_CHNL_OFFSET_DONT_CARE,
@@ -7664,276 +4409,220 @@ void site_survey23a(struct rtw_adapter *padapter)
 
                if (ScanType == SCAN_ACTIVE) /* obey the channel plan setting... */
                {
-#ifdef CONFIG_8723AU_P2P
-                       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) ||
-                               rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH)
-                       )
-                       {
-                               issue23a_probereq_p2p(padapter, NULL);
-                               issue23a_probereq_p2p(padapter, NULL);
-                               issue23a_probereq_p2p(padapter, NULL);
-                       }
-                       else
-#endif /* CONFIG_8723AU_P2P */
-                       {
-                               int i;
-                               for (i = 0;i<RTW_SSID_SCAN_AMOUNT;i++) {
-                                       if (pmlmeext->sitesurvey_res.ssid[i].ssid_len) {
-                                               /* todo: to issue two probe req??? */
-                                               issue_probereq23a(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL);
-                                               /* msleep(SURVEY_TO>>1); */
-                                               issue_probereq23a(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL);
-                                       }
-                               }
-
-                               if (pmlmeext->sitesurvey_res.scan_mode == SCAN_ACTIVE) {
+                       int i;
+                       for (i = 0;i<RTW_SSID_SCAN_AMOUNT;i++) {
+                               if (pmlmeext->sitesurvey_res.ssid[i].ssid_len) {
                                        /* todo: to issue two probe req??? */
-                                       issue_probereq23a(padapter, NULL, NULL);
+                                       issue_probereq23a(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL);
                                        /* msleep(SURVEY_TO>>1); */
-                                       issue_probereq23a(padapter, NULL, NULL);
+                                       issue_probereq23a(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL);
                                }
                        }
+
+                       if (pmlmeext->sitesurvey_res.scan_mode == SCAN_ACTIVE) {
+                               /* todo: to issue two probe req??? */
+                               issue_probereq23a(padapter, NULL, NULL);
+                               /* msleep(SURVEY_TO>>1); */
+                               issue_probereq23a(padapter, NULL, NULL);
+                       }
                }
 
                set_survey_timer(pmlmeext, pmlmeext->chan_scan_time);
        } else {
-
                /*      channel number is 0 or this channel is not valid. */
+               pmlmeext->sitesurvey_res.state = SCAN_COMPLETE;
 
+               /* switch back to the original channel */
 
-#ifdef CONFIG_8723AU_P2P
-               if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH))
-               {
-                       if ((pwdinfo->rx_invitereq_info.scan_op_ch_only) || (pwdinfo->p2p_info.scan_op_ch_only))
-                       {
-                               /*      Set the find_phase_state_exchange_cnt to P2P_FINDPHASE_EX_CNT. */
-                               /*      This will let the following flow to run the scanning end. */
-                               rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_MAX);
-                       }
-               }
-
-               if (rtw_p2p_findphase_ex_is_needed(pwdinfo))
-               {
-                       /*      Set the P2P State to the listen state of find phase and set the current channel to the listen channel */
-                       set_channel_bwmode23a(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
-                       rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_LISTEN);
-                       pmlmeext->sitesurvey_res.state = SCAN_DISABLE;
-
-                       initialgain = 0xff; /* restore RX GAIN */
-                       rtw_hal_set_hwreg23a(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain));
-                       /* turn on dynamic functions */
-                       Restore_DM_Func_Flag23a(padapter);
-                       /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DIG|DYNAMIC_FUNC_HP|DYNAMIC_FUNC_SS, true); */
-
-                       mod_timer(&pwdinfo->find_phase_timer, jiffies +
-                                 msecs_to_jiffies(pwdinfo->listen_dwell * 100));
-               } else
-#endif /* CONFIG_8723AU_P2P */
-               {
-#ifdef CONFIG_8723AU_P2P
-                       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH))
-                               rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo));
-                       rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_NONE);
-#endif /* CONFIG_8723AU_P2P */
-
-                       pmlmeext->sitesurvey_res.state = SCAN_COMPLETE;
-
-                       /* switch back to the original channel */
-
-                       set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
+               set_channel_bwmode23a(padapter, pmlmeext->cur_channel,
+                                     pmlmeext->cur_ch_offset,
+                                     pmlmeext->cur_bwmode);
 
-                       /* flush 4-AC Queue after site_survey23a */
-                       /* val8 = 0; */
-                       /* rtw_hal_set_hwreg23a(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */
+               /* flush 4-AC Queue after site_survey23a */
+               /* val8 = 0; */
 
-                       /* config MSR */
-                       Set_MSR23a(padapter, (pmlmeinfo->state & 0x3));
-
-                       initialgain = 0xff; /* restore RX GAIN */
-                       rtw_hal_set_hwreg23a(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain));
-                       /* turn on dynamic functions */
-                       Restore_DM_Func_Flag23a(padapter);
-                       /* Switch_DM_Func23a(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); */
-
-                       if (is_client_associated_to_ap23a(padapter) == true)
-                       {
-                               issue_nulldata23a(padapter, NULL, 0, 3, 500);
+               /* config MSR */
+               Set_MSR23a(padapter, (pmlmeinfo->state & 0x3));
 
-                       }
+               /* restore RX GAIN */
+               rtl8723a_set_initial_gain(padapter, 0xff);
+               /* turn on dynamic functions */
+               rtl8723a_odm_support_ability_restore(padapter);
 
-                       val8 = 0; /* survey done */
-                       rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8));
+               if (is_client_associated_to_ap23a(padapter) == true)
+                       issue_nulldata23a(padapter, NULL, 0, 3, 500);
 
-                       report_surveydone_event23a(padapter);
+               rtl8723a_mlme_sitesurvey(padapter, 0);
 
-                       pmlmeext->chan_scan_time = SURVEY_TO;
-                       pmlmeext->sitesurvey_res.state = SCAN_DISABLE;
+               report_surveydone_event23a(padapter);
 
-                       issue_action_BSSCoexistPacket(padapter);
-                       issue_action_BSSCoexistPacket(padapter);
-                       issue_action_BSSCoexistPacket(padapter);
+               pmlmeext->chan_scan_time = SURVEY_TO;
+               pmlmeext->sitesurvey_res.state = SCAN_DISABLE;
 
-               }
+               issue_action_BSSCoexistPacket(padapter);
+               issue_action_BSSCoexistPacket(padapter);
+               issue_action_BSSCoexistPacket(padapter);
        }
 
        return;
 }
 
 /* collect bss info from Beacon and Probe request/response frames. */
-u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame, struct wlan_bssid_ex *bssid)
+u8 collect_bss_info23a(struct rtw_adapter *padapter,
+                      struct recv_frame *precv_frame,
+                      struct wlan_bssid_ex *bssid)
 {
-       int     i;
-       u32     len;
-       u8      *p;
-       u16     val16;
+       int i;
+       const u8 *p;
        struct sk_buff *skb = precv_frame->pkt;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       u8      *pframe = skb->data;
-       u32     packet_len = skb->len;
+       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
+       unsigned int length;
        u8 ie_offset;
-       struct registry_priv    *pregistrypriv = &padapter->registrypriv;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
+       struct registry_priv *pregistrypriv = &padapter->registrypriv;
+       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
+       u16 capab_info;
 
-       len = packet_len - sizeof(struct ieee80211_hdr_3addr);
+       length = skb->len - sizeof(struct ieee80211_hdr_3addr);
 
-       if (len > MAX_IE_SZ)
-       {
+       if (length > MAX_IE_SZ) {
                /* DBG_8723A("IE too long for survey event\n"); */
                return _FAIL;
        }
 
        memset(bssid, 0, sizeof(struct wlan_bssid_ex));
 
-       if (ieee80211_is_beacon(hdr->frame_control)) {
+       if (ieee80211_is_beacon(mgmt->frame_control)) {
                bssid->reserved = 1;
-               ie_offset = _BEACON_IE_OFFSET_;
+               ie_offset = offsetof(struct ieee80211_mgmt, u.beacon.variable);
+               capab_info = mgmt->u.beacon.capab_info;
+       } else  if (ieee80211_is_probe_req(mgmt->frame_control)) {
+               ie_offset = offsetof(struct ieee80211_mgmt,
+                                    u.probe_req.variable);
+               bssid->reserved = 2;
+               capab_info = 0;
+       } else if (ieee80211_is_probe_resp(mgmt->frame_control)) {
+               ie_offset = offsetof(struct ieee80211_mgmt,
+                                    u.probe_resp.variable);
+               bssid->reserved = 3;
+               capab_info = mgmt->u.probe_resp.capab_info;
        } else {
-               /*  FIXME : more type */
-               if (ieee80211_is_probe_req(hdr->frame_control)) {
-                       ie_offset = _PROBEREQ_IE_OFFSET_;
-                       bssid->reserved = 2;
-               } else if (ieee80211_is_probe_resp(hdr->frame_control)) {
-                       ie_offset = _PROBERSP_IE_OFFSET_;
-                       bssid->reserved = 3;
-               } else {
-                       bssid->reserved = 0;
-                       ie_offset = _FIXED_IE_LENGTH_;
-               }
+               bssid->reserved = 0;
+               ie_offset = offsetof(struct ieee80211_mgmt, u.beacon.variable);
+               capab_info = mgmt->u.beacon.capab_info;
        }
+       ie_offset -= offsetof(struct ieee80211_mgmt, u);
 
-       bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len;
+       bssid->Length = offsetof(struct wlan_bssid_ex, IEs) + length;
 
        /* below is to copy the information element */
-       bssid->IELength = len;
-       memcpy(bssid->IEs, (pframe + sizeof(struct ieee80211_hdr_3addr)), bssid->IELength);
+       bssid->IELength = length;
+       memcpy(bssid->IEs, &mgmt->u, bssid->IELength);
 
        /* get the signal strength */
-       bssid->Rssi = precv_frame->attrib.phy_info.RecvSignalPower; /*  in dBM.raw data */
-       bssid->PhyInfo.SignalQuality = precv_frame->attrib.phy_info.SignalQuality;/* in percentage */
-       bssid->PhyInfo.SignalStrength = precv_frame->attrib.phy_info.SignalStrength;/* in percentage */
+       /*  in dBM.raw data */
+       bssid->Rssi = precv_frame->attrib.phy_info.RecvSignalPower;
+       bssid->PhyInfo.SignalQuality =
+               precv_frame->attrib.phy_info.SignalQuality;/* in percentage */
+       bssid->PhyInfo.SignalStrength =
+               precv_frame->attrib.phy_info.SignalStrength;/* in percentage */
 
        /*  checking SSID */
-       if ((p = rtw_get_ie23a(bssid->IEs + ie_offset, _SSID_IE_, &len, bssid->IELength - ie_offset)) == NULL)
-       {
+       p = cfg80211_find_ie(WLAN_EID_SSID, bssid->IEs + ie_offset,
+                            bssid->IELength - ie_offset);
+
+       if (!p) {
                DBG_8723A("marc: cannot find SSID for survey event\n");
                return _FAIL;
        }
 
-       if (*(p + 1)) {
-               if (len > IEEE80211_MAX_SSID_LEN) {
-                       DBG_8723A("%s()-%d: IE too long (%d) for survey "
-                                 "event\n", __func__, __LINE__, len);
-                       return _FAIL;
-               }
-               memcpy(bssid->Ssid.ssid, (p + 2), *(p + 1));
-               bssid->Ssid.ssid_len = *(p + 1);
-       } else {
-               bssid->Ssid.ssid_len = 0;
+       if (p[1] > IEEE80211_MAX_SSID_LEN) {
+               DBG_8723A("%s()-%d: IE too long (%d) for survey "
+                         "event\n", __func__, __LINE__, p[1]);
+               return _FAIL;
        }
+       memcpy(bssid->Ssid.ssid, p + 2, p[1]);
+       bssid->Ssid.ssid_len = p[1];
 
        memset(bssid->SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX);
 
        /* checking rate info... */
        i = 0;
-       p = rtw_get_ie23a(bssid->IEs + ie_offset, _SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset);
-       if (p != NULL)
-       {
-               if (len > NDIS_802_11_LENGTH_RATES_EX)
-               {
-                       DBG_8723A("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len);
+       p = cfg80211_find_ie(WLAN_EID_SUPP_RATES, bssid->IEs + ie_offset,
+                            bssid->IELength - ie_offset);
+       if (p) {
+               if (p[1] > NDIS_802_11_LENGTH_RATES_EX) {
+                       DBG_8723A("%s()-%d: IE too long (%d) for survey "
+                                 "event\n", __func__, __LINE__, p[1]);
                        return _FAIL;
                }
-               memcpy(bssid->SupportedRates, (p + 2), len);
-               i = len;
+               memcpy(bssid->SupportedRates, p + 2, p[1]);
+               i = p[1];
        }
 
-       p = rtw_get_ie23a(bssid->IEs + ie_offset, _EXT_SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset);
-       if (p != NULL)
-       {
-               if (len > (NDIS_802_11_LENGTH_RATES_EX-i))
-               {
-                       DBG_8723A("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len);
+       p = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, bssid->IEs + ie_offset,
+                            bssid->IELength - ie_offset);
+       if (p) {
+               if (p[1] > (NDIS_802_11_LENGTH_RATES_EX-i)) {
+                       DBG_8723A("%s()-%d: IE too long (%d) for survey "
+                                 "event\n", __func__, __LINE__, p[1]);
                        return _FAIL;
                }
-               memcpy(bssid->SupportedRates + i, (p + 2), len);
+               memcpy(bssid->SupportedRates + i, p + 2, p[1]);
        }
 
-       /* todo: */
-       {
-               bssid->NetworkTypeInUse = Ndis802_11OFDM24;
-       }
+       bssid->NetworkTypeInUse = Ndis802_11OFDM24;
 
        if (bssid->IELength < 12)
                return _FAIL;
 
        /*  Checking for DSConfig */
-       p = rtw_get_ie23a(bssid->IEs + ie_offset, _DSSET_IE_, &len, bssid->IELength - ie_offset);
+       p = cfg80211_find_ie(WLAN_EID_DS_PARAMS, bssid->IEs + ie_offset,
+                            bssid->IELength - ie_offset);
 
        bssid->Configuration.DSConfig = 0;
        bssid->Configuration.Length = 0;
 
-       if (p)
-       {
-               bssid->Configuration.DSConfig = *(p + 2);
-       }
-       else
-       {/*  In 5G, some ap do not have DSSET IE */
+       if (p) {
+               bssid->Configuration.DSConfig = p[2];
+       } else {/*  In 5G, some ap do not have DSSET IE */
                /*  checking HT info for channel */
-               p = rtw_get_ie23a(bssid->IEs + ie_offset, _HT_ADD_INFO_IE_, &len, bssid->IELength - ie_offset);
-               if (p)
-               {
-                       struct HT_info_element *HT_info = (struct HT_info_element *)(p + 2);
-                       bssid->Configuration.DSConfig = HT_info->primary_channel;
-               }
-               else
-               { /*  use current channel */
-                       bssid->Configuration.DSConfig = rtw_get_oper_ch23a(padapter);
+               p = cfg80211_find_ie(WLAN_EID_HT_OPERATION,
+                                    bssid->IEs + ie_offset,
+                                    bssid->IELength - ie_offset);
+               if (p) {
+                       struct HT_info_element *HT_info =
+                               (struct HT_info_element *)(p + 2);
+                       bssid->Configuration.DSConfig =
+                               HT_info->primary_channel;
+               } else { /*  use current channel */
+                       bssid->Configuration.DSConfig =
+                               rtw_get_oper_ch23a(padapter);
                }
        }
 
-       if (ieee80211_is_probe_req(hdr->frame_control)) {
+       if (ieee80211_is_probe_req(mgmt->frame_control)) {
                /*  FIXME */
                bssid->InfrastructureMode = Ndis802_11Infrastructure;
-               ether_addr_copy(bssid->MacAddress, hdr->addr2);
+               ether_addr_copy(bssid->MacAddress, mgmt->sa);
                bssid->Privacy = 1;
                return _SUCCESS;
        }
 
-       memcpy(&bssid->Configuration.BeaconPeriod, rtw_get_beacon_interval23a_from_ie(bssid->IEs), 2);
-       bssid->Configuration.BeaconPeriod = le32_to_cpu(bssid->Configuration.BeaconPeriod);
+       memcpy(&bssid->Configuration.BeaconPeriod,
+              rtw_get_beacon_interval23a_from_ie(bssid->IEs), 2);
+       bssid->Configuration.BeaconPeriod =
+               le32_to_cpu(bssid->Configuration.BeaconPeriod);
 
-       val16 = rtw_get_capability23a(bssid);
-
-       if (val16 & BIT(0)) {
+       if (capab_info & BIT(0)) {
                bssid->InfrastructureMode = Ndis802_11Infrastructure;
-               ether_addr_copy(bssid->MacAddress, hdr->addr2);
+               ether_addr_copy(bssid->MacAddress, mgmt->sa);
        } else {
                bssid->InfrastructureMode = Ndis802_11IBSS;
-               ether_addr_copy(bssid->MacAddress, hdr->addr3);
+               ether_addr_copy(bssid->MacAddress, mgmt->bssid);
        }
 
-       if (val16 & BIT(4))
+       if (capab_info & BIT(4))
                bssid->Privacy = 1;
        else
                bssid->Privacy = 0;
@@ -7941,21 +4630,21 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr
        bssid->Configuration.ATIMWindow = 0;
 
        /* 20/40 BSS Coexistence check */
-       if ((pregistrypriv->wifi_spec == 1) && (false == pmlmeinfo->bwmode_updated))
-       {
+       if (pregistrypriv->wifi_spec == 1 &&
+           pmlmeinfo->bwmode_updated == false) {
                struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
-               p = rtw_get_ie23a(bssid->IEs + ie_offset, _HT_CAPABILITY_IE_, &len, bssid->IELength - ie_offset);
-               if (p && len > 0) {
-                       struct HT_caps_element  *pHT_caps;
-                       pHT_caps = (struct HT_caps_element      *)(p + 2);
+               p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY,
+                                    bssid->IEs + ie_offset,
+                                    bssid->IELength - ie_offset);
+               if (p && p[1] > 0) {
+                       struct HT_caps_element *pHT_caps;
+                       pHT_caps = (struct HT_caps_element *)(p + 2);
 
                        if (pHT_caps->u.HT_cap_element.HT_caps_info & BIT(14))
                                pmlmepriv->num_FortyMHzIntolerant++;
                } else
-               {
                        pmlmepriv->num_sta_no_ht++;
-               }
        }
 
 
@@ -7969,8 +4658,6 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr
 void start_create_ibss23a(struct rtw_adapter* padapter)
 {
        unsigned short  caps;
-       u8      val8;
-       u8      join_type;
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network;
@@ -7983,10 +4670,8 @@ void start_create_ibss23a(struct rtw_adapter* padapter)
        /* udpate capability */
        caps = rtw_get_capability23a(pnetwork);
        update_capinfo23a(padapter, caps);
-       if (caps&cap_IBSS)/* adhoc master */
-       {
-               val8 = 0xcf;
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8));
+       if (caps&cap_IBSS) {    /* adhoc master */
+               rtl8723a_set_sec_cfg(padapter, 0xcf);
 
                /* switch channel */
                /* SelectChannel23a(padapter, pmlmeext->cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE); */
@@ -8008,9 +4693,8 @@ void start_create_ibss23a(struct rtw_adapter* padapter)
                }
                else
                {
-                       rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, padapter->registrypriv.dev_network.MacAddress);
-                       join_type = 0;
-                       rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type));
+                       hw_var_set_bssid(padapter, padapter->registrypriv.dev_network.MacAddress);
+                       hw_var_set_mlme_join(padapter, 0);
 
                        report_join_res23a(padapter, 1);
                        pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS;
@@ -8047,9 +4731,10 @@ void start_clnt_join23a(struct rtw_adapter* padapter)
 
                Set_MSR23a(padapter, WIFI_FW_STATION_STATE);
 
-               val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X)? 0xcc: 0xcf;
+               val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) ?
+                       0xcc: 0xcf;
 
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8));
+               rtl8723a_set_sec_cfg(padapter, val8);
 
                /* switch channel */
                /* set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */
@@ -8062,12 +4747,10 @@ void start_clnt_join23a(struct rtw_adapter* padapter)
                          msecs_to_jiffies((REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO*REASSOC_LIMIT) + beacon_timeout));
                pmlmeinfo->state = WIFI_FW_AUTH_NULL | WIFI_FW_STATION_STATE;
        }
-       else if (caps&cap_IBSS) /* adhoc client */
-       {
+       else if (caps&cap_IBSS) {       /* adhoc client */
                Set_MSR23a(padapter, WIFI_FW_ADHOC_STATE);
 
-               val8 = 0xcf;
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8));
+               rtl8723a_set_sec_cfg(padapter, 0xcf);
 
                /* switch channel */
                set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
@@ -8158,7 +4841,8 @@ unsigned int receive_disconnect23a(struct rtw_adapter *padapter, unsigned char *
        return _SUCCESS;
 }
 
-static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *bssid)
+static void process_80211d(struct rtw_adapter *padapter,
+                          struct wlan_bssid_ex *bssid)
 {
        struct registry_priv *pregistrypriv;
        struct mlme_ext_priv *pmlmeext;
@@ -8171,10 +4855,8 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b
 
        /*  Adjust channel plan by AP Country IE */
        if (pregistrypriv->enable80211d &&
-               (!pmlmeext->update_channel_plan_by_ap_done))
-       {
-               u8 *ie, *p;
-               u32 len;
+           !pmlmeext->update_channel_plan_by_ap_done) {
+               const u8 *ie, *p;
                struct rt_channel_plan chplan_ap;
                struct rt_channel_info chplan_sta[MAX_CHANNEL_NUM];
                u8 country[4];
@@ -8182,31 +4864,34 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b
                u8 noc; /*  number of channel */
                u8 j, k;
 
-               ie = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, _COUNTRY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
-               if (!ie) return;
-               if (len < 6) return;
+               ie = cfg80211_find_ie(WLAN_EID_COUNTRY,
+                                     bssid->IEs + _FIXED_IE_LENGTH_,
+                                     bssid->IELength - _FIXED_IE_LENGTH_);
+               if (!ie || ie[1] < IEEE80211_COUNTRY_IE_MIN_LEN)
+                       return;
 
+               p = ie + 2;
+               ie += ie[1];
                ie += 2;
-               p = ie;
-               ie += len;
 
-               memset(country, 0, 4);
                memcpy(country, p, 3);
+               country[3] = '\0';
+
                p += 3;
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_,
-                               ("%s: 802.11d country =%s\n", __func__, country));
+                        ("%s: 802.11d country =%s\n", __func__, country));
 
                i = 0;
-               while ((ie - p) >= 3)
-               {
+               while ((ie - p) >= 3) {
                        fcn = *(p++);
                        noc = *(p++);
                        p++;
 
-                       for (j = 0; j < noc; j++)
-                       {
-                               if (fcn <= 14) channel = fcn + j; /*  2.4 GHz */
-                               else channel = fcn + j*4; /*  5 GHz */
+                       for (j = 0; j < noc; j++) {
+                               if (fcn <= 14)
+                                       channel = fcn + j; /*  2.4 GHz */
+                               else
+                                       channel = fcn + j * 4; /*  5 GHz */
 
                                chplan_ap.Channel[i++] = channel;
                        }
@@ -8220,45 +4905,55 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b
                i = j = k = 0;
                if (pregistrypriv->wireless_mode & WIRELESS_11G) {
                        do {
-                               if ((i == MAX_CHANNEL_NUM) ||
-                                       (chplan_sta[i].ChannelNum == 0) ||
-                                       (chplan_sta[i].ChannelNum > 14))
+                               if (i == MAX_CHANNEL_NUM ||
+                                   chplan_sta[i].ChannelNum == 0 ||
+                                   chplan_sta[i].ChannelNum > 14)
                                        break;
 
-                               if ((j == chplan_ap.Len) || (chplan_ap.Channel[j] > 14))
+                               if (j == chplan_ap.Len ||
+                                   chplan_ap.Channel[j] > 14)
                                        break;
 
-                               if (chplan_sta[i].ChannelNum == chplan_ap.Channel[j]) {
-                                       chplan_new[k].ChannelNum = chplan_ap.Channel[j];
+                               if (chplan_sta[i].ChannelNum ==
+                                   chplan_ap.Channel[j]) {
+                                       chplan_new[k].ChannelNum =
+                                               chplan_ap.Channel[j];
                                        chplan_new[k].ScanType = SCAN_ACTIVE;
                                        i++;
                                        j++;
                                        k++;
-                               } else if (chplan_sta[i].ChannelNum < chplan_ap.Channel[j]) {
-                                       chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum;
-                                       chplan_new[k].ScanType = SCAN_PASSIVE;
+                               } else if (chplan_sta[i].ChannelNum <
+                                          chplan_ap.Channel[j]) {
+                                       chplan_new[k].ChannelNum =
+                                               chplan_sta[i].ChannelNum;
+                                       chplan_new[k].ScanType =
+                                               SCAN_PASSIVE;
                                        i++;
                                        k++;
-                               } else if (chplan_sta[i].ChannelNum > chplan_ap.Channel[j]) {
-                                       chplan_new[k].ChannelNum = chplan_ap.Channel[j];
-                                       chplan_new[k].ScanType = SCAN_ACTIVE;
+                               } else if (chplan_sta[i].ChannelNum >
+                                          chplan_ap.Channel[j]) {
+                                       chplan_new[k].ChannelNum =
+                                               chplan_ap.Channel[j];
+                                       chplan_new[k].ScanType =
+                                               SCAN_ACTIVE;
                                        j++;
                                        k++;
                                }
                        } while (1);
 
                        /*  change AP not support channel to Passive scan */
-                       while ((i < MAX_CHANNEL_NUM) &&
-                               (chplan_sta[i].ChannelNum != 0) &&
-                               (chplan_sta[i].ChannelNum <= 14)) {
-                               chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum;
+                       while (i < MAX_CHANNEL_NUM &&
+                              chplan_sta[i].ChannelNum != 0 &&
+                              chplan_sta[i].ChannelNum <= 14) {
+                               chplan_new[k].ChannelNum =
+                                       chplan_sta[i].ChannelNum;
                                chplan_new[k].ScanType = SCAN_PASSIVE;
                                i++;
                                k++;
                        }
 
                        /*  add channel AP supported */
-                       while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) {
+                       while (j < chplan_ap.Len && chplan_ap.Channel[j] <= 14){
                                chplan_new[k].ChannelNum = chplan_ap.Channel[j];
                                chplan_new[k].ScanType = SCAN_ACTIVE;
                                j++;
@@ -8266,49 +4961,50 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b
                        }
                } else {
                        /*  keep original STA 2.4G channel plan */
-                       while ((i < MAX_CHANNEL_NUM) &&
-                               (chplan_sta[i].ChannelNum != 0) &&
-                               (chplan_sta[i].ChannelNum <= 14)) {
-                               chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum;
+                       while (i < MAX_CHANNEL_NUM &&
+                              chplan_sta[i].ChannelNum != 0 &&
+                              chplan_sta[i].ChannelNum <= 14) {
+                               chplan_new[k].ChannelNum =
+                                       chplan_sta[i].ChannelNum;
                                chplan_new[k].ScanType = chplan_sta[i].ScanType;
                                i++;
                                k++;
                        }
 
                        /*  skip AP 2.4G channel plan */
-                       while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) {
+                       while (j < chplan_ap.Len && chplan_ap.Channel[j] <= 14)
                                j++;
-                       }
                }
 
                if (pregistrypriv->wireless_mode & WIRELESS_11A) {
                        do {
-                               if ((i == MAX_CHANNEL_NUM) ||
-                                   (chplan_sta[i].ChannelNum == 0))
+                               if (i == MAX_CHANNEL_NUM ||
+                                   chplan_sta[i].ChannelNum == 0)
                                        break;
 
-                               if ((j == chplan_ap.Len) || (chplan_ap.Channel[j] == 0))
+                               if (j == chplan_ap.Len ||
+                                   chplan_ap.Channel[j] == 0)
                                        break;
 
-                               if (chplan_sta[i].ChannelNum == chplan_ap.Channel[j])
-                               {
-                                       chplan_new[k].ChannelNum = chplan_ap.Channel[j];
+                               if (chplan_sta[i].ChannelNum ==
+                                   chplan_ap.Channel[j]) {
+                                       chplan_new[k].ChannelNum =
+                                               chplan_ap.Channel[j];
                                        chplan_new[k].ScanType = SCAN_ACTIVE;
                                        i++;
                                        j++;
                                        k++;
-                               }
-                               else if (chplan_sta[i].ChannelNum < chplan_ap.Channel[j])
-                               {
-                                       chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum;
-/*                                     chplan_new[k].ScanType = chplan_sta[i].ScanType; */
+                               } else if (chplan_sta[i].ChannelNum <
+                                          chplan_ap.Channel[j]) {
+                                       chplan_new[k].ChannelNum =
+                                               chplan_sta[i].ChannelNum;
                                        chplan_new[k].ScanType = SCAN_PASSIVE;
                                        i++;
                                        k++;
-                               }
-                               else if (chplan_sta[i].ChannelNum > chplan_ap.Channel[j])
-                               {
-                                       chplan_new[k].ChannelNum = chplan_ap.Channel[j];
+                               } else if (chplan_sta[i].ChannelNum >
+                                          chplan_ap.Channel[j]) {
+                                       chplan_new[k].ChannelNum =
+                                               chplan_ap.Channel[j];
                                        chplan_new[k].ScanType = SCAN_ACTIVE;
                                        j++;
                                        k++;
@@ -8316,15 +5012,17 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b
                        } while (1);
 
                        /*  change AP not support channel to Passive scan */
-                       while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) {
-                               chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum;
+                       while (i < MAX_CHANNEL_NUM &&
+                              chplan_sta[i].ChannelNum != 0) {
+                               chplan_new[k].ChannelNum =
+                                       chplan_sta[i].ChannelNum;
                                chplan_new[k].ScanType = SCAN_PASSIVE;
                                i++;
                                k++;
                        }
 
                        /*  add channel AP supported */
-                       while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] != 0)) {
+                       while (j < chplan_ap.Len && chplan_ap.Channel[j] != 0) {
                                chplan_new[k].ChannelNum = chplan_ap.Channel[j];
                                chplan_new[k].ScanType = SCAN_ACTIVE;
                                j++;
@@ -8332,8 +5030,10 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b
                        }
                } else {
                        /*  keep original STA 5G channel plan */
-                       while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) {
-                               chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum;
+                       while (i < MAX_CHANNEL_NUM &&
+                              chplan_sta[i].ChannelNum != 0) {
+                               chplan_new[k].ChannelNum =
+                                       chplan_sta[i].ChannelNum;
                                chplan_new[k].ScanType = chplan_sta[i].ScanType;
                                i++;
                                k++;
@@ -8346,18 +5046,19 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b
        channel = bssid->Configuration.DSConfig;
        chplan_new = pmlmeext->channel_set;
        i = 0;
-       while ((i < MAX_CHANNEL_NUM) && (chplan_new[i].ChannelNum != 0)) {
-               if (chplan_new[i].ChannelNum == channel)
-               {
+       while (i < MAX_CHANNEL_NUM && chplan_new[i].ChannelNum != 0) {
+               if (chplan_new[i].ChannelNum == channel) {
                        if (chplan_new[i].ScanType == SCAN_PASSIVE) {
-                               /* 5G Bnad 2, 3 (DFS) doesn't change to active scan */
+                               /* 5G Bnad 2, 3 (DFS) doesn't change
+                                  to active scan */
                                if (channel >= 52 && channel <= 144)
                                        break;
 
                                chplan_new[i].ScanType = SCAN_ACTIVE;
                                RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_,
-                                                ("%s: change channel %d scan type from passive to active\n",
-                                                 __func__, channel));
+                                        ("%s: change channel %d scan type "
+                                         "from passive to active\n",
+                                         __func__, channel));
                        }
                        break;
                }
@@ -8399,8 +5100,6 @@ void report_survey_event23a(struct rtw_adapter *padapter, struct recv_frame *pre
                return;
        }
 
-       INIT_LIST_HEAD(&pcmd_obj->list);
-
        pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT);
        pcmd_obj->cmdsz = cmdsz;
        pcmd_obj->parmbuf = pevtcmd;
@@ -8452,8 +5151,6 @@ void report_surveydone_event23a(struct rtw_adapter *padapter)
                return;
        }
 
-       INIT_LIST_HEAD(&pcmd_obj->list);
-
        pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT);
        pcmd_obj->cmdsz = cmdsz;
        pcmd_obj->parmbuf = pevtcmd;
@@ -8499,8 +5196,6 @@ void report_join_res23a(struct rtw_adapter *padapter, int res)
                return;
        }
 
-       INIT_LIST_HEAD(&pcmd_obj->list);
-
        pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT);
        pcmd_obj->cmdsz = cmdsz;
        pcmd_obj->parmbuf = pevtcmd;
@@ -8551,8 +5246,6 @@ void report_del_sta_event23a(struct rtw_adapter *padapter, unsigned char* MacAdd
                return;
        }
 
-       INIT_LIST_HEAD(&pcmd_obj->list);
-
        pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT);
        pcmd_obj->cmdsz = cmdsz;
        pcmd_obj->parmbuf = pevtcmd;
@@ -8607,8 +5300,6 @@ void report_add_sta_event23a(struct rtw_adapter *padapter, unsigned char* MacAdd
                return;
        }
 
-       INIT_LIST_HEAD(&pcmd_obj->list);
-
        pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT);
        pcmd_obj->cmdsz = cmdsz;
        pcmd_obj->parmbuf = pevtcmd;
@@ -8691,17 +5382,14 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct wlan_bssid_ex *cur_network = &pmlmeinfo->network;
        struct sta_priv         *pstapriv = &padapter->stapriv;
-       u8      join_type;
-       u16 media_status;
 
-       if (join_res < 0)
-       {
-               join_type = 1;
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type));
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, null_addr);
+       if (join_res < 0) {
+               hw_var_set_mlme_join(padapter, 1);
+               hw_var_set_bssid(padapter, null_addr);
 
                /* restore to initial setting. */
-               update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode);
+               update_tx_basic_rate23a(padapter,
+                                       padapter->registrypriv.wireless_mode);
 
                goto exit_mlmeext_joinbss_event_callback23a;
        }
@@ -8719,15 +5407,15 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re
        }
 
        /* turn on dynamic functions */
-       Switch_DM_Func23a(padapter, DYNAMIC_ALL_FUNC_ENABLE, true);
+       rtl8723a_odm_support_ability_set(padapter, DYNAMIC_ALL_FUNC_ENABLE);
 
        /*  update IOT-releated issue */
        update_IOT_info23a(padapter);
 
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_BASIC_RATE, cur_network->SupportedRates);
+       HalSetBrateCfg23a(padapter, cur_network->SupportedRates);
 
        /* BCN interval */
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&pmlmeinfo->bcn_interval));
+       rtl8723a_set_beacon_interval(padapter, pmlmeinfo->bcn_interval);
 
        /* udpate capability */
        update_capinfo23a(padapter, pmlmeinfo->capability);
@@ -8752,18 +5440,13 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re
 
                /* set per sta rate after updating HT cap. */
                set_sta_rate23a(padapter, psta);
-
-               media_status = (psta->mac_id<<8)|1; /*   MACID|OPMODE: 1 means connect */
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status);
        }
 
-       join_type = 2;
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type));
+       hw_var_set_mlme_join(padapter, 2);
 
-       if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE)
-       {
+       if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) {
                /*  correcting TSF */
-               correct_TSF23a(padapter, pmlmeext);
+               rtw_correct_TSF(padapter);
 
                /* set_link_timer(pmlmeext, DISCONNECT_TO); */
        }
@@ -8778,7 +5461,6 @@ void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, struct sta_
 {
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
-       u8      join_type;
 
        DBG_8723A("%s\n", __func__);
 
@@ -8790,11 +5472,8 @@ void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, struct sta_
                }
                else/* adhoc client */
                {
-                       /* update TSF Value */
-                       /* update_TSF23a(pmlmeext, pframe, len); */
-
                        /*  correcting TSF */
-                       correct_TSF23a(padapter, pmlmeext);
+                       rtw_correct_TSF(padapter);
 
                        /* start beacon */
                        if (send_beacon23a(padapter) == _FAIL)
@@ -8810,8 +5489,7 @@ void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, struct sta_
 
                }
 
-               join_type = 2;
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type));
+               hw_var_set_mlme_join(padapter, 2);
        }
 
        pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta;
@@ -8832,8 +5510,8 @@ void mlmeext_sta_del_event_callback23a(struct rtw_adapter *padapter)
        {
                /* set_opmode_cmd(padapter, infra_client_with_mlme); */
 
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_DISCONNECT, NULL);
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, null_addr);
+               hw_var_set_mlme_disconnect(padapter);
+               hw_var_set_bssid(padapter, null_addr);
 
                /* restore to initial setting. */
                update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode);
@@ -8856,28 +5534,6 @@ void mlmeext_sta_del_event_callback23a(struct rtw_adapter *padapter)
        }
 }
 
-/****************************************************************************
-
-Following are the functions for the timer handlers
-
-*****************************************************************************/
-void linked23a_rx_sig_stren_disp(struct rtw_adapter *padapter)
-{
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
-       u8 mac_id;
-       int UndecoratedSmoothedPWDB;
-       if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE)
-               mac_id = 0;
-       else if ((pmlmeinfo->state&0x03) == _HW_STATE_AP_)
-               mac_id = 2;
-
-       rtw_hal_get_def_var23a(padapter, HW_DEF_RA_INFO_DUMP,&mac_id);
-
-       rtw_hal_get_def_var23a(padapter, HAL_DEF_UNDERCORATEDSMOOTHEDPWDB, &UndecoratedSmoothedPWDB);
-       DBG_8723A("UndecoratedSmoothedPWDB:%d\n", UndecoratedSmoothedPWDB);
-}
-
 static u8 chk_ap_is_alive(struct rtw_adapter *padapter, struct sta_info *psta)
 {
        u8 ret = false;
@@ -8902,9 +5558,6 @@ void linked_status_chk23a(struct rtw_adapter *padapter)
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct sta_priv         *pstapriv = &padapter->stapriv;
 
-       if (padapter->bRxRSSIDisplay)
-                linked23a_rx_sig_stren_disp(padapter);
-
        rtw_hal_sreset_linked_status_check23a(padapter);
 
        if (is_client_associated_to_ap23a(padapter))
@@ -8919,9 +5572,6 @@ void linked_status_chk23a(struct rtw_adapter *padapter)
                if ((psta = rtw_get_stainfo23a(pstapriv, pmlmeinfo->network.MacAddress)) != NULL)
                {
                        bool is_p2p_enable = false;
-#ifdef CONFIG_8723AU_P2P
-                       is_p2p_enable = !rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE);
-#endif
 
                        if (chk_ap_is_alive(padapter, psta) == false)
                                rx_chk = _FAIL;
@@ -9035,32 +5685,17 @@ static void survey_timer_hdl(unsigned long data)
        struct sitesurvey_parm *psurveyPara;
        struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-#endif
 
        /* issue rtw_sitesurvey_cmd23a */
        if (pmlmeext->sitesurvey_res.state > SCAN_START) {
                if (pmlmeext->sitesurvey_res.state ==  SCAN_PROCESS)
                        pmlmeext->sitesurvey_res.channel_idx++;
 
-               if (pmlmeext->scan_abort == true)
-               {
-#ifdef CONFIG_8723AU_P2P
-                       if (!rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE))
-                       {
-                               rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_MAX);
-                               pmlmeext->sitesurvey_res.channel_idx = 3;
-                               DBG_8723A("%s idx:%d, cnt:%u\n", __func__,
-                                         pmlmeext->sitesurvey_res.channel_idx,
-                                         pwdinfo->find_phase_state_exchange_cnt);
-                       } else
-                       #endif
-                       {
-                               pmlmeext->sitesurvey_res.channel_idx = pmlmeext->sitesurvey_res.ch_num;
-                               DBG_8723A("%s idx:%d\n", __func__,
-                                         pmlmeext->sitesurvey_res.channel_idx);
-                       }
+               if (pmlmeext->scan_abort == true) {
+                       pmlmeext->sitesurvey_res.channel_idx =
+                               pmlmeext->sitesurvey_res.ch_num;
+                       DBG_8723A("%s idx:%d\n", __func__,
+                                 pmlmeext->sitesurvey_res.channel_idx);
 
                        pmlmeext->scan_abort = false;/* reset */
                }
@@ -9177,50 +5812,42 @@ void init_mlme_ext_timer23a(struct rtw_adapter *padapter)
                    (unsigned long)padapter);
 }
 
-u8 NULL_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
+u8 NULL_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
        return H2C_SUCCESS;
 }
 
-u8 setopmode_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
+u8 setopmode_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
        u8      type;
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct setopmode_parm *psetop = (struct setopmode_parm *)pbuf;
+       const struct setopmode_parm *psetop = (struct setopmode_parm *)pbuf;
 
-       if (psetop->mode == Ndis802_11APMode)
-       {
+       if (psetop->mode == Ndis802_11APMode) {
                pmlmeinfo->state = WIFI_FW_AP_STATE;
                type = _HW_STATE_AP_;
-       }
-       else if (psetop->mode == Ndis802_11Infrastructure)
-       {
+       } else if (psetop->mode == Ndis802_11Infrastructure) {
                pmlmeinfo->state &= ~(BIT(0)|BIT(1));/*  clear state */
                pmlmeinfo->state |= WIFI_FW_STATION_STATE;/* set to     STATION_STATE */
                type = _HW_STATE_STATION_;
-       }
-       else if (psetop->mode == Ndis802_11IBSS)
-       {
+       } else if (psetop->mode == Ndis802_11IBSS)
                type = _HW_STATE_ADHOC_;
-       }
        else
-       {
                type = _HW_STATE_NOLINK_;
-       }
 
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_SET_OPMODE, (u8 *)(&type));
+       hw_var_set_opmode(padapter, type);
        /* Set_NETYPE0_MSR(padapter, type); */
 
        return H2C_SUCCESS;
 }
 
-u8 createbss_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
+u8 createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network;
-       struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf;
+       const struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf;
        /* u32  initialgain; */
 
        if (pparm->InfrastructureMode == Ndis802_11APMode) {
@@ -9249,12 +5876,10 @@ u8 createbss_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
                pmlmeinfo->candidate_tid_bitmap = 0;
 
                /* disable dynamic functions, such as high power, DIG */
-               Save_DM_Func_Flag23a(padapter);
-               Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false);
+               rtl8723a_odm_support_ability_backup(padapter);
 
-               /* config the initial gain under linking, need to write the BB registers */
-               /* initialgain = 0x1E; */
-               /* rtw_hal_set_hwreg23a(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); */
+               rtl8723a_odm_support_ability_clr(padapter,
+                                                DYNAMIC_FUNC_DISABLE);
 
                /* cancel link timer */
                del_timer_sync(&pmlmeext->link_timer);
@@ -9273,15 +5898,14 @@ u8 createbss_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
        return H2C_SUCCESS;
 }
 
-u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
+u8 join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
-       u8      join_type;
        struct ndis_802_11_var_ies *    pIE;
        struct registry_priv    *pregpriv = &padapter->registrypriv;
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network;
-       struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf;
+       const struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf;
        struct HT_info_element *pht_info;
        u32 i;
         /* u32 initialgain; */
@@ -9305,7 +5929,7 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
                /* Set_MSR23a(padapter, _HW_STATE_NOLINK_); */
                Set_MSR23a(padapter, _HW_STATE_STATION_);
 
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_DISCONNECT, NULL);
+               hw_var_set_mlme_disconnect(padapter);
        }
 
        rtw_joinbss_reset23a(padapter);
@@ -9337,16 +5961,16 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
 
                switch (pIE->ElementID)
                {
-               case _VENDOR_SPECIFIC_IE_:/* Get WMM IE. */
+               case WLAN_EID_VENDOR_SPECIFIC:/* Get WMM IE. */
                        if (!memcmp(pIE->data, WMM_OUI23A, 4))
                                pmlmeinfo->WMM_enable = 1;
                        break;
 
-               case _HT_CAPABILITY_IE_:        /* Get HT Cap IE. */
+               case WLAN_EID_HT_CAPABILITY:    /* Get HT Cap IE. */
                        pmlmeinfo->HT_caps_enable = 1;
                        break;
 
-               case _HT_EXTRA_INFO_IE_:        /* Get HT Info IE. */
+               case WLAN_EID_HT_OPERATION:     /* Get HT Info IE. */
                        pmlmeinfo->HT_info_enable = 1;
 
                        /* spec case only for cisco's ap because cisco's ap
@@ -9385,19 +6009,9 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
 
                i += (pIE->Length + 2);
        }
-       /* disable dynamic functions, such as high power, DIG */
-       /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); */
-
-       /* config the initial gain under linking, need to write the BB
-          registers */
-       /* initialgain = 0x1E; */
-       /* rtw_hal_set_hwreg23a(padapter, HW_VAR_INITIAL_GAIN,
-          (u8 *)(&initialgain)); */
 
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID,
-                         pmlmeinfo->network.MacAddress);
-       join_type = 0;
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type));
+       hw_var_set_bssid(padapter, pmlmeinfo->network.MacAddress);
+       hw_var_set_mlme_join(padapter, 0);
 
        /* cancel link timer */
        del_timer_sync(&pmlmeext->link_timer);
@@ -9407,13 +6021,12 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
        return H2C_SUCCESS;
 }
 
-u8 disconnect_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
+u8 disconnect_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
-       struct disconnect_parm *param = (struct disconnect_parm *)pbuf;
+       const struct disconnect_parm *param = (struct disconnect_parm *)pbuf;
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network;
-       u8      val8;
 
        if (is_client_associated_to_ap23a(padapter))
        {
@@ -9424,18 +6037,15 @@ u8 disconnect_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
 
        /* pmlmeinfo->state = WIFI_FW_NULL_STATE; */
 
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_DISCONNECT, NULL);
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, null_addr);
+       hw_var_set_mlme_disconnect(padapter);
+       hw_var_set_bssid(padapter, null_addr);
 
        /* restore to initial setting. */
        update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode);
 
-       if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE))
-       {
-               /* Stop BCN */
-               val8 = 0;
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_BCN_FUNC, (u8 *)(&val8));
-       }
+       if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) ||
+           ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE))
+               rtl8723a_set_bcn_func(padapter, 0);     /* Stop BCN */
 
        /* set MSR to no link state -> infra. mode */
        Set_MSR23a(padapter, _HW_STATE_STATION_);
@@ -9457,8 +6067,10 @@ u8 disconnect_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
        return  H2C_SUCCESS;
 }
 
-static int rtw_scan_ch_decision(struct rtw_adapter *padapter, struct rtw_ieee80211_channel *out,
-       u32 out_num, struct rtw_ieee80211_channel *in, u32 in_num)
+static int
+rtw_scan_ch_decision(struct rtw_adapter *padapter,
+                    struct rtw_ieee80211_channel *out, u32 out_num,
+                    const struct rtw_ieee80211_channel *in, u32 in_num)
 {
        int i, j;
        int scan_ch_num = 0;
@@ -9522,19 +6134,15 @@ static int rtw_scan_ch_decision(struct rtw_adapter *padapter, struct rtw_ieee802
        return j;
 }
 
-u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
+u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct sitesurvey_parm *pparm = (struct sitesurvey_parm *)pbuf;
+       const struct sitesurvey_parm *pparm = (struct sitesurvey_parm *)pbuf;
        u8 bdelayscan = false;
-       u8 val8;
        u32 initialgain;
        u32 i;
 
        if (pmlmeext->sitesurvey_res.state == SCAN_DISABLE) {
-               /* for first time sitesurvey_cmd */
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_CHECK_TXBUF, NULL);
-
                pmlmeext->sitesurvey_res.state = SCAN_START;
                pmlmeext->sitesurvey_res.bss_cnt = 0;
                pmlmeext->sitesurvey_res.channel_idx = 0;
@@ -9582,25 +6190,23 @@ u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
        if ((pmlmeext->sitesurvey_res.state == SCAN_START) ||
            (pmlmeext->sitesurvey_res.state == SCAN_TXNULL)) {
                /* disable dynamic functions, such as high power, DIG */
-               Save_DM_Func_Flag23a(padapter);
-               Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false);
+               rtl8723a_odm_support_ability_backup(padapter);
+               rtl8723a_odm_support_ability_clr(padapter,
+                                                DYNAMIC_FUNC_DISABLE);
 
                /* config the initial gain under scaning, need to
                   write the BB registers */
-               if ((wdev_to_priv(padapter->rtw_wdev))->p2p_enabled == true) {
+               if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled == true)
                        initialgain = 0x30;
-               else
+               else
                        initialgain = 0x1E;
 
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_INITIAL_GAIN,
-                                 (u8 *)(&initialgain));
+               rtl8723a_set_initial_gain(padapter, initialgain);
 
                /* set MSR to no link state */
                Set_MSR23a(padapter, _HW_STATE_NOLINK_);
 
-               val8 = 1; /* under site survey */
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_SITESURVEY,
-                                 (u8 *)(&val8));
+               rtl8723a_mlme_sitesurvey(padapter, 1);
 
                pmlmeext->sitesurvey_res.state = SCAN_PROCESS;
        }
@@ -9610,9 +6216,9 @@ u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
        return H2C_SUCCESS;
 }
 
-u8 setauth_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
+u8 setauth_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
-       struct setauth_parm             *pparm = (struct setauth_parm *)pbuf;
+       const struct setauth_parm *pparm = (struct setauth_parm *)pbuf;
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
 
@@ -9624,10 +6230,10 @@ u8 setauth_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
        return  H2C_SUCCESS;
 }
 
-u8 setkey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
+u8 setkey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
        unsigned short                          ctrl;
-       struct setkey_parm              *pparm = (struct setkey_parm *)pbuf;
+       const struct setkey_parm *pparm = (struct setkey_parm *)pbuf;
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        unsigned char                                   null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
@@ -9641,21 +6247,21 @@ u8 setkey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
 
        DBG_8723A_LEVEL(_drv_always_, "set group key to hw: alg:%d(WEP40-1 WEP104-5 TKIP-2 AES-4) "
                        "keyid:%d\n", pparm->algorithm, pparm->keyid);
-       write_cam23a(padapter, pparm->keyid, ctrl, null_sta, pparm->key);
+       rtl8723a_cam_write(padapter, pparm->keyid, ctrl, null_sta, pparm->key);
 
        /* allow multicast packets to driver */
-        padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_ON_RCR_AM, null_addr);
+       rtl8723a_on_rcr_am(padapter);
 
        return H2C_SUCCESS;
 }
 
-u8 set_stakey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
+u8 set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
        u16 ctrl = 0;
        u8 cam_id;/* cam_entry */
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
-       struct set_stakey_parm  *pparm = (struct set_stakey_parm *)pbuf;
+       const struct set_stakey_parm *pparm = (struct set_stakey_parm *)pbuf;
 
        /* cam_entry: */
        /* 0~3 for default key */
@@ -9705,7 +6311,8 @@ u8 set_stakey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
                                                pparm->addr[1], pparm->addr[2], pparm->addr[3], pparm->addr[4],
                                                pparm->addr[5], cam_id);
 
-                       write_cam23a(padapter, cam_id, ctrl, pparm->addr, pparm->key);
+                       rtl8723a_cam_write(padapter, cam_id, ctrl,
+                                          pparm->addr, pparm->key);
 
                        return H2C_SUCCESS_RSP;
 
@@ -9728,16 +6335,16 @@ u8 set_stakey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
 
        ctrl = BIT(15) | ((pparm->algorithm) << 2);
 
-       write_cam23a(padapter, cam_id, ctrl, pparm->addr, pparm->key);
+       rtl8723a_cam_write(padapter, cam_id, ctrl, pparm->addr, pparm->key);
 
        pmlmeinfo->enc_algo = pparm->algorithm;
 
        return H2C_SUCCESS;
 }
 
-u8 add_ba_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
+u8 add_ba_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
-       struct addBaReq_parm    *pparm = (struct addBaReq_parm *)pbuf;
+       const struct addBaReq_parm *pparm = (struct addBaReq_parm *)pbuf;
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
 
@@ -9805,11 +6412,11 @@ exit:
        return res;
 }
 
-u8 mlme_evt_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
+u8 mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
        u8 evt_code, evt_seq;
        u16 evt_sz;
-       uint    *peventbuf;
+       const uint *peventbuf;
        void (*event_callback)(struct rtw_adapter *dev, u8 *pbuf);
        struct evt_priv *pevt_priv = &padapter->evtpriv;
 
@@ -9848,7 +6455,7 @@ _abort_event_:
        return H2C_SUCCESS;
 }
 
-u8 h2c_msg_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
+u8 h2c_msg_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
        if (!pbuf)
                return H2C_PARAMETERS_ERROR;
@@ -9856,7 +6463,7 @@ u8 h2c_msg_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
        return H2C_SUCCESS;
 }
 
-u8 tx_beacon_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
+u8 tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
        if (send_beacon23a(padapter) == _FAIL)
        {
@@ -9915,9 +6522,9 @@ u8 tx_beacon_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
        return H2C_SUCCESS;
 }
 
-u8 set_ch_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
+u8 set_ch_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
-       struct set_ch_parm *set_ch_parm;
+       const struct set_ch_parm *set_ch_parm;
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
 
        if (!pbuf)
@@ -9938,9 +6545,9 @@ u8 set_ch_hdl23a(struct rtw_adapter *padapter, u8 *pbuf)
        return  H2C_SUCCESS;
 }
 
-u8 set_chplan_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
+u8 set_chplan_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
-       struct SetChannelPlan_param *setChannelPlan_param;
+       const struct SetChannelPlan_param *setChannelPlan_param;
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
 
        if (!pbuf)
@@ -9954,7 +6561,7 @@ u8 set_chplan_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
        return  H2C_SUCCESS;
 }
 
-u8 led_blink_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
+u8 led_blink_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
        struct LedBlink_param *ledBlink_param;
 
@@ -9966,7 +6573,7 @@ u8 led_blink_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
        return  H2C_SUCCESS;
 }
 
-u8 set_csa_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
+u8 set_csa_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
        return  H2C_REJECTED;
 }
@@ -9984,7 +6591,7 @@ u8 set_csa_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
 /*  TDLS_CKALV_PH1     : check alive timer phase1 */
 /*  TDLS_CKALV_PH2     : check alive timer phase2 */
 /*  TDLS_FREE_STA      : free tdls sta */
-u8 tdls_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
+u8 tdls_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
        return H2C_REJECTED;
 }
diff --git a/drivers/staging/rtl8723au/core/rtw_p2p.c b/drivers/staging/rtl8723au/core/rtw_p2p.c
deleted file mode 100644 (file)
index 1a961e3..0000000
+++ /dev/null
@@ -1,4001 +0,0 @@
-/******************************************************************************
- *
- * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- ******************************************************************************/
-#define _RTW_P2P_C_
-
-#include <drv_types.h>
-#include <rtw_p2p.h>
-#include <wifi.h>
-
-#ifdef CONFIG_8723AU_P2P
-
-static int rtw_p2p_is_channel_list_ok(u8 desired_ch, u8* ch_list, u8 ch_cnt)
-{
-       int found = 0, i = 0;
-
-       for (i = 0; i < ch_cnt; i++)
-       {
-               if (ch_list[ i ] == desired_ch)
-               {
-                       found = 1;
-                       break;
-               }
-       }
-       return found;
-}
-
-static int is_any_client_associated(struct rtw_adapter *padapter)
-{
-       return padapter->stapriv.asoc_list_cnt ? true : false;
-}
-
-static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf)
-{
-       struct list_head *phead, *plist;
-       u32 len = 0;
-       u16 attr_len = 0;
-       u8 tmplen, *pdata_attr, *pstart, *pcur;
-       struct sta_info *psta;
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-
-       DBG_8723A("%s\n", __func__);
-
-       pdata_attr = kzalloc(MAX_P2P_IE_LEN, GFP_ATOMIC);
-
-       pstart = pdata_attr;
-       pcur = pdata_attr;
-
-       spin_lock_bh(&pstapriv->asoc_list_lock);
-       phead = &pstapriv->asoc_list;
-
-       list_for_each(plist, phead) {
-               psta = container_of(plist, struct sta_info, asoc_list);
-
-               if (psta->is_p2p_device)
-               {
-                       tmplen = 0;
-
-                       pcur++;
-
-                       /* P2P device address */
-                       memcpy(pcur, psta->dev_addr, ETH_ALEN);
-                       pcur += ETH_ALEN;
-
-                       /* P2P interface address */
-                       memcpy(pcur, psta->hwaddr, ETH_ALEN);
-                       pcur += ETH_ALEN;
-
-                       *pcur = psta->dev_cap;
-                       pcur++;
-
-                       /* u16*)(pcur) = cpu_to_be16(psta->config_methods); */
-                       put_unaligned_be16(psta->config_methods, pcur);
-                       pcur += 2;
-
-                       memcpy(pcur, psta->primary_dev_type, 8);
-                       pcur += 8;
-
-                       *pcur = psta->num_of_secdev_type;
-                       pcur++;
-
-                       memcpy(pcur, psta->secdev_types_list, psta->num_of_secdev_type*8);
-                       pcur += psta->num_of_secdev_type*8;
-
-                       if (psta->dev_name_len>0)
-                       {
-                               /* u16*)(pcur) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */
-                               put_unaligned_be16(WPS_ATTR_DEVICE_NAME, pcur);
-                               pcur += 2;
-
-                               /* u16*)(pcur) = cpu_to_be16(psta->dev_name_len); */
-                               put_unaligned_be16(psta->dev_name_len, pcur);
-                               pcur += 2;
-
-                               memcpy(pcur, psta->dev_name, psta->dev_name_len);
-                               pcur += psta->dev_name_len;
-                       }
-
-                       tmplen = (u8)(pcur-pstart);
-
-                       *pstart = (tmplen-1);
-
-                       attr_len += tmplen;
-
-                       /* pstart += tmplen; */
-                       pstart = pcur;
-
-               }
-
-       }
-       spin_unlock_bh(&pstapriv->asoc_list_lock);
-
-       if (attr_len>0)
-       {
-               len = rtw_set_p2p_attr_content23a(pbuf, P2P_ATTR_GROUP_INFO, attr_len, pdata_attr);
-       }
-
-       kfree(pdata_attr);
-
-       return len;
-}
-
-static void issue_group_disc_req(struct wifidirect_info *pwdinfo, u8 *da)
-{
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr    *pwlanhdr;
-       unsigned short                          *fctrl;
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       unsigned char category = WLAN_CATEGORY_VENDOR_SPECIFIC;/* P2P action frame */
-       u32     p2poui = cpu_to_be32(P2POUI);
-       u8      oui_subtype = P2P_GO_DISC_REQUEST;
-       u8      dialogToken = 0;
-
-       DBG_8723A("[%s]\n", __func__);
-
-       if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL)
-       {
-               return;
-       }
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib23a(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *fctrl = 0;
-
-       memcpy(pwlanhdr->addr1, da, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, pwdinfo->interface_addr, ETH_ALEN);
-       memcpy(pwlanhdr->addr3, pwdinfo->interface_addr, ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       /* Build P2P action frame header */
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen);
-
-       /* there is no IE in this P2P action frame */
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe23a(padapter, pmgntframe);
-}
-
-static void issue_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 status, u8 dialogToken)
-{
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr    *pwlanhdr;
-       unsigned short                          *fctrl;
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       unsigned char category = WLAN_CATEGORY_PUBLIC;
-       u8                      action = P2P_PUB_ACTION_ACTION;
-       u32                     p2poui = cpu_to_be32(P2POUI);
-       u8                      oui_subtype = P2P_DEVDISC_RESP;
-       u8 p2pie[8] = { 0x00 };
-       u32 p2pielen = 0;
-
-       DBG_8723A("[%s]\n", __func__);
-
-       if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL)
-       {
-               return;
-       }
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib23a(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *fctrl = 0;
-
-       memcpy(pwlanhdr->addr1, da, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, pwdinfo->device_addr, ETH_ALEN);
-       memcpy(pwlanhdr->addr3, pwdinfo->device_addr, ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       /* Build P2P public action frame header */
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *) &p2poui,
-                                    &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen);
-
-       /* Build P2P IE */
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[ p2pielen++ ] = 0x50;
-       p2pie[ p2pielen++ ] = 0x6F;
-       p2pie[ p2pielen++ ] = 0x9A;
-       p2pie[ p2pielen++ ] = 0x09;     /*      WFA P2P v1.0 */
-
-       /*  P2P_ATTR_STATUS */
-       p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status);
-
-       pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, p2pie, &pattrib->pktlen);
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe23a(padapter, pmgntframe);
-}
-
-static void issue_p2p_provision_resp(struct wifidirect_info *pwdinfo, u8* raddr, u8* frame_body, u16 config_method)
-{
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       unsigned char category = WLAN_CATEGORY_PUBLIC;
-       u8                      action = P2P_PUB_ACTION_ACTION;
-       u8                      dialogToken = frame_body[7];    /*      The Dialog Token of provisioning discovery request frame. */
-       u32                     p2poui = cpu_to_be32(P2POUI);
-       u8                      oui_subtype = P2P_PROVISION_DISC_RESP;
-       u8                      wpsie[ 100 ] = { 0x00 };
-       u8                      wpsielen = 0;
-#ifdef CONFIG_8723AU_P2P
-       u32                                     wfdielen = 0;
-#endif /* CONFIG_8723AU_P2P */
-
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr    *pwlanhdr;
-       unsigned short                          *fctrl;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-
-       if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL)
-               return;
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib23a(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *fctrl = 0;
-
-       memcpy(pwlanhdr->addr1, raddr, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-       memcpy(pwlanhdr->addr3, myid(&padapter->eeprompriv), ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *) &p2poui,
-                                    &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen);
-
-       wpsielen = 0;
-       /*      WPS OUI */
-       /* u32*) (wpsie) = cpu_to_be32(WPSOUI); */
-       put_unaligned_be32(WPSOUI, wpsie);
-       wpsielen += 4;
-
-       /*      Config Method */
-       /*      Type: */
-       /* u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); */
-       put_unaligned_be16(WPS_ATTR_CONF_METHOD, wpsie + wpsielen);
-       wpsielen += 2;
-
-       /*      Length: */
-       /* u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002); */
-       put_unaligned_be16(0x0002, wpsie + wpsielen);
-       wpsielen += 2;
-
-       /*      Value: */
-       /* u16*) (wpsie + wpsielen) = cpu_to_be16(config_method); */
-       put_unaligned_be16(config_method, wpsie + wpsielen);
-       wpsielen += 2;
-
-       pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *) wpsie, &pattrib->pktlen);
-
-#ifdef CONFIG_8723AU_P2P
-       wfdielen = build_provdisc_resp_wfd_ie(pwdinfo, pframe);
-       pframe += wfdielen;
-       pattrib->pktlen += wfdielen;
-#endif /* CONFIG_8723AU_P2P */
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe23a(padapter, pmgntframe);
-
-       return;
-}
-
-static void issue_p2p_presence_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 status, u8 dialogToken)
-{
-       struct xmit_frame                       *pmgntframe;
-       struct pkt_attrib                       *pattrib;
-       unsigned char                                   *pframe;
-       struct ieee80211_hdr    *pwlanhdr;
-       unsigned short                          *fctrl;
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       unsigned char category = WLAN_CATEGORY_VENDOR_SPECIFIC;/* P2P action frame */
-       u32     p2poui = cpu_to_be32(P2POUI);
-       u8      oui_subtype = P2P_PRESENCE_RESPONSE;
-       u8 p2pie[ MAX_P2P_IE_LEN] = { 0x00 };
-       u8 noa_attr_content[32] = { 0x00 };
-       u32 p2pielen = 0;
-
-       DBG_8723A("[%s]\n", __func__);
-
-       if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL)
-       {
-               return;
-       }
-
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib23a(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *fctrl = 0;
-
-       memcpy(pwlanhdr->addr1, da, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, pwdinfo->interface_addr, ETH_ALEN);
-       memcpy(pwlanhdr->addr3, pwdinfo->interface_addr, ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       /* Build P2P action frame header */
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *) &p2poui,
-                                    &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen);
-
-       /* Add P2P IE header */
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[ p2pielen++ ] = 0x50;
-       p2pie[ p2pielen++ ] = 0x6F;
-       p2pie[ p2pielen++ ] = 0x9A;
-       p2pie[ p2pielen++ ] = 0x09;     /*      WFA P2P v1.0 */
-
-       /* Add Status attribute in P2P IE */
-       p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status);
-
-       /* Add NoA attribute in P2P IE */
-       noa_attr_content[0] = 0x1;/* index */
-       noa_attr_content[1] = 0x0;/* CTWindow and OppPS Parameters */
-
-       /* todo: Notice of Absence Descriptor(s) */
-
-       p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_NOA, 2, noa_attr_content);
-
-       pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, p2pie,
-                              &pattrib->pktlen);
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       dump_mgntframe23a(padapter, pmgntframe);
-}
-
-u32 build_beacon_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf)
-{
-       u8 p2pie[ MAX_P2P_IE_LEN] = { 0x00 };
-       u16 capability = 0;
-       u32 len = 0, p2pielen = 0;
-
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[ p2pielen++ ] = 0x50;
-       p2pie[ p2pielen++ ] = 0x6F;
-       p2pie[ p2pielen++ ] = 0x9A;
-       p2pie[ p2pielen++ ] = 0x09;     /*      WFA P2P v1.0 */
-
-       /*      According to the P2P Specification, the beacon frame should contain 3 P2P attributes */
-       /*      1. P2P Capability */
-       /*      2. P2P Device ID */
-       /*      3. Notice of Absence (NOA) */
-
-       /*      P2P Capability ATTR */
-       /*      Type: */
-       /*      Length: */
-       /*      Value: */
-       /*      Device Capability Bitmap, 1 byte */
-       /*      Be able to participate in additional P2P Groups and */
-       /*      support the P2P Invitation Procedure */
-       /*      Group Capability Bitmap, 1 byte */
-       capability = P2P_DEVCAP_INVITATION_PROC|P2P_DEVCAP_CLIENT_DISCOVERABILITY;
-       capability |=  ((P2P_GRPCAP_GO | P2P_GRPCAP_INTRABSS) << 8);
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING))
-               capability |= (P2P_GRPCAP_GROUP_FORMATION<<8);
-
-       capability = cpu_to_le16(capability);
-
-       p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_CAPABILITY, 2, (u8*)&capability);
-
-       /*  P2P Device ID ATTR */
-       p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_DEVICE_ID, ETH_ALEN, pwdinfo->device_addr);
-
-       /*  Notice of Absence ATTR */
-       /*      Type: */
-       /*      Length: */
-       /*      Value: */
-
-       /* go_add_noa_attr(pwdinfo); */
-
-       pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *) p2pie, &len);
-
-       return len;
-}
-
-#ifdef CONFIG_8723AU_P2P
-u32 build_beacon_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
-{
-       u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 };
-       u32 len = 0, wfdielen = 0;
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct wifi_display_info*       pwfd_info = padapter->wdinfo.wfd_info;
-
-       /*      WFD OUI */
-       wfdielen = 0;
-       wfdie[ wfdielen++ ] = 0x50;
-       wfdie[ wfdielen++ ] = 0x6F;
-       wfdie[ wfdielen++ ] = 0x9A;
-       wfdie[ wfdielen++ ] = 0x0A;     /*      WFA WFD v1.0 */
-
-       /*      Commented by Albert 20110812 */
-       /*      According to the WFD Specification, the beacon frame should contain 4 WFD attributes */
-       /*      1. WFD Device Information */
-       /*      2. Associated BSSID */
-       /*      3. Coupled Sink Information */
-
-       /*      WFD Device Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value1: */
-       /*      WFD device information */
-
-       if (P2P_ROLE_GO == pwdinfo->role)
-       {
-               if (is_any_client_associated(pwdinfo->padapter))
-               {
-                       /*      WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) */
-                       put_unaligned_be16(pwfd_info->wfd_device_type |
-                                          WFD_DEVINFO_WSD, wfdie + wfdielen);
-               }
-               else
-               {
-                       /*      WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
-                       put_unaligned_be16(pwfd_info->wfd_device_type |
-                                          WFD_DEVINFO_SESSION_AVAIL |
-                                          WFD_DEVINFO_WSD, wfdie + wfdielen);
-               }
-
-       }
-       else
-       {
-               /*      WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
-               put_unaligned_be16(pwfd_info->wfd_device_type |
-                                  WFD_DEVINFO_SESSION_AVAIL |
-                                  WFD_DEVINFO_WSD, wfdie + wfdielen);
-       }
-
-       wfdielen += 2;
-
-       /*      Value2: */
-       /*      Session Management Control Port */
-       /*      Default TCP port for RTSP messages is 554 */
-       put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value3: */
-       /*      WFD Device Maximum Throughput */
-       /*      300Mbps is the maximum throughput */
-       put_unaligned_be16(300, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Associated BSSID ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Associated BSSID */
-       if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
-       {
-               memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN);
-       }
-       else
-       {
-               memset(wfdie + wfdielen, 0x00, ETH_ALEN);
-       }
-
-       wfdielen += ETH_ALEN;
-
-       /*      Coupled Sink Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0007, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Coupled Sink Status bitmap */
-       /*      Not coupled/available for Coupling */
-       wfdie[ wfdielen++ ] = 0;
-       /*   MAC Addr. */
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-
-       pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len);
-
-       return len;
-}
-
-u32 build_probe_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
-{
-       u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 };
-       u32 len = 0, wfdielen = 0;
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct wifi_display_info*       pwfd_info = padapter->wdinfo.wfd_info;
-
-       /*      WFD OUI */
-       wfdielen = 0;
-       wfdie[ wfdielen++ ] = 0x50;
-       wfdie[ wfdielen++ ] = 0x6F;
-       wfdie[ wfdielen++ ] = 0x9A;
-       wfdie[ wfdielen++ ] = 0x0A;     /*      WFA WFD v1.0 */
-
-       /*      Commented by Albert 20110812 */
-       /*      According to the WFD Specification, the probe request frame should contain 4 WFD attributes */
-       /*      1. WFD Device Information */
-       /*      2. Associated BSSID */
-       /*      3. Coupled Sink Information */
-
-       /*      WFD Device Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value1: */
-       /*      WFD device information */
-
-       if (1 == pwdinfo->wfd_tdls_enable)
-       {
-               /*      WFD primary sink + available for WFD session + WiFi TDLS mode + WSC (WFD Service Discovery) */
-               put_unaligned_be16(pwfd_info->wfd_device_type |
-                                  WFD_DEVINFO_SESSION_AVAIL |
-                                  WFD_DEVINFO_WSD |
-                                  WFD_DEVINFO_PC_TDLS, wfdie + wfdielen);
-       }
-       else
-       {
-               /*      WFD primary sink + available for WFD session + WiFi Direct mode + WSC (WFD Service Discovery) */
-               put_unaligned_be16(pwfd_info->wfd_device_type |
-                                  WFD_DEVINFO_SESSION_AVAIL |
-                                  WFD_DEVINFO_WSD, wfdie + wfdielen);
-       }
-
-       wfdielen += 2;
-
-       /*      Value2: */
-       /*      Session Management Control Port */
-       /*      Default TCP port for RTSP messages is 554 */
-       put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value3: */
-       /*      WFD Device Maximum Throughput */
-       /*      300Mbps is the maximum throughput */
-       put_unaligned_be16(300, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Associated BSSID ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Associated BSSID */
-       if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
-       {
-               memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN);
-       }
-       else
-       {
-               memset(wfdie + wfdielen, 0x00, ETH_ALEN);
-       }
-
-       wfdielen += ETH_ALEN;
-
-       /*      Coupled Sink Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0007, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Coupled Sink Status bitmap */
-       /*      Not coupled/available for Coupling */
-       wfdie[ wfdielen++ ] = 0;
-       /*   MAC Addr. */
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-
-       pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len);
-
-       return len;
-}
-
-u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 tunneled)
-{
-       u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 };
-       u32 len = 0, wfdielen = 0;
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct wifi_display_info*       pwfd_info = padapter->wdinfo.wfd_info;
-
-       /*      WFD OUI */
-       wfdielen = 0;
-       wfdie[ wfdielen++ ] = 0x50;
-       wfdie[ wfdielen++ ] = 0x6F;
-       wfdie[ wfdielen++ ] = 0x9A;
-       wfdie[ wfdielen++ ] = 0x0A;     /*      WFA WFD v1.0 */
-
-       /*      Commented by Albert 20110812 */
-       /*      According to the WFD Specification, the probe response frame should contain 4 WFD attributes */
-       /*      1. WFD Device Information */
-       /*      2. Associated BSSID */
-       /*      3. Coupled Sink Information */
-       /*      4. WFD Session Information */
-
-       /*      WFD Device Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value1: */
-       /*      WFD device information */
-       /*      WFD primary sink + available for WFD session + WiFi Direct mode */
-
-       if (true == pwdinfo->session_available)
-       {
-               if (P2P_ROLE_GO == pwdinfo->role)
-               {
-                       if (is_any_client_associated(pwdinfo->padapter))
-                       {
-                               if (pwdinfo->wfd_tdls_enable)
-                               {
-                                       /*      TDLS mode + WSD (WFD Service Discovery) */
-                                       put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_WSD | WFD_DEVINFO_PC_TDLS | WFD_DEVINFO_HDCP_SUPPORT, wfdie + wfdielen);
-                               }
-                               else
-                               {
-                                       /*      WiFi Direct mode + WSD (WFD Service Discovery) */
-                                       put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_WSD | WFD_DEVINFO_HDCP_SUPPORT, wfdie + wfdielen);
-                               }
-                       }
-                       else
-                       {
-                               if (pwdinfo->wfd_tdls_enable)
-                               {
-                                       /*      available for WFD session + TDLS mode + WSD (WFD Service Discovery) */
-                                       put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD | WFD_DEVINFO_PC_TDLS | WFD_DEVINFO_HDCP_SUPPORT, wfdie + wfdielen);
-                               }
-                               else
-                               {
-                                       /*      available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
-                                       put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD | WFD_DEVINFO_HDCP_SUPPORT, wfdie + wfdielen);
-                               }
-                       }
-               }
-               else
-               {
-                       if (pwdinfo->wfd_tdls_enable)
-                       {
-                               /*      available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
-                               put_unaligned_be16(pwfd_info->wfd_device_type |
-                                                  WFD_DEVINFO_SESSION_AVAIL |
-                                                  WFD_DEVINFO_WSD |
-                                                  WFD_DEVINFO_PC_TDLS |
-                                                  WFD_DEVINFO_HDCP_SUPPORT,
-                                                  wfdie + wfdielen);
-                       }
-                       else
-                       {
-
-                               /*      available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
-                               put_unaligned_be16(pwfd_info->wfd_device_type |
-                                                  WFD_DEVINFO_SESSION_AVAIL |
-                                                  WFD_DEVINFO_WSD |
-                                                  WFD_DEVINFO_HDCP_SUPPORT,
-                                                  wfdie + wfdielen);
-                       }
-               }
-       }
-       else
-       {
-               if (pwdinfo->wfd_tdls_enable)
-               {
-                       put_unaligned_be16(pwfd_info->wfd_device_type |
-                                          WFD_DEVINFO_WSD |
-                                          WFD_DEVINFO_PC_TDLS |
-                                          WFD_DEVINFO_HDCP_SUPPORT,
-                                          wfdie + wfdielen);
-               }
-               else
-               {
-                       put_unaligned_be16(pwfd_info->wfd_device_type |
-                                          WFD_DEVINFO_WSD |
-                                          WFD_DEVINFO_HDCP_SUPPORT,
-                                          wfdie + wfdielen);
-               }
-
-       }
-
-       wfdielen += 2;
-
-       /*      Value2: */
-       /*      Session Management Control Port */
-       /*      Default TCP port for RTSP messages is 554 */
-       put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value3: */
-       /*      WFD Device Maximum Throughput */
-       /*      300Mbps is the maximum throughput */
-       put_unaligned_be16(300, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Associated BSSID ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Associated BSSID */
-       if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
-       {
-               memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN);
-       }
-       else
-       {
-               memset(wfdie + wfdielen, 0x00, ETH_ALEN);
-       }
-
-       wfdielen += ETH_ALEN;
-
-       /*      Coupled Sink Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0007, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Coupled Sink Status bitmap */
-       /*      Not coupled/available for Coupling */
-       wfdie[ wfdielen++ ] = 0;
-       /*   MAC Addr. */
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO))
-       {
-               /*      WFD Session Information ATTR */
-               /*      Type: */
-               wfdie[ wfdielen++ ] = WFD_ATTR_SESSION_INFO;
-
-               /*      Length: */
-               /*      Note: In the WFD specification, the size of length field is 2. */
-               put_unaligned_be16(0x0000, wfdie + wfdielen);
-               wfdielen += 2;
-
-               /*      Todo: to add the list of WFD device info descriptor in WFD group. */
-
-       }
-
-       pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len);
-
-       return len;
-}
-
-u32 build_assoc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
-{
-       u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 };
-       u32 len = 0, wfdielen = 0;
-       struct rtw_adapter                                      *padapter = NULL;
-       struct mlme_priv                        *pmlmepriv = NULL;
-       struct wifi_display_info                *pwfd_info = NULL;
-
-       /*      WFD OUI */
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE))
-       {
-               return 0;
-       }
-
-       padapter = pwdinfo->padapter;
-       pmlmepriv = &padapter->mlmepriv;
-       pwfd_info = padapter->wdinfo.wfd_info;
-
-       wfdielen = 0;
-       wfdie[ wfdielen++ ] = 0x50;
-       wfdie[ wfdielen++ ] = 0x6F;
-       wfdie[ wfdielen++ ] = 0x9A;
-       wfdie[ wfdielen++ ] = 0x0A;     /*      WFA WFD v1.0 */
-
-       /*      Commented by Albert 20110812 */
-       /*      According to the WFD Specification, the probe request frame should contain 4 WFD attributes */
-       /*      1. WFD Device Information */
-       /*      2. Associated BSSID */
-       /*      3. Coupled Sink Information */
-
-       /*      WFD Device Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value1: */
-       /*      WFD device information */
-       /*      WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
-       put_unaligned_be16(pwfd_info->wfd_device_type |
-                          WFD_DEVINFO_SESSION_AVAIL |
-                          WFD_DEVINFO_WSD, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value2: */
-       /*      Session Management Control Port */
-       /*      Default TCP port for RTSP messages is 554 */
-       put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value3: */
-       /*      WFD Device Maximum Throughput */
-       /*      300Mbps is the maximum throughput */
-       put_unaligned_be16(300, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Associated BSSID ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Associated BSSID */
-       if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
-       {
-               memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN);
-       }
-       else
-       {
-               memset(wfdie + wfdielen, 0x00, ETH_ALEN);
-       }
-
-       wfdielen += ETH_ALEN;
-
-       /*      Coupled Sink Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0007, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Coupled Sink Status bitmap */
-       /*      Not coupled/available for Coupling */
-       wfdie[ wfdielen++ ] = 0;
-       /*   MAC Addr. */
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-
-       pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len);
-
-       return len;
-}
-
-u32 build_assoc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
-{
-       u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 };
-       u32 len = 0, wfdielen = 0;
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct wifi_display_info*       pwfd_info = padapter->wdinfo.wfd_info;
-
-       /*      WFD OUI */
-       wfdielen = 0;
-       wfdie[ wfdielen++ ] = 0x50;
-       wfdie[ wfdielen++ ] = 0x6F;
-       wfdie[ wfdielen++ ] = 0x9A;
-       wfdie[ wfdielen++ ] = 0x0A;     /*      WFA WFD v1.0 */
-
-       /*      Commented by Albert 20110812 */
-       /*      According to the WFD Specification, the probe request frame should contain 4 WFD attributes */
-       /*      1. WFD Device Information */
-       /*      2. Associated BSSID */
-       /*      3. Coupled Sink Information */
-
-       /*      WFD Device Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value1: */
-       /*      WFD device information */
-       /*      WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
-       put_unaligned_be16(pwfd_info->wfd_device_type |
-                          WFD_DEVINFO_SESSION_AVAIL |
-                          WFD_DEVINFO_WSD, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value2: */
-       /*      Session Management Control Port */
-       /*      Default TCP port for RTSP messages is 554 */
-       put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value3: */
-       /*      WFD Device Maximum Throughput */
-       /*      300Mbps is the maximum throughput */
-       put_unaligned_be16(300, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Associated BSSID ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Associated BSSID */
-       if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
-       {
-               memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN);
-       }
-       else
-       {
-               memset(wfdie + wfdielen, 0x00, ETH_ALEN);
-       }
-
-       wfdielen += ETH_ALEN;
-
-       /*      Coupled Sink Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0007, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Coupled Sink Status bitmap */
-       /*      Not coupled/available for Coupling */
-       wfdie[ wfdielen++ ] = 0;
-       /*   MAC Addr. */
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-
-       pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len);
-
-       return len;
-}
-
-u32 build_nego_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
-{
-       u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 };
-       u32 len = 0, wfdielen = 0;
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct wifi_display_info*       pwfd_info = padapter->wdinfo.wfd_info;
-
-       /*      WFD OUI */
-       wfdielen = 0;
-       wfdie[ wfdielen++ ] = 0x50;
-       wfdie[ wfdielen++ ] = 0x6F;
-       wfdie[ wfdielen++ ] = 0x9A;
-       wfdie[ wfdielen++ ] = 0x0A;     /*      WFA WFD v1.0 */
-
-       /*      Commented by Albert 20110825 */
-       /*      According to the WFD Specification, the negotiation request frame should contain 3 WFD attributes */
-       /*      1. WFD Device Information */
-       /*      2. Associated BSSID (Optional) */
-       /*      3. Local IP Adress (Optional) */
-
-       /*      WFD Device Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value1: */
-       /*      WFD device information */
-       /*      WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) + WFD Session Available */
-       put_unaligned_be16(pwfd_info->wfd_device_type |
-                          WFD_DEVINFO_WSD | WFD_DEVINFO_SESSION_AVAIL,
-                          wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value2: */
-       /*      Session Management Control Port */
-       /*      Default TCP port for RTSP messages is 554 */
-       put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value3: */
-       /*      WFD Device Maximum Throughput */
-       /*      300Mbps is the maximum throughput */
-       put_unaligned_be16(300, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Associated BSSID ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Associated BSSID */
-       if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
-       {
-               memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN);
-       }
-       else
-       {
-               memset(wfdie + wfdielen, 0x00, ETH_ALEN);
-       }
-
-       wfdielen += ETH_ALEN;
-
-       /*      Coupled Sink Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0007, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Coupled Sink Status bitmap */
-       /*      Not coupled/available for Coupling */
-       wfdie[ wfdielen++ ] = 0;
-       /*   MAC Addr. */
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-
-       pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len);
-
-       return len;
-}
-
-u32 build_nego_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
-{
-       u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 };
-       u32 len = 0, wfdielen = 0;
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct wifi_display_info*       pwfd_info = padapter->wdinfo.wfd_info;
-
-       /*      WFD OUI */
-       wfdielen = 0;
-       wfdie[ wfdielen++ ] = 0x50;
-       wfdie[ wfdielen++ ] = 0x6F;
-       wfdie[ wfdielen++ ] = 0x9A;
-       wfdie[ wfdielen++ ] = 0x0A;     /*      WFA WFD v1.0 */
-
-       /*      Commented by Albert 20110825 */
-       /*      According to the WFD Specification, the negotiation request frame should contain 3 WFD attributes */
-       /*      1. WFD Device Information */
-       /*      2. Associated BSSID (Optional) */
-       /*      3. Local IP Adress (Optional) */
-
-       /*      WFD Device Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value1: */
-       /*      WFD device information */
-       /*      WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) + WFD Session Available */
-       put_unaligned_be16(pwfd_info->wfd_device_type |
-                          WFD_DEVINFO_WSD | WFD_DEVINFO_SESSION_AVAIL,
-                          wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value2: */
-       /*      Session Management Control Port */
-       /*      Default TCP port for RTSP messages is 554 */
-       put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value3: */
-       /*      WFD Device Maximum Throughput */
-       /*      300Mbps is the maximum throughput */
-       put_unaligned_be16(300, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Associated BSSID ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Associated BSSID */
-       if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
-       {
-               memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN);
-       }
-       else
-       {
-               memset(wfdie + wfdielen, 0x00, ETH_ALEN);
-       }
-
-       wfdielen += ETH_ALEN;
-
-       /*      Coupled Sink Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0007, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Coupled Sink Status bitmap */
-       /*      Not coupled/available for Coupling */
-       wfdie[ wfdielen++ ] = 0;
-       /*   MAC Addr. */
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-
-       pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len);
-
-       return len;
-}
-
-u32 build_nego_confirm_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
-{
-       u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 };
-       u32 len = 0, wfdielen = 0;
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct wifi_display_info*       pwfd_info = padapter->wdinfo.wfd_info;
-
-       /*      WFD OUI */
-       wfdielen = 0;
-       wfdie[ wfdielen++ ] = 0x50;
-       wfdie[ wfdielen++ ] = 0x6F;
-       wfdie[ wfdielen++ ] = 0x9A;
-       wfdie[ wfdielen++ ] = 0x0A;     /*      WFA WFD v1.0 */
-
-       /*      Commented by Albert 20110825 */
-       /*      According to the WFD Specification, the negotiation request frame should contain 3 WFD attributes */
-       /*      1. WFD Device Information */
-       /*      2. Associated BSSID (Optional) */
-       /*      3. Local IP Adress (Optional) */
-
-       /*      WFD Device Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value1: */
-       /*      WFD device information */
-       /*      WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) + WFD Session Available */
-       put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_WSD |
-                          WFD_DEVINFO_SESSION_AVAIL, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value2: */
-       /*      Session Management Control Port */
-       /*      Default TCP port for RTSP messages is 554 */
-       put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value3: */
-       /*      WFD Device Maximum Throughput */
-       /*      300Mbps is the maximum throughput */
-       put_unaligned_be16(300, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Associated BSSID ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Associated BSSID */
-       if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
-       {
-               memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN);
-       }
-       else
-       {
-               memset(wfdie + wfdielen, 0x00, ETH_ALEN);
-       }
-
-       wfdielen += ETH_ALEN;
-
-       /*      Coupled Sink Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0007, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Coupled Sink Status bitmap */
-       /*      Not coupled/available for Coupling */
-       wfdie[ wfdielen++ ] = 0;
-       /*   MAC Addr. */
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-
-       pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len);
-
-       return len;
-}
-
-u32 build_invitation_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
-{
-       u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 };
-       u32 len = 0, wfdielen = 0;
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct wifi_display_info*       pwfd_info = padapter->wdinfo.wfd_info;
-
-       /*      WFD OUI */
-       wfdielen = 0;
-       wfdie[ wfdielen++ ] = 0x50;
-       wfdie[ wfdielen++ ] = 0x6F;
-       wfdie[ wfdielen++ ] = 0x9A;
-       wfdie[ wfdielen++ ] = 0x0A;     /*      WFA WFD v1.0 */
-
-       /*      Commented by Albert 20110825 */
-       /*      According to the WFD Specification, the provision discovery request frame should contain 3 WFD attributes */
-       /*      1. WFD Device Information */
-       /*      2. Associated BSSID (Optional) */
-       /*      3. Local IP Adress (Optional) */
-
-       /*      WFD Device Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value1: */
-       /*      WFD device information */
-       /*      WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
-       put_unaligned_be16(pwfd_info->wfd_device_type |
-                          WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD,
-                          wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value2: */
-       /*      Session Management Control Port */
-       /*      Default TCP port for RTSP messages is 554 */
-       put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value3: */
-       /*      WFD Device Maximum Throughput */
-       /*      300Mbps is the maximum throughput */
-       put_unaligned_be16(300, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Associated BSSID ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Associated BSSID */
-       if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
-       {
-               memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN);
-       }
-       else
-       {
-               memset(wfdie + wfdielen, 0x00, ETH_ALEN);
-       }
-
-       wfdielen += ETH_ALEN;
-
-       /*      Coupled Sink Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0007, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Coupled Sink Status bitmap */
-       /*      Not coupled/available for Coupling */
-       wfdie[ wfdielen++ ] = 0;
-       /*   MAC Addr. */
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-
-       if (P2P_ROLE_GO == pwdinfo->role)
-       {
-               /*      WFD Session Information ATTR */
-               /*      Type: */
-               wfdie[ wfdielen++ ] = WFD_ATTR_SESSION_INFO;
-
-               /*      Length: */
-               /*      Note: In the WFD specification, the size of length field is 2. */
-               put_unaligned_be16(0x0000, wfdie + wfdielen);
-               wfdielen += 2;
-
-               /*      Todo: to add the list of WFD device info descriptor in WFD group. */
-
-       }
-
-       pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len);
-
-       return len;
-}
-
-u32 build_invitation_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
-{
-       u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 };
-       u32 len = 0, wfdielen = 0;
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct wifi_display_info*       pwfd_info = padapter->wdinfo.wfd_info;
-
-       /*      WFD OUI */
-       wfdielen = 0;
-       wfdie[ wfdielen++ ] = 0x50;
-       wfdie[ wfdielen++ ] = 0x6F;
-       wfdie[ wfdielen++ ] = 0x9A;
-       wfdie[ wfdielen++ ] = 0x0A;     /*      WFA WFD v1.0 */
-
-       /*      Commented by Albert 20110825 */
-       /*      According to the WFD Specification, the provision discovery request frame should contain 3 WFD attributes */
-       /*      1. WFD Device Information */
-       /*      2. Associated BSSID (Optional) */
-       /*      3. Local IP Adress (Optional) */
-
-       /*      WFD Device Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value1: */
-       /*      WFD device information */
-       /*      WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
-       put_unaligned_be16(pwfd_info->wfd_device_type |
-                          WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD,
-                          wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value2: */
-       /*      Session Management Control Port */
-       /*      Default TCP port for RTSP messages is 554 */
-       put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value3: */
-       /*      WFD Device Maximum Throughput */
-       /*      300Mbps is the maximum throughput */
-       put_unaligned_be16(300, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Associated BSSID ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Associated BSSID */
-       if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
-       {
-               memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN);
-       }
-       else
-       {
-               memset(wfdie + wfdielen, 0x00, ETH_ALEN);
-       }
-
-       wfdielen += ETH_ALEN;
-
-       /*      Coupled Sink Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0007, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Coupled Sink Status bitmap */
-       /*      Not coupled/available for Coupling */
-       wfdie[ wfdielen++ ] = 0;
-       /*   MAC Addr. */
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-
-       if (P2P_ROLE_GO == pwdinfo->role)
-       {
-               /*      WFD Session Information ATTR */
-               /*      Type: */
-               wfdie[ wfdielen++ ] = WFD_ATTR_SESSION_INFO;
-
-               /*      Length: */
-               /*      Note: In the WFD specification, the size of length field is 2. */
-               put_unaligned_be16(0x0000, wfdie + wfdielen);
-               wfdielen += 2;
-
-               /*      Todo: to add the list of WFD device info descriptor in WFD group. */
-
-       }
-
-       pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len);
-
-       return len;
-}
-
-u32 build_provdisc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
-{
-       u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 };
-       u32 len = 0, wfdielen = 0;
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct wifi_display_info*       pwfd_info = padapter->wdinfo.wfd_info;
-
-       /*      WFD OUI */
-       wfdielen = 0;
-       wfdie[ wfdielen++ ] = 0x50;
-       wfdie[ wfdielen++ ] = 0x6F;
-       wfdie[ wfdielen++ ] = 0x9A;
-       wfdie[ wfdielen++ ] = 0x0A;     /*      WFA WFD v1.0 */
-
-       /*      Commented by Albert 20110825 */
-       /*      According to the WFD Specification, the provision discovery request frame should contain 3 WFD attributes */
-       /*      1. WFD Device Information */
-       /*      2. Associated BSSID (Optional) */
-       /*      3. Local IP Adress (Optional) */
-
-       /*      WFD Device Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value1: */
-       /*      WFD device information */
-       /*      WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
-       put_unaligned_be16(pwfd_info->wfd_device_type |
-                          WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD,
-                          wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value2: */
-       /*      Session Management Control Port */
-       /*      Default TCP port for RTSP messages is 554 */
-       put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value3: */
-       /*      WFD Device Maximum Throughput */
-       /*      300Mbps is the maximum throughput */
-       put_unaligned_be16(300, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Associated BSSID ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Associated BSSID */
-       if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
-       {
-               memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN);
-       }
-       else
-       {
-               memset(wfdie + wfdielen, 0x00, ETH_ALEN);
-       }
-
-       wfdielen += ETH_ALEN;
-
-       /*      Coupled Sink Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0007, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Coupled Sink Status bitmap */
-       /*      Not coupled/available for Coupling */
-       wfdie[ wfdielen++ ] = 0;
-       /*   MAC Addr. */
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-
-       pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len);
-
-       return len;
-}
-
-u32 build_provdisc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
-{
-       u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 };
-       u32 len = 0, wfdielen = 0;
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct wifi_display_info*       pwfd_info = padapter->wdinfo.wfd_info;
-
-       /*      WFD OUI */
-       wfdielen = 0;
-       wfdie[ wfdielen++ ] = 0x50;
-       wfdie[ wfdielen++ ] = 0x6F;
-       wfdie[ wfdielen++ ] = 0x9A;
-       wfdie[ wfdielen++ ] = 0x0A;     /*      WFA WFD v1.0 */
-
-       /*      Commented by Albert 20110825 */
-       /*      According to the WFD Specification, the provision discovery response frame should contain 3 WFD attributes */
-       /*      1. WFD Device Information */
-       /*      2. Associated BSSID (Optional) */
-       /*      3. Local IP Adress (Optional) */
-
-       /*      WFD Device Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value1: */
-       /*      WFD device information */
-       /*      WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
-       put_unaligned_be16(pwfd_info->wfd_device_type |
-                          WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD,
-                          wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value2: */
-       /*      Session Management Control Port */
-       /*      Default TCP port for RTSP messages is 554 */
-       put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value3: */
-       /*      WFD Device Maximum Throughput */
-       /*      300Mbps is the maximum throughput */
-       put_unaligned_be16(300, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Associated BSSID ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0006, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Associated BSSID */
-       if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
-       {
-               memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN);
-       }
-       else
-       {
-               memset(wfdie + wfdielen, 0x00, ETH_ALEN);
-       }
-
-       wfdielen += ETH_ALEN;
-
-       /*      Coupled Sink Information ATTR */
-       /*      Type: */
-       wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO;
-
-       /*      Length: */
-       /*      Note: In the WFD specification, the size of length field is 2. */
-       put_unaligned_be16(0x0007, wfdie + wfdielen);
-       wfdielen += 2;
-
-       /*      Value: */
-       /*      Coupled Sink Status bitmap */
-       /*      Not coupled/available for Coupling */
-       wfdie[ wfdielen++ ] = 0;
-       /*   MAC Addr. */
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-       wfdie[ wfdielen++ ] = 0;
-
-       pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len);
-
-       return len;
-}
-
-#endif /* CONFIG_8723AU_P2P */
-
-u32 build_probe_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf)
-{
-       u8 p2pie[ MAX_P2P_IE_LEN] = { 0x00 };
-       u32 len = 0, p2pielen = 0;
-
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[ p2pielen++ ] = 0x50;
-       p2pie[ p2pielen++ ] = 0x6F;
-       p2pie[ p2pielen++ ] = 0x9A;
-       p2pie[ p2pielen++ ] = 0x09;     /*      WFA P2P v1.0 */
-
-       /*      Commented by Albert 20100907 */
-       /*      According to the P2P Specification, the probe response frame should contain 5 P2P attributes */
-       /*      1. P2P Capability */
-       /*      2. Extended Listen Timing */
-       /*      3. Notice of Absence (NOA)      (Only GO needs this) */
-       /*      4. Device Info */
-       /*      5. Group Info   (Only GO need this) */
-
-       /*      P2P Capability ATTR */
-       /*      Type: */
-       p2pie[ p2pielen++ ] = P2P_ATTR_CAPABILITY;
-
-       /*      Length: */
-       /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); */
-       put_unaligned_le16(0x0002, p2pie + p2pielen);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Device Capability Bitmap, 1 byte */
-       p2pie[ p2pielen++ ] = DMP_P2P_DEVCAP_SUPPORT;
-
-       /*      Group Capability Bitmap, 1 byte */
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO))
-       {
-               p2pie[ p2pielen ] = (P2P_GRPCAP_GO | P2P_GRPCAP_INTRABSS);
-
-               if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING))
-                       p2pie[ p2pielen ] |= P2P_GRPCAP_GROUP_FORMATION;
-
-               p2pielen++;
-       }
-       else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE))
-       {
-               /*      Group Capability Bitmap, 1 byte */
-               if (pwdinfo->persistent_supported)
-                       p2pie[ p2pielen++ ] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT;
-               else
-                       p2pie[ p2pielen++ ] = DMP_P2P_GRPCAP_SUPPORT;
-       }
-
-       /*      Extended Listen Timing ATTR */
-       /*      Type: */
-       p2pie[ p2pielen++ ] = P2P_ATTR_EX_LISTEN_TIMING;
-
-       /*      Length: */
-       /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0004); */
-       put_unaligned_le16(0x0004, p2pie + p2pielen);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Availability Period */
-       /* u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); */
-       put_unaligned_le16(0xFFFF, p2pie + p2pielen);
-       p2pielen += 2;
-
-       /*      Availability Interval */
-       /* u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); */
-       put_unaligned_le16(0xFFFF, p2pie + p2pielen);
-       p2pielen += 2;
-
-       /*  Notice of Absence ATTR */
-       /*      Type: */
-       /*      Length: */
-       /*      Value: */
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO))
-       {
-               /* go_add_noa_attr(pwdinfo); */
-       }
-
-       /*      Device Info ATTR */
-       /*      Type: */
-       p2pie[ p2pielen++ ] = P2P_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */
-       /*      + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */
-       /* u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); */
-       put_unaligned_le16(21 + pwdinfo->device_name_len, p2pie + p2pielen);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      P2P Device Address */
-       memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN);
-       p2pielen += ETH_ALEN;
-
-       /*      Config Method */
-       /*      This field should be big endian. Noted by P2P specification. */
-       /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); */
-       put_unaligned_be16(pwdinfo->supported_wps_cm, p2pie + p2pielen);
-       p2pielen += 2;
-
-       /*      Primary Device Type */
-       /*      Category ID */
-       /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); */
-       put_unaligned_be16(WPS_PDT_CID_MULIT_MEDIA, p2pie + p2pielen);
-       p2pielen += 2;
-
-       /*      OUI */
-       /* u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); */
-       put_unaligned_be32(WPSOUI, p2pie + p2pielen);
-       p2pielen += 4;
-
-       /*      Sub Category ID */
-       /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); */
-       put_unaligned_be16(WPS_PDT_SCID_MEDIA_SERVER, p2pie + p2pielen);
-       p2pielen += 2;
-
-       /*      Number of Secondary Device Types */
-       p2pie[ p2pielen++ ] = 0x00;     /*      No Secondary Device Type List */
-
-       /*      Device Name */
-       /*      Type: */
-       /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */
-       put_unaligned_be16(WPS_ATTR_DEVICE_NAME, p2pie + p2pielen);
-       p2pielen += 2;
-
-       /*      Length: */
-       /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); */
-       put_unaligned_be16(pwdinfo->device_name_len, p2pie + p2pielen);
-       p2pielen += 2;
-
-       /*      Value: */
-       memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len);
-       p2pielen += pwdinfo->device_name_len;
-
-       /*  Group Info ATTR */
-       /*      Type: */
-       /*      Length: */
-       /*      Value: */
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO))
-       {
-               p2pielen += go_add_group_info_attr(pwdinfo, p2pie + p2pielen);
-       }
-
-       pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *) p2pie, &len);
-
-       return len;
-}
-
-u32 build_prov_disc_request_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf, u8* pssid, u8 ussidlen, u8* pdev_raddr)
-{
-       u8 p2pie[ MAX_P2P_IE_LEN] = { 0x00 };
-       u32 len = 0, p2pielen = 0;
-
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[ p2pielen++ ] = 0x50;
-       p2pie[ p2pielen++ ] = 0x6F;
-       p2pie[ p2pielen++ ] = 0x9A;
-       p2pie[ p2pielen++ ] = 0x09;     /*      WFA P2P v1.0 */
-
-       /*      Commented by Albert 20110301 */
-       /*      According to the P2P Specification, the provision discovery request frame should contain 3 P2P attributes */
-       /*      1. P2P Capability */
-       /*      2. Device Info */
-       /*      3. Group ID (When joining an operating P2P Group) */
-
-       /*      P2P Capability ATTR */
-       /*      Type: */
-       p2pie[ p2pielen++ ] = P2P_ATTR_CAPABILITY;
-
-       /*      Length: */
-       /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); */
-       put_unaligned_le16(0x0002, p2pie + p2pielen);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Device Capability Bitmap, 1 byte */
-       p2pie[ p2pielen++ ] = DMP_P2P_DEVCAP_SUPPORT;
-
-       /*      Group Capability Bitmap, 1 byte */
-       if (pwdinfo->persistent_supported)
-               p2pie[ p2pielen++ ] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT;
-       else
-               p2pie[ p2pielen++ ] = DMP_P2P_GRPCAP_SUPPORT;
-
-       /*      Device Info ATTR */
-       /*      Type: */
-       p2pie[ p2pielen++ ] = P2P_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       /*      21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */
-       /*      + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */
-       /* u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); */
-       put_unaligned_le16(21 + pwdinfo->device_name_len, p2pie + p2pielen);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      P2P Device Address */
-       memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN);
-       p2pielen += ETH_ALEN;
-
-       /*      Config Method */
-       /*      This field should be big endian. Noted by P2P specification. */
-       if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PBC)
-       {
-               /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_PBC); */
-               put_unaligned_be16(WPS_CONFIG_METHOD_PBC, p2pie + p2pielen);
-       }
-       else
-       {
-               /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); */
-               put_unaligned_be16(WPS_CONFIG_METHOD_DISPLAY, p2pie + p2pielen);
-       }
-
-       p2pielen += 2;
-
-       /*      Primary Device Type */
-       /*      Category ID */
-       /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); */
-       put_unaligned_be16(WPS_PDT_CID_MULIT_MEDIA, p2pie + p2pielen);
-       p2pielen += 2;
-
-       /*      OUI */
-       /* u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); */
-       put_unaligned_be32(WPSOUI, p2pie + p2pielen);
-       p2pielen += 4;
-
-       /*      Sub Category ID */
-       /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); */
-       put_unaligned_be16(WPS_PDT_SCID_MEDIA_SERVER, p2pie + p2pielen);
-       p2pielen += 2;
-
-       /*      Number of Secondary Device Types */
-       p2pie[ p2pielen++ ] = 0x00;     /*      No Secondary Device Type List */
-
-       /*      Device Name */
-       /*      Type: */
-       /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */
-       put_unaligned_be16(WPS_ATTR_DEVICE_NAME, p2pie + p2pielen);
-       p2pielen += 2;
-
-       /*      Length: */
-       /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); */
-       put_unaligned_be16(pwdinfo->device_name_len, p2pie + p2pielen);
-       p2pielen += 2;
-
-       /*      Value: */
-       memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len);
-       p2pielen += pwdinfo->device_name_len;
-
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT))
-       {
-               /*      Added by Albert 2011/05/19 */
-               /*      In this case, the pdev_raddr is the device address of the group owner. */
-
-               /*      P2P Group ID ATTR */
-               /*      Type: */
-               p2pie[ p2pielen++ ] = P2P_ATTR_GROUP_ID;
-
-               /*      Length: */
-               /* u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN + ussidlen); */
-               put_unaligned_le16(ETH_ALEN + ussidlen, p2pie + p2pielen);
-               p2pielen += 2;
-
-               /*      Value: */
-               memcpy(p2pie + p2pielen, pdev_raddr, ETH_ALEN);
-               p2pielen += ETH_ALEN;
-
-               memcpy(p2pie + p2pielen, pssid, ussidlen);
-               p2pielen += ussidlen;
-
-       }
-
-       pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *) p2pie, &len);
-
-       return len;
-}
-
-u32 build_assoc_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 status_code)
-{
-       u8 p2pie[ MAX_P2P_IE_LEN] = { 0x00 };
-       u32 len = 0, p2pielen = 0;
-
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2pie[ p2pielen++ ] = 0x50;
-       p2pie[ p2pielen++ ] = 0x6F;
-       p2pie[ p2pielen++ ] = 0x9A;
-       p2pie[ p2pielen++ ] = 0x09;     /*      WFA P2P v1.0 */
-
-       /*  According to the P2P Specification, the Association response frame should contain 2 P2P attributes */
-       /*      1. Status */
-       /*      2. Extended Listen Timing (optional) */
-
-       /*      Status ATTR */
-       p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status_code);
-
-       /*  Extended Listen Timing ATTR */
-       /*      Type: */
-       /*      Length: */
-       /*      Value: */
-
-       pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *) p2pie, &len);
-
-       return len;
-}
-
-u32 build_deauth_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf)
-{
-       u32 len = 0;
-
-       return len;
-}
-
-u32 process_probe_req_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len)
-{
-       u8 *p;
-       u32 ret = false;
-       u8 *p2pie;
-       u32     p2pielen = 0;
-       int ssid_len = 0, rate_cnt = 0;
-
-       p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_, _SUPPORTEDRATES_IE_, (int *)&rate_cnt,
-                       len - sizeof(struct ieee80211_hdr_3addr) - _PROBEREQ_IE_OFFSET_);
-
-       if (rate_cnt <= 4)
-       {
-               int i, g_rate = 0;
-
-               for (i = 0; i < rate_cnt; i++)
-               {
-                       if (((*(p + 2 + i) & 0xff) != 0x02) &&
-                               ((*(p + 2 + i) & 0xff) != 0x04) &&
-                               ((*(p + 2 + i) & 0xff) != 0x0B) &&
-                               ((*(p + 2 + i) & 0xff) != 0x16))
-                       {
-                               g_rate = 1;
-                       }
-               }
-
-               if (g_rate == 0)
-               {
-                       /*      There is no OFDM rate included in SupportedRates IE of this probe request frame */
-                       /*      The driver should response this probe request. */
-                       return ret;
-               }
-       }
-       else
-       {
-               /*      rate_cnt > 4 means the SupportRates IE contains the OFDM rate because the count of CCK rates are 4. */
-               /*      We should proceed the following check for this probe request. */
-       }
-
-       /*      Added comments by Albert 20100906 */
-       /*      There are several items we should check here. */
-       /*      1. This probe request frame must contain the P2P IE. (Done) */
-       /*      2. This probe request frame must contain the wildcard SSID. (Done) */
-       /*      3. Wildcard BSSID. (Todo) */
-       /*      4. Destination Address. (Done in mgt_dispatcher23a function) */
-       /*      5. Requested Device Type in WSC IE. (Todo) */
-       /*      6. Device ID attribute in P2P IE. (Todo) */
-
-       p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_, _SSID_IE_, (int *)&ssid_len,
-                       len - sizeof(struct ieee80211_hdr_3addr) - _PROBEREQ_IE_OFFSET_);
-
-       ssid_len &= 0xff;       /*      Just last 1 byte is valid for ssid len of the probe request */
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO))
-       {
-               if ((p2pie = rtw_get_p2p_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_, len - sizeof(struct ieee80211_hdr_3addr) - _PROBEREQ_IE_OFFSET_, NULL, &p2pielen)))
-               {
-                       if ((p) && !memcmp((void *)(p+2), (void *)pwdinfo->p2p_wildcard_ssid, 7))
-                       {
-                               /* todo: */
-                               /* Check Requested Device Type attributes in WSC IE. */
-                               /* Check Device ID attribute in P2P IE */
-
-                               ret = true;
-                       }
-                       else if ((p != NULL) && (ssid_len == 0))
-                       {
-                               ret = true;
-                       }
-               }
-               else
-               {
-                       /* non -p2p device */
-               }
-
-       }
-
-       return ret;
-}
-
-u32 process_assoc_req_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len, struct sta_info *psta)
-{
-       u8 status_code = P2P_STATUS_SUCCESS;
-       u8 *pbuf, *pattr_content = NULL;
-       u32 attr_contentlen = 0;
-       u16 cap_attr = 0;
-       unsigned short ie_offset;
-       u8 * ies;
-       u32 ies_len;
-       u8 * p2p_ie;
-       u32     p2p_ielen = 0;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
-
-       if (!rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO))
-               return P2P_STATUS_FAIL_REQUEST_UNABLE;
-
-       if (ieee80211_is_assoc_req(hdr->frame_control))
-               ie_offset = _ASOCREQ_IE_OFFSET_;
-       else /*  WIFI_REASSOCREQ */
-               ie_offset = _REASOCREQ_IE_OFFSET_;
-
-       ies = pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset;
-       ies_len = len - sizeof(struct ieee80211_hdr_3addr) - ie_offset;
-
-       p2p_ie = rtw_get_p2p_ie23a(ies, ies_len, NULL, &p2p_ielen);
-
-       if (!p2p_ie)
-       {
-               DBG_8723A("[%s] P2P IE not Found!!\n", __func__);
-               status_code =  P2P_STATUS_FAIL_INVALID_PARAM;
-       }
-       else
-       {
-               DBG_8723A("[%s] P2P IE Found!!\n", __func__);
-       }
-
-       while (p2p_ie)
-       {
-               /* Check P2P Capability ATTR */
-               if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_CAPABILITY, (u8*)&cap_attr, (uint*) &attr_contentlen))
-               {
-                       DBG_8723A("[%s] Got P2P Capability Attr!!\n", __func__);
-                       cap_attr = le16_to_cpu(cap_attr);
-                       psta->dev_cap = cap_attr&0xff;
-               }
-
-               /* Check Extended Listen Timing ATTR */
-
-               /* Check P2P Device Info ATTR */
-               if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO, NULL, (uint*)&attr_contentlen))
-               {
-                       DBG_8723A("[%s] Got P2P DEVICE INFO Attr!!\n", __func__);
-                       pattr_content = pbuf = kzalloc(attr_contentlen,
-                                                      GFP_ATOMIC);
-                       if (pattr_content) {
-                               u8 num_of_secdev_type;
-                               u16 dev_name_len;
-
-                               rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO, pattr_content, (uint*)&attr_contentlen);
-
-                               memcpy(psta->dev_addr,  pattr_content, ETH_ALEN);/* P2P Device Address */
-
-                               pattr_content += ETH_ALEN;
-
-                               memcpy(&psta->config_methods, pattr_content, 2);/* Config Methods */
-                               psta->config_methods = be16_to_cpu(psta->config_methods);
-
-                               pattr_content += 2;
-
-                               memcpy(psta->primary_dev_type, pattr_content, 8);
-
-                               pattr_content += 8;
-
-                               num_of_secdev_type = *pattr_content;
-                               pattr_content += 1;
-
-                               if (num_of_secdev_type == 0)
-                               {
-                                       psta->num_of_secdev_type = 0;
-                               }
-                               else
-                               {
-                                       u32 len;
-
-                                       psta->num_of_secdev_type = num_of_secdev_type;
-
-                                       len = (sizeof(psta->secdev_types_list)<(num_of_secdev_type*8)) ? (sizeof(psta->secdev_types_list)) : (num_of_secdev_type*8);
-
-                                       memcpy(psta->secdev_types_list, pattr_content, len);
-
-                                       pattr_content += (num_of_secdev_type*8);
-                               }
-
-                               /* dev_name_len = attr_contentlen - ETH_ALEN - 2 - 8 - 1 - (num_of_secdev_type*8); */
-                               psta->dev_name_len = 0;
-                               if (WPS_ATTR_DEVICE_NAME == be16_to_cpu(*(u16*)pattr_content))
-                               {
-                                       dev_name_len = be16_to_cpu(*(u16*)(pattr_content+2));
-
-                                       psta->dev_name_len = (sizeof(psta->dev_name)<dev_name_len) ? sizeof(psta->dev_name):dev_name_len;
-
-                                       memcpy(psta->dev_name, pattr_content+4, psta->dev_name_len);
-                               }
-
-                               kfree(pbuf);
-
-                       }
-
-               }
-
-               /* Get the next P2P IE */
-               p2p_ie = rtw_get_p2p_ie23a(p2p_ie+p2p_ielen, ies_len -(p2p_ie -ies + p2p_ielen), NULL, &p2p_ielen);
-
-       }
-
-       return status_code;
-}
-
-u32 process_p2p_devdisc_req23a(struct wifidirect_info *pwdinfo, u8 *pframe,
-                           uint len)
-{
-       u8 *frame_body;
-       u8 status, dialogToken;
-       struct sta_info *psta = NULL;
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       u8 *p2p_ie;
-       u32     p2p_ielen = 0;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) pframe;
-
-       frame_body = (unsigned char *)
-               (pframe + sizeof(struct ieee80211_hdr_3addr));
-
-       dialogToken = frame_body[7];
-       status = P2P_STATUS_FAIL_UNKNOWN_P2PGROUP;
-
-       if ((p2p_ie = rtw_get_p2p_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_,
-                                    len - _PUBLIC_ACTION_IE_OFFSET_, NULL,
-                                    &p2p_ielen))) {
-               u8 groupid[38] = { 0x00 };
-               u8 dev_addr[ETH_ALEN] = { 0x00 };
-               u32 attr_contentlen = 0;
-
-               if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen,
-                                            P2P_ATTR_GROUP_ID, groupid,
-                                            &attr_contentlen)) {
-                       if (!memcmp(pwdinfo->device_addr, groupid, ETH_ALEN) &&
-                           !memcmp(pwdinfo->p2p_group_ssid, groupid + ETH_ALEN,
-                                   pwdinfo->p2p_group_ssid_len)) {
-                               attr_contentlen = 0;
-
-                               if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen,
-                                                            P2P_ATTR_DEVICE_ID,
-                                                            dev_addr,
-                                                            &attr_contentlen)) {
-                                       struct list_head *phead, *plist, *ptmp;
-
-                                       spin_lock_bh(&pstapriv->asoc_list_lock);
-                                       phead = &pstapriv->asoc_list;
-
-                                       list_for_each_safe(plist, ptmp, phead) {
-                                               psta = container_of(plist, struct sta_info, asoc_list);
-
-                                               if (psta->is_p2p_device && (psta->dev_cap&P2P_DEVCAP_CLIENT_DISCOVERABILITY) &&
-                                                  !memcmp(psta->dev_addr, dev_addr, ETH_ALEN))
-                                               {
-                                                       /* spin_unlock_bh(&pstapriv->asoc_list_lock); */
-                                                       /* issue GO Discoverability Request */
-                                                       issue_group_disc_req(pwdinfo, psta->hwaddr);
-                                                       /* spin_lock_bh(&pstapriv->asoc_list_lock); */
-                                                       status = P2P_STATUS_SUCCESS;
-                                                       break;
-                                               } else {
-                                                       status = P2P_STATUS_FAIL_INFO_UNAVAILABLE;
-                                               }
-                                       }
-                                       spin_unlock_bh(&pstapriv->asoc_list_lock);
-                               } else {
-                                       status = P2P_STATUS_FAIL_INVALID_PARAM;
-                               }
-                       } else {
-                               status = P2P_STATUS_FAIL_INVALID_PARAM;
-                       }
-               }
-       }
-
-       /* issue Device Discoverability Response */
-       issue_p2p_devdisc_resp(pwdinfo, hdr->addr2, status, dialogToken);
-
-       return (status == P2P_STATUS_SUCCESS) ? true:false;
-}
-
-u32 process_p2p_devdisc_resp23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len)
-{
-       return true;
-}
-
-u8 process_p2p_provdisc_req23a(struct wifidirect_info *pwdinfo,
-                           u8 *pframe, uint len)
-{
-       u8 *frame_body;
-       u8 *wpsie;
-       u8 *ptr = NULL;
-       uint    wps_ielen = 0, attr_contentlen = 0;
-       u16     uconfig_method = 0;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
-
-       frame_body = (pframe + sizeof(struct ieee80211_hdr_3addr));
-
-       wpsie = rtw_get_wps_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_,
-                              len - _PUBLIC_ACTION_IE_OFFSET_, NULL,
-                              &wps_ielen);
-       if (!wpsie)
-               goto out;
-
-       if (!rtw_get_wps_attr_content23a(wpsie, wps_ielen, WPS_ATTR_CONF_METHOD,
-                                    (u8 *)&uconfig_method, &attr_contentlen))
-               goto out;
-
-       uconfig_method = be16_to_cpu(uconfig_method);
-       ptr = pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req;
-
-       switch (uconfig_method)
-       {
-       case WPS_CM_DISPLYA:
-               memcpy(ptr, "dis", 3);
-               break;
-
-       case WPS_CM_LABEL:
-               memcpy(ptr, "lab", 3);
-               break;
-
-       case WPS_CM_PUSH_BUTTON:
-               memcpy(ptr, "pbc", 3);
-               break;
-
-       case WPS_CM_KEYPAD:
-               memcpy(ptr, "pad", 3);
-               break;
-       }
-       issue_p2p_provision_resp(pwdinfo, hdr->addr2, frame_body,
-                                uconfig_method);
-
-out:
-       DBG_8723A("[%s] config method = %s\n", __func__, ptr);
-
-       return true;
-}
-
-u8 process_p2p_provdisc_resp23a(struct wifidirect_info *pwdinfo,  u8 *pframe)
-{
-
-       return true;
-}
-
-static u8 rtw_p2p_get_peer_ch_list(struct wifidirect_info *pwdinfo, u8 *ch_content, u8 ch_cnt, u8 *peer_ch_list)
-{
-       u8 i = 0, j = 0;
-       u8 temp = 0;
-       u8 ch_no = 0;
-       ch_content += 3;
-       ch_cnt -= 3;
-
-       while(ch_cnt > 0)
-       {
-               ch_content += 1;
-               ch_cnt -= 1;
-               temp = *ch_content;
-               for (i = 0 ; i < temp ; i++, j++)
-               {
-                       peer_ch_list[j] = *(ch_content + 1 + i);
-               }
-               ch_content += (temp + 1);
-               ch_cnt -= (temp + 1);
-               ch_no += temp ;
-       }
-
-       return ch_no;
-}
-
-static u8 rtw_p2p_ch_inclusion(struct mlme_ext_priv *pmlmeext, u8 *peer_ch_list, u8 peer_ch_num, u8 *ch_list_inclusioned)
-{
-       int     i = 0, j = 0, temp = 0;
-       u8 ch_no = 0;
-
-       for (i = 0; i < peer_ch_num; i++)
-       {
-               for (j = temp; j < pmlmeext->max_chan_nums; j++)
-               {
-                       if (*(peer_ch_list + i) == pmlmeext->channel_set[ j ].ChannelNum)
-                       {
-                               ch_list_inclusioned[ ch_no++ ] = *(peer_ch_list + i);
-                               temp = j;
-                               break;
-                       }
-               }
-       }
-
-       return ch_no;
-}
-
-u8 process_p2p_group_negotation_req23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len)
-{
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       u8      result = P2P_STATUS_SUCCESS;
-       u32     p2p_ielen = 0, wps_ielen = 0;
-       u8 * ies;
-       u32 ies_len;
-       u8 *p2p_ie;
-       u8 *wpsie;
-       u16             wps_devicepassword_id = 0x0000;
-       uint    wps_devicepassword_id_len = 0;
-#ifdef CONFIG_8723AU_P2P
-       u8      wfd_ie[MAX_WFD_IE_LEN] = { 0x00 };
-       u32     wfd_ielen = 0;
-#endif /*  CONFIG_8723AU_P2P */
-
-       if ((wpsie = rtw_get_wps_ie23a(pframe + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &wps_ielen)))
-       {
-               /*      Commented by Kurt 20120113 */
-               /*      If some device wants to do p2p handshake without sending prov_disc_req */
-               /*      We have to get peer_req_cm from here. */
-               if (!memcmp(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "000", 3))
-               {
-                       rtw_get_wps_attr_content23a(wpsie, wps_ielen, WPS_ATTR_DEVICE_PWID, (u8*) &wps_devicepassword_id, &wps_devicepassword_id_len);
-                       wps_devicepassword_id = be16_to_cpu(wps_devicepassword_id);
-
-                       if (wps_devicepassword_id == WPS_DPID_USER_SPEC)
-                       {
-                               memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3);
-                       }
-                       else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC)
-                       {
-                               memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pad", 3);
-                       }
-                       else
-                       {
-                               memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pbc", 3);
-                       }
-               }
-       }
-       else
-       {
-               DBG_8723A("[%s] WPS IE not Found!!\n", __func__);
-               result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM;
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL);
-               return result;
-       }
-
-       if (pwdinfo->ui_got_wps_info == P2P_NO_WPSINFO)
-       {
-               result = P2P_STATUS_FAIL_INFO_UNAVAILABLE;
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_INFOR_NOREADY);
-               return result;
-       }
-
-       ies = pframe + _PUBLIC_ACTION_IE_OFFSET_;
-       ies_len = len - _PUBLIC_ACTION_IE_OFFSET_;
-
-       p2p_ie = rtw_get_p2p_ie23a(ies, ies_len, NULL, &p2p_ielen);
-
-       if (!p2p_ie)
-       {
-               DBG_8723A("[%s] P2P IE not Found!!\n", __func__);
-               result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM;
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL);
-       }
-
-       while (p2p_ie)
-       {
-               u8      attr_content = 0x00;
-               u32     attr_contentlen = 0;
-               u8      ch_content[50] = { 0x00 };
-               uint    ch_cnt = 0;
-               u8      peer_ch_list[50] = { 0x00 };
-               u8      peer_ch_num = 0;
-               u8      ch_list_inclusioned[50] = { 0x00 };
-               u8      ch_num_inclusioned = 0;
-               u16     cap_attr;
-
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_ING);
-
-               /* Check P2P Capability ATTR */
-               if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_CAPABILITY, (u8*)&cap_attr, (uint*)&attr_contentlen))
-                       cap_attr = le16_to_cpu(cap_attr);
-
-               if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT, &attr_content, &attr_contentlen))
-               {
-                       DBG_8723A("[%s] GO Intent = %d, tie = %d\n", __func__, attr_content >> 1, attr_content & 0x01);
-                       pwdinfo->peer_intent = attr_content;    /*      include both intent and tie breaker values. */
-
-                       if (pwdinfo->intent == (pwdinfo->peer_intent >> 1))
-                       {
-                               /*      Try to match the tie breaker value */
-                               if (pwdinfo->intent == P2P_MAX_INTENT)
-                               {
-                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-                                       result = P2P_STATUS_FAIL_BOTH_GOINTENT_15;
-                               }
-                               else
-                               {
-                                       if (attr_content & 0x01)
-                                       {
-                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                                       }
-                                       else
-                                       {
-                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-                                       }
-                               }
-                       }
-                       else if (pwdinfo->intent > (pwdinfo->peer_intent >> 1))
-                       {
-                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-                       }
-                       else
-                       {
-                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                       }
-
-                       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO))
-                       {
-                               /*      Store the group id information. */
-                               memcpy(pwdinfo->groupid_info.go_device_addr, pwdinfo->device_addr, ETH_ALEN);
-                               memcpy(pwdinfo->groupid_info.ssid, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen);
-                       }
-               }
-
-               attr_contentlen = 0;
-               if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_INTENTED_IF_ADDR, pwdinfo->p2p_peer_interface_addr, &attr_contentlen))
-               {
-                       if (attr_contentlen != ETH_ALEN)
-                       {
-                               memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN);
-                       }
-               }
-
-               if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_CH_LIST, ch_content, &ch_cnt))
-               {
-                       peer_ch_num = rtw_p2p_get_peer_ch_list(pwdinfo, ch_content, ch_cnt, peer_ch_list);
-                       ch_num_inclusioned = rtw_p2p_ch_inclusion(&padapter->mlmeextpriv, peer_ch_list, peer_ch_num, ch_list_inclusioned);
-
-                       if (ch_num_inclusioned == 0)
-                       {
-                               DBG_8723A("[%s] No common channel in channel list!\n", __func__);
-                               result = P2P_STATUS_FAIL_NO_COMMON_CH;
-                               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL);
-                               break;
-                       }
-
-                       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO))
-                       {
-                               if (!rtw_p2p_is_channel_list_ok(pwdinfo->operating_channel,
-                                                                                               ch_list_inclusioned, ch_num_inclusioned))
-                               {
-                                       {
-                                               u8 operatingch_info[5] = { 0x00 }, peer_operating_ch = 0;
-                                               attr_contentlen = 0;
-
-                                               if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen))
-                                               {
-                                                       peer_operating_ch = operatingch_info[4];
-                                               }
-
-                                               if (rtw_p2p_is_channel_list_ok(peer_operating_ch,
-                                                                                                               ch_list_inclusioned, ch_num_inclusioned))
-                                               {
-                                                       /**
-                                                        *      Change our operating channel as peer's for compatibility.
-                                                        */
-                                                       pwdinfo->operating_channel = peer_operating_ch;
-                                                       DBG_8723A("[%s] Change op ch to %02x as peer's\n", __func__, pwdinfo->operating_channel);
-                                               }
-                                               else
-                                               {
-                                                       /*  Take first channel of ch_list_inclusioned as operating channel */
-                                                       pwdinfo->operating_channel = ch_list_inclusioned[0];
-                                                       DBG_8723A("[%s] Change op ch to %02x\n", __func__, pwdinfo->operating_channel);
-                                               }
-                                       }
-
-                               }
-                       }
-               }
-
-               /* Get the next P2P IE */
-               p2p_ie = rtw_get_p2p_ie23a(p2p_ie+p2p_ielen, ies_len -(p2p_ie -ies + p2p_ielen), NULL, &p2p_ielen);
-       }
-
-#ifdef CONFIG_8723AU_P2P
-       /*      Added by Albert 20110823 */
-       /*      Try to get the TCP port information when receiving the negotiation request. */
-       if (rtw_get_wfd_ie(pframe + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, wfd_ie, &wfd_ielen))
-       {
-               u8      attr_content[ 10 ] = { 0x00 };
-               u32     attr_contentlen = 0;
-
-               DBG_8723A("[%s] WFD IE Found!!\n", __func__);
-               rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen);
-               if (attr_contentlen)
-               {
-                       pwdinfo->wfd_info->peer_rtsp_ctrlport = get_unaligned_be16(attr_content + 2);
-                       DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport);
-               }
-       }
-#endif /*  CONFIG_8723AU_P2P */
-
-       return result;
-}
-
-u8 process_p2p_group_negotation_resp23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len)
-{
-       struct rtw_adapter *padapter = pwdinfo->padapter;
-       u8      result = P2P_STATUS_SUCCESS;
-       u32     p2p_ielen, wps_ielen;
-       u8 * ies;
-       u32 ies_len;
-       u8 * p2p_ie;
-#ifdef CONFIG_8723AU_P2P
-       u8      wfd_ie[MAX_WFD_IE_LEN] = { 0x00 };
-       u32     wfd_ielen = 0;
-#endif /*  CONFIG_8723AU_P2P */
-
-       ies = pframe + _PUBLIC_ACTION_IE_OFFSET_;
-       ies_len = len - _PUBLIC_ACTION_IE_OFFSET_;
-
-       /*      Be able to know which one is the P2P GO and which one is P2P client. */
-
-       if (rtw_get_wps_ie23a(ies, ies_len, NULL, &wps_ielen))
-       {
-
-       }
-       else
-       {
-               DBG_8723A("[%s] WPS IE not Found!!\n", __func__);
-               result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM;
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL);
-       }
-
-       p2p_ie = rtw_get_p2p_ie23a(ies, ies_len, NULL, &p2p_ielen);
-       if (!p2p_ie)
-       {
-               rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL);
-               result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM;
-       }
-       else
-       {
-
-               u8      attr_content = 0x00;
-               u32     attr_contentlen = 0;
-               u8      operatingch_info[5] = { 0x00 };
-               u8      groupid[ 38 ];
-               u16     cap_attr;
-               u8      peer_ch_list[50] = { 0x00 };
-               u8      peer_ch_num = 0;
-               u8      ch_list_inclusioned[50] = { 0x00 };
-               u8      ch_num_inclusioned = 0;
-
-               while (p2p_ie)  /*      Found the P2P IE. */
-               {
-
-                       /* Check P2P Capability ATTR */
-                       if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_CAPABILITY, (u8*)&cap_attr, (uint*)&attr_contentlen))
-                               cap_attr = le16_to_cpu(cap_attr);
-
-                       rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen);
-                       if (attr_contentlen == 1)
-                       {
-                               DBG_8723A("[%s] Status = %d\n", __func__, attr_content);
-                               if (attr_content == P2P_STATUS_SUCCESS)
-                               {
-                                       /*      Do nothing. */
-                               }
-                               else
-                               {
-                                       if (P2P_STATUS_FAIL_INFO_UNAVAILABLE == attr_content) {
-                                               rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INFOR_NOREADY);
-                                       } else {
-                                               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL);
-                                       }
-                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-                                       result = attr_content;
-                                       break;
-                               }
-                       }
-
-                       /*      Try to get the peer's interface address */
-                       attr_contentlen = 0;
-                       if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_INTENTED_IF_ADDR, pwdinfo->p2p_peer_interface_addr, &attr_contentlen))
-                       {
-                               if (attr_contentlen != ETH_ALEN)
-                               {
-                                       memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN);
-                               }
-                       }
-
-                       /*      Try to get the peer's intent and tie breaker value. */
-                       attr_content = 0x00;
-                       attr_contentlen = 0;
-                       if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT, &attr_content, &attr_contentlen))
-                       {
-                               DBG_8723A("[%s] GO Intent = %d, tie = %d\n", __func__, attr_content >> 1, attr_content & 0x01);
-                               pwdinfo->peer_intent = attr_content;    /*      include both intent and tie breaker values. */
-
-                               if (pwdinfo->intent == (pwdinfo->peer_intent >> 1))
-                               {
-                                       /*      Try to match the tie breaker value */
-                                       if (pwdinfo->intent == P2P_MAX_INTENT)
-                                       {
-                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-                                               result = P2P_STATUS_FAIL_BOTH_GOINTENT_15;
-                                               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL);
-                                       }
-                                       else
-                                       {
-                                               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK);
-                                               rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK);
-                                               if (attr_content & 0x01)
-                                               {
-                                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                                               }
-                                               else
-                                               {
-                                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-                                               }
-                                       }
-                               }
-                               else if (pwdinfo->intent > (pwdinfo->peer_intent >> 1))
-                               {
-                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK);
-                                       rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK);
-                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-                               }
-                               else
-                               {
-                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK);
-                                       rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK);
-                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                               }
-
-                               if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO))
-                               {
-                                       /*      Store the group id information. */
-                                       memcpy(pwdinfo->groupid_info.go_device_addr, pwdinfo->device_addr, ETH_ALEN);
-                                       memcpy(pwdinfo->groupid_info.ssid, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen);
-
-                               }
-                       }
-
-                       /*      Try to get the operation channel information */
-
-                       attr_contentlen = 0;
-                       if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen))
-                       {
-                               DBG_8723A("[%s] Peer's operating channel = %d\n", __func__, operatingch_info[4]);
-                               pwdinfo->peer_operating_ch = operatingch_info[4];
-                       }
-
-                       /*      Try to get the channel list information */
-                       if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_CH_LIST, pwdinfo->channel_list_attr, &pwdinfo->channel_list_attr_len))
-                       {
-                               DBG_8723A("[%s] channel list attribute found, len = %d\n", __func__,  pwdinfo->channel_list_attr_len);
-
-                               peer_ch_num = rtw_p2p_get_peer_ch_list(pwdinfo, pwdinfo->channel_list_attr, pwdinfo->channel_list_attr_len, peer_ch_list);
-                               ch_num_inclusioned = rtw_p2p_ch_inclusion(&padapter->mlmeextpriv, peer_ch_list, peer_ch_num, ch_list_inclusioned);
-
-                               if (ch_num_inclusioned == 0)
-                               {
-                                       DBG_8723A("[%s] No common channel in channel list!\n", __func__);
-                                       result = P2P_STATUS_FAIL_NO_COMMON_CH;
-                                       rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL);
-                                       break;
-                               }
-
-                               if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO))
-                               {
-                                       if (!rtw_p2p_is_channel_list_ok(pwdinfo->operating_channel,
-                                                                                                       ch_list_inclusioned, ch_num_inclusioned))
-                                       {
-                                               {
-                                                       u8 operatingch_info[5] = { 0x00 }, peer_operating_ch = 0;
-                                                       attr_contentlen = 0;
-
-                                                       if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen))
-                                                       {
-                                                               peer_operating_ch = operatingch_info[4];
-                                                       }
-
-                                                       if (rtw_p2p_is_channel_list_ok(peer_operating_ch,
-                                                                                                                       ch_list_inclusioned, ch_num_inclusioned))
-                                                       {
-                                                               /**
-                                                                *      Change our operating channel as peer's for compatibility.
-                                                                */
-                                                               pwdinfo->operating_channel = peer_operating_ch;
-                                                               DBG_8723A("[%s] Change op ch to %02x as peer's\n", __func__, pwdinfo->operating_channel);
-                                                       }
-                                                       else
-                                                       {
-                                                               /*  Take first channel of ch_list_inclusioned as operating channel */
-                                                               pwdinfo->operating_channel = ch_list_inclusioned[0];
-                                                               DBG_8723A("[%s] Change op ch to %02x\n", __func__, pwdinfo->operating_channel);
-                                                       }
-                                               }
-
-                                       }
-                               }
-
-                       }
-                       else
-                       {
-                               DBG_8723A("[%s] channel list attribute not found!\n", __func__);
-                       }
-
-                       /*      Try to get the group id information if peer is GO */
-                       attr_contentlen = 0;
-                       memset(groupid, 0x00, 38);
-                       if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen))
-                       {
-                               memcpy(pwdinfo->groupid_info.go_device_addr, &groupid[0], ETH_ALEN);
-                               memcpy(pwdinfo->groupid_info.ssid, &groupid[6], attr_contentlen - ETH_ALEN);
-                       }
-
-                       /* Get the next P2P IE */
-                       p2p_ie = rtw_get_p2p_ie23a(p2p_ie+p2p_ielen, ies_len -(p2p_ie -ies + p2p_ielen), NULL, &p2p_ielen);
-               }
-
-       }
-
-#ifdef CONFIG_8723AU_P2P
-       /*      Added by Albert 20111122 */
-       /*      Try to get the TCP port information when receiving the negotiation response. */
-       if (rtw_get_wfd_ie(pframe + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, wfd_ie, &wfd_ielen))
-       {
-               u8      attr_content[ 10 ] = { 0x00 };
-               u32     attr_contentlen = 0;
-
-               DBG_8723A("[%s] WFD IE Found!!\n", __func__);
-               rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen);
-               if (attr_contentlen)
-               {
-                       pwdinfo->wfd_info->peer_rtsp_ctrlport = get_unaligned_be16(attr_content + 2);
-                       DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport);
-               }
-       }
-#endif /*  CONFIG_8723AU_P2P */
-
-       return result;
-}
-
-u8 process_p2p_group_negotation_confirm23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len)
-{
-       u8 * ies;
-       u32 ies_len;
-       u8 * p2p_ie;
-       u32     p2p_ielen = 0;
-       u8      result = P2P_STATUS_SUCCESS;
-       ies = pframe + _PUBLIC_ACTION_IE_OFFSET_;
-       ies_len = len - _PUBLIC_ACTION_IE_OFFSET_;
-
-       p2p_ie = rtw_get_p2p_ie23a(ies, ies_len, NULL, &p2p_ielen);
-       while (p2p_ie)  /*      Found the P2P IE. */
-       {
-               u8      attr_content = 0x00, operatingch_info[5] = { 0x00 };
-               u8      groupid[ 38 ] = { 0x00 };
-               u32     attr_contentlen = 0;
-
-               pwdinfo->negotiation_dialog_token = 1;
-               rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen);
-               if (attr_contentlen == 1)
-               {
-                       DBG_8723A("[%s] Status = %d\n", __func__, attr_content);
-                       result = attr_content;
-
-                       if (attr_content == P2P_STATUS_SUCCESS)
-                       {
-                               del_timer_sync(&pwdinfo->restore_p2p_state_timer);
-
-                               /*      Commented by Albert 20100911 */
-                               /*      Todo: Need to handle the case which both Intents are the same. */
-                               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK);
-                               rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK);
-                               if ((pwdinfo->intent) > (pwdinfo->peer_intent >> 1))
-                               {
-                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-                               }
-                               else if ((pwdinfo->intent) < (pwdinfo->peer_intent >> 1))
-                               {
-                                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                               }
-                               else
-                               {
-                                       /*      Have to compare the Tie Breaker */
-                                       if (pwdinfo->peer_intent & 0x01)
-                                       {
-                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-                                       }
-                                       else
-                                       {
-                                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-                                       }
-                               }
-                       }
-                       else
-                       {
-                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-                               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL);
-                               break;
-                       }
-               }
-
-               /*      Try to get the group id information */
-               attr_contentlen = 0;
-               memset(groupid, 0x00, 38);
-               if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen))
-               {
-                       DBG_8723A("[%s] Ssid = %s, ssidlen = %zu\n", __func__, &groupid[ETH_ALEN], strlen(&groupid[ETH_ALEN]));
-                       memcpy(pwdinfo->groupid_info.go_device_addr, &groupid[0], ETH_ALEN);
-                       memcpy(pwdinfo->groupid_info.ssid, &groupid[6], attr_contentlen - ETH_ALEN);
-               }
-
-               attr_contentlen = 0;
-               if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen))
-               {
-                       DBG_8723A("[%s] Peer's operating channel = %d\n", __func__, operatingch_info[4]);
-                       pwdinfo->peer_operating_ch = operatingch_info[4];
-               }
-
-               /* Get the next P2P IE */
-               p2p_ie = rtw_get_p2p_ie23a(p2p_ie+p2p_ielen, ies_len -(p2p_ie -ies + p2p_ielen), NULL, &p2p_ielen);
-
-       }
-
-       return result;
-}
-
-u8 process_p2p_presence_req23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len)
-{
-       u8 *frame_body;
-       u8 dialogToken = 0;
-       u8 status = P2P_STATUS_SUCCESS;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) pframe;
-
-       frame_body = (unsigned char *)(pframe + sizeof(struct ieee80211_hdr_3addr));
-
-       dialogToken = frame_body[6];
-
-       /* todo: check NoA attribute */
-
-       issue_p2p_presence_resp(pwdinfo, hdr->addr2, status, dialogToken);
-
-       return true;
-}
-
-static void find_phase_handler(struct rtw_adapter *padapter)
-{
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-       struct mlme_priv                *pmlmepriv = &padapter->mlmepriv;
-       struct cfg80211_ssid ssid;
-       u8                                      _status = 0;
-
-
-
-       memset((unsigned char*)&ssid, 0, sizeof(struct cfg80211_ssid));
-       memcpy(ssid.ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN);
-       ssid.ssid_len = P2P_WILDCARD_SSID_LEN;
-
-       rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH);
-
-       spin_lock_bh(&pmlmepriv->lock);
-       _status = rtw_sitesurvey_cmd23a(padapter, &ssid, 1, NULL, 0);
-       spin_unlock_bh(&pmlmepriv->lock);
-
-
-}
-
-void p2p_concurrent_handler(struct rtw_adapter* padapter);
-
-static void restore_p2p_state_handler(struct rtw_adapter *padapter)
-{
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL))
-               rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-
-       rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo));
-
-       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE)) {
-               /*      In the P2P client mode, the driver should not switch back to its listen channel */
-               /*      because this P2P client should stay at the operating channel of P2P GO. */
-               set_channel_bwmode23a(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
-       }
-}
-
-static void pre_tx_invitereq_handler(struct rtw_adapter *padapter)
-{
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-       u8      val8 = 1;
-
-       set_channel_bwmode23a(padapter, pwdinfo->invitereq_info.peer_ch, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
-       padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8));
-       issue23a_probereq_p2p(padapter, NULL);
-       mod_timer(&pwdinfo->pre_tx_scan_timer,
-                 jiffies + msecs_to_jiffies(P2P_TX_PRESCAN_TIMEOUT));
-
-
-}
-
-static void pre_tx_provdisc_handler(struct rtw_adapter *padapter)
-{
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-       u8      val8 = 1;
-
-
-       set_channel_bwmode23a(padapter, pwdinfo->tx_prov_disc_info.peer_channel_num[0], HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8));
-       issue23a_probereq_p2p(padapter, NULL);
-       mod_timer(&pwdinfo->pre_tx_scan_timer,
-                 jiffies + msecs_to_jiffies(P2P_TX_PRESCAN_TIMEOUT));
-
-
-}
-
-static void pre_tx_negoreq_handler(struct rtw_adapter *padapter)
-{
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-       u8      val8 = 1;
-
-
-       set_channel_bwmode23a(padapter, pwdinfo->nego_req_info.peer_channel_num[0], HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8));
-       issue23a_probereq_p2p(padapter, NULL);
-       mod_timer(&pwdinfo->pre_tx_scan_timer,
-                 jiffies + msecs_to_jiffies(P2P_TX_PRESCAN_TIMEOUT));
-
-
-}
-
-static void ro_ch_handler(struct rtw_adapter *padapter)
-{
-       struct cfg80211_wifidirect_info *pcfg80211_wdinfo = &padapter->cfg80211_wdinfo;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-
-       if (pcfg80211_wdinfo->restore_channel != pmlmeext->cur_channel) {
-               if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED))
-                       pmlmeext->cur_channel = pcfg80211_wdinfo->restore_channel;
-
-               set_channel_bwmode23a(padapter, pmlmeext->cur_channel,
-                                     HAL_PRIME_CHNL_OFFSET_DONT_CARE,
-                                     HT_CHANNEL_WIDTH_20);
-       }
-
-       rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo));
-
-       pcfg80211_wdinfo->is_ro_ch = false;
-
-       DBG_8723A("cfg80211_remain_on_channel_expired\n");
-
-       rtw_cfg80211_remain_on_channel_expired(padapter,
-               pcfg80211_wdinfo->remain_on_ch_cookie,
-               &pcfg80211_wdinfo->remain_on_ch_channel,
-               pcfg80211_wdinfo->remain_on_ch_type, GFP_KERNEL);
-}
-
-static void ro_ch_timer_process (unsigned long data)
-{
-       struct rtw_adapter *adapter = (struct rtw_adapter *)data;
-
-       p2p_protocol_wk_cmd23a(adapter, P2P_RO_CH_WK);
-}
-
-#ifdef CONFIG_8723AU_P2P
-void rtw_append_wfd_ie(struct rtw_adapter *padapter, u8 *buf, u32* len)
-{
-       unsigned char   *frame_body;
-       u8 category, action, OUI_Subtype, dialogToken = 0;
-       u32     wfdielen = 0;
-
-       frame_body = (unsigned char *)(buf + sizeof(struct ieee80211_hdr_3addr));
-       category = frame_body[0];
-
-       if (category == WLAN_CATEGORY_PUBLIC) {
-               action = frame_body[1];
-               if (action == ACT_PUBLIC_VENDOR &&
-                   !memcmp(frame_body+2, P2P_OUI23A, 4)) {
-                       OUI_Subtype = frame_body[6];
-                       dialogToken = frame_body[7];
-                       switch (OUI_Subtype)/* OUI Subtype */ {
-                       case P2P_GO_NEGO_REQ:
-                               wfdielen = build_nego_req_wfd_ie(&padapter->wdinfo, buf + (*len));
-                               (*len) += wfdielen;
-                               break;
-                       case P2P_GO_NEGO_RESP:
-                               wfdielen = build_nego_resp_wfd_ie(&padapter->wdinfo, buf + (*len));
-                               (*len) += wfdielen;
-                               break;
-                       case P2P_GO_NEGO_CONF:
-                               wfdielen = build_nego_confirm_wfd_ie(&padapter->wdinfo, buf + (*len));
-                               (*len) += wfdielen;
-                               break;
-                       case P2P_INVIT_REQ:
-                               wfdielen = build_invitation_req_wfd_ie(&padapter->wdinfo, buf + (*len));
-                               (*len) += wfdielen;
-                               break;
-                       case P2P_INVIT_RESP:
-                               wfdielen = build_invitation_resp_wfd_ie(&padapter->wdinfo, buf + (*len));
-                               (*len) += wfdielen;
-                               break;
-                       case P2P_DEVDISC_REQ:
-                               break;
-                       case P2P_DEVDISC_RESP:
-                               break;
-                       case P2P_PROVISION_DISC_REQ:
-                               wfdielen = build_provdisc_req_wfd_ie(&padapter->wdinfo, buf + (*len));
-                               (*len) += wfdielen;
-                               break;
-                       case P2P_PROVISION_DISC_RESP:
-                               wfdielen = build_provdisc_resp_wfd_ie(&padapter->wdinfo, buf + (*len));
-                               (*len) += wfdielen;
-                               break;
-                       default:
-                               break;
-                       }
-               }
-       } else if (category == WLAN_CATEGORY_VENDOR_SPECIFIC) {
-               OUI_Subtype = frame_body[5];
-               dialogToken = frame_body[6];
-       } else {
-               DBG_8723A("%s, action frame category =%d\n", __func__, category);
-       }
-}
-#endif
-
-int rtw_p2p_check_frames(struct rtw_adapter *padapter, const u8 *buf, u32 len, u8 tx)
-{
-       int is_p2p_frame = (-1);
-       unsigned char   *frame_body;
-       u8 category, action, OUI_Subtype, dialogToken = 0;
-       u8 *p2p_ie = NULL;
-       uint p2p_ielen = 0;
-       struct rtw_wdev_priv *pwdev_priv = wdev_to_priv(padapter->rtw_wdev);
-
-       frame_body = (unsigned char *)(buf + sizeof(struct ieee80211_hdr_3addr));
-       category = frame_body[0];
-       /* just for check */
-       if (category == WLAN_CATEGORY_PUBLIC)
-       {
-               action = frame_body[1];
-               if (action == ACT_PUBLIC_VENDOR &&
-                   !memcmp(frame_body+2, P2P_OUI23A, 4)) {
-                       OUI_Subtype = frame_body[6];
-                       dialogToken = frame_body[7];
-                       is_p2p_frame = OUI_Subtype;
-                       p2p_ie = rtw_get_p2p_ie23a(
-                               (u8 *)buf+sizeof(struct ieee80211_hdr_3addr)+_PUBLIC_ACTION_IE_OFFSET_,
-                               len-sizeof(struct ieee80211_hdr_3addr)-_PUBLIC_ACTION_IE_OFFSET_,
-                               NULL, &p2p_ielen);
-
-                       switch (OUI_Subtype) {/* OUI Subtype */
-                       u8 *cont;
-                       uint cont_len;
-                       case P2P_GO_NEGO_REQ:
-                               DBG_8723A("RTW_%s:P2P_GO_NEGO_REQ, dialogToken =%d\n", (tx == true)?"Tx":"Rx", dialogToken);
-                               break;
-                       case P2P_GO_NEGO_RESP:
-                               cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, NULL, &cont_len);
-                               DBG_8723A("RTW_%s:P2P_GO_NEGO_RESP, dialogToken =%d, status:%d\n", (tx == true)?"Tx":"Rx", dialogToken, cont?*cont:-1);
-
-                               if (!tx)
-                                       pwdev_priv->provdisc_req_issued = false;
-                               break;
-                       case P2P_GO_NEGO_CONF:
-                               cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, NULL, &cont_len);
-                               DBG_8723A("RTW_%s:P2P_GO_NEGO_CONF, dialogToken =%d, status:%d\n",
-                                         (tx == true)?"Tx":"Rx", dialogToken, cont?*cont:-1);
-                               break;
-                       case P2P_INVIT_REQ:
-                       {
-                               struct rtw_wdev_invit_info* invit_info = &pwdev_priv->invit_info;
-                               int flags = -1;
-                               int op_ch = 0;
-
-                               if ((cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_INVITATION_FLAGS, NULL, &cont_len)))
-                                       flags = *cont;
-                               if ((cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, NULL, &cont_len)))
-                                       op_ch = *(cont+4);
-
-                               if (invit_info->token != dialogToken)
-                                       rtw_wdev_invit_info_init(invit_info);
-
-                               invit_info->token = dialogToken;
-                               invit_info->flags = (flags ==-1) ? 0x0 : flags;
-                               invit_info->req_op_ch = op_ch;
-
-                               DBG_8723A("RTW_%s:P2P_INVIT_REQ, dialogToken =%d, flags:0x%02x, op_ch:%d\n",
-                                         (tx) ? "Tx" : "Rx", dialogToken, flags, op_ch);
-                               break;
-                       }
-                       case P2P_INVIT_RESP:
-                       {
-                               struct rtw_wdev_invit_info* invit_info = &pwdev_priv->invit_info;
-                               int status = -1;
-                               int op_ch = 0;
-
-                               if ((cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, NULL, &cont_len)))
-                                       status = *cont;
-                               if ((cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, NULL, &cont_len)))
-                                       op_ch = *(cont+4);
-
-                               if (invit_info->token != dialogToken) {
-                                       rtw_wdev_invit_info_init(invit_info);
-                               } else {
-                                       invit_info->token = 0;
-                                       invit_info->status = (status ==-1) ? 0xff : status;
-                                       invit_info->rsp_op_ch = op_ch;
-                               }
-
-                               DBG_8723A("RTW_%s:P2P_INVIT_RESP, dialogToken =%d, status:%d, op_ch:%d\n",
-                                         (tx == true)?"Tx":"Rx", dialogToken, status, op_ch);
-                               break;
-                       }
-                       case P2P_DEVDISC_REQ:
-                               DBG_8723A("RTW_%s:P2P_DEVDISC_REQ, dialogToken =%d\n", (tx == true)?"Tx":"Rx", dialogToken);
-                               break;
-                       case P2P_DEVDISC_RESP:
-                               cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, NULL, &cont_len);
-                               DBG_8723A("RTW_%s:P2P_DEVDISC_RESP, dialogToken =%d, status:%d\n", (tx == true)?"Tx":"Rx", dialogToken, cont?*cont:-1);
-                               break;
-                       case P2P_PROVISION_DISC_REQ:
-                       {
-                               size_t frame_body_len = len - sizeof(struct ieee80211_hdr_3addr);
-                               u8 *p2p_ie;
-                               uint p2p_ielen = 0;
-                               uint contentlen = 0;
-
-                               DBG_8723A("RTW_%s:P2P_PROVISION_DISC_REQ, dialogToken =%d\n", (tx == true)?"Tx":"Rx", dialogToken);
-
-                               pwdev_priv->provdisc_req_issued = false;
-
-                               p2p_ie = rtw_get_p2p_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_,
-                                                          frame_body_len - _PUBLIC_ACTION_IE_OFFSET_,
-                                                          NULL, &p2p_ielen);
-                               if (p2p_ie) {
-                                       if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, NULL, &contentlen))
-                                               pwdev_priv->provdisc_req_issued = false;/* case: p2p_client join p2p GO */
-                                       else
-                                               pwdev_priv->provdisc_req_issued = true;/* case: p2p_devices connection before Nego req. */
-                               }
-                       }
-                               break;
-                       case P2P_PROVISION_DISC_RESP:
-                               DBG_8723A("RTW_%s:P2P_PROVISION_DISC_RESP, dialogToken =%d\n", (tx == true)?"Tx":"Rx", dialogToken);
-                               break;
-                       default:
-                               DBG_8723A("RTW_%s:OUI_Subtype =%d, dialogToken =%d\n", (tx == true)?"Tx":"Rx", OUI_Subtype, dialogToken);
-                               break;
-                       }
-
-               }
-
-       }
-       else if (category == WLAN_CATEGORY_VENDOR_SPECIFIC)
-       {
-               OUI_Subtype = frame_body[5];
-               dialogToken = frame_body[6];
-
-               is_p2p_frame = OUI_Subtype;
-
-               switch (OUI_Subtype) {
-               case P2P_NOTICE_OF_ABSENCE:
-                       DBG_8723A("RTW_%s:P2P_NOTICE_OF_ABSENCE, dialogToken =%d\n", (tx == true)?"TX":"RX", dialogToken);
-                       break;
-               case P2P_PRESENCE_REQUEST:
-                       DBG_8723A("RTW_%s:P2P_PRESENCE_REQUEST, dialogToken =%d\n", (tx == true)?"TX":"RX", dialogToken);
-                       break;
-               case P2P_PRESENCE_RESPONSE:
-                       DBG_8723A("RTW_%s:P2P_PRESENCE_RESPONSE, dialogToken =%d\n", (tx == true)?"TX":"RX", dialogToken);
-                       break;
-               case P2P_GO_DISC_REQUEST:
-                       DBG_8723A("RTW_%s:P2P_GO_DISC_REQUEST, dialogToken =%d\n", (tx == true)?"TX":"RX", dialogToken);
-                       break;
-               default:
-                       DBG_8723A("RTW_%s:OUI_Subtype =%d, dialogToken =%d\n", (tx == true)?"TX":"RX", OUI_Subtype, dialogToken);
-                       break;
-               }
-
-       } else {
-               DBG_8723A("RTW_%s:action frame category =%d\n", (tx == true)?"TX":"RX", category);
-       }
-       return is_p2p_frame;
-}
-
-void rtw_init_cfg80211_wifidirect_info(struct rtw_adapter *padapter)
-{
-       struct cfg80211_wifidirect_info *pcfg80211_wdinfo = &padapter->cfg80211_wdinfo;
-
-       memset(pcfg80211_wdinfo, 0x00, sizeof(struct cfg80211_wifidirect_info));
-
-       setup_timer(&pcfg80211_wdinfo->remain_on_ch_timer,
-                   ro_ch_timer_process, (unsigned long)padapter);
-}
-
-void p2p_protocol_wk_hdl23a(struct rtw_adapter *padapter, int intCmdType)
-{
-       switch (intCmdType) {
-       case P2P_FIND_PHASE_WK:
-               find_phase_handler(padapter);
-               break;
-       case P2P_RESTORE_STATE_WK:
-               restore_p2p_state_handler(padapter);
-               break;
-       case P2P_PRE_TX_PROVDISC_PROCESS_WK:
-               pre_tx_provdisc_handler(padapter);
-               break;
-       case P2P_PRE_TX_INVITEREQ_PROCESS_WK:
-               pre_tx_invitereq_handler(padapter);
-               break;
-       case P2P_PRE_TX_NEGOREQ_PROCESS_WK:
-               pre_tx_negoreq_handler(padapter);
-               break;
-       case P2P_RO_CH_WK:
-               ro_ch_handler(padapter);
-               break;
-       }
-}
-
-#ifdef CONFIG_8723AU_P2P
-void process_p2p_ps_ie23a(struct rtw_adapter *padapter, u8 *IEs, u32 IELength)
-{
-       u8 * ies;
-       u32 ies_len;
-       u8 * p2p_ie;
-       u32     p2p_ielen = 0;
-       u8      noa_attr[MAX_P2P_IE_LEN] = { 0x00 };/*  NoA length should be n*(13) + 2 */
-       u32     attr_contentlen = 0;
-
-       struct wifidirect_info  *pwdinfo = &padapter->wdinfo;
-       u8      find_p2p = false, find_p2p_ps = false;
-       u8      noa_offset, noa_num, noa_index;
-
-
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-       {
-               return;
-       }
-       if (IELength <= _BEACON_IE_OFFSET_)
-               return;
-
-       ies = IEs + _BEACON_IE_OFFSET_;
-       ies_len = IELength - _BEACON_IE_OFFSET_;
-
-       p2p_ie = rtw_get_p2p_ie23a(ies, ies_len, NULL, &p2p_ielen);
-
-       while(p2p_ie)
-       {
-               find_p2p = true;
-               /*  Get Notice of Absence IE. */
-               if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_NOA, noa_attr, &attr_contentlen))
-               {
-                       find_p2p_ps = true;
-                       noa_index = noa_attr[0];
-
-                       if ((pwdinfo->p2p_ps_mode == P2P_PS_NONE) ||
-                               (noa_index != pwdinfo->noa_index))/*  if index change, driver should reconfigure related setting. */
-                       {
-                               pwdinfo->noa_index = noa_index;
-                               pwdinfo->opp_ps = noa_attr[1] >> 7;
-                               pwdinfo->ctwindow = noa_attr[1] & 0x7F;
-
-                               noa_offset = 2;
-                               noa_num = 0;
-                               /*  NoA length should be n*(13) + 2 */
-                               if (attr_contentlen > 2)
-                               {
-                                       while(noa_offset < attr_contentlen)
-                                       {
-                                               /* memcpy(&wifidirect_info->noa_count[noa_num], &noa_attr[noa_offset], 1); */
-                                               pwdinfo->noa_count[noa_num] = noa_attr[noa_offset];
-                                               noa_offset += 1;
-
-                                               memcpy(&pwdinfo->noa_duration[noa_num], &noa_attr[noa_offset], 4);
-                                               noa_offset += 4;
-
-                                               memcpy(&pwdinfo->noa_interval[noa_num], &noa_attr[noa_offset], 4);
-                                               noa_offset += 4;
-
-                                               memcpy(&pwdinfo->noa_start_time[noa_num], &noa_attr[noa_offset], 4);
-                                               noa_offset += 4;
-
-                                               noa_num++;
-                                       }
-                               }
-                               pwdinfo->noa_num = noa_num;
-
-                               if (pwdinfo->opp_ps == 1)
-                               {
-                                       pwdinfo->p2p_ps_mode = P2P_PS_CTWINDOW;
-                                       /*  driver should wait LPS for entering CTWindow */
-                                       if (padapter->pwrctrlpriv.bFwCurrentInPSMode == true)
-                                       {
-                                               p2p_ps_wk_cmd23a(padapter, P2P_PS_ENABLE, 1);
-                                       }
-                               }
-                               else if (pwdinfo->noa_num > 0)
-                               {
-                                       pwdinfo->p2p_ps_mode = P2P_PS_NOA;
-                                       p2p_ps_wk_cmd23a(padapter, P2P_PS_ENABLE, 1);
-                               }
-                               else if (pwdinfo->p2p_ps_mode > P2P_PS_NONE)
-                               {
-                                       p2p_ps_wk_cmd23a(padapter, P2P_PS_DISABLE, 1);
-                               }
-                       }
-
-                       break; /*  find target, just break. */
-               }
-
-               /* Get the next P2P IE */
-               p2p_ie = rtw_get_p2p_ie23a(p2p_ie+p2p_ielen, ies_len -(p2p_ie -ies + p2p_ielen), NULL, &p2p_ielen);
-
-       }
-
-       if (find_p2p == true)
-       {
-               if ((pwdinfo->p2p_ps_mode > P2P_PS_NONE) && (find_p2p_ps == false))
-               {
-                       p2p_ps_wk_cmd23a(padapter, P2P_PS_DISABLE, 1);
-               }
-       }
-
-
-}
-
-void p2p_ps_wk_hdl23a(struct rtw_adapter *padapter, u8 p2p_ps_state)
-{
-       struct pwrctrl_priv             *pwrpriv = &padapter->pwrctrlpriv;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-
-
-       /*  Pre action for p2p state */
-       switch (p2p_ps_state)
-       {
-               case P2P_PS_DISABLE:
-                       pwdinfo->p2p_ps_state = p2p_ps_state;
-
-                       rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state));
-
-                       pwdinfo->noa_index = 0;
-                       pwdinfo->ctwindow = 0;
-                       pwdinfo->opp_ps = 0;
-                       pwdinfo->noa_num = 0;
-                       pwdinfo->p2p_ps_mode = P2P_PS_NONE;
-                       if (padapter->pwrctrlpriv.bFwCurrentInPSMode == true)
-                       {
-                               if (pwrpriv->smart_ps == 0)
-                               {
-                                       pwrpriv->smart_ps = 2;
-                                       rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)&padapter->pwrctrlpriv.pwr_mode);
-                               }
-                       }
-                       break;
-               case P2P_PS_ENABLE:
-                       if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) {
-                               pwdinfo->p2p_ps_state = p2p_ps_state;
-
-                               if (pwdinfo->ctwindow > 0)
-                               {
-                                       if (pwrpriv->smart_ps != 0)
-                                       {
-                                               pwrpriv->smart_ps = 0;
-                                               DBG_8723A("%s(): Enter CTW, change SmartPS\n", __func__);
-                                               rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)&padapter->pwrctrlpriv.pwr_mode);
-                                       }
-                               }
-                               rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state));
-                       }
-                       break;
-               case P2P_PS_SCAN:
-               case P2P_PS_SCAN_DONE:
-               case P2P_PS_ALLSTASLEEP:
-                       if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) {
-                               pwdinfo->p2p_ps_state = p2p_ps_state;
-                               rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state));
-                       }
-                       break;
-               default:
-                       break;
-       }
-
-
-}
-
-u8 p2p_ps_wk_cmd23a(struct rtw_adapter*padapter, u8 p2p_ps_state, u8 enqueue)
-{
-       struct cmd_obj  *ph2c;
-       struct drvextra_cmd_parm        *pdrvextra_cmd_parm;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-       u8      res = _SUCCESS;
-
-
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-               return res;
-
-       if (enqueue) {
-               ph2c = (struct cmd_obj *)kzalloc(sizeof(struct cmd_obj),
-                                                GFP_ATOMIC);
-               if (!ph2c) {
-                       res = _FAIL;
-                       goto exit;
-               }
-
-               pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)
-                       kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
-               if (pdrvextra_cmd_parm == NULL) {
-                       kfree(ph2c);
-                       res = _FAIL;
-                       goto exit;
-               }
-
-               pdrvextra_cmd_parm->ec_id = P2P_PS_WK_CID;
-               pdrvextra_cmd_parm->type_size = p2p_ps_state;
-               pdrvextra_cmd_parm->pbuf = NULL;
-
-               init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
-
-               res = rtw_enqueue_cmd23a(pcmdpriv, ph2c);
-       }
-       else
-       {
-               p2p_ps_wk_hdl23a(padapter, p2p_ps_state);
-       }
-
-exit:
-
-
-
-       return res;
-}
-#endif /*  CONFIG_8723AU_P2P */
-
-static void reset_ch_sitesurvey_timer_process(unsigned long data)
-{
-       struct rtw_adapter *adapter = (struct rtw_adapter *)data;
-       struct  wifidirect_info *pwdinfo = &adapter->wdinfo;
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-               return;
-
-       DBG_8723A("[%s] In\n", __func__);
-       /*      Reset the operation channel information */
-       pwdinfo->rx_invitereq_info.operation_ch[0] = 0;
-       pwdinfo->rx_invitereq_info.scan_op_ch_only = 0;
-}
-
-static void reset_ch_sitesurvey_timer_process2(unsigned long data)
-{
-       struct rtw_adapter *adapter = (struct rtw_adapter *)data;
-       struct wifidirect_info *pwdinfo = &adapter->wdinfo;
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-               return;
-
-       DBG_8723A("[%s] In\n", __func__);
-       /*      Reset the operation channel information */
-       pwdinfo->p2p_info.operation_ch[0] = 0;
-       pwdinfo->p2p_info.scan_op_ch_only = 0;
-}
-
-static void restore_p2p_state_timer_process (unsigned long data)
-{
-       struct rtw_adapter *adapter = (struct rtw_adapter *)data;
-       struct  wifidirect_info         *pwdinfo = &adapter->wdinfo;
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-               return;
-
-       p2p_protocol_wk_cmd23a(adapter, P2P_RESTORE_STATE_WK);
-}
-
-static void pre_tx_scan_timer_process (unsigned long data)
-{
-       struct rtw_adapter *adapter = (struct rtw_adapter *)data;
-       struct wifidirect_info *pwdinfo = &adapter->wdinfo;
-       struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-               return;
-
-       spin_lock_bh(&pmlmepriv->lock);
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ))
-       {
-               if (true == pwdinfo->tx_prov_disc_info.benable) /*      the provision discovery request frame is trigger to send or not */
-               {
-                       p2p_protocol_wk_cmd23a(adapter, P2P_PRE_TX_PROVDISC_PROCESS_WK);
-                       /* issue23a_probereq_p2p(adapter, NULL); */
-                       /* _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); */
-               }
-       }
-       else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING))
-       {
-               if (true == pwdinfo->nego_req_info.benable)
-               {
-                       p2p_protocol_wk_cmd23a(adapter, P2P_PRE_TX_NEGOREQ_PROCESS_WK);
-               }
-       }
-       else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_INVITE_REQ))
-       {
-               if (true == pwdinfo->invitereq_info.benable)
-               {
-                       p2p_protocol_wk_cmd23a(adapter, P2P_PRE_TX_INVITEREQ_PROCESS_WK);
-               }
-       }
-       else
-       {
-               DBG_8723A("[%s] p2p_state is %d, ignore!!\n", __func__, rtw_p2p_state(pwdinfo));
-       }
-
-       spin_unlock_bh(&pmlmepriv->lock);
-}
-
-static void find_phase_timer_process (unsigned long data)
-{
-       struct rtw_adapter *adapter = (struct rtw_adapter *)data;
-       struct  wifidirect_info         *pwdinfo = &adapter->wdinfo;
-
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-               return;
-
-       adapter->wdinfo.find_phase_state_exchange_cnt++;
-
-       p2p_protocol_wk_cmd23a(adapter, P2P_FIND_PHASE_WK);
-}
-
-void reset_global_wifidirect_info23a(struct rtw_adapter *padapter)
-{
-       struct wifidirect_info  *pwdinfo;
-
-       pwdinfo = &padapter->wdinfo;
-       pwdinfo->persistent_supported = 0;
-       pwdinfo->session_available = true;
-       pwdinfo->wfd_tdls_enable = 0;
-       pwdinfo->wfd_tdls_weaksec = 0;
-}
-
-#ifdef CONFIG_8723AU_P2P
-int rtw_init_wifi_display_info(struct rtw_adapter* padapter)
-{
-       int     res = _SUCCESS;
-       struct wifi_display_info *pwfd_info = &padapter->wfd_info;
-
-       /*  Used in P2P and TDLS */
-       pwfd_info->rtsp_ctrlport = 554;
-       pwfd_info->peer_rtsp_ctrlport = 0;      /*      Reset to 0 */
-       pwfd_info->wfd_enable = false;
-       pwfd_info->wfd_device_type = WFD_DEVINFO_PSINK;
-       pwfd_info->scan_result_type = SCAN_RESULT_P2P_ONLY;
-
-       /*  Used in P2P */
-       pwfd_info->peer_session_avail = true;
-       pwfd_info->wfd_pc = false;
-
-       /*  Used in TDLS */
-       memset(pwfd_info->ip_address, 0x00, 4);
-       memset(pwfd_info->peer_ip_address, 0x00, 4);
-       return res;
-}
-#endif /* CONFIG_8723AU_P2P */
-
-void rtw_init_wifidirect_timers23a(struct rtw_adapter* padapter)
-{
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       setup_timer(&pwdinfo->find_phase_timer, find_phase_timer_process,
-                   (unsigned long)padapter);
-       setup_timer(&pwdinfo->restore_p2p_state_timer,
-                   restore_p2p_state_timer_process, (unsigned long)padapter);
-       setup_timer(&pwdinfo->pre_tx_scan_timer, pre_tx_scan_timer_process,
-                   (unsigned long)padapter);
-       setup_timer(&pwdinfo->reset_ch_sitesurvey,
-                   reset_ch_sitesurvey_timer_process, (unsigned long)padapter);
-       setup_timer(&pwdinfo->reset_ch_sitesurvey2,
-                   reset_ch_sitesurvey_timer_process2,
-                   (unsigned long)padapter);
-}
-
-void rtw_init_wifidirect_addrs23a(struct rtw_adapter* padapter, u8 *dev_addr, u8 *iface_addr)
-{
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-
-       /*init device&interface address */
-       if (dev_addr) {
-               memcpy(pwdinfo->device_addr, dev_addr, ETH_ALEN);
-       }
-       if (iface_addr) {
-               memcpy(pwdinfo->interface_addr, iface_addr, ETH_ALEN);
-       }
-#endif
-}
-
-void init_wifidirect_info23a(struct rtw_adapter *padapter, enum P2P_ROLE role)
-{
-       struct wifidirect_info  *pwdinfo;
-#ifdef CONFIG_8723AU_P2P
-       struct wifi_display_info        *pwfd_info = &padapter->wfd_info;
-#endif
-
-       pwdinfo = &padapter->wdinfo;
-
-       pwdinfo->padapter = padapter;
-
-       /*      1, 6, 11 are the social channel defined in the WiFi Direct specification. */
-       pwdinfo->social_chan[0] = 1;
-       pwdinfo->social_chan[1] = 6;
-       pwdinfo->social_chan[2] = 11;
-       pwdinfo->social_chan[3] = 0;    /*      channel 0 for scanning ending in site survey function. */
-
-       /*      Use the channel 11 as the listen channel */
-       pwdinfo->listen_channel = 11;
-
-       if (role == P2P_ROLE_DEVICE)
-       {
-               rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN);
-               pwdinfo->intent = 1;
-               rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_LISTEN);
-       }
-       else if (role == P2P_ROLE_CLIENT)
-       {
-               rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK);
-               pwdinfo->intent = 1;
-               rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK);
-       }
-       else if (role == P2P_ROLE_GO)
-       {
-               rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK);
-               pwdinfo->intent = 15;
-               rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK);
-       }
-
-/*     Use the OFDM rate in the P2P probe response frame. (6(B), 9(B), 12, 18, 24, 36, 48, 54) */
-       pwdinfo->support_rate[0] = 0x8c;        /*      6(B) */
-       pwdinfo->support_rate[1] = 0x92;        /*      9(B) */
-       pwdinfo->support_rate[2] = 0x18;        /*      12 */
-       pwdinfo->support_rate[3] = 0x24;        /*      18 */
-       pwdinfo->support_rate[4] = 0x30;        /*      24 */
-       pwdinfo->support_rate[5] = 0x48;        /*      36 */
-       pwdinfo->support_rate[6] = 0x60;        /*      48 */
-       pwdinfo->support_rate[7] = 0x6c;        /*      54 */
-
-       memcpy((void*) pwdinfo->p2p_wildcard_ssid, "DIRECT-", 7);
-
-       memset(pwdinfo->device_name, 0x00, WPS_MAX_DEVICE_NAME_LEN);
-       pwdinfo->device_name_len = 0;
-
-       memset(&pwdinfo->invitereq_info, 0x00, sizeof(struct tx_invite_req_info));
-       pwdinfo->invitereq_info.token = 3;      /*      Token used for P2P invitation request frame. */
-
-       memset(&pwdinfo->inviteresp_info, 0x00, sizeof(struct tx_invite_resp_info));
-       pwdinfo->inviteresp_info.token = 0;
-
-       pwdinfo->profileindex = 0;
-       memset(&pwdinfo->profileinfo[ 0 ], 0x00, sizeof(struct profile_info) * P2P_MAX_PERSISTENT_GROUP_NUM);
-
-       rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_NONE);
-
-       pwdinfo->listen_dwell = (u8) ((jiffies % 3) + 1);
-       /* DBG_8723A("[%s] listen_dwell time is %d00ms\n", __func__, pwdinfo->listen_dwell); */
-
-       memset(&pwdinfo->tx_prov_disc_info, 0x00, sizeof(struct tx_provdisc_req_info));
-       pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_NONE;
-
-       memset(&pwdinfo->nego_req_info, 0x00, sizeof(struct tx_nego_req_info));
-
-       pwdinfo->device_password_id_for_nego = WPS_DPID_PBC;
-       pwdinfo->negotiation_dialog_token = 1;
-
-       memset(pwdinfo->nego_ssid, 0x00, IEEE80211_MAX_SSID_LEN);
-       pwdinfo->nego_ssidlen = 0;
-
-       pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO;
-#ifdef CONFIG_8723AU_P2P
-       pwdinfo->supported_wps_cm = WPS_CONFIG_METHOD_DISPLAY  | WPS_CONFIG_METHOD_PBC;
-       pwdinfo->wfd_info = pwfd_info;
-#else
-       pwdinfo->supported_wps_cm = WPS_CONFIG_METHOD_DISPLAY | WPS_CONFIG_METHOD_PBC | WPS_CONFIG_METHOD_KEYPAD;
-#endif /* CONFIG_8723AU_P2P */
-       pwdinfo->channel_list_attr_len = 0;
-       memset(pwdinfo->channel_list_attr, 0x00, 100);
-
-       memset(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, 0x00, 4);
-       memset(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, '0', 3);
-       memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info));
-       pwdinfo->wfd_tdls_enable = 0;
-       memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN);
-       memset(pwdinfo->p2p_peer_device_addr, 0x00, ETH_ALEN);
-
-       pwdinfo->rx_invitereq_info.operation_ch[0] = 0;
-       pwdinfo->rx_invitereq_info.operation_ch[1] = 0; /*      Used to indicate the scan end in site survey function */
-       pwdinfo->rx_invitereq_info.scan_op_ch_only = 0;
-       pwdinfo->p2p_info.operation_ch[0] = 0;
-       pwdinfo->p2p_info.operation_ch[1] = 0;                  /*      Used to indicate the scan end in site survey function */
-       pwdinfo->p2p_info.scan_op_ch_only = 0;
-}
-
-int rtw_p2p_enable23a(struct rtw_adapter *padapter, enum P2P_ROLE role)
-{
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       int ret = _SUCCESS;
-
-       if (role == P2P_ROLE_DEVICE || role == P2P_ROLE_CLIENT ||
-           role == P2P_ROLE_GO) {
-               /* leave IPS/Autosuspend */
-               if (_FAIL == rtw_pwr_wakeup(padapter)) {
-                       ret = _FAIL;
-                       goto exit;
-               }
-
-               /*      Added by Albert 2011/03/22 */
-               /*      In the P2P mode, the driver should not support the b mode. */
-               /*      So, the Tx packet shouldn't use the CCK rate */
-               update_tx_basic_rate23a(padapter, WIRELESS_11AGN);
-
-               /* Enable P2P function */
-               init_wifidirect_info23a(padapter, role);
-
-               rtw_hal_set_odm_var23a(padapter, HAL_ODM_P2P_STATE, NULL, true);
-               #ifdef CONFIG_8723AU_P2P
-               rtw_hal_set_odm_var23a(padapter, HAL_ODM_WIFI_DISPLAY_STATE, NULL, true);
-               #endif
-
-       }
-       else if (role == P2P_ROLE_DISABLE)
-       {
-               if (_FAIL == rtw_pwr_wakeup(padapter)) {
-                       ret = _FAIL;
-                       goto exit;
-               }
-
-               /* Disable P2P function */
-               if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-               {
-                       del_timer_sync(&pwdinfo->find_phase_timer);
-                       del_timer_sync(&pwdinfo->restore_p2p_state_timer);
-                       del_timer_sync(&pwdinfo->pre_tx_scan_timer);
-                       del_timer_sync(&pwdinfo->reset_ch_sitesurvey);
-                       del_timer_sync(&pwdinfo->reset_ch_sitesurvey2);
-                       reset_ch_sitesurvey_timer_process((unsigned long)padapter);
-                       reset_ch_sitesurvey_timer_process2((unsigned long)padapter);
-                       rtw_p2p_set_state(pwdinfo, P2P_STATE_NONE);
-                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_DISABLE);
-                       memset(&pwdinfo->rx_prov_disc_info, 0x00, sizeof(struct rx_provdisc_req_info));
-               }
-
-               rtw_hal_set_odm_var23a(padapter, HAL_ODM_P2P_STATE, NULL, false);
-               #ifdef CONFIG_8723AU_P2P
-               rtw_hal_set_odm_var23a(padapter, HAL_ODM_WIFI_DISPLAY_STATE, NULL, false);
-               #endif
-
-               /* Restore to initial setting. */
-               update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode);
-       }
-
-exit:
-       return ret;
-}
-
-#endif /* CONFIG_8723AU_P2P */
index 8ddd67f194ba7bf406b083ea95ebd5a7d9a74d07..8a95ae1d353cbbb652b28df6db103e51482195b9 100644 (file)
@@ -17,6 +17,7 @@
 #include <osdep_service.h>
 #include <drv_types.h>
 #include <osdep_intf.h>
+#include <rtl8723a_cmd.h>
 
 #ifdef CONFIG_8723AU_BT_COEXIST
 #include <rtl8723a_hal.h>
@@ -108,33 +109,30 @@ static bool rtw_pwr_unassociated_idle(struct rtw_adapter *adapter)
        struct rtw_adapter *buddy = adapter->pbuddy_adapter;
        struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
        struct xmit_priv *pxmit_priv = &adapter->xmitpriv;
-       struct wifidirect_info *pwdinfo = &adapter->wdinfo;
 
        bool ret = false;
 
        if (time_after_eq(adapter->pwrctrlpriv.ips_deny_time, jiffies))
                goto exit;
 
-       if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR)
-               || check_fwstate(pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS)
-               || check_fwstate(pmlmepriv, WIFI_AP_STATE)
-               || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE)
-               || !rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)
-       ) {
+       if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) ||
+           check_fwstate(pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) ||
+           check_fwstate(pmlmepriv, WIFI_AP_STATE) ||
+           check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE)){
                goto exit;
        }
 
        /* consider buddy, if exist */
        if (buddy) {
                struct mlme_priv *b_pmlmepriv = &buddy->mlmepriv;
-               struct wifidirect_info *b_pwdinfo = &buddy->wdinfo;
-
-               if (check_fwstate(b_pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR)
-                       || check_fwstate(b_pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS)
-                       || check_fwstate(b_pmlmepriv, WIFI_AP_STATE)
-                       || check_fwstate(b_pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE)
-                       || !rtw_p2p_chk_state(b_pwdinfo, P2P_STATE_NONE)
-               ) {
+
+               if (check_fwstate(b_pmlmepriv,
+                                 WIFI_ASOC_STATE|WIFI_SITE_MONITOR) ||
+                   check_fwstate(b_pmlmepriv,
+                                 WIFI_UNDER_LINKING|WIFI_UNDER_WPS) ||
+                   check_fwstate(b_pmlmepriv, WIFI_AP_STATE) ||
+                   check_fwstate(b_pmlmepriv,
+                                 WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE)) {
                        goto exit;
                }
        }
@@ -263,7 +261,7 @@ void rtw_set_rpwm23a(struct rtw_adapter *padapter, u8 pslv)
 
        pwrpriv->rpwm = pslv;
 
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_SET_RPWM, (u8 *)(&rpwm));
+       rtl8723a_set_rpwm(padapter, rpwm);
 
        pwrpriv->tog += 0x80;
        pwrpriv->cpwm = pslv;
@@ -271,7 +269,7 @@ void rtw_set_rpwm23a(struct rtw_adapter *padapter, u8 pslv)
 
 }
 
-u8 PS_RDY_CHECK(struct rtw_adapter * padapter)
+static u8 PS_RDY_CHECK(struct rtw_adapter * padapter)
 {
        unsigned long delta_time;
        struct pwrctrl_priv     *pwrpriv = &padapter->pwrctrlpriv;
@@ -306,11 +304,6 @@ u8 PS_RDY_CHECK(struct rtw_adapter * padapter)
 void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode)
 {
        struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-#endif /* CONFIG_8723AU_P2P */
-
-
 
        RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_,
                         ("%s: PowerMode =%d Smart_PS =%d\n",
@@ -333,45 +326,29 @@ void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode, u8 smart_ps, u
        }
 
        if (ps_mode == PS_MODE_ACTIVE) {
-#ifdef CONFIG_8723AU_P2P
-               if (pwdinfo->opp_ps == 0)
-#endif /* CONFIG_8723AU_P2P */
-               {
-                       DBG_8723A("rtw_set_ps_mode23a: Leave 802.11 power save\n");
+               DBG_8723A("rtw_set_ps_mode23a: Leave 802.11 power save\n");
 
-                       pwrpriv->pwr_mode = ps_mode;
-                       rtw_set_rpwm23a(padapter, PS_STATE_S4);
-                       rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode));
-                       pwrpriv->bFwCurrentInPSMode = false;
-               }
-       }
-       else
-       {
+               pwrpriv->pwr_mode = ps_mode;
+               rtw_set_rpwm23a(padapter, PS_STATE_S4);
+               rtl8723a_set_FwPwrMode_cmd(padapter, ps_mode);
+               pwrpriv->bFwCurrentInPSMode = false;
+       } else {
                if (PS_RDY_CHECK(padapter)
 #ifdef CONFIG_8723AU_BT_COEXIST
                        || (BT_1Ant(padapter) == true)
 #endif
-                       )
-               {
+                       ) {
                        DBG_8723A("%s: Enter 802.11 power save\n", __func__);
 
                        pwrpriv->bFwCurrentInPSMode = true;
                        pwrpriv->pwr_mode = ps_mode;
                        pwrpriv->smart_ps = smart_ps;
                        pwrpriv->bcn_ant_mode = bcn_ant_mode;
-                       rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode));
-
-#ifdef CONFIG_8723AU_P2P
-                       /*  Set CTWindow after LPS */
-                       if (pwdinfo->opp_ps == 1)
-                               p2p_ps_wk_cmd23a(padapter, P2P_PS_ENABLE, 0);
-#endif /* CONFIG_8723AU_P2P */
+                       rtl8723a_set_FwPwrMode_cmd(padapter, ps_mode);
 
                        rtw_set_rpwm23a(padapter, PS_STATE_S2);
                }
        }
-
-
 }
 
 /*
@@ -391,12 +368,11 @@ s32 LPS_RF_ON_check23a(struct rtw_adapter *padapter, u32 delay_ms)
 
        while (1)
        {
-               rtw23a_hal_get_hwreg(padapter, HW_VAR_FWLPS_RF_ON, &bAwake);
-               if (true == bAwake)
+               bAwake = rtl8723a_get_fwlps_rf_on(padapter);
+               if (bAwake == true)
                        break;
 
-               if (true == padapter->bSurpriseRemoved)
-               {
+               if (padapter->bSurpriseRemoved == true) {
                        err = -2;
                        DBG_8723A("%s: device surprise removed!!\n", __func__);
                        break;
@@ -469,10 +445,6 @@ void LeaveAllPowerSaveMode23a(struct rtw_adapter *Adapter)
        /* DBG_8723A("%s.....\n", __func__); */
        if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
        { /* connect */
-#ifdef CONFIG_8723AU_P2P
-               p2p_ps_wk_cmd23a(Adapter, P2P_PS_DISABLE, enqueue);
-#endif /* CONFIG_8723AU_P2P */
-
                rtw_lps_ctrl_wk_cmd23a(Adapter, LPS_CTRL_LEAVE, enqueue);
        }
 
@@ -525,14 +497,6 @@ void rtw_free_pwrctrl_priv(struct rtw_adapter *adapter)
 {
 }
 
-u8 rtw_interface_ps_func23a(struct rtw_adapter *padapter, enum hal_intf_ps_func efunc_id, u8* val)
-{
-       u8 bResult = true;
-       rtw_hal_intf_ps_func23a(padapter, efunc_id, val);
-
-       return bResult;
-}
-
 inline void rtw_set_ips_deny23a(struct rtw_adapter *padapter, u32 ms)
 {
        struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
index 0b2455e4f5b681e5226937a0041aef1f738c1ff3..3791bbbdc58242c4a61ba15d6b16fa915f65f48b 100644 (file)
@@ -19,7 +19,6 @@
 #include <mlme_osdep.h>
 #include <linux/ip.h>
 #include <linux/if_ether.h>
-#include <ethernet.h>
 #include <usb_ops.h>
 #include <linux/ieee80211.h>
 #include <wifi.h>
@@ -80,8 +79,6 @@ int _rtw_init_recv_priv23a(struct recv_priv *precvpriv,
                list_add_tail(&precvframe->list,
                              &precvpriv->free_recv_queue.queue);
 
-               res = rtw_os_recv_resource_alloc23a(padapter, precvframe);
-
                precvframe->adapter = padapter;
                precvframe++;
        }
@@ -569,31 +566,35 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter,
 static struct recv_frame *portctrl(struct rtw_adapter *adapter,
                                   struct recv_frame *precv_frame)
 {
-       u8 *psta_addr = NULL, *ptr;
+       u8 *psta_addr, *ptr;
        uint auth_alg;
        struct recv_frame *pfhdr;
        struct sta_info *psta;
        struct sta_priv *pstapriv ;
        struct recv_frame *prtnframe;
-       u16 ether_type = 0;
-       u16 eapol_type = 0x888e;/* for Funia BD's WPA issue */
+       u16 ether_type;
+       u16 eapol_type = ETH_P_PAE;/* for Funia BD's WPA issue */
        struct rx_pkt_attrib *pattrib;
 
        pstapriv = &adapter->stapriv;
-       psta = rtw_get_stainfo23a(pstapriv, psta_addr);
 
        auth_alg = adapter->securitypriv.dot11AuthAlgrthm;
 
-       ptr = precv_frame->pkt->data;
        pfhdr = precv_frame;
        pattrib = &pfhdr->attrib;
        psta_addr = pattrib->ta;
+       psta = rtw_get_stainfo23a(pstapriv, psta_addr);
 
        RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
                 ("########portctrl:adapter->securitypriv.dot11AuthAlgrthm ="
                  "%d\n", adapter->securitypriv.dot11AuthAlgrthm));
 
-       if (auth_alg == 2) {
+       if (auth_alg == dot11AuthAlgrthm_8021X) {
+               /* get ether_type */
+               ptr = pfhdr->pkt->data + pfhdr->attrib.hdrlen;
+
+               ether_type = (ptr[6] << 8) | ptr[7];
+
                if ((psta != NULL) && (psta->ieee8021x_blocked)) {
                        /* blocked */
                        /* only accept EAPOL frame */
@@ -601,13 +602,6 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter,
                                 ("########portctrl:psta->ieee8021x_blocked =="
                                  "1\n"));
 
-                       prtnframe = precv_frame;
-
-                       /* get ether_type */
-                       ptr = ptr + pfhdr->attrib.hdrlen + LLC_HEADER_SIZE;
-                       memcpy(&ether_type, ptr, 2);
-                       ether_type = ntohs((unsigned short)ether_type);
-
                        if (ether_type == eapol_type) {
                                prtnframe = precv_frame;
                        } else {
@@ -651,9 +645,7 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter,
                prtnframe = precv_frame;
        }
 
-
-
-               return prtnframe;
+       return prtnframe;
 }
 
 int recv_decache(struct recv_frame *precv_frame, u8 bretry,
@@ -1222,8 +1214,8 @@ int validate_recv_ctrl_frame(struct rtw_adapter *padapter,
 
                                        /* upate BCN for TIM IE */
                                        /* update_BCNTIM(padapter); */
-                                       update_beacon23a(padapter, _TIM_IE_,
-                                                     NULL, false);
+                                       update_beacon23a(padapter, WLAN_EID_TIM,
+                                                        NULL, false);
                                }
 
                                /* spin_unlock_bh(&psta->sleep_q.lock); */
@@ -1254,8 +1246,8 @@ int validate_recv_ctrl_frame(struct rtw_adapter *padapter,
 
                                        /* upate BCN for TIM IE */
                                        /* update_BCNTIM(padapter); */
-                                       update_beacon23a(padapter, _TIM_IE_,
-                                                     NULL, false);
+                                       update_beacon23a(padapter, WLAN_EID_TIM,
+                                                        NULL, false);
                                }
                        }
                }
@@ -1942,8 +1934,8 @@ int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num)
        return true;
 }
 
-int enqueue_reorder_recvframe23a(struct recv_reorder_ctrl *preorder_ctrl,
-                             struct recv_frame *prframe)
+static int enqueue_reorder_recvframe23a(struct recv_reorder_ctrl *preorder_ctrl,
+                                       struct recv_frame *prframe)
 {
        struct rx_pkt_attrib *pattrib = &prframe->attrib;
        struct rtw_queue *ppending_recvframe_queue;
@@ -2102,7 +2094,7 @@ int recv_indicatepkt_reorder(struct rtw_adapter *padapter,
                /* s1. */
                wlanhdr_to_ethhdr(prframe);
 
-               if ((pattrib->qos!= 1) || (pattrib->eth_type == 0x0806) ||
+               if ((pattrib->qos!= 1) || (pattrib->eth_type == ETH_P_ARP) ||
                    (pattrib->ack_policy != 0)) {
                        if ((padapter->bDriverStopped == false) &&
                            (padapter->bSurpriseRemoved == false)) {
index 4f745920339083bdb2190dd53e44f0b0b006ad9b..5bf7beb6d19cdeb90e80eb8edb8f3c272bb88a55 100644 (file)
@@ -99,7 +99,8 @@ static void sreset_restore_security_station(struct rtw_adapter *padapter)
                val8 = 0xcc;
        else
                val8 = 0xcf;
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8));
+
+       rtl8723a_set_sec_cfg(padapter, val8);
 
        if ((padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_) ||
            (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) {
@@ -131,23 +132,16 @@ static void sreset_restore_network_station(struct rtw_adapter *padapter)
                        threshold = 1;
                else
                        threshold = 0;
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold));
-       } else {
+       } else
                threshold = 1;
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold));
-       }
 
-       set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
+       rtl8723a_set_rxdma_agg_pg_th(padapter, threshold);
 
-       /* disable dynamic functions, such as high power, DIG */
-       /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); */
+       set_channel_bwmode23a(padapter, pmlmeext->cur_channel,
+                             pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
 
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, pmlmeinfo->network.MacAddress);
-
-       {
-               u8      join_type = 0;
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type));
-       }
+       hw_var_set_bssid(padapter, pmlmeinfo->network.MacAddress);
+       hw_var_set_mlme_join(padapter, 0);
 
        Set_MSR23a(padapter, (pmlmeinfo->state & 0x3));
 
index 451b58f47287989069e4e66630882894ba80417e..53dd3207ecef707edf1f01d1910bf72cdeab3d9a 100644 (file)
@@ -21,7 +21,7 @@
 #include <mlme_osdep.h>
 #include <sta_info.h>
 
-void _rtw_init_stainfo(struct sta_info *psta)
+static void _rtw_init_stainfo(struct sta_info *psta)
 {
        memset((u8 *)psta, 0, sizeof (struct sta_info));
        spin_lock_init(&psta->lock);
@@ -109,7 +109,7 @@ inline struct sta_info *rtw_get_stainfo23a_by_offset23a(struct sta_priv *stapriv
 }
 
 /*  this function is used to free the memory of lock || sema for all stainfos */
-void rtw_mfree_all_stainfo(struct sta_priv *pstapriv)
+static void rtw_mfree_all_stainfo(struct sta_priv *pstapriv)
 {
        struct list_head *plist, *phead;
        struct sta_info *psta;
@@ -124,7 +124,7 @@ void rtw_mfree_all_stainfo(struct sta_priv *pstapriv)
        spin_unlock_bh(&pstapriv->sta_hash_lock);
 }
 
-void rtw_mfree_sta_priv_lock(struct    sta_priv *pstapriv)
+static void rtw_mfree_sta_priv_lock(struct sta_priv *pstapriv)
 {
        rtw_mfree_all_stainfo(pstapriv); /* be done before free sta_hash_lock */
 }
@@ -405,12 +405,12 @@ void rtw_free_all_stainfo23a(struct rtw_adapter *padapter)
 }
 
 /* any station allocated can be searched by hash list */
-struct sta_info *rtw_get_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr)
+struct sta_info *rtw_get_stainfo23a(struct sta_priv *pstapriv, const u8 *hwaddr)
 {
        struct list_head *plist, *phead;
        struct sta_info *psta = NULL;
        u32     index;
-       u8 *addr;
+       const u8 *addr;
        u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 
        if (hwaddr == NULL)
index 99d81e612e7b69bf8cc368af3f41f842dc197367..09f3a66010d991759ca9da6c9073fcd566ab64c9 100644 (file)
@@ -140,7 +140,7 @@ u8 judge_network_type23a(struct rtw_adapter *padapter, unsigned char *rate, int
        return  network_type;
 }
 
-unsigned char ratetbl_val_2wifirate(unsigned char rate)
+static unsigned char ratetbl_val_2wifirate(unsigned char rate)
 {
        unsigned char val = 0;
 
@@ -185,7 +185,7 @@ unsigned char ratetbl_val_2wifirate(unsigned char rate)
        return val;
 }
 
-int is_basicrate(struct rtw_adapter *padapter, unsigned char rate)
+static int is_basicrate(struct rtw_adapter *padapter, unsigned char rate)
 {
        int i;
        unsigned char val;
@@ -203,7 +203,8 @@ int is_basicrate(struct rtw_adapter *padapter, unsigned char rate)
        return false;
 }
 
-unsigned int ratetbl2rateset(struct rtw_adapter *padapter, unsigned char *rateset)
+static unsigned int ratetbl2rateset(struct rtw_adapter *padapter,
+                                   unsigned char *rateset)
 {
        int i;
        unsigned char rate;
@@ -283,35 +284,9 @@ void Update23aTblForSoftAP(u8 *bssrateset, u32 bssratelen)
        }
 }
 
-void Save_DM_Func_Flag23a(struct rtw_adapter *padapter)
-{
-       u8      bSaveFlag = true;
-
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&bSaveFlag));
-}
-
-void Restore_DM_Func_Flag23a(struct rtw_adapter *padapter)
-{
-       u8      bSaveFlag = false;
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&bSaveFlag));
-}
-
-void Switch_DM_Func23a(struct rtw_adapter *padapter, unsigned long mode, u8 enable)
-{
-       if (enable == true)
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_DM_FUNC_SET, (u8 *)(&mode));
-       else
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_DM_FUNC_CLR, (u8 *)(&mode));
-}
-
-static void Set_NETYPE0_MSR(struct rtw_adapter *padapter, u8 type)
-{
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_MEDIA_STATUS, (u8 *)(&type));
-}
-
 void Set_MSR23a(struct rtw_adapter *padapter, u8 type)
 {
-               Set_NETYPE0_MSR(padapter, type);
+       rtl8723a_set_media_status(padapter, type);
 }
 
 inline u8 rtw_get_oper_ch23a(struct rtw_adapter *adapter)
@@ -483,51 +458,9 @@ unsigned int decide_wait_for_beacon_timeout23a(unsigned int bcn_interval)
                return bcn_interval << 2;
 }
 
-void CAM_empty_entry23a(struct rtw_adapter *Adapter, u8 ucIndex)
-{
-       rtw_hal_set_hwreg23a(Adapter, HW_VAR_CAM_EMPTY_ENTRY, (u8 *)(&ucIndex));
-}
-
 void invalidate_cam_all23a(struct rtw_adapter *padapter)
 {
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_CAM_INVALID_ALL, NULL);
-}
-
-void write_cam23a(struct rtw_adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key)
-{
-       unsigned int    i, val, addr;
-       int j;
-       u32     cam_val[2];
-
-       addr = entry << 3;
-
-       for (j = 5; j >= 0; j--) {
-               switch (j) {
-               case 0:
-                       val = (ctrl | (mac[0] << 16) | (mac[1] << 24));
-                       break;
-               case 1:
-                       val = (mac[2] | (mac[3] << 8) | (mac[4] << 16) | (mac[5] << 24));
-                       break;
-               default:
-                       i = (j - 2) << 2;
-                       val = (key[i] | (key[i+1] << 8) | (key[i+2] << 16) | (key[i+3] << 24));
-                       break;
-               }
-
-               cam_val[0] = val;
-               cam_val[1] = addr + (unsigned int)j;
-
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_CAM_WRITE, (u8 *)cam_val);
-
-               /* rtw_write32(padapter, WCAMI, val); */
-
-               /* cmd = CAM_POLLINIG | CAM_WRITE | (addr + j); */
-               /* rtw_write32(padapter, RWCAM, cmd); */
-
-               /* DBG_8723A("%s => cam write: %x, %x\n", __func__, cmd, val); */
-
-       }
+       rtl8723a_cam_invalid_all(padapter);
 }
 
 void clear_cam_entry23a(struct rtw_adapter *padapter, u8 entry)
@@ -536,7 +469,7 @@ void clear_cam_entry23a(struct rtw_adapter *padapter, u8 entry)
 
        unsigned char null_key[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
 
-       write_cam23a(padapter, entry, 0, null_sta, null_key);
+       rtl8723a_cam_write(padapter, entry, 0, null_sta, null_key);
 }
 
 int allocate_fw_sta_entry23a(struct rtw_adapter *padapter)
@@ -561,37 +494,11 @@ void flush_all_cam_entry23a(struct rtw_adapter *padapter)
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
 
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_CAM_INVALID_ALL, NULL);
+       rtl8723a_cam_invalid_all(padapter);
 
        memset((u8 *)(pmlmeinfo->FW_sta_info), 0, sizeof(pmlmeinfo->FW_sta_info));
 }
 
-#if defined(CONFIG_8723AU_P2P) && defined(CONFIG_8723AU_P2P)
-int WFD_info_handler(struct rtw_adapter *padapter, struct ndis_802_11_var_ies *        pIE)
-{
-       struct wifidirect_info  *pwdinfo;
-       u8      wfd_ie[MAX_WFD_IE_LEN] = {0x00};
-       u32     wfd_ielen = 0;
-
-       pwdinfo = &padapter->wdinfo;
-       if (rtw_get_wfd_ie((u8 *) pIE, pIE->Length, wfd_ie, &wfd_ielen)) {
-               u8      attr_content[ 10 ] = { 0x00 };
-               u32     attr_contentlen = 0;
-
-               DBG_8723A("[%s] Found WFD IE\n", __func__);
-               rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen);
-               if (attr_contentlen) {
-                       pwdinfo->wfd_info->peer_rtsp_ctrlport = get_unaligned_be16(attr_content + 2);
-                       DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport);
-                       return true;
-               }
-       } else {
-               DBG_8723A("[%s] NO WFD IE\n", __func__);
-       }
-       return _FAIL;
-}
-#endif
-
 int WMM_param_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies *    pIE)
 {
        /* struct registry_priv *pregpriv = &padapter->registrypriv; */
@@ -649,22 +556,22 @@ void WMMOnAssocRsp23a(struct rtw_adapter *padapter)
 
                switch (ACI) {
                case 0x0:
-                       rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acParm));
+                       rtl8723a_set_ac_param_be(padapter, acParm);
                        acm_mask |= (ACM? BIT(1):0);
                        edca[XMIT_BE_QUEUE] = acParm;
                        break;
                case 0x1:
-                       rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acParm));
+                       rtl8723a_set_ac_param_bk(padapter, acParm);
                        /* acm_mask |= (ACM? BIT(0):0); */
                        edca[XMIT_BK_QUEUE] = acParm;
                        break;
                case 0x2:
-                       rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acParm));
+                       rtl8723a_set_ac_param_vi(padapter, acParm);
                        acm_mask |= (ACM? BIT(2):0);
                        edca[XMIT_VI_QUEUE] = acParm;
                        break;
                case 0x3:
-                       rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acParm));
+                       rtl8723a_set_ac_param_vo(padapter, acParm);
                        acm_mask |= (ACM? BIT(3):0);
                        edca[XMIT_VO_QUEUE] = acParm;
                        break;
@@ -674,7 +581,7 @@ void WMMOnAssocRsp23a(struct rtw_adapter *padapter)
        }
 
        if (padapter->registrypriv.acm_method == 1)
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_ACM_CTRL, (u8 *)(&acm_mask));
+               rtl8723a_set_acm_ctrl(padapter, acm_mask);
        else
                padapter->mlmepriv.acm_mask = acm_mask;
 
@@ -838,7 +745,7 @@ void HT_caps_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies
        pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info = le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info);
        pmlmeinfo->HT_caps.u.HT_cap_element.HT_ext_caps = le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_ext_caps);
 
-       rtw23a_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
+       rf_type = rtl8723a_get_rf_type(padapter);
 
        /* update the MCS rates */
        for (i = 0; i < 16; i++) {
@@ -896,9 +803,8 @@ void HTOnAssocRsp23a(struct rtw_adapter *padapter)
 
        min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2;
 
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing));
-
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len));
+       rtl8723a_set_ampdu_min_space(padapter, min_MPDU_spacing);
+       rtl8723a_set_ampdu_factor(padapter, max_AMPDU_len);
 }
 
 void ERP_IE_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies * pIE)
@@ -951,116 +857,135 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta)
        }
 }
 
-int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_len)
+int rtw_check_bcn_info23a(struct rtw_adapter *Adapter,
+                         struct ieee80211_mgmt *mgmt, u32 pkt_len)
 {
-       unsigned int            len;
-       unsigned char           *p;
-       unsigned short  val16;
        struct wlan_network *cur_network = &Adapter->mlmepriv.cur_network;
-       u16 wpa_len = 0, rsn_len = 0;
-       u8 encryp_protocol = 0;
+       struct HT_info_element *pht_info;
+       struct ieee80211_ht_cap *pht_cap;
        struct wlan_bssid_ex *bssid;
-       int group_cipher = 0, pairwise_cipher = 0, is_8021x = 0;
-       unsigned char *pbuf;
-       u32 wpa_ielen = 0;
-       u32 hidden_ssid = 0;
-       struct HT_info_element *pht_info = NULL;
-       struct ieee80211_ht_cap *pht_cap = NULL;
+       unsigned short val16;
+       u16 wpa_len = 0, rsn_len = 0;
+       u8 encryp_protocol;
+       int group_cipher = 0, pairwise_cipher = 0, is_8021x = 0, r;
        u32 bcn_channel;
-       unsigned short  ht_cap_info;
-       unsigned char   ht_info_infos_0;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) pframe;
-       u8 *pbssid = hdr->addr3;
+       unsigned short ht_cap_info;
+       unsigned char ht_info_infos_0;
+       int len, pie_len, ie_offset;
+       const u8 *p;
+       u8 *pie;
 
        if (is_client_associated_to_ap23a(Adapter) == false)
                return true;
 
-       len = packet_len - sizeof(struct ieee80211_hdr_3addr);
+       if (unlikely(!ieee80211_is_beacon(mgmt->frame_control))) {
+               printk(KERN_WARNING "%s: received a non beacon frame!\n",
+                      __func__);
+               return false;
+       }
+
+       len = pkt_len - sizeof(struct ieee80211_hdr_3addr);
 
        if (len > MAX_IE_SZ) {
                DBG_8723A("%s IE too long for survey event\n", __func__);
                return _FAIL;
        }
 
-       if (memcmp(cur_network->network.MacAddress, pbssid, 6)) {
-               DBG_8723A("Oops: rtw_check_network_encrypt linked but recv other bssid bcn\n" MAC_FMT MAC_FMT,
-                               MAC_ARG(pbssid), MAC_ARG(cur_network->network.MacAddress));
+       if (memcmp(cur_network->network.MacAddress, mgmt->bssid, 6)) {
+               DBG_8723A("Oops: rtw_check_network_encrypt linked but recv "
+                         "other bssid bcn\n" MAC_FMT MAC_FMT,
+                         MAC_ARG(mgmt->bssid),
+                         MAC_ARG(cur_network->network.MacAddress));
                return true;
        }
 
        bssid = (struct wlan_bssid_ex *)kzalloc(sizeof(struct wlan_bssid_ex),
-               GFP_ATOMIC);
+                                               GFP_ATOMIC);
+       if (!bssid)
+               return _FAIL;
 
-       if (ieee80211_is_beacon(hdr->frame_control))
-               bssid->reserved = 1;
+       bssid->reserved = 1;
 
-       bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len;
+       bssid->Length = offsetof(struct wlan_bssid_ex, IEs) + len;
 
        /* below is to copy the information element */
        bssid->IELength = len;
-       memcpy(bssid->IEs, (pframe + sizeof(struct ieee80211_hdr_3addr)), bssid->IELength);
+       memcpy(bssid->IEs, &mgmt->u, len);
 
        /* check bw and channel offset */
        /* parsing HT_CAP_IE */
-       p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
-       if (p && len>0) {
-                       pht_cap = (struct ieee80211_ht_cap *)(p + 2);
-                       ht_cap_info = pht_cap->cap_info;
+       ie_offset = offsetof(struct ieee80211_mgmt, u.beacon.variable) -
+               offsetof(struct ieee80211_mgmt, u);
+       pie = bssid->IEs + ie_offset;
+       pie_len = pkt_len - ie_offset;
+
+       p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, pie, pie_len);
+       if (p && p[1] > 0) {
+               pht_cap = (struct ieee80211_ht_cap *)(p + 2);
+               ht_cap_info = pht_cap->cap_info;
        } else {
-                       ht_cap_info = 0;
+               pht_cap = NULL;
+               ht_cap_info = 0;
        }
+
        /* parsing HT_INFO_IE */
-       p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
-       if (p && len>0) {
-                       pht_info = (struct HT_info_element *)(p + 2);
-                       ht_info_infos_0 = pht_info->infos[0];
+       p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, pie, pie_len);
+       if (p && p[1] > 0) {
+               pht_info = (struct HT_info_element *)(p + 2);
+               ht_info_infos_0 = pht_info->infos[0];
        } else {
-                       ht_info_infos_0 = 0;
+               pht_info = NULL;
+               ht_info_infos_0 = 0;
        }
+
        if (ht_cap_info != cur_network->BcnInfo.ht_cap_info ||
-               ((ht_info_infos_0&0x03) != (cur_network->BcnInfo.ht_info_infos_0&0x03))) {
-                       DBG_8723A("%s bcn now: ht_cap_info:%x ht_info_infos_0:%x\n", __func__,
-                                                       ht_cap_info, ht_info_infos_0);
-                       DBG_8723A("%s bcn link: ht_cap_info:%x ht_info_infos_0:%x\n", __func__,
-                                                       cur_network->BcnInfo.ht_cap_info, cur_network->BcnInfo.ht_info_infos_0);
-                       DBG_8723A("%s bw mode change, disconnect\n", __func__);
-                       /* bcn_info_update */
-                       cur_network->BcnInfo.ht_cap_info = ht_cap_info;
-                       cur_network->BcnInfo.ht_info_infos_0 = ht_info_infos_0;
-                       /* to do : need to check that whether modify related register of BB or not */
+           ((ht_info_infos_0 & 0x03) !=
+            (cur_network->BcnInfo.ht_info_infos_0 & 0x03))) {
+               DBG_8723A("%s bcn now: ht_cap_info:%x ht_info_infos_0:%x\n",
+                         __func__, ht_cap_info, ht_info_infos_0);
+               DBG_8723A("%s bcn link: ht_cap_info:%x ht_info_infos_0:%x\n",
+                         __func__, cur_network->BcnInfo.ht_cap_info,
+                         cur_network->BcnInfo.ht_info_infos_0);
+               DBG_8723A("%s bw mode change, disconnect\n", __func__);
+               /* bcn_info_update */
+               cur_network->BcnInfo.ht_cap_info = ht_cap_info;
+               cur_network->BcnInfo.ht_info_infos_0 = ht_info_infos_0;
+               /* to do : need to check that whether modify related
+                  register of BB or not */
        }
 
        /* Checking for channel */
-       p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, _DSSET_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
-       if (p) {
-                       bcn_channel = *(p + 2);
-       } else {/* In 5G, some ap do not have DSSET IE checking HT info for channel */
-                       p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
-                       if (pht_info) {
-                                       bcn_channel = pht_info->primary_channel;
-                       } else { /* we don't find channel IE, so don't check it */
-                                       DBG_8723A("Oops: %s we don't find channel IE, so don't check it\n", __func__);
-                                       bcn_channel = Adapter->mlmeextpriv.cur_channel;
-                       }
+       p = cfg80211_find_ie(WLAN_EID_DS_PARAMS, pie, pie_len);
+       if (p)
+               bcn_channel = p[2];
+       else {
+               /* In 5G, some ap do not have DSSET IE checking HT
+                  info for channel */
+               p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, pie, pie_len);
+
+               if (pht_info)
+                       bcn_channel = pht_info->primary_channel;
+               else { /* we don't find channel IE, so don't check it */
+                       DBG_8723A("Oops: %s we don't find channel IE, so don't "
+                                 "check it\n", __func__);
+                       bcn_channel = Adapter->mlmeextpriv.cur_channel;
+               }
        }
        if (bcn_channel != Adapter->mlmeextpriv.cur_channel) {
-                       DBG_8723A("%s beacon channel:%d cur channel:%d disconnect\n", __func__,
-                                                  bcn_channel, Adapter->mlmeextpriv.cur_channel);
-                       goto _mismatch;
+               DBG_8723A("%s beacon channel:%d cur channel:%d disconnect\n",
+                         __func__, bcn_channel,
+                         Adapter->mlmeextpriv.cur_channel);
+               goto _mismatch;
        }
 
        /* checking SSID */
-       if ((p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, _SSID_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_)) == NULL) {
-               DBG_8723A("%s marc: cannot find SSID for survey event\n", __func__);
-               hidden_ssid = true;
-       } else {
-               hidden_ssid = false;
-       }
-
-       if ((NULL != p) && (false == hidden_ssid && (*(p + 1)))) {
-               memcpy(bssid->Ssid.ssid, (p + 2), *(p + 1));
-               bssid->Ssid.ssid_len = *(p + 1);
+       p = cfg80211_find_ie(WLAN_EID_SSID, pie, pie_len);
+       if (p && p[1]) {
+               memcpy(bssid->Ssid.ssid, p + 2, p[1]);
+               bssid->Ssid.ssid_len = p[1];
        } else {
+               DBG_8723A("%s marc: cannot find SSID for survey event\n",
+                         __func__);
                bssid->Ssid.ssid_len = 0;
                bssid->Ssid.ssid[0] = '\0';
        }
@@ -1083,7 +1008,7 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_le
        }
 
        /* check encryption info */
-       val16 = rtw_get_capability23a((struct wlan_bssid_ex *)bssid);
+       val16 = rtw_get_capability23a(bssid);
 
        if (val16 & BIT(4))
                bssid->Privacy = 1;
@@ -1091,60 +1016,83 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_le
                bssid->Privacy = 0;
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                       ("%s(): cur_network->network.Privacy is %d, bssid.Privacy is %d\n",
-                        __func__, cur_network->network.Privacy, bssid->Privacy));
+                ("%s(): cur_network->network.Privacy is %d, bssid.Privacy "
+                 "is %d\n", __func__, cur_network->network.Privacy,
+                 bssid->Privacy));
        if (cur_network->network.Privacy != bssid->Privacy) {
                DBG_8723A("%s(), privacy is not match return FAIL\n", __func__);
                goto _mismatch;
        }
 
-       rtw_get_sec_ie23a(bssid->IEs, bssid->IELength, NULL,&rsn_len, NULL,&wpa_len);
+       rtw_get_sec_ie23a(bssid->IEs, bssid->IELength, NULL, &rsn_len, NULL,
+                         &wpa_len);
 
-       if (rsn_len > 0) {
+       if (rsn_len > 0)
                encryp_protocol = ENCRYP_PROTOCOL_WPA2;
-       } else if (wpa_len > 0) {
+       else if (wpa_len > 0)
                encryp_protocol = ENCRYP_PROTOCOL_WPA;
-       else {
+       else {
                if (bssid->Privacy)
                        encryp_protocol = ENCRYP_PROTOCOL_WEP;
+               else
+                       encryp_protocol = ENCRYP_PROTOCOL_OPENSYS;
        }
 
        if (cur_network->BcnInfo.encryp_protocol != encryp_protocol) {
-               DBG_8723A("%s(): enctyp is not match , return FAIL\n", __func__);
+               DBG_8723A("%s(): enctyp is not match, return FAIL\n", __func__);
                goto _mismatch;
        }
 
-       if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) {
-               pbuf = rtw_get_wpa_ie23a(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12);
-               if (pbuf && (wpa_ielen>0)) {
-                       if (_SUCCESS == rtw_parse_wpa_ie23a(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) {
+       if (encryp_protocol == ENCRYP_PROTOCOL_WPA ||
+           encryp_protocol == ENCRYP_PROTOCOL_WPA2) {
+               p = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
+                                           WLAN_OUI_TYPE_MICROSOFT_WPA,
+                                           pie, pie_len);
+               if (p && p[1] > 0) {
+                       r = rtw_parse_wpa_ie23a(p, p[1] + 2, &group_cipher,
+                                               &pairwise_cipher, &is_8021x);
+                       if (r == _SUCCESS)
                                RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                                               ("%s pnetwork->pairwise_cipher: %d, group_cipher is %d, is_8021x is %d\n", __func__,
-                                                pairwise_cipher, group_cipher, is_8021x));
-                       }
+                                        ("%s pnetwork->pairwise_cipher: %d, "
+                                         "group_cipher is %d, is_8021x is "
+                                         "%d\n", __func__, pairwise_cipher,
+                                         group_cipher, is_8021x));
                } else {
-                       pbuf = rtw_get_wpa2_ie23a(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12);
-
-                       if (pbuf && (wpa_ielen>0)) {
-                               if (_SUCCESS == rtw_parse_wpa2_ie23a(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) {
-                                       RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                                                       ("%s pnetwork->pairwise_cipher: %d, pnetwork->group_cipher is %d, is_802x is %d\n",
-                                                        __func__, pairwise_cipher, group_cipher, is_8021x));
-                               }
+                       p = cfg80211_find_ie(WLAN_EID_RSN, pie, pie_len);
+
+                       if (p && p[1] > 0) {
+                               r = rtw_parse_wpa2_ie23a(p, p[1] + 2,
+                                                        &group_cipher,
+                                                        &pairwise_cipher,
+                                                        &is_8021x);
+                               if (r == _SUCCESS)
+                                       RT_TRACE(_module_rtl871x_mlme_c_,
+                                                _drv_info_,
+                                                ("%s pnetwork->pairwise_cipher"
+                                                 ": %d, pnetwork->group_cipher"
+                                                 " is %d, is_802x is %d\n",
+                                                 __func__, pairwise_cipher,
+                                                 group_cipher, is_8021x));
                        }
                }
 
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                               ("%s cur_network->group_cipher is %d: %d\n", __func__, cur_network->BcnInfo.group_cipher, group_cipher));
-               if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher || group_cipher != cur_network->BcnInfo.group_cipher) {
-                       DBG_8723A("%s pairwise_cipher(%x:%x) or group_cipher(%x:%x) is not match , return FAIL\n", __func__,
-                                       pairwise_cipher, cur_network->BcnInfo.pairwise_cipher,
-                                       group_cipher, cur_network->BcnInfo.group_cipher);
+                        ("%s cur_network->group_cipher is %d: %d\n", __func__,
+                         cur_network->BcnInfo.group_cipher, group_cipher));
+               if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher ||
+                   group_cipher != cur_network->BcnInfo.group_cipher) {
+                       DBG_8723A("%s pairwise_cipher(%x:%x) or group_cipher "
+                                 "(%x:%x) is not match, return FAIL\n",
+                                 __func__, pairwise_cipher,
+                                 cur_network->BcnInfo.pairwise_cipher,
+                                 group_cipher,
+                                 cur_network->BcnInfo.group_cipher);
                        goto _mismatch;
                }
 
                if (is_8021x != cur_network->BcnInfo.is_8021x) {
-                       DBG_8723A("%s authentication is not match , return FAIL\n", __func__);
+                       DBG_8723A("%s authentication is not match, return "
+                                 "FAIL\n", __func__);
                        goto _mismatch;
                }
        }
@@ -1171,11 +1119,11 @@ void update_beacon23a_info(struct rtw_adapter *padapter, u8 *pframe, uint pkt_le
                pIE = (struct ndis_802_11_var_ies *)(pframe + (_BEACON_IE_OFFSET_ + sizeof(struct ieee80211_hdr_3addr)) + i);
 
                switch (pIE->ElementID) {
-               case _HT_EXTRA_INFO_IE_:        /* HT info */
+               case WLAN_EID_HT_OPERATION:     /* HT info */
                        /* HT_info_handler23a(padapter, pIE); */
                        bwmode_update_check(padapter, pIE);
                        break;
-               case _ERPINFO_IE_:
+               case WLAN_EID_ERP_INFO:
                        ERP_IE_handler23a(padapter, pIE);
                        VCS_update23a(padapter, psta);
                        break;
@@ -1194,16 +1142,16 @@ unsigned int is_ap_in_tkip23a(struct rtw_adapter *padapter)
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct wlan_bssid_ex *cur_network = &pmlmeinfo->network;
 
-       if (rtw_get_capability23a((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) {
+       if (rtw_get_capability23a(cur_network) & WLAN_CAPABILITY_PRIVACY) {
                for (i = sizeof(struct ndis_802_11_fixed_ies); i < pmlmeinfo->network.IELength;) {
                        pIE = (struct ndis_802_11_var_ies *)(pmlmeinfo->network.IEs + i);
 
                        switch (pIE->ElementID) {
-                       case _VENDOR_SPECIFIC_IE_:
-                               if ((!memcmp(pIE->data, RTW_WPA_OUI23A, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER23A, 4)))
+                       case WLAN_EID_VENDOR_SPECIFIC:
+                               if ((!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER23A, 4)))
                                        return true;
                                break;
-                       case _RSN_IE_2_:
+                       case WLAN_EID_RSN:
                                if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER23A, 4))
                                        return true;
                                break;
@@ -1225,18 +1173,18 @@ unsigned int should_forbid_n_rate23a(struct rtw_adapter * padapter)
        struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
        struct wlan_bssid_ex  *cur_network = &pmlmepriv->cur_network.network;
 
-       if (rtw_get_capability23a((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) {
+       if (rtw_get_capability23a(cur_network) & WLAN_CAPABILITY_PRIVACY) {
                for (i = sizeof(struct ndis_802_11_fixed_ies); i < cur_network->IELength;) {
                        pIE = (struct ndis_802_11_var_ies *)(cur_network->IEs + i);
 
                        switch (pIE->ElementID) {
-                       case _VENDOR_SPECIFIC_IE_:
-                               if (!memcmp(pIE->data, RTW_WPA_OUI23A, 4) &&
+                       case WLAN_EID_VENDOR_SPECIFIC:
+                               if (!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4) &&
                                        ((!memcmp((pIE->data + 12), WPA_CIPHER_SUITE_CCMP23A, 4)) ||
                                          (!memcmp((pIE->data + 16), WPA_CIPHER_SUITE_CCMP23A, 4))))
                                        return false;
                                break;
-                       case _RSN_IE_2_:
+                       case WLAN_EID_RSN:
                                if  ((!memcmp((pIE->data + 8), RSN_CIPHER_SUITE_CCMP23A, 4))  ||
                                       (!memcmp((pIE->data + 12), RSN_CIPHER_SUITE_CCMP23A, 4)))
                                return false;
@@ -1260,16 +1208,16 @@ unsigned int is_ap_in_wep23a(struct rtw_adapter *padapter)
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct wlan_bssid_ex *cur_network = &pmlmeinfo->network;
 
-       if (rtw_get_capability23a((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) {
+       if (rtw_get_capability23a(cur_network) & WLAN_CAPABILITY_PRIVACY) {
                for (i = sizeof(struct ndis_802_11_fixed_ies); i < pmlmeinfo->network.IELength;) {
                        pIE = (struct ndis_802_11_var_ies *)(pmlmeinfo->network.IEs + i);
 
                        switch (pIE->ElementID) {
-                       case _VENDOR_SPECIFIC_IE_:
-                               if (!memcmp(pIE->data, RTW_WPA_OUI23A, 4))
+                       case WLAN_EID_VENDOR_SPECIFIC:
+                               if (!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4))
                                        return false;
                                break;
-                       case _RSN_IE_2_:
+                       case WLAN_EID_RSN:
                                return false;
 
                        default:
@@ -1285,7 +1233,7 @@ unsigned int is_ap_in_wep23a(struct rtw_adapter *padapter)
        }
 }
 
-int wifirate2_ratetbl_inx23a(unsigned char rate)
+static int wifirate2_ratetbl_inx23a(unsigned char rate)
 {
        int     inx = 0;
        rate = rate & 0x7f;
@@ -1399,25 +1347,13 @@ unsigned char get_highest_rate_idx23a(u32 mask)
        return rate_idx;
 }
 
-unsigned char get_highest_mcs_rate(struct HT_caps_element *pHT_caps)
-{
-       int i, mcs_rate;
-
-       mcs_rate = (pHT_caps->u.HT_cap_element.MCS_rate[0] | (pHT_caps->u.HT_cap_element.MCS_rate[1] << 8));
-
-       for (i = 15; i >= 0; i--) {
-               if (mcs_rate & (0x1 << i))
-                       break;
-       }
-       return i;
-}
-
 void Update_RA_Entry23a(struct rtw_adapter *padapter, struct sta_info *psta)
 {
        rtw_hal_update_ra_mask23a(psta, 0);
 }
 
-void enable_rate_adaptive(struct rtw_adapter *padapter, struct sta_info *psta)
+static void enable_rate_adaptive(struct rtw_adapter *padapter,
+                                struct sta_info *psta)
 {
        Update_RA_Entry23a(padapter, psta);
 }
@@ -1432,15 +1368,6 @@ void set_sta_rate23a(struct rtw_adapter *padapter, struct sta_info *psta)
 void update_tx_basic_rate23a(struct rtw_adapter *padapter, u8 wirelessmode)
 {
        unsigned char supported_rates[NDIS_802_11_LENGTH_RATES_EX];
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info* pwdinfo = &padapter->wdinfo;
-
-       /*      Added by Albert 2011/03/22 */
-       /*      In the P2P mode, the driver should not support the b mode. */
-       /*      So, the Tx packet shouldn't use the CCK rate */
-       if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-               return;
-#endif /* CONFIG_8723AU_P2P */
 
        memset(supported_rates, 0, NDIS_802_11_LENGTH_RATES_EX);
 
@@ -1457,7 +1384,7 @@ void update_tx_basic_rate23a(struct rtw_adapter *padapter, u8 wirelessmode)
        else
                update_mgnt_tx_rate23a(padapter, IEEE80211_OFDM_RATE_6MB);
 
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_BASIC_RATE, supported_rates);
+       HalSetBrateCfg23a(padapter, supported_rates);
 }
 
 unsigned char check_assoc_AP23a(u8 *pframe, uint len)
@@ -1473,7 +1400,7 @@ unsigned char check_assoc_AP23a(u8 *pframe, uint len)
                pIE = (struct ndis_802_11_var_ies *)(pframe + i);
 
                switch (pIE->ElementID) {
-               case _VENDOR_SPECIFIC_IE_:
+               case WLAN_EID_VENDOR_SPECIFIC:
                        if ((!memcmp(pIE->data, ARTHEROS_OUI1, 3)) ||
                            (!memcmp(pIE->data, ARTHEROS_OUI2, 3))) {
                                DBG_8723A("link to Artheros AP\n");
@@ -1546,15 +1473,15 @@ void update_IOT_info23a(struct rtw_adapter *padapter)
                pmlmeinfo->turboMode_cts2self = 0;
                pmlmeinfo->turboMode_rtsen = 1;
                /* disable high power */
-               Switch_DM_Func23a(padapter, ~DYNAMIC_BB_DYNAMIC_TXPWR,
-                              false);
+               rtl8723a_odm_support_ability_clr(padapter, (u32)
+                                                ~DYNAMIC_BB_DYNAMIC_TXPWR);
                break;
        case HT_IOT_PEER_REALTEK:
                /* rtw_write16(padapter, 0x4cc, 0xffff); */
                /* rtw_write16(padapter, 0x546, 0x01c0); */
                /* disable high power */
-               Switch_DM_Func23a(padapter, ~DYNAMIC_BB_DYNAMIC_TXPWR,
-                              false);
+               rtl8723a_odm_support_ability_clr(padapter, (u32)
+                                                ~DYNAMIC_BB_DYNAMIC_TXPWR);
                break;
        default:
                pmlmeinfo->turboMode_cts2self = 0;
@@ -1567,22 +1494,19 @@ void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap)
 {
        struct mlme_ext_priv    *pmlmeext = &Adapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
-       bool            ShortPreamble;
 
        if (updateCap & cShortPreamble) {
                /*  Short Preamble */
                if (pmlmeinfo->preamble_mode != PREAMBLE_SHORT) {
                        /*  PREAMBLE_LONG or PREAMBLE_AUTO */
-                       ShortPreamble = true;
                        pmlmeinfo->preamble_mode = PREAMBLE_SHORT;
-                       rtw_hal_set_hwreg23a(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble);
+                       rtl8723a_ack_preamble(Adapter, true);
                }
        } else { /*  Long Preamble */
                if (pmlmeinfo->preamble_mode != PREAMBLE_LONG) {
                        /*  PREAMBLE_SHORT or PREAMBLE_AUTO */
-                       ShortPreamble = false;
                        pmlmeinfo->preamble_mode = PREAMBLE_LONG;
-                       rtw_hal_set_hwreg23a(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble);
+                       rtl8723a_ack_preamble(Adapter, false);
                }
        }
        if (updateCap & cIBSS) {
@@ -1605,13 +1529,12 @@ void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap)
                        pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME;
                }
        }
-       rtw_hal_set_hwreg23a(Adapter, HW_VAR_SLOT_TIME, &pmlmeinfo->slotTime);
+       rtl8723a_set_slot_time(Adapter, pmlmeinfo->slotTime);
 }
 
 void update_wireless_mode23a(struct rtw_adapter *padapter)
 {
        int ratelen, network_type = 0;
-       u32 SIFS_Timer;
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct wlan_bssid_ex *cur_network = &pmlmeinfo->network;
@@ -1640,10 +1563,9 @@ void update_wireless_mode23a(struct rtw_adapter *padapter)
 
        pmlmeext->cur_wireless_mode = network_type & padapter->registrypriv.wireless_mode;
 
-       SIFS_Timer = 0x0a0a0808; /* 0x0808 -> for CCK, 0x0a0a -> for OFDM */
-                             /* change this value if having IOT issues. */
-
-       padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_RESP_SIFS,  (u8 *)&SIFS_Timer);
+       /* 0x0808 -> for CCK, 0x0a0a -> for OFDM */
+       /* change this value if having IOT issues. */
+       rtl8723a_set_resp_sifs(padapter, 0x08, 0x08, 0x0a, 0x0a);
 
        if (pmlmeext->cur_wireless_mode & WIRELESS_11B)
                update_mgnt_tx_rate23a(padapter, IEEE80211_CCK_RATE_1MB);
@@ -1658,30 +1580,33 @@ void update_bmc_sta_support_rate23a(struct rtw_adapter *padapter, u32 mac_id)
 
        if (pmlmeext->cur_wireless_mode & WIRELESS_11B) {
                /*  Only B, B/G, and B/G/N AP could use CCK rate */
-               memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), rtw_basic_rate_cck, 4);
+               memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates),
+                      rtw_basic_rate_cck, 4);
        } else {
-               memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), rtw_basic_rate_ofdm, 4);
+               memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates),
+                      rtw_basic_rate_ofdm, 3);
        }
 }
 
-int update_sta_support_rate23a(struct rtw_adapter *padapter, u8 *pvar_ie, uint var_ie_len, int cam_idx)
+int update_sta_support_rate23a(struct rtw_adapter *padapter, u8 *pvar_ie,
+                              uint var_ie_len, int cam_idx)
 {
-       unsigned int    ie_len;
-       struct ndis_802_11_var_ies *pIE;
-       int     supportRateNum = 0;
+       int supportRateNum = 0;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
+       const u8 *p;
 
-       pIE = (struct ndis_802_11_var_ies *)rtw_get_ie23a(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len);
-       if (pIE == NULL)
+       p = cfg80211_find_ie(WLAN_EID_SUPP_RATES, pvar_ie, var_ie_len);
+       if (!p)
                return _FAIL;
 
-       memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len);
-       supportRateNum = ie_len;
+       memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, p + 2, p[1]);
+       supportRateNum = p[1];
 
-       pIE = (struct ndis_802_11_var_ies *)rtw_get_ie23a(pvar_ie, _EXT_SUPPORTEDRATES_IE_, &ie_len, var_ie_len);
-       if (pIE)
-               memcpy((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + supportRateNum), pIE->data, ie_len);
+       p = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, pvar_ie, var_ie_len);
+       if (p)
+               memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates +
+                      supportRateNum, p + 2, p[1]);
        return _SUCCESS;
 }
 
@@ -1711,26 +1636,6 @@ void process_addba_req23a(struct rtw_adapter *padapter, u8 *paddba_req, u8 *addr
        }
 }
 
-void update_TSF23a(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len)
-{
-       u8 *pIE;
-       u32 *pbuf;
-
-       pIE = pframe + sizeof(struct ieee80211_hdr_3addr);
-       pbuf = (u32 *)pIE;
-
-       pmlmeext->TSFValue = le32_to_cpu(*(pbuf+1));
-
-       pmlmeext->TSFValue = pmlmeext->TSFValue << 32;
-
-       pmlmeext->TSFValue |= le32_to_cpu(*pbuf);
-}
-
-void correct_TSF23a(struct rtw_adapter *padapter, struct mlme_ext_priv *pmlmeext)
-{
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_CORRECT_TSF, NULL);
-}
-
 void beacon_timing_control23a(struct rtw_adapter *padapter)
 {
        rtw_hal_bcn_related_reg_setting23a(padapter);
index 0f10cfa10d39e42c93af988ee1a3d6c89dc0a559..31a44feaab1d8432ee09211d73f4aecb6e3f5f20 100644 (file)
@@ -443,21 +443,17 @@ u8 qos_acm23a(u8 acm_mask, u8 priority)
        return change_priority;
 }
 
-static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib)
+static void set_qos(struct sk_buff *skb, struct pkt_attrib *pattrib)
 {
-       struct ethhdr etherhdr;
-       struct iphdr ip_hdr;
+       u8 *pframe = skb->data;
+       struct iphdr *ip_hdr;
        s32 UserPriority = 0;
 
-       _rtw_open_pktfile23a(ppktfile->pkt, ppktfile);
-       _rtw_pktfile_read23a(ppktfile, (unsigned char*)&etherhdr, ETH_HLEN);
-
        /*  get UserPriority from IP hdr */
-       if (pattrib->ether_type == 0x0800) {
-               _rtw_pktfile_read23a(ppktfile, (u8*)&ip_hdr, sizeof(ip_hdr));
-/*             UserPriority = (ntohs(ip_hdr.tos) >> 5) & 0x3; */
-               UserPriority = ip_hdr.tos >> 5;
-       } else if (pattrib->ether_type == 0x888e) {
+       if (pattrib->ether_type == ETH_P_IP) {
+               ip_hdr = (struct iphdr *)(pframe + ETH_HLEN);
+               UserPriority = ip_hdr->tos >> 5;
+       } else if (pattrib->ether_type == ETH_P_PAE) {
                /*  "When priority processing of data frames is supported, */
                /*  a STA's SME should send EAPOL-Key frames at the highest
                    priority." */
@@ -470,57 +466,53 @@ static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib)
 }
 
 static s32 update_attrib(struct rtw_adapter *padapter,
-                        struct sk_buff *pkt, struct pkt_attrib *pattrib)
+                        struct sk_buff *skb, struct pkt_attrib *pattrib)
 {
-       uint i;
-       struct pkt_file pktfile;
        struct sta_info *psta = NULL;
-       struct ethhdr etherhdr;
-
        int bmcast;
        struct sta_priv *pstapriv = &padapter->stapriv;
        struct security_priv *psecuritypriv = &padapter->securitypriv;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct qos_priv *pqospriv = &pmlmepriv->qospriv;
        int res = _SUCCESS;
+       struct ethhdr *ehdr = (struct ethhdr *) skb->data;
 
-       _rtw_open_pktfile23a(pkt, &pktfile);
-       i = _rtw_pktfile_read23a(&pktfile, (u8*)&etherhdr, ETH_HLEN);
-
-       pattrib->ether_type = ntohs(etherhdr.h_proto);
+       pattrib->ether_type = ntohs(ehdr->h_proto);
 
-       memcpy(pattrib->dst, &etherhdr.h_dest, ETH_ALEN);
-       memcpy(pattrib->src, &etherhdr.h_source, ETH_ALEN);
+       ether_addr_copy(pattrib->dst, ehdr->h_dest);
+       ether_addr_copy(pattrib->src, ehdr->h_source);
 
        pattrib->pctrl = 0;
 
        if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) ||
                (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) {
-               memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
-               memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
+               ether_addr_copy(pattrib->ra, pattrib->dst);
+               ether_addr_copy(pattrib->ta, pattrib->src);
        }
        else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
-               memcpy(pattrib->ra, get_bssid(pmlmepriv), ETH_ALEN);
-               memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
+               ether_addr_copy(pattrib->ra, get_bssid(pmlmepriv));
+               ether_addr_copy(pattrib->ta, pattrib->src);
        }
        else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
-               memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
-               memcpy(pattrib->ta, get_bssid(pmlmepriv), ETH_ALEN);
+               ether_addr_copy(pattrib->ra, pattrib->dst);
+               ether_addr_copy(pattrib->ta, get_bssid(pmlmepriv));
        }
 
-       pattrib->pktlen = pktfile.pkt_len;
+       pattrib->pktlen = skb->len - ETH_HLEN;
 
        if (pattrib->ether_type == ETH_P_IP) {
                /*  The following is for DHCP and ARP packet, we use cck1M
                    to tx these packets and let LPS awake some time */
                /*  to prevent DHCP protocol fail */
-               u8 tmp[24];
-               _rtw_pktfile_read23a(&pktfile, &tmp[0], 24);
                pattrib->dhcp_pkt = 0;
-               if (pktfile.pkt_len > 282) {/* MINIMUM_DHCP_PACKET_SIZE) { */
-                       if (ETH_P_IP == pattrib->ether_type) {/*  IP header */
-                               if (((tmp[21] == 68) && (tmp[23] == 67)) ||
-                                   ((tmp[21] == 67) && (tmp[23] == 68))) {
+               /* MINIMUM_DHCP_PACKET_SIZE) { */
+               if (pattrib->pktlen > 282 + 24) {
+                       if (pattrib->ether_type == ETH_P_IP) {/*  IP header */
+                               u8 *pframe = skb->data;
+                               pframe += ETH_HLEN;
+
+                               if ((pframe[21] == 68 && pframe[23] == 67) ||
+                                   (pframe[21] == 67 && pframe[23] == 68)) {
                                        /*  68 : UDP BOOTP client */
                                        /*  67 : UDP BOOTP server */
                                        RT_TRACE(_module_rtl871x_xmit_c_,
@@ -532,17 +524,17 @@ static s32 update_attrib(struct rtw_adapter *padapter,
                                }
                        }
                }
-       } else if (0x888e == pattrib->ether_type) {
+       } else if (pattrib->ether_type == ETH_P_PAE) {
                DBG_8723A_LEVEL(_drv_always_, "send eapol packet\n");
        }
 
-       if ((pattrib->ether_type == 0x888e) || (pattrib->dhcp_pkt == 1)) {
+       if ((pattrib->ether_type == ETH_P_PAE) || (pattrib->dhcp_pkt == 1)) {
                rtw_set_scan_deny(padapter, 3000);
        }
 
        /*  If EAPOL , ARP , OR DHCP packet, driver must be in active mode. */
-       if ((pattrib->ether_type == 0x0806) ||
-           (pattrib->ether_type == 0x888e) || (pattrib->dhcp_pkt == 1)) {
+       if ((pattrib->ether_type == ETH_P_ARP) ||
+           (pattrib->ether_type == ETH_P_PAE) || (pattrib->dhcp_pkt == 1)) {
                rtw_lps_ctrl_wk_cmd23a(padapter, LPS_CTRL_SPECIAL_PACKET, 1);
        }
 
@@ -592,10 +584,10 @@ static s32 update_attrib(struct rtw_adapter *padapter,
        if (check_fwstate(pmlmepriv, WIFI_AP_STATE | WIFI_ADHOC_STATE |
                          WIFI_ADHOC_MASTER_STATE)) {
                if (psta->qos_option)
-                       set_qos(&pktfile, pattrib);
+                       set_qos(skb, pattrib);
        } else {
                if (pqospriv->qos_option) {
-                       set_qos(&pktfile, pattrib);
+                       set_qos(skb, pattrib);
 
                        if (pmlmepriv->acm_mask != 0) {
                                pattrib->priority = qos_acm23a(pmlmepriv->acm_mask,
@@ -610,7 +602,7 @@ static s32 update_attrib(struct rtw_adapter *padapter,
 
                pattrib->encrypt = 0;
 
-               if ((pattrib->ether_type != 0x888e) &&
+               if ((pattrib->ether_type != ETH_P_PAE) &&
                    (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false)) {
                        RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
                                 ("\npsta->ieee8021x_blocked == true,  "
@@ -916,7 +908,7 @@ s32 rtw_make_wlanhdr23a(struct rtw_adapter *padapter, u8 *hdr,
        struct qos_priv *pqospriv = &pmlmepriv->qospriv;
        u8 qos_option = false;
        int res = _SUCCESS;
-       u16 *fctrl = &pwlanhdr->frame_control;
+       __le16 *fctrl = &pwlanhdr->frame_control;
 
        struct sta_info *psta;
 
@@ -1116,39 +1108,40 @@ This sub-routine will perform all the following:
 6. apply sw-encrypt, if necessary.
 
 */
-s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt,
+s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb,
                              struct xmit_frame *pxmitframe)
 {
-       struct pkt_file pktfile;
-       struct sta_info         *psta;
-       struct xmit_priv        *pxmitpriv = &padapter->xmitpriv;
-       struct pkt_attrib       *pattrib = &pxmitframe->attrib;
+       struct sta_info *psta;
+       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+       struct pkt_attrib *pattrib = &pxmitframe->attrib;
        s32 frg_inx, frg_len, mpdu_len, llc_sz, mem_sz;
        u8 *pframe, *mem_start;
        u8 hw_hdr_offset;
        u8 *pbuf_start;
-
+       u8 *pdata = skb->data;
+       int data_len = skb->len;
        s32 bmcst = is_multicast_ether_addr(pattrib->ra);
        s32 res = _SUCCESS;
 
-       if (pattrib->psta) {
+       if (pattrib->psta)
                psta = pattrib->psta;
-       else {
+       else {
                DBG_8723A("%s, call rtw_get_stainfo23a()\n", __func__);
                psta = rtw_get_stainfo23a(&padapter->stapriv, pattrib->ra);
        }
 
-       if (psta == NULL) {
+       if (!psta) {
                DBG_8723A("%s, psta == NUL\n", __func__);
                return _FAIL;
        }
 
        if (!(psta->state &_FW_LINKED)) {
-               DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state);
+               DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n",
+                         __func__, psta->state);
                return _FAIL;
        }
 
-       if (pxmitframe->buf_addr == NULL) {
+       if (!pxmitframe->buf_addr) {
                DBG_8723A("==> %s buf_addr == NULL\n", __func__);
                return _FAIL;
        }
@@ -1157,7 +1150,7 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt,
 
        hw_hdr_offset = TXDESC_OFFSET;
 
-       mem_start = pbuf_start +        hw_hdr_offset;
+       mem_start = pbuf_start + hw_hdr_offset;
 
        if (rtw_make_wlanhdr23a(padapter, mem_start, pattrib) == _FAIL) {
                RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
@@ -1167,8 +1160,8 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt,
                goto exit;
        }
 
-       _rtw_open_pktfile23a(pkt, &pktfile);
-       _rtw_pktfile_read23a(&pktfile, NULL, pattrib->pkt_hdrlen);
+       pdata += pattrib->pkt_hdrlen;
+       data_len -= pattrib->pkt_hdrlen;
 
        frg_inx = 0;
        frg_len = pxmitpriv->frag_len - 4;/* 2346-4 = 2342 */
@@ -1187,23 +1180,30 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt,
 
                /* adding icv, if necessary... */
                if (pattrib->iv_len) {
-                       if (psta != NULL) {
+                       if (psta) {
                                switch (pattrib->encrypt) {
                                case _WEP40_:
                                case _WEP104_:
-                                       WEP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx);
+                                       WEP_IV(pattrib->iv, psta->dot11txpn,
+                                              pattrib->key_idx);
                                        break;
                                case _TKIP_:
                                        if (bmcst)
-                                               TKIP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx);
+                                               TKIP_IV(pattrib->iv,
+                                                       psta->dot11txpn,
+                                                       pattrib->key_idx);
                                        else
-                                               TKIP_IV(pattrib->iv, psta->dot11txpn, 0);
+                                               TKIP_IV(pattrib->iv,
+                                                       psta->dot11txpn, 0);
                                        break;
                                case _AES_:
                                        if (bmcst)
-                                               AES_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx);
+                                               AES_IV(pattrib->iv,
+                                                      psta->dot11txpn,
+                                                      pattrib->key_idx);
                                        else
-                                               AES_IV(pattrib->iv, psta->dot11txpn, 0);
+                                               AES_IV(pattrib->iv,
+                                                      psta->dot11txpn, 0);
                                        break;
                                }
                        }
@@ -1225,16 +1225,20 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt,
                        mpdu_len -= llc_sz;
                }
 
-               if ((pattrib->icv_len >0) && (pattrib->bswenc))
+               if (pattrib->icv_len > 0 && pattrib->bswenc)
                        mpdu_len -= pattrib->icv_len;
 
-               if (bmcst) {
+               if (bmcst)
                        /*  don't do fragment to broadcat/multicast packets */
-                       mem_sz = _rtw_pktfile_read23a(&pktfile, pframe, pattrib->pktlen);
-               } else {
-                       mem_sz = _rtw_pktfile_read23a(&pktfile, pframe, mpdu_len);
-               }
+                       mem_sz = min_t(s32, data_len, pattrib->pktlen);
+               else
+                       mem_sz = min_t(s32, data_len, mpdu_len);
+
+               memcpy(pframe, pdata, mem_sz);
+
                pframe += mem_sz;
+               pdata += mem_sz;
+               data_len -= mem_sz;
 
                if ((pattrib->icv_len >0) && (pattrib->bswenc)) {
                        memcpy(pframe, pattrib->icv, pattrib->icv_len);
@@ -1243,7 +1247,7 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt,
 
                frg_inx++;
 
-               if (bmcst || (rtw_endofpktfile23a(&pktfile))) {
+               if (bmcst || data_len <= 0) {
                        pattrib->nr_frags = frg_inx;
 
                        pattrib->last_txcmdsz = pattrib->hdrlen +
@@ -1257,16 +1261,18 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt,
 
                        break;
                } else {
-                       RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("%s: There're still something in packet!\n", __func__));
+                       RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
+                                ("%s: There're still something in packet!\n",
+                                 __func__));
                }
 
                mem_start = PTR_ALIGN(pframe, 4) + hw_hdr_offset;
                memcpy(mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen);
-
        }
 
        if (xmitframe_addmic(padapter, pxmitframe) == _FAIL) {
-               RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n"));
+               RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
+                        ("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n"));
                DBG_8723A("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n");
                res = _FAIL;
                goto exit;
@@ -1313,11 +1319,10 @@ s32 rtw_put_snap23a(u8 *data, u16 h_proto)
 
 void rtw_update_protection23a(struct rtw_adapter *padapter, u8 *ie, uint ie_len)
 {
-       struct  xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct  registry_priv *pregistrypriv = &padapter->registrypriv;
-       uint    protection;
-       u8      *perp;
-       int      erp_len;
+       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+       struct registry_priv *pregistrypriv = &padapter->registrypriv;
+       uint protection;
+       const u8 *p;
 
        switch (pxmitpriv->vcs_setting) {
        case DISABLE_VCS:
@@ -1327,11 +1332,11 @@ void rtw_update_protection23a(struct rtw_adapter *padapter, u8 *ie, uint ie_len)
                break;
        case AUTO_VCS:
        default:
-               perp = rtw_get_ie23a(ie, _ERPINFO_IE_, &erp_len, ie_len);
-               if (perp == NULL) {
+               p = cfg80211_find_ie(WLAN_EID_ERP_INFO, ie, ie_len);
+               if (!p)
                        pxmitpriv->vcs = NONE_VCS;
-               else {
-                       protection = (*(perp + 2)) & BIT(1);
+               else {
+                       protection = (*(p + 2)) & BIT(1);
                        if (protection) {
                                if (pregistrypriv->vcs_type == RTS_CTS)
                                        pxmitpriv->vcs = RTS_CTS;
@@ -2036,7 +2041,8 @@ int xmitframe_enqueue_for_sleeping_sta23a(struct rtw_adapter *padapter, struct x
 
                        /* DBG_8723A("enqueue, sq_len =%d, tim =%x\n", psta->sleepq_len, pstapriv->tim_bitmap); */
 
-                       update_beacon23a(padapter, _TIM_IE_, NULL, false);/* tx bc/mc packets after upate bcn */
+                       /* tx bc/mc packets after upate bcn */
+                       update_beacon23a(padapter, WLAN_EID_TIM, NULL, false);
 
                        /* spin_unlock_bh(&psta->sleep_q.lock); */
 
@@ -2093,7 +2099,8 @@ int xmitframe_enqueue_for_sleeping_sta23a(struct rtw_adapter *padapter, struct x
 
                                if (psta->sleepq_len == 1) {
                                        /* upate BCN for TIM IE */
-                                       update_beacon23a(padapter, _TIM_IE_, NULL, false);
+                                       update_beacon23a(padapter, WLAN_EID_TIM,
+                                                        NULL, false);
                                }
                        }
 
@@ -2307,7 +2314,7 @@ void wakeup_sta_to_xmit23a(struct rtw_adapter *padapter, struct sta_info *psta)
        }
 
        if (update_mask)
-               update_beacon23a(padapter, _TIM_IE_, NULL, false);
+               update_beacon23a(padapter, WLAN_EID_TIM, NULL, false);
 }
 
 void xmit_delivery_enabled_frames23a(struct rtw_adapter *padapter,
@@ -2372,7 +2379,7 @@ void xmit_delivery_enabled_frames23a(struct rtw_adapter *padapter,
                        pstapriv->tim_bitmap &= ~CHKBIT(psta->aid);
 
                        /* upate BCN for TIM IE */
-                       update_beacon23a(padapter, _TIM_IE_, NULL, false);
+                       update_beacon23a(padapter, WLAN_EID_TIM, NULL, false);
                }
        }
        spin_unlock_bh(&pxmitpriv->lock);
index 0640f3522136d5783b8e1cb35c164f16e792bdd2..8e08977e929b82ce4b33434e59880d4490702737 100644 (file)
@@ -344,12 +344,6 @@ bool Hal_MappingOutPipe23a(struct rtw_adapter *pAdapter, u8 NumOutPipe)
        return result;
 }
 
-void hal_init_macaddr23a(struct rtw_adapter *adapter)
-{
-       rtw_hal_set_hwreg23a(adapter, HW_VAR_MAC_ADDR,
-                         adapter->eeprompriv.mac_addr);
-}
-
 /*
 * C2H event format:
 * Field         TRIGGER                CONTENT    CMD_SEQ      CMD_LEN          CMD_ID
@@ -676,11 +670,13 @@ void rtl8723a_cam_empty_entry(struct rtw_adapter *padapter, u8 ucIndex)
                /* delay_ms(40); */
                rtw_write32(padapter, WCAMI, ulContent);
                /* RT_TRACE(COMP_SEC, DBG_LOUD,
-                  ("CAM_empty_entry23a(): WRITE A4: %lx \n", ulContent));*/
+                  ("rtl8723a_cam_empty_entry(): WRITE A4: %lx \n",
+                  ulContent));*/
                /* delay_ms(40); */
                rtw_write32(padapter, RWCAM, ulCommand);
                /* RT_TRACE(COMP_SEC, DBG_LOUD,
-                  ("CAM_empty_entry23a(): WRITE A0: %lx \n", ulCommand));*/
+                  ("rtl8723a_cam_empty_entry(): WRITE A0: %lx \n",
+                  ulCommand));*/
        }
 }
 
@@ -689,14 +685,37 @@ void rtl8723a_cam_invalid_all(struct rtw_adapter *padapter)
        rtw_write32(padapter, RWCAM, BIT(31) | BIT(30));
 }
 
-void rtl8723a_cam_write(struct rtw_adapter *padapter, u32 val1, u32 val2)
+void rtl8723a_cam_write(struct rtw_adapter *padapter,
+                       u8 entry, u16 ctrl, const u8 *mac, const u8 *key)
 {
        u32 cmd;
+       unsigned int i, val, addr;
+       int j;
+
+       addr = entry << 3;
+
+       for (j = 5; j >= 0; j--) {
+               switch (j) {
+               case 0:
+                       val = ctrl | (mac[0] << 16) | (mac[1] << 24);
+                       break;
+               case 1:
+                       val = mac[2] | (mac[3] << 8) |
+                               (mac[4] << 16) | (mac[5] << 24);
+                       break;
+               default:
+                       i = (j - 2) << 2;
+                       val = key[i] | (key[i+1] << 8) |
+                               (key[i+2] << 16) | (key[i+3] << 24);
+                       break;
+               }
 
-       rtw_write32(padapter, WCAMI, val1);
+               rtw_write32(padapter, WCAMI, val);
+               cmd = CAM_POLLINIG | CAM_WRITE | (addr + j);
+               rtw_write32(padapter, RWCAM, cmd);
 
-       cmd = CAM_POLLINIG | CAM_WRITE | val2;
-       rtw_write32(padapter, RWCAM, cmd);
+               /* DBG_8723A("%s => cam write: %x, %x\n", __func__, cmd, val);*/
+       }
 }
 
 void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter)
@@ -736,14 +755,6 @@ void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter)
        }
 }
 
-void rtl8723a_set_apfm_on_mac(struct rtw_adapter *padapter, u8 val)
-{
-       struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
-
-       pHalData->bMacPwrCtrlOn = val;
-       DBG_8723A("%s: bMacPwrCtrlOn =%d\n", __func__, pHalData->bMacPwrCtrlOn);
-}
-
 void rtl8723a_bcn_valid(struct rtw_adapter *padapter)
 {
        /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2,
@@ -752,9 +763,13 @@ void rtl8723a_bcn_valid(struct rtw_adapter *padapter)
                   rtw_read8(padapter, REG_TDECTRL + 2) | BIT0);
 }
 
-void rtl8723a_set_tx_pause(struct rtw_adapter *padapter, u8 pause)
+bool rtl8723a_get_bcn_valid(struct rtw_adapter *padapter)
 {
-       rtw_write8(padapter, REG_TXPAUSE, pause);
+       bool retval;
+
+       retval = (rtw_read8(padapter, REG_TDECTRL + 2) & BIT0) ? true : false;
+
+       return retval;
 }
 
 void rtl8723a_set_beacon_interval(struct rtw_adapter *padapter, u16 interval)
@@ -837,23 +852,18 @@ void rtl8723a_set_initial_gain(struct rtw_adapter *padapter, u32 rx_gain)
        }
 }
 
-void rtl8723a_odm_support_ability_write(struct rtw_adapter *padapter, u32 val)
+void rtl8723a_odm_support_ability_restore(struct rtw_adapter *padapter)
 {
        struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
 
-       pHalData->odmpriv.SupportAbility = val;
+       pHalData->odmpriv.SupportAbility = pHalData->odmpriv.BK_SupportAbility;
 }
 
-void rtl8723a_odm_support_ability_backup(struct rtw_adapter *padapter, u8 val)
+void rtl8723a_odm_support_ability_backup(struct rtw_adapter *padapter)
 {
        struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
 
-       if (val)        /*  save dm flag */
-               pHalData->odmpriv.BK_SupportAbility =
-                       pHalData->odmpriv.SupportAbility;
-       else            /*  restore dm flag */
-               pHalData->odmpriv.SupportAbility =
-                       pHalData->odmpriv.BK_SupportAbility;
+       pHalData->odmpriv.BK_SupportAbility = pHalData->odmpriv.SupportAbility;
 }
 
 void rtl8723a_odm_support_ability_set(struct rtw_adapter *padapter, u32 val)
@@ -879,3 +889,42 @@ void rtl8723a_set_rpwm(struct rtw_adapter *padapter, u8 val)
 {
        rtw_write8(padapter, REG_USB_HRPWM, val);
 }
+
+u8 rtl8723a_get_rf_type(struct rtw_adapter *padapter)
+{
+       struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
+
+       return pHalData->rf_type;
+}
+
+bool rtl8723a_get_fwlps_rf_on(struct rtw_adapter *padapter)
+{
+       bool retval;
+       u32 valRCR;
+
+       /*  When we halt NIC, we should check if FW LPS is leave. */
+
+       if ((padapter->bSurpriseRemoved == true) ||
+           (padapter->pwrctrlpriv.rf_pwrstate == rf_off)) {
+               /*  If it is in HW/SW Radio OFF or IPS state, we do
+                   not check Fw LPS Leave, because Fw is unload. */
+               retval = true;
+       } else {
+               valRCR = rtw_read32(padapter, REG_RCR);
+               if (valRCR & 0x00070000)
+                       retval = false;
+               else
+                       retval = true;
+       }
+
+       return retval;
+}
+
+bool rtl8723a_chk_hi_queue_empty(struct rtw_adapter *padapter)
+{
+       u32 hgq;
+
+       hgq = rtw_read32(padapter, REG_HGQ_INFORMATION);
+
+       return ((hgq & 0x0000ff00) == 0) ? true : false;
+}
index de3608b4010aec9a0af902a96723dec414d2e047..1931f428722f55cd4de5ceca50e39a13ffd13171 100644 (file)
@@ -117,18 +117,6 @@ uint rtw_hal_deinit23a(struct rtw_adapter *padapter)
        return status;
 }
 
-void rtw_hal_set_hwreg23a(struct rtw_adapter *padapter, u8 variable, u8 *val)
-{
-       if (padapter->HalFunc.SetHwRegHandler)
-               padapter->HalFunc.SetHwRegHandler(padapter, variable, val);
-}
-
-void rtw23a_hal_get_hwreg(struct rtw_adapter *padapter, u8 variable, u8 *val)
-{
-       if (padapter->HalFunc.GetHwRegHandler)
-               padapter->HalFunc.GetHwRegHandler(padapter, variable, val);
-}
-
 u8 rtw_hal_set_def_var23a(struct rtw_adapter *padapter, enum hal_def_variable eVariable, void *pValue)
 {
        if (padapter->HalFunc.SetHalDefVarHandler)
@@ -190,13 +178,6 @@ u32        rtw_hal_inirp_deinit23a(struct rtw_adapter *padapter)
 
 }
 
-u8     rtw_hal_intf_ps_func23a(struct rtw_adapter *padapter, enum hal_intf_ps_func efunc_id, u8 *val)
-{
-       if (padapter->HalFunc.interface_ps_func)
-               return padapter->HalFunc.interface_ps_func(padapter, efunc_id, val);
-       return _FAIL;
-}
-
 s32    rtw_hal_xmit23aframe_enqueue(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe)
 {
        if (padapter->HalFunc.hal_xmitframe_enqueue)
@@ -274,32 +255,6 @@ void       rtw_hal_add_ra_tid23a(struct rtw_adapter *padapter, u32 bitmap, u8 arg, u8
                padapter->HalFunc.Add_RateATid(padapter, bitmap, arg, rssi_level);
 }
 
-/*     Start specifical interface thread               */
-void   rtw_hal_start_thread23a(struct rtw_adapter *padapter)
-{
-       if (padapter->HalFunc.run_thread)
-               padapter->HalFunc.run_thread(padapter);
-}
-/*     Start specifical interface thread               */
-void   rtw_hal_stop_thread23a(struct rtw_adapter *padapter)
-{
-       if (padapter->HalFunc.cancel_thread)
-               padapter->HalFunc.cancel_thread(padapter);
-}
-
-u32    rtw_hal_read_bbreg23a(struct rtw_adapter *padapter, u32 RegAddr, u32 BitMask)
-{
-       u32 data = 0;
-       if (padapter->HalFunc.read_bbreg)
-                data = padapter->HalFunc.read_bbreg(padapter, RegAddr, BitMask);
-       return data;
-}
-void   rtw_hal_write_bbreg23a(struct rtw_adapter *padapter, u32 RegAddr, u32 BitMask, u32 Data)
-{
-       if (padapter->HalFunc.write_bbreg)
-               padapter->HalFunc.write_bbreg(padapter, RegAddr, BitMask, Data);
-}
-
 u32    rtw_hal_read_rfreg23a(struct rtw_adapter *padapter, u32 eRFPath, u32 RegAddr, u32 BitMask)
 {
        u32 data = 0;
index 9d738d79de4bb748020ead68b563dc1510b22b92..0d1452757a09c1de2bc6960dffb58a0cb7333760 100644 (file)
@@ -3944,7 +3944,6 @@ bthci_CmdAMPTestEnd(struct rtw_adapter *padapter,
        enum hci_status status = HCI_STATUS_SUCCESS;
        struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
        struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo;
-       u8 bFilterOutNonAssociatedBSSID = true;
 
        if (!pBtHciInfo->bInTestMode) {
                RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), ("Not in Test mode, return status = HCI_STATUS_CMD_DISALLOW\n"));
@@ -3956,7 +3955,7 @@ bthci_CmdAMPTestEnd(struct rtw_adapter *padapter,
 
        del_timer_sync(&pBTInfo->BTTestSendPacketTimer);
 
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_CHECK_BSSID, (u8 *)(&bFilterOutNonAssociatedBSSID));
+       rtl8723a_check_bssid(padapter, true);
 
        /* send command complete event here when all data are received. */
        {
@@ -4057,8 +4056,7 @@ bthci_CmdAMPTestCommand(struct rtw_adapter *padapter,
                          jiffies + msecs_to_jiffies(50));
                RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), ("TX Single Test \n"));
        } else if (pBtHciInfo->TestScenario == 0x02) {
-               u8 bFilterOutNonAssociatedBSSID = false;
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_CHECK_BSSID, (u8 *)(&bFilterOutNonAssociatedBSSID));
+               rtl8723a_check_bssid(padapter, false);
                RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), ("Receive Frame Test \n"));
        }
 
@@ -4677,7 +4675,7 @@ bthci_StateConnected(struct rtw_adapter *padapter,
                if (padapter->HalFunc.UpdateRAMaskHandler)
                        padapter->HalFunc.UpdateRAMaskHandler(padapter, MAX_FW_SUPPORT_MACID_NUM-1-EntryNum, 0);
 
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_BASIC_RATE, padapter->mlmepriv.cur_network.network.SupportedRates);
+               HalSetBrateCfg23a(padapter, padapter->mlmepriv.cur_network.network.SupportedRates);
                BTDM_SetFwChnlInfo(padapter, RT_MEDIA_CONNECT);
                break;
        default:
@@ -5764,13 +5762,17 @@ static void btdm_1AntCoexProcessForWifiConnect(struct rtw_adapter *padapter)
        pBtdm8723 = &pBtCoex->btdm1Ant;
        BtState = pBtCoex->c2hBtInfo;
 
-       RTPRINT(FBT, BT_TRACE, ("[BTCoex], WiFi is %s\n", BTDM_IsWifiBusy(padapter)?"Busy":"IDLE"));
-       RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT is %s\n", BtStateString[BtState]));
+       RTPRINT(FBT, BT_TRACE, ("[BTCoex], WiFi is %s\n",
+                               BTDM_IsWifiBusy(padapter)?"Busy":"IDLE"));
+       RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT is %s\n",
+                               BtStateString[BtState]));
 
        padapter->pwrctrlpriv.btcoex_rfon = false;
 
-       if ((!BTDM_IsWifiBusy(padapter)) && (!check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE)) &&
-           ((BtState == BT_INFO_STATE_NO_CONNECTION) || (BtState == BT_INFO_STATE_CONNECT_IDLE))) {
+       if (!BTDM_IsWifiBusy(padapter) &&
+           !check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) &&
+           (BtState == BT_INFO_STATE_NO_CONNECTION ||
+            BtState == BT_INFO_STATE_CONNECT_IDLE)) {
                switch (BtState) {
                case BT_INFO_STATE_NO_CONNECTION:
                        _btdm_1AntSetPSTDMA(padapter, true, 2, 0x26, false, 9);
@@ -5789,20 +5791,25 @@ static void btdm_1AntCoexProcessForWifiConnect(struct rtw_adapter *padapter)
                        rtw_write32(padapter, 0x6c4, 0x5a5a5a5a);
                        break;
                case BT_INFO_STATE_ACL_INQ_OR_PAG:
-                       RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT PROFILE is BT_INFO_STATE_ACL_INQ_OR_PAG\n"));
+                       RTPRINT(FBT, BT_TRACE,
+                               ("[BTCoex], BT PROFILE is "
+                                "BT_INFO_STATE_ACL_INQ_OR_PAG\n"));
                case BT_INFO_STATE_INQ_OR_PAG:
                        padapter->pwrctrlpriv.btcoex_rfon = true;
                        btdm_1AntSetPSTDMA(padapter, true, 0, true, 30);
                        break;
                case BT_INFO_STATE_SCO_ONLY_BUSY:
                case BT_INFO_STATE_ACL_SCO_BUSY:
-                       if (true == pBtCoex->bC2hBtInquiryPage) {
-                               btdm_1AntSetPSTDMA(padapter, false, 0, true, 32);
-                       } else {
+                       if (true == pBtCoex->bC2hBtInquiryPage)
+                               btdm_1AntSetPSTDMA(padapter, false, 0,
+                                                  true, 32);
+                       else {
 #ifdef BTCOEX_CMCC_TEST
-                               btdm_1AntSetPSTDMA(padapter, false, 0, true, 23);
+                               btdm_1AntSetPSTDMA(padapter, false, 0,
+                                                  true, 23);
 #else /*  !BTCOEX_CMCC_TEST */
-                               btdm_1AntSetPSTDMA(padapter, false, 0, false, 8);
+                               btdm_1AntSetPSTDMA(padapter, false, 0,
+                                                  false, 8);
                                rtw_write32(padapter, 0x6c0, 0x5a5a5a5a);
                                rtw_write32(padapter, 0x6c4, 0x5a5a5a5a);
 #endif /*  !BTCOEX_CMCC_TEST */
@@ -5811,19 +5818,28 @@ static void btdm_1AntCoexProcessForWifiConnect(struct rtw_adapter *padapter)
                case BT_INFO_STATE_ACL_ONLY_BUSY:
                        padapter->pwrctrlpriv.btcoex_rfon = true;
                        if (pBtCoex->c2hBtProfile == BT_INFO_HID) {
-                               RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT PROFILE is HID\n"));
+                               RTPRINT(FBT, BT_TRACE,
+                                       ("[BTCoex], BT PROFILE is HID\n"));
                                btdm_1AntSetPSTDMA(padapter, true, 0, true, 31);
                        } else if (pBtCoex->c2hBtProfile == BT_INFO_FTP) {
-                               RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT PROFILE is FTP/OPP\n"));
+                               RTPRINT(FBT, BT_TRACE,
+                                       ("[BTCoex], BT PROFILE is FTP/OPP\n"));
                                btdm_1AntSetPSTDMA(padapter, true, 0, true, 3);
                        } else if (pBtCoex->c2hBtProfile == (BT_INFO_A2DP|BT_INFO_FTP)) {
-                               RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT PROFILE is A2DP_FTP\n"));
+                               RTPRINT(FBT, BT_TRACE,
+                                       ("[BTCoex], BT PROFILE is A2DP_FTP\n"));
                                btdm_1AntSetPSTDMA(padapter, true, 0, true, 11);
                        } else {
                                if (pBtCoex->c2hBtProfile == BT_INFO_A2DP)
-                                       RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT PROFILE is A2DP\n"));
+                                       RTPRINT(FBT, BT_TRACE,
+                                               ("[BTCoex], BT PROFILE is "
+                                                "A2DP\n"));
                                else
-                                       RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT PROFILE is UNKNOWN(0x%02X)! Use A2DP Profile\n", pBtCoex->c2hBtProfile));
+                                       RTPRINT(FBT, BT_TRACE,
+                                               ("[BTCoex], BT PROFILE is "
+                                                "UNKNOWN(0x%02X)! Use A2DP "
+                                                "Profile\n",
+                                                pBtCoex->c2hBtProfile));
                                btdm_1AntTdmaDurationAdjustForACL(padapter);
                        }
                        break;
@@ -5833,13 +5849,14 @@ static void btdm_1AntCoexProcessForWifiConnect(struct rtw_adapter *padapter)
        pBtdm8723->psTdmaGlobalCnt++;
 }
 
-static void btdm_1AntUpdateHalRAMask(struct rtw_adapter *padapter, u32 mac_id, u32 filter)
+static void
+btdm_1AntUpdateHalRAMask(struct rtw_adapter *padapter, u32 mac_id, u32 filter)
 {
        u8 init_rate = 0;
        u8 raid;
        u32 mask;
        u8 shortGIrate = false;
-       int     supportRateNum = 0;
+       int supportRateNum = 0;
        struct sta_info *psta;
        struct hal_data_8723a *pHalData;
        struct dm_priv *pdmpriv;
@@ -5847,7 +5864,8 @@ static void btdm_1AntUpdateHalRAMask(struct rtw_adapter *padapter, u32 mac_id, u
        struct mlme_ext_info *pmlmeinfo;
        struct wlan_bssid_ex *cur_network;
 
-       RTPRINT(FBT, BT_TRACE, ("[BTCoex], %s, MACID =%d, filter = 0x%08x!!\n", __func__, mac_id, filter));
+       RTPRINT(FBT, BT_TRACE, ("[BTCoex], %s, MACID =%d, filter = 0x%08x!!\n",
+                               __func__, mac_id, filter));
 
        pHalData = GET_HAL_DATA(padapter);
        pdmpriv = &pHalData->dmpriv;
@@ -5856,13 +5874,15 @@ static void btdm_1AntUpdateHalRAMask(struct rtw_adapter *padapter, u32 mac_id, u
        cur_network = &pmlmeinfo->network;
 
        if (mac_id >= NUM_STA) { /* CAM_SIZE */
-               RTPRINT(FBT, BT_TRACE, ("[BTCoex], %s, MACID =%d illegal!!\n", __func__, mac_id));
+               RTPRINT(FBT, BT_TRACE, ("[BTCoex], %s, MACID =%d illegal!!\n",
+                                       __func__, mac_id));
                return;
        }
 
        psta = pmlmeinfo->FW_sta_info[mac_id].psta;
-       if (psta == NULL) {
-               RTPRINT(FBT, BT_TRACE, ("[BTCoex], %s, Can't find station!!\n", __func__));
+       if (!psta) {
+               RTPRINT(FBT, BT_TRACE, ("[BTCoex], %s, Can't find station!!\n",
+                                       __func__));
                return;
        }
 
@@ -5870,19 +5890,26 @@ static void btdm_1AntUpdateHalRAMask(struct rtw_adapter *padapter, u32 mac_id, u
 
        switch (mac_id) {
        case 0:/*  for infra mode */
-               supportRateNum = rtw_get_rateset_len23a(cur_network->SupportedRates);
-               mask = update_supported_rate23a(cur_network->SupportedRates, supportRateNum);
-               mask |= (pmlmeinfo->HT_enable) ? update_MSC_rate23a(&pmlmeinfo->HT_caps):0;
+               supportRateNum =
+                       rtw_get_rateset_len23a(cur_network->SupportedRates);
+               mask = update_supported_rate23a(cur_network->SupportedRates,
+                                               supportRateNum);
+               mask |= (pmlmeinfo->HT_enable) ?
+                       update_MSC_rate23a(&pmlmeinfo->HT_caps):0;
                if (support_short_GI23a(padapter, &pmlmeinfo->HT_caps))
                        shortGIrate = true;
                break;
        case 1:/* for broadcast/multicast */
-               supportRateNum = rtw_get_rateset_len23a(pmlmeinfo->FW_sta_info[mac_id].SupportedRates);
-               mask = update_basic_rate23a(cur_network->SupportedRates, supportRateNum);
+               supportRateNum = rtw_get_rateset_len23a(
+                       pmlmeinfo->FW_sta_info[mac_id].SupportedRates);
+               mask = update_basic_rate23a(cur_network->SupportedRates,
+                                           supportRateNum);
                break;
        default: /* for each sta in IBSS */
-               supportRateNum = rtw_get_rateset_len23a(pmlmeinfo->FW_sta_info[mac_id].SupportedRates);
-               mask = update_supported_rate23a(cur_network->SupportedRates, supportRateNum);
+               supportRateNum = rtw_get_rateset_len23a(
+                       pmlmeinfo->FW_sta_info[mac_id].SupportedRates);
+               mask = update_supported_rate23a(cur_network->SupportedRates,
+                                               supportRateNum);
                break;
        }
        mask |= ((raid<<28)&0xf0000000);
@@ -5899,8 +5926,8 @@ static void btdm_1AntUpdateHalRAMask(struct rtw_adapter *padapter, u32 mac_id, u
                        arg |= BIT(5);
 
                RTPRINT(FBT, BT_TRACE,
-                       ("[BTCoex], Update FW RAID entry, MASK = 0x%08x, arg = 0x%02x\n",
-                       mask, arg));
+                       ("[BTCoex], Update FW RAID entry, MASK = 0x%08x, "
+                        "arg = 0x%02x\n", mask, arg));
 
                rtl8723a_set_raid_cmd(padapter, mask, arg);
        } else {
@@ -5914,7 +5941,8 @@ static void btdm_1AntUpdateHalRAMask(struct rtw_adapter *padapter, u32 mac_id, u
        pdmpriv->INIDATA_RATE[mac_id] = init_rate;
 }
 
-static void btdm_1AntUpdateHalRAMaskForSCO(struct rtw_adapter *padapter, u8 forceUpdate)
+static void
+btdm_1AntUpdateHalRAMaskForSCO(struct rtw_adapter *padapter, u8 forceUpdate)
 {
        struct btdm_8723a_1ant *pBtdm8723;
        struct sta_priv *pstapriv;
@@ -5925,7 +5953,7 @@ static void btdm_1AntUpdateHalRAMaskForSCO(struct rtw_adapter *padapter, u8 forc
 
        pBtdm8723 = &GET_HAL_DATA(padapter)->bt_coexist.halCoex8723.btdm1Ant;
 
-       if ((pBtdm8723->bRAChanged == true) && (forceUpdate == false))
+       if (pBtdm8723->bRAChanged == true && forceUpdate == false)
                return;
 
        pstapriv = &padapter->stapriv;
@@ -5968,9 +5996,13 @@ static void btdm_1AntRecoverHalRAMask(struct rtw_adapter *padapter)
 
 static void
 btdm_1AntBTStateChangeHandler(struct rtw_adapter *padapter,
-                             enum bt_state_1ant oldState, enum bt_state_1ant newState)
+                             enum bt_state_1ant oldState,
+                             enum bt_state_1ant newState)
 {
-       RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT state change, %s => %s\n", BtStateString[oldState], BtStateString[newState]));
+       struct hal_data_8723a *phaldata;
+       RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT state change, %s => %s\n",
+                               BtStateString[oldState],
+                               BtStateString[newState]));
 
        /*  BT default ignore wlan active, */
        /*  WiFi MUST disable this when BT is enable */
@@ -5987,22 +6019,23 @@ btdm_1AntBTStateChangeHandler(struct rtw_adapter *padapter,
                        btdm_1AntRecoverHalRAMask(padapter);
                }
        } else {
-               GET_HAL_DATA(padapter)->bt_coexist.halCoex8723.btdm1Ant.bRAChanged = false;
+               phaldata = GET_HAL_DATA(padapter);
+               phaldata->bt_coexist.halCoex8723.btdm1Ant.bRAChanged = false;
        }
 
        if (oldState == newState)
                return;
 
        if (oldState == BT_INFO_STATE_ACL_ONLY_BUSY) {
-               struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
-               pHalData->bt_coexist.halCoex8723.btdm1Ant.psTdmaMonitorCnt = 0;
-               pHalData->bt_coexist.halCoex8723.btdm1Ant.psTdmaMonitorCntForSCO = 0;
+               struct hal_data_8723a *Hal = GET_HAL_DATA(padapter);
+               Hal->bt_coexist.halCoex8723.btdm1Ant.psTdmaMonitorCnt = 0;
+               Hal->bt_coexist.halCoex8723.btdm1Ant.psTdmaMonitorCntForSCO = 0;
        }
 
        if ((oldState == BT_INFO_STATE_SCO_ONLY_BUSY) ||
            (oldState == BT_INFO_STATE_ACL_SCO_BUSY)) {
-               struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
-               pHalData->bt_coexist.halCoex8723.btdm1Ant.psTdmaMonitorCntForSCO = 0;
+               struct hal_data_8723a *Hal = GET_HAL_DATA(padapter);
+               Hal->bt_coexist.halCoex8723.btdm1Ant.psTdmaMonitorCntForSCO = 0;
        }
 
        /*  Active 2Ant mechanism when BT Connected */
@@ -6010,14 +6043,16 @@ btdm_1AntBTStateChangeHandler(struct rtw_adapter *padapter,
            (oldState == BT_INFO_STATE_NO_CONNECTION)) {
                if ((newState != BT_INFO_STATE_DISABLED) &&
                    (newState != BT_INFO_STATE_NO_CONNECTION)) {
-                       BTDM_SetSwRfRxLpfCorner(padapter, BT_RF_RX_LPF_CORNER_SHRINK);
+                       BTDM_SetSwRfRxLpfCorner(padapter,
+                                               BT_RF_RX_LPF_CORNER_SHRINK);
                        BTDM_AGCTable(padapter, BT_AGCTABLE_ON);
                        BTDM_BBBackOffLevel(padapter, BT_BB_BACKOFF_ON);
                }
        } else {
                if ((newState == BT_INFO_STATE_DISABLED) ||
                    (newState == BT_INFO_STATE_NO_CONNECTION)) {
-                       BTDM_SetSwRfRxLpfCorner(padapter, BT_RF_RX_LPF_CORNER_RESUME);
+                       BTDM_SetSwRfRxLpfCorner(padapter,
+                                               BT_RF_RX_LPF_CORNER_RESUME);
                        BTDM_AGCTable(padapter, BT_AGCTABLE_OFF);
                        BTDM_BBBackOffLevel(padapter, BT_BB_BACKOFF_OFF);
                }
@@ -6038,17 +6073,23 @@ static void btdm_1AntBtCoexistHandler(struct rtw_adapter *padapter)
                RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT is disabled\n"));
 
                if (BTDM_IsWifiConnectionExist(padapter)) {
-                       RTPRINT(FBT, BT_TRACE, ("[BTCoex], wifi is connected\n"));
+                       RTPRINT(FBT, BT_TRACE,
+                               ("[BTCoex], wifi is connected\n"));
 
                        if (BTDM_IsWifiBusy(padapter)) {
-                               RTPRINT(FBT, BT_TRACE, ("[BTCoex], Wifi is busy\n"));
-                               btdm_1AntSetPSTDMA(padapter, false, 0, false, 9);
+                               RTPRINT(FBT, BT_TRACE,
+                                       ("[BTCoex], Wifi is busy\n"));
+                               btdm_1AntSetPSTDMA(padapter, false, 0,
+                                                  false, 9);
                        } else {
-                               RTPRINT(FBT, BT_TRACE, ("[BTCoex], Wifi is idle\n"));
-                               _btdm_1AntSetPSTDMA(padapter, true, 2, 1, false, 9);
+                               RTPRINT(FBT, BT_TRACE,
+                                       ("[BTCoex], Wifi is idle\n"));
+                               _btdm_1AntSetPSTDMA(padapter, true, 2, 1,
+                                                   false, 9);
                        }
                } else {
-                       RTPRINT(FBT, BT_TRACE, ("[BTCoex], wifi is disconnected\n"));
+                       RTPRINT(FBT, BT_TRACE,
+                               ("[BTCoex], wifi is disconnected\n"));
 
                        btdm_1AntSetPSTDMA(padapter, false, 0, false, 9);
                }
@@ -6056,24 +6097,29 @@ static void btdm_1AntBtCoexistHandler(struct rtw_adapter *padapter)
                RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT is enabled\n"));
 
                if (BTDM_IsWifiConnectionExist(padapter)) {
-                       RTPRINT(FBT, BT_TRACE, ("[BTCoex], wifi is connected\n"));
+                       RTPRINT(FBT, BT_TRACE,
+                               ("[BTCoex], wifi is connected\n"));
 
                        btdm_1AntWifiParaAdjust(padapter, true);
                        btdm_1AntCoexProcessForWifiConnect(padapter);
                } else {
-                       RTPRINT(FBT, BT_TRACE, ("[BTCoex], wifi is disconnected\n"));
+                       RTPRINT(FBT, BT_TRACE,
+                               ("[BTCoex], wifi is disconnected\n"));
 
-                       /*  Antenna switch at BT side(0x870 = 0x300, 0x860 = 0x210) after PSTDMA off */
+                       /*  Antenna switch at BT side(0x870 = 0x300,
+                           0x860 = 0x210) after PSTDMA off */
                        btdm_1AntWifiParaAdjust(padapter, false);
                        btdm_1AntSetPSTDMA(padapter, false, 0, false, 0);
                }
        }
 
-       btdm_1AntBTStateChangeHandler(padapter, pBtCoex8723->prec2hBtInfo, pBtCoex8723->c2hBtInfo);
+       btdm_1AntBTStateChangeHandler(padapter, pBtCoex8723->prec2hBtInfo,
+                                     pBtCoex8723->c2hBtInfo);
        pBtCoex8723->prec2hBtInfo = pBtCoex8723->c2hBtInfo;
 }
 
-void BTDM_1AntSignalCompensation(struct rtw_adapter *padapter, u8 *rssi_wifi, u8 *rssi_bt)
+void BTDM_1AntSignalCompensation(struct rtw_adapter *padapter,
+                                u8 *rssi_wifi, u8 *rssi_bt)
 {
        struct hal_data_8723a *pHalData;
        struct btdm_8723a_1ant *pBtdm8723;
@@ -6119,14 +6165,19 @@ void BTDM_1AntSignalCompensation(struct rtw_adapter *padapter, u8 *rssi_wifi, u8
        }
 
        if (rssi_wifi && RSSI_WiFi_Cmpnstn) {
-               RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1AntSgnlCmpnstn, case %d, WiFiCmpnstn =%d(%d => %d)\n",
-                               pBtdm8723->curPsTdma, RSSI_WiFi_Cmpnstn, *rssi_wifi, *rssi_wifi+RSSI_WiFi_Cmpnstn));
+               RTPRINT(FBT, BT_TRACE,
+                       ("[BTCoex], 1AntSgnlCmpnstn, case %d, WiFiCmpnstn "
+                        "=%d(%d => %d)\n", pBtdm8723->curPsTdma,
+                        RSSI_WiFi_Cmpnstn, *rssi_wifi,
+                        *rssi_wifi+RSSI_WiFi_Cmpnstn));
                *rssi_wifi += RSSI_WiFi_Cmpnstn;
        }
 
        if (rssi_bt && RSSI_BT_Cmpnstn) {
-               RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1AntSgnlCmpnstn, case %d, BTCmpnstn =%d(%d => %d)\n",
-                               pBtdm8723->curPsTdma, RSSI_BT_Cmpnstn, *rssi_bt, *rssi_bt+RSSI_BT_Cmpnstn));
+               RTPRINT(FBT, BT_TRACE,
+                       ("[BTCoex], 1AntSgnlCmpnstn, case %d, BTCmpnstn "
+                        "=%d(%d => %d)\n", pBtdm8723->curPsTdma,
+                        RSSI_BT_Cmpnstn, *rssi_bt, *rssi_bt+RSSI_BT_Cmpnstn));
                *rssi_bt += RSSI_BT_Cmpnstn;
        }
 }
@@ -6162,7 +6213,8 @@ static void BTDM_1AntForHalt(struct rtw_adapter *padapter)
 {
        RTPRINT(FBT, BT_TRACE, ("\n[BTCoex], 1Ant for halt\n"));
 
-       GET_HAL_DATA(padapter)->bt_coexist.halCoex8723.btdm1Ant.bWiFiHalt = true;
+       GET_HAL_DATA(padapter)->bt_coexist.halCoex8723.btdm1Ant.bWiFiHalt =
+               true;
 
        btdm_1AntWifiParaAdjust(padapter, false);
 
@@ -6180,7 +6232,8 @@ static void BTDM_1AntLpsLeave(struct rtw_adapter *padapter)
        RTPRINT(FBT, BT_TRACE, ("\n[BTCoex], 1Ant for LPS Leave\n"));
 
        /*  Prevent from entering LPS again */
-       GET_HAL_DATA(padapter)->bt_coexist.halCoex8723.btdm1Ant.bWiFiHalt = true;
+       GET_HAL_DATA(padapter)->bt_coexist.halCoex8723.btdm1Ant.bWiFiHalt =
+               true;
 
        btdm_1AntSetPSTDMA(padapter, false, 0, false, 8);
 /*btdm_1AntPsTdma(padapter, false, 8); */
@@ -6190,13 +6243,14 @@ static void BTDM_1AntWifiAssociateNotify(struct rtw_adapter *padapter, u8 type)
 {
        struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
 
-       RTPRINT(FBT, BT_TRACE, ("\n[BTCoex], 1Ant for associate, type =%d\n", type));
+       RTPRINT(FBT, BT_TRACE,
+               ("\n[BTCoex], 1Ant for associate, type =%d\n", type));
 
        if (type) {
                rtl8723a_CheckAntenna_Selection(padapter);
-               if (BT_IsBtDisabled(padapter)) {
+               if (BT_IsBtDisabled(padapter))
                        btdm_1AntSetPSTDMA(padapter, false, 0, false, 9);
-               else {
+               else {
                        struct bt_coexist_8723a *pBtCoex;
                        u8 BtState;
 
@@ -6205,20 +6259,24 @@ static void BTDM_1AntWifiAssociateNotify(struct rtw_adapter *padapter, u8 type)
 
                        btdm_1AntTSFSwitch(padapter, true);
 
-                       if ((BtState == BT_INFO_STATE_NO_CONNECTION) ||
-                           (BtState == BT_INFO_STATE_CONNECT_IDLE)) {
-                               btdm_1AntSetPSTDMA(padapter, false, 0, true, 28);
-                       } else if ((BtState == BT_INFO_STATE_SCO_ONLY_BUSY) ||
-                                  (BtState == BT_INFO_STATE_ACL_SCO_BUSY)) {
-                               btdm_1AntSetPSTDMA(padapter, false, 0, false, 8);
+                       if (BtState == BT_INFO_STATE_NO_CONNECTION ||
+                           BtState == BT_INFO_STATE_CONNECT_IDLE) {
+                               btdm_1AntSetPSTDMA(padapter, false, 0,
+                                                  true, 28);
+                       } else if (BtState == BT_INFO_STATE_SCO_ONLY_BUSY ||
+                                  BtState == BT_INFO_STATE_ACL_SCO_BUSY) {
+                               btdm_1AntSetPSTDMA(padapter, false, 0,
+                                                  false, 8);
                                rtw_write32(padapter, 0x6c0, 0x5a5a5a5a);
                                rtw_write32(padapter, 0x6c4, 0x5a5a5a5a);
-                       } else if ((BtState == BT_INFO_STATE_ACL_ONLY_BUSY) ||
-                                  (BtState == BT_INFO_STATE_ACL_INQ_OR_PAG)) {
+                       } else if (BtState == BT_INFO_STATE_ACL_ONLY_BUSY ||
+                                  BtState == BT_INFO_STATE_ACL_INQ_OR_PAG) {
                                if (pBtCoex->c2hBtProfile == BT_INFO_HID)
-                                       btdm_1AntSetPSTDMA(padapter, false, 0, true, 35);
+                                       btdm_1AntSetPSTDMA(padapter, false, 0,
+                                                          true, 35);
                                else
-                                       btdm_1AntSetPSTDMA(padapter, false, 0, true, 29);
+                                       btdm_1AntSetPSTDMA(padapter, false, 0,
+                                                          true, 29);
                        }
                }
        } else {
@@ -6241,22 +6299,24 @@ BTDM_1AntMediaStatusNotify(struct rtw_adapter *padapter,
 
        pBtCoex = &GET_HAL_DATA(padapter)->bt_coexist.halCoex8723;
 
-       RTPRINT(FBT, BT_TRACE, ("\n\n[BTCoex]******************************\n"));
+       RTPRINT(FBT, BT_TRACE,
+               ("\n\n[BTCoex]******************************\n"));
        RTPRINT(FBT, BT_TRACE, ("[BTCoex], MediaStatus, WiFi %s !!\n",
                        mstatus == RT_MEDIA_CONNECT?"CONNECT":"DISCONNECT"));
        RTPRINT(FBT, BT_TRACE, ("[BTCoex]******************************\n"));
 
        if (RT_MEDIA_CONNECT == mstatus) {
                if (check_fwstate(&padapter->mlmepriv, WIFI_STATION_STATE)) {
-                       if ((pBtCoex->c2hBtInfo == BT_INFO_STATE_SCO_ONLY_BUSY) ||
-                           (pBtCoex->c2hBtInfo == BT_INFO_STATE_ACL_SCO_BUSY))
+                       if (pBtCoex->c2hBtInfo == BT_INFO_STATE_SCO_ONLY_BUSY ||
+                           pBtCoex->c2hBtInfo == BT_INFO_STATE_ACL_SCO_BUSY)
                                btdm_1AntUpdateHalRAMaskForSCO(padapter, true);
                }
 
                padapter->pwrctrlpriv.DelayLPSLastTimeStamp = jiffies;
                BTDM_1AntForDhcp(padapter);
        } else {
-               /* DBG_8723A("%s rtl8723a_DeinitAntenna_Selection\n", __func__); */
+               /* DBG_8723A("%s rtl8723a_DeinitAntenna_Selection\n",
+                  __func__); */
                rtl8723a_DeinitAntenna_Selection(padapter);
                btdm_1AntBtCoexistHandler(padapter);
                pBtCoex->btdm1Ant.bRAChanged = false;
@@ -6276,8 +6336,10 @@ void BTDM_1AntForDhcp(struct rtw_adapter *padapter)
        pBtdm8723 = &pBtCoex->btdm1Ant;
 
        RTPRINT(FBT, BT_TRACE, ("\n[BTCoex], 1Ant for DHCP\n"));
-       RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1Ant for DHCP, WiFi is %s\n", BTDM_IsWifiBusy(padapter)?"Busy":"IDLE"));
-       RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1Ant for DHCP, %s\n", BtStateString[BtState]));
+       RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1Ant for DHCP, WiFi is %s\n",
+                               BTDM_IsWifiBusy(padapter)?"Busy":"IDLE"));
+       RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1Ant for DHCP, %s\n",
+                               BtStateString[BtState]));
 
        BTDM_1AntWifiAssociateNotify(padapter, true);
 }
@@ -6294,9 +6356,12 @@ static void BTDM_1AntWifiScanNotify(struct rtw_adapter *padapter, u8 scanType)
        pBtCoex = &pHalData->bt_coexist.halCoex8723;
        pBtdm8723 = &pBtCoex->btdm1Ant;
 
-       RTPRINT(FBT, BT_TRACE, ("\n[BTCoex], 1Ant for wifi scan =%d!!\n", scanType));
-       RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1Ant for wifi scan, WiFi is %s\n", BTDM_IsWifiBusy(padapter)?"Busy":"IDLE"));
-       RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1Ant for wifi scan, %s\n", BtStateString[BtState]));
+       RTPRINT(FBT, BT_TRACE, ("\n[BTCoex], 1Ant for wifi scan =%d!!\n",
+                               scanType));
+       RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1Ant for wifi scan, WiFi is %s\n",
+                               BTDM_IsWifiBusy(padapter)?"Busy":"IDLE"));
+       RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1Ant for wifi scan, %s\n",
+                               BtStateString[BtState]));
 
        if (scanType) {
                rtl8723a_CheckAntenna_Selection(padapter);
@@ -6308,10 +6373,13 @@ static void BTDM_1AntWifiScanNotify(struct rtw_adapter *padapter, u8 scanType)
                        if ((BtState == BT_INFO_STATE_SCO_ONLY_BUSY) ||
                            (BtState == BT_INFO_STATE_ACL_SCO_BUSY)) {
                                if (pBtCoex->bC2hBtInquiryPage) {
-                                       btdm_1AntSetPSTDMA(padapter, false, 0, true, 32);
+                                       btdm_1AntSetPSTDMA(padapter, false, 0,
+                                                          true, 32);
                                } else {
-                                       padapter->pwrctrlpriv.btcoex_rfon = true;
-                                       btdm_1AntSetPSTDMA(padapter, true, 0, true, 33);
+                                       padapter->pwrctrlpriv.btcoex_rfon =
+                                               true;
+                                       btdm_1AntSetPSTDMA(padapter, true, 0,
+                                                          true, 33);
                                }
                        } else if (true == pBtCoex->bC2hBtInquiryPage) {
                                padapter->pwrctrlpriv.btcoex_rfon = true;
@@ -6319,9 +6387,11 @@ static void BTDM_1AntWifiScanNotify(struct rtw_adapter *padapter, u8 scanType)
                        } else if (BtState == BT_INFO_STATE_ACL_ONLY_BUSY) {
                                padapter->pwrctrlpriv.btcoex_rfon = true;
                                if (pBtCoex->c2hBtProfile == BT_INFO_HID)
-                                       btdm_1AntSetPSTDMA(padapter, true, 0, true, 34);
+                                       btdm_1AntSetPSTDMA(padapter, true, 0,
+                                                          true, 34);
                                else
-                                       btdm_1AntSetPSTDMA(padapter, true, 0, true, 4);
+                                       btdm_1AntSetPSTDMA(padapter, true, 0,
+                                                          true, 4);
                        } else {
                                padapter->pwrctrlpriv.btcoex_rfon = true;
                                btdm_1AntSetPSTDMA(padapter, true, 0, true, 5);
@@ -6365,16 +6435,18 @@ static void BTDM_1AntFwC2hBtInfo8723A(struct rtw_adapter *padapter)
                pBtCoex->bC2hBtInquiryPage = false;
        btState &= ~BIT(2);
 
-       if (!(btState & BIT(0))) {
+       if (!(btState & BIT(0)))
                pBtCoex->c2hBtInfo = BT_INFO_STATE_NO_CONNECTION;
-       else {
-               if (btState == 0x1) {
+       else {
+               if (btState == 0x1)
                        pBtCoex->c2hBtInfo = BT_INFO_STATE_CONNECT_IDLE;
-               else if (btState == 0x9) {
+               else if (btState == 0x9) {
                        if (pBtCoex->bC2hBtInquiryPage == true)
-                               pBtCoex->c2hBtInfo = BT_INFO_STATE_ACL_INQ_OR_PAG;
+                               pBtCoex->c2hBtInfo =
+                                       BT_INFO_STATE_ACL_INQ_OR_PAG;
                        else
-                               pBtCoex->c2hBtInfo = BT_INFO_STATE_ACL_ONLY_BUSY;
+                               pBtCoex->c2hBtInfo =
+                                       BT_INFO_STATE_ACL_ONLY_BUSY;
                        pBtMgnt->ExtConfig.bBTBusy = true;
                } else if (btState == 0x3) {
                        pBtCoex->c2hBtInfo = BT_INFO_STATE_SCO_ONLY_BUSY;
@@ -6382,15 +6454,15 @@ static void BTDM_1AntFwC2hBtInfo8723A(struct rtw_adapter *padapter)
                } else if (btState == 0xb) {
                        pBtCoex->c2hBtInfo = BT_INFO_STATE_ACL_SCO_BUSY;
                        pBtMgnt->ExtConfig.bBTBusy = true;
-               } else {
+               } else
                        pBtCoex->c2hBtInfo = BT_INFO_STATE_MAX;
-               }
                if (pBtMgnt->ExtConfig.bBTBusy)
-                       pHalData->bt_coexist.CurrentState &= ~BT_COEX_STATE_BT_IDLE;
+                       pHalData->bt_coexist.CurrentState &=
+                               ~BT_COEX_STATE_BT_IDLE;
        }
 
-       if ((BT_INFO_STATE_NO_CONNECTION == pBtCoex->c2hBtInfo) ||
-           (BT_INFO_STATE_CONNECT_IDLE == pBtCoex->c2hBtInfo)) {
+       if (BT_INFO_STATE_NO_CONNECTION == pBtCoex->c2hBtInfo ||
+           BT_INFO_STATE_CONNECT_IDLE == pBtCoex->c2hBtInfo) {
                if (pBtCoex->bC2hBtInquiryPage)
                        pBtCoex->c2hBtInfo = BT_INFO_STATE_INQ_OR_PAG;
        }
@@ -6413,12 +6485,14 @@ void BTDM_1AntBtCoexist8723A(struct rtw_adapter *padapter)
 
        if (check_fwstate(pmlmepriv, WIFI_SITE_MONITOR)) {
                /*  already done in BTDM_1AntForScan() */
-               RTPRINT(FBT, BT_TRACE, ("[BTCoex], wifi is under scan progress!!\n"));
+               RTPRINT(FBT, BT_TRACE,
+                       ("[BTCoex], wifi is under scan progress!!\n"));
                return;
        }
 
        if (check_fwstate(pmlmepriv, WIFI_UNDER_LINKING)) {
-               RTPRINT(FBT, BT_TRACE, ("[BTCoex], wifi is under link progress!!\n"));
+               RTPRINT(FBT, BT_TRACE,
+                       ("[BTCoex], wifi is under link progress!!\n"));
                return;
        }
 
@@ -11221,7 +11295,9 @@ void HALBT_SetKey(struct rtw_adapter *padapter, u8 EntryNum)
        pBtAssocEntry->HwCAMIndex = BT_HWCAM_STAR + EntryNum;
 
        usConfig = CAM_VALID | (CAM_AES << 2);
-       write_cam23a(padapter, pBtAssocEntry->HwCAMIndex, usConfig, pBtAssocEntry->BTRemoteMACAddr, pBtAssocEntry->PTK + TKIP_ENC_KEY_POS);
+       rtl8723a_cam_write(padapter, pBtAssocEntry->HwCAMIndex, usConfig,
+                          pBtAssocEntry->BTRemoteMACAddr,
+                          pBtAssocEntry->PTK + TKIP_ENC_KEY_POS);
 }
 
 void HALBT_RemoveKey(struct rtw_adapter *padapter, u8 EntryNum)
@@ -11234,8 +11310,10 @@ void HALBT_RemoveKey(struct rtw_adapter *padapter, u8 EntryNum)
 
        if (pBTinfo->BtAsocEntry[EntryNum].HwCAMIndex != 0) {
                /*  ToDo : add New HALBT_RemoveKey function !! */
-               if (pBtAssocEntry->HwCAMIndex >= BT_HWCAM_STAR && pBtAssocEntry->HwCAMIndex < HALF_CAM_ENTRY)
-                       CAM_empty_entry23a(padapter, pBtAssocEntry->HwCAMIndex);
+               if (pBtAssocEntry->HwCAMIndex >= BT_HWCAM_STAR &&
+                   pBtAssocEntry->HwCAMIndex < HALF_CAM_ENTRY)
+                       rtl8723a_cam_empty_entry(padapter,
+                                                pBtAssocEntry->HwCAMIndex);
                pBTinfo->BtAsocEntry[EntryNum].HwCAMIndex = 0;
        }
 }
index 0b205e1204fc3ea7b68367d7c7c6fa06239d536d..ffd6b73eb6a89aa25272fc7f063cdf40ad0b36ee 100644 (file)
@@ -17,7 +17,6 @@
 #include <osdep_service.h>
 #include <drv_types.h>
 #include <recv_osdep.h>
-#include <cmd_osdep.h>
 #include <mlme_osdep.h>
 #include <rtw_ioctl_set.h>
 #include <rtl8723a_hal.h>
@@ -203,7 +202,7 @@ void rtl8723a_set_FwPwrMode_cmd(struct rtw_adapter *padapter, u8 Mode)
 static void ConstructBeacon(struct rtw_adapter *padapter, u8 *pframe, u32 *pLength)
 {
        struct ieee80211_hdr *pwlanhdr;
-       u16 *fctrl;
+       __le16 *fctrl;
        u32 rate_len, pktlen;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
@@ -255,30 +254,36 @@ static void ConstructBeacon(struct rtw_adapter *padapter, u8 *pframe, u32 *pLeng
        /* below for ad-hoc mode */
 
        /*  SSID */
-       pframe = rtw_set_ie23a(pframe, _SSID_IE_, cur_network->Ssid.ssid_len,
-                           cur_network->Ssid.ssid, &pktlen);
+       pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID,
+                              cur_network->Ssid.ssid_len,
+                              cur_network->Ssid.ssid, &pktlen);
 
        /*  supported rates... */
        rate_len = rtw_get_rateset_len23a(cur_network->SupportedRates);
-       pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ?
+       pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ?
                               8 : rate_len), cur_network->SupportedRates, &pktlen);
 
        /*  DS parameter set */
-       pframe = rtw_set_ie23a(pframe, _DSSET_IE_, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pktlen);
+       pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)
+                              &cur_network->Configuration.DSConfig, &pktlen);
 
        if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) {
                u32 ATIMWindow;
                /*  IBSS Parameter Set... */
                /* ATIMWindow = cur->Configuration.ATIMWindow; */
                ATIMWindow = 0;
-               pframe = rtw_set_ie23a(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pktlen);
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_IBSS_PARAMS, 2,
+                                      (unsigned char *)(&ATIMWindow), &pktlen);
        }
 
        /* todo: ERP IE */
 
        /*  EXTERNDED SUPPORTED RATE */
        if (rate_len > 8)
-               pframe = rtw_set_ie23a(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pktlen);
+               pframe = rtw_set_ie23a(pframe, WLAN_EID_EXT_SUPP_RATES,
+                                      (rate_len - 8),
+                                      (cur_network->SupportedRates + 8),
+                                      &pktlen);
 
        /* todo:HT for adhoc */
 
@@ -298,7 +303,7 @@ _ConstructBeacon:
 static void ConstructPSPoll(struct rtw_adapter *padapter, u8 *pframe, u32 *pLength)
 {
        struct ieee80211_hdr *pwlanhdr;
-       u16 *fctrl;
+       __le16 *fctrl;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
 
@@ -333,7 +338,7 @@ static void ConstructNullFunctionData(
        u8 bForcePowerSave)
 {
        struct ieee80211_hdr *pwlanhdr;
-       u16 *fctrl;
+       __le16 *fctrl;
        u32 pktlen;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct wlan_network             *cur_network = &pmlmepriv->cur_network;
@@ -397,7 +402,7 @@ static void ConstructNullFunctionData(
 static void ConstructProbeRsp(struct rtw_adapter *padapter, u8 *pframe, u32 *pLength, u8 *StaAddr, bool bHideSSID)
 {
        struct ieee80211_hdr *pwlanhdr;
-       u16 *fctrl;
+       __le16 *fctrl;
        u8 *mac, *bssid;
        u32 pktlen;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
@@ -770,76 +775,3 @@ void rtl8723a_set_BTCoex_AP_mode_FwRsvdPkt_cmd(struct rtw_adapter *padapter)
        }
 }
 #endif
-
-#ifdef CONFIG_8723AU_P2P
-void rtl8723a_set_p2p_ps_offload_cmd(struct rtw_adapter *padapter, u8 p2p_ps_state)
-{
-       struct hal_data_8723a   *pHalData = GET_HAL_DATA(padapter);
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       struct P2P_PS_Offload_t *p2p_ps_offload = &pHalData->p2p_ps_offload;
-       u8 i;
-
-       switch (p2p_ps_state) {
-       case P2P_PS_DISABLE:
-               DBG_8723A("P2P_PS_DISABLE \n");
-               memset(p2p_ps_offload, 0, 1);
-               break;
-       case P2P_PS_ENABLE:
-               DBG_8723A("P2P_PS_ENABLE \n");
-               /*  update CTWindow value. */
-               if (pwdinfo->ctwindow > 0) {
-                       p2p_ps_offload->CTWindow_En = 1;
-                       rtw_write8(padapter, REG_P2P_CTWIN, pwdinfo->ctwindow);
-               }
-
-               /*  hw only support 2 set of NoA */
-               for (i = 0; i < pwdinfo->noa_num; i++) {
-                       /*  To control the register setting for which NOA */
-                       rtw_write8(padapter, REG_NOA_DESC_SEL, (i << 4));
-                       if (i == 0)
-                               p2p_ps_offload->NoA0_En = 1;
-                       else
-                               p2p_ps_offload->NoA1_En = 1;
-
-                       /*  config P2P NoA Descriptor Register */
-                       rtw_write32(padapter, REG_NOA_DESC_DURATION, pwdinfo->noa_duration[i]);
-
-                       rtw_write32(padapter, REG_NOA_DESC_INTERVAL, pwdinfo->noa_interval[i]);
-
-                       rtw_write32(padapter, REG_NOA_DESC_START, pwdinfo->noa_start_time[i]);
-
-                       rtw_write8(padapter, REG_NOA_DESC_COUNT, pwdinfo->noa_count[i]);
-               }
-
-               if ((pwdinfo->opp_ps == 1) || (pwdinfo->noa_num > 0)) {
-                       /*  rst p2p circuit */
-                       rtw_write8(padapter, REG_DUAL_TSF_RST, BIT(4));
-
-                       p2p_ps_offload->Offload_En = 1;
-
-                       if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-                               p2p_ps_offload->role = 1;
-                               p2p_ps_offload->AllStaSleep = 0;
-                       } else {
-                               p2p_ps_offload->role = 0;
-                       }
-
-                       p2p_ps_offload->discovery = 0;
-               }
-               break;
-       case P2P_PS_SCAN:
-               DBG_8723A("P2P_PS_SCAN \n");
-               p2p_ps_offload->discovery = 1;
-               break;
-       case P2P_PS_SCAN_DONE:
-               DBG_8723A("P2P_PS_SCAN_DONE \n");
-               p2p_ps_offload->discovery = 0;
-               pwdinfo->p2p_ps_state = P2P_PS_ENABLE;
-               break;
-       default:
-               break;
-       }
-
-       FillH2CCmd(padapter, P2P_PS_OFFLOAD_EID, 1, (u8 *)p2p_ps_offload);
-}
-#endif /* CONFIG_8723AU_P2P */
index f204ab1714e7f921184cb0400248a8635cd7771f..4ca7b8ec7b38606210df706fc5c02fac59ce9176 100644 (file)
@@ -76,7 +76,7 @@ static void dm_CheckPbcGPIO(struct rtw_adapter *padapter)
                        return;
                }
 
-               rtw_signal_process(padapter->pid[0], SIGUSR1);
+               kill_pid(find_vpid(padapter->pid[0]), SIGUSR1, 1);
        }
 }
 
@@ -217,14 +217,7 @@ rtl8723a_HalDmWatchDog(
                goto skip_dm;
 
        bFwCurrentInPSMode = Adapter->pwrctrlpriv.bFwCurrentInPSMode;
-       rtw23a_hal_get_hwreg(Adapter, HW_VAR_FWLPS_RF_ON, (u8 *)(&bFwPSAwake));
-
-#ifdef CONFIG_8723AU_P2P
-       /*  Fw is under p2p powersaving mode, driver should stop dynamic mechanism. */
-       /*  modifed by thomas. 2011.06.11. */
-       if (Adapter->wdinfo.p2p_ps_mode)
-               bFwPSAwake = false;
-#endif /* CONFIG_8723AU_P2P */
+       bFwPSAwake = rtl8723a_get_fwlps_rf_on(Adapter);
 
        if ((hw_init_completed) && ((!bFwCurrentInPSMode) && bFwPSAwake)) {
                /*  Calculate Tx/Rx statistics. */
index 0982b0a4ab9b37791ddcbe810330963ec836f5f1..ee05bc00655a8cdbffd3a10e423b92de723ce53b 100644 (file)
@@ -619,6 +619,7 @@ hal_ReadEFuse_WiFi(struct rtw_adapter *padapter,
        u8 offset, wden;
        u8 efuseHeader, efuseExtHdr, efuseData;
        u16 i, total, used;
+       struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
 
        /*  Do NOT excess total size of EFuse table.
            Added by Roger, 2008.11.10. */
@@ -696,7 +697,7 @@ hal_ReadEFuse_WiFi(struct rtw_adapter *padapter,
        EFUSE_GetEfuseDefinition23a(padapter, EFUSE_WIFI,
                                 TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, &total);
        used = eFuse_Addr - 1;
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_EFUSE_BYTES, (u8 *)&used);
+       pHalData->EfuseUsedBytes = used;
 
        kfree(efuseTbl);
 }
@@ -711,6 +712,7 @@ hal_ReadEFuse_BT(struct rtw_adapter *padapter,
        u8 efuseHeader, efuseExtHdr, efuseData;
        u8 offset, wden;
        u16 i, total, used;
+       struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
 
        /*  Do NOT excess total size of EFuse table.
            Added by Roger, 2008.11.10. */
@@ -812,7 +814,7 @@ hal_ReadEFuse_BT(struct rtw_adapter *padapter,
        EFUSE_GetEfuseDefinition23a(padapter, EFUSE_BT,
                                 TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, &total);
        used = (EFUSE_BT_REAL_BANK_CONTENT_LEN * (bank - 1)) + eFuse_Addr - 1;
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_EFUSE_BT_BYTES, (u8 *) &used);
+       pHalData->BTEfuseUsedBytes = used;
 
 exit:
        kfree(efuseTbl);
@@ -834,8 +836,9 @@ hal_EfuseGetCurrentSize_WiFi(struct rtw_adapter *padapter)
        u16 efuse_addr = 0;
        u8 hoffset = 0, hworden = 0;
        u8 efuse_data, word_cnts = 0;
+       struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
 
-       rtw23a_hal_get_hwreg(padapter, HW_VAR_EFUSE_BYTES, (u8 *) &efuse_addr);
+       efuse_addr = pHalData->EfuseUsedBytes;
 
        DBG_8723A("%s: start_efuse_addr = 0x%X\n", __func__, efuse_addr);
 
@@ -872,7 +875,7 @@ hal_EfuseGetCurrentSize_WiFi(struct rtw_adapter *padapter)
                efuse_addr += (word_cnts * 2) + 1;
        }
 
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_EFUSE_BYTES, (u8 *) &efuse_addr);
+       pHalData->EfuseUsedBytes = efuse_addr;
 
        DBG_8723A("%s: CurrentSize =%d\n", __func__, efuse_addr);
 
@@ -888,8 +891,9 @@ hal_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter)
        u8 hoffset = 0, hworden = 0;
        u8 efuse_data, word_cnts = 0;
        u16 retU2 = 0;
+       struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
 
-       rtw23a_hal_get_hwreg(padapter, HW_VAR_EFUSE_BT_BYTES, (u8 *) &btusedbytes);
+       btusedbytes = pHalData->BTEfuseUsedBytes;
 
        efuse_addr = (u16) ((btusedbytes % EFUSE_BT_REAL_BANK_CONTENT_LEN));
        startBank = (u8) (1 + (btusedbytes / EFUSE_BT_REAL_BANK_CONTENT_LEN));
@@ -954,7 +958,7 @@ hal_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter)
        }
 
        retU2 = ((bank - 1) * EFUSE_BT_REAL_BANK_CONTENT_LEN) + efuse_addr;
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_EFUSE_BT_BYTES, (u8 *)&retU2);
+       pHalData->BTEfuseUsedBytes = retU2;
 
        DBG_8723A("%s: CurrentSize =%d\n", __func__, retU2);
        return retU2;
@@ -1144,6 +1148,7 @@ static u8
 hal_EfusePartialWriteCheck(struct rtw_adapter *padapter, u8 efuseType,
                           u16 *pAddr, struct pg_pkt_struct *pTargetPkt)
 {
+       struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
        u8 bRet = false;
        u16 startAddr = 0, efuse_max_available_len = 0, efuse_max = 0;
        u8 efuse_data = 0;
@@ -1154,13 +1159,11 @@ hal_EfusePartialWriteCheck(struct rtw_adapter *padapter, u8 efuseType,
        EFUSE_GetEfuseDefinition23a(padapter, efuseType,
                                 TYPE_EFUSE_CONTENT_LEN_BANK, &efuse_max);
 
-       if (efuseType == EFUSE_WIFI) {
-               rtw23a_hal_get_hwreg(padapter, HW_VAR_EFUSE_BYTES,
-                                 (u8 *) &startAddr);
-       } else {
-               rtw23a_hal_get_hwreg(padapter, HW_VAR_EFUSE_BT_BYTES,
-                                 (u8 *) &startAddr);
-       }
+       if (efuseType == EFUSE_WIFI)
+               startAddr = pHalData->EfuseUsedBytes;
+       else
+               startAddr = pHalData->BTEfuseUsedBytes;
+
        startAddr %= efuse_max;
 
        while (1) {
@@ -1735,11 +1738,7 @@ void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc)
                &rtl8723a_SetBeaconRelatedRegisters;
 
        pHalFunc->Add_RateATid = &rtl8723a_add_rateatid;
-       pHalFunc->run_thread = &rtl8723a_start_thread;
-       pHalFunc->cancel_thread = &rtl8723a_stop_thread;
 
-       pHalFunc->read_bbreg = &PHY_QueryBBReg;
-       pHalFunc->write_bbreg = &PHY_SetBBReg;
        pHalFunc->read_rfreg = &PHY_QueryRFReg;
        pHalFunc->write_rfreg = &PHY_SetRFReg;
 
@@ -2041,7 +2040,6 @@ static void _ResetDigitalProcedure1_92C(struct rtw_adapter *padapter,
                    are trying to enter IPS/HW&SW radio off. For
                    S3/S4/S5/Disable, we can stop 8051 because */
                /*  we will init FW when power on again. */
-               /* if (!pDevice->RegUsbSS) */
                /*  If we want to SS mode, we can not reset 8051. */
                if (rtw_read8(padapter, REG_MCUFWDL) & BIT1) {
                        /* IF fw in RAM code, do reset */
@@ -2935,7 +2933,7 @@ void rtl8723a_fill_fake_txdesc(struct rtw_adapter *padapter, u8 *pDesc,
        rtl8723a_cal_txdesc_chksum(ptxdesc);
 }
 
-static void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode)
+void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode)
 {
        u8 val8;
 
@@ -2996,7 +2994,7 @@ static void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode)
        rtw_write8(padapter, MSR, val8);
 }
 
-static void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val)
+void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val)
 {
        u8 idx = 0;
        u32 reg_macid;
@@ -3007,7 +3005,7 @@ static void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val)
                rtw_write8(padapter, (reg_macid + idx), val[idx]);
 }
 
-static void hw_var_set_bssid(struct rtw_adapter *padapter, u8 *val)
+void hw_var_set_bssid(struct rtw_adapter *padapter, u8 *val)
 {
        u8 idx = 0;
        u32 reg_bssid;
@@ -3018,7 +3016,7 @@ static void hw_var_set_bssid(struct rtw_adapter *padapter, u8 *val)
                rtw_write8(padapter, (reg_bssid + idx), val[idx]);
 }
 
-static void hw_var_set_correct_tsf(struct rtw_adapter *padapter)
+void hw_var_set_correct_tsf(struct rtw_adapter *padapter)
 {
        u64 tsf;
        u32 reg_tsftr;
@@ -3028,8 +3026,8 @@ static void hw_var_set_correct_tsf(struct rtw_adapter *padapter)
        /* tsf = pmlmeext->TSFValue - ((u32)pmlmeext->TSFValue %
           (pmlmeinfo->bcn_interval*1024)) - 1024; us */
        tsf = pmlmeext->TSFValue -
-               rtw_modular6423a(pmlmeext->TSFValue,
-                             (pmlmeinfo->bcn_interval * 1024)) - 1024; /* us */
+               do_div(pmlmeext->TSFValue,
+                      (pmlmeinfo->bcn_interval * 1024)) - 1024;        /* us */
 
        if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) ||
            ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) {
@@ -3055,7 +3053,7 @@ static void hw_var_set_correct_tsf(struct rtw_adapter *padapter)
                ResumeTxBeacon(padapter);
 }
 
-static void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter)
+void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter)
 {
        /*  reject all data frames */
        rtw_write16(padapter, REG_RXFLTMAP2, 0);
@@ -3067,7 +3065,7 @@ static void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter)
        SetBcnCtrlReg23a(padapter, DIS_TSF_UDT, 0);
 }
 
-static void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type)
+void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type)
 {
        u8 RetryLimit = 0x30;
 
@@ -3129,264 +3127,6 @@ static void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type)
 #endif
 }
 
-void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val)
-{
-       struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
-       u32 *val32 = (u32 *)val;
-
-       switch (variable) {
-       case HW_VAR_MEDIA_STATUS:
-               rtl8723a_set_media_status(padapter, *val);
-               break;
-
-       case HW_VAR_MEDIA_STATUS1:
-               rtl8723a_set_media_status1(padapter, *val);
-               break;
-
-       case HW_VAR_SET_OPMODE:
-               hw_var_set_opmode(padapter, *val);
-               break;
-
-       case HW_VAR_MAC_ADDR:
-               hw_var_set_macaddr(padapter, val);
-               break;
-
-       case HW_VAR_BSSID:
-               hw_var_set_bssid(padapter, val);
-               break;
-
-       case HW_VAR_BASIC_RATE:
-               HalSetBrateCfg23a(padapter, val);
-               break;
-
-       case HW_VAR_TXPAUSE:
-               rtl8723a_set_tx_pause(padapter, *val);
-               break;
-
-       case HW_VAR_BCN_FUNC:
-               rtl8723a_set_bcn_func(padapter, *val);
-               break;
-
-       case HW_VAR_CORRECT_TSF:
-               hw_var_set_correct_tsf(padapter);
-               break;
-
-       case HW_VAR_CHECK_BSSID:
-               rtl8723a_check_bssid(padapter, *val);
-               break;
-
-       case HW_VAR_MLME_DISCONNECT:
-               hw_var_set_mlme_disconnect(padapter);
-               break;
-
-       case HW_VAR_MLME_SITESURVEY:
-               rtl8723a_mlme_sitesurvey(padapter, *val);
-               break;
-
-       case HW_VAR_MLME_JOIN:
-               hw_var_set_mlme_join(padapter, *val);
-               break;
-
-       case HW_VAR_ON_RCR_AM:
-               rtl8723a_on_rcr_am(padapter);
-               break;
-
-       case HW_VAR_OFF_RCR_AM:
-               rtl8723a_off_rcr_am(padapter);
-               break;
-
-       case HW_VAR_BEACON_INTERVAL:
-               rtl8723a_set_beacon_interval(padapter, *((u16 *) val));
-               break;
-
-       case HW_VAR_SLOT_TIME:
-               rtl8723a_set_slot_time(padapter, *val);
-               break;
-
-       case HW_VAR_RESP_SIFS:
-               rtl8723a_set_resp_sifs(padapter, val[0], val[1],
-                                      val[2], val[3]);
-               break;
-
-       case HW_VAR_ACK_PREAMBLE:
-               rtl8723a_ack_preamble(padapter, *val);
-               break;
-
-       case HW_VAR_SEC_CFG:
-               rtl8723a_set_sec_cfg(padapter, *val);
-               break;
-
-       case HW_VAR_DM_FLAG:
-               rtl8723a_odm_support_ability_write(padapter, *val32);
-               break;
-       case HW_VAR_DM_FUNC_OP:
-               rtl8723a_odm_support_ability_backup(padapter, *val);
-               break;
-       case HW_VAR_DM_FUNC_SET:
-               rtl8723a_odm_support_ability_set(padapter, *val32);
-               break;
-
-       case HW_VAR_DM_FUNC_CLR:
-               rtl8723a_odm_support_ability_clr(padapter, *val32);
-               break;
-
-       case HW_VAR_CAM_EMPTY_ENTRY:
-               rtl8723a_cam_empty_entry(padapter, *val);
-               break;
-
-       case HW_VAR_CAM_INVALID_ALL:
-               rtl8723a_cam_invalid_all(padapter);
-               break;
-
-       case HW_VAR_CAM_WRITE:
-               rtl8723a_cam_write(padapter, val32[0], val32[1]);
-               break;
-
-       case HW_VAR_AC_PARAM_VO:
-               rtl8723a_set_ac_param_vo(padapter, *val32);
-               break;
-
-       case HW_VAR_AC_PARAM_VI:
-               rtl8723a_set_ac_param_vi(padapter, *val32);
-               break;
-
-       case HW_VAR_AC_PARAM_BE:
-               rtl8723a_set_ac_param_be(padapter, *val32);
-               break;
-
-       case HW_VAR_AC_PARAM_BK:
-               rtl8723a_set_ac_param_bk(padapter, *val32);
-               break;
-
-       case HW_VAR_ACM_CTRL:
-               rtl8723a_set_acm_ctrl(padapter, *val);
-               break;
-
-       case HW_VAR_AMPDU_MIN_SPACE:
-               rtl8723a_set_ampdu_min_space(padapter, *val);
-               break;
-
-       case HW_VAR_AMPDU_FACTOR:
-               rtl8723a_set_ampdu_factor(padapter, *val);
-               break;
-
-       case HW_VAR_RXDMA_AGG_PG_TH:
-               rtl8723a_set_rxdma_agg_pg_th(padapter, *val);
-               break;
-
-       case HW_VAR_H2C_FW_PWRMODE:
-               rtl8723a_set_FwPwrMode_cmd(padapter, *val);
-               break;
-
-       case HW_VAR_H2C_FW_JOINBSSRPT:
-               rtl8723a_set_FwJoinBssReport_cmd(padapter, *val);
-               break;
-
-#ifdef CONFIG_8723AU_P2P
-       case HW_VAR_H2C_FW_P2P_PS_OFFLOAD:
-               rtl8723a_set_p2p_ps_offload_cmd(padapter, *val);
-               break;
-#endif /* CONFIG_8723AU_P2P */
-
-       case HW_VAR_INITIAL_GAIN:
-               rtl8723a_set_initial_gain(padapter, *val32);
-               break;
-       case HW_VAR_EFUSE_BYTES:
-               pHalData->EfuseUsedBytes = *((u16 *) val);
-               break;
-       case HW_VAR_EFUSE_BT_BYTES:
-               pHalData->BTEfuseUsedBytes = *((u16 *) val);
-               break;
-       case HW_VAR_FIFO_CLEARN_UP:
-               rtl8723a_fifo_cleanup(padapter);
-               break;
-       case HW_VAR_CHECK_TXBUF:
-               break;
-       case HW_VAR_APFM_ON_MAC:
-               rtl8723a_set_apfm_on_mac(padapter, *val);
-               break;
-
-       case HW_VAR_NAV_UPPER:
-               rtl8723a_set_nav_upper(padapter, *val32);
-               break;
-       case HW_VAR_BCN_VALID:
-               rtl8723a_bcn_valid(padapter);
-               break;
-       default:
-               break;
-       }
-
-}
-
-void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val)
-{
-       struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
-
-       switch (variable) {
-       case HW_VAR_BASIC_RATE:
-               *((u16 *) val) = pHalData->BasicRateSet;
-               break;
-
-       case HW_VAR_TXPAUSE:
-               *val = rtw_read8(padapter, REG_TXPAUSE);
-               break;
-
-       case HW_VAR_BCN_VALID:
-               /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2 */
-               val[0] = (BIT0 & rtw_read8(padapter, REG_TDECTRL + 2)) ? true :
-                       false;
-               break;
-
-       case HW_VAR_RF_TYPE:
-               *val = pHalData->rf_type;
-               break;
-
-       case HW_VAR_DM_FLAG:
-       {
-               struct dm_odm_t *podmpriv = &pHalData->odmpriv;
-               *((u32 *) val) = podmpriv->SupportAbility;
-       }
-               break;
-
-       case HW_VAR_FWLPS_RF_ON:
-       {
-               /*  When we halt NIC, we should check if FW LPS is leave. */
-               u32 valRCR;
-
-               if ((padapter->bSurpriseRemoved == true) ||
-                   (padapter->pwrctrlpriv.rf_pwrstate == rf_off)) {
-                       /*  If it is in HW/SW Radio OFF or IPS state, we do
-                           not check Fw LPS Leave, because Fw is unload. */
-                       *val = true;
-               } else {
-                       valRCR = rtw_read32(padapter, REG_RCR);
-                       valRCR &= 0x00070000;
-                       if (valRCR)
-                               *val = false;
-                       else
-                               *val = true;
-               }
-       }
-               break;
-       case HW_VAR_EFUSE_BYTES:
-               *((u16 *) val) = pHalData->EfuseUsedBytes;
-               break;
-
-       case HW_VAR_EFUSE_BT_BYTES:
-               *((u16 *) val) = pHalData->BTEfuseUsedBytes;
-               break;
-
-       case HW_VAR_APFM_ON_MAC:
-               *val = pHalData->bMacPwrCtrlOn;
-               break;
-       case HW_VAR_CHK_HI_QUEUE_EMPTY:
-               *val =
-                   ((rtw_read32(padapter, REG_HGQ_INFORMATION) & 0x0000ff00) ==
-                    0) ? true : false;
-               break;
-       }
-}
-
 #ifdef CONFIG_8723AU_BT_COEXIST
 
 void rtl8723a_SingleDualAntennaDetection(struct rtw_adapter *padapter)
@@ -3442,11 +3182,3 @@ void rtl8723a_clone_haldata(struct rtw_adapter *dst_adapter,
        memcpy(dst_adapter->HalData, src_adapter->HalData,
               dst_adapter->hal_data_sz);
 }
-
-void rtl8723a_start_thread(struct rtw_adapter *padapter)
-{
-}
-
-void rtl8723a_stop_thread(struct rtw_adapter *padapter)
-{
-}
index 213d1936109d019e0b6f9c936f4ec8b3509625dd..1b5b83619c89ef6b0ab1d2481971eef40c36bcaf 100644 (file)
@@ -19,7 +19,6 @@
 #include <mlme_osdep.h>
 #include <linux/ip.h>
 #include <linux/if_ether.h>
-#include <ethernet.h>
 #include <usb_ops.h>
 #include <wifi.h>
 #include <rtl8723a_hal.h>
@@ -66,8 +65,8 @@ int rtl8723au_init_recv_priv(struct rtw_adapter *padapter)
        for (i = 0; i < NR_RECVBUFF; i++) {
                INIT_LIST_HEAD(&precvbuf->list);
 
-               res = rtw_os_recvbuf_resource_alloc23a(padapter, precvbuf);
-               if (res == _FAIL)
+               precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL);
+               if (!precvbuf->purb)
                        break;
 
                precvbuf->adapter = padapter;
@@ -110,7 +109,11 @@ void rtl8723au_free_recv_priv(struct rtw_adapter *padapter)
        precvbuf = (struct recv_buf *)precvpriv->precv_buf;
 
        for (i = 0; i < NR_RECVBUFF; i++) {
-               rtw_os_recvbuf_resource_free23a(padapter, precvbuf);
+               usb_free_urb(precvbuf->purb);
+
+               if (precvbuf->pskb)
+                       dev_kfree_skb_any(precvbuf->pskb);
+
                precvbuf++;
        }
 
@@ -132,11 +135,20 @@ void rtl8723au_free_recv_priv(struct rtw_adapter *padapter)
        skb_queue_purge(&precvpriv->free_recv_skb_queue);
 }
 
+struct recv_stat_cpu {
+       u32 rxdw0;
+       u32 rxdw1;
+       u32 rxdw2;
+       u32 rxdw3;
+       u32 rxdw4;
+       u32 rxdw5;
+};
+
 void update_recvframe_attrib(struct recv_frame *precvframe,
                             struct recv_stat *prxstat)
 {
        struct rx_pkt_attrib *pattrib;
-       struct recv_stat report;
+       struct recv_stat_cpu report;
        struct rxreport_8723a *prxreport;
 
        report.rxdw0 = le32_to_cpu(prxstat->rxdw0);
index e206829d50fa370ff4eb773ad3cdc1ff5284c4b7..20c11353a6106b197eb16a8a8c74ef6695506b75 100644 (file)
@@ -621,7 +621,6 @@ static u32 rtl8723au_hal_init(struct rtw_adapter *Adapter)
        struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
        struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv;
        struct registry_priv *pregistrypriv = &Adapter->registrypriv;
-       u32 NavUpper = WiFiNavUpperUs;
 
        unsigned long init_start_time = jiffies;
 
@@ -779,7 +778,7 @@ static u32 rtl8723au_hal_init(struct rtw_adapter *Adapter)
        _InitDriverInfoSize(Adapter, DRVINFO_SZ);
 
        _InitInterrupt(Adapter);
-       hal_init_macaddr23a(Adapter);/* set mac_address */
+       hw_var_set_macaddr(Adapter, Adapter->eeprompriv.mac_addr);
        _InitNetworkType(Adapter);/* set msr */
        _InitWMACSetting(Adapter);
        _InitAdaptiveCtrl(Adapter);
@@ -888,7 +887,7 @@ static u32 rtl8723au_hal_init(struct rtw_adapter *Adapter)
        rtl8723a_InitHalDm(Adapter);
 
        HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC31);
-       rtw_hal_set_hwreg23a(Adapter, HW_VAR_NAV_UPPER, (u8 *)&NavUpper);
+       rtl8723a_set_nav_upper(Adapter, WiFiNavUpperUs);
 
        /*  2011/03/09 MH debug only, UMC-B cut pass 2500 S5 test, but we need to fin root cause. */
        if (((rtw_read32(Adapter, rFPGA0_RFMOD) & 0xFF000000) != 0x83000000)) {
@@ -1228,14 +1227,14 @@ static unsigned int rtl8723au_inirp_init(struct rtw_adapter *Adapter)
        u8 i;
        struct recv_buf *precvbuf;
        uint    status;
-       struct intf_hdl *pintfhdl = &Adapter->iopriv.intf;
+       struct _io_ops *io_ops = &Adapter->io_ops;
        struct recv_priv *precvpriv = &Adapter->recvpriv;
-       u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
+       u32 (*_read_port)(struct rtw_adapter *padapter, u32 addr, u32 cnt,
                          struct recv_buf *rbuf);
-       u32 (*_read_interrupt)(struct intf_hdl *pintfhdl, u32 addr);
+       u32 (*_read_interrupt)(struct rtw_adapter *padapter, u32 addr);
        struct hal_data_8723a   *pHalData = GET_HAL_DATA(Adapter);
 
-       _read_port = pintfhdl->io_ops._read_port;
+       _read_port = io_ops->_read_port;
 
        status = _SUCCESS;
 
@@ -1246,7 +1245,7 @@ static unsigned int rtl8723au_inirp_init(struct rtw_adapter *Adapter)
        /* issue Rx irp to receive data */
        precvbuf = (struct recv_buf *)precvpriv->precv_buf;
        for (i = 0; i < NR_RECVBUFF; i++) {
-               if (_read_port(pintfhdl, precvpriv->ff_hwaddr, 0, precvbuf) ==
+               if (_read_port(Adapter, precvpriv->ff_hwaddr, 0, precvbuf) ==
                    false) {
                        RT_TRACE(_module_hci_hal_init_c_, _drv_err_,
                                 ("usb_rx_init: usb_read_port error\n"));
@@ -1256,8 +1255,8 @@ static unsigned int rtl8723au_inirp_init(struct rtw_adapter *Adapter)
                precvbuf++;
                precvpriv->free_recv_buf_queue_cnt--;
        }
-       _read_interrupt = pintfhdl->io_ops._read_interrupt;
-       if (_read_interrupt(pintfhdl, RECV_INT_IN_ADDR) == false) {
+       _read_interrupt = io_ops->_read_interrupt;
+       if (_read_interrupt(Adapter, RECV_INT_IN_ADDR) == false) {
                RT_TRACE(_module_hci_hal_init_c_, _drv_err_,
                         ("usb_rx_init: usb_read_interrupt error\n"));
                status = _FAIL;
@@ -1497,52 +1496,6 @@ static void ReadAdapterInfo8723AU(struct rtw_adapter *Adapter)
        _ReadAdapterInfo8723AU(Adapter);
 }
 
-#define GPIO_DEBUG_PORT_NUM 0
-static void rtl8723au_trigger_gpio_0(struct rtw_adapter *padapter)
-{
-       u32 gpioctrl;
-       DBG_8723A("==> trigger_gpio_0...\n");
-       rtw_write16_async(padapter, REG_GPIO_PIN_CTRL, 0);
-       rtw_write8_async(padapter, REG_GPIO_PIN_CTRL+2, 0xFF);
-       gpioctrl = (BIT(GPIO_DEBUG_PORT_NUM) << 24)|
-               (BIT(GPIO_DEBUG_PORT_NUM) << 16);
-       rtw_write32_async(padapter, REG_GPIO_PIN_CTRL, gpioctrl);
-       gpioctrl |= (BIT(GPIO_DEBUG_PORT_NUM)<<8);
-       rtw_write32_async(padapter, REG_GPIO_PIN_CTRL, gpioctrl);
-       DBG_8723A("<=== trigger_gpio_0...\n");
-}
-
-/*
- * If variable not handled here,
- * some variables will be processed in SetHwReg8723A()
- */
-static void SetHwReg8723AU(struct rtw_adapter *Adapter, u8 variable, u8 *val)
-{
-       switch (variable) {
-       case HW_VAR_RXDMA_AGG_PG_TH:
-               break;
-       case HW_VAR_SET_RPWM:
-               rtl8723a_set_rpwm(Adapter, *val);
-               break;
-       case HW_VAR_TRIGGER_GPIO_0:
-               rtl8723au_trigger_gpio_0(Adapter);
-               break;
-       default:
-               SetHwReg8723A(Adapter, variable, val);
-               break;
-       }
-
-}
-
-/*
- * If variable not handled here,
- * some variables will be processed in GetHwReg8723A()
- */
-static void GetHwReg8723AU(struct rtw_adapter *Adapter, u8 variable, u8 *val)
-{
-       GetHwReg8723A(Adapter, variable, val);
-}
-
 /*  */
 /*     Description: */
 /*             Query setting of specified variable. */
@@ -1786,12 +1739,6 @@ static void rtl8723au_init_default_value(struct rtw_adapter *padapter)
        rtl8723a_init_default_value(padapter);
 }
 
-static u8 rtl8192cu_ps_func(struct rtw_adapter *Adapter,
-                           enum hal_intf_ps_func efunc_id, u8 *val)
-{
-       return true;
-}
-
 int rtl8723au_set_hal_ops(struct rtw_adapter *padapter)
 {
        struct hal_ops  *pHalFunc = &padapter->HalFunc;
@@ -1820,15 +1767,12 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter)
        pHalFunc->init_default_value = &rtl8723au_init_default_value;
        pHalFunc->intf_chip_configure = &rtl8723au_interface_configure;
        pHalFunc->read_adapter_info = &ReadAdapterInfo8723AU;
-       pHalFunc->SetHwRegHandler = &SetHwReg8723AU;
-       pHalFunc->GetHwRegHandler = &GetHwReg8723AU;
        pHalFunc->GetHalDefVarHandler = &GetHalDefVar8192CUsb;
        pHalFunc->SetHalDefVarHandler = &SetHalDefVar8192CUsb;
        pHalFunc->UpdateRAMaskHandler = &UpdateHalRAMask8192CUsb;
        pHalFunc->hal_xmit = &rtl8723au_hal_xmit;
        pHalFunc->mgnt_xmit = &rtl8723au_mgnt_xmit;
        pHalFunc->hal_xmitframe_enqueue = &rtl8723au_hal_xmitframe_enqueue;
-       pHalFunc->interface_ps_func = &rtl8192cu_ps_func;
        rtl8723a_set_hal_ops(pHalFunc);
        return 0;
 }
index 0311cdf77ff1b854eaf1123144a508aa407af006..12997a5cd7a8e6fef70bf508776ea5afd865dbb4 100644 (file)
 #include <rtl8723a_hal.h>
 #include <rtl8723a_recv.h>
 
-static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype)
+static int usbctrl_vendorreq(struct rtw_adapter *padapter, u8 request,
+                            u16 value, u16 index, void *pdata, u16 len,
+                            u8 requesttype)
 {
-       struct rtw_adapter              *padapter = pintfhdl->padapter ;
        struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter);
        struct usb_device *udev = pdvobjpriv->pusbdev;
 
@@ -124,7 +125,7 @@ exit:
        return status;
 }
 
-static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr)
+static u8 usb_read8(struct rtw_adapter *padapter, u32 addr)
 {
        u8 request;
        u8 requesttype;
@@ -140,12 +141,13 @@ static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr)
        wvalue = (u16)(addr&0x0000ffff);
        len = 1;
 
-       usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype);
+       usbctrl_vendorreq(padapter, request, wvalue, index, &data,
+                         len, requesttype);
 
        return data;
 }
 
-static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr)
+static u16 usb_read16(struct rtw_adapter *padapter, u32 addr)
 {
        u8 request;
        u8 requesttype;
@@ -161,12 +163,13 @@ static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr)
        wvalue = (u16)(addr&0x0000ffff);
        len = 2;
 
-       usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype);
+       usbctrl_vendorreq(padapter, request, wvalue, index, &data,
+                         len, requesttype);
 
        return data;
 }
 
-static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr)
+static u32 usb_read32(struct rtw_adapter *padapter, u32 addr)
 {
        u8 request;
        u8 requesttype;
@@ -182,12 +185,13 @@ static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr)
        wvalue = (u16)(addr&0x0000ffff);
        len = 4;
 
-       usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype);
+       usbctrl_vendorreq(padapter, request, wvalue, index, &data,
+                         len, requesttype);
 
        return data;
 }
 
-static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val)
+static int usb_write8(struct rtw_adapter *padapter, u32 addr, u8 val)
 {
        u8 request;
        u8 requesttype;
@@ -206,12 +210,13 @@ static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val)
 
        data = val;
 
-       ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype);
+       ret = usbctrl_vendorreq(padapter, request, wvalue, index, &data,
+                               len, requesttype);
 
        return ret;
 }
 
-static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val)
+static int usb_write16(struct rtw_adapter *padapter, u32 addr, u16 val)
 {
        u8 request;
        u8 requesttype;
@@ -230,11 +235,12 @@ static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val)
 
        data = val;
 
-       ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype);
+       ret = usbctrl_vendorreq(padapter, request, wvalue, index, &data,
+                               len, requesttype);
        return ret;
 }
 
-static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val)
+static int usb_write32(struct rtw_adapter *padapter, u32 addr, u32 val)
 {
        u8 request;
        u8 requesttype;
@@ -252,12 +258,14 @@ static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val)
        len = 4;
        data = val;
 
-       ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype);
+       ret = usbctrl_vendorreq(padapter, request, wvalue, index, &data,
+                               len, requesttype);
 
        return ret;
 }
 
-static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata)
+static int usb_writeN(struct rtw_adapter *padapter,
+                     u32 addr, u32 length, u8 *pdata)
 {
        u8 request;
        u8 requesttype;
@@ -273,9 +281,10 @@ static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata
 
        wvalue = (u16)(addr&0x0000ffff);
        len = length;
-        memcpy(buf, pdata, len);
+       memcpy(buf, pdata, len);
 
-       ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, buf, len, requesttype);
+       ret = usbctrl_vendorreq(padapter, request, wvalue, index, buf,
+                               len, requesttype);
 
        return ret;
 }
@@ -423,12 +432,11 @@ urb_submit:
        }
 }
 
-static u32 usb_read_interrupt(struct intf_hdl *pintfhdl, u32 addr)
+static u32 usb_read_interrupt(struct rtw_adapter *adapter, u32 addr)
 {
        int err;
        unsigned int pipe;
        u32 ret = _SUCCESS;
-       struct rtw_adapter *adapter = pintfhdl->padapter;
        struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter);
        struct recv_priv *precvpriv = &adapter->recvpriv;
        struct usb_device *pusbd = pdvobj->pusbdev;
@@ -720,7 +728,7 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs)
        }
 }
 
-static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
+static u32 usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt,
                         struct recv_buf *precvbuf)
 {
        int err;
@@ -729,7 +737,6 @@ static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
        unsigned long alignment = 0;
        u32 ret = _SUCCESS;
        struct urb *purb = NULL;
-       struct rtw_adapter              *adapter = pintfhdl->padapter;
        struct dvobj_priv       *pdvobj = adapter_to_dvobj(adapter);
        struct recv_priv        *precvpriv = &adapter->recvpriv;
        struct usb_device       *pusbd = pdvobj->pusbdev;
@@ -815,8 +822,9 @@ void rtl8723au_xmit_tasklet(void *priv)
        }
 }
 
-void rtl8723au_set_intf_ops(struct _io_ops *pops)
+void rtl8723au_set_intf_ops(struct rtw_adapter *padapter)
 {
+       struct _io_ops *pops = &padapter->io_ops;
 
        memset((u8 *)pops, 0, sizeof(struct _io_ops));
 
diff --git a/drivers/staging/rtl8723au/include/cmd_osdep.h b/drivers/staging/rtl8723au/include/cmd_osdep.h
deleted file mode 100644 (file)
index 4866bee..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/******************************************************************************
- *
- * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- ******************************************************************************/
-#ifndef __CMD_OSDEP_H_
-#define __CMD_OSDEP_H_
-
-#include <osdep_service.h>
-#include <drv_types.h>
-
-int _rtw_init_evt_priv23a(struct evt_priv *pevtpriv);
-void _rtw_free_evt_priv23a(struct      evt_priv *pevtpriv);
-void _rtw_free_cmd_priv23a(struct      cmd_priv *pcmdpriv);
-int _rtw_enqueue_cmd23a(struct rtw_queue *queue, struct cmd_obj *obj);
-
-#endif
index 53eecea48ceca3053fa76d9aa9aa81f5d88f35ba..bec8fd7126d1bf82fa34cde59607a944ffc342e7 100644 (file)
@@ -55,26 +55,10 @@ enum _NIC_VERSION {
 #include <rtw_event.h>
 #include <rtw_led.h>
 #include <rtw_mlme_ext.h>
-#include <rtw_p2p.h>
 #include <rtw_ap.h>
 
 #include "ioctl_cfg80211.h"
 
-#define SPEC_DEV_ID_NONE BIT(0)
-#define SPEC_DEV_ID_DISABLE_HT BIT(1)
-#define SPEC_DEV_ID_ENABLE_PS BIT(2)
-#define SPEC_DEV_ID_RF_CONFIG_1T1R BIT(3)
-#define SPEC_DEV_ID_RF_CONFIG_2T2R BIT(4)
-#define SPEC_DEV_ID_ASSIGN_IFNAME BIT(5)
-
-struct specific_device_id {
-       u32             flags;
-
-       u16             idVendor;
-       u16             idProduct;
-
-};
-
 struct registry_priv {
        u8      chip_version;
        u8      rfintfs;
@@ -187,8 +171,6 @@ struct dvobj_priv {
        int     RtOutPipe[3];
        u8      Queue2Pipe[HW_QUEUE_ENTRY];/* for out pipe mapping */
 
-       u8      irq_alloc;
-
 /*-------- below is for USB INTERFACE --------*/
 
        u8      nr_endpoint;
@@ -197,8 +179,6 @@ struct dvobj_priv {
        u8      RtNumOutPipes;
        int     ep_num[5]; /* endpoint number */
 
-       int     RegUsbSS;
-
        struct semaphore usb_suspend_sema;
 
        struct mutex  usb_vendor_req_mutex;
@@ -243,8 +223,7 @@ struct rtw_adapter {
        struct  mlme_ext_priv mlmeextpriv;
        struct  cmd_priv        cmdpriv;
        struct  evt_priv        evtpriv;
-       /* struct       io_queue        *pio_queue; */
-       struct  io_priv iopriv;
+       struct _io_ops  io_ops;
        struct  xmit_priv       xmitpriv;
        struct  recv_priv       recvpriv;
        struct  sta_priv        stapriv;
@@ -258,13 +237,7 @@ struct rtw_adapter {
        struct  hostapd_priv    *phostapdpriv;
 #endif
 
-       struct cfg80211_wifidirect_info cfg80211_wdinfo;
        u32     setband;
-       struct wifidirect_info  wdinfo;
-
-#ifdef CONFIG_8723AU_P2P
-       struct wifi_display_info wfd_info;
-#endif /* CONFIG_8723AU_P2P */
 
        void *HalData;
        u32 hal_data_sz;
@@ -283,28 +256,14 @@ struct rtw_adapter {
        u8      init_adpt_in_progress;
        u8      bHaltInProgress;
 
-       void *cmdThread;
-       void *evtThread;
-       void *xmitThread;
-       void *recvThread;
-
        void (*intf_start)(struct rtw_adapter *adapter);
        void (*intf_stop)(struct rtw_adapter *adapter);
 
        struct net_device *pnetdev;
 
        /*  used by rtw_rereg_nd_name related function */
-       struct rereg_nd_name_data {
-               struct net_device *old_pnetdev;
-               char old_ifname[IFNAMSIZ];
-               u8 old_ips_mode;
-               u8 old_bRegUseLed;
-       } rereg_nd_name_priv;
-
        int bup;
        struct net_device_stats stats;
-       struct iw_statistics iwstats;
-       struct proc_dir_entry *dir_dev;/*  for proc directory */
 
        struct wireless_dev *rtw_wdev;
        int net_closed;
@@ -313,39 +272,14 @@ struct rtw_adapter {
        u8 bBTFWReady;
        u8 bReadPortCancel;
        u8 bWritePortCancel;
-       u8 bRxRSSIDisplay;
        /* The driver will show the desired chan nor when this flag is 1. */
        u8 bNotifyChannelChange;
-#ifdef CONFIG_8723AU_P2P
-       /* driver will show current P2P status when the  application reads it*/
-       u8 bShowGetP2PState;
-#endif
        struct rtw_adapter *pbuddy_adapter;
 
        /* extend to support multi interface */
        /* IFACE_ID0 is equals to PRIMARY_ADAPTER */
        /* IFACE_ID1 is equals to SECONDARY_ADAPTER */
        u8 iface_id;
-
-#ifdef CONFIG_BR_EXT
-       _lock                                   br_ext_lock;
-       /* unsigned int                 macclone_completed; */
-       struct nat25_network_db_entry   *nethash[NAT25_HASH_SIZE];
-       int                             pppoe_connection_in_progress;
-       unsigned char                   pppoe_addr[MACADDRLEN];
-       unsigned char                   scdb_mac[MACADDRLEN];
-       unsigned char                   scdb_ip[4];
-       struct nat25_network_db_entry   *scdb_entry;
-       unsigned char                   br_mac[MACADDRLEN];
-       unsigned char                   br_ip[4];
-
-       struct br_ext_info              ethBrExtInfo;
-#endif /*  CONFIG_BR_EXT */
-
-       u8    fix_rate;
-
-       unsigned char     in_cta_test;
-
 };
 
 #define adapter_to_dvobj(adapter) (adapter->dvobj)
diff --git a/drivers/staging/rtl8723au/include/ethernet.h b/drivers/staging/rtl8723au/include/ethernet.h
deleted file mode 100644 (file)
index 39fc6df..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/******************************************************************************
- *
- * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- *
- ******************************************************************************/
-/*! \file */
-#ifndef __INC_ETHERNET_H
-#define __INC_ETHERNET_H
-
-#define LLC_HEADER_SIZE                        6       /*  LLC Header Length */
-
-#endif /*  #ifndef __INC_ETHERNET_H */
index 20f983cfc2b7a7b16e5b38d1d65d765270e364cb..4a161e26c8dc5c82690d51795dc3d7d7b9c3f441 100644 (file)
@@ -165,8 +165,6 @@ void HalSetBrateCfg23a(struct rtw_adapter *padapter, u8 *mBratesOS);
 bool
 Hal_MappingOutPipe23a(struct rtw_adapter *pAdapter, u8 NumOutPipe);
 
-void hal_init_macaddr23a(struct rtw_adapter *adapter);
-
 void c2h_evt_clear23a(struct rtw_adapter *adapter);
 s32 c2h_evt_read23a(struct rtw_adapter *adapter, u8 *buf);
 
@@ -185,11 +183,12 @@ void rtl8723a_ack_preamble(struct rtw_adapter *padapter, u8 bShortPreamble);
 void rtl8723a_set_sec_cfg(struct rtw_adapter *padapter, u8 sec);
 void rtl8723a_cam_empty_entry(struct rtw_adapter *padapter, u8 ucIndex);
 void rtl8723a_cam_invalid_all(struct rtw_adapter *padapter);
-void rtl8723a_cam_write(struct rtw_adapter *padapter, u32 val1, u32 val2);
+void rtl8723a_cam_write(struct rtw_adapter *padapter,
+                       u8 entry, u16 ctrl, const u8 *mac, const u8 *key);
 void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter);
 void rtl8723a_set_apfm_on_mac(struct rtw_adapter *padapter, u8 val);
 void rtl8723a_bcn_valid(struct rtw_adapter *padapter);
-void rtl8723a_set_tx_pause(struct rtw_adapter *padapter, u8 pause);
+bool rtl8723a_get_bcn_valid(struct rtw_adapter *padapter);
 void rtl8723a_set_beacon_interval(struct rtw_adapter *padapter, u16 interval);
 void rtl8723a_set_resp_sifs(struct rtw_adapter *padapter,
                            u8 r2t1, u8 r2t2, u8 t2t1, u8 t2t2);
@@ -202,10 +201,14 @@ void rtl8723a_set_nav_upper(struct rtw_adapter *padapter, u32 usNavUpper);
 void rtl8723a_set_initial_gain(struct rtw_adapter *padapter, u32 rx_gain);
 
 void rtl8723a_odm_support_ability_write(struct rtw_adapter *padapter, u32 val);
-void rtl8723a_odm_support_ability_backup(struct rtw_adapter *padapter, u8 val);
+void rtl8723a_odm_support_ability_backup(struct rtw_adapter *padapter);
+void rtl8723a_odm_support_ability_restore(struct rtw_adapter *padapter);
 void rtl8723a_odm_support_ability_set(struct rtw_adapter *padapter, u32 val);
 void rtl8723a_odm_support_ability_clr(struct rtw_adapter *padapter, u32 val);
 
 void rtl8723a_set_rpwm(struct rtw_adapter *padapter, u8 val);
+u8 rtl8723a_get_rf_type(struct rtw_adapter *padapter);
+bool rtl8723a_get_fwlps_rf_on(struct rtw_adapter *padapter);
+bool rtl8723a_chk_hi_queue_empty(struct rtw_adapter *padapter);
 
 #endif /* __HAL_COMMON_H__ */
index d183f4ba1ecb295cc62992bc251c39fa5559cadc..52b33fe61b3fef240d9473c2aa2e19ba3973c4a2 100644 (file)
@@ -35,78 +35,6 @@ enum _CHIP_TYPE {
        MAX_CHIP_TYPE
 };
 
-enum HW_VARIABLES {
-       HW_VAR_MEDIA_STATUS,
-       HW_VAR_MEDIA_STATUS1,
-       HW_VAR_SET_OPMODE,
-       HW_VAR_MAC_ADDR,
-       HW_VAR_BSSID,
-       HW_VAR_INIT_RTS_RATE,
-       HW_VAR_BASIC_RATE,
-       HW_VAR_TXPAUSE,
-       HW_VAR_BCN_FUNC,
-       HW_VAR_CORRECT_TSF,
-       HW_VAR_CHECK_BSSID,
-       HW_VAR_MLME_DISCONNECT,
-       HW_VAR_MLME_SITESURVEY,
-       HW_VAR_MLME_JOIN,
-       HW_VAR_ON_RCR_AM,
-       HW_VAR_OFF_RCR_AM,
-       HW_VAR_BEACON_INTERVAL,
-       HW_VAR_SLOT_TIME,
-       HW_VAR_RESP_SIFS,
-       HW_VAR_ACK_PREAMBLE,
-       HW_VAR_SEC_CFG,
-       HW_VAR_BCN_VALID,
-       HW_VAR_RF_TYPE,
-       HW_VAR_DM_FLAG,
-       HW_VAR_DM_FUNC_OP,
-       HW_VAR_DM_FUNC_SET,
-       HW_VAR_DM_FUNC_CLR,
-       HW_VAR_CAM_EMPTY_ENTRY,
-       HW_VAR_CAM_INVALID_ALL,
-       HW_VAR_CAM_WRITE,
-       HW_VAR_CAM_READ,
-       HW_VAR_AC_PARAM_VO,
-       HW_VAR_AC_PARAM_VI,
-       HW_VAR_AC_PARAM_BE,
-       HW_VAR_AC_PARAM_BK,
-       HW_VAR_ACM_CTRL,
-       HW_VAR_AMPDU_MIN_SPACE,
-       HW_VAR_AMPDU_FACTOR,
-       HW_VAR_RXDMA_AGG_PG_TH,
-       HW_VAR_SET_RPWM,
-       HW_VAR_H2C_FW_PWRMODE,
-       HW_VAR_H2C_FW_JOINBSSRPT,
-       HW_VAR_FWLPS_RF_ON,
-       HW_VAR_H2C_FW_P2P_PS_OFFLOAD,
-       HW_VAR_TDLS_WRCR,
-       HW_VAR_TDLS_INIT_CH_SEN,
-       HW_VAR_TDLS_RS_RCR,
-       HW_VAR_TDLS_DONE_CH_SEN,
-       HW_VAR_INITIAL_GAIN,
-       HW_VAR_TRIGGER_GPIO_0,
-       HW_VAR_BT_SET_COEXIST,
-       HW_VAR_BT_ISSUE_DELBA,
-       HW_VAR_CURRENT_ANTENNA,
-       HW_VAR_ANTENNA_DIVERSITY_LINK,
-       HW_VAR_ANTENNA_DIVERSITY_SELECT,
-       HW_VAR_SWITCH_EPHY_WoWLAN,
-       HW_VAR_EFUSE_BYTES,
-       HW_VAR_EFUSE_BT_BYTES,
-       HW_VAR_FIFO_CLEARN_UP,
-       HW_VAR_CHECK_TXBUF,
-       HW_VAR_APFM_ON_MAC, /* Auto FSM to Turn On, include clock, isolation, power control for MAC only */
-       /*  The valid upper nav range for the HW updating, if the true value is larger than the upper range, the HW won't update it. */
-       /*  Unit in microsecond. 0 means disable this function. */
-       HW_VAR_NAV_UPPER,
-       HW_VAR_RPT_TIMER_SETTING,
-       HW_VAR_TX_RPT_MAX_MACID,
-       HW_VAR_H2C_MEDIA_STATUS_RPT,
-       HW_VAR_CHK_HI_QUEUE_EMPTY,
-       HW_VAR_READ_LLT_TAB,
-};
-
 enum hal_def_variable {
        HAL_DEF_UNDERCORATEDSMOOTHEDPWDB,
        HAL_DEF_IS_SUPPORT_ANT_DIV,
@@ -132,11 +60,6 @@ enum hal_odm_variable {
        HAL_ODM_WIFI_DISPLAY_STATE,
 };
 
-enum hal_intf_ps_func {
-       HAL_USB_SELECT_SUSPEND,
-       HAL_MAX_ID,
-};
-
 struct hal_ops {
        u32 (*hal_power_on)(struct rtw_adapter *padapter);
        u32 (*hal_init)(struct rtw_adapter *padapter);
@@ -175,11 +98,6 @@ struct hal_ops {
 
        void (*hal_dm_watchdog)(struct rtw_adapter *padapter);
 
-       void (*SetHwRegHandler)(struct rtw_adapter *padapter,
-                               u8 variable, u8 *val);
-       void (*GetHwRegHandler)(struct rtw_adapter *padapter,
-                               u8 variable, u8 *val);
-
        u8 (*GetHalDefVarHandler)(struct rtw_adapter *padapter,
                                  enum hal_def_variable eVariable,
                                  void *pValue);
@@ -200,11 +118,6 @@ struct hal_ops {
 
        void (*Add_RateATid)(struct rtw_adapter *padapter, u32 bitmap,
                             u8 arg, u8 rssi_level);
-       void (*run_thread)(struct rtw_adapter *padapter);
-       void (*cancel_thread)(struct rtw_adapter *padapter);
-
-       u8 (*interface_ps_func)(struct rtw_adapter *padapter,
-                               enum hal_intf_ps_func efunc_id, u8 *val);
 
        s32 (*hal_xmit)(struct rtw_adapter *padapter,
                        struct xmit_frame *pxmitframe);
@@ -213,10 +126,6 @@ struct hal_ops {
        s32 (*hal_xmitframe_enqueue)(struct rtw_adapter *padapter,
                                     struct xmit_frame *pxmitframe);
 
-       u32 (*read_bbreg)(struct rtw_adapter *padapter, u32 RegAddr,
-                         u32 BitMask);
-       void (*write_bbreg)(struct rtw_adapter *padapter, u32 RegAddr,
-                           u32 BitMask, u32 Data);
        u32 (*read_rfreg)(struct rtw_adapter *padapter, u32 eRFPath,
                          u32 RegAddr, u32 BitMask);
        void (*write_rfreg)(struct rtw_adapter *padapter, u32 eRFPath,
@@ -291,11 +200,6 @@ enum hardware_type {
 };
 
 #define GET_EEPROM_EFUSE_PRIV(adapter) (&adapter->eeprompriv)
-#define is_boot_from_eeprom(adapter) (adapter->eeprompriv.EepromOrEfuse)
-
-extern int rtw_ht_enable23A;
-extern int rtw_cbw40_enable23A;
-extern int rtw_ampdu_enable23A;/* for enable tx_ampdu */
 
 void rtw_hal_def_value_init23a(struct rtw_adapter *padapter);
 int pm_netdev_open23a(struct net_device *pnetdev, u8 bnormal);
@@ -312,8 +216,6 @@ u32 rtw_hal_power_on23a(struct rtw_adapter *padapter);
 uint rtw_hal_init23a(struct rtw_adapter *padapter);
 uint rtw_hal_deinit23a(struct rtw_adapter *padapter);
 void rtw_hal_stop(struct rtw_adapter *padapter);
-void rtw_hal_set_hwreg23a(struct rtw_adapter *padapter, u8 variable, u8 *val);
-void rtw23a_hal_get_hwreg(struct rtw_adapter *padapter, u8 variable, u8 *val);
 
 void rtw_hal_chip_configure23a(struct rtw_adapter *padapter);
 void rtw_hal_read_chip_info23a(struct rtw_adapter *padapter);
@@ -339,9 +241,6 @@ void rtw_hal_disable_interrupt23a(struct rtw_adapter *padapter);
 u32 rtw_hal_inirp_init23a(struct rtw_adapter *padapter);
 u32 rtw_hal_inirp_deinit23a(struct rtw_adapter *padapter);
 
-u8 rtw_hal_intf_ps_func23a(struct rtw_adapter *padapter,
-                          enum hal_intf_ps_func efunc_id, u8 *val);
-
 s32 rtw_hal_xmit23aframe_enqueue(struct rtw_adapter *padapter,
                                 struct xmit_frame *pxmitframe);
 s32 rtw_hal_xmit23a(struct rtw_adapter *padapter,
@@ -358,13 +257,9 @@ void       rtw_hal_free_recv_priv23a(struct rtw_adapter *padapter);
 void rtw_hal_update_ra_mask23a(struct sta_info *psta, u8 rssi_level);
 void   rtw_hal_add_ra_tid23a(struct rtw_adapter *padapter, u32 bitmap, u8 arg, u8 rssi_level);
 void   rtw_hal_clone_data(struct rtw_adapter *dst_padapter, struct rtw_adapter *src_padapter);
-void   rtw_hal_start_thread23a(struct rtw_adapter *padapter);
-void   rtw_hal_stop_thread23a(struct rtw_adapter *padapter);
 
 void rtw_hal_bcn_related_reg_setting23a(struct rtw_adapter *padapter);
 
-u32    rtw_hal_read_bbreg23a(struct rtw_adapter *padapter, u32 RegAddr, u32 BitMask);
-void   rtw_hal_write_bbreg23a(struct rtw_adapter *padapter, u32 RegAddr, u32 BitMask, u32 Data);
 u32    rtw_hal_read_rfreg23a(struct rtw_adapter *padapter, u32 eRFPath, u32 RegAddr, u32 BitMask);
 void   rtw_hal_write_rfreg23a(struct rtw_adapter *padapter, u32 eRFPath, u32 RegAddr, u32 BitMask, u32 Data);
 
@@ -388,5 +283,11 @@ void rtw_hal_reset_security_engine23a(struct rtw_adapter *adapter);
 
 s32 rtw_hal_c2h_handler23a(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt);
 c2h_id_filter rtw_hal_c2h_id_filter_ccx23a(struct rtw_adapter *adapter);
+void hw_var_set_correct_tsf(struct rtw_adapter *padapter);
+void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter);
+void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode);
+void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val);
+void hw_var_set_bssid(struct rtw_adapter *padapter, u8 *val);
+void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type);
 
 #endif /* __HAL_INTF_H__ */
index 28e4ab239fb963ad98a5a005949ae62bf6b6301b..76875f651d822655c8ebafe7972d26209e35b4dc 100644 (file)
@@ -298,53 +298,6 @@ struct ieee80211_snap_hdr {
 #define WEP_KEY_LEN 13
 
 
-
-/*
-
- 802.11 data frame from AP
-
-      ,-------------------------------------------------------------------.
-Bytes |  2   |  2   |    6    |    6    |    6    |  2   | 0..2312 |   4  |
-      |------|------|---------|---------|---------|------|---------|------|
-Desc. | ctrl | dura |  DA/RA  |   TA    |    SA   | Sequ |  frame  |  fcs |
-      |      | tion | (BSSID) |         |         | ence |  data   |      |
-      `-------------------------------------------------------------------'
-
-Total: 28-2340 bytes
-
-*/
-
-struct ieee80211_header_data {
-       u16 frame_ctl;
-       u16 duration_id;
-       u8 addr1[6];
-       u8 addr2[6];
-       u8 addr3[6];
-       u16 seq_ctrl;
-};
-
-struct ieee80211_info_element_hdr {
-       u8 id;
-       u8 len;
-} __attribute__ ((packed));
-
-struct ieee80211_info_element {
-       u8 id;
-       u8 len;
-       u8 data[0];
-} __attribute__ ((packed));
-
-
-struct ieee80211_txb {
-       u8 nr_frags;
-       u8 encrypted;
-       u16 reserved;
-       u16 frag_size;
-       u16 payload_size;
-       struct sk_buff *fragments[0];
-};
-
-
 /* MAX_RATES_LENGTH needs to be 12.  The spec says 8, and many APs
  * only use 8, and then use extended rates for the remaining supported
  * rates.  Other APs, however, stick all of their supported rates on the
@@ -382,9 +335,6 @@ join_res:
 #define IEEE_G            (1<<2)
 #define IEEE_MODE_MASK    (IEEE_A|IEEE_B|IEEE_G)
 
-/* Baron move to ieee80211.c */
-int ieee80211_is_empty_essid23a(const char *essid, int essid_len);
-
 enum _PUBLIC_ACTION{
        ACT_PUBLIC_BSSCOEXIST = 0, /*  20/40 BSS Coexistence */
        ACT_PUBLIC_DSE_ENABLE = 1,
@@ -457,68 +407,8 @@ struct rtw_ieee80211_channel {
        /*, (channel)->orig_mag*/ \
        /*, (channel)->orig_mpwr*/ \
 
-/* Parsed Information Elements */
-struct rtw_ieee802_11_elems {
-       u8 *ssid;
-       u8 ssid_len;
-       u8 *supp_rates;
-       u8 supp_rates_len;
-       u8 *fh_params;
-       u8 fh_params_len;
-       u8 *ds_params;
-       u8 ds_params_len;
-       u8 *cf_params;
-       u8 cf_params_len;
-       u8 *tim;
-       u8 tim_len;
-       u8 *ibss_params;
-       u8 ibss_params_len;
-       u8 *challenge;
-       u8 challenge_len;
-       u8 *erp_info;
-       u8 erp_info_len;
-       u8 *ext_supp_rates;
-       u8 ext_supp_rates_len;
-       u8 *wpa_ie;
-       u8 wpa_ie_len;
-       u8 *rsn_ie;
-       u8 rsn_ie_len;
-       u8 *wme;
-       u8 wme_len;
-       u8 *wme_tspec;
-       u8 wme_tspec_len;
-       u8 *wps_ie;
-       u8 wps_ie_len;
-       u8 *power_cap;
-       u8 power_cap_len;
-       u8 *supp_channels;
-       u8 supp_channels_len;
-       u8 *mdie;
-       u8 mdie_len;
-       u8 *ftie;
-       u8 ftie_len;
-       u8 *timeout_int;
-       u8 timeout_int_len;
-       u8 *ht_capabilities;
-       u8 ht_capabilities_len;
-       u8 *ht_operation;
-       u8 ht_operation_len;
-       u8 *vendor_ht_cap;
-       u8 vendor_ht_cap_len;
-};
-
-enum parse_res {
-       ParseOK = 0,
-       ParseUnknown = 1,
-       ParseFailed = -1
-};
-
-enum parse_res rtw_ieee802_11_parse_elems23a(u8 *start, uint len,
-                               struct rtw_ieee802_11_elems *elems,
-                               int show_errors);
-
 u8 *rtw_set_fixed_ie23a(unsigned char *pbuf, unsigned int len, unsigned char *source, unsigned int *frlen);
-u8 *rtw_set_ie23a(u8 *pbuf, int index, uint len, u8 *source, uint *frlen);
+u8 *rtw_set_ie23a(u8 *pbuf, int index, uint len, const u8 *source, uint *frlen);
 
 enum secondary_ch_offset {
        SCN = 0, /* no secondary channel */
@@ -537,12 +427,10 @@ int rtw_ies_remove_ie23a(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u
 
 void rtw_set_supported_rate23a(u8* SupportedRates, uint mode) ;
 
-unsigned char *rtw_get_wpa_ie23a(unsigned char *pie, int *wpa_ie_len, int limit);
-unsigned char *rtw_get_wpa2_ie23a(unsigned char *pie, int *rsn_ie_len, int limit);
-int rtw_get_wpa_cipher_suite23a(u8 *s);
-int rtw_get_wpa2_cipher_suite23a(u8 *s);
-int rtw_parse_wpa_ie23a(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
-int rtw_parse_wpa2_ie23a(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
+int rtw_get_wpa_cipher_suite23a(const u8 *s);
+int rtw_get_wpa2_cipher_suite23a(const u8 *s);
+int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
+int rtw_parse_wpa2_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
 
 int rtw_get_sec_ie23a(u8 *in_ie,uint in_len,u8 *rsn_ie,u16 *rsn_len,u8 *wpa_ie,u16 *wpa_len);
 
@@ -551,32 +439,6 @@ u8 *rtw_get_wps_ie23a(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
 u8 *rtw_get_wps_attr23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_attr, u32 *len_attr);
 u8 *rtw_get_wps_attr_content23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_content, uint *len_content);
 
-/**
- * for_each_ie - iterate over continuous IEs
- * @ie:
- * @buf:
- * @buf_len:
- */
-#define for_each_ie(ie, buf, buf_len) \
-       for (ie = (void*)buf; (((u8*)ie) - ((u8*)buf) + 1) < buf_len; ie = (void*)(((u8*)ie) + *(((u8*)ie)+1) + 2))
-
-void dump_ies23a(u8 *buf, u32 buf_len);
-void dump_wps_ie23a(u8 *ie, u32 ie_len);
-
-#ifdef CONFIG_8723AU_P2P
-void dump_p2p_ie23a(u8 *ie, u32 ie_len);
-u8 *rtw_get_p2p_ie23a(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen);
-u8 *rtw_get_p2p_attr23a(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id ,u8 *buf_attr, u32 *len_attr);
-u8 *rtw_get_p2p_attr23a_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id ,u8 *buf_content, uint *len_content);
-u32 rtw_set_p2p_attr_content23a(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_attr);
-void rtw_wlan_bssid_ex_remove_p2p_attr23a(struct wlan_bssid_ex *bss_ex, u8 attr_id);
-#endif
-
-#ifdef CONFIG_8723AU_P2P
-int rtw_get_wfd_ie(u8 *in_ie, int in_len, u8 *wfd_ie, uint *wfd_ielen);
-int rtw_get_wfd_attr_content(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id ,u8 *attr_content, uint *attr_contentlen);
-#endif /*  CONFIG_8723AU_P2P */
-
 uint   rtw_get_rateset_len23a(u8       *rateset);
 
 struct registry_priv;
index b7132a9a13783f039a3460d236e23cb9e772718b..4bb5525b7a6823c4237ea49b506ef8b078614c24 100644 (file)
 #include <drv_types.h>
 
 void rtw_os_indicate_disconnect23a(struct rtw_adapter *adapter);
-void rtw_os_indicate_connect23a(struct rtw_adapter *adapter);
-void rtw_os_indicate_scan_done23a(struct rtw_adapter *padapter, bool aborted);
-void rtw_report_sec_ie23a(struct rtw_adapter *adapter, u8 authmode, u8 *sec_ie);
-
 void rtw_reset_securitypriv23a(struct rtw_adapter *adapter);
 
 #endif /* _MLME_OSDEP_H_ */
index b603cf532900af391e9d2b7987cf8c035c6c3531..d3e22635e9ea2d9842181fc0b0387e7be26408c4 100644 (file)
@@ -26,8 +26,6 @@ u8 rtw_init_drv_sw23a(struct rtw_adapter *padapter);
 u8 rtw_free_drv_sw23a(struct rtw_adapter *padapter);
 u8 rtw_reset_drv_sw23a(struct rtw_adapter *padapter);
 
-u32 rtw_start_drv_threads23a(struct rtw_adapter *padapter);
-void rtw_stop_drv_threads23a (struct rtw_adapter *padapter);
 void rtw_cancel_all_timer23a(struct rtw_adapter *padapter);
 
 int rtw_init_netdev23a_name23a(struct net_device *pnetdev, const char *ifname);
index 039bc7285ed010c62e93c285cccec6ddd8df50e3..40445bbafe771f9dbedc849f76297f749e862cd7 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/kref.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
-#include <linux/circ_buf.h>
 #include <asm/uaccess.h>
 #include <asm/byteorder.h>
 #include <asm/atomic.h>
@@ -40,7 +39,6 @@
 #include <linux/sched.h>
 #include <linux/etherdevice.h>
 #include <linux/wireless.h>
-#include <net/iw_handler.h>
 #include <linux/if_arp.h>
 #include <linux/rtnetlink.h>
 #include <linux/delay.h>
@@ -139,7 +137,6 @@ void        _rtw_vmfree(u8 *pbuf, u32 sz);
 
 extern unsigned char REALTEK_96B_IE23A[];
 extern unsigned char MCS_rate_2R23A[16];
-extern unsigned char RTW_WPA_OUI23A[];
 extern unsigned char WPA_TKIP_CIPHER23A[4];
 extern unsigned char RSN_TKIP_CIPHER23A[4];
 
@@ -149,16 +146,6 @@ extern unsigned char       MCS_rate_1R23A[16];
 void   _rtw_init_queue23a(struct rtw_queue *pqueue);
 u32    _rtw_queue_empty23a(struct rtw_queue *pqueue);
 
-static inline u32 bitshift(u32 bitmask)
-{
-       u32 i;
-
-       for (i = 0; i <= 31; i++)
-               if (((bitmask>>i) &  0x1) == 1) break;
-
-       return i;
-}
-
 void rtw_suspend_lock_init(void);
 void rtw_suspend_lock_uninit(void);
 void rtw_lock_suspend(void);
@@ -174,12 +161,6 @@ void rtw_unlock_suspend(void);
 #define FUNC_ADPT_FMT "%s(%s)"
 #define FUNC_ADPT_ARG(adapter) __func__, adapter->pnetdev->name
 
-#define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)),(sig), 1)
-
-u64 rtw_modular6423a(u64 x, u64 y);
-u64 rtw_division6423a(u64 x, u64 y);
-
-
 /* Macros for handling unaligned memory accesses */
 
 #define RTW_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \
@@ -199,9 +180,7 @@ bool rtw_cbuf_push23a(struct rtw_cbuf *cbuf, void *buf);
 void *rtw_cbuf_pop23a(struct rtw_cbuf *cbuf);
 struct rtw_cbuf *rtw_cbuf_alloc23a(u32 size);
 void rtw_cbuf_free(struct rtw_cbuf *cbuf);
-int rtw_change_ifname(struct rtw_adapter *padapter, const char *ifname);
 s32 c2h_evt_hdl(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter);
-void indicate_wx_scan_complete_event(struct rtw_adapter *padapter);
 u8 rtw_do_join23a(struct rtw_adapter *padapter);
 
 #endif
index 15c94b6168bfeb1904d782b57a65e19a0282d47f..c2d3f1bd594827eb4fbb4d2787e76a79d9261c18 100644 (file)
@@ -23,22 +23,13 @@ void _rtw_free_recv_priv23a (struct recv_priv *precvpriv);
 
 int rtw_recv_entry23a(struct recv_frame *precv_frame);
 int rtw_recv_indicatepkt23a(struct rtw_adapter *adapter, struct recv_frame *precv_frame);
-void rtw_recv_returnpacket(struct net_device *cnxt, struct sk_buff *preturnedpkt);
 
-void rtw_hostapd_mlme_rx23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
 void rtw_handle_tkip_mic_err23a(struct rtw_adapter *padapter, u8 bgroup);
 
 int    rtw_init_recv_priv(struct recv_priv *precvpriv, struct rtw_adapter *padapter);
 void rtw_free_recv_priv (struct recv_priv *precvpriv);
 
 int rtw_os_recv_resource_init(struct recv_priv *precvpriv, struct rtw_adapter *padapter);
-int rtw_os_recv_resource_alloc23a(struct rtw_adapter *padapter, struct recv_frame *precvframe);
-void rtw_os_recv_resource_free(struct recv_priv *precvpriv);
-
-int rtw_os_recvbuf_resource_alloc23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf);
-int rtw_os_recvbuf_resource_free23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf);
-
-void rtw_os_read_port23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf);
 
 void rtw_init_recv_timer23a(struct recv_reorder_ctrl *preorder_ctrl);
 
index 8fccbfc3a45c65dd92873cb41f37b8899b800d93..09fa72340302582b3954f56be9a454fef146c447 100644 (file)
@@ -151,10 +151,6 @@ u8 rtl8723a_set_rssi_cmd(struct rtw_adapter * padapter, u8 *param);
 u8 rtl8723a_set_raid_cmd(struct rtw_adapter * padapter, u32 mask, u8 arg);
 void rtl8723a_add_rateatid(struct rtw_adapter * padapter, u32 bitmap, u8 arg, u8 rssi_level);
 
-#ifdef CONFIG_8723AU_P2P
-void rtl8723a_set_p2p_ps_offload_cmd(struct rtw_adapter * padapter, u8 p2p_ps_state);
-#endif /* CONFIG_8723AU_P2P */
-
 void CheckFwRsvdPageContent23a(struct rtw_adapter *padapter);
 
 #endif
index c20248bab717421a13ecc433f1a1894ab5b663de..f6b4b7c7c22dc983c77fbf7be59b676f77311777 100644 (file)
@@ -424,11 +424,6 @@ struct hal_data_8723a {
 
        bool                            bMACFuncEnable;
 
-#ifdef CONFIG_8723AU_P2P
-       struct P2P_PS_Offload_t p2p_ps_offload;
-#endif
-
-
        /*  */
        /*  For USB Interface HAL related */
        /*  */
@@ -437,14 +432,6 @@ struct hal_data_8723a {
        /*  Interrupt related register information. */
        u32     IntArray[2];
        u32     IntrMask[2];
-
-       /*  */
-       /*  For SDIO Interface HAL related */
-       /*  */
-
-       /*  Auto FSM to Turn On, include clock, isolation, power control for MAC only */
-       u8                      bMacPwrCtrlOn;
-
 };
 
 #define GET_HAL_DATA(__pAdapter)       ((struct hal_data_8723a *)((__pAdapter)->HalData))
@@ -556,8 +543,6 @@ void Hal_EfuseParseThermalMeter_8723A(struct rtw_adapter *padapter, u8 *hwinfo,
 void Hal_InitChannelPlan23a(struct rtw_adapter *padapter);
 
 void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc);
-void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val);
-void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val);
 #ifdef CONFIG_8723AU_BT_COEXIST
 void rtl8723a_SingleDualAntennaDetection(struct rtw_adapter *padapter);
 #endif
index 76f82d68f633d2b205cf2360174a146d78a38e86..8d9be5a36eae760105bfd9c182935c03dca3a0dc 100644 (file)
@@ -22,8 +22,6 @@
 #ifdef CONFIG_8723AU_AP_MODE
 
 /* external function */
-void rtw_indicate_sta_assoc_event23a(struct rtw_adapter *padapter, struct sta_info *psta);
-void rtw_indicate_sta_disassoc_event23a(struct rtw_adapter *padapter, struct sta_info *psta);
 
 void init_mlme_ap_info23a(struct rtw_adapter *padapter);
 void free_mlme_ap_info23a(struct rtw_adapter *padapter);
@@ -34,7 +32,7 @@ void update_beacon23a(struct rtw_adapter *padapter, u8 ie_id, u8 *oui, u8 tx);
 void add_RATid23a(struct rtw_adapter *padapter, struct sta_info *psta, u8 rssi_level);
 void expire_timeout_chk23a(struct rtw_adapter *padapter);
 void update_sta_info23a_apmode23a(struct rtw_adapter *padapter, struct sta_info *psta);
-int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf,  int len);
+int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, unsigned int len);
 void rtw_ap_restore_network(struct rtw_adapter *padapter);
 void rtw_set_macaddr_acl23a(struct rtw_adapter *padapter, int mode);
 int rtw_acl_add_sta23a(struct rtw_adapter *padapter, u8 *addr);
index f9caa3e35f57d3288c07294747b173cb927f9794..3ecb971c6e3995d0b694ddf58e7178f72b15b12f 100644 (file)
@@ -25,8 +25,6 @@
 #include <ieee80211.h> /*  <ieee80211/ieee80211.h> */
 
 
-#define FREE_CMDOBJ_SZ 128
-
 #define MAX_CMDSZ      1024
 #define MAX_RSPSZ      512
 #define MAX_EVTSZ      1024
@@ -34,6 +32,7 @@
 #define CMDBUFF_ALIGN_SZ 512
 
 struct cmd_obj {
+       struct work_struct work;
        struct rtw_adapter *padapter;
        u16     cmdcode;
        u8      res;
@@ -41,16 +40,10 @@ struct cmd_obj {
        u32     cmdsz;
        u8      *rsp;
        u32     rspsz;
-       /* struct semaphore             cmd_sem; */
-       struct list_head        list;
 };
 
 struct cmd_priv {
-       struct semaphore        cmd_queue_sema;
-       /* struct semaphore     cmd_done_sema; */
-       struct semaphore        terminate_cmdthread_sema;
-       struct rtw_queue        cmd_queue;
-       u8      cmd_seq;
+       struct workqueue_struct *wq;
        u8      *cmd_buf;       /* shall be non-paged, and 4 bytes aligned */
        u8      *cmd_allocated_buf;
        u8      *rsp_buf;       /* shall be non-paged, and 4 bytes aligned */
@@ -58,7 +51,6 @@ struct cmd_priv {
        u32     cmd_issued_cnt;
        u32     cmd_done_cnt;
        u32     rsp_cnt;
-       u8 cmdthd_running;
        struct rtw_adapter *padapter;
 };
 
@@ -77,7 +69,6 @@ struct        evt_priv {
 
 #define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \
 do {\
-       INIT_LIST_HEAD(&pcmd->list);\
        pcmd->cmdcode = code;\
        pcmd->parmbuf = (u8 *)(pparm);\
        pcmd->cmdsz = sizeof (*pparm);\
@@ -94,7 +85,7 @@ struct c2h_evt_hdr {
 
 #define c2h_evt_exist(c2h_evt) ((c2h_evt)->id || (c2h_evt)->plen)
 
-u32 rtw_enqueue_cmd23a(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
+int rtw_enqueue_cmd23a(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
 void rtw_free_cmd_obj23a(struct cmd_obj *pcmd);
 
 int rtw_cmd_thread23a(void *context);
@@ -106,9 +97,6 @@ u32 rtw_init_evt_priv23a (struct evt_priv *pevtpriv);
 void rtw_free_evt_priv23a (struct evt_priv *pevtpriv);
 void rtw_cmd_clr_isr23a(struct cmd_priv *pcmdpriv);
 void rtw_evt_notify_isr(struct evt_priv *pevtpriv);
-#ifdef CONFIG_8723AU_P2P
-u8 p2p_protocol_wk_cmd23a(struct rtw_adapter*padapter, int intCmdType );
-#endif /* CONFIG_8723AU_P2P */
 
 enum rtw_drvextra_cmd_id
 {
@@ -731,7 +719,7 @@ u8 rtw_tdls_cmd(struct rtw_adapter*padapter, u8 *addr, u8 option);
 
 u8 rtw_c2h_wk_cmd23a(struct rtw_adapter *padapter, u8 *c2h_evt);
 
-u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf);
+u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
 
 void rtw_survey_cmd_callback23a(struct rtw_adapter  *padapter, struct cmd_obj *pcmd);
 void rtw_disassoc_cmd23a_callback(struct rtw_adapter  *padapter, struct cmd_obj *pcmd);
index 8d39d800267de17bcd5068736577d79e388a596c..fffe028750c20c066b4313558bf3c6fadc4df2b7 100644 (file)
 #define _INTF_ASYNC_   BIT(0)  /* support async io */
 
 struct intf_priv;
-struct intf_hdl;
-struct io_queue;
 
 struct _io_ops
 {
-               u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr);
-               u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr);
-               u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr);
+       u8 (*_read8)(struct rtw_adapter *adapter, u32 addr);
+       u16 (*_read16)(struct rtw_adapter *adapter, u32 addr);
+       u32 (*_read32)(struct rtw_adapter *adapter, u32 addr);
 
-               int (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
-               int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
-               int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
-               int (*_writeN)(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata);
+       int (*_write8)(struct rtw_adapter *adapter, u32 addr, u8 val);
+       int (*_write16)(struct rtw_adapter *adapter, u32 addr, u16 val);
+       int (*_write32)(struct rtw_adapter *adapter, u32 addr, u32 val);
+       int (*_writeN)(struct rtw_adapter *adapter, u32 addr, u32 length, u8 *pdata);
 
-               int (*_write8_async)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
-               int (*_write16_async)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
-               int (*_write32_async)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
+       void (*_read_mem)(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
+       void (*_write_mem)(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
 
-               void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
-               void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
+       u32 (*_read_interrupt)(struct rtw_adapter *adapter, u32 addr);
 
-               void (*_sync_irp_protocol_rw)(struct io_queue *pio_q);
-
-               u32 (*_read_interrupt)(struct intf_hdl *pintfhdl, u32 addr);
-
-               u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, struct recv_buf *rbuf);
-               u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, struct xmit_buf *pmem);
-
-               u32 (*_write_scsi)(struct intf_hdl *pintfhdl,u32 cnt, u8 *pmem);
-
-               void (*_read_port_cancel)(struct intf_hdl *pintfhdl);
-               void (*_write_port_cancel)(struct intf_hdl *pintfhdl);
+       u32 (*_read_port)(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct recv_buf *rbuf);
+       u32 (*_write_port)(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *pmem);
 
+       void (*_read_port_cancel)(struct rtw_adapter *adapter);
+       void (*_write_port_cancel)(struct rtw_adapter *adapter);
 };
 
 struct io_req {
@@ -145,14 +134,6 @@ struct io_req {
        u8 *cnxt;
 };
 
-struct intf_hdl {
-       struct rtw_adapter *padapter;
-       struct dvobj_priv *pintf_dev;/*         pointer to &(padapter->dvobjpriv); */
-
-       struct _io_ops  io_ops;
-
-};
-
 struct reg_protocol_rd {
 
 #ifdef __LITTLE_ENDIAN
@@ -266,40 +247,6 @@ struct reg_protocol_wt {
 };
 
 
-
-/*
-Below is the data structure used by _io_handler
-
-*/
-
-struct io_queue {
-       spinlock_t      lock;
-       struct list_head free_ioreqs;
-       struct list_head pending;               /* The io_req list that will be served in the single protocol read/write. */
-       struct list_head processing;
-       u8      *free_ioreqs_buf; /*  4-byte aligned */
-       u8      *pallocated_free_ioreqs_buf;
-       struct  intf_hdl        intf;
-};
-
-struct io_priv{
-
-       struct rtw_adapter *padapter;
-
-       struct intf_hdl intf;
-
-};
-
-uint ioreq_flush(struct rtw_adapter *adapter, struct io_queue *ioqueue);
-void sync_ioreq_enqueue(struct io_req *preq,struct io_queue *ioqueue);
-uint sync_ioreq_flush(struct rtw_adapter *adapter, struct io_queue *ioqueue);
-
-uint free_ioreq(struct io_req *preq, struct io_queue *pio_queue);
-struct io_req *alloc_ioreq(struct io_queue *pio_q);
-
-uint register_intf_hdl(u8 *dev, struct intf_hdl *pintfhdl);
-void unregister_intf_hdl(struct intf_hdl *pintfhdl);
-
 void _rtw_attrib_read(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
 void _rtw_attrib_write(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
 
@@ -315,13 +262,8 @@ int _rtw_write1623a(struct rtw_adapter *adapter, u32 addr, u16 val);
 int _rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val);
 int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr, u32 length, u8 *pdata);
 
-int _rtw_write823a_async23a(struct rtw_adapter *adapter, u32 addr, u8 val);
-int _rtw_write1623a_async(struct rtw_adapter *adapter, u32 addr, u16 val);
-int _rtw_write3223a_async23a(struct rtw_adapter *adapter, u32 addr, u32 val);
-
 void _rtw_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
 u32 _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *pmem);
-u32 _rtw_write_port23a_and_wait23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *pmem, int timeout_ms);
 void _rtw_write_port23a_cancel(struct rtw_adapter *adapter);
 
 #ifdef DBG_IO
@@ -349,13 +291,8 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da
 #define  rtw_write32(adapter, addr, val) dbg_rtw_write3223a((adapter), (addr), (val), __FUNCTION__, __LINE__)
 #define  rtw_writeN(adapter, addr, length, data) dbg_rtw_writeN23a((adapter), (addr), (length), (data), __FUNCTION__, __LINE__)
 
-#define rtw_write8_async(adapter, addr, val) _rtw_write823a_async23a((adapter), (addr), (val))
-#define rtw_write16_async(adapter, addr, val) _rtw_write1623a_async((adapter), (addr), (val))
-#define rtw_write32_async(adapter, addr, val) _rtw_write3223a_async23a((adapter), (addr), (val))
-
 #define rtw_write_mem(adapter, addr, cnt, mem) _rtw_write_mem23a((adapter), addr, cnt, mem)
 #define rtw_write_port(adapter, addr, cnt, mem) _rtw_write_port23a(adapter, addr, cnt, mem)
-#define rtw_write_port_and_wait(adapter, addr, cnt, mem, timeout_ms) _rtw_write_port23a_and_wait23a((adapter), (addr), (cnt), (mem), (timeout_ms))
 #define rtw_write_port_cancel(adapter) _rtw_write_port23a_cancel(adapter)
 #else /* DBG_IO */
 #define rtw_read8(adapter, addr) _rtw_read823a((adapter), (addr))
@@ -370,35 +307,11 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da
 #define  rtw_write32(adapter, addr, val) _rtw_write3223a((adapter), (addr), (val))
 #define  rtw_writeN(adapter, addr, length, data) _rtw_writeN23a((adapter), (addr), (length), (data))
 
-#define rtw_write8_async(adapter, addr, val) _rtw_write823a_async23a((adapter), (addr), (val))
-#define rtw_write16_async(adapter, addr, val) _rtw_write1623a_async((adapter), (addr), (val))
-#define rtw_write32_async(adapter, addr, val) _rtw_write3223a_async23a((adapter), (addr), (val))
-
 #define rtw_write_mem(adapter, addr, cnt, mem) _rtw_write_mem23a((adapter), (addr), (cnt), (mem))
 #define rtw_write_port(adapter, addr, cnt, mem) _rtw_write_port23a((adapter), (addr), (cnt), (mem))
-#define rtw_write_port_and_wait(adapter, addr, cnt, mem, timeout_ms) _rtw_write_port23a_and_wait23a((adapter), (addr), (cnt), (mem), (timeout_ms))
 #define rtw_write_port_cancel(adapter) _rtw_write_port23a_cancel((adapter))
 #endif /* DBG_IO */
 
-void rtw_write_scsi(struct rtw_adapter *adapter, u32 cnt, u8 *pmem);
-
-/* ioreq */
-void ioreq_read8(struct rtw_adapter *adapter, u32 addr, u8 *pval);
-void ioreq_read16(struct rtw_adapter *adapter, u32 addr, u16 *pval);
-void ioreq_read32(struct rtw_adapter *adapter, u32 addr, u32 *pval);
-void ioreq_write8(struct rtw_adapter *adapter, u32 addr, u8 val);
-void ioreq_write16(struct rtw_adapter *adapter, u32 addr, u16 val);
-void ioreq_write32(struct rtw_adapter *adapter, u32 addr, u32 val);
-
-int rtw_init_io_priv23a(struct rtw_adapter *padapter, void (*set_intf_ops)(struct _io_ops *pops));
-
-uint alloc_io_queue(struct rtw_adapter *adapter);
-void free_io_queue(struct rtw_adapter *adapter);
-void async_bus_io(struct io_queue *pio_q);
-void bus_sync_io(struct io_queue *pio_q);
-u32 _ioreq2rwmem(struct io_queue *pio_q);
-void dev_power_down(struct rtw_adapter * Adapter, u8 bpwrup);
-
 #define PlatformEFIOWrite1Byte(_a,_b,_c)               \
        rtw_write8(_a,_b,_c)
 #define PlatformEFIOWrite2Byte(_a,_b,_c)               \
index 31f96f39b498dcb6bb9fe9ea142d749e676b6e7b..38203f16aee8210c1aabc805fb748e5101254ad5 100644 (file)
@@ -148,30 +148,6 @@ struct tx_invite_resp_info {
        u8      token;  /*      Used to record the dialog token of p2p invitation request frame. */
 };
 
-#ifdef CONFIG_8723AU_P2P
-
-struct wifi_display_info {
-       u16     wfd_enable;             /* Enable/Disable the WFD function. */
-       u16     rtsp_ctrlport;          /* TCP port number at which the this WFD device listens for RTSP messages */
-       u16     peer_rtsp_ctrlport;     /* TCP port number at which the peer WFD device listens for RTSP messages */
-                                       /* This filed should be filled when receiving the gropu negotiation request */
-
-       u8      peer_session_avail;     /* WFD session is available or not for the peer wfd device. */
-                                       /* This variable will be set when sending the provisioning discovery request to peer WFD device. */
-                                       /* And this variable will be reset when it is read by using the iwpriv p2p_get wfd_sa command. */
-       u8      ip_address[4];
-       u8      peer_ip_address[4];
-       u8      wfd_pc;         /* WFD preferred connection */
-                               /* 0 -> Prefer to use the P2P for WFD connection on peer side. */
-                               /* 1 -> Prefer to use the TDLS for WFD connection on peer side. */
-
-       u8      wfd_device_type;/* WFD Device Type */
-                               /* 0 -> WFD Source Device */
-                               /* 1 -> WFD Primary Sink Device */
-       enum    SCAN_RESULT_TYPE scan_result_type;      /* Used when P2P is enable. This parameter will impact the scan result. */
-};
-#endif /* CONFIG_8723AU_P2P */
-
 struct tx_provdisc_req_info {
        u16     wps_config_method_request;      /* Used when sending the provisioning request frame */
        u16     peer_channel_num[2];            /* The channel number which the receiver stands. */
@@ -203,102 +179,6 @@ struct scan_limit_info {
        u8      operation_ch[2];        /* Store the operation channel of invitation request frame */
 };
 
-struct cfg80211_wifidirect_info {
-       struct timer_list               remain_on_ch_timer;
-       u8              restore_channel;
-       struct ieee80211_channel        remain_on_ch_channel;
-       enum nl80211_channel_type       remain_on_ch_type;
-       u64     remain_on_ch_cookie;
-       bool is_ro_ch;
-};
-
-struct wifidirect_info {
-       struct rtw_adapter      *padapter;
-       struct timer_list       find_phase_timer;
-       struct timer_list       restore_p2p_state_timer;
-
-       /*      Used to do the scanning. After confirming the peer is availalble, the driver transmits the P2P frame to peer. */
-       struct timer_list       pre_tx_scan_timer;
-       struct timer_list       reset_ch_sitesurvey;
-       struct timer_list       reset_ch_sitesurvey2;   /*      Just for resetting the scan limit function by using p2p nego */
-       struct tx_provdisc_req_info     tx_prov_disc_info;
-       struct rx_provdisc_req_info rx_prov_disc_info;
-       struct tx_invite_req_info       invitereq_info;
-       struct profile_info     profileinfo[P2P_MAX_PERSISTENT_GROUP_NUM];      /*      Store the profile information of persistent group */
-       struct tx_invite_resp_info      inviteresp_info;
-       struct tx_nego_req_info nego_req_info;
-       struct group_id_info    groupid_info;   /*      Store the group id information when doing the group negotiation handshake. */
-       struct scan_limit_info  rx_invitereq_info;      /*      Used for get the limit scan channel from the Invitation procedure */
-       struct scan_limit_info  p2p_info;               /*      Used for get the limit scan channel from the P2P negotiation handshake */
-#ifdef CONFIG_8723AU_P2P
-       struct wifi_display_info        *wfd_info;
-#endif
-       enum P2P_ROLE   role;
-       enum P2P_STATE  pre_p2p_state;
-       enum P2P_STATE  p2p_state;
-       u8      device_addr[ETH_ALEN];  /*      The device address should be the mac address of this device. */
-       u8      interface_addr[ETH_ALEN];
-       u8      social_chan[4];
-       u8      listen_channel;
-       u8      operating_channel;
-       u8      listen_dwell;           /*      This value should be between 1 and 3 */
-       u8      support_rate[8];
-       u8      p2p_wildcard_ssid[P2P_WILDCARD_SSID_LEN];
-       u8      intent;         /*      should only include the intent value. */
-       u8      p2p_peer_interface_addr[ETH_ALEN];
-       u8      p2p_peer_device_addr[ETH_ALEN];
-       u8      peer_intent;    /*      Included the intent value and tie breaker value. */
-       u8      device_name[WPS_MAX_DEVICE_NAME_LEN];   /*      Device name for displaying on searching device screen */
-       u8      device_name_len;
-       u8      profileindex;   /*      Used to point to the index of profileinfo array */
-       u8      peer_operating_ch;
-       u8      find_phase_state_exchange_cnt;
-       u16     device_password_id_for_nego;    /*      The device password ID for group negotation */
-       u8      negotiation_dialog_token;
-       /*      SSID information for group negotitation */
-       u8 nego_ssid[IEEE80211_MAX_SSID_LEN];
-       u8 nego_ssidlen;
-       u8 p2p_group_ssid[IEEE80211_MAX_SSID_LEN];
-       u8 p2p_group_ssid_len;
-       u8      persistent_supported;   /*      Flag to know the persistent function should be supported or not. */
-                                       /*      In the Sigma test, the Sigma will provide this enable from the sta_set_p2p CAPI. */
-                                       /*      0: disable */
-                                       /*      1: enable */
-       u8      session_available;      /*      Flag to set the WFD session available to enable or disable "by Sigma" */
-                                       /*      In the Sigma test, the Sigma will disable the session available by using the sta_preset CAPI. */
-                                       /*      0: disable */
-                                       /*      1: enable */
-
-       u8      wfd_tdls_enable;        /*      Flag to enable or disable the TDLS by WFD Sigma */
-                                       /*      0: disable */
-                                       /*      1: enable */
-       u8      wfd_tdls_weaksec;       /*      Flag to enable or disable the weak security function for TDLS by WFD Sigma */
-                               /*      0: disable */
-                               /*      In this case, the driver can't issue the tdsl setup request frame. */
-                               /*      1: enable */
-                               /*      In this case, the driver can issue the tdls setup request frame */
-                               /*      even the current security is weak security. */
-
-       enum    P2P_WPSINFO             ui_got_wps_info;                        /*      This field will store the WPS value (PIN value or PBC) that UI had got from the user. */
-       u16     supported_wps_cm;                       /*      This field describes the WPS config method which this driver supported. */
-                                                                                                               /*      The value should be the combination of config method defined in page104 of WPS v2.0 spec. */
-       uint    channel_list_attr_len;          /*      This field will contain the length of body of P2P Channel List attribute of group negotitation response frame. */
-       u8      channel_list_attr[100];         /*      This field will contain the body of P2P Channel List attribute of group negotitation response frame. */
-                                                                                                               /*      We will use the channel_cnt and channel_list fields when constructing the group negotitation confirm frame. */
-#ifdef CONFIG_8723AU_P2P
-       enum P2P_PS_MODE        p2p_ps_mode; /*  indicate p2p ps mode */
-       enum P2P_PS_STATE       p2p_ps_state; /*  indicate p2p ps state */
-       u8      noa_index; /*  Identifies and instance of Notice of Absence timing. */
-       u8      ctwindow; /*  Client traffic window. A period of time in TU after TBTT. */
-       u8      opp_ps; /*  opportunistic power save. */
-       u8      noa_num; /*  number of NoA descriptor in P2P IE. */
-       u8      noa_count[P2P_MAX_NOA_NUM]; /*  Count for owner, Type of client. */
-       u32     noa_duration[P2P_MAX_NOA_NUM]; /*  Max duration for owner, preferred or min acceptable duration for client. */
-       u32     noa_interval[P2P_MAX_NOA_NUM]; /*  Length of interval for owner, preferred or max acceptable interval of client. */
-       u32     noa_start_time[P2P_MAX_NOA_NUM]; /*  schedule expressed in terms of the lower 4 bytes of the TSF timer. */
-#endif /*  CONFIG_8723AU_P2P */
-};
-
 struct tdls_ss_record {        /* signal strength record */
        u8      macaddr[ETH_ALEN];
        u8      RxPWDBAll;
@@ -324,9 +204,6 @@ struct tdls_info {
        u8      watchdog_count;
        u8      dev_discovered;         /* WFD_TDLS: for sigma test */
        u8      enable;
-#ifdef CONFIG_8723AU_P2P
-       struct wifi_display_info                *wfd_info;
-#endif
 };
 
 struct mlme_priv {
@@ -468,7 +345,7 @@ void rtw_cpwm_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf);
 int event_thread(void *context);
 void rtw23a_join_to_handler(unsigned long);
 
-void rtw_free_network_queue23a(struct rtw_adapter *adapter, u8 isfreeall);
+void rtw_free_network_queue23a(struct rtw_adapter *adapter);
 int rtw_init_mlme_priv23a(struct rtw_adapter *adapter);
 
 void rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv);
@@ -553,7 +430,6 @@ void rtw_free_assoc_resources23a(struct rtw_adapter *adapter,
                              int lock_scanned_queue);
 void rtw_indicate_disconnect23a(struct rtw_adapter *adapter);
 void rtw_indicate_connect23a(struct rtw_adapter *adapter);
-void rtw_indicate_scan_done23a(struct rtw_adapter *padapter, bool aborted);
 void rtw_scan_abort23a(struct rtw_adapter *adapter);
 
 int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie,
@@ -574,30 +450,18 @@ void rtw_clear_scan_deny(struct rtw_adapter *adapter);
 void rtw_set_scan_deny_timer_hdl(unsigned long data);
 void rtw_set_scan_deny(struct rtw_adapter *adapter, u32 ms);
 
-int _rtw_init_mlme_priv23a(struct rtw_adapter *padapter);
-
 void rtw23a_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv);
 
 void _rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv);
 
 struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv);
 
-void _rtw_free_network23a(struct mlme_priv *pmlmepriv,
-                      struct wlan_network *pnetwork, u8 isfreeall);
-void _rtw_free_network23a_nolock23a(struct mlme_priv *pmlmepriv,
-                             struct wlan_network *pnetwork);
-
-struct wlan_network *_rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr);
-
-void _rtw_free_network23a_queue23a(struct rtw_adapter *padapter, u8 isfreeall);
-
 int rtw_if_up23a(struct rtw_adapter *padapter);
 
 int rtw_linked_check(struct rtw_adapter *padapter);
 
-u8 *rtw_get_capability23a_from_ie(u8 *ie);
-u8 *rtw_get_timestampe_from_ie23a(u8 *ie);
-u8 *rtw_get_beacon_interval23a_from_ie(u8 *ie);
+__le16 *rtw_get_capability23a_from_ie(u8 *ie);
+__le16 *rtw_get_beacon_interval23a_from_ie(u8 *ie);
 
 
 void rtw_joinbss_reset23a(struct rtw_adapter *padapter);
@@ -613,12 +477,8 @@ int rtw_is_same_ibss23a(struct rtw_adapter *adapter,
                     struct wlan_network *pnetwork);
 int is_same_network23a(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst);
 
-void _rtw23a_roaming(struct rtw_adapter *adapter,
-                 struct wlan_network *tgt_network);
 void rtw23a_roaming(struct rtw_adapter *adapter,
                 struct wlan_network *tgt_network);
 void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming);
-u8 rtw_to_roaming(struct rtw_adapter *adapter);
-void rtw_stassoc_hw_rpt23a(struct rtw_adapter *adapter, struct sta_info *psta);
 
 #endif /* __RTL871X_MLME_H_ */
index 0aaf0d5d8aeaa654fce8c193401c729344977db4..26d360178eac1265d282a163312bb00c7002bed4 100644 (file)
@@ -89,7 +89,6 @@
 #define                _54M_RATE_      11
 
 
-extern unsigned char RTW_WPA_OUI23A[];
 extern unsigned char WMM_OUI23A[];
 extern unsigned char WPS_OUI23A[];
 extern unsigned char WFD_OUI23A[];
@@ -262,13 +261,13 @@ enum SCAN_STATE {
 
 struct mlme_handler {
        char *str;
-       unsigned int (*func)(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+       int (*func)(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
 };
 
 struct action_handler {
        unsigned int   num;
        char* str;
-       unsigned int (*func)(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
+       int (*func)(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
 };
 
 struct ss_res
@@ -474,10 +473,6 @@ void get_rate_set23a(struct rtw_adapter *padapter, unsigned char *pbssrate,
 void UpdateBrateTbl23a(struct rtw_adapter *padapter,u8 *mBratesOS);
 void Update23aTblForSoftAP(u8 *bssrateset, u32 bssratelen);
 
-void Save_DM_Func_Flag23a(struct rtw_adapter *padapter);
-void Restore_DM_Func_Flag23a(struct rtw_adapter *padapter);
-void Switch_DM_Func23a(struct rtw_adapter *padapter, unsigned long mode, u8 enable);
-
 void Set_MSR23a(struct rtw_adapter *padapter, u8 type);
 
 u8 rtw_get_oper_ch23a(struct rtw_adapter *adapter);
@@ -495,12 +490,9 @@ void SetBWMode23a(struct rtw_adapter *padapter, unsigned short bwmode,
 
 unsigned int decide_wait_for_beacon_timeout23a(unsigned int bcn_interval);
 
-void write_cam23a(struct rtw_adapter *padapter, u8 entry, u16 ctrl,
-              u8 *mac, u8 *key);
 void clear_cam_entry23a(struct rtw_adapter *padapter, u8 entry);
 
 void invalidate_cam_all23a(struct rtw_adapter *padapter);
-void CAM_empty_entry23a(struct rtw_adapter *Adapter, u8 ucIndex);
 
 int allocate_fw_sta_entry23a(struct rtw_adapter *padapter);
 void flush_all_cam_entry23a(struct rtw_adapter *padapter);
@@ -526,10 +518,6 @@ unsigned char check_assoc_AP23a(u8 *pframe, uint len);
 
 int WMM_param_handler23a(struct rtw_adapter *padapter,
                      struct ndis_802_11_var_ies *pIE);
-#ifdef CONFIG_8723AU_P2P
-int WFD_info_handler(struct rtw_adapter *padapter,
-                    struct ndis_802_11_var_ies *pIE);
-#endif
 void WMMOnAssocRsp23a(struct rtw_adapter *padapter);
 
 void HT_caps_handler23a(struct rtw_adapter *padapter,
@@ -544,7 +532,8 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta);
 
 void update_beacon23a_info(struct rtw_adapter *padapter, u8 *pframe, uint len,
                        struct sta_info *psta);
-int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_len);
+int rtw_check_bcn_info23a(struct rtw_adapter *Adapter,
+                         struct ieee80211_mgmt *mgmt, u32 packet_len);
 void update_IOT_info23a(struct rtw_adapter *padapter);
 void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap);
 void update_wireless_mode23a(struct rtw_adapter * padapter);
@@ -594,18 +583,6 @@ s32 dump_mgntframe23a_and_wait(struct rtw_adapter *padapter,
 s32 dump_mgntframe23a_and_wait_ack23a(struct rtw_adapter *padapter,
                                struct xmit_frame *pmgntframe);
 
-#ifdef CONFIG_8723AU_P2P
-void issue_probersp23a_p2p23a(struct rtw_adapter *padapter, unsigned char *da);
-void issue_p2p_provision_request23a(struct rtw_adapter *padapter, u8 *pssid,
-                                u8 ussidlen, u8* pdev_raddr);
-void issue_p2p_GO_request23a(struct rtw_adapter *padapter, u8* raddr);
-void issue23a_probereq_p2p(struct rtw_adapter *padapter, u8 *da);
-int issue23a_probereq_p2p_ex(struct rtw_adapter *adapter, u8 *da, int try_cnt,
-                         int wait_ms);
-void issue_p2p_invitation_response23a(struct rtw_adapter *padapter, u8* raddr,
-                                  u8 dialogToken, u8 success);
-void issue_p2p_invitation_request23a(struct rtw_adapter *padapter, u8* raddr);
-#endif /* CONFIG_8723AU_P2P */
 void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms);
 void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da,
                    u8 is_valid_p2p_probereq);
@@ -628,8 +605,9 @@ int issue_deauth23a_ex23a(struct rtw_adapter *padapter, u8 *da, unsigned short r
                    int try_cnt, int wait_ms);
 void issue_action_spct_ch_switch23a(struct rtw_adapter *padapter, u8 *ra,
                                 u8 new_ch, u8 ch_offset);
-void issue_action_BA23a(struct rtw_adapter *padapter, unsigned char *raddr,
-                    unsigned char action, unsigned short status);
+void issue_action_BA23a(struct rtw_adapter *padapter,
+                       const unsigned char *raddr,
+                       unsigned char action, unsigned short status);
 unsigned int send_delba23a(struct rtw_adapter *padapter, u8 initiator, u8 *addr);
 unsigned int send_beacon23a(struct rtw_adapter *padapter);
 
@@ -638,28 +616,6 @@ void start_clnt_auth23a(struct rtw_adapter *padapter);
 void start_clnt_join23a(struct rtw_adapter *padapter);
 void start_create_ibss23a(struct rtw_adapter *padapter);
 
-unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-unsigned int OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-unsigned int OnProbeRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-unsigned int DoReserved23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-unsigned int OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-unsigned int OnAtim23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-unsigned int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-unsigned int OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-unsigned int OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-unsigned int OnDeAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-unsigned int OnAction23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-
-unsigned int on_action_spct23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-unsigned int OnAction23a_qos(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-unsigned int OnAction23a_dls(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-unsigned int on_action_public23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-unsigned int OnAction23a_ht(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-unsigned int OnAction23a_wmm(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-unsigned int OnAction23a_p2p(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
-
 
 void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_res);
 void mlmeext_sta_del_event_callback23a(struct rtw_adapter *padapter);
@@ -680,12 +636,11 @@ int cckratesonly_included23a(unsigned char *rate, int ratelen);
 
 void process_addba_req23a(struct rtw_adapter *padapter, u8 *paddba_req, u8 *addr);
 
-void update_TSF23a(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len);
 void correct_TSF23a(struct rtw_adapter *padapter, struct mlme_ext_priv *pmlmeext);
 
 struct cmd_hdl {
        uint    parmsize;
-       u8 (*h2cfuns)(struct rtw_adapter *padapter, u8 *pbuf);
+       u8 (*h2cfuns)(struct rtw_adapter *padapter, const u8 *pbuf);
 };
 
 
@@ -697,27 +652,27 @@ u8 read_rfreg_hdl(struct rtw_adapter *padapter, u8 *pbuf);
 u8 write_rfreg_hdl(struct rtw_adapter *padapter, u8 *pbuf);
 
 
-u8 NULL_hdl23a(struct rtw_adapter *padapter, u8 *pbuf);
-u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf);
-u8 disconnect_hdl23a(struct rtw_adapter *padapter, u8 *pbuf);
-u8 createbss_hdl23a(struct rtw_adapter *padapter, u8 *pbuf);
-u8 setopmode_hdl23a(struct rtw_adapter *padapter, u8 *pbuf);
-u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf);
-u8 setauth_hdl23a(struct rtw_adapter *padapter, u8 *pbuf);
-u8 setkey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf);
-u8 set_stakey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf);
-u8 set_assocsta_hdl(struct rtw_adapter *padapter, u8 *pbuf);
-u8 del_assocsta_hdl(struct rtw_adapter *padapter, u8 *pbuf);
-u8 add_ba_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf);
-
-u8 mlme_evt_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf);
-u8 h2c_msg_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf);
-u8 tx_beacon_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf);
-u8 set_ch_hdl23a(struct rtw_adapter *padapter, u8 *pbuf);
-u8 set_chplan_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf);
-u8 led_blink_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf);
-u8 set_csa_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf);  /* Kurt: Handling DFS channel switch announcement ie. */
-u8 tdls_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf);
+u8 NULL_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
+u8 join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
+u8 disconnect_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
+u8 createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
+u8 setopmode_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
+u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
+u8 setauth_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
+u8 setkey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
+u8 set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
+u8 set_assocsta_hdl(struct rtw_adapter *padapter, const u8 *pbuf);
+u8 del_assocsta_hdl(struct rtw_adapter *padapter, const u8 *pbuf);
+u8 add_ba_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
+
+u8 mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
+u8 h2c_msg_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
+u8 tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
+u8 set_ch_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
+u8 set_chplan_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
+u8 led_blink_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
+u8 set_csa_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);       /* Kurt: Handling DFS channel switch announcement ie. */
+u8 tdls_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
 
 #define GEN_DRV_CMD_HANDLER(size, cmd) {size, &cmd ## _hdl23a},
 #define GEN_MLME_EXT_HANDLER(size, cmd)        {size, cmd},
diff --git a/drivers/staging/rtl8723au/include/rtw_p2p.h b/drivers/staging/rtl8723au/include/rtw_p2p.h
deleted file mode 100644 (file)
index 93fdc65..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/******************************************************************************
- *
- * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- ******************************************************************************/
-#ifndef __RTW_P2P_H_
-#define __RTW_P2P_H_
-
-#include <drv_types.h>
-
-u32 build_beacon_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf);
-u32 build_probe_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf);
-u32 build_prov_disc_request_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf,
-                                  u8 *pssid, u8 ussidlen, u8 *pdev_raddr);
-u32 build_assoc_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf,
-                           u8 status_code);
-u32 build_deauth_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf);
-#ifdef CONFIG_8723AU_P2P
-u32 build_probe_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
-u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf,
-                           u8 tunneled);
-u32 build_beacon_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
-u32 build_nego_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
-u32 build_nego_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
-u32 build_nego_confirm_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
-u32 build_invitation_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
-u32 build_invitation_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
-u32 build_assoc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
-u32 build_assoc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
-u32 build_provdisc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
-u32 build_provdisc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
-#endif /* CONFIG_8723AU_P2P */
-
-u32 process_probe_req_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pframe,
-                            uint len);
-u32 process_assoc_req_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pframe,
-                            uint len, struct sta_info *psta);
-u32 process_p2p_devdisc_req23a(struct wifidirect_info *pwdinfo, u8 *pframe,
-                           uint len);
-u32 process_p2p_devdisc_resp23a(struct wifidirect_info *pwdinfo, u8 *pframe,
-                            uint len);
-u8 process_p2p_provdisc_req23a(struct wifidirect_info *pwdinfo, u8 *pframe,
-                           uint len);
-u8 process_p2p_provdisc_resp23a(struct wifidirect_info *pwdinfo, u8 *pframe);
-u8 process_p2p_group_negotation_req23a(struct wifidirect_info *pwdinfo,
-                                   u8 *pframe, uint len);
-u8 process_p2p_group_negotation_resp23a(struct wifidirect_info *pwdinfo,
-                                    u8 *pframe, uint len);
-u8 process_p2p_group_negotation_confirm23a(struct wifidirect_info *pwdinfo,
-                                       u8 *pframe, uint len);
-u8 process_p2p_presence_req23a(struct wifidirect_info *pwdinfo,
-                           u8 *pframe, uint len);
-
-void p2p_protocol_wk_hdl23a(struct rtw_adapter *padapter, int cmdtype);
-
-#ifdef CONFIG_8723AU_P2P
-void   process_p2p_ps_ie23a(struct rtw_adapter *padapter, u8 *IEs, u32 IELength);
-void   p2p_ps_wk_hdl23a(struct rtw_adapter *padapter, u8 p2p_ps_state);
-u8 p2p_ps_wk_cmd23a(struct rtw_adapter *padapter, u8 p2p_ps_state, u8 enqueue);
-#endif /*  CONFIG_8723AU_P2P */
-
-void rtw_init_cfg80211_wifidirect_info(struct rtw_adapter *padapter);
-int rtw_p2p_check_frames(struct rtw_adapter *padapter, const u8 *buf,
-                        u32 len, u8 tx);
-void rtw_append_wfd_ie(struct rtw_adapter *padapter, u8 *buf, u32 *len);
-
-void reset_global_wifidirect_info23a(struct rtw_adapter *padapter);
-int rtw_init_wifi_display_info(struct rtw_adapter *padapter);
-void rtw_init_wifidirect_timers23a(struct rtw_adapter *padapter);
-void rtw_init_wifidirect_addrs23a(struct rtw_adapter *padapter, u8 *dev_addr,
-                              u8 *iface_addr);
-void init_wifidirect_info23a(struct rtw_adapter *padapter, enum P2P_ROLE role);
-int rtw_p2p_enable23a(struct rtw_adapter *padapter, enum P2P_ROLE role);
-
-static inline void _rtw_p2p_set_state(struct wifidirect_info *wdinfo,
-                                     enum P2P_STATE state)
-{
-       if (wdinfo->p2p_state != state) {
-               /* wdinfo->pre_p2p_state = wdinfo->p2p_state; */
-               wdinfo->p2p_state = state;
-       }
-}
-
-static inline void _rtw_p2p_set_pre_state(struct wifidirect_info *wdinfo,
-                                         enum P2P_STATE state)
-{
-       if (wdinfo->pre_p2p_state != state)
-               wdinfo->pre_p2p_state = state;
-}
-
-static inline void _rtw_p2p_set_role(struct wifidirect_info *wdinfo,
-                                    enum P2P_ROLE role)
-{
-       if (wdinfo->role != role)
-               wdinfo->role = role;
-}
-
-static inline int _rtw_p2p_state(struct wifidirect_info *wdinfo)
-{
-       return wdinfo->p2p_state;
-}
-
-static inline int _rtw_p2p_pre_state(struct wifidirect_info *wdinfo)
-{
-       return wdinfo->pre_p2p_state;
-}
-
-static inline int _rtw_p2p_role(struct wifidirect_info *wdinfo)
-{
-       return wdinfo->role;
-}
-
-static inline bool _rtw_p2p_chk_state(struct wifidirect_info *wdinfo,
-                                     enum P2P_STATE state)
-{
-       return wdinfo->p2p_state == state;
-}
-
-static inline bool _rtw_p2p_chk_role(struct wifidirect_info *wdinfo,
-                                    enum P2P_ROLE role)
-{
-       return wdinfo->role == role;
-}
-
-#define rtw_p2p_set_state(wdinfo, state) _rtw_p2p_set_state(wdinfo, state)
-#define rtw_p2p_set_pre_state(wdinfo, state)                   \
-       _rtw_p2p_set_pre_state(wdinfo, state)
-#define rtw_p2p_set_role(wdinfo, role) _rtw_p2p_set_role(wdinfo, role)
-
-#define rtw_p2p_state(wdinfo) _rtw_p2p_state(wdinfo)
-#define rtw_p2p_pre_state(wdinfo) _rtw_p2p_pre_state(wdinfo)
-#define rtw_p2p_role(wdinfo) _rtw_p2p_role(wdinfo)
-#define rtw_p2p_chk_state(wdinfo, state) _rtw_p2p_chk_state(wdinfo, state)
-#define rtw_p2p_chk_role(wdinfo, role) _rtw_p2p_chk_role(wdinfo, role)
-
-#define rtw_p2p_findphase_ex_set(wdinfo, value) \
-       ((wdinfo)->find_phase_state_exchange_cnt = (value))
-
-/* is this find phase exchange for social channel scan? */
-#define rtw_p2p_findphase_ex_is_social(wdinfo)                 \
-       ((wdinfo)->find_phase_state_exchange_cnt >=             \
-        P2P_FINDPHASE_EX_SOCIAL_FIRST)
-
-/* should we need find phase exchange anymore? */
-#define rtw_p2p_findphase_ex_is_needed(wdinfo) \
-       ((wdinfo)->find_phase_state_exchange_cnt < P2P_FINDPHASE_EX_MAX && \
-       (wdinfo)->find_phase_state_exchange_cnt != P2P_FINDPHASE_EX_NONE)
-
-#endif
index e0da87d4d3d6a489d29509fa134e0fb2c892ac8d..44a7d4f97e0947f18b07c24c964ae4c4ffdd6e5a 100644 (file)
@@ -165,7 +165,6 @@ struct pwrctrl_priv {
        struct work_struct cpwm_event;
        u8      bpower_saving;
 
-       u8      b_hw_radio_off;
        u8      reg_rfoff;
        u8      reg_pdnmode; /* powerdown mode */
        u32     rfoff_reason;
@@ -250,8 +249,6 @@ s32 LPS_RF_ON_check23a(struct rtw_adapter *padapter, u32 delay_ms);
 void LPS_Enter23a(struct rtw_adapter *padapter);
 void LPS_Leave23a(struct rtw_adapter *padapter);
 
-u8 rtw_interface_ps_func23a(struct rtw_adapter *padapter,
-                        enum hal_intf_ps_func efunc_id, u8 *val);
 void rtw_set_ips_deny23a(struct rtw_adapter *padapter, u32 ms);
 int _rtw_pwr_wakeup23a(struct rtw_adapter *padapter, u32 ips_deffer_ms,
                    const char *caller);
index d1866a6e831f47114af899531c3a8dc751961a76..1f18af8dcc040a164db3b06cf3ca1cbbdbacbbe5 100644 (file)
@@ -152,12 +152,12 @@ struct rx_pkt_attrib      {
 #define RXDESC_OFFSET RXDESC_SIZE
 
 struct recv_stat {
-       unsigned int rxdw0;
-       unsigned int rxdw1;
-       unsigned int rxdw2;
-       unsigned int rxdw3;
-       unsigned int rxdw4;
-       unsigned int rxdw5;
+       __le32 rxdw0;
+       __le32 rxdw1;
+       __le32 rxdw2;
+       __le32 rxdw3;
+       __le32 rxdw4;
+       __le32 rxdw5;
 };
 
 /* accesser of recv_priv: rtw_recv_entry23a(dispatch / passive level); \
index 75bbb934a53cf228d295e70828b0207986c9bffd..702dd845a3ff033a4fe65c1c86bc93b283f0cffd 100644 (file)
@@ -30,7 +30,6 @@
 
 #define is_wep_enc(alg) (((alg) == _WEP40_) || ((alg) == _WEP104_))
 
-#define _WPA_IE_ID_    0xdd
 #define _WPA2_IE_ID_   0x30
 
 #define SHA256_MAC_LEN 32
@@ -316,22 +315,6 @@ static const unsigned long K[64] = {
        0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
 };
 
-/* Various logical functions */
-#define RORc(x, y) \
-(((((unsigned long)(x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
-((unsigned long)(x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
-#define Ch(x, y, z)     (z ^ (x & (y ^ z)))
-#define Maj(x, y, z)    (((x | y) & z) | (x & y))
-#define S(x, n)         RORc((x), (n))
-#define R(x, n)         (((x)&0xFFFFFFFFUL)>>(n))
-#define Sigma0(x)       (S(x, 2) ^ S(x, 13) ^ S(x, 22))
-#define Sigma1(x)       (S(x, 6) ^ S(x, 11) ^ S(x, 25))
-#define Gamma0(x)       (S(x, 7) ^ S(x, 18) ^ R(x, 3))
-#define Gamma1(x)       (S(x, 17) ^ S(x, 19) ^ R(x, 10))
-#ifndef MIN
-#define MIN(x, y) (((x) < (y)) ? (x) : (y))
-#endif
-
 void rtw_secmicsetkey23a(struct mic_data *pmicdata, u8 *key);
 void rtw_secmicappend23abyte23a(struct mic_data *pmicdata, u8 b);
 void rtw_secmicappend23a(struct mic_data *pmicdata, u8 *src, u32 nbBytes);
index 65a33a07c8ee27bba8f0728ead8464d5575d0a23..5b879764518f1c82180bf0b130558c5be8649d11 100644 (file)
@@ -92,14 +92,14 @@ do {                                                                        \
 
 struct tx_desc {
        /* DWORD 0 */
-       unsigned int txdw0;
-       unsigned int txdw1;
-       unsigned int txdw2;
-       unsigned int txdw3;
-       unsigned int txdw4;
-       unsigned int txdw5;
-       unsigned int txdw6;
-       unsigned int txdw7;
+       __le32 txdw0;
+       __le32 txdw1;
+       __le32 txdw2;
+       __le32 txdw3;
+       __le32 txdw4;
+       __le32 txdw5;
+       __le32 txdw6;
+       __le32 txdw7;
 };
 
 union txdesc {
index ffbc9e3f2156f9e8eb225b625f0c473f356653ee..c02947f6bd9b37f7dd381dc0f942ebb022175234 100644 (file)
@@ -349,7 +349,7 @@ struct      sta_priv {
        struct wlan_acl_pool acl_list;
 };
 
-static inline u32 wifi_mac_hash(u8 *mac)
+static inline u32 wifi_mac_hash(const u8 *mac)
 {
        u32 x;
 
@@ -377,7 +377,7 @@ struct sta_info *rtw_get_stainfo23a_by_offset23a(struct sta_priv *stapriv,
 struct sta_info *rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr);
 u32 rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta);
 void rtw_free_all_stainfo23a(struct rtw_adapter *padapter);
-struct sta_info *rtw_get_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr);
+struct sta_info *rtw_get_stainfo23a(struct sta_priv *pstapriv, const u8 *hwaddr);
 u32 rtw_init_bcmc_stainfo23a(struct rtw_adapter *padapter);
 struct sta_info *rtw_get_bcmc_stainfo23a(struct rtw_adapter *padapter);
 u8 rtw_access_ctrl23a(struct rtw_adapter *padapter, u8 *mac_addr);
index 55d1380f903686e2a453a0cac5038b374c4c160c..1013406c9c77dee1449110082242acffd4389fb5 100644 (file)
@@ -45,8 +45,7 @@ enum {
 void rtl8723au_set_hw_type(struct rtw_adapter *padapter);
 #define hal_set_hw_type rtl8723au_set_hw_type
 
-void rtl8723au_set_intf_ops(struct _io_ops *pops);
-#define usb_set_intf_ops rtl8723au_set_intf_ops
+void rtl8723au_set_intf_ops(struct rtw_adapter *padapter);
 
 void rtl8723au_recv_tasklet(void *priv);
 
index 8f5c59eace5a18229acd1a4d00eea030bae14325..0eb33e01c78c79d4cf8a6343366e5adfb5149e45 100644 (file)
 
 unsigned int ffaddr2pipehdl23a(struct dvobj_priv *pdvobj, u32 addr);
 
-void usb_read_mem23a(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem);
-void usb_write_mem23a(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem);
+void usb_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *rmem);
+void usb_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *wmem);
 
-void usb_read_port_cancel23a(struct intf_hdl *pintfhdl);
+void usb_read_port_cancel23a(struct rtw_adapter *adapter);
 
-u32 usb_write_port23a(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
-                  struct xmit_buf *wmem);
-void usb_write_port23a_cancel(struct intf_hdl *pintfhdl);
+u32 usb_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt,
+                     struct xmit_buf *wmem);
+void usb_write_port23a_cancel(struct rtw_adapter *adapter);
 
 #endif
index b5034c6ef1dc7db10d811c8599c6ca82e595a130..aebc05d8a1235e820b7f9da786f85ea6cc0dc011 100644 (file)
@@ -82,42 +82,42 @@ enum WIFI_REG_DOMAIN {
 
 
 #define SetToDs(pbuf)  \
-       (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_TODS))
+       (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_TODS))
 
 #define SetFrDs(pbuf)  \
-       (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS))
+       (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS))
 
 #define get_tofr_ds(pframe)    ((ieee80211_has_tods(pframe) << 1) | \
                                 ieee80211_has_fromds(pframe))
 
 #define SetMFrag(pbuf) \
-       (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREFRAGS))
+       (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREFRAGS))
 
 #define ClearMFrag(pbuf)       \
-       (*(unsigned short *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)))
+       (*(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)))
 
 #define SetRetry(pbuf) \
-       (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_RETRY))
+       (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_RETRY))
 
 #define SetPwrMgt(pbuf)        \
-       (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PM))
+       (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PM))
 
 #define SetMData(pbuf) \
-       (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREDATA))
+       (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREDATA))
 
 #define SetPrivacy(pbuf)       \
-       (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PROTECTED))
+       (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PROTECTED))
 
 #define SetFrameType(pbuf, type)       \
        do {    \
-               *(unsigned short *)(pbuf) &= __constant_cpu_to_le16(~(BIT(3) | BIT(2))); \
-               *(unsigned short *)(pbuf) |= __constant_cpu_to_le16(type); \
+               *(__le16 *)(pbuf) &= __constant_cpu_to_le16(~(BIT(3) | BIT(2))); \
+               *(__le16 *)(pbuf) |= __constant_cpu_to_le16(type); \
        } while (0)
 
 #define SetFrameSubType(pbuf, type) \
        do {    \
-               *(unsigned short *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2))); \
-               *(unsigned short *)(pbuf) |= cpu_to_le16(type); \
+               *(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2))); \
+               *(__le16 *)(pbuf) |= cpu_to_le16(type); \
        } while (0)
 
 #define GetTupleCache(pbuf)    (cpu_to_le16(*(unsigned short *)((unsigned long)(pbuf) + 22)))
@@ -131,26 +131,26 @@ enum WIFI_REG_DOMAIN {
 
 #define SetSeqNum(pbuf, num) \
        do {    \
-               *(unsigned short *)((unsigned long)(pbuf) + 22) = \
-                       ((*(unsigned short *)((unsigned long)(pbuf) + 22)) & le16_to_cpu((unsigned short)0x000f)) | \
-                       le16_to_cpu((unsigned short)(0xfff0 & (num << 4))); \
+               *(__le16 *)((size_t)(pbuf) + 22) = \
+                       ((*(__le16 *)((size_t)(pbuf) + 22)) & cpu_to_le16((unsigned short)0x000f)) | \
+                       cpu_to_le16((unsigned short)(0xfff0 & (num << 4))); \
        } while (0)
 
 #define SetDuration(pbuf, dur) \
-       (*(unsigned short *)((unsigned long)(pbuf) + 2) =               \
+       (*(__le16 *)((unsigned long)(pbuf) + 2) =               \
         cpu_to_le16(0xffff & (dur)))
 
 #define SetPriority(pbuf, tid) \
-       (*(unsigned short *)(pbuf) |= cpu_to_le16(tid & 0xf))
+       (*(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf))
 
 #define SetEOSP(pbuf, eosp)    \
-       (*(unsigned short *)(pbuf) |= cpu_to_le16((eosp & 1) << 4))
+       (*(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4))
 
 #define SetAckpolicy(pbuf, ack)        \
-       (*(unsigned short *)(pbuf) |= cpu_to_le16((ack & 3) << 5))
+       (*(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5))
 
 #define SetAMsdu(pbuf, amsdu)  \
-       (*(unsigned short *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7))
+       (*(__le16 *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7))
 
 #define GetAid(pbuf)                                                   \
        (cpu_to_le16(*(unsigned short *)((unsigned long)(pbuf) + 2)) &  \
@@ -219,39 +219,8 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
 
 #define _FIXED_IE_LENGTH_              _BEACON_IE_OFFSET_
 
-#define _SSID_IE_                      0
-#define _SUPPORTEDRATES_IE_            1
-#define _DSSET_IE_                     3
-#define _TIM_IE_                       5
-#define _IBSS_PARA_IE_                 6
-#define _COUNTRY_IE_                   7
-#define _CHLGETXT_IE_                  16
-#define _SUPPORTED_CH_IE_              36
-#define _CH_SWTICH_ANNOUNCE_   37      /* Secondary Channel Offset */
-#define _RSN_IE_2_                     48
-#define _SSN_IE_1_                     221
-#define _ERPINFO_IE_                   42
-#define _EXT_SUPPORTEDRATES_IE_                50
-
-#define _HT_CAPABILITY_IE_             45
-#define _FTIE_                         55
-#define _TIMEOUT_ITVL_IE_              56
-#define _SRC_IE_                       59
-#define _HT_EXTRA_INFO_IE_             61
-#define _HT_ADD_INFO_IE_               61 /* _HT_EXTRA_INFO_IE_ */
-
-
-#define        EID_BSSCoexistence              72 /*  20/40 BSS Coexistence */
-#define        EID_BSSIntolerantChlReport      73
-#define _RIC_Descriptor_IE_            75
-
-#define _LINK_ID_IE_           101
-#define _CH_SWITCH_TIMING_     104
-#define _PTI_BUFFER_STATUS_    106
-#define _EXT_CAP_IE_           127
-#define _VENDOR_SPECIFIC_IE_   221
 
-#define        _RESERVED47_            47
+#define        EID_BSSIntolerantChlReport      73
 
 /* ---------------------------------------------------------------------------
                                        Below is the fixed elements...
@@ -490,72 +459,6 @@ struct ADDBA_request {
 #define WPS_ASSOC_STATE_ASSOCIATION_FAILURE    0x03
 #define WPS_ASSOC_STATE_IP_FAILURE             0x04
 
-/*     =====================P2P Section===================== */
-/*     For P2P */
-#define        P2POUI                                  0x506F9A09
-
-/*     P2P Attribute ID */
-#define        P2P_ATTR_STATUS                         0x00
-#define        P2P_ATTR_MINOR_REASON_CODE              0x01
-#define        P2P_ATTR_CAPABILITY                     0x02
-#define        P2P_ATTR_DEVICE_ID                      0x03
-#define        P2P_ATTR_GO_INTENT                      0x04
-#define        P2P_ATTR_CONF_TIMEOUT                   0x05
-#define        P2P_ATTR_LISTEN_CH                      0x06
-#define        P2P_ATTR_GROUP_BSSID                    0x07
-#define        P2P_ATTR_EX_LISTEN_TIMING               0x08
-#define        P2P_ATTR_INTENTED_IF_ADDR               0x09
-#define        P2P_ATTR_MANAGEABILITY                  0x0A
-#define        P2P_ATTR_CH_LIST                        0x0B
-#define        P2P_ATTR_NOA                            0x0C
-#define        P2P_ATTR_DEVICE_INFO                    0x0D
-#define        P2P_ATTR_GROUP_INFO                     0x0E
-#define        P2P_ATTR_GROUP_ID                       0x0F
-#define        P2P_ATTR_INTERFACE                      0x10
-#define        P2P_ATTR_OPERATING_CH                   0x11
-#define        P2P_ATTR_INVITATION_FLAGS               0x12
-
-/*     Value of Status Attribute */
-#define        P2P_STATUS_SUCCESS                      0x00
-#define        P2P_STATUS_FAIL_INFO_UNAVAILABLE        0x01
-#define        P2P_STATUS_FAIL_INCOMPATIBLE_PARAM      0x02
-#define        P2P_STATUS_FAIL_LIMIT_REACHED           0x03
-#define        P2P_STATUS_FAIL_INVALID_PARAM           0x04
-#define        P2P_STATUS_FAIL_REQUEST_UNABLE          0x05
-#define        P2P_STATUS_FAIL_PREVOUS_PROTO_ERR       0x06
-#define        P2P_STATUS_FAIL_NO_COMMON_CH            0x07
-#define        P2P_STATUS_FAIL_UNKNOWN_P2PGROUP        0x08
-#define        P2P_STATUS_FAIL_BOTH_GOINTENT_15        0x09
-#define        P2P_STATUS_FAIL_INCOMPATIBLE_PROVSION   0x0A
-#define        P2P_STATUS_FAIL_USER_REJECT             0x0B
-
-/*     Value of Inviation Flags Attribute */
-#define        P2P_INVITATION_FLAGS_PERSISTENT         BIT(0)
-
-#define        DMP_P2P_DEVCAP_SUPPORT  (P2P_DEVCAP_SERVICE_DISCOVERY | \
-                                P2P_DEVCAP_CLIENT_DISCOVERABILITY | \
-                                P2P_DEVCAP_CONCURRENT_OPERATION | \
-                                P2P_DEVCAP_INVITATION_PROC)
-
-#define        DMP_P2P_GRPCAP_SUPPORT  (P2P_GRPCAP_INTRABSS)
-
-/*     Value of Device Capability Bitmap */
-#define        P2P_DEVCAP_SERVICE_DISCOVERY            BIT(0)
-#define        P2P_DEVCAP_CLIENT_DISCOVERABILITY       BIT(1)
-#define        P2P_DEVCAP_CONCURRENT_OPERATION         BIT(2)
-#define        P2P_DEVCAP_INFRA_MANAGED                BIT(3)
-#define        P2P_DEVCAP_DEVICE_LIMIT                 BIT(4)
-#define        P2P_DEVCAP_INVITATION_PROC              BIT(5)
-
-/*     Value of Group Capability Bitmap */
-#define        P2P_GRPCAP_GO                           BIT(0)
-#define        P2P_GRPCAP_PERSISTENT_GROUP             BIT(1)
-#define        P2P_GRPCAP_GROUP_LIMIT                  BIT(2)
-#define        P2P_GRPCAP_INTRABSS                     BIT(3)
-#define        P2P_GRPCAP_CROSS_CONN                   BIT(4)
-#define        P2P_GRPCAP_PERSISTENT_RECONN            BIT(5)
-#define        P2P_GRPCAP_GROUP_FORMATION              BIT(6)
-
 /*     P2P Public Action Frame ( Management Frame ) */
 #define        P2P_PUB_ACTION_ACTION                   0x09
 
@@ -570,37 +473,6 @@ struct ADDBA_request {
 #define        P2P_PROVISION_DISC_REQ                  7
 #define        P2P_PROVISION_DISC_RESP                 8
 
-/*     P2P Action Frame Type */
-#define        P2P_NOTICE_OF_ABSENCE                   0
-#define        P2P_PRESENCE_REQUEST                    1
-#define        P2P_PRESENCE_RESPONSE                   2
-#define        P2P_GO_DISC_REQUEST                     3
-
-
-#define        P2P_MAX_PERSISTENT_GROUP_NUM            10
-
-#define        P2P_PROVISIONING_SCAN_CNT               3
-
-#define        P2P_WILDCARD_SSID_LEN                   7
-
-#define        P2P_FINDPHASE_EX_NONE                   0       /*  default value, used when: (1)p2p disabed or (2)p2p enabled but only do 1 scan phase */
-#define        P2P_FINDPHASE_EX_FULL                   1       /*  used when p2p enabled and want to do 1 scan phase and P2P_FINDPHASE_EX_MAX-1 find phase */
-#define        P2P_FINDPHASE_EX_SOCIAL_FIRST           (P2P_FINDPHASE_EX_FULL+1)
-#define        P2P_FINDPHASE_EX_MAX                                    4
-#define        P2P_FINDPHASE_EX_SOCIAL_LAST            P2P_FINDPHASE_EX_MAX
-
-#define        P2P_PROVISION_TIMEOUT                   5000    /*5 sec timeout for sending the provision discovery request */
-#define        P2P_CONCURRENT_PROVISION_TIMEOUT        3000    /*3 sec timeout for sending the provision discovery request under concurrent mode */
-#define        P2P_GO_NEGO_TIMEOUT                     5000    /*5 sec timeout for receiving the group negotation response */
-#define        P2P_CONCURRENT_GO_NEGO_TIMEOUT          3000    /*3 sec timeout for sending the negotiation request under concurrent mode */
-#define        P2P_TX_PRESCAN_TIMEOUT                  100     /*100ms */
-#define        P2P_INVITE_TIMEOUT                      5000    /*5 sec timeout for sending the invitation request */
-#define        P2P_CONCURRENT_INVITE_TIMEOUT           3000    /*3 sec timeout for sending the invitation request under concurrent mode */
-#define        P2P_RESET_SCAN_CH                       25000   /*25 sec t/o to reset the scan channel ( based on channel plan ) */
-#define        P2P_MAX_INTENT                          15
-
-#define        P2P_MAX_NOA_NUM                         2
-
 /*     WPS Configuration Method */
 #define        WPS_CM_NONE                                     0x0000
 #define        WPS_CM_LABEL                                    0x0004
@@ -615,93 +487,4 @@ struct ADDBA_request {
 #define        WPS_CM_SW_DISPLAY_PIN                           0x2008
 #define        WPS_CM_LCD_DISPLAY_PIN                          0x4008
 
-enum P2P_ROLE {
-       P2P_ROLE_DISABLE = 0,
-       P2P_ROLE_DEVICE = 1,
-       P2P_ROLE_CLIENT = 2,
-       P2P_ROLE_GO = 3
-};
-
-enum P2P_STATE {
-       P2P_STATE_NONE = 0,                     /*P2P disable */
-       P2P_STATE_IDLE = 1,                     /*P2P had enabled and do nothing */
-       P2P_STATE_LISTEN = 2,                   /*In pure listen state */
-       P2P_STATE_SCAN = 3,                     /*In scan phase */
-       P2P_STATE_FIND_PHASE_LISTEN = 4,        /*In the listen state of find phase */
-       P2P_STATE_FIND_PHASE_SEARCH = 5,        /*In the search state of find phase */
-       P2P_STATE_TX_PROVISION_DIS_REQ = 6,     /*In P2P provisioning discovery */
-       P2P_STATE_RX_PROVISION_DIS_RSP = 7,
-       P2P_STATE_RX_PROVISION_DIS_REQ = 8,
-       P2P_STATE_GONEGO_ING = 9,               /*Doing the group owner negoitation handshake */
-       P2P_STATE_GONEGO_OK = 10,               /*finish the group negoitation handshake with success */
-       P2P_STATE_GONEGO_FAIL = 11,             /*finish the group negoitation handshake with failure */
-       P2P_STATE_RECV_INVITE_REQ_MATCH = 12,   /*receiving the P2P Inviation request and match with the profile. */
-       P2P_STATE_PROVISIONING_ING = 13,        /*Doing the P2P WPS */
-       P2P_STATE_PROVISIONING_DONE = 14,       /*Finish the P2P WPS */
-       P2P_STATE_TX_INVITE_REQ = 15,           /*Transmit the P2P Invitation request */
-       P2P_STATE_RX_INVITE_RESP_OK = 16,       /*Receiving the P2P Invitation response */
-       P2P_STATE_RECV_INVITE_REQ_DISMATCH = 17,/*receiving the P2P Inviation request and dismatch with the profile. */
-       P2P_STATE_RECV_INVITE_REQ_GO = 18,      /*receiving the P2P Inviation request and this wifi is GO. */
-       P2P_STATE_RECV_INVITE_REQ_JOIN = 19,    /*receiving the P2P Inviation request to join an existing P2P Group. */
-       P2P_STATE_RX_INVITE_RESP_FAIL = 20,     /*receiving the P2P Inviation response with failure */
-       P2P_STATE_RX_INFOR_NOREADY = 21,        /*receiving p2p negotiation response with information is not available */
-       P2P_STATE_TX_INFOR_NOREADY = 22,        /*sending p2p negotiation response with information is not available */
-};
-
-enum P2P_WPSINFO {
-       P2P_NO_WPSINFO                          = 0,
-       P2P_GOT_WPSINFO_PEER_DISPLAY_PIN        = 1,
-       P2P_GOT_WPSINFO_SELF_DISPLAY_PIN        = 2,
-       P2P_GOT_WPSINFO_PBC                     = 3,
-};
-
-#define        P2P_PRIVATE_IOCTL_SET_LEN               64
-
-enum P2P_PROTO_WK_ID {
-       P2P_FIND_PHASE_WK = 0,
-       P2P_RESTORE_STATE_WK = 1,
-       P2P_PRE_TX_PROVDISC_PROCESS_WK = 2,
-       P2P_PRE_TX_NEGOREQ_PROCESS_WK = 3,
-       P2P_PRE_TX_INVITEREQ_PROCESS_WK = 4,
-       P2P_AP_P2P_CH_SWITCH_PROCESS_WK = 5,
-       P2P_RO_CH_WK = 6,
-};
-
-#ifdef CONFIG_8723AU_P2P
-enum P2P_PS_STATE {
-       P2P_PS_DISABLE = 0,
-       P2P_PS_ENABLE = 1,
-       P2P_PS_SCAN = 2,
-       P2P_PS_SCAN_DONE = 3,
-       P2P_PS_ALLSTASLEEP = 4, /*  for P2P GO */
-};
-
-enum P2P_PS_MODE {
-       P2P_PS_NONE = 0,
-       P2P_PS_CTWINDOW = 1,
-       P2P_PS_NOA       = 2,
-       P2P_PS_MIX = 3, /*  CTWindow and NoA */
-};
-#endif /*  CONFIG_8723AU_P2P */
-
-/*     =====================WFD Section===================== */
-/*     For Wi-Fi Display */
-#define        WFD_ATTR_DEVICE_INFO                    0x00
-#define        WFD_ATTR_ASSOC_BSSID                    0x01
-#define        WFD_ATTR_COUPLED_SINK_INFO      0x06
-#define        WFD_ATTR_LOCAL_IP_ADDR          0x08
-#define        WFD_ATTR_SESSION_INFO           0x09
-#define        WFD_ATTR_ALTER_MAC                      0x0a
-
-/*     For WFD Device Information Attribute */
-#define        WFD_DEVINFO_SOURCE                                      0x0000
-#define        WFD_DEVINFO_PSINK                                       0x0001
-#define        WFD_DEVINFO_SSINK                                       0x0002
-#define        WFD_DEVINFO_DUAL                                        0x0003
-
-#define        WFD_DEVINFO_SESSION_AVAIL                       0x0010
-#define        WFD_DEVINFO_WSD                                         0x0040
-#define        WFD_DEVINFO_PC_TDLS                                     0x0080
-#define        WFD_DEVINFO_HDCP_SUPPORT                        0x0100
-
 #endif /*  _WIFI_H_ */
index 0eca53ece75d4fface20889819093fb5ad5fe641..2be04c48656c459a86366cf8cbd69defc1997db8 100644 (file)
 #include <osdep_service.h>
 #include <drv_types.h>
 
-struct pkt_file {
-       struct sk_buff *pkt;
-       __kernel_size_t pkt_len; /* the remainder length of the open_file */
-       unsigned char *cur_buffer;
-       u8 *buf_start;
-       u8 *cur_addr;
-       __kernel_size_t buf_len;
-};
-
 
 #define NR_XMITFRAME   256
 
-struct xmit_priv;
-struct pkt_attrib;
-struct sta_xmit_priv;
-struct xmit_frame;
-struct xmit_buf;
-
 int rtw_xmit23a_entry23a(struct sk_buff *pkt, struct net_device *pnetdev);
 
 void rtw_os_xmit_schedule23a(struct rtw_adapter *padapter);
@@ -44,10 +29,6 @@ int rtw_os_xmit_resource_alloc23a(struct rtw_adapter *padapter,
                               struct xmit_buf *pxmitbuf, u32 alloc_sz);
 void rtw_os_xmit_resource_free23a(struct rtw_adapter *padapter,
                               struct xmit_buf *pxmitbuf);
-uint rtw_remainder_len23a(struct pkt_file *pfile);
-void _rtw_open_pktfile23a(struct sk_buff *pkt, struct pkt_file *pfile);
-uint _rtw_pktfile_read23a(struct pkt_file *pfile, u8 *rmem, uint rlen);
-int rtw_endofpktfile23a(struct pkt_file *pfile);
 
 void rtw_os_pkt_complete23a(struct rtw_adapter *padapter, struct sk_buff *pkt);
 void rtw_os_xmit_complete23a(struct rtw_adapter *padapter,
index 50840b9a11fa06075ba0d58386a449957c5aa192..ca100dcc27631dc0796101f78b30a784bf03f69d 100644 (file)
@@ -260,10 +260,9 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter,
        size_t notify_ielen;
        s32 notify_signal;
        u8 buf[MAX_BSSINFO_LEN], *pbuf;
-       size_t len, bssinf_len = 0;
+       size_t len;
        struct ieee80211_hdr *pwlanhdr;
-       unsigned short *fctrl;
-       u8 bc_addr[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+       __le16 *fctrl;
 
        struct wireless_dev *wdev = padapter->rtw_wdev;
        struct wiphy *wiphy = wdev->wiphy;
@@ -271,11 +270,9 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter,
 
        /* DBG_8723A("%s\n", __func__); */
 
-       bssinf_len =
-               pnetwork->network.IELength + sizeof(struct ieee80211_hdr_3addr);
-       if (bssinf_len > MAX_BSSINFO_LEN) {
+       if (pnetwork->network.IELength > MAX_IE_SZ) {
                DBG_8723A("%s IE Length too long > %d byte\n", __func__,
-                         MAX_BSSINFO_LEN);
+                         MAX_IE_SZ);
                goto exit;
        }
 
@@ -289,14 +286,13 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter,
 
        notify_channel = ieee80211_get_channel(wiphy, freq);
 
-       /* rtw_get_timestampe_from_ie23a() */
        notify_timestamp = jiffies_to_msecs(jiffies) * 1000;    /* uSec */
 
        notify_interval =
            le16_to_cpu(*(u16 *)
                        rtw_get_beacon_interval23a_from_ie(pnetwork->network.IEs));
        notify_capability =
-           le16_to_cpu(*(u16 *)
+               get_unaligned_le16(
                        rtw_get_capability23a_from_ie(pnetwork->network.IEs));
 
        notify_ie = pnetwork->network.IEs + _FIXED_IE_LENGTH_;
@@ -321,7 +317,7 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter,
        SetSeqNum(pwlanhdr, 0);
 
        if (pnetwork->network.reserved == 1) {  /*  WIFI_BEACON */
-               memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN);
+               eth_broadcast_addr(pwlanhdr->addr1);
                SetFrameSubType(pbuf, WIFI_BEACON);
        } else {
                memcpy(pwlanhdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN);
@@ -357,9 +353,6 @@ void rtw_cfg80211_indicate_connect(struct rtw_adapter *padapter)
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct wlan_network *cur_network = &pmlmepriv->cur_network;
        struct wireless_dev *pwdev = padapter->rtw_wdev;
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-#endif
 
        DBG_8723A("%s(padapter =%p)\n", __func__, padapter);
 
@@ -370,18 +363,7 @@ void rtw_cfg80211_indicate_connect(struct rtw_adapter *padapter)
        if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
                return;
 
-#ifdef CONFIG_8723AU_P2P
-       if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {
-               rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo));
-               rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT);
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK);
-               DBG_8723A("%s, role =%d, p2p_state =%d, pre_p2p_state =%d\n",
-                         __func__, rtw_p2p_role(pwdinfo),
-                         rtw_p2p_state(pwdinfo), rtw_p2p_pre_state(pwdinfo));
-       }
-#endif /* CONFIG_8723AU_P2P */
-
-       if (rtw_to_roaming(padapter) > 0) {
+       if (padapter->mlmepriv.to_roaming > 0) {
                struct wiphy *wiphy = pwdev->wiphy;
                struct ieee80211_channel *notify_channel;
                u32 freq;
@@ -429,9 +411,6 @@ void rtw_cfg80211_indicate_disconnect(struct rtw_adapter *padapter)
 {
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct wireless_dev *pwdev = padapter->rtw_wdev;
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-#endif
 
        DBG_8723A("%s(padapter =%p)\n", __func__, padapter);
 
@@ -442,21 +421,6 @@ void rtw_cfg80211_indicate_disconnect(struct rtw_adapter *padapter)
        if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
                return;
 
-#ifdef CONFIG_8723AU_P2P
-       if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {
-               del_timer_sync(&pwdinfo->find_phase_timer);
-               del_timer_sync(&pwdinfo->restore_p2p_state_timer);
-               del_timer_sync(&pwdinfo->pre_tx_scan_timer);
-
-               rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo));
-               rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-
-               DBG_8723A("%s, role =%d, p2p_state =%d, pre_p2p_state =%d\n",
-                         __func__, rtw_p2p_role(pwdinfo),
-                         rtw_p2p_state(pwdinfo), rtw_p2p_pre_state(pwdinfo));
-       }
-#endif /* CONFIG_8723AU_P2P */
-
        if (!padapter->mlmepriv.not_indic_disco) {
                if (check_fwstate(&padapter->mlmepriv, WIFI_UNDER_LINKING)) {
                        cfg80211_connect_result(padapter->pnetdev, NULL, NULL,
@@ -558,8 +522,6 @@ static int set_group_key(struct rtw_adapter *padapter, u8 *key, u8 alg,
        pcmd->rsp = NULL;
        pcmd->rspsz = 0;
 
-       INIT_LIST_HEAD(&pcmd->list);
-
        res = rtw_enqueue_cmd23a(pcmdpriv, pcmd);
 
 exit:
@@ -921,11 +883,6 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev,
        struct rtw_adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct security_priv *psecuritypriv = &padapter->securitypriv;
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-#endif /* CONFIG_8723AU_P2P */
-
-
 
        DBG_8723A("%s\n", __func__);
 
@@ -1080,15 +1037,6 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev,
                                        rtw_set_key23a(padapter,
                                                    &padapter->securitypriv,
                                                    param->u.crypt.idx, 1);
-#ifdef CONFIG_8723AU_P2P
-                                       if (rtw_p2p_chk_state
-                                           (pwdinfo,
-                                            P2P_STATE_PROVISIONING_ING)) {
-                                               rtw_p2p_set_state(pwdinfo,
-                                                                 P2P_STATE_PROVISIONING_DONE);
-                                       }
-#endif /* CONFIG_8723AU_P2P */
-
                                }
                        }
 
@@ -1127,7 +1075,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev,
 {
        char *alg_name;
        u32 param_len;
-       struct ieee_param *param = NULL;
+       struct ieee_param *param;
        int ret = 0;
        struct wireless_dev *rtw_wdev = wiphy_to_wdev(wiphy);
        struct rtw_adapter *padapter = wiphy_to_adapter(wiphy);
@@ -1143,11 +1091,11 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev,
 
        param_len = sizeof(struct ieee_param) + params->key_len;
        param = kzalloc(param_len, GFP_KERNEL);
-       if (param == NULL)
-               return -1;
+       if (!param)
+               return -ENOMEM;
 
        param->cmd = IEEE_CMD_SET_ENCRYPTION;
-       memset(param->sta_addr, 0xff, ETH_ALEN);
+       eth_broadcast_addr(param->sta_addr);
 
        switch (params->cipher) {
        case IW_AUTH_CIPHER_NONE:
@@ -1298,10 +1246,8 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy,
                ret = -ENOENT;
                goto exit;
        }
-#ifdef CONFIG_DEBUG_CFG80211
        DBG_8723A(FUNC_NDEV_FMT " mac =" MAC_FMT "\n", FUNC_NDEV_ARG(ndev),
                  MAC_ARG(mac));
-#endif
 
        /* for infra./P2PClient mode */
        if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) &&
@@ -1352,9 +1298,6 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy,
        struct rtw_adapter *padapter = wiphy_to_adapter(wiphy);
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct wireless_dev *rtw_wdev = wiphy_to_wdev(wiphy);
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-#endif
        int ret = 0;
        u8 change = false;
 
@@ -1386,34 +1329,10 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy,
        case NL80211_IFTYPE_P2P_CLIENT:
        case NL80211_IFTYPE_STATION:
                networkType = Ndis802_11Infrastructure;
-#ifdef CONFIG_8723AU_P2P
-               if (change && rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) {
-                       del_timer_sync(&pwdinfo->find_phase_timer);
-                       del_timer_sync(&pwdinfo->restore_p2p_state_timer);
-                       del_timer_sync(&pwdinfo->pre_tx_scan_timer);
-
-                       /* it means remove GO and change mode from AP(GO)
-                          to station(P2P DEVICE) */
-                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE);
-                       rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo));
-
-                       DBG_8723A("%s, role =%d, p2p_state =%d, pre_p2p_state ="
-                                 "%d\n", __func__, rtw_p2p_role(pwdinfo),
-                                 rtw_p2p_state(pwdinfo),
-                                 rtw_p2p_pre_state(pwdinfo));
-               }
-#endif /* CONFIG_8723AU_P2P */
                break;
        case NL80211_IFTYPE_P2P_GO:
        case NL80211_IFTYPE_AP:
                networkType = Ndis802_11APMode;
-#ifdef CONFIG_8723AU_P2P
-               if (change && !rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {
-                       /* it means P2P Group created, we will be GO
-                          and change mode from  P2P DEVICE to AP(GO) */
-                       rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-               }
-#endif /* CONFIG_8723AU_P2P */
                break;
        default:
                return -EOPNOTSUPP;
@@ -1438,9 +1357,8 @@ void rtw_cfg80211_indicate_scan_done(struct rtw_wdev_priv *pwdev_priv,
 {
        spin_lock_bh(&pwdev_priv->scan_req_lock);
        if (pwdev_priv->scan_request != NULL) {
-#ifdef CONFIG_DEBUG_CFG80211
                DBG_8723A("%s with scan req\n", __func__);
-#endif
+
                if (pwdev_priv->scan_request->wiphy !=
                    pwdev_priv->rtw_wdev->wiphy)
                        DBG_8723A("error wiphy compare\n");
@@ -1449,9 +1367,7 @@ void rtw_cfg80211_indicate_scan_done(struct rtw_wdev_priv *pwdev_priv,
 
                pwdev_priv->scan_request = NULL;
        } else {
-#ifdef CONFIG_DEBUG_CFG80211
                DBG_8723A("%s without scan req\n", __func__);
-#endif
        }
        spin_unlock_bh(&pwdev_priv->scan_req_lock);
 }
@@ -1463,10 +1379,6 @@ void rtw_cfg80211_surveydone_event_callback(struct rtw_adapter *padapter)
        struct rtw_queue *queue = &pmlmepriv->scanned_queue;
        struct wlan_network *pnetwork;
 
-#ifdef CONFIG_DEBUG_CFG80211
-       DBG_8723A("%s\n", __func__);
-#endif
-
        spin_lock_bh(&pmlmepriv->scanned_queue.lock);
 
        phead = get_list_head(queue);
@@ -1495,23 +1407,15 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct rtw_adapter *padapter,
        int ret = 0;
        uint wps_ielen = 0;
        u8 *wps_ie;
-#ifdef CONFIG_8723AU_P2P
-       u32 p2p_ielen = 0;
-       u8 *p2p_ie;
-       u32 wfd_ielen = 0;
-#endif
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
-#ifdef CONFIG_DEBUG_CFG80211
        DBG_8723A("%s, ielen =%d\n", __func__, len);
-#endif
 
        if (len > 0) {
                wps_ie = rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen);
                if (wps_ie) {
-#ifdef CONFIG_DEBUG_CFG80211
                        DBG_8723A("probe_req_wps_ielen =%d\n", wps_ielen);
-#endif
+
                        if (pmlmepriv->wps_probe_req_ie) {
                                pmlmepriv->wps_probe_req_ie_len = 0;
                                kfree(pmlmepriv->wps_probe_req_ie);
@@ -1528,60 +1432,6 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct rtw_adapter *padapter,
                        memcpy(pmlmepriv->wps_probe_req_ie, wps_ie, wps_ielen);
                        pmlmepriv->wps_probe_req_ie_len = wps_ielen;
                }
-#ifdef CONFIG_8723AU_P2P
-               p2p_ie = rtw_get_p2p_ie23a(buf, len, NULL, &p2p_ielen);
-               if (p2p_ie) {
-#ifdef CONFIG_DEBUG_CFG80211
-                       DBG_8723A("probe_req_p2p_ielen =%d\n", p2p_ielen);
-#endif
-
-                       if (pmlmepriv->p2p_probe_req_ie) {
-                               pmlmepriv->p2p_probe_req_ie_len = 0;
-                               kfree(pmlmepriv->p2p_probe_req_ie);
-                               pmlmepriv->p2p_probe_req_ie = NULL;
-                       }
-
-                       pmlmepriv->p2p_probe_req_ie =
-                               kmalloc(p2p_ielen, GFP_KERNEL);
-                       if (pmlmepriv->p2p_probe_req_ie == NULL) {
-                               DBG_8723A("%s()-%d: kmalloc() ERROR!\n",
-                                         __func__, __LINE__);
-                               return -EINVAL;
-
-                       }
-                       memcpy(pmlmepriv->p2p_probe_req_ie, p2p_ie, p2p_ielen);
-                       pmlmepriv->p2p_probe_req_ie_len = p2p_ielen;
-               }
-#endif /* CONFIG_8723AU_P2P */
-
-               /* buf += p2p_ielen; */
-               /* len -= p2p_ielen; */
-
-#ifdef CONFIG_8723AU_P2P
-               if (rtw_get_wfd_ie(buf, len, NULL, &wfd_ielen)) {
-#ifdef CONFIG_DEBUG_CFG80211
-                       DBG_8723A("probe_req_wfd_ielen =%d\n", wfd_ielen);
-#endif
-
-                       if (pmlmepriv->wfd_probe_req_ie) {
-                               pmlmepriv->wfd_probe_req_ie_len = 0;
-                               kfree(pmlmepriv->wfd_probe_req_ie);
-                               pmlmepriv->wfd_probe_req_ie = NULL;
-                       }
-
-                       pmlmepriv->wfd_probe_req_ie =
-                               kmalloc(wfd_ielen, GFP_KERNEL);
-                       if (pmlmepriv->wfd_probe_req_ie == NULL) {
-                               DBG_8723A("%s()-%d: kmalloc() ERROR!\n",
-                                         __func__, __LINE__);
-                               return -EINVAL;
-
-                       }
-                       rtw_get_wfd_ie(buf, len, pmlmepriv->wfd_probe_req_ie,
-                                      &pmlmepriv->wfd_probe_req_ie_len);
-               }
-#endif /* CONFIG_8723AU_P2P */
-
        }
 
        return ret;
@@ -1599,25 +1449,16 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy,
        struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT];
        struct rtw_wdev_priv *pwdev_priv = wdev_to_priv(padapter->rtw_wdev);
        struct cfg80211_ssid *ssids = request->ssids;
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       int social_channel = 0;
-#endif /* CONFIG_8723AU_P2P */
        bool need_indicate_scan_done = false;
 
-#ifdef CONFIG_DEBUG_CFG80211
        DBG_8723A(FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(padapter));
-#endif
 
        spin_lock_bh(&pwdev_priv->scan_req_lock);
        pwdev_priv->scan_request = request;
        spin_unlock_bh(&pwdev_priv->scan_req_lock);
 
        if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
-
-#ifdef CONFIG_DEBUG_CFG80211
                DBG_8723A("%s under WIFI_AP_STATE\n", __func__);
-#endif
                /* need_indicate_scan_done = true; */
                /* goto check_need_indicate_scan_done; */
        }
@@ -1626,29 +1467,6 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy,
                need_indicate_scan_done = true;
                goto check_need_indicate_scan_done;
        }
-#ifdef CONFIG_8723AU_P2P
-       if (!memcmp(ssids->ssid, "DIRECT-", 7) &&
-           rtw_get_p2p_ie23a((u8 *) request->ie, request->ie_len, NULL, NULL)) {
-               if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {
-                       rtw_p2p_enable23a(padapter, P2P_ROLE_DEVICE);
-                       wdev_to_priv(padapter->rtw_wdev)->p2p_enabled = true;
-               } else {
-                       rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo));
-#ifdef CONFIG_DEBUG_CFG80211
-                       DBG_8723A("%s, role =%d, p2p_state =%d\n", __func__,
-                                 rtw_p2p_role(pwdinfo),
-                                 rtw_p2p_state(pwdinfo));
-#endif
-               }
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN);
-
-               if (request->n_channels == 3 &&
-                   request->channels[0]->hw_value == 1 &&
-                   request->channels[1]->hw_value == 6 &&
-                   request->channels[2]->hw_value == 11)
-                       social_channel = 1;
-       }
-#endif /* CONFIG_8723AU_P2P */
 
        if (request->ie && request->ie_len > 0) {
                rtw_cfg80211_set_probe_req_wpsp2pie(padapter,
@@ -1674,28 +1492,12 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy,
                need_indicate_scan_done = true;
                goto check_need_indicate_scan_done;
        }
-#ifdef CONFIG_8723AU_P2P
-       if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) &&
-           !rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE)) {
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH);
-               rtw_free_network_queue23a(padapter, true);
-
-               if (social_channel == 0)
-                       rtw_p2p_findphase_ex_set(pwdinfo,
-                                                P2P_FINDPHASE_EX_NONE);
-               else
-                       rtw_p2p_findphase_ex_set(pwdinfo,
-                                                P2P_FINDPHASE_EX_SOCIAL_LAST);
-       }
-#endif /* CONFIG_8723AU_P2P */
 
        memset(ssid, 0, sizeof(struct cfg80211_ssid) * RTW_SSID_SCAN_AMOUNT);
        /* parsing request ssids, n_ssids */
        for (i = 0; i < request->n_ssids && i < RTW_SSID_SCAN_AMOUNT; i++) {
-#ifdef CONFIG_DEBUG_CFG80211
                DBG_8723A("ssid =%s, len =%d\n", ssids[i].ssid,
                          ssids[i].ssid_len);
-#endif
                memcpy(ssid[i].ssid, ssids[i].ssid, ssids[i].ssid_len);
                ssid[i].ssid_len = ssids[i].ssid_len;
        }
@@ -1707,11 +1509,9 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy,
        if (request->n_channels == 1) {
                for (i = 0; i < request->n_channels &&
                     i < RTW_CHANNEL_SCAN_AMOUNT; i++) {
-#ifdef CONFIG_DEBUG_CFG80211
                        DBG_8723A(FUNC_ADPT_FMT CHAN_FMT "\n",
                                  FUNC_ADPT_ARG(padapter),
                                  CHAN_ARG(request->channels[i]));
-#endif
                        ch[i].hw_value = request->channels[i]->hw_value;
                        ch[i].flags = request->channels[i]->flags;
                }
@@ -1877,13 +1677,10 @@ static int rtw_cfg80211_set_key_mgt(struct security_priv *psecuritypriv,
 static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie,
                                   size_t ielen)
 {
-       u8 *buf = NULL, *pos = NULL;
+       u8 *buf = NULL;
        int group_cipher = 0, pairwise_cipher = 0;
        int ret = 0;
-       int wpa_ielen = 0;
-       int wpa2_ielen = 0;
-       u8 *pwpa, *pwpa2;
-       u8 null_addr[] = { 0, 0, 0, 0, 0, 0 };
+       const u8 *pwpa, *pwpa2;
        int i;
 
        if (!pie || !ielen) {
@@ -1910,7 +1707,6 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie,
                          buf[i], buf[i + 1],
                          buf[i + 2], buf[i + 3], buf[i + 4],
                          buf[i + 5], buf[i + 6], buf[i + 7]);
-       pos = buf;
        if (ielen < RSN_HEADER_LEN) {
                RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_,
                         ("Ie len too short %d\n", (int)ielen));
@@ -1918,33 +1714,35 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie,
                goto exit;
        }
 
-       pwpa = rtw_get_wpa_ie23a(buf, &wpa_ielen, ielen);
-       if (pwpa && wpa_ielen > 0) {
-               if (rtw_parse_wpa_ie23a(pwpa, wpa_ielen + 2, &group_cipher,
-                                    &pairwise_cipher, NULL) == _SUCCESS) {
+       pwpa = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
+                                      WLAN_OUI_TYPE_MICROSOFT_WPA,
+                                      buf, ielen);
+       if (pwpa && pwpa[1] > 0) {
+               if (rtw_parse_wpa_ie23a(pwpa, pwpa[1] + 2, &group_cipher,
+                                       &pairwise_cipher, NULL) == _SUCCESS) {
                        padapter->securitypriv.dot11AuthAlgrthm =
                                dot11AuthAlgrthm_8021X;
                        padapter->securitypriv.ndisauthtype =
                                Ndis802_11AuthModeWPAPSK;
-                       memcpy(padapter->securitypriv.supplicant_ie, &pwpa[0],
-                              wpa_ielen + 2);
+                       memcpy(padapter->securitypriv.supplicant_ie, pwpa,
+                              pwpa[1] + 2);
 
-                       DBG_8723A("got wpa_ie, wpa_ielen:%u\n", wpa_ielen);
+                       DBG_8723A("got wpa_ie, wpa_ielen:%u\n", pwpa[1]);
                }
        }
 
-       pwpa2 = rtw_get_wpa2_ie23a(buf, &wpa2_ielen, ielen);
-       if (pwpa2 && wpa2_ielen > 0) {
-               if (rtw_parse_wpa2_ie23a (pwpa2, wpa2_ielen + 2, &group_cipher,
-                                      &pairwise_cipher, NULL) == _SUCCESS) {
+       pwpa2 = cfg80211_find_ie(WLAN_EID_RSN, buf, ielen);
+       if (pwpa2 && pwpa2[1] > 0) {
+               if (rtw_parse_wpa2_ie23a (pwpa2, pwpa2[1] + 2, &group_cipher,
+                                         &pairwise_cipher, NULL) == _SUCCESS) {
                        padapter->securitypriv.dot11AuthAlgrthm =
                                dot11AuthAlgrthm_8021X;
                        padapter->securitypriv.ndisauthtype =
                                Ndis802_11AuthModeWPA2PSK;
-                       memcpy(padapter->securitypriv.supplicant_ie, &pwpa2[0],
-                              wpa2_ielen + 2);
+                       memcpy(padapter->securitypriv.supplicant_ie, pwpa2,
+                              pwpa2[1] + 2);
 
-                       DBG_8723A("got wpa2_ie, wpa2_ielen:%u\n", wpa2_ielen);
+                       DBG_8723A("got wpa2_ie, wpa2_ielen:%u\n", pwpa2[1]);
                }
        }
 
@@ -2029,75 +1827,13 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie,
                }
        }
 
-#ifdef CONFIG_8723AU_P2P
-       {                       /* check p2p_ie for assoc req; */
-               uint p2p_ielen = 0;
-               u8 *p2p_ie;
-               struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-               p2p_ie = rtw_get_p2p_ie23a(buf, ielen, NULL, &p2p_ielen);
-               if (p2p_ie) {
-#ifdef CONFIG_DEBUG_CFG80211
-                       DBG_8723A("%s p2p_assoc_req_ielen =%d\n", __func__,
-                                 p2p_ielen);
-#endif
-
-                       if (pmlmepriv->p2p_assoc_req_ie) {
-                               pmlmepriv->p2p_assoc_req_ie_len = 0;
-                               kfree(pmlmepriv->p2p_assoc_req_ie);
-                               pmlmepriv->p2p_assoc_req_ie = NULL;
-                       }
-
-                       pmlmepriv->p2p_assoc_req_ie =
-                               kmalloc(p2p_ielen, GFP_KERNEL);
-                       if (pmlmepriv->p2p_assoc_req_ie == NULL) {
-                               DBG_8723A("%s()-%d: kmalloc() ERROR!\n",
-                                         __func__, __LINE__);
-                               goto exit;
-                       }
-                       memcpy(pmlmepriv->p2p_assoc_req_ie, p2p_ie, p2p_ielen);
-                       pmlmepriv->p2p_assoc_req_ie_len = p2p_ielen;
-               }
-       }
-#endif /* CONFIG_8723AU_P2P */
-
-#ifdef CONFIG_8723AU_P2P
-       {                       /* check wfd_ie for assoc req; */
-               uint wfd_ielen = 0;
-               struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-               if (rtw_get_wfd_ie(buf, ielen, NULL, &wfd_ielen)) {
-#ifdef CONFIG_DEBUG_CFG80211
-                       DBG_8723A("%s wfd_assoc_req_ielen =%d\n", __func__,
-                                 wfd_ielen);
-#endif
-
-                       if (pmlmepriv->wfd_assoc_req_ie) {
-                               pmlmepriv->wfd_assoc_req_ie_len = 0;
-                               kfree(pmlmepriv->wfd_assoc_req_ie);
-                               pmlmepriv->wfd_assoc_req_ie = NULL;
-                       }
-
-                       pmlmepriv->wfd_assoc_req_ie =
-                               kmalloc(wfd_ielen, GFP_KERNEL);
-                       if (pmlmepriv->wfd_assoc_req_ie == NULL) {
-                               DBG_8723A("%s()-%d: kmalloc() ERROR!\n",
-                                         __func__, __LINE__);
-                               goto exit;
-                       }
-                       rtw_get_wfd_ie(buf, ielen, pmlmepriv->wfd_assoc_req_ie,
-                                      &pmlmepriv->wfd_assoc_req_ie_len);
-               }
-       }
-#endif /* CONFIG_8723AU_P2P */
-
        /* TKIP and AES disallow multicast packets until installing group key */
        if (padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_ ||
            padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_WTMIC_ ||
            padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)
                /* WPS open need to enable multicast */
                /* check_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS) == true)*/
-               rtw_hal_set_hwreg23a(padapter, HW_VAR_OFF_RCR_AM, null_addr);
+               rtl8723a_off_rcr_am(padapter);
 
        RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_,
                 ("rtw_set_wpa_ie: pairwise_cipher = 0x%08x padapter->"
@@ -2513,8 +2249,7 @@ static int cfg80211_rtw_del_pmksa(struct wiphy *wiphy,
                if (!memcmp(psecuritypriv->PMKIDList[index].Bssid,
                            pmksa->bssid, ETH_ALEN)) {
                        /* BSSID is matched, the same AP => Remove this PMKID information and reset it. */
-                       memset(psecuritypriv->PMKIDList[index].Bssid, 0x00,
-                              ETH_ALEN);
+                       eth_zero_addr(psecuritypriv->PMKIDList[index].Bssid);
                        memset(psecuritypriv->PMKIDList[index].PMKID, 0x00,
                               WLAN_PMKID_LEN);
                        psecuritypriv->PMKIDList[index].bUsed = false;
@@ -2597,7 +2332,7 @@ void rtw_cfg80211_indicate_sta_disassoc(struct rtw_adapter *padapter,
        u8 *pmgmt_frame;
        uint frame_len;
        struct ieee80211_hdr *pwlanhdr;
-       unsigned short *fctrl;
+       __le16 *fctrl;
        u8 mgmt_buf[128] = { 0 };
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
@@ -2739,9 +2474,6 @@ static int rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb,
                struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
                u32 len = skb->len;
                u8 category, action;
-#ifdef CONFIG_8723AU_P2P
-               int type = -1;
-#endif
 
                if (rtw_action_frame_parse23a(skb->data, len, &category,
                                           &action) == false) {
@@ -2753,19 +2485,12 @@ static int rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb,
 
                DBG_8723A("RTW_Tx:da =" MAC_FMT " via " FUNC_NDEV_FMT "\n",
                          MAC_ARG(dot11_hdr->addr1), FUNC_NDEV_ARG(ndev));
-#ifdef CONFIG_8723AU_P2P
-               type = rtw_p2p_check_frames(padapter, skb->data, len, true);
-               if (type >= 0)
-                       goto dump;
-#endif
                if (category == WLAN_CATEGORY_PUBLIC)
                        DBG_8723A("RTW_Tx:%s\n", action_public_str23a(action));
                else
                        DBG_8723A("RTW_Tx:category(%u), action(%u)\n", category,
                                  action);
-#ifdef CONFIG_8723AU_P2P
-dump:
-#endif
+
                /* starting alloc mgmt frame to dump it */
                pmgntframe = alloc_mgtxmitframe23a(pxmitpriv);
                if (pmgntframe == NULL)
@@ -2781,16 +2506,6 @@ dump:
                pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
 
                memcpy(pframe, skb->data, len);
-#ifdef CONFIG_8723AU_P2P
-               if (type >= 0) {
-                       struct wifi_display_info *pwfd_info;
-
-                       pwfd_info = padapter->wdinfo.wfd_info;
-
-                       if (pwfd_info->wfd_enable)
-                               rtw_append_wfd_ie(padapter, pframe, &len);
-               }
-#endif /*  CONFIG_8723AU_P2P */
                pattrib->pktlen = len;
 
                /* update seq number */
@@ -2976,10 +2691,6 @@ static int rtw_add_beacon(struct rtw_adapter *adapter, const u8 *head,
        int ret = 0;
        u8 *pbuf = NULL;
        uint len, wps_ielen = 0;
-#ifdef CONFIG_8723AU_P2P
-       uint p2p_ielen = 0;
-       u8 got_p2p_ie = false;
-#endif
        struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
        /* struct sta_priv *pstapriv = &padapter->stapriv; */
 
@@ -3007,55 +2718,14 @@ static int rtw_add_beacon(struct rtw_adapter *adapter, const u8 *head,
             &wps_ielen))
                DBG_8723A("add bcn, wps_ielen =%d\n", wps_ielen);
 
-#ifdef CONFIG_8723AU_P2P
-       /* check p2p ie if inclued */
-       if (rtw_get_p2p_ie23a
-           (pbuf + _FIXED_IE_LENGTH_, len - _FIXED_IE_LENGTH_, NULL,
-            &p2p_ielen)) {
-               DBG_8723A("got p2p_ie, len =%d\n", p2p_ielen);
-               got_p2p_ie = true;
-       }
-#endif
-
        /* pbss_network->IEs will not include p2p_ie, wfd ie */
-       rtw_ies_remove_ie23a(pbuf, &len, _BEACON_IE_OFFSET_, _VENDOR_SPECIFIC_IE_,
-                         P2P_OUI23A, 4);
-       rtw_ies_remove_ie23a(pbuf, &len, _BEACON_IE_OFFSET_, _VENDOR_SPECIFIC_IE_,
-                         WFD_OUI23A, 4);
+       rtw_ies_remove_ie23a(pbuf, &len, _BEACON_IE_OFFSET_,
+                            WLAN_EID_VENDOR_SPECIFIC, P2P_OUI23A, 4);
+       rtw_ies_remove_ie23a(pbuf, &len, _BEACON_IE_OFFSET_,
+                            WLAN_EID_VENDOR_SPECIFIC, WFD_OUI23A, 4);
 
        if (rtw_check_beacon_data23a(adapter, pbuf, len) == _SUCCESS) {
-#ifdef CONFIG_8723AU_P2P
-               /* check p2p if enable */
-               if (got_p2p_ie == true) {
-                       struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv;
-                       struct wifidirect_info *pwdinfo = &adapter->wdinfo;
-
-                       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {
-                               DBG_8723A("Enable P2P function for the first "
-                                         "time\n");
-                               rtw_p2p_enable23a(adapter, P2P_ROLE_GO);
-                               wdev_to_priv(adapter->rtw_wdev)->p2p_enabled =
-                                       true;
-                       } else {
-                               del_timer_sync(&pwdinfo->find_phase_timer);
-                               del_timer_sync(&pwdinfo->
-                                              restore_p2p_state_timer);
-                               del_timer_sync(&pwdinfo->pre_tx_scan_timer);
-
-                               DBG_8723A("enter GO Mode, p2p_ielen =%d\n",
-                                         p2p_ielen);
-
-                               rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO);
-                               rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK);
-                               pwdinfo->intent = 15;
-                       }
-
-                       pwdinfo->operating_channel = pmlmeext->cur_channel;
-               }
-#endif /* CONFIG_8723AU_P2P */
-
                ret = 0;
-
        } else {
                ret = -EINVAL;
        }
@@ -3252,9 +2922,6 @@ static int cfg80211_rtw_change_bss(struct wiphy *wiphy, struct net_device *ndev,
 void rtw_cfg80211_rx_action_p2p(struct rtw_adapter *padapter, u8 *pmgmt_frame,
                                uint frame_len)
 {
-#ifdef CONFIG_8723AU_P2P
-       int type;
-#endif
        s32 freq;
        int channel;
        u8 category, action;
@@ -3262,17 +2929,9 @@ void rtw_cfg80211_rx_action_p2p(struct rtw_adapter *padapter, u8 *pmgmt_frame,
        channel = rtw_get_oper_ch23a(padapter);
 
        DBG_8723A("RTW_Rx:cur_ch =%d\n", channel);
-#ifdef CONFIG_8723AU_P2P
-       type = rtw_p2p_check_frames(padapter, pmgmt_frame, frame_len, false);
-       if (type >= 0)
-               goto indicate;
-#endif
        rtw_action_frame_parse23a(pmgmt_frame, frame_len, &category, &action);
        DBG_8723A("RTW_Rx:category(%u), action(%u)\n", category, action);
 
-#ifdef CONFIG_8723AU_P2P
-indicate:
-#endif
        if (channel <= RTW_CH_MAX_2G_CHANNEL)
                freq = ieee80211_channel_to_frequency(channel,
                                                      IEEE80211_BAND_2GHZ);
@@ -3287,9 +2946,6 @@ indicate:
 void rtw_cfg80211_rx_p2p_action_public(struct rtw_adapter *padapter,
                                       u8 *pmgmt_frame, uint frame_len)
 {
-#ifdef CONFIG_8723AU_P2P
-       int type;
-#endif
        s32 freq;
        int channel;
        u8 category, action;
@@ -3297,23 +2953,9 @@ void rtw_cfg80211_rx_p2p_action_public(struct rtw_adapter *padapter,
        channel = rtw_get_oper_ch23a(padapter);
 
        DBG_8723A("RTW_Rx:cur_ch =%d\n", channel);
-#ifdef CONFIG_8723AU_P2P
-       type = rtw_p2p_check_frames(padapter, pmgmt_frame, frame_len, false);
-       if (type >= 0) {
-               switch (type) {
-               case P2P_GO_NEGO_CONF:
-               case P2P_PROVISION_DISC_RESP:
-                       rtw_clear_scan_deny(padapter);
-               }
-               goto indicate;
-       }
-#endif
        rtw_action_frame_parse23a(pmgmt_frame, frame_len, &category, &action);
        DBG_8723A("RTW_Rx:category(%u), action(%u)\n", category, action);
 
-#ifdef CONFIG_8723AU_P2P
-indicate:
-#endif
        if (channel <= RTW_CH_MAX_2G_CHANNEL)
                freq = ieee80211_channel_to_frequency(channel,
                                                      IEEE80211_BAND_2GHZ);
@@ -3353,350 +2995,6 @@ void rtw_cfg80211_rx_action(struct rtw_adapter *adapter, u8 *frame,
        rtw_cfg80211_rx_mgmt(adapter, freq, 0, frame, frame_len, GFP_ATOMIC);
 }
 
-#ifdef CONFIG_8723AU_P2P
-void rtw_cfg80211_issue_p2p_provision_request23a(struct rtw_adapter *padapter,
-                                             const u8 *buf, size_t len)
-{
-       u16 wps_devicepassword_id = 0x0000;
-       uint wps_devicepassword_id_len = 0;
-       u8 wpsie[255] = { 0x00 }, p2p_ie[255] = { 0x00 };
-       uint p2p_ielen = 0;
-       uint wpsielen = 0;
-       u32 devinfo_contentlen = 0;
-       u8 devinfo_content[64] = { 0x00 };
-       u16 capability = 0;
-       uint capability_len = 0;
-
-       unsigned char category = WLAN_CATEGORY_PUBLIC;
-       u8 action = P2P_PUB_ACTION_ACTION;
-       u8 dialogToken = 1;
-       u32 p2poui = cpu_to_be32(P2POUI);
-       u8 oui_subtype = P2P_PROVISION_DISC_REQ;
-       u32 p2pielen = 0;
-#ifdef CONFIG_8723AU_P2P
-       u32 wfdielen = 0;
-#endif /* CONFIG_8723AU_P2P */
-
-       struct xmit_frame *pmgntframe;
-       struct pkt_attrib *pattrib;
-       unsigned char *pframe;
-       struct ieee80211_hdr *pwlanhdr, *hdr;
-       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       u8 *frame_body =
-           (unsigned char *)(buf + sizeof(struct ieee80211_hdr_3addr));
-       size_t frame_body_len = len - sizeof(struct ieee80211_hdr_3addr);
-
-       DBG_8723A("[%s] In\n", __func__);
-
-       hdr = (struct ieee80211_hdr *)buf;
-       /* prepare for building provision_request frame */
-       memcpy(pwdinfo->tx_prov_disc_info.peerIFAddr, hdr->addr1, ETH_ALEN);
-       memcpy(pwdinfo->tx_prov_disc_info.peerDevAddr, hdr->addr1, ETH_ALEN);
-
-       pwdinfo->tx_prov_disc_info.wps_config_method_request =
-           WPS_CM_PUSH_BUTTON;
-
-       rtw_get_wps_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_,
-                      frame_body_len - _PUBLIC_ACTION_IE_OFFSET_, wpsie,
-                      &wpsielen);
-       rtw_get_wps_attr_content23a(wpsie, wpsielen, WPS_ATTR_DEVICE_PWID,
-                                   (u8 *)&wps_devicepassword_id,
-                                   &wps_devicepassword_id_len);
-       wps_devicepassword_id = be16_to_cpu(wps_devicepassword_id);
-
-       switch (wps_devicepassword_id) {
-       case WPS_DPID_PIN:
-               pwdinfo->tx_prov_disc_info.wps_config_method_request =
-                       WPS_CM_LABEL;
-               break;
-       case WPS_DPID_USER_SPEC:
-               pwdinfo->tx_prov_disc_info.wps_config_method_request =
-                       WPS_CM_DISPLYA;
-               break;
-       case WPS_DPID_MACHINE_SPEC:
-               break;
-       case WPS_DPID_REKEY:
-               break;
-       case WPS_DPID_PBC:
-               pwdinfo->tx_prov_disc_info.wps_config_method_request =
-                       WPS_CM_PUSH_BUTTON;
-               break;
-       case WPS_DPID_REGISTRAR_SPEC:
-               pwdinfo->tx_prov_disc_info.wps_config_method_request =
-                       WPS_CM_KEYPAD;
-               break;
-       default:
-               break;
-       }
-
-       if (rtw_get_p2p_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_,
-                          frame_body_len - _PUBLIC_ACTION_IE_OFFSET_,
-                          p2p_ie, &p2p_ielen)) {
-               rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen,
-                                        P2P_ATTR_DEVICE_INFO, devinfo_content,
-                                        &devinfo_contentlen);
-               rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_CAPABILITY,
-                                        (u8 *)&capability, &capability_len);
-       }
-
-       /* start to build provision_request frame */
-       memset(wpsie, 0, sizeof(wpsie));
-       memset(p2p_ie, 0, sizeof(p2p_ie));
-       p2p_ielen = 0;
-
-       pmgntframe = alloc_mgtxmitframe23a(pxmitpriv);
-       if (pmgntframe == NULL)
-               return;
-       /* update attribute */
-       pattrib = &pmgntframe->attrib;
-       update_mgntframe_attrib23a(padapter, pattrib);
-
-       memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);
-
-       pframe = (u8 *) (pmgntframe->buf_addr) + TXDESC_OFFSET;
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       pwlanhdr->frame_control = 0;
-
-       memcpy(pwlanhdr->addr1, pwdinfo->tx_prov_disc_info.peerDevAddr,
-              ETH_ALEN);
-       memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
-       memcpy(pwlanhdr->addr3, pwdinfo->tx_prov_disc_info.peerDevAddr,
-              ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
-       pmlmeext->mgnt_seq++;
-       SetFrameSubType(pframe, WIFI_ACTION);
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
-
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *)&p2poui,
-                                 &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen);
-       pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen);
-
-       /* build_prov_disc_request_p2p_ie23a */
-       /*      P2P OUI */
-       p2pielen = 0;
-       p2p_ie[p2pielen++] = 0x50;
-       p2p_ie[p2pielen++] = 0x6F;
-       p2p_ie[p2pielen++] = 0x9A;
-       p2p_ie[p2pielen++] = 0x09;      /*      WFA P2P v1.0 */
-
-       /*      Commented by Albert 20110301 */
-       /*      According to the P2P Specification, the provision discovery request frame should contain 3 P2P attributes */
-       /*      1. P2P Capability */
-       /*      2. Device Info */
-       /*      3. Group ID ( When joining an operating P2P Group ) */
-
-       /*      P2P Capability ATTR */
-       /*      Type: */
-       p2p_ie[p2pielen++] = P2P_ATTR_CAPABILITY;
-
-       /*      Length: */
-       put_unaligned_le16(0x0002, p2p_ie + p2pielen);
-       p2pielen += 2;
-
-       /*      Value: */
-       /*      Device Capability Bitmap, 1 byte */
-       /*      Group Capability Bitmap, 1 byte */
-       memcpy(p2p_ie + p2pielen, &capability, 2);
-       p2pielen += 2;
-
-       /*      Device Info ATTR */
-       /*      Type: */
-       p2p_ie[p2pielen++] = P2P_ATTR_DEVICE_INFO;
-
-       /*      Length: */
-       put_unaligned_le16(devinfo_contentlen, p2p_ie + p2pielen);
-       p2pielen += 2;
-
-       /*      Value: */
-       memcpy(p2p_ie + p2pielen, devinfo_content, devinfo_contentlen);
-       p2pielen += devinfo_contentlen;
-
-       pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen,
-                           (unsigned char *)p2p_ie, &p2p_ielen);
-       pattrib->pktlen += p2p_ielen;
-
-       wpsielen = 0;
-       /*      WPS OUI */
-       *(u32 *)(wpsie) = cpu_to_be32(WPSOUI);
-       wpsielen += 4;
-
-       /*      WPS version */
-       /*      Type: */
-       *(u16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(u16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001);
-       wpsielen += 2;
-
-       /*      Value: */
-       wpsie[wpsielen++] = WPS_VERSION_1;      /*      Version 1.0 */
-
-       /*      Config Method */
-       /*      Type: */
-       *(u16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD);
-       wpsielen += 2;
-
-       /*      Length: */
-       *(u16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002);
-       wpsielen += 2;
-
-       /*      Value: */
-       *(u16 *)(wpsie + wpsielen) =
-           cpu_to_be16(pwdinfo->tx_prov_disc_info.wps_config_method_request);
-       wpsielen += 2;
-
-       pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen,
-                           (unsigned char *)wpsie, &pattrib->pktlen);
-
-#ifdef CONFIG_8723AU_P2P
-       wfdielen = build_provdisc_req_wfd_ie(pwdinfo, pframe);
-       pframe += wfdielen;
-       pattrib->pktlen += wfdielen;
-#endif /* CONFIG_8723AU_P2P */
-
-       pattrib->last_txcmdsz = pattrib->pktlen;
-
-       /* dump_mgntframe23a(padapter, pmgntframe); */
-       if (dump_mgntframe23a_and_wait_ack23a(padapter, pmgntframe) != _SUCCESS)
-               DBG_8723A("%s, ack to\n", __func__);
-}
-
-static s32 cfg80211_rtw_remain_on_channel(struct wiphy *wiphy,
-                                         struct wireless_dev *wdev,
-                                         struct ieee80211_channel *channel,
-                                         unsigned int duration, u64 *cookie)
-{
-       s32 err = 0;
-       struct rtw_adapter *padapter = wiphy_to_adapter(wiphy);
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       struct cfg80211_wifidirect_info *pcfg80211_wdinfo =
-           &padapter->cfg80211_wdinfo;
-       u8 remain_ch =
-               (u8) ieee80211_frequency_to_channel(channel->center_freq);
-       u8 ready_on_channel = false;
-
-       DBG_8723A(FUNC_ADPT_FMT " ch:%u duration:%d\n", FUNC_ADPT_ARG(padapter),
-                 remain_ch, duration);
-
-       if (pcfg80211_wdinfo->is_ro_ch == true) {
-               DBG_8723A("%s, cancel ro ch timer\n", __func__);
-
-               del_timer_sync(&padapter->cfg80211_wdinfo.remain_on_ch_timer);
-
-#ifdef CONFIG_8723AU_P2P
-               p2p_protocol_wk_hdl23a(padapter, P2P_RO_CH_WK);
-#endif
-       }
-
-       pcfg80211_wdinfo->is_ro_ch = true;
-
-       if (_FAIL == rtw_pwr_wakeup(padapter)) {
-               err = -EFAULT;
-               goto exit;
-       }
-
-       memcpy(&pcfg80211_wdinfo->remain_on_ch_channel, channel,
-              sizeof(struct ieee80211_channel));
-       pcfg80211_wdinfo->remain_on_ch_cookie = *cookie;
-
-       rtw_scan_abort23a(padapter);
-       if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {
-               rtw_p2p_enable23a(padapter, P2P_ROLE_DEVICE);
-               wdev_to_priv(padapter->rtw_wdev)->p2p_enabled = true;
-       } else {
-               rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo));
-#ifdef CONFIG_DEBUG_CFG80211
-               DBG_8723A("%s, role =%d, p2p_state =%d\n", __func__,
-                         rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo));
-#endif
-       }
-
-       rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN);
-
-       if (duration < 400)
-               duration = duration * 3;        /* extend from exper. */
-
-       pcfg80211_wdinfo->restore_channel = pmlmeext->cur_channel;
-
-       if (rtw_ch_set_search_ch23a(pmlmeext->channel_set, remain_ch) >= 0) {
-               if (remain_ch != pmlmeext->cur_channel) {
-                       ready_on_channel = true;
-               }
-       } else {
-               DBG_8723A("%s remain_ch:%u not in channel plan!!!!\n",
-                         __func__, remain_ch);
-       }
-
-       /* call this after other things have been done */
-       if (ready_on_channel == true) {
-               if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) {
-                       pmlmeext->cur_channel = remain_ch;
-
-                       set_channel_bwmode23a(padapter, remain_ch,
-                                          HAL_PRIME_CHNL_OFFSET_DONT_CARE,
-                                          HT_CHANNEL_WIDTH_20);
-               }
-       }
-       DBG_8723A("%s, set ro ch timer, duration =%d\n", __func__, duration);
-       mod_timer(&pcfg80211_wdinfo->remain_on_ch_timer,
-                 jiffies + msecs_to_jiffies(duration));
-
-       rtw_cfg80211_ready_on_channel(padapter, *cookie, channel, channel_type,
-                                     duration, GFP_KERNEL);
-
-       pwdinfo->listen_channel = pmlmeext->cur_channel;
-
-exit:
-       if (err)
-               pcfg80211_wdinfo->is_ro_ch = false;
-
-       return err;
-}
-
-static s32 cfg80211_rtw_cancel_remain_on_channel(struct wiphy *wiphy,
-                                                struct wireless_dev *wdev,
-                                                u64 cookie)
-{
-       s32 err = 0;
-       struct rtw_adapter *padapter = wiphy_to_adapter(wiphy);
-       struct wifidirect_info *pwdinfo = &padapter->wdinfo;
-       struct cfg80211_wifidirect_info *pcfg80211_wdinfo =
-           &padapter->cfg80211_wdinfo;
-
-       DBG_8723A(FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(padapter));
-
-       if (pcfg80211_wdinfo->is_ro_ch == true) {
-               DBG_8723A("%s, cancel ro ch timer\n", __func__);
-               del_timer_sync(&padapter->cfg80211_wdinfo.remain_on_ch_timer);
-#ifdef CONFIG_8723AU_P2P
-               p2p_protocol_wk_hdl23a(padapter, P2P_RO_CH_WK);
-#endif
-       }
-
-       rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo));
-#ifdef CONFIG_DEBUG_CFG80211
-       DBG_8723A("%s, role =%d, p2p_state =%d\n", __func__,
-                 rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo));
-#endif
-       pcfg80211_wdinfo->is_ro_ch = false;
-
-       return err;
-}
-
-#endif /* CONFIG_8723AU_P2P */
-
 static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch,
                                 const u8 *buf, size_t len)
 {
@@ -3708,7 +3006,6 @@ static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch,
        struct ieee80211_hdr *pwlanhdr;
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       /* struct cfg80211_wifidirect_info *pcfg80211_wdinfo = &padapter->cfg80211_wdinfo; */
 
        if (_FAIL == rtw_pwr_wakeup(padapter)) {
                ret = -EFAULT;
@@ -3753,39 +3050,21 @@ static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch,
        pattrib->seqnum = pmlmeext->mgnt_seq;
        pmlmeext->mgnt_seq++;
 
-#ifdef CONFIG_8723AU_P2P
-       {
-               struct wifi_display_info *pwfd_info;
-
-               pwfd_info = padapter->wdinfo.wfd_info;
-
-               if (true == pwfd_info->wfd_enable) {
-                       rtw_append_wfd_ie(padapter, pframe, &pattrib->pktlen);
-               }
-       }
-#endif /*  CONFIG_8723AU_P2P */
-
        pattrib->last_txcmdsz = pattrib->pktlen;
 
        if (dump_mgntframe23a_and_wait_ack23a(padapter, pmgntframe) != _SUCCESS) {
                ack = false;
                ret = _FAIL;
 
-#ifdef CONFIG_DEBUG_CFG80211
                DBG_8723A("%s, ack == _FAIL\n", __func__);
-#endif
        } else {
-#ifdef CONFIG_DEBUG_CFG80211
                DBG_8723A("%s, ack =%d, ok!\n", __func__, ack);
-#endif
                ret = _SUCCESS;
        }
 
 exit:
 
-#ifdef CONFIG_DEBUG_CFG80211
        DBG_8723A("%s, ret =%d\n", __func__, ret);
-#endif
 
        return ret;
 }
@@ -3824,10 +3103,8 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
        /* cookie generation */
        *cookie = (unsigned long)buf;
 
-#ifdef CONFIG_DEBUG_CFG80211
        DBG_8723A(FUNC_ADPT_FMT " len =%zu, ch =%d"
                  "\n", FUNC_ADPT_ARG(padapter), len, tx_ch);
-#endif /* CONFIG_DEBUG_CFG80211 */
 
        /* indicate ack before issue frame to avoid racing with rsp frame */
        rtw_cfg80211_mgmt_tx_status(padapter, *cookie, buf, len, ack,
@@ -3842,20 +3119,12 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
 
        DBG_8723A("RTW_Tx:tx_ch =%d, da =" MAC_FMT "\n", tx_ch,
                  MAC_ARG(hdr->addr1));
-#ifdef CONFIG_8723AU_P2P
-       type = rtw_p2p_check_frames(padapter, buf, len, true);
-       if (type >= 0)
-               goto dump;
-#endif
        if (category == WLAN_CATEGORY_PUBLIC)
                DBG_8723A("RTW_Tx:%s\n", action_public_str23a(action));
        else
                DBG_8723A("RTW_Tx:category(%u), action(%u)\n",
                          category, action);
 
-#ifdef CONFIG_8723AU_P2P
-dump:
-#endif
        do {
                dump_cnt++;
                tx_ret = _cfg80211_rtw_mgmt_tx(padapter, tx_ch, buf, len);
@@ -3893,12 +3162,6 @@ static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy,
                                             struct wireless_dev *wdev,
                                             u16 frame_type, bool reg)
 {
-
-#ifdef CONFIG_DEBUG_CFG80211
-       DBG_8723A(FUNC_ADPT_FMT " frame_type:%x, reg:%d\n",
-                 FUNC_ADPT_ARG(adapter), frame_type, reg);
-#endif
-
        if (frame_type != (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ))
                return;
 
@@ -3911,11 +3174,6 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf,
        int ret = 0;
        uint wps_ielen = 0;
        u8 *wps_ie;
-#ifdef CONFIG_8723AU_P2P
-       u32 p2p_ielen = 0;
-       u32 wfd_ielen = 0;
-       u8 *p2p_ie;
-#endif
 #ifdef CONFIG_8723AU_AP_MODE
        u8 wps_oui[8] = { 0x0, 0x50, 0xf2, 0x04 };
 #endif
@@ -3928,9 +3186,7 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf,
        if (len > 0) {
                wps_ie = rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen);
                if (wps_ie) {
-#ifdef CONFIG_DEBUG_CFG80211
                        DBG_8723A("bcn_wps_ielen =%d\n", wps_ielen);
-#endif
 
                        if (pmlmepriv->wps_beacon_ie) {
                                pmlmepriv->wps_beacon_ie_len = 0;
@@ -3949,63 +3205,10 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf,
                        pmlmepriv->wps_beacon_ie_len = wps_ielen;
 
 #ifdef CONFIG_8723AU_AP_MODE
-                       update_beacon23a(padapter, _VENDOR_SPECIFIC_IE_, wps_oui,
-                                     true);
-#endif
-               }
-#ifdef CONFIG_8723AU_P2P
-               p2p_ie = rtw_get_p2p_ie23a(buf, len, NULL, &p2p_ielen);
-               if (p2p_ie) {
-#ifdef CONFIG_DEBUG_CFG80211
-                       DBG_8723A("bcn_p2p_ielen =%d\n", p2p_ielen);
-#endif
-
-                       if (pmlmepriv->p2p_beacon_ie) {
-                               pmlmepriv->p2p_beacon_ie_len = 0;
-                               kfree(pmlmepriv->p2p_beacon_ie);
-                               pmlmepriv->p2p_beacon_ie = NULL;
-                       }
-
-                       pmlmepriv->p2p_beacon_ie =
-                               kmalloc(p2p_ielen, GFP_KERNEL);
-                       if (pmlmepriv->p2p_beacon_ie == NULL) {
-                               DBG_8723A("%s()-%d: kmalloc() ERROR!\n",
-                                         __func__, __LINE__);
-                               return -EINVAL;
-                       }
-
-                       memcpy(pmlmepriv->p2p_beacon_ie, p2p_ie, p2p_ielen);
-                       pmlmepriv->p2p_beacon_ie_len = p2p_ielen;
-               }
-#endif /* CONFIG_8723AU_P2P */
-
-               /* buf += p2p_ielen; */
-               /* len -= p2p_ielen; */
-
-#ifdef CONFIG_8723AU_P2P
-               if (rtw_get_wfd_ie(buf, len, NULL, &wfd_ielen)) {
-#ifdef CONFIG_DEBUG_CFG80211
-                       DBG_8723A("bcn_wfd_ielen =%d\n", wfd_ielen);
+                       update_beacon23a(padapter, WLAN_EID_VENDOR_SPECIFIC,
+                                        wps_oui, true);
 #endif
-
-                       if (pmlmepriv->wfd_beacon_ie) {
-                               pmlmepriv->wfd_beacon_ie_len = 0;
-                               kfree(pmlmepriv->wfd_beacon_ie);
-                               pmlmepriv->wfd_beacon_ie = NULL;
-                       }
-
-                       pmlmepriv->wfd_beacon_ie =
-                               kmalloc(wfd_ielen, GFP_KERNEL);
-                       if (pmlmepriv->wfd_beacon_ie == NULL) {
-                               DBG_8723A("%s()-%d: kmalloc() ERROR!\n",
-                                         __func__, __LINE__);
-                               return -EINVAL;
-
-                       }
-                       rtw_get_wfd_ie(buf, len, pmlmepriv->wfd_beacon_ie,
-                                      &pmlmepriv->wfd_beacon_ie_len);
                }
-#endif /* CONFIG_8723AU_P2P */
 
                pmlmeext->bstart_bss = true;
 
@@ -4019,11 +3222,6 @@ static int rtw_cfg80211_set_probe_resp_wpsp2pie(struct net_device *net,
 {
        struct rtw_adapter *padapter = netdev_priv(net);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-#ifdef CONFIG_8723AU_P2P
-       u32 p2p_ielen = 0;
-       u8 *p2p_ie;
-       u32 wfd_ielen = 0;
-#endif
        int ret = 0;
        uint wps_ielen = 0;
        u8 *wps_ie;
@@ -4067,104 +3265,6 @@ static int rtw_cfg80211_set_probe_resp_wpsp2pie(struct net_device *net,
 
                }
 
-               /* buf += wps_ielen; */
-               /* len -= wps_ielen; */
-
-#ifdef CONFIG_8723AU_P2P
-               p2p_ie = rtw_get_p2p_ie23a(buf, len, NULL, &p2p_ielen);
-               if (p2p_ie) {
-                       u8 is_GO = false;
-                       u32 attr_contentlen = 0;
-                       u16 cap_attr = 0;
-
-#ifdef CONFIG_DEBUG_CFG80211
-                       DBG_8723A("probe_resp_p2p_ielen =%d\n", p2p_ielen);
-#endif
-
-                       /* Check P2P Capability ATTR */
-                       if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen,
-                                                    P2P_ATTR_CAPABILITY,
-                                                    (u8 *) &cap_attr,
-                                                    (uint *) &attr_contentlen)) {
-                               u8 grp_cap = 0;
-                               /* DBG_8723A( "[%s] Got P2P Capability Attr!!\n", __func__ ); */
-                               cap_attr = le16_to_cpu(cap_attr);
-                               grp_cap = (u8) ((cap_attr >> 8) & 0xff);
-
-                               is_GO = (grp_cap & BIT(0)) ? true : false;
-
-                               if (is_GO)
-                                       DBG_8723A
-                                           ("Got P2P Capability Attr, grp_cap"
-                                            "= 0x%x, is_GO\n", grp_cap);
-                       }
-
-                       if (is_GO == false) {
-                               if (pmlmepriv->p2p_probe_resp_ie) {
-                                       pmlmepriv->p2p_probe_resp_ie_len = 0;
-                                       kfree(pmlmepriv->p2p_probe_resp_ie);
-                                       pmlmepriv->p2p_probe_resp_ie = NULL;
-                               }
-
-                               pmlmepriv->p2p_probe_resp_ie =
-                                   kmalloc(p2p_ielen, GFP_KERNEL);
-                               if (pmlmepriv->p2p_probe_resp_ie == NULL) {
-                                       DBG_8723A("%s()-%d: kmalloc() ERROR!\n",
-                                                 __func__, __LINE__);
-                                       return -EINVAL;
-                               }
-                               memcpy(pmlmepriv->p2p_probe_resp_ie, p2p_ie,
-                                      p2p_ielen);
-                               pmlmepriv->p2p_probe_resp_ie_len = p2p_ielen;
-                       } else {
-                               if (pmlmepriv->p2p_go_probe_resp_ie) {
-                                       pmlmepriv->p2p_go_probe_resp_ie_len = 0;
-                                       kfree(pmlmepriv->p2p_go_probe_resp_ie);
-                                       pmlmepriv->p2p_go_probe_resp_ie = NULL;
-                               }
-
-                               pmlmepriv->p2p_go_probe_resp_ie =
-                                   kmalloc(p2p_ielen, GFP_KERNEL);
-                               if (pmlmepriv->p2p_go_probe_resp_ie == NULL) {
-                                       DBG_8723A("%s()-%d: kmalloc() ERROR!\n",
-                                                 __func__, __LINE__);
-                                       return -EINVAL;
-
-                               }
-                               memcpy(pmlmepriv->p2p_go_probe_resp_ie,
-                                      p2p_ie, p2p_ielen);
-                               pmlmepriv->p2p_go_probe_resp_ie_len = p2p_ielen;
-                       }
-               }
-#endif /* CONFIG_8723AU_P2P */
-
-               /* buf += p2p_ielen; */
-               /* len -= p2p_ielen; */
-
-#ifdef CONFIG_8723AU_P2P
-               if (rtw_get_wfd_ie(buf, len, NULL, &wfd_ielen)) {
-#ifdef CONFIG_DEBUG_CFG80211
-                       DBG_8723A("probe_resp_wfd_ielen =%d\n", wfd_ielen);
-#endif
-
-                       if (pmlmepriv->wfd_probe_resp_ie) {
-                               pmlmepriv->wfd_probe_resp_ie_len = 0;
-                               kfree(pmlmepriv->wfd_probe_resp_ie);
-                               pmlmepriv->wfd_probe_resp_ie = NULL;
-                       }
-
-                       pmlmepriv->wfd_probe_resp_ie =
-                           kmalloc(wfd_ielen, GFP_KERNEL);
-                       if (pmlmepriv->wfd_probe_resp_ie == NULL) {
-                               DBG_8723A("%s()-%d: kmalloc() ERROR!\n",
-                                         __func__, __LINE__);
-                               return -EINVAL;
-
-                       }
-                       rtw_get_wfd_ie(buf, len, pmlmepriv->wfd_probe_resp_ie,
-                                      &pmlmepriv->wfd_probe_resp_ie_len);
-               }
-#endif /* CONFIG_8723AU_P2P */
        }
 
        return ret;
@@ -4205,19 +3305,10 @@ int rtw_cfg80211_set_mgnt_wpsp2pie(struct net_device *net, char *buf, int len,
 {
        int ret = 0;
        uint wps_ielen = 0;
-#ifdef CONFIG_8723AU_P2P
-       u32 p2p_ielen = 0;
-#endif
 
-#ifdef CONFIG_DEBUG_CFG80211
        DBG_8723A("%s, ielen =%d\n", __func__, len);
-#endif
 
-       if ((rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen) && (wps_ielen > 0))
-#ifdef CONFIG_8723AU_P2P
-           || (rtw_get_p2p_ie23a(buf, len, NULL, &p2p_ielen) && (p2p_ielen > 0))
-#endif
-           ) {
+       if (rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen) && (wps_ielen > 0)) {
                if (net) {
                        switch (type) {
                        case 0x1:       /* BEACON */
@@ -4280,11 +3371,6 @@ static struct cfg80211_ops rtw_cfg80211_ops = {
        .change_bss = cfg80211_rtw_change_bss,
 #endif /* CONFIG_8723AU_AP_MODE */
 
-#ifdef CONFIG_8723AU_P2P
-       .remain_on_channel = cfg80211_rtw_remain_on_channel,
-       .cancel_remain_on_channel = cfg80211_rtw_cancel_remain_on_channel,
-#endif
-
        .mgmt_tx = cfg80211_rtw_mgmt_tx,
        .mgmt_frame_register = cfg80211_rtw_mgmt_frame_register,
 };
@@ -4348,7 +3434,7 @@ void rtw_cfg80211_init_wiphy(struct rtw_adapter *padapter)
        struct wireless_dev *pwdev = padapter->rtw_wdev;
        struct wiphy *wiphy = pwdev->wiphy;
 
-       rtw23a_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
+       rf_type = rtl8723a_get_rf_type(padapter);
 
        DBG_8723A("%s:rf_type =%d\n", __func__, rf_type);
 
@@ -4387,9 +3473,6 @@ static void rtw_cfg80211_preinit_wiphy(struct rtw_adapter *padapter,
            BIT(NL80211_IFTYPE_ADHOC) |
 #ifdef CONFIG_8723AU_AP_MODE
            BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) |
-#endif
-#if defined(CONFIG_8723AU_P2P)
-           BIT(NL80211_IFTYPE_P2P_CLIENT) | BIT(NL80211_IFTYPE_P2P_GO) |
 #endif
            0;
 
index b30d4d37556ab8d601e59c546856f4c869205ced..c0e79f56d2eb80be6f89fc820f4f7c8ad5fe76bd 100644 (file)
 #include <mlme_osdep.h>
 #include <rtw_ioctl_set.h>
 
-void rtw_os_indicate_connect23a(struct rtw_adapter *adapter)
-{
-       rtw_cfg80211_indicate_connect(adapter);
-
-       netif_carrier_on(adapter->pnetdev);
-
-       if (adapter->pid[2] != 0)
-               rtw_signal_process(adapter->pid[2], SIGALRM);
-}
-
-void rtw_os_indicate_scan_done23a(struct rtw_adapter *padapter, bool aborted)
-{
-       rtw_cfg80211_indicate_scan_done(wdev_to_priv(padapter->rtw_wdev),
-                                       aborted);
-}
-
 static struct rt_pmkid_list backupPMKIDList[NUM_PMKID_CACHE];
 
 void rtw_reset_securitypriv23a(struct rtw_adapter *adapter)
@@ -52,9 +36,6 @@ void rtw_reset_securitypriv23a(struct rtw_adapter *adapter)
                 *  When the countermeasure is trigger, the driver have to
                 *  disconnect with AP for 60 seconds.
                 */
-               memset(&backupPMKIDList[0], 0x00, sizeof(struct rt_pmkid_list) *
-                      NUM_PMKID_CACHE);
-
                memcpy(&backupPMKIDList[0], &adapter->securitypriv.PMKIDList[0],
                       sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
                backupPMKIDIndex = adapter->securitypriv.PMKIDIndex;
@@ -99,89 +80,3 @@ void rtw_os_indicate_disconnect23a(struct rtw_adapter *adapter)
 
        rtw_reset_securitypriv23a(adapter);
 }
-
-void rtw_report_sec_ie23a(struct rtw_adapter *adapter, u8 authmode, u8 *sec_ie)
-{
-       uint    len;
-       u8      *buff, *p, i;
-       union iwreq_data wrqu;
-
-       RT_TRACE(_module_mlme_osdep_c_, _drv_info_,
-                ("+rtw_report_sec_ie23a, authmode =%d\n", authmode));
-
-       buff = NULL;
-       if (authmode == _WPA_IE_ID_) {
-               RT_TRACE(_module_mlme_osdep_c_, _drv_info_,
-                        ("rtw_report_sec_ie23a, authmode =%d\n", authmode));
-
-               buff = kzalloc(IW_CUSTOM_MAX, GFP_KERNEL);
-               if (!buff)
-                       return;
-               p = buff;
-
-               p += sprintf(p, "ASSOCINFO(ReqIEs =");
-
-               len = sec_ie[1]+2;
-               len =  (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX;
-
-               for (i = 0; i < len; i++)
-                       p += sprintf(p, "%02x", sec_ie[i]);
-
-               p += sprintf(p, ")");
-
-               memset(&wrqu, 0, sizeof(wrqu));
-
-               wrqu.data.length = p-buff;
-
-               wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ?
-                                  wrqu.data.length : IW_CUSTOM_MAX;
-
-               kfree(buff);
-       }
-}
-
-#ifdef CONFIG_8723AU_AP_MODE
-void rtw_indicate_sta_assoc_event23a(struct rtw_adapter *padapter,
-                                 struct sta_info *psta)
-{
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       union iwreq_data wrqu;
-
-       if (psta == NULL)
-               return;
-
-       if (psta->aid > NUM_STA)
-               return;
-
-       if (pstapriv->sta_aid[psta->aid - 1] != psta)
-               return;
-
-       wrqu.addr.sa_family = ARPHRD_ETHER;
-
-       memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN);
-
-       DBG_8723A("+rtw_indicate_sta_assoc_event23a\n");
-}
-
-void rtw_indicate_sta_disassoc_event23a(struct rtw_adapter *padapter,
-                                    struct sta_info *psta)
-{
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       union iwreq_data wrqu;
-
-       if (psta == NULL)
-               return;
-
-       if (psta->aid > NUM_STA)
-               return;
-
-       if (pstapriv->sta_aid[psta->aid - 1] != psta)
-               return;
-
-       wrqu.addr.sa_family = ARPHRD_ETHER;
-
-       memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN);
-
-       DBG_8723A("+rtw_indicate_sta_disassoc_event23a\n");
-}
-#endif
index 57eca7a45672b94674677f88cfef688ca403c386..7c4c0a54b238c0d70687638e2ff86e944ca8593f 100644 (file)
@@ -20,7 +20,6 @@
 #include <recv_osdep.h>
 #include <hal_intf.h>
 #include <rtw_version.h>
-#include <ethernet.h>
 
 #include <usb_osintf.h>
 #include <linux/version.h>
@@ -66,10 +65,10 @@ static int rtw_acm_method;/*  0:By SW 1:By HW. */
 static int rtw_wmm_enable = 1;/*  default is set to enable the wmm. */
 static int rtw_uapsd_enable;
 
-int rtw_ht_enable23A = 1;
+static int rtw_ht_enable = 1;
 /* 0 :diable, bit(0): enable 2.4g, bit(1): enable 5g */
-int rtw_cbw40_enable23A = 3;
-int rtw_ampdu_enable23A = 1;/* for enable tx_ampdu */
+static int rtw_cbw40_enable = 3;
+static int rtw_ampdu_enable = 1;/* for enable tx_ampdu */
 /*  0: disable, bit(0):enable 2.4g, bit(1):enable 5g, default is set to enable
  * 2.4GHZ for IOT issue with bufflao's AP at 5GHZ
  */
@@ -130,9 +129,9 @@ module_param(rtw_wmm_enable, int, 0644);
 module_param(rtw_vrtl_carrier_sense, int, 0644);
 module_param(rtw_vcs_type, int, 0644);
 module_param(rtw_busy_thresh, int, 0644);
-module_param(rtw_ht_enable23A, int, 0644);
-module_param(rtw_cbw40_enable23A, int, 0644);
-module_param(rtw_ampdu_enable23A, int, 0644);
+module_param(rtw_ht_enable, int, 0644);
+module_param(rtw_cbw40_enable, int, 0644);
+module_param(rtw_ampdu_enable, int, 0644);
 module_param(rtw_rx_stbc, int, 0644);
 module_param(rtw_ampdu_amsdu, int, 0644);
 
@@ -203,9 +202,9 @@ static uint loadparam(struct rtw_adapter *padapter,  struct net_device *pnetdev)
         /* UAPSD */
        registry_par->wmm_enable = (u8)rtw_wmm_enable;
        registry_par->uapsd_enable = (u8)rtw_uapsd_enable;
-       registry_par->ht_enable = (u8)rtw_ht_enable23A;
-       registry_par->cbw40_enable = (u8)rtw_cbw40_enable23A;
-       registry_par->ampdu_enable = (u8)rtw_ampdu_enable23A;
+       registry_par->ht_enable = (u8)rtw_ht_enable;
+       registry_par->cbw40_enable = (u8)rtw_cbw40_enable;
+       registry_par->ampdu_enable = (u8)rtw_ampdu_enable;
        registry_par->rx_stbc = (u8)rtw_rx_stbc;
        registry_par->ampdu_amsdu = (u8)rtw_ampdu_amsdu;
        registry_par->lowrate_two_xmit = (u8)rtw_lowrate_two_xmit;
@@ -312,14 +311,14 @@ static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb,
 u16 rtw_recv_select_queue23a(struct sk_buff *skb)
 {
        struct iphdr *piphdr;
+       struct ethhdr *eth = (struct ethhdr *)skb->data;
        unsigned int dscp;
-       u16 eth_type;
+       u16 eth_type = get_unaligned_be16(&eth->h_proto);
        u32 priority;
        u8 *pdata = skb->data;
 
-       memcpy(&eth_type, pdata + (ETH_ALEN << 1), 2);
        switch (eth_type) {
-       case htons(ETH_P_IP):
+       case ETH_P_IP:
                piphdr = (struct iphdr *)(pdata + ETH_HLEN);
                dscp = piphdr->tos & 0xfc;
                priority = dscp >> 5;
@@ -378,35 +377,6 @@ struct net_device *rtw_init_netdev23a(struct rtw_adapter *old_padapter)
        return pnetdev;
 }
 
-u32 rtw_start_drv_threads23a(struct rtw_adapter *padapter)
-{
-       u32 _status = _SUCCESS;
-
-       RT_TRACE(_module_os_intfs_c_, _drv_info_,
-                ("+rtw_start_drv_threads23a\n"));
-       padapter->cmdThread = kthread_run(rtw_cmd_thread23a, padapter,
-                                         "RTW_CMD_THREAD");
-       if (IS_ERR(padapter->cmdThread)) {
-               _status = _FAIL;
-       } else {
-               /* wait for cmd_thread to run */
-               down(&padapter->cmdpriv.terminate_cmdthread_sema);
-       }
-       rtw_hal_start_thread23a(padapter);
-       return _status;
-}
-
-void rtw_stop_drv_threads23a(struct rtw_adapter *padapter)
-{
-       RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_stop_drv_threads23a\n"));
-
-       /* Below is to termindate rtw_cmd_thread23a & event_thread... */
-       up(&padapter->cmdpriv.cmd_queue_sema);
-       if (padapter->cmdThread)
-               down(&padapter->cmdpriv.terminate_cmdthread_sema);
-       rtw_hal_stop_thread23a(padapter);
-}
-
 static u8 rtw_init_default_value(struct rtw_adapter *padapter)
 {
        struct registry_priv *pregistrypriv = &padapter->registrypriv;
@@ -454,11 +424,7 @@ static u8 rtw_init_default_value(struct rtw_adapter *padapter)
        /* misc. */
        padapter->bReadPortCancel = false;
        padapter->bWritePortCancel = false;
-       padapter->bRxRSSIDisplay = 0;
        padapter->bNotifyChannelChange = 0;
-#ifdef CONFIG_8723AU_P2P
-       padapter->bShowGetP2PState = 1;
-#endif
        return ret;
 }
 
@@ -472,7 +438,6 @@ u8 rtw_reset_drv_sw23a(struct rtw_adapter *padapter)
        rtw_hal_def_value_init23a(padapter);
        padapter->bReadPortCancel = false;
        padapter->bWritePortCancel = false;
-       padapter->bRxRSSIDisplay = 0;
        pmlmepriv->scan_interval = SCAN_INTERVAL;/*  30*2 sec = 60sec */
 
        padapter->xmitpriv.tx_pkts = 0;
@@ -521,17 +486,6 @@ u8 rtw_init_drv_sw23a(struct rtw_adapter *padapter)
                goto exit;
        }
 
-#ifdef CONFIG_8723AU_P2P
-       rtw_init_wifidirect_timers23a(padapter);
-       init_wifidirect_info23a(padapter, P2P_ROLE_DISABLE);
-       reset_global_wifidirect_info23a(padapter);
-       rtw_init_cfg80211_wifidirect_info(padapter);
-#ifdef CONFIG_8723AU_P2P
-       if (rtw_init_wifi_display_info(padapter) == _FAIL)
-               RT_TRACE(_module_os_intfs_c_, _drv_err_,
-                        ("\n Can't init init_wifi_display_info\n"));
-#endif
-#endif /* CONFIG_8723AU_P2P */
 
        if (init_mlme_ext_priv23a(padapter) == _FAIL) {
                RT_TRACE(_module_os_intfs_c_, _drv_err_,
@@ -600,10 +554,6 @@ void rtw_cancel_all_timer23a(struct rtw_adapter *padapter)
 
        del_timer_sync(&padapter->pwrctrlpriv.pwr_state_check_timer);
 
-#ifdef CONFIG_8723AU_P2P
-       del_timer_sync(&padapter->cfg80211_wdinfo.remain_on_ch_timer);
-#endif /* CONFIG_8723AU_P2P */
-
        del_timer_sync(&padapter->mlmepriv.set_scan_deny_timer);
        rtw_clear_scan_deny(padapter);
        RT_TRACE(_module_os_intfs_c_, _drv_info_,
@@ -616,26 +566,8 @@ void rtw_cancel_all_timer23a(struct rtw_adapter *padapter)
 
 u8 rtw_free_drv_sw23a(struct rtw_adapter *padapter)
 {
-#ifdef CONFIG_8723AU_P2P
-       struct wifidirect_info *pwdinfo;
-#endif
-
        RT_TRACE(_module_os_intfs_c_, _drv_info_, ("==>rtw_free_drv_sw23a"));
 
-       /* we can call rtw_p2p_enable23a here, but:
-        *  1. rtw_p2p_enable23a may have IO operation
-        *  2. rtw_p2p_enable23a is bundled with wext interface
-        */
-#ifdef CONFIG_8723AU_P2P
-       pwdinfo = &padapter->wdinfo;
-       if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {
-               del_timer_sync(&pwdinfo->find_phase_timer);
-               del_timer_sync(&pwdinfo->restore_p2p_state_timer);
-               del_timer_sync(&pwdinfo->pre_tx_scan_timer);
-               rtw_p2p_set_state(pwdinfo, P2P_STATE_NONE);
-       }
-#endif
-
        free_mlme_ext_priv23a(&padapter->mlmeextpriv);
 
        rtw_free_cmd_priv23a(&padapter->cmdpriv);
@@ -656,12 +588,6 @@ u8 rtw_free_drv_sw23a(struct rtw_adapter *padapter)
 
        RT_TRACE(_module_os_intfs_c_, _drv_info_, ("<== rtw_free_drv_sw23a\n"));
 
-       /* free the old_pnetdev */
-       if (padapter->rereg_nd_name_priv.old_pnetdev) {
-               free_netdev(padapter->rereg_nd_name_priv.old_pnetdev);
-               padapter->rereg_nd_name_priv.old_pnetdev = NULL;
-       }
-
        /*  clear pbuddy_adapter to avoid access wrong pointer. */
        if (padapter->pbuddy_adapter != NULL)
                padapter->pbuddy_adapter->pbuddy_adapter = NULL;
@@ -760,12 +686,6 @@ int netdev_open23a(struct net_device *pnetdev)
                DBG_8723A("MAC Address = "MAC_FMT"\n",
                          MAC_ARG(pnetdev->dev_addr));
 
-               status = rtw_start_drv_threads23a(padapter);
-               if (status == _FAIL) {
-                       DBG_8723A("Initialize driver software resource Failed!\n");
-                       goto netdev_open23a_error;
-               }
-
                if (init_hw_mlme_ext23a(padapter) == _FAIL) {
                        DBG_8723A("can't init mlme_ext_priv\n");
                        goto netdev_open23a_error;
@@ -887,7 +807,7 @@ void rtw_ips_pwr_down23a(struct rtw_adapter *padapter)
 
 void rtw_ips_dev_unload23a(struct rtw_adapter *padapter)
 {
-       rtw_hal_set_hwreg23a(padapter, HW_VAR_FIFO_CLEARN_UP, NULL);
+       rtl8723a_fifo_cleanup(padapter);
 
        if (padapter->intf_stop)
                padapter->intf_stop(padapter);
@@ -941,17 +861,11 @@ static int netdev_close(struct net_device *pnetdev)
                /* s2-3. */
                rtw_free_assoc_resources23a(padapter, 1);
                /* s2-4. */
-               rtw_free_network_queue23a(padapter, true);
+               rtw_free_network_queue23a(padapter);
                /*  Close LED */
                rtw_led_control(padapter, LED_CTL_POWER_OFF);
        }
 
-#ifdef CONFIG_8723AU_P2P
-       if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled)
-               wdev_to_priv(padapter->rtw_wdev)->p2p_enabled = false;
-       rtw_p2p_enable23a(padapter, P2P_ROLE_DISABLE);
-#endif /* CONFIG_8723AU_P2P */
-
        rtw_scan_abort23a(padapter);
         /* set this at the end */
        padapter->rtw_wdev->iftype = NL80211_IFTYPE_MONITOR;
index 97fc27dce19c987288540949142bd117d9c9e951..4a937a7f1d11fcc42223909da3babc6bb83a25b6 100644 (file)
@@ -21,8 +21,6 @@
 #include <recv_osdep.h>
 #include <linux/vmalloc.h>
 
-#define RT_TAG ('1178')
-
 /*
 * Translate the OS dependent @param error_code to OS independent RTW_STATUS_CODE23a
 * @return: one of RTW_STATUS_CODE23a
@@ -71,17 +69,6 @@ u32 _rtw_queue_empty23a(struct rtw_queue *pqueue)
                return false;
 }
 
-u64 rtw_modular6423a(u64 x, u64 y)
-{
-       return do_div(x, y);
-}
-
-u64 rtw_division6423a(u64 x, u64 y)
-{
-       do_div(x, y);
-       return x;
-}
-
 /* rtw_cbuf_full23a - test if cbuf is full
  * @cbuf: pointer of struct rtw_cbuf
  *
index 84402a589f258ae56045555aebda6f30d778f5d4..528ed9253b141eaa9f27e36aa2499e3f7015e218 100644 (file)
 #include <recv_osdep.h>
 
 #include <osdep_intf.h>
-#include <ethernet.h>
 
 #include <usb_ops.h>
 
-/* alloc os related resource in struct recv_frame */
-int rtw_os_recv_resource_alloc23a(struct rtw_adapter *padapter,
-                              struct recv_frame *precvframe)
-{
-       int res = _SUCCESS;
-
-       precvframe->pkt = NULL;
-
-       return res;
-}
-
-/* alloc os related resource in struct recv_buf */
-int rtw_os_recvbuf_resource_alloc23a(struct rtw_adapter *padapter,
-                                 struct recv_buf *precvbuf)
-{
-       int res = _SUCCESS;
-
-       precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL);
-       if (precvbuf->purb == NULL)
-               res = _FAIL;
-
-       precvbuf->pskb = NULL;
-
-       return res;
-}
-
-/* free os related resource in struct recv_buf */
-int rtw_os_recvbuf_resource_free23a(struct rtw_adapter *padapter,
-                                struct recv_buf *precvbuf)
-{
-       int ret = _SUCCESS;
-
-       usb_free_urb(precvbuf->purb);
-
-       if (precvbuf->pskb)
-               dev_kfree_skb_any(precvbuf->pskb);
-
-       return ret;
-}
-
 void rtw_handle_tkip_mic_err23a(struct rtw_adapter *padapter, u8 bgroup)
 {
        enum nl80211_key_type key_type = 0;
@@ -110,11 +69,6 @@ void rtw_handle_tkip_mic_err23a(struct rtw_adapter *padapter, u8 bgroup)
        wrqu.data.length = sizeof(ev);
 }
 
-void rtw_hostapd_mlme_rx23a(struct rtw_adapter *padapter,
-                        struct recv_frame *precv_frame)
-{
-}
-
 int rtw_recv_indicatepkt23a(struct rtw_adapter *padapter,
                         struct recv_frame *precv_frame)
 {
@@ -205,18 +159,6 @@ _recv_indicatepkt_drop:
         return _FAIL;
 }
 
-void rtw_os_read_port23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf)
-{
-       struct recv_priv *precvpriv = &padapter->recvpriv;
-
-       /* free skb in recv_buf */
-       dev_kfree_skb_any(precvbuf->pskb);
-
-       precvbuf->pskb = NULL;
-
-       rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, precvbuf);
-}
-
 void rtw_init_recv_timer23a(struct recv_reorder_ctrl *preorder_ctrl)
 {
        setup_timer(&preorder_ctrl->reordering_ctrl_timer,
index 612806e0de2e80f5a2d01044f9bbdd3717d97eda..7d5233b993f15e5b8cb941fffc31c55399128874 100644 (file)
@@ -333,7 +333,7 @@ static void rtw_dev_unload(struct rtw_adapter *padapter)
 
                /* s4. */
                if (!padapter->pwrctrlpriv.bInternalAutoSuspend)
-                       rtw_stop_drv_threads23a(padapter);
+                       flush_workqueue(padapter->cmdpriv.wq);
 
                /* s5. */
                if (!padapter->bSurpriseRemoved) {
@@ -353,6 +353,7 @@ int rtw_hw_suspend23a(struct rtw_adapter *padapter)
 {
        struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
        struct net_device *pnetdev = padapter->pnetdev;
+       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
        if ((!padapter->bup) || (padapter->bDriverStopped) ||
            (padapter->bSurpriseRemoved)) {
@@ -380,26 +381,22 @@ int rtw_hw_suspend23a(struct rtw_adapter *padapter)
 
                /* s2-2.  indicate disconnect to os */
                /* rtw_indicate_disconnect23a(padapter); */
-               {
-                       struct  mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-                       if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-                               _clr_fwstate_(pmlmepriv, _FW_LINKED);
+               if (check_fwstate(pmlmepriv, _FW_LINKED)) {
+                       _clr_fwstate_(pmlmepriv, _FW_LINKED);
 
-                               rtw_led_control(padapter, LED_CTL_NO_LINK);
+                       rtw_led_control(padapter, LED_CTL_NO_LINK);
 
-                               rtw_os_indicate_disconnect23a(padapter);
+                       rtw_os_indicate_disconnect23a(padapter);
 
-                               /* donnot enqueue cmd */
-                               rtw_lps_ctrl_wk_cmd23a(padapter,
-                                                   LPS_CTRL_DISCONNECT, 0);
-                       }
+                       /* donnot enqueue cmd */
+                       rtw_lps_ctrl_wk_cmd23a(padapter,
+                                              LPS_CTRL_DISCONNECT, 0);
                }
                /* s2-3. */
                rtw_free_assoc_resources23a(padapter, 1);
 
                /* s2-4. */
-               rtw_free_network_queue23a(padapter, true);
+               rtw_free_network_queue23a(padapter);
                rtw_ips_dev_unload23a(padapter);
                pwrpriv->rf_pwrstate = rf_off;
                pwrpriv->bips_processing = false;
@@ -503,13 +500,14 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message)
        /* s2-3. */
        rtw_free_assoc_resources23a(padapter, 1);
        /* s2-4. */
-       rtw_free_network_queue23a(padapter, true);
+       rtw_free_network_queue23a(padapter);
 
        rtw_dev_unload(padapter);
        up(&pwrpriv->lock);
 
        if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
-               rtw_indicate_scan_done23a(padapter, 1);
+               rtw_cfg80211_indicate_scan_done(
+                       wdev_to_priv(padapter->rtw_wdev), true);
 
        if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING))
                rtw_indicate_disconnect23a(padapter);
@@ -565,7 +563,7 @@ int rtw_resume_process23a(struct rtw_adapter *padapter)
 
        if (padapter->pid[1] != 0) {
                DBG_8723A("pid[1]:%d\n", padapter->pid[1]);
-               rtw_signal_process(padapter->pid[1], SIGUSR2);
+               kill_pid(find_vpid(padapter->pid[1]), SIGUSR2, 1);
        }
 
        rtw23a_roaming(padapter, NULL);
@@ -624,8 +622,7 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
        padapter->intf_start = &usb_intf_start;
        padapter->intf_stop = &usb_intf_stop;
 
-       /* step init_io_priv */
-       rtw_init_io_priv23a(padapter, usb_set_intf_ops);
+       rtl8723au_set_intf_ops(padapter);
 
        /* step read_chip_version */
        rtw_hal_read_chip_version23a(padapter);
@@ -664,10 +661,6 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
 
        /*  set mac addr */
        rtw_macaddr_cfg23a(padapter->eeprompriv.mac_addr);
-#ifdef CONFIG_8723AU_P2P
-       rtw_init_wifidirect_addrs23a(padapter, padapter->eeprompriv.mac_addr,
-                                 padapter->eeprompriv.mac_addr);
-#endif
 
        DBG_8723A("bDriverStopped:%d, bSurpriseRemoved:%d, bup:%d, hw_init_completed:%d\n",
                  padapter->bDriverStopped, padapter->bSurpriseRemoved,
index c49160e477d8d0245392fea0db2a2d432c186b2f..b88f72f0f06b53f1a742347b8ac0de2c98069284 100644 (file)
@@ -41,18 +41,17 @@ struct zero_bulkout_context {
        void *padapter;
 };
 
-void usb_read_mem23a(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem)
+void usb_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *rmem)
 {
 }
 
-void usb_write_mem23a(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem)
+void usb_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *wmem)
 {
 }
 
-void usb_read_port_cancel23a(struct intf_hdl *pintfhdl)
+void usb_read_port_cancel23a(struct rtw_adapter *padapter)
 {
        struct recv_buf *precvbuf;
-       struct rtw_adapter *padapter = pintfhdl->padapter;
        int i;
 
        precvbuf = (struct recv_buf *)padapter->recvpriv.precv_buf;
@@ -161,11 +160,10 @@ check_completion:
        tasklet_hi_schedule(&pxmitpriv->xmit_tasklet);
 }
 
-u32 usb_write_port23a(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
-                  struct xmit_buf *pxmitbuf)
+u32 usb_write_port23a(struct rtw_adapter *padapter, u32 addr, u32 cnt,
+                     struct xmit_buf *pxmitbuf)
 {
        struct urb *purb = NULL;
-       struct rtw_adapter *padapter = (struct rtw_adapter *)pintfhdl->padapter;
        struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter);
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
        struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitbuf->priv_data;
@@ -255,9 +253,8 @@ exit:
        return ret;
 }
 
-void usb_write_port23a_cancel(struct intf_hdl *pintfhdl)
+void usb_write_port23a_cancel(struct rtw_adapter *padapter)
 {
-       struct rtw_adapter *padapter = pintfhdl->padapter;
        struct xmit_buf *pxmitbuf;
        struct list_head *plist;
        int j;
index e1c6fc7462333ec84741e258d63933a1002ba301..69f88848715abc9d61f58ed9cbabcf91b18e8e43 100644 (file)
 #include <xmit_osdep.h>
 #include <osdep_intf.h>
 
-uint rtw_remainder_len23a(struct pkt_file *pfile)
-{
-       return pfile->buf_len - ((unsigned long)(pfile->cur_addr) -
-              (unsigned long)(pfile->buf_start));
-}
-
-void _rtw_open_pktfile23a(struct sk_buff *pktptr, struct pkt_file *pfile)
-{
-       pfile->pkt = pktptr;
-       pfile->buf_start = pktptr->data;
-       pfile->cur_addr = pktptr->data;
-       pfile->buf_len = pktptr->len;
-       pfile->pkt_len = pktptr->len;
-
-       pfile->cur_buffer = pfile->buf_start;
-}
-
-uint _rtw_pktfile_read23a(struct pkt_file *pfile, u8 *rmem, uint rlen)
-{
-       uint    len = 0;
-
-       len =  rtw_remainder_len23a(pfile);
-       len = (rlen > len) ? len : rlen;
-
-       if (rmem)
-               skb_copy_bits(pfile->pkt, pfile->buf_len-pfile->pkt_len,
-                             rmem, len);
-
-       pfile->cur_addr += len;
-       pfile->pkt_len -= len;
-
-       return len;
-}
-
-int rtw_endofpktfile23a(struct pkt_file *pfile)
-{
-       if (pfile->pkt_len == 0)
-               return true;
-       return false;
-}
-
 int rtw_os_xmit_resource_alloc23a(struct rtw_adapter *padapter,
                               struct xmit_buf *pxmitbuf, u32 alloc_sz)
 {
index 115908928ae4293c5cfd36bc5fbb7ac71accd2a7..81706f4087f07a83e380256fb1d116eca781dac4 100644 (file)
@@ -12,7 +12,7 @@
  *   include files
  **************************************************************/
 #include "halbt_precomp.h"
-#if 1
+
 /**************************************************************
  *   Global variables, these are static variables
  **************************************************************/
@@ -21,14 +21,14 @@ static struct coex_dm_8192e_2ant *coex_dm = &glcoex_dm_8192e_2ant;
 static struct coex_sta_8192e_2ant glcoex_sta_8192e_2ant;
 static struct coex_sta_8192e_2ant *coex_sta = &glcoex_sta_8192e_2ant;
 
-const char *const GLBtInfoSrc8192e2Ant[]={
+static const char *const GLBtInfoSrc8192e2Ant[] = {
        "BT Info[wifi fw]",
        "BT Info[bt rsp]",
        "BT Info[bt auto report]",
 };
 
-u32 glcoex_ver_date_8192e_2ant = 20130902;
-u32 glcoex_ver_8192e_2ant = 0x34;
+static u32 glcoex_ver_date_8192e_2ant = 20130902;
+static u32 glcoex_ver_8192e_2ant = 0x34;
 
 /**************************************************************
  *   local function proto type if needed
@@ -36,13 +36,12 @@ u32 glcoex_ver_8192e_2ant = 0x34;
 /**************************************************************
  *   local function start with halbtc8192e2ant_
  **************************************************************/
-u8 halbtc8192e2ant_btrssi_state(u8 level_num, u8 rssi_thresh, u8 rssi_thresh1)
+static u8 halbtc8192e2ant_btrssi_state(u8 level_num, u8 rssi_thresh,
+                                      u8 rssi_thresh1)
 {
-       int btrssi=0;
+       int btrssi = coex_sta->bt_rssi;
        u8 btrssi_state = coex_sta->pre_bt_rssi_state;
 
-       btrssi = coex_sta->bt_rssi;
-
        if (level_num == 2) {
                if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
                    (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) {
@@ -82,7 +81,7 @@ u8 halbtc8192e2ant_btrssi_state(u8 level_num, u8 rssi_thresh, u8 rssi_thresh1)
                    (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) {
                        BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
                                  "BT Rssi pre state=LOW\n");
-                       if(btrssi >= (rssi_thresh +
+                       if (btrssi >= (rssi_thresh +
                                      BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) {
                                btrssi_state = BTC_RSSI_STATE_MEDIUM;
                                BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
@@ -132,8 +131,9 @@ u8 halbtc8192e2ant_btrssi_state(u8 level_num, u8 rssi_thresh, u8 rssi_thresh1)
        return btrssi_state;
 }
 
-u8 halbtc8192e2ant_wifirssi_state(struct btc_coexist * btcoexist, u8 index,
-                                 u8 level_num, u8 rssi_thresh, u8 rssi_thresh1)
+static u8 halbtc8192e2ant_wifirssi_state(struct btc_coexist *btcoexist,
+                                        u8 index, u8 level_num,
+                                        u8 rssi_thresh, u8 rssi_thresh1)
 {
        int wifirssi = 0;
        u8 wifirssi_state = coex_sta->pre_wifi_rssi_state[index];
@@ -156,8 +156,8 @@ u8 halbtc8192e2ant_wifirssi_state(struct btc_coexist * btcoexist, u8 index,
                                BTC_PRINT(BTC_MSG_ALGORITHM,
                                          ALGO_WIFI_RSSI_STATE,
                                          "wifi RSSI state stay at Low\n");
-                       }
-               } else {
+                       }
+               } else {
                        if (wifirssi < rssi_thresh) {
                                wifirssi_state = BTC_RSSI_STATE_LOW;
                                BTC_PRINT(BTC_MSG_ALGORITHM,
@@ -234,10 +234,10 @@ u8 halbtc8192e2ant_wifirssi_state(struct btc_coexist * btcoexist, u8 index,
        return wifirssi_state;
 }
 
-void halbtc8192e2ant_monitor_bt_enable_disable(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_monitor_bt_enable_disable(struct btc_coexist *btcoexist)
 {
-       static bool pre_bt_disabled = false;
-       static u32 bt_disable_cnt = 0;
+       static bool pre_bt_disabled;
+       static u32 bt_disable_cnt;
        bool bt_active = true, bt_disabled = false;
 
        /* This function check if bt is disabled */
@@ -283,7 +283,7 @@ void halbtc8192e2ant_monitor_bt_enable_disable(struct btc_coexist *btcoexist)
        }
 }
 
-u32 halbtc8192e2ant_decidera_mask(struct btc_coexist *btcoexist,
+static u32 halbtc8192e2ant_decidera_mask(struct btc_coexist *btcoexist,
                                  u8 sstype, u32 ra_masktype)
 {
        u32 disra_mask = 0x0;
@@ -296,13 +296,13 @@ u32 halbtc8192e2ant_decidera_mask(struct btc_coexist *btcoexist,
                        disra_mask = 0xfff00000;/* disable 2ss */
                break;
        case 1: /* disable cck 1/2 */
-               if(sstype == 2)
+               if (sstype == 2)
                        disra_mask = 0x00000003;/* enable 2ss */
                else
                        disra_mask = 0xfff00003;/* disable 2ss */
                break;
        case 2: /* disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 */
-               if(sstype == 2)
+               if (sstype == 2)
                        disra_mask = 0x0001f1f7;/* enable 2ss */
                else
                        disra_mask = 0xfff1f1f7;/* disable 2ss */
@@ -314,8 +314,8 @@ u32 halbtc8192e2ant_decidera_mask(struct btc_coexist *btcoexist,
        return disra_mask;
 }
 
-void halbtc8192e2ant_Updatera_mask(struct btc_coexist *btcoexist,
-                                  bool force_exec, u32 dis_ratemask)
+static void halbtc8192e2ant_Updatera_mask(struct btc_coexist *btcoexist,
+                                         bool force_exec, u32 dis_ratemask)
 {
        coex_dm->curra_mask = dis_ratemask;
 
@@ -325,8 +325,8 @@ void halbtc8192e2ant_Updatera_mask(struct btc_coexist *btcoexist,
        coex_dm->prera_mask = coex_dm->curra_mask;
 }
 
-void halbtc8192e2ant_autorate_fallback_retry(struct btc_coexist *btcoexist,
-                                            bool force_exec, u8 type)
+static void halbtc8192e2ant_autorate_fallback_retry(struct btc_coexist *btcoexist,
+                                                   bool force_exec, u8 type)
 {
        bool wifi_under_bmode = false;
 
@@ -364,32 +364,32 @@ void halbtc8192e2ant_autorate_fallback_retry(struct btc_coexist *btcoexist,
        coex_dm->pre_arfrtype = coex_dm->cur_arfrtype;
 }
 
-void halbtc8192e2ant_retrylimit(struct btc_coexist *btcoexist,
-                               bool force_exec, u8 type)
+static void halbtc8192e2ant_retrylimit(struct btc_coexist *btcoexist,
+                                      bool force_exec, u8 type)
 {
        coex_dm->cur_retrylimit_type = type;
 
        if (force_exec || (coex_dm->pre_retrylimit_type !=
                           coex_dm->cur_retrylimit_type)) {
                switch (coex_dm->cur_retrylimit_type) {
-                       case 0: /* normal mode */
-                               btcoexist->btc_write_2byte(btcoexist, 0x42a,
-                                                   coex_dm->backup_retrylimit);
-                               break;
-                       case 1: /* retry limit=8 */
-                               btcoexist->btc_write_2byte(btcoexist, 0x42a,
-                                                          0x0808);
-                               break;
-                       default:
-                               break;
+               case 0: /* normal mode */
+                       btcoexist->btc_write_2byte(btcoexist, 0x42a,
+                                           coex_dm->backup_retrylimit);
+                       break;
+               case 1: /* retry limit=8 */
+                       btcoexist->btc_write_2byte(btcoexist, 0x42a,
+                                                  0x0808);
+                       break;
+               default:
+                       break;
                }
        }
 
        coex_dm->pre_retrylimit_type = coex_dm->cur_retrylimit_type;
 }
 
-void halbtc8192e2ant_ampdu_maxtime(struct btc_coexist *btcoexist,
-                                  bool force_exec, u8 type)
+static void halbtc8192e2ant_ampdu_maxtime(struct btc_coexist *btcoexist,
+                                         bool force_exec, u8 type)
 {
        coex_dm->cur_ampdutime_type = type;
 
@@ -411,9 +411,10 @@ void halbtc8192e2ant_ampdu_maxtime(struct btc_coexist *btcoexist,
        coex_dm->pre_ampdutime_type = coex_dm->cur_ampdutime_type;
 }
 
-void halbtc8192e2ant_limited_tx(struct btc_coexist *btcoexist,
-                               bool force_exec, u8 ra_masktype, u8 arfr_type,
-                               u8 retrylimit_type, u8 ampdutime_type)
+static void halbtc8192e2ant_limited_tx(struct btc_coexist *btcoexist,
+                                      bool force_exec, u8 ra_masktype,
+                                      u8 arfr_type, u8 retrylimit_type,
+                                      u8 ampdutime_type)
 {
        u32 disra_mask = 0x0;
 
@@ -429,10 +430,10 @@ void halbtc8192e2ant_limited_tx(struct btc_coexist *btcoexist,
        halbtc8192e2ant_ampdu_maxtime(btcoexist, force_exec, ampdutime_type);
 }
 
-void halbtc8192e2ant_limited_rx(struct btc_coexist *btcoexist,
-                               bool force_exec, bool rej_ap_agg_pkt,
-                               bool b_bt_ctrl_agg_buf_size,
-                               u8 agg_buf_size)
+static void halbtc8192e2ant_limited_rx(struct btc_coexist *btcoexist,
+                                      bool force_exec, bool rej_ap_agg_pkt,
+                                      bool b_bt_ctrl_agg_buf_size,
+                                      u8 agg_buf_size)
 {
        bool reject_rx_agg = rej_ap_agg_pkt;
        bool bt_ctrl_rx_agg_size = b_bt_ctrl_agg_buf_size;
@@ -455,7 +456,7 @@ void halbtc8192e2ant_limited_rx(struct btc_coexist *btcoexist,
 
 }
 
-void halbtc8192e2ant_monitor_bt_ctr(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_monitor_bt_ctr(struct btc_coexist *btcoexist)
 {
        u32 reg_hp_txrx, reg_lp_txrx, u32tmp;
        u32 reg_hp_tx = 0, reg_hp_rx = 0, reg_lp_tx = 0, reg_lp_rx = 0;
@@ -487,9 +488,9 @@ void halbtc8192e2ant_monitor_bt_ctr(struct btc_coexist *btcoexist)
        btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc);
 }
 
-void halbtc8192e2ant_querybt_info(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_querybt_info(struct btc_coexist *btcoexist)
 {
-       u8 h2c_parameter[1] ={0};
+       u8 h2c_parameter[1] = {0};
 
        coex_sta->c2h_bt_info_req_sent = true;
 
@@ -502,10 +503,10 @@ void halbtc8192e2ant_querybt_info(struct btc_coexist *btcoexist)
        btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter);
 }
 
-bool halbtc8192e2ant_iswifi_status_changed(struct btc_coexist *btcoexist)
+static bool halbtc8192e2ant_iswifi_status_changed(struct btc_coexist *btcoexist)
 {
-       static bool pre_wifi_busy = false;
-       static bool pre_under_4way = false, pre_bt_hson = false;
+       static bool pre_wifi_busy;
+       static bool pre_under_4way, pre_bt_hson;
        bool wifi_busy = false, under_4way = false, bt_hson = false;
        bool wifi_connected = false;
 
@@ -534,7 +535,7 @@ bool halbtc8192e2ant_iswifi_status_changed(struct btc_coexist *btcoexist)
        return false;
 }
 
-void halbtc8192e2ant_update_btlink_info(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_update_btlink_info(struct btc_coexist *btcoexist)
 {
        struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
        bool bt_hson = false;
@@ -590,11 +591,11 @@ void halbtc8192e2ant_update_btlink_info(struct btc_coexist *btcoexist)
                bt_link_info->hid_only = false;
 }
 
-u8 halbtc8192e2ant_action_algorithm(struct btc_coexist *btcoexist)
+static u8 halbtc8192e2ant_action_algorithm(struct btc_coexist *btcoexist)
 {
        struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
        struct btc_stack_info *stack_info = &btcoexist->stack_info;
-       bool bt_hson=false;
+       bool bt_hson = false;
        u8 algorithm = BT_8192E_2ANT_COEX_ALGO_UNDEFINED;
        u8 numOfDiffProfile = 0;
 
@@ -777,10 +778,10 @@ u8 halbtc8192e2ant_action_algorithm(struct btc_coexist *btcoexist)
        return algorithm;
 }
 
-void halbtc8192e2ant_setfw_dac_swinglevel(struct btc_coexist *btcoexist,
-                                         u8 dac_swinglvl)
+static void halbtc8192e2ant_setfw_dac_swinglevel(struct btc_coexist *btcoexist,
+                                                u8 dac_swinglvl)
 {
-       u8 h2c_parameter[1] ={0};
+       u8 h2c_parameter[1] = {0};
 
        /* There are several type of dacswing
         * 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 */
@@ -794,10 +795,10 @@ void halbtc8192e2ant_setfw_dac_swinglevel(struct btc_coexist *btcoexist,
        btcoexist->btc_fill_h2c(btcoexist, 0x64, 1, h2c_parameter);
 }
 
-void halbtc8192e2ant_set_fwdec_btpwr(struct btc_coexist *btcoexist,
-                                    u8 dec_btpwr_lvl)
+static void halbtc8192e2ant_set_fwdec_btpwr(struct btc_coexist *btcoexist,
+                                           u8 dec_btpwr_lvl)
 {
-       u8 h2c_parameter[1] ={0};
+       u8 h2c_parameter[1] = {0};
 
        h2c_parameter[0] = dec_btpwr_lvl;
 
@@ -808,12 +809,12 @@ void halbtc8192e2ant_set_fwdec_btpwr(struct btc_coexist *btcoexist,
        btcoexist->btc_fill_h2c(btcoexist, 0x62, 1, h2c_parameter);
 }
 
-void halbtc8192e2ant_dec_btpwr(struct btc_coexist *btcoexist,
-                              bool force_exec, u8 dec_btpwr_lvl)
+static void halbtc8192e2ant_dec_btpwr(struct btc_coexist *btcoexist,
+                                     bool force_exec, u8 dec_btpwr_lvl)
 {
        BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
                  "[BTCoex], %s Dec BT power level = %d\n",
-                 (force_exec? "force to":""), dec_btpwr_lvl);
+                 (force_exec ? "force to":""), dec_btpwr_lvl);
        coex_dm->cur_dec_bt_pwr = dec_btpwr_lvl;
 
        if (!force_exec) {
@@ -826,10 +827,10 @@ void halbtc8192e2ant_dec_btpwr(struct btc_coexist *btcoexist,
        coex_dm->pre_dec_bt_pwr = coex_dm->cur_dec_bt_pwr;
 }
 
-void halbtc8192e2ant_set_bt_autoreport(struct btc_coexist *btcoexist,
-                                      bool enable_autoreport)
+static void halbtc8192e2ant_set_bt_autoreport(struct btc_coexist *btcoexist,
+                                             bool enable_autoreport)
 {
-       u8 h2c_parameter[1] ={0};
+       u8 h2c_parameter[1] = {0};
 
        h2c_parameter[0] = 0;
 
@@ -838,19 +839,20 @@ void halbtc8192e2ant_set_bt_autoreport(struct btc_coexist *btcoexist,
 
        BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
                  "[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n",
-                 (enable_autoreport? "Enabled!!":"Disabled!!"),
+                 (enable_autoreport ? "Enabled!!":"Disabled!!"),
                  h2c_parameter[0]);
 
        btcoexist->btc_fill_h2c(btcoexist, 0x68, 1, h2c_parameter);
 }
 
-void halbtc8192e2ant_bt_autoreport(struct btc_coexist *btcoexist,
-                                  bool force_exec, bool enable_autoreport)
+static void halbtc8192e2ant_bt_autoreport(struct btc_coexist *btcoexist,
+                                         bool force_exec,
+                                         bool enable_autoreport)
 {
        BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
                  "[BTCoex], %s BT Auto report = %s\n",
-                 (force_exec? "force to":""),
-                 ((enable_autoreport)? "Enabled":"Disabled"));
+                 (force_exec ? "force to":""),
+                 ((enable_autoreport) ? "Enabled":"Disabled"));
        coex_dm->cur_bt_auto_report = enable_autoreport;
 
        if (!force_exec) {
@@ -868,12 +870,12 @@ void halbtc8192e2ant_bt_autoreport(struct btc_coexist *btcoexist,
        coex_dm->pre_bt_auto_report = coex_dm->cur_bt_auto_report;
 }
 
-void halbtc8192e2ant_fw_dac_swinglvl(struct btc_coexist *btcoexist,
-                                    bool force_exec, u8 fw_dac_swinglvl)
+static void halbtc8192e2ant_fw_dac_swinglvl(struct btc_coexist *btcoexist,
+                                           bool force_exec, u8 fw_dac_swinglvl)
 {
        BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
                  "[BTCoex], %s set FW Dac Swing level = %d\n",
-                 (force_exec? "force to":""), fw_dac_swinglvl);
+                 (force_exec ? "force to":""), fw_dac_swinglvl);
        coex_dm->cur_fw_dac_swing_lvl = fw_dac_swinglvl;
 
        if (!force_exec) {
@@ -893,8 +895,8 @@ void halbtc8192e2ant_fw_dac_swinglvl(struct btc_coexist *btcoexist,
        coex_dm->pre_fw_dac_swing_lvl = coex_dm->cur_fw_dac_swing_lvl;
 }
 
-void halbtc8192e2ant_set_sw_rf_rx_lpf_corner(struct btc_coexist *btcoexist,
-                                            bool rx_rf_shrink_on)
+static void halbtc8192e2ant_set_sw_rf_rx_lpf_corner(struct btc_coexist *btcoexist,
+                                                   bool rx_rf_shrink_on)
 {
        if (rx_rf_shrink_on) {
                /* Shrink RF Rx LPF corner */
@@ -915,12 +917,12 @@ void halbtc8192e2ant_set_sw_rf_rx_lpf_corner(struct btc_coexist *btcoexist,
        }
 }
 
-void halbtc8192e2ant_rf_shrink(struct btc_coexist *btcoexist,
-                              bool force_exec, bool rx_rf_shrink_on)
+static void halbtc8192e2ant_rf_shrink(struct btc_coexist *btcoexist,
+                                     bool force_exec, bool rx_rf_shrink_on)
 {
        BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
                  "[BTCoex], %s turn Rx RF Shrink = %s\n",
-                 (force_exec? "force to":""), ((rx_rf_shrink_on)? "ON":"OFF"));
+                 (force_exec ? "force to":""), ((rx_rf_shrink_on) ? "ON":"OFF"));
        coex_dm->cur_rf_rx_lpf_shrink = rx_rf_shrink_on;
 
        if (!force_exec) {
@@ -939,56 +941,8 @@ void halbtc8192e2ant_rf_shrink(struct btc_coexist *btcoexist,
        coex_dm->pre_rf_rx_lpf_shrink = coex_dm->cur_rf_rx_lpf_shrink;
 }
 
-void halbtc8192e2ant_set_sw_penalty_tx_rateadaptive(
-                                               struct btc_coexist *btcoexist,
-                                               bool low_penalty_ra)
-{
-       u8 h2c_parameter[6] ={0};
-
-       h2c_parameter[0] = 0x6; /* opCode, 0x6= Retry_Penalty */
-
-       if (low_penalty_ra) {
-               h2c_parameter[1] |= BIT0;
-               /* normal rate except MCS7/6/5, OFDM54/48/36 */
-               h2c_parameter[2] = 0x00;
-               h2c_parameter[3] = 0xf7;  /* MCS7 or OFDM54 */
-               h2c_parameter[4] = 0xf8;  /* MCS6 or OFDM48 */
-               h2c_parameter[5] = 0xf9;  /* MCS5 or OFDM36 */
-       }
-
-       BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
-                 "[BTCoex], set WiFi Low-Penalty Retry: %s",
-                 (low_penalty_ra? "ON!!":"OFF!!"));
-
-       btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, h2c_parameter);
-}
-
-void halbtc8192e2ant_low_penalty_ra(struct btc_coexist *btcoexist,
-                                   bool force_exec, bool low_penalty_ra)
-{
-       BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
-                 "[BTCoex], %s turn LowPenaltyRA = %s\n",
-                 (force_exec? "force to":""), ((low_penalty_ra)? "ON":"OFF"));
-       coex_dm->cur_low_penalty_ra = low_penalty_ra;
-
-       if (!force_exec) {
-               BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
-                         "[BTCoex] bPreLowPenaltyRa=%d, bCurLowPenaltyRa=%d\n",
-                         coex_dm->pre_low_penalty_ra,
-                         coex_dm->cur_low_penalty_ra);
-
-               if (coex_dm->pre_low_penalty_ra ==
-                   coex_dm->cur_low_penalty_ra)
-                       return;
-       }
-       halbtc8192e2ant_set_sw_penalty_tx_rateadaptive(btcoexist,
-                                               coex_dm->cur_low_penalty_ra);
-
-       coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra;
-}
-
-void halbtc8192e2ant_set_dac_swingreg(struct btc_coexist *btcoexist,
-                                     u32 level)
+static void halbtc8192e2ant_set_dac_swingreg(struct btc_coexist *btcoexist,
+                                            u32 level)
 {
        u8 val = (u8)level;
 
@@ -997,9 +951,9 @@ void halbtc8192e2ant_set_dac_swingreg(struct btc_coexist *btcoexist,
        btcoexist->btc_write_1byte_bitmask(btcoexist, 0x883, 0x3e, val);
 }
 
-void halbtc8192e2ant_setsw_fulltime_dacswing(struct btc_coexist *btcoexist,
-                                            bool sw_dac_swingon,
-                                            u32 sw_dac_swinglvl)
+static void halbtc8192e2ant_setsw_fulltime_dacswing(struct btc_coexist *btcoexist,
+                                                   bool sw_dac_swingon,
+                                                   u32 sw_dac_swinglvl)
 {
        if (sw_dac_swingon)
                halbtc8192e2ant_set_dac_swingreg(btcoexist, sw_dac_swinglvl);
@@ -1007,15 +961,14 @@ void halbtc8192e2ant_setsw_fulltime_dacswing(struct btc_coexist *btcoexist,
                halbtc8192e2ant_set_dac_swingreg(btcoexist, 0x18);
 }
 
-
-void halbtc8192e2ant_DacSwing(struct btc_coexist *btcoexist,
-                             bool force_exec, bool dac_swingon,
-                             u32 dac_swinglvl)
+static void halbtc8192e2ant_DacSwing(struct btc_coexist *btcoexist,
+                                    bool force_exec, bool dac_swingon,
+                                    u32 dac_swinglvl)
 {
        BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
                  "[BTCoex], %s turn DacSwing=%s, dac_swinglvl=0x%x\n",
-                 (force_exec? "force to":""),
-                 ((dac_swingon)? "ON":"OFF"), dac_swinglvl);
+                 (force_exec ? "force to":""),
+                 ((dac_swingon) ? "ON":"OFF"), dac_swinglvl);
        coex_dm->cur_dac_swing_on = dac_swingon;
        coex_dm->cur_dac_swing_lvl = dac_swinglvl;
 
@@ -1041,46 +994,8 @@ void halbtc8192e2ant_DacSwing(struct btc_coexist *btcoexist,
        coex_dm->pre_dac_swing_lvl = coex_dm->cur_dac_swing_lvl;
 }
 
-void halbtc8192e2ant_set_adc_backoff(struct btc_coexist *btcoexist,
-                                    bool adc_backoff)
-{
-       if(adc_backoff)
-       {
-               BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
-                         "[BTCoex], BB BackOff Level On!\n");
-               btcoexist->btc_write_1byte_bitmask(btcoexist, 0xc05, 0x30, 0x3);
-       }
-       else
-       {
-               BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
-                         "[BTCoex], BB BackOff Level Off!\n");
-               btcoexist->btc_write_1byte_bitmask(btcoexist, 0xc05, 0x30, 0x1);
-       }
-}
-
-void halbtc8192e2ant_adc_backoff(struct btc_coexist *btcoexist,
-                                bool force_exec, bool adc_backoff)
-{
-       BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
-                 "[BTCoex], %s turn AdcBackOff = %s\n",
-                 (force_exec? "force to":""), ((adc_backoff)? "ON":"OFF"));
-       coex_dm->cur_adc_back_off = adc_backoff;
-
-       if (!force_exec) {
-               BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
-                         "[BTCoex], bPreAdcBackOff=%d, bCurAdcBackOff=%d\n",
-                         coex_dm->pre_adc_back_off, coex_dm->cur_adc_back_off);
-
-               if (coex_dm->pre_adc_back_off == coex_dm->cur_adc_back_off)
-                       return;
-       }
-       halbtc8192e2ant_set_adc_backoff(btcoexist, coex_dm->cur_adc_back_off);
-
-       coex_dm->pre_adc_back_off = coex_dm->cur_adc_back_off;
-}
-
-void halbtc8192e2ant_set_agc_table(struct btc_coexist *btcoexist,
-                                  bool agc_table_en)
+static void halbtc8192e2ant_set_agc_table(struct btc_coexist *btcoexist,
+                                         bool agc_table_en)
 {
 
        /* BB AGC Gain Table */
@@ -1096,7 +1011,7 @@ void halbtc8192e2ant_set_agc_table(struct btc_coexist *btcoexist,
        } else {
                BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
                          "[BTCoex], BB Agc Table Off!\n");
-               btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xaa1A0001);
+               btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xaa1A0001);
                btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa91B0001);
                btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa81C0001);
                btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa71D0001);
@@ -1105,13 +1020,13 @@ void halbtc8192e2ant_set_agc_table(struct btc_coexist *btcoexist,
        }
 }
 
-void halbtc8192e2ant_AgcTable(struct btc_coexist *btcoexist,
-                             bool force_exec, bool agc_table_en)
+static void halbtc8192e2ant_AgcTable(struct btc_coexist *btcoexist,
+                                    bool force_exec, bool agc_table_en)
 {
        BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
                  "[BTCoex], %s %s Agc Table\n",
-                 (force_exec? "force to":""),
-                 ((agc_table_en)? "Enable":"Disable"));
+                 (force_exec ? "force to":""),
+                 ((agc_table_en) ? "Enable":"Disable"));
        coex_dm->cur_agc_table_en = agc_table_en;
 
        if (!force_exec) {
@@ -1127,9 +1042,9 @@ void halbtc8192e2ant_AgcTable(struct btc_coexist *btcoexist,
        coex_dm->pre_agc_table_en = coex_dm->cur_agc_table_en;
 }
 
-void halbtc8192e2ant_set_coex_table(struct btc_coexist *btcoexist,
-                                   u32 val0x6c0, u32 val0x6c4,
-                                   u32 val0x6c8, u8 val0x6cc)
+static void halbtc8192e2ant_set_coex_table(struct btc_coexist *btcoexist,
+                                          u32 val0x6c0, u32 val0x6c4,
+                                          u32 val0x6c8, u8 val0x6cc)
 {
        BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
                  "[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0);
@@ -1148,13 +1063,14 @@ void halbtc8192e2ant_set_coex_table(struct btc_coexist *btcoexist,
        btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc);
 }
 
-void halbtc8192e2ant_coex_table(struct btc_coexist *btcoexist, bool force_exec,
-                               u32 val0x6c0, u32 val0x6c4,
-                               u32 val0x6c8, u8 val0x6cc)
+static void halbtc8192e2ant_coex_table(struct btc_coexist *btcoexist,
+                                      bool force_exec,
+                                      u32 val0x6c0, u32 val0x6c4,
+                                      u32 val0x6c8, u8 val0x6cc)
 {
        BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
                  "[BTCoex], %s write Coex Table 0x6c0=0x%x, ",
-                 (force_exec? "force to":""), val0x6c0);
+                 (force_exec ? "force to":""), val0x6c0);
        BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
                  "0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
                  val0x6c4, val0x6c8, val0x6cc);
@@ -1171,7 +1087,7 @@ void halbtc8192e2ant_coex_table(struct btc_coexist *btcoexist, bool force_exec,
                          "preVal0x6c8=0x%x, preVal0x6cc=0x%x !!\n",
                          coex_dm->pre_val0x6c8, coex_dm->pre_val0x6cc);
                BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
-                         "[BTCoex], curVal0x6c0=0x%x, curVal0x6c4=0x%x, \n",
+                         "[BTCoex], curVal0x6c0=0x%x, curVal0x6c4=0x%x,\n",
                          coex_dm->cur_val0x6c0, coex_dm->cur_val0x6c4);
                BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
                          "curVal0x6c8=0x%x, curVal0x6cc=0x%x !!\n",
@@ -1192,8 +1108,8 @@ void halbtc8192e2ant_coex_table(struct btc_coexist *btcoexist, bool force_exec,
        coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc;
 }
 
-void halbtc8192e2ant_coex_table_with_type(struct btc_coexist *btcoexist,
-                                         bool force_exec, u8 type)
+static void halbtc8192e2ant_coex_table_with_type(struct btc_coexist *btcoexist,
+                                                bool force_exec, u8 type)
 {
        switch (type) {
        case 0:
@@ -1221,10 +1137,10 @@ void halbtc8192e2ant_coex_table_with_type(struct btc_coexist *btcoexist,
        }
 }
 
-void halbtc8192e2ant_set_fw_ignore_wlanact(struct btc_coexist *btcoexist,
-                                          bool enable)
+static void halbtc8192e2ant_set_fw_ignore_wlanact(struct btc_coexist *btcoexist,
+                                                 bool enable)
 {
-       u8 h2c_parameter[1] ={0};
+       u8 h2c_parameter[1] = {0};
 
        if (enable)
                h2c_parameter[0] |= BIT0; /* function enable */
@@ -1236,12 +1152,12 @@ void halbtc8192e2ant_set_fw_ignore_wlanact(struct btc_coexist *btcoexist,
        btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter);
 }
 
-void halbtc8192e2ant_IgnoreWlanAct(struct btc_coexist *btcoexist,
-                                  bool force_exec, bool enable)
+static void halbtc8192e2ant_IgnoreWlanAct(struct btc_coexist *btcoexist,
+                                         bool force_exec, bool enable)
 {
        BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
                  "[BTCoex], %s turn Ignore WlanAct %s\n",
-                 (force_exec? "force to":""), (enable? "ON":"OFF"));
+                 (force_exec ? "force to":""), (enable ? "ON":"OFF"));
        coex_dm->cur_ignore_wlan_act = enable;
 
        if (!force_exec) {
@@ -1261,10 +1177,10 @@ void halbtc8192e2ant_IgnoreWlanAct(struct btc_coexist *btcoexist,
        coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act;
 }
 
-void halbtc8192e2ant_SetFwPstdma(struct btc_coexist *btcoexist, u8 byte1,
-                                u8 byte2, u8 byte3, u8 byte4, u8 byte5)
+static void halbtc8192e2ant_SetFwPstdma(struct btc_coexist *btcoexist, u8 byte1,
+                                       u8 byte2, u8 byte3, u8 byte4, u8 byte5)
 {
-       u8 h2c_parameter[5] ={0};
+       u8 h2c_parameter[5] = {0};
 
        h2c_parameter[0] = byte1;
        h2c_parameter[1] = byte2;
@@ -1287,29 +1203,33 @@ void halbtc8192e2ant_SetFwPstdma(struct btc_coexist *btcoexist, u8 byte1,
        btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter);
 }
 
-void halbtc8192e2ant_sw_mechanism1(struct btc_coexist *btcoexist,
-                                  bool shrink_rx_lpf, bool low_penalty_ra,
-                                  bool limited_dig, bool btlan_constrain)
+static void halbtc8192e2ant_sw_mechanism1(struct btc_coexist *btcoexist,
+                                         bool shrink_rx_lpf,
+                                         bool low_penalty_ra,
+                                         bool limited_dig,
+                                         bool btlan_constrain)
 {
        halbtc8192e2ant_rf_shrink(btcoexist, NORMAL_EXEC, shrink_rx_lpf);
 }
 
-void halbtc8192e2ant_sw_mechanism2(struct btc_coexist *btcoexist,
-                                  bool agc_table_shift, bool adc_backoff,
-                                  bool sw_dac_swing, u32 dac_swinglvl)
+static void halbtc8192e2ant_sw_mechanism2(struct btc_coexist *btcoexist,
+                                         bool agc_table_shift,
+                                         bool adc_backoff,
+                                         bool sw_dac_swing,
+                                         u32 dac_swinglvl)
 {
        halbtc8192e2ant_AgcTable(btcoexist, NORMAL_EXEC, agc_table_shift);
        halbtc8192e2ant_DacSwing(btcoexist, NORMAL_EXEC, sw_dac_swing,
                                 dac_swinglvl);
 }
 
-void halbtc8192e2ant_ps_tdma(struct btc_coexist *btcoexist,
-                            bool force_exec, bool turn_on, u8 type)
+static void halbtc8192e2ant_ps_tdma(struct btc_coexist *btcoexist,
+                                   bool force_exec, bool turn_on, u8 type)
 {
 
        BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
                  "[BTCoex], %s turn %s PS TDMA, type=%d\n",
-                 (force_exec? "force to":""), (turn_on? "ON":"OFF"), type);
+                 (force_exec ? "force to":""), (turn_on ? "ON":"OFF"), type);
        coex_dm->cur_ps_tdma_on = turn_on;
        coex_dm->cur_ps_tdma = type;
 
@@ -1440,7 +1360,8 @@ void halbtc8192e2ant_ps_tdma(struct btc_coexist *btcoexist,
        coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma;
 }
 
-void halbtc8192e2ant_set_switch_sstype(struct btc_coexist *btcoexist, u8 sstype)
+static void halbtc8192e2ant_set_switch_sstype(struct btc_coexist *btcoexist,
+                                             u8 sstype)
 {
        u8 mimops = BTC_MIMO_PS_DYNAMIC;
        u32 disra_mask = 0x0;
@@ -1461,7 +1382,7 @@ void halbtc8192e2ant_set_switch_sstype(struct btc_coexist *btcoexist, u8 sstype)
                /* switch cck patch */
                btcoexist->btc_write_1byte_bitmask(btcoexist, 0xe77, 0x4, 0x1);
                btcoexist->btc_write_1byte(btcoexist, 0xa07, 0x81);
-               mimops=BTC_MIMO_PS_STATIC;
+               mimops = BTC_MIMO_PS_STATIC;
        } else if (sstype == 2) {
                halbtc8192e2ant_ps_tdma(btcoexist, FORCE_EXEC, false, 0);
                btcoexist->btc_write_1byte(btcoexist, 0xc04, 0x33);
@@ -1469,18 +1390,18 @@ void halbtc8192e2ant_set_switch_sstype(struct btc_coexist *btcoexist, u8 sstype)
                btcoexist->btc_write_4byte(btcoexist, 0x90c, 0x81121313);
                btcoexist->btc_write_1byte_bitmask(btcoexist, 0xe77, 0x4, 0x0);
                btcoexist->btc_write_1byte(btcoexist, 0xa07, 0x41);
-               mimops=BTC_MIMO_PS_DYNAMIC;
+               mimops = BTC_MIMO_PS_DYNAMIC;
        }
        /* set rx 1ss or 2ss */
        btcoexist->btc_set(btcoexist, BTC_SET_ACT_SEND_MIMO_PS, &mimops);
 }
 
-void halbtc8192e2ant_switch_sstype(struct btc_coexist *btcoexist,
+static void halbtc8192e2ant_switch_sstype(struct btc_coexist *btcoexist,
                                   bool force_exec, u8 new_sstype)
 {
        BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
                  "[BTCoex], %s Switch SS Type = %d\n",
-                 (force_exec? "force to":""), new_sstype);
+                 (force_exec ? "force to":""), new_sstype);
        coex_dm->cur_sstype = new_sstype;
 
        if (!force_exec) {
@@ -1492,7 +1413,7 @@ void halbtc8192e2ant_switch_sstype(struct btc_coexist *btcoexist,
        coex_dm->pre_sstype = coex_dm->cur_sstype;
 }
 
-void halbtc8192e2ant_coex_alloff(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_coex_alloff(struct btc_coexist *btcoexist)
 {
        /* fw all off */
        halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
@@ -1507,7 +1428,7 @@ void halbtc8192e2ant_coex_alloff(struct btc_coexist *btcoexist)
        halbtc8192e2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
 }
 
-void halbtc8192e2ant_init_coex_dm(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_init_coex_dm(struct btc_coexist *btcoexist)
 {
        /* force to reset coex mechanism */
 
@@ -1522,7 +1443,7 @@ void halbtc8192e2ant_init_coex_dm(struct btc_coexist *btcoexist)
        halbtc8192e2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
 }
 
-void halbtc8192e2ant_action_bt_inquiry(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_action_bt_inquiry(struct btc_coexist *btcoexist)
 {
        bool low_pwr_disable = true;
 
@@ -1540,7 +1461,7 @@ void halbtc8192e2ant_action_bt_inquiry(struct btc_coexist *btcoexist)
        halbtc8192e2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
 }
 
-bool halbtc8192e2ant_is_common_action(struct btc_coexist *btcoexist)
+static bool halbtc8192e2ant_is_common_action(struct btc_coexist *btcoexist)
 {
        struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
        bool common = false, wifi_connected = false, wifi_busy = false;
@@ -1586,7 +1507,7 @@ bool halbtc8192e2ant_is_common_action(struct btc_coexist *btcoexist)
                halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6);
                halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
 
-               halbtc8192e2ant_sw_mechanism1(btcoexist, false, false, false,
+               halbtc8192e2ant_sw_mechanism1(btcoexist, false, false, false,
                                              false);
                halbtc8192e2ant_sw_mechanism2(btcoexist, false, false, false,
                                              0x18);
@@ -1685,9 +1606,9 @@ bool halbtc8192e2ant_is_common_action(struct btc_coexist *btcoexist)
        return common;
 }
 
-void halbtc8192e2ant_tdma_duration_adjust(struct btc_coexist *btcoexist,
-                                         bool sco_hid, bool tx_pause,
-                                         u8 max_interval)
+static void halbtc8192e2ant_tdma_duration_adjust(struct btc_coexist *btcoexist,
+                                                bool sco_hid, bool tx_pause,
+                                                u8 max_interval)
 {
        static int up, dn, m, n, wait_cnt;
        /* 0: no change, +1: increase WiFi duration,
@@ -1799,7 +1720,7 @@ void halbtc8192e2ant_tdma_duration_adjust(struct btc_coexist *btcoexist,
                up = 0;
                dn = 0;
                m = 1;
-               n= 3;
+               n = 3;
                result = 0;
                wait_cnt = 0;
        } else {
@@ -2116,7 +2037,7 @@ void halbtc8192e2ant_tdma_duration_adjust(struct btc_coexist *btcoexist,
                                                                             12;
                                        }
                                } else if (result == 1) {
-                                       if (coex_dm->cur_ps_tdma == 4) {
+                                       if (coex_dm->cur_ps_tdma == 4) {
                                                halbtc8192e2ant_ps_tdma(
                                                                    btcoexist,
                                                                    NORMAL_EXEC,
@@ -2416,21 +2337,21 @@ void halbtc8192e2ant_tdma_duration_adjust(struct btc_coexist *btcoexist,
                                                                    true, 2);
                                                coex_dm->ps_tdma_du_adj_type =
                                                                             2;
-                                       } else if(coex_dm->cur_ps_tdma == 12) {
+                                       } else if (coex_dm->cur_ps_tdma == 12) {
                                                halbtc8192e2ant_ps_tdma(
                                                                    btcoexist,
                                                                    NORMAL_EXEC,
                                                                    true, 11);
                                                coex_dm->ps_tdma_du_adj_type =
                                                                             11;
-                                       } else if(coex_dm->cur_ps_tdma == 11) {
+                                       } else if (coex_dm->cur_ps_tdma == 11) {
                                                halbtc8192e2ant_ps_tdma(
                                                                    btcoexist,
                                                                    NORMAL_EXEC,
                                                                    true, 10);
                                                coex_dm->ps_tdma_du_adj_type =
                                                                             10;
-                                       } else if(coex_dm->cur_ps_tdma == 10) {
+                                       } else if (coex_dm->cur_ps_tdma == 10) {
                                                halbtc8192e2ant_ps_tdma(
                                                                    btcoexist,
                                                                    NORMAL_EXEC,
@@ -2721,7 +2642,7 @@ void halbtc8192e2ant_tdma_duration_adjust(struct btc_coexist *btcoexist,
        if (coex_dm->cur_ps_tdma != coex_dm->ps_tdma_du_adj_type) {
                bool scan = false, link = false, roam = false;
                BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
-                         "[BTCoex], PsTdma type dismatch!!!, " );
+                         "[BTCoex], PsTdma type dismatch!!!, ");
                BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
                          "curPsTdma=%d, recordPsTdma=%d\n",
                          coex_dm->cur_ps_tdma, coex_dm->ps_tdma_du_adj_type);
@@ -2730,7 +2651,7 @@ void halbtc8192e2ant_tdma_duration_adjust(struct btc_coexist *btcoexist,
                btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
                btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
 
-               if ( !scan && !link && !roam)
+               if (!scan && !link && !roam)
                        halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC,
                                                true,
                                                coex_dm->ps_tdma_du_adj_type);
@@ -2742,7 +2663,7 @@ void halbtc8192e2ant_tdma_duration_adjust(struct btc_coexist *btcoexist,
 }
 
 /* SCO only or SCO+PAN(HS) */
-void halbtc8192e2ant_action_sco(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_action_sco(struct btc_coexist *btcoexist)
 {
        u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_STAY_LOW;
        u32 wifi_bw;
@@ -2804,7 +2725,7 @@ void halbtc8192e2ant_action_sco(struct btc_coexist *btcoexist)
        }
 }
 
-void halbtc8192e2ant_action_sco_pan(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_action_sco_pan(struct btc_coexist *btcoexist)
 {
        u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_STAY_LOW;
        u32 wifi_bw;
@@ -2866,9 +2787,9 @@ void halbtc8192e2ant_action_sco_pan(struct btc_coexist *btcoexist)
        }
 }
 
-void halbtc8192e2ant_action_hid(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_action_hid(struct btc_coexist *btcoexist)
 {
-       u8 wifirssi_state, btrssi_state=BTC_RSSI_STATE_HIGH;
+       u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH;
        u32 wifi_bw;
 
        wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0);
@@ -2906,7 +2827,7 @@ void halbtc8192e2ant_action_hid(struct btc_coexist *btcoexist)
                        halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
                                                      false, 0x18);
                } else {
-                       halbtc8192e2ant_sw_mechanism1(btcoexist, true, true,
+                       halbtc8192e2ant_sw_mechanism1(btcoexist, true, true,
                                                      false, false);
                        halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
                                                      false, 0x18);
@@ -2918,8 +2839,8 @@ void halbtc8192e2ant_action_hid(struct btc_coexist *btcoexist)
                                                      false, false);
                        halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
                                                      false, 0x18);
-               } else {
-                       halbtc8192e2ant_sw_mechanism1(btcoexist, false, true,
+               } else {
+                       halbtc8192e2ant_sw_mechanism1(btcoexist, false, true,
                                                      false, false);
                        halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
                                                      false, 0x18);
@@ -2928,7 +2849,7 @@ void halbtc8192e2ant_action_hid(struct btc_coexist *btcoexist)
 }
 
 /* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */
-void halbtc8192e2ant_action_a2dp(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_action_a2dp(struct btc_coexist *btcoexist)
 {
        u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH;
        u32 wifi_bw;
@@ -2991,7 +2912,7 @@ void halbtc8192e2ant_action_a2dp(struct btc_coexist *btcoexist)
        if (BTC_WIFI_BW_HT40 == wifi_bw) {
                if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
                    (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
-                       halbtc8192e2ant_sw_mechanism1(btcoexist, true, false,
+                       halbtc8192e2ant_sw_mechanism1(btcoexist, true, false,
                                                      false, false);
                        halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
                                                      false, 0x18);
@@ -3017,7 +2938,7 @@ void halbtc8192e2ant_action_a2dp(struct btc_coexist *btcoexist)
        }
 }
 
-void halbtc8192e2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist)
 {
        u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH;
        u32 wifi_bw;
@@ -3052,7 +2973,7 @@ void halbtc8192e2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist)
        if (BTC_WIFI_BW_HT40 == wifi_bw) {
                if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
                    (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
-                       halbtc8192e2ant_sw_mechanism1(btcoexist, true, false,
+                       halbtc8192e2ant_sw_mechanism1(btcoexist, true, false,
                                                      false, false);
                        halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
                                                      true, 0x6);
@@ -3078,7 +2999,7 @@ void halbtc8192e2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist)
        }
 }
 
-void halbtc8192e2ant_action_pan_edr(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_action_pan_edr(struct btc_coexist *btcoexist)
 {
        u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH;
        u32 wifi_bw;
@@ -3139,7 +3060,7 @@ void halbtc8192e2ant_action_pan_edr(struct btc_coexist *btcoexist)
 }
 
 /* PAN(HS) only */
-void halbtc8192e2ant_action_pan_hs(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_action_pan_hs(struct btc_coexist *btcoexist)
 {
        u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH;
        u32 wifi_bw;
@@ -3197,9 +3118,9 @@ void halbtc8192e2ant_action_pan_hs(struct btc_coexist *btcoexist)
 }
 
 /* PAN(EDR)+A2DP */
-void halbtc8192e2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist)
 {
-       u8 wifirssi_state, btrssi_state=BTC_RSSI_STATE_HIGH;
+       u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH;
        u32 wifi_bw;
 
        wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0);
@@ -3260,7 +3181,7 @@ void halbtc8192e2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist)
        }
 }
 
-void halbtc8192e2ant_action_pan_edr_hid(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_action_pan_edr_hid(struct btc_coexist *btcoexist)
 {
        u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH;
        u32 wifi_bw;
@@ -3280,15 +3201,15 @@ void halbtc8192e2ant_action_pan_edr_hid(struct btc_coexist *btcoexist)
        if ((btrssi_state == BTC_RSSI_STATE_LOW) ||
            (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) {
                halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
-               halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
+               halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
        } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) ||
                   (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) {
                halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2);
-               halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 10);
+               halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 10);
        } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) ||
                   (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
                halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4);
-               halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 10);
+               halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 10);
        }
 
        /* sw mechanism */
@@ -3322,7 +3243,7 @@ void halbtc8192e2ant_action_pan_edr_hid(struct btc_coexist *btcoexist)
 }
 
 /* HID+A2DP+PAN(EDR) */
-void halbtc8192e2ant_action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist)
 {
        u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH;
        u32 wifi_bw;
@@ -3383,7 +3304,7 @@ void halbtc8192e2ant_action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist)
        }
 }
 
-void halbtc8192e2ant_action_hid_a2dp(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_action_hid_a2dp(struct btc_coexist *btcoexist)
 {
        u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH;
        u32 wifi_bw;
@@ -3403,7 +3324,7 @@ void halbtc8192e2ant_action_hid_a2dp(struct btc_coexist *btcoexist)
                halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
                halbtc8192e2ant_tdma_duration_adjust(btcoexist, true, true, 2);
        } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) ||
-                  (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM))        {
+                  (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) {
                halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2);
                halbtc8192e2ant_tdma_duration_adjust(btcoexist, true, false, 2);
        } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) ||
@@ -3442,7 +3363,7 @@ void halbtc8192e2ant_action_hid_a2dp(struct btc_coexist *btcoexist)
        }
 }
 
-void halbtc8192e2ant_run_coexist_mechanism(struct btc_coexist *btcoexist)
+static void halbtc8192e2ant_run_coexist_mechanism(struct btc_coexist *btcoexist)
 {
        u8 algorithm = 0;
 
@@ -3472,7 +3393,7 @@ void halbtc8192e2ant_run_coexist_mechanism(struct btc_coexist *btcoexist)
 
        coex_dm->cur_algorithm = algorithm;
        BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
-                 "[BTCoex], Algorithm = %d \n", coex_dm->cur_algorithm);
+                 "[BTCoex], Algorithm = %d\n", coex_dm->cur_algorithm);
 
        if (halbtc8192e2ant_is_common_action(btcoexist)) {
                BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
@@ -3552,7 +3473,8 @@ void halbtc8192e2ant_run_coexist_mechanism(struct btc_coexist *btcoexist)
        }
 }
 
-void halbtc8192e2ant_init_hwconfig(struct btc_coexist *btcoexist, bool backup)
+static void halbtc8192e2ant_init_hwconfig(struct btc_coexist *btcoexist,
+                                         bool backup)
 {
        u16 u16tmp = 0;
        u8 u8tmp = 0;
@@ -3649,7 +3571,7 @@ void ex_halbtc8192e2ant_init_coex_dm(struct btc_coexist *btcoexist)
 void ex_halbtc8192e2ant_display_coex_info(struct btc_coexist *btcoexist)
 {
        struct btc_board_info *board_info = &btcoexist->board_info;
-       struct btc_stack_info*stack_info = &btcoexist->stack_info;
+       struct btc_stack_info *stack_info = &btcoexist->stack_info;
        u8 *cli_buf = btcoexist->cli_buf;
        u8 u8tmp[4], i, bt_info_ext, ps_tdma_case = 0;
        u16 u16tmp[4];
@@ -3735,9 +3657,9 @@ void ex_halbtc8192e2ant_display_coex_info(struct btc_coexist *btcoexist)
        CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ",
                   "Wifi status", (wifi_under_5g ? "5G" : "2.4G"),
                   ((BTC_WIFI_BW_LEGACY == wifi_bw) ? "Legacy" :
-                       (((BTC_WIFI_BW_HT40 == wifi_bw) ? "HT40" : "HT20"))),
+                       (((BTC_WIFI_BW_HT40 == wifi_bw) ? "HT40" : "HT20"))),
                   ((!wifi_busy) ? "idle" :
-                       ((BTC_WIFI_TRAFFIC_TX == wifi_traffic_dir) ?
+                       ((BTC_WIFI_TRAFFIC_TX == wifi_traffic_dir) ?
                                "uplink" : "downlink")));
        CL_PRINTF(cli_buf);
 
@@ -3766,7 +3688,7 @@ void ex_halbtc8192e2ant_display_coex_info(struct btc_coexist *btcoexist)
                   (bt_info_ext&BIT0) ? "Basic rate" : "EDR rate");
        CL_PRINTF(cli_buf);
 
-       for (i=0; i<BT_INFO_SRC_8192E_2ANT_MAX; i++) {
+       for (i = 0; i < BT_INFO_SRC_8192E_2ANT_MAX; i++) {
                if (coex_sta->bt_info_c2h_cnt[i]) {
                        CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
                                   "\r\n %-35s = %02x %02x %02x %02x ",
@@ -3911,7 +3833,7 @@ void ex_halbtc8192e2ant_display_coex_info(struct btc_coexist *btcoexist)
                   "0x774(lp rx[31:16]/tx[15:0])",
                   coex_sta->low_priority_rx, coex_sta->low_priority_tx);
        CL_PRINTF(cli_buf);
-#if(BT_AUTO_REPORT_ONLY_8192E_2ANT == 1)
+#if (BT_AUTO_REPORT_ONLY_8192E_2ANT == 1)
        halbtc8192e2ant_monitor_bt_ctr(btcoexist);
 #endif
        btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS);
@@ -3950,7 +3872,7 @@ void ex_halbtc8192e2ant_scan_notify(struct btc_coexist *btcoexist, u8 type)
        if (BTC_SCAN_START == type)
                BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
                          "[BTCoex], SCAN START notify\n");
-       else if(BTC_SCAN_FINISH == type)
+       else if (BTC_SCAN_FINISH == type)
                BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
                          "[BTCoex], SCAN FINISH notify\n");
 }
@@ -3960,7 +3882,7 @@ void ex_halbtc8192e2ant_connect_notify(struct btc_coexist *btcoexist, u8 type)
        if (BTC_ASSOCIATE_START == type)
                BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
                          "[BTCoex], CONNECT START notify\n");
-       else if(BTC_ASSOCIATE_FINISH == type)
+       else if (BTC_ASSOCIATE_FINISH == type)
                BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
                          "[BTCoex], CONNECT FINISH notify\n");
 }
@@ -3968,7 +3890,7 @@ void ex_halbtc8192e2ant_connect_notify(struct btc_coexist *btcoexist, u8 type)
 void ex_halbtc8192e2ant_media_status_notify(struct btc_coexist *btcoexist,
                                            u8 type)
 {
-       u8 h2c_parameter[3] ={0};
+       u8 h2c_parameter[3] = {0};
        u32 wifi_bw;
        u8 wifi_center_chnl;
 
@@ -4014,12 +3936,12 @@ void ex_halbtc8192e2ant_special_packet_notify(struct btc_coexist *btcoexist,
                                              u8 type)
 {
        if (type == BTC_PACKET_DHCP)
-               BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
+               BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
                          "[BTCoex], DHCP Packet notify\n");
- }
+}
 
 void ex_halbtc8192e2ant_bt_info_notify(struct btc_coexist *btcoexist,
-                                      u8 *tmp_buf, u8 length )
+                                      u8 *tmp_buf, u8 length)
 {
        u8 bt_info = 0;
        u8 i, rspSource = 0;
@@ -4089,7 +4011,7 @@ void ex_halbtc8192e2ant_bt_info_notify(struct btc_coexist *btcoexist,
                         * do nothing here. */
                }
 
-#if(BT_AUTO_REPORT_ONLY_8192E_2ANT == 0)
+#if (BT_AUTO_REPORT_ONLY_8192E_2ANT == 0)
                if ((coex_sta->bt_info_ext & BIT4)) {
                        /* BT auto report already enabled, do nothing */
                } else {
@@ -4100,7 +4022,7 @@ void ex_halbtc8192e2ant_bt_info_notify(struct btc_coexist *btcoexist,
        }
 
        /* check BIT2 first ==> check if bt is under inquiry or page scan */
-       if(bt_info & BT_INFO_8192E_2ANT_B_INQ_PAGE)
+       if (bt_info & BT_INFO_8192E_2ANT_B_INQ_PAGE)
                coex_sta->c2h_bt_inquiry_page = true;
        else
                coex_sta->c2h_bt_inquiry_page = false;
@@ -4180,10 +4102,10 @@ void ex_halbtc8192e2ant_stack_operation_notify(struct btc_coexist *btcoexist,
 {
        if (BTC_STACK_OP_INQ_PAGE_PAIR_START == type)
                BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
-                         "[BTCoex] StackOP Inquiry/page/pair start notify\n");
-       else if(BTC_STACK_OP_INQ_PAGE_PAIR_FINISH == type)
+                         "[BTCoex] StackOP Inquiry/page/pair start notify\n");
+       else if (BTC_STACK_OP_INQ_PAGE_PAIR_FINISH == type)
                BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
-                         "[BTCoex] StackOP Inquiry/page/pair finish notify\n");
+                         "[BTCoex] StackOP Inquiry/page/pair finish notify\n");
 }
 
 void ex_halbtc8192e2ant_halt_notify(struct btc_coexist *btcoexist)
@@ -4196,10 +4118,10 @@ void ex_halbtc8192e2ant_halt_notify(struct btc_coexist *btcoexist)
 
 void ex_halbtc8192e2ant_periodical(struct btc_coexist *btcoexist)
 {
-       static u8 dis_ver_info_cnt = 0;
+       static u8 dis_ver_info_cnt;
        u32 fw_ver = 0, bt_patch_ver = 0;
-       struct btc_board_info *board_info=&btcoexist->board_info;
-       struct btc_stack_info *stack_info=&btcoexist->stack_info;
+       struct btc_board_info *board_info = &btcoexist->board_info;
+       struct btc_stack_info *stack_info = &btcoexist->stack_info;
 
        BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
                  "=======================Periodical=======================\n");
@@ -4226,7 +4148,7 @@ void ex_halbtc8192e2ant_periodical(struct btc_coexist *btcoexist)
                          "************************************************\n");
        }
 
-#if(BT_AUTO_REPORT_ONLY_8192E_2ANT == 0)
+#if (BT_AUTO_REPORT_ONLY_8192E_2ANT == 0)
        halbtc8192e2ant_querybt_info(btcoexist);
        halbtc8192e2ant_monitor_bt_ctr(btcoexist);
        halbtc8192e2ant_monitor_bt_enable_disable(btcoexist);
@@ -4237,6 +4159,3 @@ void ex_halbtc8192e2ant_periodical(struct btc_coexist *btcoexist)
 #endif
 }
 
-
-#endif
-
index a562aa60d5955bf3a2d15c4383379e85e5fff1d9..94f72832a83881d0a9c695e58dc2ae0684206ba2 100644 (file)
@@ -2313,16 +2313,16 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev,
 
        /*shared mem start */
        rtlpriv->io.pci_mem_start =
-                       (unsigned long)pci_iomap(pdev,
+                       pci_iomap(pdev,
                        rtlpriv->cfg->bar_id, pmem_len);
-       if (rtlpriv->io.pci_mem_start == 0) {
+       if (rtlpriv->io.pci_mem_start == NULL) {
                RT_ASSERT(false, ("Can't map PCI mem\n"));
                goto fail2;
        }
 
        RT_TRACE(COMP_INIT, DBG_DMESG,
                 ("mem mapped space: start: 0x%08lx len:%08lx "
-                 "flags:%08lx, after map:0x%08lx\n",
+                 "flags:%08lx, after map:0x%p\n",
                  pmem_start, pmem_len, pmem_flags,
                  rtlpriv->io.pci_mem_start));
 
@@ -2415,8 +2415,8 @@ fail3:
        rtl_deinit_core(hw);
        ieee80211_free_hw(hw);
 
-       if (rtlpriv->io.pci_mem_start != 0)
-               pci_iounmap(pdev, (void *)rtlpriv->io.pci_mem_start);
+       if (rtlpriv->io.pci_mem_start != NULL)
+               pci_iounmap(pdev, rtlpriv->io.pci_mem_start);
 
 fail2:
        pci_release_regions(pdev);
@@ -2478,8 +2478,8 @@ void rtl_pci_disconnect(struct pci_dev *pdev)
                pci_disable_msi(rtlpci->pdev);
 
        list_del(&rtlpriv->list);
-       if (rtlpriv->io.pci_mem_start != 0) {
-               pci_iounmap(pdev, (void *)rtlpriv->io.pci_mem_start);
+       if (rtlpriv->io.pci_mem_start != NULL) {
+               pci_iounmap(pdev, rtlpriv->io.pci_mem_start);
                pci_release_regions(pdev);
        }
 
index 4fb6bf0d1da2de68f72b5d73fb8dc936924f1c30..256e514f424ab25f425e744419e0695cfa26b0a3 100644 (file)
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  * more details.
  *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
  * The full GNU General Public License is included in this distribution in the
  * file called LICENSE.
  *
@@ -34,42 +30,43 @@ void rtl8821ae_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
 void rtl8821ae_read_eeprom_info(struct ieee80211_hw *hw);
 
 void rtl8821ae_interrupt_recognized(struct ieee80211_hw *hw,
-                                                                                        u32 *p_inta, u32 *p_intb);
+                                   u32 *p_inta, u32 *p_intb);
 int rtl8821ae_hw_init(struct ieee80211_hw *hw);
 void rtl8821ae_card_disable(struct ieee80211_hw *hw);
 void rtl8821ae_enable_interrupt(struct ieee80211_hw *hw);
 void rtl8821ae_disable_interrupt(struct ieee80211_hw *hw);
-int rtl8821ae_set_network_type(struct ieee80211_hw *hw, enum nl80211_iftype type);
+int rtl8821ae_set_network_type(struct ieee80211_hw *hw,
+                              enum nl80211_iftype type);
 void rtl8821ae_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid);
 void rtl8821ae_set_qos(struct ieee80211_hw *hw, int aci);
 void rtl8821ae_set_beacon_related_registers(struct ieee80211_hw *hw);
 void rtl8821ae_set_beacon_interval(struct ieee80211_hw *hw);
 void rtl8821ae_update_interrupt_mask(struct ieee80211_hw *hw,
-                                                                                               u32 add_msr, u32 rm_msr);
+                                    u32 add_msr, u32 rm_msr);
 void rtl8821ae_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
 void rtl8821ae_update_hal_rate_tbl(struct ieee80211_hw *hw,
-                                                                                       struct ieee80211_sta *sta,
-                                                                                       u8 rssi_level);
+                                  struct ieee80211_sta *sta,
+                                  u8 rssi_level);
 void rtl8821ae_update_channel_access_setting(struct ieee80211_hw *hw);
 bool rtl8821ae_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid);
 void rtl8821ae_enable_hw_security_config(struct ieee80211_hw *hw);
 void rtl8821ae_set_key(struct ieee80211_hw *hw, u32 key_index,
-                                               u8 *p_macaddr, bool is_group, u8 enc_algo,
-                                               bool is_wepkey, bool clear_all);
+                      u8 *p_macaddr, bool is_group, u8 enc_algo,
+                      bool is_wepkey, bool clear_all);
 
 void rtl8821ae_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw,
-                                                                                                                       bool autoload_fail,
-                                                                                                                       u8* hwinfo);
+                                             bool autoload_fail,
+                                             u8 *hwinfo);
 void rtl8812ae_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw,
-                                                                                                                       bool autoload_fail,
-                                                                                                                       u8* hwinfo);
-void rtl8821ae_bt_reg_init(struct ieee80211_hwhw);
-void rtl8821ae_bt_hw_init(struct ieee80211_hwhw);
+                                             bool autoload_fail,
+                                             u8 *hwinfo);
+void rtl8821ae_bt_reg_init(struct ieee80211_hw *hw);
+void rtl8821ae_bt_hw_init(struct ieee80211_hw *hw);
 void rtl8821ae_suspend(struct ieee80211_hw *hw);
 void rtl8821ae_resume(struct ieee80211_hw *hw);
 void rtl8821ae_allow_all_destaddr(struct ieee80211_hw *hw,
-                                                                                 bool allow_all_da,
-                                                                                 bool write_into_reg);
+                                 bool allow_all_da,
+                                 bool write_into_reg);
 void _rtl8821ae_stop_tx_beacon(struct ieee80211_hw *hw);
 void _rtl8821ae_resume_tx_beacon(struct ieee80211_hw *hw);
 #endif
index 17a9d9f8781d53b95688cff21a654e95183d91e1..e8250dad613bd75668983798082a7438e11f7d71 100644 (file)
@@ -1086,8 +1086,8 @@ struct rtl_io {
        struct device *dev;
 
        /*PCI MEM map */
-       unsigned long pci_mem_end;      /*shared mem end        */
-       unsigned long pci_mem_start;    /*shared mem start */
+       void __iomem *pci_mem_end;      /*shared mem end        */
+       void __iomem *pci_mem_start;    /*shared mem start */
 
        /*PCI IO map */
        unsigned long pci_base_addr;    /*device I/O address */
diff --git a/drivers/staging/sbe-2t3e3/2t3e3.h b/drivers/staging/sbe-2t3e3/2t3e3.h
deleted file mode 100644 (file)
index e7bf721..0000000
+++ /dev/null
@@ -1,889 +0,0 @@
-/*
- * SBE 2T3E3 synchronous serial card driver for Linux
- *
- * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- *
- * This code is based on a driver written by SBE Inc.
- */
-
-#ifndef T3E3_H
-#define T3E3_H
-
-#include <linux/hdlc.h>
-#include <linux/interrupt.h>
-#include <linux/netdevice.h>
-#include <linux/pci.h>
-#include <linux/io.h>
-#include "ctrl.h"
-
-/**************************************************************
- *  21143
- **************************************************************/
-
-/* CSR */
-#define SBE_2T3E3_21143_REG_BUS_MODE                                   0
-#define SBE_2T3E3_21143_REG_TRANSMIT_POLL_DEMAND                       1
-#define SBE_2T3E3_21143_REG_RECEIVE_POLL_DEMAND                                2
-#define SBE_2T3E3_21143_REG_RECEIVE_LIST_BASE_ADDRESS                  3
-#define SBE_2T3E3_21143_REG_TRANSMIT_LIST_BASE_ADDRESS                 4
-#define SBE_2T3E3_21143_REG_STATUS                                     5
-#define SBE_2T3E3_21143_REG_OPERATION_MODE                             6
-#define SBE_2T3E3_21143_REG_INTERRUPT_ENABLE                           7
-#define SBE_2T3E3_21143_REG_MISSED_FRAMES_AND_OVERFLOW_COUNTER         8
-#define SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT     9
-#define SBE_2T3E3_21143_REG_BOOT_ROM_PROGRAMMING_ADDRESS               10
-#define SBE_2T3E3_21143_REG_GENERAL_PURPOSE_TIMER_AND_INTERRUPT_MITIGATION_CONTROL 11
-#define SBE_2T3E3_21143_REG_SIA_STATUS                                 12
-#define SBE_2T3E3_21143_REG_SIA_CONNECTIVITY                           13
-#define SBE_2T3E3_21143_REG_SIA_TRANSMIT_AND_RECEIVE                   14
-#define SBE_2T3E3_21143_REG_SIA_AND_GENERAL_PURPOSE_PORT               15
-#define SBE_2T3E3_21143_REG_MAX                                                16
-
-/* CSR0 - BUS_MODE */
-#define SBE_2T3E3_21143_VAL_WRITE_AND_INVALIDATE_ENABLE                0x01000000
-#define SBE_2T3E3_21143_VAL_READ_LINE_ENABLE                   0x00800000
-#define SBE_2T3E3_21143_VAL_READ_MULTIPLE_ENABLE               0x00200000
-#define SBE_2T3E3_21143_VAL_TRANSMIT_AUTOMATIC_POLLING_200us   0x00020000
-#define SBE_2T3E3_21143_VAL_TRANSMIT_AUTOMATIC_POLLING_DISABLED        0x00000000
-#define SBE_2T3E3_21143_VAL_CACHE_ALIGNMENT_32                 0x0000c000
-#define SBE_2T3E3_21143_VAL_CACHE_ALIGNMENT_16                 0x00008000
-#define SBE_2T3E3_21143_VAL_CACHE_ALIGNMENT_8                  0x00004000
-#define SBE_2T3E3_21143_VAL_BUS_ARBITRATION_RR                 0x00000002
-#define SBE_2T3E3_21143_VAL_SOFTWARE_RESET                     0x00000001
-
-/* CSR5 - STATUS */
-#define SBE_2T3E3_21143_VAL_GENERAL_PURPOSE_PORT_INTERRUPT     0x04000000
-#define SBE_2T3E3_21143_VAL_ERROR_BITS                         0x03800000
-#define SBE_2T3E3_21143_VAL_PARITY_ERROR                       0x00000000
-#define SBE_2T3E3_21143_VAL_MASTER_ABORT                       0x00800000
-#define SBE_2T3E3_21143_VAL_TARGET_ABORT                       0x01000000
-#define SBE_2T3E3_21143_VAL_TRANSMISSION_PROCESS_STATE         0x00700000
-#define SBE_2T3E3_21143_VAL_TX_STOPPED                         0x00000000
-#define SBE_2T3E3_21143_VAL_TX_SUSPENDED                       0x00600000
-#define SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STATE              0x000e0000
-#define SBE_2T3E3_21143_VAL_RX_STOPPED                         0x00000000
-#define SBE_2T3E3_21143_VAL_RX_SUSPENDED                       0x000a0000
-#define SBE_2T3E3_21143_VAL_NORMAL_INTERRUPT_SUMMARY           0x00010000
-#define SBE_2T3E3_21143_VAL_ABNORMAL_INTERRUPT_SUMMARY         0x00008000
-#define SBE_2T3E3_21143_VAL_EARLY_RECEIVE_INTERRUPT            0x00004000
-#define SBE_2T3E3_21143_VAL_FATAL_BUS_ERROR                    0x00002000
-#define SBE_2T3E3_21143_VAL_GENERAL_PURPOSE_TIMER_EXPIRED      0x00000800
-#define SBE_2T3E3_21143_VAL_EARLY_TRANSMIT_INTERRUPT           0x00000400
-#define SBE_2T3E3_21143_VAL_RECEIVE_WATCHDOG_TIMEOUT           0x00000200
-#define SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STOPPED            0x00000100
-#define SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE         0x00000080
-#define SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT                  0x00000040
-#define SBE_2T3E3_21143_VAL_TRANSMIT_UNDERFLOW                 0x00000020
-#define SBE_2T3E3_21143_VAL_TRANSMIT_JABBER_TIMEOUT            0x00000008
-#define SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE                0x00000004
-#define SBE_2T3E3_21143_VAL_TRANSMIT_PROCESS_STOPPED           0x00000002
-#define SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT                 0x00000001
-
-/* CSR6 - OPERATION_MODE */
-#define SBE_2T3E3_21143_VAL_SPECIAL_CAPTURE_EFFECT_ENABLE      0x80000000
-#define SBE_2T3E3_21143_VAL_RECEIVE_ALL                                0x40000000
-#define SBE_2T3E3_21143_VAL_MUST_BE_ONE                                0x02000000
-#define SBE_2T3E3_21143_VAL_SCRAMBLER_MODE                     0x01000000
-#define SBE_2T3E3_21143_VAL_PCS_FUNCTION                       0x00800000
-#define SBE_2T3E3_21143_VAL_TRANSMIT_THRESHOLD_MODE_10Mbs      0x00400000
-#define SBE_2T3E3_21143_VAL_TRANSMIT_THRESHOLD_MODE_100Mbs     0x00000000
-#define SBE_2T3E3_21143_VAL_STORE_AND_FORWARD                  0x00200000
-#define SBE_2T3E3_21143_VAL_HEARTBEAT_DISABLE                  0x00080000
-#define SBE_2T3E3_21143_VAL_PORT_SELECT                                0x00040000
-#define SBE_2T3E3_21143_VAL_CAPTURE_EFFECT_ENABLE              0x00020000
-#define SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS             0x0000c000
-#define SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_1           0x00000000
-#define SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_2           0x00004000
-#define SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_3           0x00008000
-#define SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_4           0x0000c000
-#define SBE_2T3E3_21143_VAL_TRANSMISSION_START                 0x00002000
-#define SBE_2T3E3_21143_VAL_OPERATING_MODE                     0x00000c00
-#define SBE_2T3E3_21143_VAL_LOOPBACK_OFF                       0x00000000
-#define SBE_2T3E3_21143_VAL_LOOPBACK_EXTERNAL                  0x00000800
-#define SBE_2T3E3_21143_VAL_LOOPBACK_INTERNAL                  0x00000400
-#define SBE_2T3E3_21143_VAL_FULL_DUPLEX_MODE                   0x00000200
-#define SBE_2T3E3_21143_VAL_PASS_ALL_MULTICAST                 0x00000080
-#define SBE_2T3E3_21143_VAL_PROMISCUOUS_MODE                   0x00000040
-#define SBE_2T3E3_21143_VAL_PASS_BAD_FRAMES                    0x00000008
-#define SBE_2T3E3_21143_VAL_RECEIVE_START                      0x00000002
-
-/* CSR7 - INTERRUPT_ENABLE */
-#define SBE_2T3E3_21143_VAL_LINK_CHANGED_ENABLE                        0x08000000
-#define SBE_2T3E3_21143_VAL_GENERAL_PURPOSE_PORT_ENABLE                0x04000000
-#define SBE_2T3E3_21143_VAL_NORMAL_INTERRUPT_SUMMARY_ENABLE    0x00010000
-#define SBE_2T3E3_21143_VAL_ABNORMAL_INTERRUPT_SUMMARY_ENABLE  0x00008000
-#define SBE_2T3E3_21143_VAL_EARLY_RECEIVE_INTERRUPT_ENABLE     0x00004000
-#define SBE_2T3E3_21143_VAL_FATAL_BUS_ERROR_ENABLE             0x00002000
-#define SBE_2T3E3_21143_VAL_LINK_FAIL_ENABLE                   0x00001000
-#define SBE_2T3E3_21143_VAL_GENERAL_PURPOSE_TIMER_ENABLE       0x00000800
-#define SBE_2T3E3_21143_VAL_EARLY_TRANSMIT_INTERRUPT_ENABLE    0x00000400
-#define SBE_2T3E3_21143_VAL_RECEIVE_WATCHDOG_TIMEOUT_ENABLE    0x00000200
-#define SBE_2T3E3_21143_VAL_RECEIVE_STOPPED_ENABLE             0x00000100
-#define SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE_ENABLE  0x00000080
-#define SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT_ENABLE           0x00000040
-#define SBE_2T3E3_21143_VAL_TRANSMIT_UNDERFLOW_INTERRUPT_ENABLE        0x00000020
-#define SBE_2T3E3_21143_VAL_TRANSMIT_JABBER_TIMEOUT_ENABLE     0x00000008
-#define SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE_ENABLE 0x00000004
-#define SBE_2T3E3_21143_VAL_TRANSMIT_STOPPED_ENABLE            0x00000002
-#define SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT_ENABLE          0x00000001
-
-/* CSR8 - MISSED_FRAMES_AND_OVERFLOW_COUNTER */
-#define SBE_2T3E3_21143_VAL_OVERFLOW_COUNTER_OVERFLOW          0x10000000
-#define SBE_2T3E3_21143_VAL_OVERFLOW_COUNTER                   0x0ffe0000
-#define SBE_2T3E3_21143_VAL_MISSED_FRAME_OVERFLOW              0x00010000
-#define SBE_2T3E3_21143_VAL_MISSED_FRAMES_COUNTER              0x0000ffff
-
-/* CSR9 - BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT */
-#define SBE_2T3E3_21143_VAL_MII_MANAGEMENT_DATA_IN             0x00080000
-#define SBE_2T3E3_21143_VAL_MII_MANAGEMENT_READ_MODE           0x00040000
-#define SBE_2T3E3_21143_VAL_MII_MANAGEMENT_DATA_OUT            0x00020000
-#define SBE_2T3E3_21143_VAL_MII_MANAGEMENT_CLOCK               0x00010000
-#define SBE_2T3E3_21143_VAL_READ_OPERATION                     0x00004000
-#define SBE_2T3E3_21143_VAL_WRITE_OPERATION                    0x00002000
-#define SBE_2T3E3_21143_VAL_BOOT_ROM_SELECT                    0x00001000
-#define SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT                  0x00000800
-#define SBE_2T3E3_21143_VAL_BOOT_ROM_DATA                      0x000000ff
-#define SBE_2T3E3_21143_VAL_SERIAL_ROM_DATA_OUT                        0x00000008
-#define SBE_2T3E3_21143_VAL_SERIAL_ROM_DATA_IN                 0x00000004
-#define SBE_2T3E3_21143_VAL_SERIAL_ROM_CLOCK                   0x00000002
-#define SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT             0x00000001
-
-/* CSR11 - GENERAL_PURPOSE_TIMER_AND_INTERRUPT_MITIGATION_CONTROL */
-#define SBE_2T3E3_21143_VAL_CYCLE_SIZE                         0x80000000
-#define SBE_2T3E3_21143_VAL_TRANSMIT_TIMER                     0x78000000
-#define SBE_2T3E3_21143_VAL_NUMBER_OF_TRANSMIT_PACKETS         0x07000000
-#define SBE_2T3E3_21143_VAL_RECEIVE_TIMER                      0x00f00000
-#define SBE_2T3E3_21143_VAL_NUMBER_OF_RECEIVE_PACKETS          0x000e0000
-#define SBE_2T3E3_21143_VAL_CONTINUOUS_MODE                    0x00010000
-#define SBE_2T3E3_21143_VAL_TIMER_VALUE                                0x0000ffff
-
-/* CSR12 - SIA_STATUS */
-#define SBE_2T3E3_21143_VAL_10BASE_T_RECEIVE_PORT_ACTIVITY     0x00000200
-#define SBE_2T3E3_21143_VAL_AUI_RECEIVE_PORT_ACTIVITY          0x00000100
-#define SBE_2T3E3_21143_VAL_10Mbs_LINK_STATUS                  0x00000004
-#define SBE_2T3E3_21143_VAL_100Mbs_LINK_STATUS                 0x00000002
-#define SBE_2T3E3_21143_VAL_MII_RECEIVE_PORT_ACTIVITY          0x00000001
-
-/* CSR13 - SIA_CONNECTIVITY */
-#define SBE_2T3E3_21143_VAL_10BASE_T_OR_AUI                    0x00000008
-#define SBE_2T3E3_21143_VAL_SIA_RESET                          0x00000001
-
-/* CSR14 - SIA_TRANSMIT_AND_RECEIVE */
-#define SBE_2T3E3_21143_VAL_100BASE_TX_FULL_DUPLEX             0x00020000
-#define SBE_2T3E3_21143_VAL_COLLISION_DETECT_ENABLE            0x00000400
-#define SBE_2T3E3_21143_VAL_COLLISION_SQUELCH_ENABLE           0x00000200
-#define SBE_2T3E3_21143_VAL_RECEIVE_SQUELCH_ENABLE             0x00000100
-#define SBE_2T3E3_21143_VAL_LINK_PULSE_SEND_ENABLE             0x00000004
-#define SBE_2T3E3_21143_VAL_ENCODER_ENABLE                     0x00000001
-
-/* CSR15 - SIA_AND_GENERAL_PURPOSE_PORT */
-#define SBE_2T3E3_21143_VAL_RECEIVE_WATCHDOG_DISABLE           0x00000010
-#define SBE_2T3E3_21143_VAL_AUI_BNC_MODE                       0x00000008
-#define SBE_2T3E3_21143_VAL_HOST_UNJAB                         0x00000002
-#define SBE_2T3E3_21143_VAL_JABBER_DISABLE                     0x00000001
-
-/**************************************************************
- *  CPLD
- **************************************************************/
-
-/* reg_map indexes */
-#define SBE_2T3E3_CPLD_REG_PCRA                                0
-#define SBE_2T3E3_CPLD_REG_PCRB                                1
-#define SBE_2T3E3_CPLD_REG_PLCR                                2
-#define SBE_2T3E3_CPLD_REG_PLTR                                3
-#define SBE_2T3E3_CPLD_REG_PPFR                                4
-#define SBE_2T3E3_CPLD_REG_BOARD_ID                    5
-#define SBE_2T3E3_CPLD_REG_FPGA_VERSION                        6
-#define SBE_2T3E3_CPLD_REG_FRAMER_BASE_ADDRESS         7
-#define SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT          8
-#define SBE_2T3E3_CPLD_REG_STATIC_RESET                        9
-#define SBE_2T3E3_CPLD_REG_PULSE_RESET                 10
-#define SBE_2T3E3_CPLD_REG_FPGA_RECONFIGURATION                11
-#define SBE_2T3E3_CPLD_REG_LEDR                                12
-#define SBE_2T3E3_CPLD_REG_PICSR                       13
-#define SBE_2T3E3_CPLD_REG_PIER                                14
-#define SBE_2T3E3_CPLD_REG_PCRC                                15
-#define SBE_2T3E3_CPLD_REG_PBWF                                16
-#define SBE_2T3E3_CPLD_REG_PBWL                                17
-
-#define SBE_2T3E3_CPLD_REG_MAX                         18
-
-/**********/
-
-/* val_map indexes */
-#define SBE_2T3E3_CPLD_VAL_LIU_SELECT                  0
-#define SBE_2T3E3_CPLD_VAL_DAC_SELECT                  1
-#define SBE_2T3E3_CPLD_VAL_LOOP_TIMING_SOURCE          2
-#define SBE_2T3E3_CPLD_VAL_LIU_FRAMER_RESET            3
-
-/* PCRA */
-#define SBE_2T3E3_CPLD_VAL_CRC32                               0x40
-#define SBE_2T3E3_CPLD_VAL_TRANSPARENT_MODE                    0x20
-#define SBE_2T3E3_CPLD_VAL_REAR_PANEL                          0x10
-#define SBE_2T3E3_CPLD_VAL_RAW_MODE                            0x08
-#define SBE_2T3E3_CPLD_VAL_ALT                                 0x04
-#define SBE_2T3E3_CPLD_VAL_LOOP_TIMING                         0x02
-#define SBE_2T3E3_CPLD_VAL_LOCAL_CLOCK_E3                      0x01
-
-/* PCRB */
-#define SBE_2T3E3_CPLD_VAL_PAD_COUNT                           0x30
-#define SBE_2T3E3_CPLD_VAL_PAD_COUNT_1                         0x00
-#define SBE_2T3E3_CPLD_VAL_PAD_COUNT_2                         0x10
-#define SBE_2T3E3_CPLD_VAL_PAD_COUNT_3                         0x20
-#define SBE_2T3E3_CPLD_VAL_PAD_COUNT_4                         0x30
-#define SBE_2T3E3_CPLD_VAL_SCRAMBLER_TYPE                      0x02
-#define SBE_2T3E3_CPLD_VAL_SCRAMBLER_ENABLE                    0x01
-
-/* PCRC */
-#define SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_NONE                        0x00
-#define SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_0                   0x01
-#define SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_1                   0x11
-#define SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_2                   0x21
-
-/* PLTR */
-#define SBE_2T3E3_CPLD_VAL_LCV_COUNTER                         0xff
-
-/* SCSR */
-#define SBE_2T3E3_CPLD_VAL_EEPROM_SELECT                       0x10
-
-/* PICSR */
-#define SBE_2T3E3_CPLD_VAL_LOSS_OF_SIGNAL_THRESHOLD_LEVEL_1    0x80
-#define SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_CHANGE       0x40
-#define SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_ETHERNET_ASSERTED    0x20
-#define SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_FRAMER_ASSERTED      0x10
-#define SBE_2T3E3_CPLD_VAL_LCV_LIMIT_EXCEEDED                  0x08
-#define SBE_2T3E3_CPLD_VAL_DMO_SIGNAL_DETECTED                 0x04
-#define SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_LOCK_DETECTED       0x02
-#define SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_DETECTED     0x01
-
-/* PIER */
-#define SBE_2T3E3_CPLD_VAL_RECEIVE_LOS_CHANGE_ENABLE           0x40
-#define SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_ETHERNET_ENABLE      0x20
-#define SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_FRAMER_ENABLE                0x10
-#define SBE_2T3E3_CPLD_VAL_LCV_INTERRUPT_ENABLE                        0x08
-#define SBE_2T3E3_CPLD_VAL_DMO_ENABLE                          0x04
-#define SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_LOCK_ENABLE         0x02
-#define SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_ENABLE       0x01
-
-/**************************************************************
- *  Framer
- **************************************************************/
-
-/* reg_map indexes */
-/* common */
-#define SBE_2T3E3_FRAMER_REG_OPERATING_MODE                            0
-#define SBE_2T3E3_FRAMER_REG_IO_CONTROL                                        1
-#define SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE                    2
-#define SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_STATUS                    3
-#define SBE_2T3E3_FRAMER_REG_PMON_LCV_EVENT_COUNT_MSB                  28
-#define SBE_2T3E3_FRAMER_REG_PMON_LCV_EVENT_COUNT_LSB                  29
-#define SBE_2T3E3_FRAMER_REG_PMON_FRAMING_BIT_ERROR_EVENT_COUNT_MSB    30
-#define SBE_2T3E3_FRAMER_REG_PMON_FRAMING_BIT_ERROR_EVENT_COUNT_LSB    31
-#define SBE_2T3E3_FRAMER_REG_PMON_PARITY_ERROR_EVENT_COUNT_MSB         32
-#define SBE_2T3E3_FRAMER_REG_PMON_PARITY_ERROR_EVENT_COUNT_LSB         33
-#define SBE_2T3E3_FRAMER_REG_PMON_FEBE_EVENT_COUNT_MSB                 34
-#define SBE_2T3E3_FRAMER_REG_PMON_FEBE_EVENT_COUNT_LSB                 35
-#define SBE_2T3E3_FRAMER_REG_PMON_CP_BIT_ERROR_EVENT_COUNT_MSB         36
-#define SBE_2T3E3_FRAMER_REG_PMON_CP_BIT_ERROR_EVENT_COUNT_LSB         37
-#define SBE_2T3E3_FRAMER_REG_PMON_HOLDING_REGISTER                     38
-#define SBE_2T3E3_FRAMER_REG_ONE_SECOND_ERROR_STATUS                   39
-#define SBE_2T3E3_FRAMER_REG_LCV_ONE_SECOND_ACCUMULATOR_MSB            40
-#define SBE_2T3E3_FRAMER_REG_LCV_ONE_SECOND_ACCUMULATOR_LSB            41
-#define SBE_2T3E3_FRAMER_REG_FRAME_PARITY_ERROR_ONE_SECOND_ACCUMULATOR_MSB  42
-#define SBE_2T3E3_FRAMER_REG_FRAME_PARITY_ERROR_ONE_SECOND_ACCUMULATOR_LSB  43
-#define SBE_2T3E3_FRAMER_REG_FRAME_CP_BIT_ERROR_ONE_SECOND_ACCUMULATOR_MSB  44
-#define SBE_2T3E3_FRAMER_REG_FRAME_CP_BIT_ERROR_ONE_SECOND_ACCUMULATOR_LSB  45
-#define SBE_2T3E3_FRAMER_REG_LINE_INTERFACE_DRIVE                      46
-#define SBE_2T3E3_FRAMER_REG_LINE_INTERFACE_SCAN                       47
-
-/* T3 */
-#define SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS                        4
-#define SBE_2T3E3_FRAMER_REG_T3_RX_STATUS                              5
-#define SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE                    6
-#define SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_STATUS                    7
-#define SBE_2T3E3_FRAMER_REG_T3_RX_SYNC_DETECT_ENABLE                  8
-#define SBE_2T3E3_FRAMER_REG_T3_RX_FEAC                                        10
-#define SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS                11
-#define SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL                                12
-#define SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_STATUS                         13
-#define SBE_2T3E3_FRAMER_REG_T3_TX_CONFIGURATION                       16
-#define SBE_2T3E3_FRAMER_REG_T3_TX_FEAC_CONFIGURATION_STATUS           17
-#define SBE_2T3E3_FRAMER_REG_T3_TX_FEAC                                        18
-#define SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_CONFIGURATION                  19
-#define SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_STATUS                         20
-#define SBE_2T3E3_FRAMER_REG_T3_TX_MBIT_MASK                           21
-#define SBE_2T3E3_FRAMER_REG_T3_TX_FBIT_MASK                           22
-#define SBE_2T3E3_FRAMER_REG_T3_TX_FBIT_MASK_2                         23
-#define SBE_2T3E3_FRAMER_REG_T3_TX_FBIT_MASK_3                         24
-
-/* E3 */
-#define SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_1              4
-#define SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2              5
-#define SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_1                  6
-#define SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_2                  7
-#define SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_1                  8
-#define SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2                  9
-#define SBE_2T3E3_FRAMER_REG_E3_RX_LAPD_CONTROL                                12
-#define SBE_2T3E3_FRAMER_REG_E3_RX_LAPD_STATUS                         13
-#define SBE_2T3E3_FRAMER_REG_E3_RX_NR_BYTE                             14
-#define SBE_2T3E3_FRAMER_REG_E3_RX_SERVICE_BITS                                14
-#define SBE_2T3E3_FRAMER_REG_E3_RX_GC_BYTE                             15
-#define SBE_2T3E3_FRAMER_REG_E3_TX_CONFIGURATION                       16
-#define SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_CONFIGURATION                  19
-#define SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_STATUS                         19
-#define SBE_2T3E3_FRAMER_REG_E3_TX_GC_BYTE                             21
-#define SBE_2T3E3_FRAMER_REG_E3_TX_SERVICE_BITS                                21
-#define SBE_2T3E3_FRAMER_REG_E3_TX_MA_BYTE                             22
-#define SBE_2T3E3_FRAMER_REG_E3_TX_NR_BYTE                             23
-#define SBE_2T3E3_FRAMER_REG_E3_TX_FA1_ERROR_MASK                      25
-#define SBE_2T3E3_FRAMER_REG_E3_TX_FAS_ERROR_MASK_UPPER                        25
-#define SBE_2T3E3_FRAMER_REG_E3_TX_FA2_ERROR_MASK                      26
-#define SBE_2T3E3_FRAMER_REG_E3_TX_FAS_ERROR_MASK_LOWER                        26
-#define SBE_2T3E3_FRAMER_REG_E3_TX_BIP8_MASK                           27
-#define SBE_2T3E3_FRAMER_REG_E3_TX_BIP4_MASK                           27
-
-#define SBE_2T3E3_FRAMER_REG_MAX                                       48
-
-/**********/
-
-/* OPERATING_MODE */
-#define SBE_2T3E3_FRAMER_VAL_LOCAL_LOOPBACK_MODE               0x80
-#define SBE_2T3E3_FRAMER_VAL_T3_E3_SELECT                      0x40
-#define SBE_2T3E3_FRAMER_VAL_INTERNAL_LOS_ENABLE               0x20
-#define SBE_2T3E3_FRAMER_VAL_RESET                             0x10
-#define SBE_2T3E3_FRAMER_VAL_INTERRUPT_ENABLE_RESET            0x08
-#define SBE_2T3E3_FRAMER_VAL_FRAME_FORMAT_SELECT               0x04
-#define SBE_2T3E3_FRAMER_VAL_TIMING_ASYNCH_TXINCLK             0x03
-#define SBE_2T3E3_FRAMER_VAL_E3_G751                           0x00
-#define SBE_2T3E3_FRAMER_VAL_E3_G832                           0x04
-#define SBE_2T3E3_FRAMER_VAL_T3_CBIT                           0x40
-#define SBE_2T3E3_FRAMER_VAL_T3_M13                            0x44
-#define SBE_2T3E3_FRAMER_VAL_LOOPBACK_ON                       0x80
-#define SBE_2T3E3_FRAMER_VAL_LOOPBACK_OFF                      0x00
-
-/* IO_CONTROL */
-#define SBE_2T3E3_FRAMER_VAL_DISABLE_TX_LOSS_OF_CLOCK          0x80
-#define SBE_2T3E3_FRAMER_VAL_LOSS_OF_CLOCK_STATUS              0x40
-#define SBE_2T3E3_FRAMER_VAL_DISABLE_RX_LOSS_OF_CLOCK          0x20
-#define SBE_2T3E3_FRAMER_VAL_AMI_LINE_CODE                     0x10
-#define SBE_2T3E3_FRAMER_VAL_UNIPOLAR                          0x08
-#define SBE_2T3E3_FRAMER_VAL_TX_LINE_CLOCK_INVERT              0x04
-#define SBE_2T3E3_FRAMER_VAL_RX_LINE_CLOCK_INVERT              0x02
-#define SBE_2T3E3_FRAMER_VAL_REFRAME                           0x01
-
-/* BLOCK_INTERRUPT_ENABLE */
-#define SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_ENABLE               0x80
-#define SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_ENABLE               0x02
-#define SBE_2T3E3_FRAMER_VAL_ONE_SECOND_INTERRUPT_ENABLE       0x01
-
-/* BLOCK_INTERRUPT_STATUS */
-#define SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_STATUS               0x80
-#define SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_STATUS               0x02
-#define SBE_2T3E3_FRAMER_VAL_ONE_SECOND_INTERRUPT_STATUS       0x01
-
-/**********/
-
-/* T3_RX_CONFIGURATION_STATUS */
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_AIS                         0x80
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_LOS                         0x40
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE                                0x20
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_OOF                         0x10
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_FRAMING_ON_PARITY           0x04
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_F_SYNC_ALGO                 0x02
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_M_SYNC_ALGO                 0x01
-
-/* T3_RX_STATUS */
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_FERF                                0x10
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_AIC                         0x04
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_FEBE                                0x07
-
-/* T3_RX_INTERRUPT_ENABLE */
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_CP_BIT_ERROR_INTERRUPT_ENABLE 0x80
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE                0x40
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_AIS_INTERRUPT_ENABLE                0x20
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE_INTERRUPT_ENABLE       0x10
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_FERF_INTERRUPT_ENABLE       0x08
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_AIC_INTERRUPT_ENABLE                0x04
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE                0x02
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_P_BIT_INTERRUPT_ENABLE      0x01
-
-/* T3_RX_INTERRUPT_STATUS */
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_CP_BIT_ERROR_INTERRUPT_STATUS 0x80
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_STATUS                0x40
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_AIS_INTERRUPT_STATUS                0x20
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE_INTERRUPT_STATUS       0x10
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_FERF_INTERRUPT_STATUS       0x08
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_AIC_INTERRUPT_STATUS                0x04
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_STATUS                0x02
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_P_BIT_INTERRUPT_STATUS      0x01
-
-/* T3_RX_FEAC_INTERRUPT_ENABLE_STATUS */
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_VALID                  0x10
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_REMOVE_INTERRUPT_ENABLE        0x08
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_REMOVE_INTERRUPT_STATUS        0x04
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_VALID_INTERRUPT_ENABLE 0x02
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_VALID_INTERRUPT_STATUS 0x01
-
-/* T3_RX_LAPD_CONTROL */
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_LAPD_ENABLE                 0x04
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_LAPD_INTERRUPT_ENABLE       0x02
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_LAPD_INTERRUPT_STATUS       0x01
-
-/* T3_RX_LAPD_STATUS */
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_ABORT                       0x40
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_LAPD_TYPE                   0x30
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_CR_TYPE                     0x08
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_FCS_ERROR                   0x04
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_END_OF_MESSAGE              0x02
-#define SBE_2T3E3_FRAMER_VAL_T3_RX_FLAG_PRESENT                        0x01
-
-/* T3_TX_CONFIGURATION */
-#define SBE_2T3E3_FRAMER_VAL_T3_TX_YELLOW_ALARM                        0x80
-#define SBE_2T3E3_FRAMER_VAL_T3_TX_X_BIT                       0x40
-#define SBE_2T3E3_FRAMER_VAL_T3_TX_IDLE                                0x20
-#define SBE_2T3E3_FRAMER_VAL_T3_TX_AIS                         0x10
-#define SBE_2T3E3_FRAMER_VAL_T3_TX_LOS                         0x08
-#define SBE_2T3E3_FRAMER_VAL_T3_TX_FERF_ON_LOS                 0x04
-#define SBE_2T3E3_FRAMER_VAL_T3_TX_FERF_ON_OOF                 0x02
-#define SBE_2T3E3_FRAMER_VAL_T3_TX_FERF_ON_AIS                 0x01
-
-/* T3_TX_FEAC_CONFIGURATION_STATUS */
-#define SBE_2T3E3_FRAMER_VAL_T3_TX_FEAC_INTERRUPT_ENABLE       0x10
-#define SBE_2T3E3_FRAMER_VAL_T3_TX_FEAC_INTERRUPT_STATUS       0x08
-#define SBE_2T3E3_FRAMER_VAL_T3_TX_FEAC_ENABLE                 0x04
-#define SBE_2T3E3_FRAMER_VAL_T3_TX_FEAC_GO                     0x02
-#define SBE_2T3E3_FRAMER_VAL_T3_TX_FEAC_BUSY                   0x01
-
-/* T3_TX_LAPD_STATUS */
-#define SBE_2T3E3_FRAMER_VAL_T3_TX_DL_START                    0x08
-#define SBE_2T3E3_FRAMER_VAL_T3_TX_DL_BUSY                     0x04
-#define SBE_2T3E3_FRAMER_VAL_T3_TX_LAPD_INTERRUPT_ENABLE       0x02
-#define SBE_2T3E3_FRAMER_VAL_T3_TX_LAPD_INTERRUPT_STATUS       0x01
-
-/**********/
-
-/* E3_RX_CONFIGURATION_STATUS_1 */
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_PAYLOAD_TYPE                        0xe0
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_FERF_ALGO                   0x10
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_T_MARK_ALGO                 0x08
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_PAYLOAD_EXPECTED            0x07
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_BIP4                                0x01
-
-/* E3_RX_CONFIGURATION_STATUS_2 */
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOF_ALGO                    0x80
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOF                         0x40
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_OOF                         0x20
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOS                         0x10
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_AIS                         0x08
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_PAYLOAD_UNSTABLE            0x04
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_T_MARK                      0x02
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_FERF                                0x01
-
-/* E3_RX_INTERRUPT_ENABLE_1 */
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_COFA_INTERRUPT_ENABLE       0x10
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE                0x08
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOF_INTERRUPT_ENABLE                0x04
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE                0x02
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_AIS_INTERRUPT_ENABLE                0x01
-
-/* E3_RX_INTERRUPT_ENABLE_2 */
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_TTB_CHANGE_INTERRUPT_ENABLE 0x40
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_FEBE_INTERRUPT_ENABLE       0x10
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_FERF_INTERRUPT_ENABLE       0x08
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_BIP8_ERROR_INTERRUPT_ENABLE 0x04
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_BIP4_ERROR_INTERRUPT_ENABLE 0x04
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_FRAMING_BYTE_ERROR_INTERRUPT_ENABLE 0x02
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_PAYLOAD_MISMATCH_INTERRUPT_ENABLE 0x01
-
-/* E3_RX_INTERRUPT_STATUS_1 */
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_COFA_INTERRUPT_STATUS       0x10
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_STATUS                0x08
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOF_INTERRUPT_STATUS                0x04
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_STATUS                0x02
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_AIS_INTERRUPT_STATUS                0x01
-
-/* E3_RX_INTERRUPT_STATUS_2 */
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_TTB_CHANGE_INTERRUPT_STATUS 0x40
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_FEBE_INTERRUPT_STATUS       0x10
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_FERF_INTERRUPT_STATUS       0x08
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_BIP8_ERROR_INTERRUPT_STATUS 0x04
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_BIP4_ERROR_INTERRUPT_STATUS 0x04
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_FRAMING_BYTE_ERROR_INTERRUPT_STATUS 0x02
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_PAYLOAD_MISMATCH_INTERRUPT_STATUS 0x01
-
-/* E3_RX_LAPD_CONTROL */
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_DL_FROM_NR                  0x08
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_LAPD_ENABLE                 0x04
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_LAPD_INTERRUPT_ENABLE       0x02
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_LAPD_INTERRUPT_STATUS       0x01
-
-/* E3_RX_LAPD_STATUS */
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_ABORT                       0x40
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_LAPD_TYPE                   0x30
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_CR_TYPE                     0x08
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_FCS_ERROR                   0x04
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_END_OF_MESSAGE              0x02
-#define SBE_2T3E3_FRAMER_VAL_E3_RX_FLAG_PRESENT                        0x01
-
-/* E3_TX_CONFIGURATION */
-#define SBE_2T3E3_FRAMER_VAL_E3_TX_BIP4_ENABLE                 0x80
-#define SBE_2T3E3_FRAMER_VAL_E3_TX_A_SOURCE_SELECT             0x60
-#define SBE_2T3E3_FRAMER_VAL_E3_TX_DL_IN_NR                    0x10
-#define SBE_2T3E3_FRAMER_VAL_E3_TX_N_SOURCE_SELECT             0x18
-#define SBE_2T3E3_FRAMER_VAL_E3_TX_AIS_ENABLE                  0x04
-#define SBE_2T3E3_FRAMER_VAL_E3_TX_LOS_ENABLE                  0x02
-#define SBE_2T3E3_FRAMER_VAL_E3_TX_MA_RX                       0x01
-#define SBE_2T3E3_FRAMER_VAL_E3_TX_FAS_SOURCE_SELECT           0x01
-
-/* E3_TX_LAPD_CONFIGURATION */
-#define SBE_2T3E3_FRAMER_VAL_E3_TX_AUTO_RETRANSMIT             0x08
-#define SBE_2T3E3_FRAMER_VAL_E3_TX_LAPD_MESSAGE_LENGTH         0x02
-#define SBE_2T3E3_FRAMER_VAL_E3_TX_LAPD_ENABLE                 0x01
-
-/* E3_TX_LAPD_STATUS_INTERRUPT */
-#define SBE_2T3E3_FRAMER_VAL_E3_TX_DL_START                    0x08
-#define SBE_2T3E3_FRAMER_VAL_E3_TX_DL_BUSY                     0x04
-#define SBE_2T3E3_FRAMER_VAL_E3_TX_LAPD_INTERRUPT_ENABLE       0x02
-#define SBE_2T3E3_FRAMER_VAL_E3_TX_LAPD_INTERRUPT_STATUS       0x01
-
-
-
-
-
-
-/**************************************************************
- *  LIU
- **************************************************************/
-
-/* reg_map indexes */
-#define SBE_2T3E3_LIU_REG_REG0                 0
-#define SBE_2T3E3_LIU_REG_REG1                 1
-#define SBE_2T3E3_LIU_REG_REG2                 2
-#define SBE_2T3E3_LIU_REG_REG3                 3
-#define SBE_2T3E3_LIU_REG_REG4                 4
-
-#define        SBE_2T3E3_LIU_REG_MAX                   5
-
-/**********/
-
-/* REG0 */
-#define SBE_2T3E3_LIU_VAL_RECEIVE_LOSS_OF_LOCK_STATUS          0x10
-#define SBE_2T3E3_LIU_VAL_RECEIVE_LOSS_OF_SIGNAL_STATUS                0x08
-#define SBE_2T3E3_LIU_VAL_ANALOG_LOSS_OF_SIGNAL_STATUS         0x04
-#define SBE_2T3E3_LIU_VAL_DIGITAL_LOSS_OF_SIGNAL_STATUS                0x02
-#define SBE_2T3E3_LIU_VAL_DMO_STATUS                           0x01
-
-/* REG1 */
-#define SBE_2T3E3_LIU_VAL_TRANSMITTER_OFF                      0x10
-#define SBE_2T3E3_LIU_VAL_TRANSMIT_ALL_ONES                    0x08
-#define SBE_2T3E3_LIU_VAL_TRANSMIT_CLOCK_INVERT                        0x04
-#define SBE_2T3E3_LIU_VAL_TRANSMIT_LEVEL_SELECT                        0x02
-#define SBE_2T3E3_LIU_VAL_TRANSMIT_BINARY_DATA                 0x01
-
-/* REG2 */
-#define SBE_2T3E3_LIU_VAL_DECODER_DISABLE                      0x10
-#define SBE_2T3E3_LIU_VAL_ENCODER_DISABLE                      0x08
-#define SBE_2T3E3_LIU_VAL_ANALOG_LOSS_OF_SIGNAL_DISABLE                0x04
-#define SBE_2T3E3_LIU_VAL_DIGITAL_LOSS_OF_SIGNAL_DISABLE       0x02
-#define SBE_2T3E3_LIU_VAL_RECEIVE_EQUALIZATION_DISABLE         0x01
-
-/* REG3 */
-#define SBE_2T3E3_LIU_VAL_RECEIVE_BINARY_DATA                  0x10
-#define SBE_2T3E3_LIU_VAL_RECOVERED_DATA_MUTING                        0x08
-#define SBE_2T3E3_LIU_VAL_RECEIVE_CLOCK_OUTPUT_2               0x04
-#define SBE_2T3E3_LIU_VAL_INVERT_RECEIVE_CLOCK_2               0x02
-#define SBE_2T3E3_LIU_VAL_INVERT_RECEIVE_CLOCK_1               0x01
-
-/* REG4 */
-#define SBE_2T3E3_LIU_VAL_T3_MODE_SELECT                       0x00
-#define SBE_2T3E3_LIU_VAL_E3_MODE_SELECT                       0x04
-#define SBE_2T3E3_LIU_VAL_LOCAL_LOOPBACK                       0x02
-#define SBE_2T3E3_LIU_VAL_REMOTE_LOOPBACK                      0x01
-#define SBE_2T3E3_LIU_VAL_LOOPBACK_OFF                         0x00
-#define SBE_2T3E3_LIU_VAL_LOOPBACK_REMOTE                      0x01
-#define SBE_2T3E3_LIU_VAL_LOOPBACK_ANALOG                      0x02
-#define SBE_2T3E3_LIU_VAL_LOOPBACK_DIGITAL                     0x03
-
-/**********************************************************************
- *
- * descriptor list and data buffer
- *
- **********************************************************************/
-struct t3e3_rx_desc {
-       u32 rdes0;
-       u32 rdes1;
-       u32 rdes2;
-       u32 rdes3;
-};
-
-#define SBE_2T3E3_RX_DESC_RING_SIZE                    64
-
-/* RDES0 */
-#define SBE_2T3E3_RX_DESC_21143_OWN                    0X80000000
-#define SBE_2T3E3_RX_DESC_FRAME_LENGTH                 0x3fff0000
-#define SBE_2T3E3_RX_DESC_FRAME_LENGTH_SHIFT           16
-#define SBE_2T3E3_RX_DESC_ERROR_SUMMARY                        0x00008000
-#define SBE_2T3E3_RX_DESC_DESC_ERROR                   0x00004000
-#define SBE_2T3E3_RX_DESC_DATA_TYPE                    0x00003000
-#define SBE_2T3E3_RX_DESC_RUNT_FRAME                   0x00000800
-#define SBE_2T3E3_RX_DESC_FIRST_DESC                   0x00000200
-#define SBE_2T3E3_RX_DESC_LAST_DESC                    0x00000100
-#define SBE_2T3E3_RX_DESC_FRAME_TOO_LONG               0x00000080
-#define SBE_2T3E3_RX_DESC_COLLISION_SEEN               0x00000040
-#define SBE_2T3E3_RX_DESC_FRAME_TYPE                   0x00000020
-#define SBE_2T3E3_RX_DESC_RECEIVE_WATCHDOG             0x00000010
-#define SBE_2T3E3_RX_DESC_MII_ERROR                    0x00000008
-#define SBE_2T3E3_RX_DESC_DRIBBLING_BIT                        0x00000004
-#define SBE_2T3E3_RX_DESC_CRC_ERROR                    0x00000002
-
-/* RDES1 */
-#define SBE_2T3E3_RX_DESC_END_OF_RING                  0x02000000
-#define SBE_2T3E3_RX_DESC_SECOND_ADDRESS_CHAINED       0x01000000
-#define SBE_2T3E3_RX_DESC_BUFFER_2_SIZE                        0x003ff800
-#define SBE_2T3E3_RX_DESC_BUFFER_1_SIZE                        0x000007ff
-
-/*********************/
-
-struct t3e3_tx_desc {
-       u32 tdes0;
-       u32 tdes1;
-       u32 tdes2;
-       u32 tdes3;
-};
-
-#define SBE_2T3E3_TX_DESC_RING_SIZE                    256
-
-/* TDES0 */
-#define SBE_2T3E3_TX_DESC_21143_OWN                    0x80000000
-#define SBE_2T3E3_TX_DESC_ERROR_SUMMARY                        0x00008000
-#define SBE_2T3E3_TX_DESC_TRANSMIT_JABBER_TIMEOUT      0x00004000
-#define SBE_2T3E3_TX_DESC_LOSS_OF_CARRIER              0x00000800
-#define SBE_2T3E3_TX_DESC_NO_CARRIER                   0x00000400
-#define SBE_2T3E3_TX_DESC_LINK_FAIL_REPORT             0x00000004
-#define SBE_2T3E3_TX_DESC_UNDERFLOW_ERROR              0x00000002
-#define SBE_2T3E3_TX_DESC_DEFFERED                     0x00000001
-
-/* TDES1 */
-#define SBE_2T3E3_TX_DESC_INTERRUPT_ON_COMPLETION      0x80000000
-#define SBE_2T3E3_TX_DESC_LAST_SEGMENT                 0x40000000
-#define SBE_2T3E3_TX_DESC_FIRST_SEGMENT                        0x20000000
-#define SBE_2T3E3_TX_DESC_CRC_DISABLE                  0x04000000
-#define SBE_2T3E3_TX_DESC_END_OF_RING                  0x02000000
-#define SBE_2T3E3_TX_DESC_SECOND_ADDRESS_CHAINED       0x01000000
-#define SBE_2T3E3_TX_DESC_DISABLE_PADDING              0x00800000
-#define SBE_2T3E3_TX_DESC_BUFFER_2_SIZE                        0x003ff800
-#define SBE_2T3E3_TX_DESC_BUFFER_1_SIZE                        0x000007ff
-
-
-#define SBE_2T3E3_MTU                                  1600
-#define SBE_2T3E3_CRC16_LENGTH                         2
-#define SBE_2T3E3_CRC32_LENGTH                         4
-
-#define MCLBYTES (SBE_2T3E3_MTU + 128)
-
-struct channel {
-       struct pci_dev *pdev;
-       struct net_device *dev;
-       struct card *card;
-       unsigned long addr;     /* DECchip */
-
-       int leds;
-
-       /* pci specific */
-       struct {
-               u32 slot;           /* should be 0 or 1 */
-               u32 command;
-               u8 cache_size;
-       } h;
-
-       /* statistics */
-       struct t3e3_stats s;
-
-       /* running */
-       struct {
-               u32 flags;
-       } r;
-
-       /* parameters */
-       struct t3e3_param p;
-
-       u32 liu_regs[SBE_2T3E3_LIU_REG_MAX];       /* LIU registers */
-       u32 framer_regs[SBE_2T3E3_FRAMER_REG_MAX]; /* Framer registers */
-
-       /* Ethernet Controller */
-       struct {
-               u_int16_t card_serial_number[3];
-
-               u32 reg[SBE_2T3E3_21143_REG_MAX]; /* registers i.e. CSR */
-
-               u32 interrupt_enable_mask;
-
-               /* receive chain/ring */
-               struct t3e3_rx_desc *rx_ring;
-               struct sk_buff *rx_data[SBE_2T3E3_RX_DESC_RING_SIZE];
-               u32 rx_ring_current_read;
-
-               /* transmit chain/ring */
-               struct t3e3_tx_desc *tx_ring;
-               struct sk_buff *tx_data[SBE_2T3E3_TX_DESC_RING_SIZE];
-               u32 tx_ring_current_read;
-               u32 tx_ring_current_write;
-               int tx_full;
-               int tx_free_cnt;
-               spinlock_t tx_lock;
-       } ether;
-
-       int32_t interrupt_active;
-       int32_t rcv_count;
-};
-
-struct card {
-       spinlock_t bootrom_lock;
-       unsigned long bootrom_addr;
-       struct timer_list timer; /* for updating LEDs */
-       struct channel channels[0];
-};
-
-#define SBE_2T3E3_FLAG_NETWORK_UP              0x00000001
-#define SBE_2T3E3_FLAG_NO_ERROR_MESSAGES       0x00000002
-
-extern const u32 cpld_reg_map[][2];
-extern const u32 cpld_val_map[][2];
-extern const u32 t3e3_framer_reg_map[];
-extern const u32 t3e3_liu_reg_map[];
-
-void t3e3_init(struct channel *);
-void t3e3_if_up(struct channel *);
-void t3e3_if_down(struct channel *);
-int t3e3_if_start_xmit(struct sk_buff *skb, struct net_device *dev);
-void t3e3_if_config(struct channel *, u32, char *, struct t3e3_resp *, int *);
-void t3e3_set_frame_type(struct channel *, u32);
-u32 t3e3_eeprom_read_word(struct channel *, u32);
-void t3e3_read_card_serial_number(struct channel *);
-
-/* interrupt handlers */
-irqreturn_t t3e3_intr(int irq, void *dev_instance);
-void dc_intr(struct channel *);
-void dc_intr_rx(struct channel *);
-void dc_intr_tx(struct channel *);
-void dc_intr_tx_underflow(struct channel *);
-void exar7250_intr(struct channel *);
-void exar7250_E3_intr(struct channel *, u32);
-void exar7250_T3_intr(struct channel *, u32);
-
-/* Ethernet controller */
-u32 bootrom_read(struct channel *, u32);
-void bootrom_write(struct channel *, u32, u32);
-void dc_init(struct channel *);
-void dc_start(struct channel *);
-void dc_stop(struct channel *);
-void dc_start_intr(struct channel *);
-void dc_stop_intr(struct channel *);
-void dc_reset(struct channel *);
-void dc_restart(struct channel *);
-void dc_receiver_onoff(struct channel *, u32);
-void dc_transmitter_onoff(struct channel *, u32);
-void dc_set_loopback(struct channel *, u32);
-void dc_clear_descriptor_list(struct channel *);
-void dc_drop_descriptor_list(struct channel *);
-void dc_set_output_port(struct channel *);
-void t3e3_sc_init(struct channel *);
-
-/* CPLD */
-void cpld_init(struct channel *sc);
-u32 cpld_read(struct channel *sc, u32 reg);
-void cpld_set_crc(struct channel *, u32);
-void cpld_start_intr(struct channel *);
-void cpld_stop_intr(struct channel *);
-void cpld_set_clock(struct channel *sc, u32 mode);
-void cpld_set_scrambler(struct channel *, u32);
-void cpld_select_panel(struct channel *, u32);
-void cpld_set_frame_mode(struct channel *, u32);
-void cpld_set_frame_type(struct channel *, u32);
-void cpld_set_pad_count(struct channel *, u32);
-void cpld_set_fractional_mode(struct channel *, u32, u32, u32);
-void cpld_LOS_update(struct channel *);
-
-/* Framer */
-extern u32 exar7250_read(struct channel *, u32);
-extern void exar7250_write(struct channel *, u32, u32);
-void exar7250_init(struct channel *);
-void exar7250_start_intr(struct channel *, u32);
-void exar7250_stop_intr(struct channel *, u32);
-void exar7250_set_frame_type(struct channel *, u32);
-void exar7250_set_loopback(struct channel *, u32);
-void exar7250_unipolar_onoff(struct channel *, u32);
-
-/* LIU */
-u32 exar7300_read(struct channel *, u32);
-void exar7300_write(struct channel *, u32, u32);
-void exar7300_init(struct channel *);
-void exar7300_line_build_out_onoff(struct channel *, u32);
-void exar7300_set_frame_type(struct channel *, u32);
-void exar7300_set_loopback(struct channel *, u32);
-void exar7300_transmit_all_ones_onoff(struct channel *, u32);
-void exar7300_receive_equalization_onoff(struct channel *, u32);
-void exar7300_unipolar_onoff(struct channel *, u32);
-
-void update_led(struct channel *, int);
-int setup_device(struct net_device *dev, struct channel *sc);
-
-static inline int has_two_ports(struct pci_dev *pdev)
-{
-       return pdev->subsystem_device == PCI_SUBDEVICE_ID_SBE_2T3E3_P0;
-}
-
-#define dev_to_priv(dev) (*(struct channel **) ((hdlc_device *)(dev) + 1))
-
-static inline u32 dc_read(unsigned long addr, u32 reg)
-{
-       return inl(addr + (reg << 3));
-}
-
-static inline void dc_write(unsigned long addr, u32 reg, u32 val)
-{
-       outl(val, addr + (reg << 3));
-}
-
-static inline void dc_set_bits(unsigned long addr, u32 reg, u32 bits)
-{
-       dc_write(addr, reg, dc_read(addr, reg) | bits);
-}
-
-static inline void dc_clear_bits(unsigned long addr, u32 reg, u32 bits)
-{
-       dc_write(addr, reg, dc_read(addr, reg) & ~bits);
-}
-
-#define CPLD_MAP_REG(reg, sc)  (cpld_reg_map[(reg)][(sc)->h.slot])
-
-static inline void cpld_write(struct channel *channel, unsigned reg, u32 val)
-{
-       unsigned long flags;
-       spin_lock_irqsave(&channel->card->bootrom_lock, flags);
-       bootrom_write(channel, CPLD_MAP_REG(reg, channel), val);
-       spin_unlock_irqrestore(&channel->card->bootrom_lock, flags);
-}
-
-#define exar7250_set_bit(sc, reg, bit)                 \
-       exar7250_write((sc), (reg),                     \
-                      exar7250_read(sc, reg) | (bit))
-
-#define exar7250_clear_bit(sc, reg, bit)               \
-       exar7250_write((sc), (reg),                     \
-                      exar7250_read(sc, reg) & ~(bit))
-
-#define exar7300_set_bit(sc, reg, bit)                 \
-       exar7300_write((sc), (reg),                     \
-                      exar7300_read(sc, reg) | (bit))
-
-#define exar7300_clear_bit(sc, reg, bit)               \
-       exar7300_write((sc), (reg),                     \
-                      exar7300_read(sc, reg) & ~(bit))
-
-
-#endif /* T3E3_H */
diff --git a/drivers/staging/sbe-2t3e3/Kconfig b/drivers/staging/sbe-2t3e3/Kconfig
deleted file mode 100644 (file)
index 8ec86cf..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-config SBE_2T3E3
-       tristate "SBE wanPMC-2T3E3 support"
-       depends on HDLC && PCI
-       help
-         Driver for wanPMC-2T3E3 cards by SBE Inc.
-
-         If you have such a card, say Y here and see
-         <http://www.kernel.org/pub/linux/utils/net/hdlc/>.
-
-         To compile this as a module, choose M here: the
-         module will be called sbe-2t3e3.
-
-         If unsure, say N.
diff --git a/drivers/staging/sbe-2t3e3/Makefile b/drivers/staging/sbe-2t3e3/Makefile
deleted file mode 100644 (file)
index cce2a7a..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-obj-$(CONFIG_SBE_2T3E3) += sbe-2t3e3.o
-
-sbe-2t3e3-y := module.o netdev.o maps.o        \
-       main.o cpld.o intr.o ctrl.o io.o dc.o exar7250.o exar7300.o
diff --git a/drivers/staging/sbe-2t3e3/TODO b/drivers/staging/sbe-2t3e3/TODO
deleted file mode 100644 (file)
index 624b20f..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-TODO:
-       - additional cleaning and tests
-       - wait for the new configuration interface in generic HDLC layer and
-         when available, convert the driver to it
-
-Please send patches to Krzysztof Halasa <khc@pm.waw.pl>.
\ No newline at end of file
diff --git a/drivers/staging/sbe-2t3e3/cpld.c b/drivers/staging/sbe-2t3e3/cpld.c
deleted file mode 100644 (file)
index c6370d3..0000000
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * SBE 2T3E3 synchronous serial card driver for Linux
- *
- * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- *
- * This code is based on a driver written by SBE Inc.
- */
-
-#include <linux/delay.h>
-#include "2t3e3.h"
-#include "ctrl.h"
-
-#define bootrom_set_bit(sc, reg, bit)                          \
-       bootrom_write((sc), (reg),                              \
-                     bootrom_read((sc), (reg)) | (bit))
-
-#define bootrom_clear_bit(sc, reg, bit)                                \
-       bootrom_write((sc), (reg),                              \
-                     bootrom_read((sc), (reg)) & ~(bit))
-
-static inline void cpld_set_bit(struct channel *channel, unsigned reg, u32 bit)
-{
-       unsigned long flags;
-       spin_lock_irqsave(&channel->card->bootrom_lock, flags);
-       bootrom_set_bit(channel, CPLD_MAP_REG(reg, channel), bit);
-       spin_unlock_irqrestore(&channel->card->bootrom_lock, flags);
-}
-
-static inline void cpld_clear_bit(struct channel *channel, unsigned reg, u32 bit)
-{
-       unsigned long flags;
-       spin_lock_irqsave(&channel->card->bootrom_lock, flags);
-       bootrom_clear_bit(channel, CPLD_MAP_REG(reg, channel), bit);
-       spin_unlock_irqrestore(&channel->card->bootrom_lock, flags);
-}
-
-void cpld_init(struct channel *sc)
-{
-       u32 val;
-
-       /* PCRA */
-       val = SBE_2T3E3_CPLD_VAL_CRC32 |
-               cpld_val_map[SBE_2T3E3_CPLD_VAL_LOOP_TIMING_SOURCE][sc->h.slot];
-       cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRA, val);
-
-       /* PCRB */
-       val = 0;
-       cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRB, val);
-
-       /* PCRC */
-       val = 0;
-       cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRC, val);
-
-       /* PBWF */
-       val = 0;
-       cpld_write(sc, SBE_2T3E3_CPLD_REG_PBWF, val);
-
-       /* PBWL */
-       val = 0;
-       cpld_write(sc, SBE_2T3E3_CPLD_REG_PBWL, val);
-
-       /* PLTR */
-       val = SBE_2T3E3_CPLD_VAL_LCV_COUNTER;
-       cpld_write(sc, SBE_2T3E3_CPLD_REG_PLTR, val);
-       udelay(1000);
-
-       /* PLCR */
-       val = 0;
-       cpld_write(sc, SBE_2T3E3_CPLD_REG_PLCR, val);
-       udelay(1000);
-
-       /* PPFR */
-       val = 0x55;
-       cpld_write(sc, SBE_2T3E3_CPLD_REG_PPFR, val);
-       /* TODO: this doesn't work!!! */
-
-       /* SERIAL_CHIP_SELECT */
-       val = 0;
-       cpld_write(sc, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT, val);
-
-       /* PICSR */
-       val = SBE_2T3E3_CPLD_VAL_DMO_SIGNAL_DETECTED |
-               SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_LOCK_DETECTED |
-               SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_DETECTED;
-       cpld_write(sc, SBE_2T3E3_CPLD_REG_PICSR, val);
-
-       cpld_start_intr(sc);
-
-       udelay(1000);
-}
-
-void cpld_start_intr(struct channel *sc)
-{
-       u32 val;
-
-       /* PIER */
-       val = SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_ETHERNET_ENABLE |
-               SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_FRAMER_ENABLE;
-       cpld_write(sc, SBE_2T3E3_CPLD_REG_PIER, val);
-}
-
-void cpld_stop_intr(struct channel *sc)
-{
-       u32 val;
-
-       /* PIER */
-       val = 0;
-       cpld_write(sc, SBE_2T3E3_CPLD_REG_PIER, val);
-}
-
-void cpld_set_frame_mode(struct channel *sc, u32 mode)
-{
-       if (sc->p.frame_mode == mode)
-               return;
-
-       switch (mode) {
-       case SBE_2T3E3_FRAME_MODE_HDLC:
-               cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
-                              SBE_2T3E3_CPLD_VAL_TRANSPARENT_MODE |
-                              SBE_2T3E3_CPLD_VAL_RAW_MODE);
-               exar7250_unipolar_onoff(sc, SBE_2T3E3_OFF);
-               exar7300_unipolar_onoff(sc, SBE_2T3E3_OFF);
-               break;
-       case SBE_2T3E3_FRAME_MODE_TRANSPARENT:
-               cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
-                              SBE_2T3E3_CPLD_VAL_RAW_MODE);
-               cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
-                            SBE_2T3E3_CPLD_VAL_TRANSPARENT_MODE);
-               exar7250_unipolar_onoff(sc, SBE_2T3E3_OFF);
-               exar7300_unipolar_onoff(sc, SBE_2T3E3_OFF);
-               break;
-       case SBE_2T3E3_FRAME_MODE_RAW:
-               cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
-                            SBE_2T3E3_CPLD_VAL_RAW_MODE);
-               exar7250_unipolar_onoff(sc, SBE_2T3E3_ON);
-               exar7300_unipolar_onoff(sc, SBE_2T3E3_ON);
-               break;
-       default:
-               return;
-       }
-
-       sc->p.frame_mode = mode;
-}
-
-/* set rate of the local clock */
-void cpld_set_frame_type(struct channel *sc, u32 type)
-{
-       switch (type) {
-       case SBE_2T3E3_FRAME_TYPE_E3_G751:
-       case SBE_2T3E3_FRAME_TYPE_E3_G832:
-               cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
-                            SBE_2T3E3_CPLD_VAL_LOCAL_CLOCK_E3);
-               break;
-       case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
-       case SBE_2T3E3_FRAME_TYPE_T3_M13:
-               cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
-                              SBE_2T3E3_CPLD_VAL_LOCAL_CLOCK_E3);
-               break;
-       default:
-               return;
-       }
-}
-
-void cpld_set_scrambler(struct channel *sc, u32 mode)
-{
-       if (sc->p.scrambler == mode)
-               return;
-
-       switch (mode) {
-       case SBE_2T3E3_SCRAMBLER_OFF:
-               cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRB,
-                              SBE_2T3E3_CPLD_VAL_SCRAMBLER_ENABLE);
-               break;
-       case SBE_2T3E3_SCRAMBLER_LARSCOM:
-               cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRB,
-                              SBE_2T3E3_CPLD_VAL_SCRAMBLER_TYPE);
-               cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRB,
-                            SBE_2T3E3_CPLD_VAL_SCRAMBLER_ENABLE);
-               break;
-       case SBE_2T3E3_SCRAMBLER_ADC_KENTROX_DIGITAL:
-               cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRB,
-                            SBE_2T3E3_CPLD_VAL_SCRAMBLER_TYPE);
-               cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRB,
-                            SBE_2T3E3_CPLD_VAL_SCRAMBLER_ENABLE);
-               break;
-       default:
-               return;
-       }
-
-       sc->p.scrambler = mode;
-}
-
-
-void cpld_set_crc(struct channel *sc, u32 crc)
-{
-       if (sc->p.crc == crc)
-               return;
-
-       switch (crc) {
-       case SBE_2T3E3_CRC_16:
-               cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
-                              SBE_2T3E3_CPLD_VAL_CRC32);
-               break;
-       case SBE_2T3E3_CRC_32:
-               cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
-                            SBE_2T3E3_CPLD_VAL_CRC32);
-               break;
-       default:
-               return;
-       }
-
-       sc->p.crc = crc;
-}
-
-
-void cpld_select_panel(struct channel *sc, u32 panel)
-{
-       if (sc->p.panel == panel)
-               return;
-       switch (panel) {
-       case SBE_2T3E3_PANEL_FRONT:
-               cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
-                              SBE_2T3E3_CPLD_VAL_REAR_PANEL);
-               break;
-       case SBE_2T3E3_PANEL_REAR:
-               cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
-                            SBE_2T3E3_CPLD_VAL_REAR_PANEL);
-               break;
-       default:
-               return;
-       }
-
-       udelay(100);
-
-       sc->p.panel = panel;
-}
-
-
-void cpld_set_clock(struct channel *sc, u32 mode)
-{
-       if (sc->p.clock_source == mode)
-               return;
-
-       switch (mode) {
-       case SBE_2T3E3_TIMING_LOCAL:
-               cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
-                            SBE_2T3E3_CPLD_VAL_ALT);
-               break;
-       case SBE_2T3E3_TIMING_LOOP:
-               cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
-                              SBE_2T3E3_CPLD_VAL_ALT);
-               break;
-       default:
-               return;
-       }
-
-       sc->p.clock_source = mode;
-}
-
-void cpld_set_pad_count(struct channel *sc, u32 count)
-{
-       u32 val;
-
-       if (sc->p.pad_count == count)
-               return;
-
-       switch (count) {
-       case SBE_2T3E3_PAD_COUNT_1:
-               val = SBE_2T3E3_CPLD_VAL_PAD_COUNT_1;
-               break;
-       case SBE_2T3E3_PAD_COUNT_2:
-               val = SBE_2T3E3_CPLD_VAL_PAD_COUNT_2;
-               break;
-       case SBE_2T3E3_PAD_COUNT_3:
-               val = SBE_2T3E3_CPLD_VAL_PAD_COUNT_3;
-               break;
-       case SBE_2T3E3_PAD_COUNT_4:
-               val = SBE_2T3E3_CPLD_VAL_PAD_COUNT_4;
-               break;
-       default:
-               return;
-       }
-
-       cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRB,
-                      SBE_2T3E3_CPLD_VAL_PAD_COUNT);
-       cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRB, val);
-       sc->p.pad_count = count;
-}
-
-void cpld_LOS_update(struct channel *sc)
-{
-       u_int8_t los;
-
-       cpld_write(sc, SBE_2T3E3_CPLD_REG_PICSR,
-                  SBE_2T3E3_CPLD_VAL_DMO_SIGNAL_DETECTED |
-                  SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_LOCK_DETECTED |
-                  SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_DETECTED);
-       los = cpld_read(sc, SBE_2T3E3_CPLD_REG_PICSR) &
-               SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_DETECTED;
-
-       if (los != sc->s.LOS)
-               dev_info(&sc->pdev->dev, "SBE 2T3E3: LOS status: %s\n",
-                        los ? "Loss of signal" : "Signal OK");
-       sc->s.LOS = los;
-}
-
-void cpld_set_fractional_mode(struct channel *sc, u32 mode,
-                             u32 start, u32 stop)
-{
-       if (mode == SBE_2T3E3_FRACTIONAL_MODE_NONE) {
-               start = 0;
-               stop = 0;
-       }
-
-       if (sc->p.fractional_mode == mode && sc->p.bandwidth_start == start &&
-           sc->p.bandwidth_stop == stop)
-               return;
-
-       switch (mode) {
-       case SBE_2T3E3_FRACTIONAL_MODE_NONE:
-               cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRC,
-                          SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_NONE);
-               break;
-       case SBE_2T3E3_FRACTIONAL_MODE_0:
-               cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRC,
-                          SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_0);
-               break;
-       case SBE_2T3E3_FRACTIONAL_MODE_1:
-               cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRC,
-                          SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_1);
-               break;
-       case SBE_2T3E3_FRACTIONAL_MODE_2:
-               cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRC,
-                          SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_2);
-               break;
-       default:
-               netdev_err(sc->dev, "wrong mode in set_fractional_mode\n");
-               return;
-       }
-
-       cpld_write(sc, SBE_2T3E3_CPLD_REG_PBWF, start);
-       cpld_write(sc, SBE_2T3E3_CPLD_REG_PBWL, stop);
-
-       sc->p.fractional_mode = mode;
-       sc->p.bandwidth_start = start;
-       sc->p.bandwidth_stop = stop;
-}
diff --git a/drivers/staging/sbe-2t3e3/ctrl.c b/drivers/staging/sbe-2t3e3/ctrl.c
deleted file mode 100644 (file)
index e0964ac..0000000
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * SBE 2T3E3 synchronous serial card driver for Linux
- *
- * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- *
- * This code is based on a driver written by SBE Inc.
- */
-
-#include <linux/types.h>
-#include "2t3e3.h"
-#include "ctrl.h"
-
-void t3e3_set_frame_type(struct channel *sc, u32 mode)
-{
-       if (sc->p.frame_type == mode)
-               return;
-
-       if (sc->r.flags & SBE_2T3E3_FLAG_NETWORK_UP) {
-               dev_err(&sc->pdev->dev, "SBE 2T3E3: changing frame type during active connection\n");
-               return;
-       }
-
-       exar7300_set_frame_type(sc, mode);
-       exar7250_set_frame_type(sc, mode);
-       cpld_set_frame_type(sc, mode);
-
-       sc->p.frame_type = mode;
-}
-
-static void t3e3_set_loopback(struct channel *sc, u32 mode)
-{
-       u32 tx, rx;
-
-       if (sc->p.loopback == mode)
-               return;
-
-       tx = sc->p.transmitter_on;
-       rx = sc->p.receiver_on;
-       if (tx == SBE_2T3E3_ON)
-               dc_transmitter_onoff(sc, SBE_2T3E3_OFF);
-       if (rx == SBE_2T3E3_ON)
-               dc_receiver_onoff(sc, SBE_2T3E3_OFF);
-
-       /* stop current loopback if any exists */
-       switch (sc->p.loopback) {
-       case SBE_2T3E3_LOOPBACK_NONE:
-               break;
-       case SBE_2T3E3_LOOPBACK_ETHERNET:
-               dc_set_loopback(sc, SBE_2T3E3_21143_VAL_LOOPBACK_OFF);
-               break;
-       case SBE_2T3E3_LOOPBACK_FRAMER:
-               exar7250_set_loopback(sc, SBE_2T3E3_FRAMER_VAL_LOOPBACK_OFF);
-               break;
-       case SBE_2T3E3_LOOPBACK_LIU_DIGITAL:
-       case SBE_2T3E3_LOOPBACK_LIU_ANALOG:
-       case SBE_2T3E3_LOOPBACK_LIU_REMOTE:
-               exar7300_set_loopback(sc, SBE_2T3E3_LIU_VAL_LOOPBACK_OFF);
-               break;
-       default:
-               return;
-       }
-
-       switch (mode) {
-       case SBE_2T3E3_LOOPBACK_NONE:
-               break;
-       case SBE_2T3E3_LOOPBACK_ETHERNET:
-               dc_set_loopback(sc, SBE_2T3E3_21143_VAL_LOOPBACK_INTERNAL);
-               break;
-       case SBE_2T3E3_LOOPBACK_FRAMER:
-               exar7250_set_loopback(sc, SBE_2T3E3_FRAMER_VAL_LOOPBACK_ON);
-               break;
-       case SBE_2T3E3_LOOPBACK_LIU_DIGITAL:
-               exar7300_set_loopback(sc, SBE_2T3E3_LIU_VAL_LOOPBACK_DIGITAL);
-               break;
-       case SBE_2T3E3_LOOPBACK_LIU_ANALOG:
-               exar7300_set_loopback(sc, SBE_2T3E3_LIU_VAL_LOOPBACK_ANALOG);
-               break;
-       case SBE_2T3E3_LOOPBACK_LIU_REMOTE:
-               exar7300_set_loopback(sc, SBE_2T3E3_LIU_VAL_LOOPBACK_REMOTE);
-               break;
-       default:
-               return;
-       }
-
-       sc->p.loopback = mode;
-
-       if (tx == SBE_2T3E3_ON)
-               dc_transmitter_onoff(sc, SBE_2T3E3_ON);
-       if (rx == SBE_2T3E3_ON)
-               dc_receiver_onoff(sc, SBE_2T3E3_ON);
-}
-
-
-static void t3e3_reg_read(struct channel *sc, u32 *reg, u32 *val)
-{
-       u32 i;
-
-       *val = 0;
-
-       switch (reg[0]) {
-       case SBE_2T3E3_CHIP_21143:
-               if (!(reg[1] & 7))
-                       *val = dc_read(sc->addr, reg[1] / 8);
-               break;
-       case SBE_2T3E3_CHIP_CPLD:
-               for (i = 0; i < SBE_2T3E3_CPLD_REG_MAX; i++)
-                       if (cpld_reg_map[i][sc->h.slot] == reg[1]) {
-                               *val = cpld_read(sc, i);
-                               break;
-                       }
-               break;
-       case SBE_2T3E3_CHIP_FRAMER:
-               for (i = 0; i < SBE_2T3E3_FRAMER_REG_MAX; i++)
-                       if (t3e3_framer_reg_map[i] == reg[1]) {
-                               *val = exar7250_read(sc, i);
-                               break;
-                       }
-               break;
-       case SBE_2T3E3_CHIP_LIU:
-               for (i = 0; i < SBE_2T3E3_LIU_REG_MAX; i++)
-                       if (t3e3_liu_reg_map[i] == reg[1]) {
-                               *val = exar7300_read(sc, i);
-                               break;
-                       }
-               break;
-       default:
-               break;
-       }
-}
-
-static void t3e3_reg_write(struct channel *sc, u32 *reg)
-{
-       u32 i;
-
-       switch (reg[0]) {
-       case SBE_2T3E3_CHIP_21143:
-               dc_write(sc->addr, reg[1], reg[2]);
-               break;
-       case SBE_2T3E3_CHIP_CPLD:
-               for (i = 0; i < SBE_2T3E3_CPLD_REG_MAX; i++)
-                       if (cpld_reg_map[i][sc->h.slot] == reg[1]) {
-                               cpld_write(sc, i, reg[2]);
-                               break;
-                       }
-               break;
-       case SBE_2T3E3_CHIP_FRAMER:
-               for (i = 0; i < SBE_2T3E3_FRAMER_REG_MAX; i++)
-                       if (t3e3_framer_reg_map[i] == reg[1]) {
-                               exar7250_write(sc, i, reg[2]);
-                               break;
-                       }
-               break;
-       case SBE_2T3E3_CHIP_LIU:
-               for (i = 0; i < SBE_2T3E3_LIU_REG_MAX; i++)
-                       if (t3e3_liu_reg_map[i] == reg[1]) {
-                               exar7300_write(sc, i, reg[2]);
-                               break;
-                       }
-               break;
-       }
-}
-
-static void t3e3_port_get(struct channel *sc, struct t3e3_param *param)
-{
-       memcpy(param, &(sc->p), sizeof(struct t3e3_param));
-}
-
-static void t3e3_port_set(struct channel *sc, struct t3e3_param *param)
-{
-       if (param->frame_mode != 0xff)
-               cpld_set_frame_mode(sc, param->frame_mode);
-
-       if (param->fractional_mode != 0xff)
-               cpld_set_fractional_mode(sc, param->fractional_mode,
-                                        param->bandwidth_start,
-                                        param->bandwidth_stop);
-
-       if (param->pad_count != 0xff)
-               cpld_set_pad_count(sc, param->pad_count);
-
-       if (param->crc != 0xff)
-               cpld_set_crc(sc, param->crc);
-
-       if (param->receiver_on != 0xff)
-               dc_receiver_onoff(sc, param->receiver_on);
-
-       if (param->transmitter_on != 0xff)
-               dc_transmitter_onoff(sc, param->transmitter_on);
-
-       if (param->frame_type != 0xff)
-               t3e3_set_frame_type(sc, param->frame_type);
-
-       if (param->panel != 0xff)
-               cpld_select_panel(sc, param->panel);
-
-       if (param->line_build_out != 0xff)
-               exar7300_line_build_out_onoff(sc, param->line_build_out);
-
-       if (param->receive_equalization != 0xff)
-               exar7300_receive_equalization_onoff(sc, param->receive_equalization);
-
-       if (param->transmit_all_ones != 0xff)
-               exar7300_transmit_all_ones_onoff(sc, param->transmit_all_ones);
-
-       if (param->loopback != 0xff)
-               t3e3_set_loopback(sc, param->loopback);
-
-       if (param->clock_source != 0xff)
-               cpld_set_clock(sc, param->clock_source);
-
-       if (param->scrambler != 0xff)
-               cpld_set_scrambler(sc, param->scrambler);
-}
-
-static void t3e3_port_get_stats(struct channel *sc, struct t3e3_stats *stats)
-{
-       u32 result;
-
-       sc->s.LOC = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_IO_CONTROL)
-               & SBE_2T3E3_FRAMER_VAL_LOSS_OF_CLOCK_STATUS ? 1 : 0;
-
-       switch (sc->p.frame_type) {
-       case SBE_2T3E3_FRAME_TYPE_E3_G751:
-       case SBE_2T3E3_FRAME_TYPE_E3_G832:
-               result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2);
-               sc->s.LOF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_LOF ? 1 : 0;
-               sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0;
-
-               cpld_LOS_update(sc);
-
-               sc->s.AIS = result & SBE_2T3E3_FRAMER_VAL_E3_RX_AIS ? 1 : 0;
-               sc->s.FERF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_FERF ? 1 : 0;
-               break;
-
-       case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
-       case SBE_2T3E3_FRAME_TYPE_T3_M13:
-               result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS);
-               sc->s.AIS = result & SBE_2T3E3_FRAMER_VAL_T3_RX_AIS ? 1 : 0;
-
-               cpld_LOS_update(sc);
-
-               sc->s.IDLE = result & SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE ? 1 : 0;
-               sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0;
-
-               result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_STATUS);
-               sc->s.FERF = result & SBE_2T3E3_FRAMER_VAL_T3_RX_FERF ? 1 : 0;
-               sc->s.AIC = result & SBE_2T3E3_FRAMER_VAL_T3_RX_AIC ? 1 : 0;
-               sc->s.FEBE_code = result & SBE_2T3E3_FRAMER_VAL_T3_RX_FEBE;
-
-               sc->s.FEAC = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC);
-               break;
-
-       default:
-               break;
-       }
-
-       result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_LCV_EVENT_COUNT_MSB) << 8;
-       result += exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_HOLDING_REGISTER);
-       sc->s.LCV += result;
-
-       result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_FRAMING_BIT_ERROR_EVENT_COUNT_MSB) << 8;
-       result += exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_HOLDING_REGISTER);
-       sc->s.FRAMING_BIT += result;
-
-       result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_PARITY_ERROR_EVENT_COUNT_MSB) << 8;
-       result += exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_HOLDING_REGISTER);
-       sc->s.PARITY_ERROR += result;
-
-       result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_FEBE_EVENT_COUNT_MSB) << 8;
-       result += exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_HOLDING_REGISTER);
-       sc->s.FEBE_count += result;
-
-       result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_CP_BIT_ERROR_EVENT_COUNT_MSB) << 8;
-       result += exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_HOLDING_REGISTER);
-       sc->s.CP_BIT += result;
-
-       memcpy(stats, &(sc->s), sizeof(struct t3e3_stats));
-}
-
-static void t3e3_port_del_stats(struct channel *sc)
-{
-       memset(&(sc->s), 0, sizeof(struct t3e3_stats));
-}
-
-void t3e3_if_config(struct channel *sc, u32 cmd, char *set,
-                   struct t3e3_resp *ret, int *rlen)
-{
-       struct t3e3_param *param = (struct t3e3_param *)set;
-       u32 *data = (u32 *)set;
-
-       /* turn off all interrupt */
-       /* cpld_stop_intr(sc); */
-
-       switch (cmd) {
-       case SBE_2T3E3_PORT_GET:
-               t3e3_port_get(sc, &(ret->u.param));
-               *rlen = sizeof(ret->u.param);
-               break;
-       case SBE_2T3E3_PORT_SET:
-               t3e3_port_set(sc, param);
-               *rlen = 0;
-               break;
-       case SBE_2T3E3_PORT_GET_STATS:
-               t3e3_port_get_stats(sc, &(ret->u.stats));
-               *rlen = sizeof(ret->u.stats);
-               break;
-       case SBE_2T3E3_PORT_DEL_STATS:
-               t3e3_port_del_stats(sc);
-               *rlen = 0;
-               break;
-       case SBE_2T3E3_PORT_READ_REGS:
-               t3e3_reg_read(sc, data, &(ret->u.data));
-               *rlen = sizeof(ret->u.data);
-               break;
-       case SBE_2T3E3_PORT_WRITE_REGS:
-               t3e3_reg_write(sc, data);
-               *rlen = 0;
-               break;
-       case SBE_2T3E3_LOG_LEVEL:
-               *rlen = 0;
-               break;
-       default:
-               *rlen = 0;
-               break;
-       }
-}
-
-void t3e3_sc_init(struct channel *sc)
-{
-       memset(sc, 0, sizeof(*sc));
-
-       sc->p.frame_mode = SBE_2T3E3_FRAME_MODE_HDLC;
-       sc->p.fractional_mode = SBE_2T3E3_FRACTIONAL_MODE_NONE;
-       sc->p.crc = SBE_2T3E3_CRC_32;
-       sc->p.receiver_on = SBE_2T3E3_OFF;
-       sc->p.transmitter_on = SBE_2T3E3_OFF;
-       sc->p.frame_type = SBE_2T3E3_FRAME_TYPE_T3_CBIT;
-       sc->p.panel = SBE_2T3E3_PANEL_FRONT;
-       sc->p.line_build_out = SBE_2T3E3_OFF;
-       sc->p.receive_equalization = SBE_2T3E3_OFF;
-       sc->p.transmit_all_ones = SBE_2T3E3_OFF;
-       sc->p.loopback = SBE_2T3E3_LOOPBACK_NONE;
-       sc->p.clock_source = SBE_2T3E3_TIMING_LOCAL;
-       sc->p.scrambler = SBE_2T3E3_SCRAMBLER_OFF;
-       sc->p.pad_count = SBE_2T3E3_PAD_COUNT_1;
-}
diff --git a/drivers/staging/sbe-2t3e3/ctrl.h b/drivers/staging/sbe-2t3e3/ctrl.h
deleted file mode 100644 (file)
index 41f144d..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * SBE 2T3E3 synchronous serial card driver for Linux
- *
- * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- *
- * This code is based on a driver written by SBE Inc.
- */
-
-#ifndef CTRL_H
-#define CTRL_H
-
-#define SBE_2T3E3_OFF                                  0
-#define SBE_2T3E3_ON                                   1
-
-#define SBE_2T3E3_LED_NONE                             0
-#define SBE_2T3E3_LED_GREEN                            1
-#define SBE_2T3E3_LED_YELLOW                           2
-
-#define SBE_2T3E3_CABLE_LENGTH_LESS_THAN_255_FEET      0
-#define SBE_2T3E3_CABLE_LENGTH_GREATER_THAN_255_FEET   1
-
-#define SBE_2T3E3_CRC_16                               0
-#define SBE_2T3E3_CRC_32                               1
-
-#define SBE_2T3E3_PANEL_FRONT                          0
-#define SBE_2T3E3_PANEL_REAR                           1
-
-#define SBE_2T3E3_FRAME_MODE_HDLC                      0
-#define SBE_2T3E3_FRAME_MODE_TRANSPARENT               1
-#define SBE_2T3E3_FRAME_MODE_RAW                       2
-
-#define SBE_2T3E3_FRAME_TYPE_E3_G751                   0
-#define SBE_2T3E3_FRAME_TYPE_E3_G832                   1
-#define SBE_2T3E3_FRAME_TYPE_T3_CBIT                   2
-#define SBE_2T3E3_FRAME_TYPE_T3_M13                    3
-
-#define SBE_2T3E3_FRACTIONAL_MODE_NONE                 0
-#define SBE_2T3E3_FRACTIONAL_MODE_0                    1
-#define SBE_2T3E3_FRACTIONAL_MODE_1                    2
-#define SBE_2T3E3_FRACTIONAL_MODE_2                    3
-
-#define SBE_2T3E3_SCRAMBLER_OFF                                0
-#define SBE_2T3E3_SCRAMBLER_LARSCOM                    1
-#define SBE_2T3E3_SCRAMBLER_ADC_KENTROX_DIGITAL                2
-
-#define SBE_2T3E3_TIMING_LOCAL                         0
-#define SBE_2T3E3_TIMING_LOOP                          1
-
-#define SBE_2T3E3_LOOPBACK_NONE                                0
-#define SBE_2T3E3_LOOPBACK_ETHERNET                    1
-#define SBE_2T3E3_LOOPBACK_FRAMER                      2
-#define SBE_2T3E3_LOOPBACK_LIU_DIGITAL                 3
-#define SBE_2T3E3_LOOPBACK_LIU_ANALOG                  4
-#define SBE_2T3E3_LOOPBACK_LIU_REMOTE                  5
-
-#define SBE_2T3E3_PAD_COUNT_1                          1
-#define SBE_2T3E3_PAD_COUNT_2                          2
-#define SBE_2T3E3_PAD_COUNT_3                          3
-#define SBE_2T3E3_PAD_COUNT_4                          4
-
-#define SBE_2T3E3_CHIP_21143                           0
-#define SBE_2T3E3_CHIP_CPLD                            1
-#define SBE_2T3E3_CHIP_FRAMER                          2
-#define SBE_2T3E3_CHIP_LIU                             3
-
-#define SBE_2T3E3_LOG_LEVEL_NONE                       0
-#define SBE_2T3E3_LOG_LEVEL_ERROR                      1
-#define SBE_2T3E3_LOG_LEVEL_WARNING                    2
-#define SBE_2T3E3_LOG_LEVEL_INFO                       3
-
-/* commands */
-#define SBE_2T3E3_PORT_GET                             0
-#define SBE_2T3E3_PORT_SET                             1
-#define SBE_2T3E3_PORT_GET_STATS                       2
-#define SBE_2T3E3_PORT_DEL_STATS                       3
-#define SBE_2T3E3_PORT_READ_REGS                       4
-#define SBE_2T3E3_LOG_LEVEL                            5
-#define SBE_2T3E3_PORT_WRITE_REGS                      6
-
-#define NG_SBE_2T3E3_NODE_TYPE  "sbe2T3E3"
-#define NG_SBE_2T3E3_COOKIE     0x03800891
-
-struct t3e3_param {
-       u_int8_t frame_mode;            /* FRAME_MODE_* */
-       u_int8_t crc;                   /* CRC_* */
-       u_int8_t receiver_on;           /* ON/OFF */
-       u_int8_t transmitter_on;        /* ON/OFF */
-       u_int8_t frame_type;            /* FRAME_TYPE_* */
-       u_int8_t panel;                 /* PANEL_* */
-       u_int8_t line_build_out;        /* ON/OFF */
-       u_int8_t receive_equalization;  /* ON/OFF */
-       u_int8_t transmit_all_ones;     /* ON/OFF */
-       u_int8_t loopback;              /* LOOPBACK_* */
-       u_int8_t clock_source;          /* TIMING_* */
-       u_int8_t scrambler;             /* SCRAMBLER_* */
-       u_int8_t pad_count;             /* PAD_COUNT_* */
-       u_int8_t log_level;             /* LOG_LEVEL_* - unused */
-       u_int8_t fractional_mode;       /* FRACTIONAL_MODE_* */
-       u_int8_t bandwidth_start;       /* 0-255 */
-       u_int8_t bandwidth_stop;        /* 0-255 */
-};
-
-struct t3e3_stats {
-       u_int64_t in_bytes;
-       u32 in_packets, in_dropped;
-       u32 in_errors, in_error_desc, in_error_coll, in_error_drib,
-               in_error_crc, in_error_mii;
-       u_int64_t out_bytes;
-       u32 out_packets, out_dropped;
-       u32 out_errors, out_error_jab, out_error_lost_carr,
-               out_error_no_carr, out_error_link_fail, out_error_underflow,
-               out_error_dereferred;
-       u_int8_t LOC, LOF, OOF, LOS, AIS, FERF, IDLE, AIC, FEAC;
-       u_int16_t FEBE_code;
-       u32 LCV, FRAMING_BIT, PARITY_ERROR, FEBE_count, CP_BIT;
-};
-
-
-struct t3e3_resp {
-       union {
-               struct t3e3_param param;
-               struct t3e3_stats stats;
-               u32 data;
-       } u;
-};
-
-#endif /* CTRL_H */
diff --git a/drivers/staging/sbe-2t3e3/dc.c b/drivers/staging/sbe-2t3e3/dc.c
deleted file mode 100644 (file)
index 02510f6..0000000
+++ /dev/null
@@ -1,460 +0,0 @@
-/*
- * SBE 2T3E3 synchronous serial card driver for Linux
- *
- * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- *
- * This code is based on a driver written by SBE Inc.
- */
-
-#include <linux/netdevice.h>
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/io.h>
-#include "2t3e3.h"
-#include "ctrl.h"
-
-static int dc_init_descriptor_list(struct channel *sc);
-
-void dc_init(struct channel *sc)
-{
-       u32 val;
-
-       dc_stop(sc);
-       /*dc_reset(sc);*/ /* do not want to reset here */
-
-       /*
-        * BUS_MODE (CSR0)
-        */
-       val = SBE_2T3E3_21143_VAL_READ_LINE_ENABLE |
-               SBE_2T3E3_21143_VAL_READ_MULTIPLE_ENABLE |
-               SBE_2T3E3_21143_VAL_TRANSMIT_AUTOMATIC_POLLING_200us |
-               SBE_2T3E3_21143_VAL_BUS_ARBITRATION_RR;
-
-       if (sc->h.command & 16)
-               val |= SBE_2T3E3_21143_VAL_WRITE_AND_INVALIDATE_ENABLE;
-
-       switch (sc->h.cache_size) {
-       case 32:
-               val |= SBE_2T3E3_21143_VAL_CACHE_ALIGNMENT_32;
-               break;
-       case 16:
-               val |= SBE_2T3E3_21143_VAL_CACHE_ALIGNMENT_16;
-               break;
-       case 8:
-               val |= SBE_2T3E3_21143_VAL_CACHE_ALIGNMENT_8;
-               break;
-       default:
-               break;
-       }
-
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_BUS_MODE, val);
-
-       /* OPERATION_MODE (CSR6) */
-       val = SBE_2T3E3_21143_VAL_RECEIVE_ALL |
-               SBE_2T3E3_21143_VAL_MUST_BE_ONE |
-               SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_1 |
-               SBE_2T3E3_21143_VAL_LOOPBACK_OFF |
-               SBE_2T3E3_21143_VAL_PASS_ALL_MULTICAST |
-               SBE_2T3E3_21143_VAL_PROMISCUOUS_MODE |
-               SBE_2T3E3_21143_VAL_PASS_BAD_FRAMES;
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, val);
-       if (sc->p.loopback == SBE_2T3E3_LOOPBACK_ETHERNET)
-               sc->p.loopback = SBE_2T3E3_LOOPBACK_NONE;
-
-       /*
-        * GENERAL_PURPOSE_TIMER_AND_INTERRUPT_MITIGATION_CONTROL (CSR11)
-        */
-       val = SBE_2T3E3_21143_VAL_CYCLE_SIZE |
-               SBE_2T3E3_21143_VAL_TRANSMIT_TIMER |
-               SBE_2T3E3_21143_VAL_NUMBER_OF_TRANSMIT_PACKETS |
-               SBE_2T3E3_21143_VAL_RECEIVE_TIMER |
-               SBE_2T3E3_21143_VAL_NUMBER_OF_RECEIVE_PACKETS;
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_GENERAL_PURPOSE_TIMER_AND_INTERRUPT_MITIGATION_CONTROL, val);
-
-       /* prepare descriptors and data for receive and transmit processes */
-       if (dc_init_descriptor_list(sc) != 0)
-               return;
-
-       /* clear ethernet interrupts status */
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_STATUS, 0xFFFFFFFF);
-
-       /* SIA mode registers */
-       dc_set_output_port(sc);
-}
-
-void dc_start(struct channel *sc)
-{
-       u32 val;
-
-       if (!(sc->r.flags & SBE_2T3E3_FLAG_NETWORK_UP))
-               return;
-
-       dc_init(sc);
-
-       /* get actual LOS and OOF status */
-       switch (sc->p.frame_type) {
-       case SBE_2T3E3_FRAME_TYPE_E3_G751:
-       case SBE_2T3E3_FRAME_TYPE_E3_G832:
-               val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2);
-               dev_dbg(&sc->pdev->dev, "Start Framer Rx Status = %02X\n", val);
-               sc->s.OOF = val & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0;
-               break;
-       case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
-       case SBE_2T3E3_FRAME_TYPE_T3_M13:
-               val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS);
-               dev_dbg(&sc->pdev->dev, "Start Framer Rx Status = %02X\n", val);
-               sc->s.OOF = val & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0;
-               break;
-       default:
-               break;
-       }
-       cpld_LOS_update(sc);
-
-       /* start receive and transmit processes */
-       dc_transmitter_onoff(sc, SBE_2T3E3_ON);
-       dc_receiver_onoff(sc, SBE_2T3E3_ON);
-
-       /* start interrupts */
-       dc_start_intr(sc);
-}
-
-#define MAX_INT_WAIT_CNT       12000
-void dc_stop(struct channel *sc)
-{
-       int wcnt;
-
-       /* stop receive and transmit processes */
-       dc_receiver_onoff(sc, SBE_2T3E3_OFF);
-       dc_transmitter_onoff(sc, SBE_2T3E3_OFF);
-
-       /* turn off ethernet interrupts */
-       dc_stop_intr(sc);
-
-       /* wait to ensure the interrupts have been completed */
-       for (wcnt = 0; wcnt < MAX_INT_WAIT_CNT; wcnt++) {
-               udelay(5);
-               if (!sc->interrupt_active)
-                       break;
-       }
-       if (wcnt >= MAX_INT_WAIT_CNT)
-               dev_warn(&sc->pdev->dev, "SBE 2T3E3: Interrupt active too long\n");
-
-       /* clear all receive/transmit data */
-       dc_drop_descriptor_list(sc);
-}
-
-void dc_start_intr(struct channel *sc)
-{
-       if (sc->p.loopback == SBE_2T3E3_LOOPBACK_NONE && sc->s.OOF)
-               return;
-
-       if (sc->p.receiver_on || sc->p.transmitter_on) {
-               if (!sc->ether.interrupt_enable_mask)
-                       dc_write(sc->addr, SBE_2T3E3_21143_REG_STATUS, 0xFFFFFFFF);
-
-               sc->ether.interrupt_enable_mask =
-                       SBE_2T3E3_21143_VAL_NORMAL_INTERRUPT_SUMMARY_ENABLE |
-                       SBE_2T3E3_21143_VAL_ABNORMAL_INTERRUPT_SUMMARY_ENABLE |
-                       SBE_2T3E3_21143_VAL_RECEIVE_STOPPED_ENABLE |
-                       SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE_ENABLE |
-                       SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT_ENABLE |
-                       SBE_2T3E3_21143_VAL_TRANSMIT_UNDERFLOW_INTERRUPT_ENABLE |
-                       SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE_ENABLE |
-                       SBE_2T3E3_21143_VAL_TRANSMIT_STOPPED_ENABLE |
-                       SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT_ENABLE;
-
-               dc_write(sc->addr, SBE_2T3E3_21143_REG_INTERRUPT_ENABLE,
-                        sc->ether.interrupt_enable_mask);
-       }
-}
-
-void dc_stop_intr(struct channel *sc)
-{
-       sc->ether.interrupt_enable_mask = 0;
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_INTERRUPT_ENABLE, 0);
-}
-
-void dc_reset(struct channel *sc)
-{
-       /* turn off ethernet interrupts */
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_INTERRUPT_ENABLE, 0);
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_STATUS, 0xFFFFFFFF);
-
-       /* software reset */
-       dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_BUS_MODE,
-                  SBE_2T3E3_21143_VAL_SOFTWARE_RESET);
-       udelay(4); /* 50 PCI cycles < 2us */
-
-       /* clear hardware configuration */
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_BUS_MODE, 0);
-
-       /* clear software configuration */
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, 0);
-
-       /* turn off SIA reset */
-       dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_SIA_CONNECTIVITY,
-                  SBE_2T3E3_21143_VAL_SIA_RESET);
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_SIA_TRANSMIT_AND_RECEIVE, 0);
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_SIA_AND_GENERAL_PURPOSE_PORT, 0);
-}
-
-
-void dc_receiver_onoff(struct channel *sc, u32 mode)
-{
-       u32 i, state = 0;
-
-       if (sc->p.receiver_on == mode)
-               return;
-
-       switch (mode) {
-       case SBE_2T3E3_OFF:
-               if (dc_read(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE) &
-                   SBE_2T3E3_21143_VAL_RECEIVE_START) {
-                       dc_clear_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
-                                     SBE_2T3E3_21143_VAL_RECEIVE_START);
-
-                       for (i = 0; i < 16; i++) {
-                               state = dc_read(sc->addr, SBE_2T3E3_21143_REG_STATUS) &
-                                       SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STATE;
-                               if (state == SBE_2T3E3_21143_VAL_RX_STOPPED)
-                                       break;
-                               udelay(5);
-                       }
-                       if (state != SBE_2T3E3_21143_VAL_RX_STOPPED)
-                               dev_warn(&sc->pdev->dev, "SBE 2T3E3: Rx failed to stop\n");
-                       else
-                               dev_info(&sc->pdev->dev, "SBE 2T3E3: Rx off\n");
-               }
-               break;
-       case SBE_2T3E3_ON:
-               dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
-                          SBE_2T3E3_21143_VAL_RECEIVE_START);
-               udelay(100);
-               dc_write(sc->addr, SBE_2T3E3_21143_REG_RECEIVE_POLL_DEMAND, 0xFFFFFFFF);
-               break;
-       default:
-               return;
-       }
-
-       sc->p.receiver_on = mode;
-}
-
-void dc_transmitter_onoff(struct channel *sc, u32 mode)
-{
-       u32 i, state = 0;
-
-       if (sc->p.transmitter_on == mode)
-               return;
-
-       switch (mode) {
-       case SBE_2T3E3_OFF:
-               if (dc_read(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE) &
-                   SBE_2T3E3_21143_VAL_TRANSMISSION_START) {
-                       dc_clear_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
-                                     SBE_2T3E3_21143_VAL_TRANSMISSION_START);
-
-                       for (i = 0; i < 16; i++) {
-                               state = dc_read(sc->addr, SBE_2T3E3_21143_REG_STATUS) &
-                                       SBE_2T3E3_21143_VAL_TRANSMISSION_PROCESS_STATE;
-                               if (state == SBE_2T3E3_21143_VAL_TX_STOPPED)
-                                       break;
-                               udelay(5);
-                       }
-                       if (state != SBE_2T3E3_21143_VAL_TX_STOPPED)
-                               dev_warn(&sc->pdev->dev, "SBE 2T3E3: Tx failed to stop\n");
-               }
-               break;
-       case SBE_2T3E3_ON:
-               dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
-                          SBE_2T3E3_21143_VAL_TRANSMISSION_START);
-               udelay(100);
-               dc_write(sc->addr, SBE_2T3E3_21143_REG_TRANSMIT_POLL_DEMAND, 0xFFFFFFFF);
-               break;
-       default:
-               return;
-       }
-
-       sc->p.transmitter_on = mode;
-}
-
-
-
-void dc_set_loopback(struct channel *sc, u32 mode)
-{
-       u32 val;
-
-       switch (mode) {
-       case SBE_2T3E3_21143_VAL_LOOPBACK_OFF:
-       case SBE_2T3E3_21143_VAL_LOOPBACK_INTERNAL:
-               break;
-       default:
-               return;
-       }
-
-       /* select loopback mode */
-       val = dc_read(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE) &
-               ~SBE_2T3E3_21143_VAL_OPERATING_MODE;
-       val |= mode;
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, val);
-
-       if (mode == SBE_2T3E3_21143_VAL_LOOPBACK_OFF)
-               dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
-                          SBE_2T3E3_21143_VAL_FULL_DUPLEX_MODE);
-       else
-               dc_clear_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
-                             SBE_2T3E3_21143_VAL_FULL_DUPLEX_MODE);
-}
-
-static int dc_init_descriptor_list(struct channel *sc)
-{
-       u32 i, j;
-       struct sk_buff *m;
-
-       if (sc->ether.rx_ring == NULL)
-               sc->ether.rx_ring = kcalloc(SBE_2T3E3_RX_DESC_RING_SIZE,
-                                           sizeof(struct t3e3_rx_desc), GFP_KERNEL);
-       if (sc->ether.rx_ring == NULL)
-               return -ENOMEM;
-
-       if (sc->ether.tx_ring == NULL)
-               sc->ether.tx_ring = kcalloc(SBE_2T3E3_TX_DESC_RING_SIZE,
-                                           sizeof(struct t3e3_tx_desc), GFP_KERNEL);
-       if (sc->ether.tx_ring == NULL) {
-               kfree(sc->ether.rx_ring);
-               sc->ether.rx_ring = NULL;
-               return -ENOMEM;
-       }
-
-
-       /*
-        * Receive ring
-        */
-       for (i = 0; i < SBE_2T3E3_RX_DESC_RING_SIZE; i++) {
-               sc->ether.rx_ring[i].rdes0 = SBE_2T3E3_RX_DESC_21143_OWN;
-               sc->ether.rx_ring[i].rdes1 =
-                       SBE_2T3E3_RX_DESC_SECOND_ADDRESS_CHAINED | SBE_2T3E3_MTU;
-
-               if (sc->ether.rx_data[i] == NULL) {
-                       m = dev_alloc_skb(MCLBYTES);
-                       if (!m) {
-                               for (j = 0; j < i; j++) {
-                                       dev_kfree_skb_any(sc->ether.rx_data[j]);
-                                       sc->ether.rx_data[j] = NULL;
-                               }
-                               kfree(sc->ether.rx_ring);
-                               sc->ether.rx_ring = NULL;
-                               kfree(sc->ether.tx_ring);
-                               sc->ether.tx_ring = NULL;
-                               dev_err(&sc->pdev->dev, "SBE 2T3E3: token_alloc err:"
-                                       " no buffer space for RX ring\n");
-                               return -ENOBUFS;
-                       }
-                       sc->ether.rx_data[i] = m;
-               }
-               sc->ether.rx_ring[i].rdes2 = virt_to_phys(sc->ether.rx_data[i]->data);
-
-               sc->ether.rx_ring[i].rdes3 = virt_to_phys(
-                       &sc->ether.rx_ring[(i + 1) % SBE_2T3E3_RX_DESC_RING_SIZE]);
-       }
-       sc->ether.rx_ring[SBE_2T3E3_RX_DESC_RING_SIZE - 1].rdes1 |=
-               SBE_2T3E3_RX_DESC_END_OF_RING;
-       sc->ether.rx_ring_current_read = 0;
-
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_RECEIVE_LIST_BASE_ADDRESS,
-                virt_to_phys(&sc->ether.rx_ring[0]));
-
-       /*
-        * Transmit ring
-        */
-       for (i = 0; i < SBE_2T3E3_TX_DESC_RING_SIZE; i++) {
-               sc->ether.tx_ring[i].tdes0 = 0;
-               sc->ether.tx_ring[i].tdes1 = SBE_2T3E3_TX_DESC_SECOND_ADDRESS_CHAINED |
-                       SBE_2T3E3_TX_DESC_DISABLE_PADDING;
-
-               sc->ether.tx_ring[i].tdes2 = 0;
-               sc->ether.tx_data[i] = NULL;
-
-               sc->ether.tx_ring[i].tdes3 = virt_to_phys(
-                       &sc->ether.tx_ring[(i + 1) % SBE_2T3E3_TX_DESC_RING_SIZE]);
-       }
-       sc->ether.tx_ring[SBE_2T3E3_TX_DESC_RING_SIZE - 1].tdes1 |=
-               SBE_2T3E3_TX_DESC_END_OF_RING;
-
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_TRANSMIT_LIST_BASE_ADDRESS,
-                virt_to_phys(&sc->ether.tx_ring[0]));
-       sc->ether.tx_ring_current_read = 0;
-       sc->ether.tx_ring_current_write = 0;
-       sc->ether.tx_free_cnt = SBE_2T3E3_TX_DESC_RING_SIZE;
-       spin_lock_init(&sc->ether.tx_lock);
-
-       return 0;
-}
-
-void dc_clear_descriptor_list(struct channel *sc)
-{
-       u32 i;
-
-       /* clear CSR3 and CSR4 */
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_RECEIVE_LIST_BASE_ADDRESS, 0);
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_TRANSMIT_LIST_BASE_ADDRESS, 0);
-
-       /* free all data buffers on TX ring */
-       for (i = 0; i < SBE_2T3E3_TX_DESC_RING_SIZE; i++) {
-               if (sc->ether.tx_data[i] != NULL) {
-                       dev_kfree_skb_any(sc->ether.tx_data[i]);
-                       sc->ether.tx_data[i] = NULL;
-               }
-       }
-}
-
-void dc_drop_descriptor_list(struct channel *sc)
-{
-       u32 i;
-
-       dc_clear_descriptor_list(sc);
-
-       /* free all data buffers on RX ring */
-       for (i = 0; i < SBE_2T3E3_RX_DESC_RING_SIZE; i++) {
-               if (sc->ether.rx_data[i] != NULL) {
-                       dev_kfree_skb_any(sc->ether.rx_data[i]);
-                       sc->ether.rx_data[i] = NULL;
-               }
-       }
-
-       kfree(sc->ether.rx_ring);
-       sc->ether.rx_ring = NULL;
-       kfree(sc->ether.tx_ring);
-       sc->ether.tx_ring = NULL;
-}
-
-
-void dc_set_output_port(struct channel *sc)
-{
-       dc_clear_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
-                     SBE_2T3E3_21143_VAL_PORT_SELECT);
-
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_SIA_STATUS, 0x00000301);
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_SIA_CONNECTIVITY, 0);
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_SIA_TRANSMIT_AND_RECEIVE, 0);
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_SIA_AND_GENERAL_PURPOSE_PORT, 0x08000011);
-
-       dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
-                  SBE_2T3E3_21143_VAL_TRANSMIT_THRESHOLD_MODE_100Mbs |
-                  SBE_2T3E3_21143_VAL_HEARTBEAT_DISABLE |
-                  SBE_2T3E3_21143_VAL_PORT_SELECT |
-                  SBE_2T3E3_21143_VAL_FULL_DUPLEX_MODE);
-}
-
-void dc_restart(struct channel *sc)
-{
-       dev_warn(&sc->pdev->dev, "SBE 2T3E3: 21143 restart\n");
-
-       dc_stop(sc);
-       dc_reset(sc);
-       dc_init(sc);    /* stop + reset + init */
-       dc_start(sc);
-}
diff --git a/drivers/staging/sbe-2t3e3/exar7250.c b/drivers/staging/sbe-2t3e3/exar7250.c
deleted file mode 100644 (file)
index e3ddd14..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * SBE 2T3E3 synchronous serial card driver for Linux
- *
- * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- *
- * This code is based on a driver written by SBE Inc.
- */
-
-#include "2t3e3.h"
-#include "ctrl.h"
-
-void exar7250_init(struct channel *sc)
-{
-       exar7250_write(sc, SBE_2T3E3_FRAMER_REG_OPERATING_MODE,
-                      SBE_2T3E3_FRAMER_VAL_T3_CBIT |
-                      SBE_2T3E3_FRAMER_VAL_INTERRUPT_ENABLE_RESET |
-                      SBE_2T3E3_FRAMER_VAL_TIMING_ASYNCH_TXINCLK);
-
-       exar7250_write(sc, SBE_2T3E3_FRAMER_REG_IO_CONTROL,
-                      SBE_2T3E3_FRAMER_VAL_DISABLE_TX_LOSS_OF_CLOCK |
-                      SBE_2T3E3_FRAMER_VAL_DISABLE_RX_LOSS_OF_CLOCK |
-                      SBE_2T3E3_FRAMER_VAL_AMI_LINE_CODE |
-                      SBE_2T3E3_FRAMER_VAL_RX_LINE_CLOCK_INVERT);
-
-       exar7250_set_frame_type(sc, SBE_2T3E3_FRAME_TYPE_T3_CBIT);
-}
-
-void exar7250_set_frame_type(struct channel *sc, u32 type)
-{
-       u32 val;
-
-       switch (type) {
-       case SBE_2T3E3_FRAME_TYPE_E3_G751:
-       case SBE_2T3E3_FRAME_TYPE_E3_G832:
-       case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
-       case SBE_2T3E3_FRAME_TYPE_T3_M13:
-               break;
-       default:
-               return;
-       }
-
-       exar7250_stop_intr(sc, type);
-
-       val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_OPERATING_MODE);
-       val &= ~(SBE_2T3E3_FRAMER_VAL_LOCAL_LOOPBACK_MODE |
-                SBE_2T3E3_FRAMER_VAL_T3_E3_SELECT |
-                SBE_2T3E3_FRAMER_VAL_FRAME_FORMAT_SELECT);
-       switch (type) {
-       case SBE_2T3E3_FRAME_TYPE_E3_G751:
-               val |= SBE_2T3E3_FRAMER_VAL_E3_G751;
-               break;
-       case SBE_2T3E3_FRAME_TYPE_E3_G832:
-               val |= SBE_2T3E3_FRAMER_VAL_E3_G832;
-               break;
-       case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
-               val |= SBE_2T3E3_FRAMER_VAL_T3_CBIT;
-               break;
-       case SBE_2T3E3_FRAME_TYPE_T3_M13:
-               val |= SBE_2T3E3_FRAMER_VAL_T3_M13;
-               break;
-       default:
-               return;
-       }
-       exar7250_write(sc, SBE_2T3E3_FRAMER_REG_OPERATING_MODE, val);
-       exar7250_start_intr(sc, type);
-}
-
-
-void exar7250_start_intr(struct channel *sc, u32 type)
-{
-       u32 val;
-
-       switch (type) {
-       case SBE_2T3E3_FRAME_TYPE_E3_G751:
-       case SBE_2T3E3_FRAME_TYPE_E3_G832:
-               val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2);
-
-               cpld_LOS_update(sc);
-
-               sc->s.OOF = val & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0;
-               exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_1);
-               exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_1,
-                              SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE |
-                              SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE);
-
-               exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2);
-               break;
-
-       case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
-       case SBE_2T3E3_FRAME_TYPE_T3_M13:
-               val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS);
-
-               cpld_LOS_update(sc);
-
-               sc->s.OOF = val & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0;
-
-               exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_STATUS);
-               exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE,
-                              SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE |
-                              SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE);
-
-               exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS);
-
-               exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL, 0);
-               break;
-
-       default:
-               return;
-       }
-
-       exar7250_read(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_STATUS);
-       exar7250_write(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE,
-                      SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_ENABLE |
-                      SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_ENABLE);
-}
-
-
-void exar7250_stop_intr(struct channel *sc, u32 type)
-{
-       exar7250_write(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE, 0);
-       exar7250_read(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_STATUS);
-
-       switch (type) {
-       case SBE_2T3E3_FRAME_TYPE_E3_G751:
-       case SBE_2T3E3_FRAME_TYPE_E3_G832:
-               exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_1, 0);
-               exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_1);
-               exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_2, 0);
-               exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2);
-               exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_LAPD_CONTROL, 0);
-               exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_LAPD_CONTROL);
-               exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_STATUS, 0);
-               exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_STATUS);
-               break;
-
-       case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
-       case SBE_2T3E3_FRAME_TYPE_T3_M13:
-               exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE, 0);
-               exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_STATUS);
-               exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS, 0);
-               exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS);
-               exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL, 0);
-               exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL);
-               exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_TX_FEAC_CONFIGURATION_STATUS, 0);
-               exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_TX_FEAC_CONFIGURATION_STATUS);
-               exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_STATUS, 0);
-               exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_STATUS);
-               break;
-       }
-}
-
-
-
-
-void exar7250_unipolar_onoff(struct channel *sc, u32 mode)
-{
-       switch (mode) {
-       case SBE_2T3E3_OFF:
-               exar7300_clear_bit(sc, SBE_2T3E3_FRAMER_REG_IO_CONTROL,
-                                  SBE_2T3E3_FRAMER_VAL_UNIPOLAR);
-               break;
-       case SBE_2T3E3_ON:
-               exar7300_set_bit(sc, SBE_2T3E3_FRAMER_REG_IO_CONTROL,
-                                SBE_2T3E3_FRAMER_VAL_UNIPOLAR);
-               break;
-       }
-}
-
-void exar7250_set_loopback(struct channel *sc, u32 mode)
-{
-       switch (mode) {
-       case SBE_2T3E3_FRAMER_VAL_LOOPBACK_OFF:
-               exar7300_clear_bit(sc, SBE_2T3E3_FRAMER_REG_OPERATING_MODE,
-                                  SBE_2T3E3_FRAMER_VAL_LOCAL_LOOPBACK_MODE);
-               break;
-       case SBE_2T3E3_FRAMER_VAL_LOOPBACK_ON:
-               exar7300_set_bit(sc, SBE_2T3E3_FRAMER_REG_OPERATING_MODE,
-                                SBE_2T3E3_FRAMER_VAL_LOCAL_LOOPBACK_MODE);
-               break;
-       }
-}
diff --git a/drivers/staging/sbe-2t3e3/exar7300.c b/drivers/staging/sbe-2t3e3/exar7300.c
deleted file mode 100644 (file)
index cd22999..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * SBE 2T3E3 synchronous serial card driver for Linux
- *
- * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- *
- * This code is based on a driver written by SBE Inc.
- */
-
-#include "2t3e3.h"
-#include "ctrl.h"
-
-void exar7300_init(struct channel *sc)
-{
-       exar7300_write(sc, SBE_2T3E3_LIU_REG_REG1, 0);
-
-       /* enable line decodeer and encoder */
-       exar7300_write(sc, SBE_2T3E3_LIU_REG_REG2, 0);
-       exar7300_write(sc, SBE_2T3E3_LIU_REG_REG3, 0);
-       exar7300_write(sc, SBE_2T3E3_LIU_REG_REG4,
-                      SBE_2T3E3_LIU_VAL_T3_MODE_SELECT |
-                      SBE_2T3E3_LIU_VAL_LOOPBACK_OFF);
-}
-
-void exar7300_set_loopback(struct channel *sc, u32 mode)
-{
-       u32 val;
-
-       switch (mode) {
-       case SBE_2T3E3_LIU_VAL_LOOPBACK_OFF:
-       case SBE_2T3E3_LIU_VAL_LOOPBACK_REMOTE:
-       case SBE_2T3E3_LIU_VAL_LOOPBACK_ANALOG:
-       case SBE_2T3E3_LIU_VAL_LOOPBACK_DIGITAL:
-               break;
-       default:
-               return;
-       }
-
-       val = exar7300_read(sc, SBE_2T3E3_LIU_REG_REG4);
-       val &= ~(SBE_2T3E3_LIU_VAL_LOCAL_LOOPBACK | SBE_2T3E3_LIU_VAL_REMOTE_LOOPBACK);
-       val |= mode;
-       exar7300_write(sc, SBE_2T3E3_LIU_REG_REG4, val);
-}
-
-void exar7300_set_frame_type(struct channel *sc, u32 type)
-{
-       u32 val;
-
-       switch (type) {
-       case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
-       case SBE_2T3E3_FRAME_TYPE_T3_M13:
-       case SBE_2T3E3_FRAME_TYPE_E3_G751:
-       case SBE_2T3E3_FRAME_TYPE_E3_G832:
-               break;
-       default:
-               return;
-       }
-
-       val = exar7300_read(sc, SBE_2T3E3_LIU_REG_REG4);
-       val &= ~(SBE_2T3E3_LIU_VAL_T3_MODE_SELECT |
-                SBE_2T3E3_LIU_VAL_E3_MODE_SELECT);
-
-       switch (type) {
-       case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
-       case SBE_2T3E3_FRAME_TYPE_T3_M13:
-               val |= SBE_2T3E3_LIU_VAL_T3_MODE_SELECT;
-               break;
-       case SBE_2T3E3_FRAME_TYPE_E3_G751:
-       case SBE_2T3E3_FRAME_TYPE_E3_G832:
-               val |= SBE_2T3E3_LIU_VAL_E3_MODE_SELECT;
-               break;
-       default:
-               return;
-       }
-
-       exar7300_write(sc, SBE_2T3E3_LIU_REG_REG4, val);
-}
-
-
-void exar7300_transmit_all_ones_onoff(struct channel *sc, u32 mode)
-{
-       if (sc->p.transmit_all_ones == mode)
-               return;
-
-       switch (mode) {
-       case SBE_2T3E3_ON:
-               exar7300_set_bit(sc, SBE_2T3E3_LIU_REG_REG1,
-                                SBE_2T3E3_LIU_VAL_TRANSMIT_ALL_ONES);
-               break;
-       case SBE_2T3E3_OFF:
-               exar7300_clear_bit(sc, SBE_2T3E3_LIU_REG_REG1,
-                                  SBE_2T3E3_LIU_VAL_TRANSMIT_ALL_ONES);
-               break;
-       default:
-               return;
-       }
-
-       sc->p.transmit_all_ones = mode;
-}
-
-void exar7300_receive_equalization_onoff(struct channel *sc, u32 mode)
-{
-       if (sc->p.receive_equalization == mode)
-               return;
-
-       switch (mode) {
-       case SBE_2T3E3_OFF:
-               exar7300_set_bit(sc, SBE_2T3E3_LIU_REG_REG2,
-                                SBE_2T3E3_LIU_VAL_RECEIVE_EQUALIZATION_DISABLE);
-               break;
-       case SBE_2T3E3_ON:
-               exar7300_clear_bit(sc, SBE_2T3E3_LIU_REG_REG2,
-                                  SBE_2T3E3_LIU_VAL_RECEIVE_EQUALIZATION_DISABLE);
-               break;
-       default:
-               return;
-       }
-
-       sc->p.receive_equalization = mode;
-}
-
-void exar7300_line_build_out_onoff(struct channel *sc, u32 mode)
-{
-       if (sc->p.line_build_out == mode)
-               return;
-
-       switch (mode) {
-       case SBE_2T3E3_OFF:
-               exar7300_set_bit(sc, SBE_2T3E3_LIU_REG_REG1,
-                                SBE_2T3E3_LIU_VAL_TRANSMIT_LEVEL_SELECT);
-               exar7300_receive_equalization_onoff(sc, SBE_2T3E3_OFF);
-               break;
-       case SBE_2T3E3_ON:
-               exar7300_clear_bit(sc, SBE_2T3E3_LIU_REG_REG1,
-                                  SBE_2T3E3_LIU_VAL_TRANSMIT_LEVEL_SELECT);
-               exar7300_receive_equalization_onoff(sc, SBE_2T3E3_ON);
-               break;
-       default:
-               return;
-       }
-
-       sc->p.line_build_out = mode;
-}
-
-/* TODO - what about encoder in raw mode??? disable it too? */
-void exar7300_unipolar_onoff(struct channel *sc, u32 mode)
-{
-       switch (mode) {
-       case SBE_2T3E3_OFF:
-               exar7300_clear_bit(sc, SBE_2T3E3_LIU_REG_REG3,
-                                  SBE_2T3E3_LIU_VAL_DECODER_DISABLE);
-               exar7300_clear_bit(sc, SBE_2T3E3_LIU_REG_REG1,
-                                  SBE_2T3E3_LIU_VAL_TRANSMIT_BINARY_DATA);
-               break;
-       case SBE_2T3E3_ON:
-               exar7300_set_bit(sc, SBE_2T3E3_LIU_REG_REG3,
-                                SBE_2T3E3_LIU_VAL_DECODER_DISABLE);
-               exar7300_set_bit(sc, SBE_2T3E3_LIU_REG_REG1,
-                                SBE_2T3E3_LIU_VAL_TRANSMIT_BINARY_DATA);
-               break;
-       }
-}
diff --git a/drivers/staging/sbe-2t3e3/intr.c b/drivers/staging/sbe-2t3e3/intr.c
deleted file mode 100644 (file)
index 1bf74b7..0000000
+++ /dev/null
@@ -1,579 +0,0 @@
-/*
- * SBE 2T3E3 synchronous serial card driver for Linux
- *
- * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- *
- * This code is based on a driver written by SBE Inc.
- */
-
-#include <linux/hdlc.h>
-#include <linux/interrupt.h>
-#include <linux/netdevice.h>
-#include "2t3e3.h"
-
-irqreturn_t t3e3_intr(int irq, void *dev_instance)
-{
-       struct channel *sc = dev_to_priv(dev_instance);
-       u32 val;
-       irqreturn_t ret = IRQ_NONE;
-
-       sc->interrupt_active = 1;
-
-       val = cpld_read(sc, SBE_2T3E3_CPLD_REG_PICSR);
-
-       if (val & SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_CHANGE) {
-               dev_dbg(&sc->pdev->dev,
-                       "Rx LOS Chng Int r=%02x (LOS|OOF=%02x)\n",
-                       val, (sc->s.LOS << 4) | sc->s.OOF);
-               cpld_LOS_update(sc);
-               ret = IRQ_HANDLED;
-       }
-
-       if (val & SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_ETHERNET_ASSERTED) {
-               dc_intr(sc);
-               ret = IRQ_HANDLED;
-       }
-
-       if (val & SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_FRAMER_ASSERTED) {
-               exar7250_intr(sc);
-               ret = IRQ_HANDLED;
-       }
-
-       /*
-         we don't care about other interrupt sources (DMO, LOS, LCV) because
-         they are handled by Framer too
-       */
-
-       sc->interrupt_active = 0;
-       return ret;
-}
-
-void dc_intr(struct channel *sc)
-{
-       u32 val;
-
-       /* disable ethernet interrupts */
-       /* grrr this clears interrupt summary bits !!! */
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_INTERRUPT_ENABLE, 0);
-
-       while ((val = dc_read(sc->addr, SBE_2T3E3_21143_REG_STATUS)) &
-              (SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STOPPED |
-               SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE |
-               SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT |
-               SBE_2T3E3_21143_VAL_TRANSMIT_UNDERFLOW |
-               SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE |
-               SBE_2T3E3_21143_VAL_TRANSMIT_PROCESS_STOPPED |
-               SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT)) {
-               dc_write(sc->addr, SBE_2T3E3_21143_REG_STATUS, val);
-
-               dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Ethernet controller interrupt! (CSR5 = %08X)\n",
-                       val);
-
-               if (val & (SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT |
-                          SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE |
-                          SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STOPPED)) {
-                       if (val & SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT)
-                               dev_dbg(&sc->pdev->dev,
-                                       "Receive interrupt (LOS=%d, OOF=%d)\n",
-                                       sc->s.LOS, sc->s.OOF);
-                       if (val & SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE)
-                               dev_dbg(&sc->pdev->dev,
-                                       "Receive buffer unavailable\n");
-                       if (val & SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STOPPED)
-                               dev_dbg(&sc->pdev->dev,
-                                       "Receive process stopped\n");
-                       dc_intr_rx(sc);
-               }
-
-               if (val & SBE_2T3E3_21143_VAL_TRANSMIT_UNDERFLOW) {
-                       dev_dbg(&sc->pdev->dev, "Transmit underflow\n");
-                       dc_intr_tx_underflow(sc);
-               }
-
-               if (val & (SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE |
-                          SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT |
-                          SBE_2T3E3_21143_VAL_TRANSMIT_PROCESS_STOPPED)) {
-                       if (val & SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT)
-                               dev_dbg(&sc->pdev->dev, "Transmit interrupt\n");
-                       if (val & SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE)
-                               dev_dbg(&sc->pdev->dev,
-                                       "Transmit buffer unavailable\n");
-                       if (val & SBE_2T3E3_21143_VAL_TRANSMIT_PROCESS_STOPPED)
-                               dev_dbg(&sc->pdev->dev,
-                                       "Transmit process stopped\n");
-                       dc_intr_tx(sc);
-               }
-       }
-
-       /* enable ethernet interrupts */
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_INTERRUPT_ENABLE,
-                sc->ether.interrupt_enable_mask);
-}
-
-void dc_intr_rx(struct channel *sc)
-{
-       u32 current_read;
-       u32 error_mask, error;
-       struct t3e3_rx_desc *current_desc;
-       struct sk_buff *m, *m2;
-       unsigned rcv_len;
-
-       sc->rcv_count++; /* for the activity LED */
-
-       current_read = sc->ether.rx_ring_current_read;
-       dev_dbg(&sc->pdev->dev, "intr_rx current_read = %d\n", current_read);
-
-       /* when ethernet loopback is set, ignore framer signals */
-       if ((sc->p.loopback != SBE_2T3E3_LOOPBACK_ETHERNET) && sc->s.OOF) {
-               while (!(sc->ether.rx_ring[current_read].rdes0 &
-                        SBE_2T3E3_RX_DESC_21143_OWN)) {
-                       current_desc = &sc->ether.rx_ring[current_read];
-                       current_desc->rdes1 &= SBE_2T3E3_RX_DESC_END_OF_RING |
-                               SBE_2T3E3_RX_DESC_SECOND_ADDRESS_CHAINED;
-                       current_desc->rdes1 |= SBE_2T3E3_MTU;
-                       current_desc->rdes0 = SBE_2T3E3_RX_DESC_21143_OWN;
-                       current_read = (current_read + 1) % SBE_2T3E3_RX_DESC_RING_SIZE;
-               }
-               sc->ether.rx_ring_current_read = current_read;
-               return;
-       }
-
-       while (!(sc->ether.rx_ring[current_read].rdes0 &
-                SBE_2T3E3_RX_DESC_21143_OWN)) {
-               current_desc = &sc->ether.rx_ring[current_read];
-
-               dev_dbg(&sc->pdev->dev, "rdes0: %08X        rdes1: %08X\n",
-                       current_desc->rdes0, current_desc->rdes1);
-
-               m = sc->ether.rx_data[current_read];
-               rcv_len = (current_desc->rdes0 & SBE_2T3E3_RX_DESC_FRAME_LENGTH) >>
-                       SBE_2T3E3_RX_DESC_FRAME_LENGTH_SHIFT;
-
-               dev_dbg(&sc->pdev->dev, "mbuf was received (mbuf len = %d)\n",
-                       rcv_len);
-
-               switch (sc->p.crc) {
-               case SBE_2T3E3_CRC_16:
-                       rcv_len -= SBE_2T3E3_CRC16_LENGTH;
-                       break;
-               case SBE_2T3E3_CRC_32:
-                       rcv_len -= SBE_2T3E3_CRC32_LENGTH;
-                       break;
-               default:
-                       break;
-               }
-
-               if (current_desc->rdes0 & SBE_2T3E3_RX_DESC_LAST_DESC) {
-
-                       /* TODO: is collision possible? */
-                       error_mask = SBE_2T3E3_RX_DESC_DESC_ERROR |
-                               SBE_2T3E3_RX_DESC_COLLISION_SEEN |
-                               SBE_2T3E3_RX_DESC_DRIBBLING_BIT;
-
-                       switch (sc->p.frame_mode) {
-                       case SBE_2T3E3_FRAME_MODE_HDLC:
-                               error_mask |= SBE_2T3E3_RX_DESC_MII_ERROR;
-                               if (sc->p.crc == SBE_2T3E3_CRC_32)
-                                       error_mask |= SBE_2T3E3_RX_DESC_CRC_ERROR;
-                               break;
-                       case SBE_2T3E3_FRAME_MODE_TRANSPARENT:
-                       case SBE_2T3E3_FRAME_MODE_RAW:
-                               break;
-                       default:
-                               error_mask = 0;
-                       }
-
-                       if (sc->s.LOS) {
-                               error_mask &= ~(SBE_2T3E3_RX_DESC_DRIBBLING_BIT |
-                                               SBE_2T3E3_RX_DESC_MII_ERROR);
-                       }
-
-                       error = current_desc->rdes0 & error_mask;
-                       if (error) {
-                               sc->s.in_errors++;
-                               dev_dbg(&sc->pdev->dev,
-                                       "error interrupt: NO_ERROR_MESSAGE = %d\n",
-                                       sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES ? 1 : 0);
-
-                               current_desc->rdes1 &= SBE_2T3E3_RX_DESC_END_OF_RING |
-                                       SBE_2T3E3_RX_DESC_SECOND_ADDRESS_CHAINED;
-                               current_desc->rdes1 |= SBE_2T3E3_MTU;
-                               current_desc->rdes0 = SBE_2T3E3_RX_DESC_21143_OWN;
-
-                               if (error & SBE_2T3E3_RX_DESC_DESC_ERROR) {
-                                       if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES))
-                                               dev_err(&sc->pdev->dev,
-                                                       "SBE 2T3E3: descriptor error\n");
-                                       sc->s.in_error_desc++;
-                               }
-
-                               if (error & SBE_2T3E3_RX_DESC_COLLISION_SEEN) {
-                                       if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES))
-                                               dev_err(&sc->pdev->dev,
-                                                       "SBE 2T3E3: collision seen\n");
-                                       sc->s.in_error_coll++;
-                               } else {
-                                       if (error & SBE_2T3E3_RX_DESC_DRIBBLING_BIT) {
-                                               if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES))
-                                                       dev_err(&sc->pdev->dev,
-                                                               "SBE 2T3E3: dribbling bits error\n");
-                                               sc->s.in_error_drib++;
-                                       }
-
-                                       if (error & SBE_2T3E3_RX_DESC_CRC_ERROR) {
-                                               if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES))
-                                                       dev_err(&sc->pdev->dev,
-                                                               "SBE 2T3E3: crc error\n");
-                                               sc->s.in_error_crc++;
-                                       }
-                               }
-
-                               if (error & SBE_2T3E3_RX_DESC_MII_ERROR) {
-                                       if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES))
-                                               dev_err(&sc->pdev->dev, "SBE 2T3E3: mii error\n");
-                                       sc->s.in_error_mii++;
-                               }
-
-                               current_read = (current_read + 1) % SBE_2T3E3_RX_DESC_RING_SIZE;
-                               sc->r.flags |= SBE_2T3E3_FLAG_NO_ERROR_MESSAGES;
-                               continue;
-                       }
-               }
-
-               current_desc->rdes1 &= SBE_2T3E3_RX_DESC_END_OF_RING |
-                       SBE_2T3E3_RX_DESC_SECOND_ADDRESS_CHAINED;
-               current_desc->rdes1 |= SBE_2T3E3_MTU;
-
-               if (rcv_len > 1600) {
-                       sc->s.in_errors++;
-                       sc->s.in_dropped++;
-                       if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES))
-                               dev_err(&sc->pdev->dev, "SBE 2T3E3: oversized rx: rdes0 = %08X\n",
-                                       current_desc->rdes0);
-               } else {
-                       m2 = dev_alloc_skb(MCLBYTES);
-                       if (m2 != NULL) {
-                               current_desc->rdes2 = virt_to_phys(m2->data);
-                               sc->ether.rx_data[current_read] = m2;
-                               sc->s.in_packets++;
-                               sc->s.in_bytes += rcv_len;
-                               m->dev = sc->dev;
-                               skb_put(m, rcv_len);
-                               skb_reset_mac_header(m);
-                               m->protocol = hdlc_type_trans(m, m->dev);
-                               netif_rx(m);
-
-                               /* good packet was received so we will show error messages again... */
-                               if (sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES) {
-                                       dev_dbg(&sc->pdev->dev,
-                                               "setting ERROR_MESSAGES->0\n");
-                                       sc->r.flags &= ~SBE_2T3E3_FLAG_NO_ERROR_MESSAGES;
-                               }
-
-                       } else {
-                               sc->s.in_errors++;
-                               sc->s.in_dropped++;
-                       }
-               }
-               current_desc->rdes0 = SBE_2T3E3_RX_DESC_21143_OWN;
-               current_read = (current_read + 1) % SBE_2T3E3_RX_DESC_RING_SIZE;
-       }
-
-       sc->ether.rx_ring_current_read = current_read;
-
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_RECEIVE_POLL_DEMAND, 0xFFFFFFFF);
-}
-
-void dc_intr_tx(struct channel *sc)
-{
-       u32 current_read, current_write;
-       u32 last_segment, error;
-       struct t3e3_tx_desc *current_desc;
-
-       spin_lock(&sc->ether.tx_lock);
-
-       current_read = sc->ether.tx_ring_current_read;
-       current_write = sc->ether.tx_ring_current_write;
-
-       while (current_read != current_write) {
-               current_desc = &sc->ether.tx_ring[current_read];
-
-               if (current_desc->tdes0 & SBE_2T3E3_RX_DESC_21143_OWN)
-                       break;
-
-               dev_dbg(&sc->pdev->dev,
-                       "txeof: tdes0 = %08X        tdes1 = %08X\n",
-                       current_desc->tdes0, current_desc->tdes1);
-
-               error = current_desc->tdes0 & (SBE_2T3E3_TX_DESC_ERROR_SUMMARY |
-                                              SBE_2T3E3_TX_DESC_TRANSMIT_JABBER_TIMEOUT |
-                                              SBE_2T3E3_TX_DESC_LOSS_OF_CARRIER |
-                                              SBE_2T3E3_TX_DESC_NO_CARRIER |
-                                              SBE_2T3E3_TX_DESC_LINK_FAIL_REPORT |
-                                              SBE_2T3E3_TX_DESC_UNDERFLOW_ERROR |
-                                              SBE_2T3E3_TX_DESC_DEFFERED);
-
-               last_segment = current_desc->tdes1 & SBE_2T3E3_TX_DESC_LAST_SEGMENT;
-
-               current_desc->tdes0 = 0;
-               current_desc->tdes1 &= SBE_2T3E3_TX_DESC_END_OF_RING |
-                       SBE_2T3E3_TX_DESC_SECOND_ADDRESS_CHAINED;
-               current_desc->tdes2 = 0;
-               sc->ether.tx_free_cnt++;
-
-               if (last_segment != SBE_2T3E3_TX_DESC_LAST_SEGMENT) {
-                       current_read = (current_read + 1) % SBE_2T3E3_TX_DESC_RING_SIZE;
-                       continue;
-               }
-
-
-               if (sc->ether.tx_data[current_read]) {
-                       sc->s.out_packets++;
-                       sc->s.out_bytes += sc->ether.tx_data[current_read]->len;
-                       dev_kfree_skb_any(sc->ether.tx_data[current_read]);
-                       sc->ether.tx_data[current_read] = NULL;
-               }
-
-               if (error > 0) {
-                       sc->s.out_errors++;
-
-                       if (error & SBE_2T3E3_TX_DESC_TRANSMIT_JABBER_TIMEOUT) {
-                               dev_err(&sc->pdev->dev, "SBE 2T3E3: transmit jabber timeout\n");
-                               sc->s.out_error_jab++;
-                       }
-
-                       if (sc->p.loopback != SBE_2T3E3_LOOPBACK_ETHERNET) {
-                               if (error & SBE_2T3E3_TX_DESC_LOSS_OF_CARRIER) {
-                                       dev_err(&sc->pdev->dev, "SBE 2T3E3: loss of carrier\n");
-                                       sc->s.out_error_lost_carr++;
-                               }
-
-                               if (error & SBE_2T3E3_TX_DESC_NO_CARRIER) {
-                                       dev_err(&sc->pdev->dev, "SBE 2T3E3: no carrier\n");
-                                       sc->s.out_error_no_carr++;
-                               }
-                       }
-
-                       if (error & SBE_2T3E3_TX_DESC_LINK_FAIL_REPORT) {
-                               dev_err(&sc->pdev->dev, "SBE 2T3E3: link fail report\n");
-                               sc->s.out_error_link_fail++;
-                       }
-
-                       if (error & SBE_2T3E3_TX_DESC_UNDERFLOW_ERROR) {
-                               dev_err(&sc->pdev->dev, "SBE 2T3E3:"
-                                       " transmission underflow error\n");
-                               sc->s.out_error_underflow++;
-                               spin_unlock(&sc->ether.tx_lock);
-
-                               dc_restart(sc);
-                               return;
-                       }
-
-                       if (error & SBE_2T3E3_TX_DESC_DEFFERED) {
-                               dev_err(&sc->pdev->dev, "SBE 2T3E3: transmission deferred\n");
-                               sc->s.out_error_dereferred++;
-                       }
-               }
-
-               current_read = (current_read + 1) % SBE_2T3E3_TX_DESC_RING_SIZE;
-       }
-
-       sc->ether.tx_ring_current_read = current_read;
-
-       /* Relieve flow control when the TX queue is drained at least half way */
-       if (sc->ether.tx_full &&
-           (sc->ether.tx_free_cnt >= (SBE_2T3E3_TX_DESC_RING_SIZE / 2))) {
-               sc->ether.tx_full = 0;
-               netif_wake_queue(sc->dev);
-       }
-       spin_unlock(&sc->ether.tx_lock);
-}
-
-
-void dc_intr_tx_underflow(struct channel *sc)
-{
-       u32 val;
-
-       dc_transmitter_onoff(sc, SBE_2T3E3_OFF);
-
-       val = dc_read(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE);
-       dc_clear_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
-                     SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS);
-
-       switch (val & SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS) {
-       case SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_1:
-               dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
-                           SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_2);
-               break;
-       case SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_2:
-               dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
-                           SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_3);
-               break;
-       case SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_3:
-               dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
-                           SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_4);
-               break;
-       case SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_4:
-       default:
-               dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
-                           SBE_2T3E3_21143_VAL_STORE_AND_FORWARD);
-               break;
-       }
-
-       dc_transmitter_onoff(sc, SBE_2T3E3_ON);
-}
-
-
-
-
-void exar7250_intr(struct channel *sc)
-{
-       u32 status, old_OOF;
-
-       old_OOF = sc->s.OOF;
-
-       status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_STATUS);
-       dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Framer interrupt! (REG[0x05] = %02X)\n", status);
-
-       switch (sc->p.frame_type) {
-       case SBE_2T3E3_FRAME_TYPE_E3_G751:
-       case SBE_2T3E3_FRAME_TYPE_E3_G832:
-               exar7250_E3_intr(sc, status);
-               break;
-
-       case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
-       case SBE_2T3E3_FRAME_TYPE_T3_M13:
-               exar7250_T3_intr(sc, status);
-               break;
-
-       default:
-               break;
-       }
-
-       if (sc->s.OOF != old_OOF) {
-               if (sc->s.OOF) {
-                       if (sc->p.loopback == SBE_2T3E3_LOOPBACK_NONE) {
-                               dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Disabling eth interrupts\n");
-                               /* turn off ethernet interrupts */
-                               dc_stop_intr(sc);
-                       }
-               } else if (sc->r.flags & SBE_2T3E3_FLAG_NETWORK_UP) {
-                       dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Enabling eth interrupts\n");
-                       /* start interrupts */
-                       sc->s.OOF = 1;
-                       dc_intr_rx(sc);
-                       sc->s.OOF = 0;
-                       if (sc->p.receiver_on) {
-                               dc_receiver_onoff(sc, SBE_2T3E3_OFF);
-                               dc_receiver_onoff(sc, SBE_2T3E3_ON);
-                       }
-                       dc_start_intr(sc);
-               }
-       }
-}
-
-
-void exar7250_T3_intr(struct channel *sc, u32 block_status)
-{
-       u32 status, result;
-
-       if (block_status & SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_STATUS) {
-               status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_STATUS);
-
-               if (status) {
-                       dev_dbg(&sc->pdev->dev,
-                               "Framer interrupt T3 RX (REG[0x13] = %02X)\n",
-                               status);
-
-                       result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS);
-
-                       cpld_LOS_update(sc);
-
-                       if (status & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_STATUS) {
-                               sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0;
-                               dev_dbg(&sc->pdev->dev,
-                                       "Framer interrupt T3: OOF (%d)\n",
-                                       sc->s.OOF);
-                       }
-
-                       exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE,
-                                      SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE |
-                                      SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE);
-                               }
-
-               status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS);
-               if (status) {
-                       dev_dbg(&sc->pdev->dev,
-                               "Framer interrupt T3 RX (REG[0x17] = %02X)\n",
-                               status);
-               }
-
-               status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL);
-               if (status)
-                       dev_dbg(&sc->pdev->dev,
-                               "Framer interrupt T3 RX (REG[0x18] = %02X)\n",
-                               status);
-       }
-
-
-       if (block_status & SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_STATUS) {
-               status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_TX_FEAC_CONFIGURATION_STATUS);
-               dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Framer interrupt T3 TX (REG[0x31] = %02X)\n",
-                       status);
-
-               status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_STATUS);
-               dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Framer interrupt T3 TX (REG[0x34] = %02X)\n",
-                       status);
-       }
-}
-
-
-void exar7250_E3_intr(struct channel *sc, u32 block_status)
-{
-       u32 status, result;
-
-       if (block_status & SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_STATUS) {
-               status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_1);
-
-               if (status) {
-                       dev_dbg(&sc->pdev->dev,
-                               "Framer interrupt E3 RX (REG[0x14] = %02X)\n",
-                               status);
-
-                       result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2);
-
-                       cpld_LOS_update(sc);
-
-                       if (status & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_STATUS) {
-                               sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0;
-                               dev_dbg(&sc->pdev->dev,
-                                       "Framer interrupt E3: OOF (%d)\n",
-                                       sc->s.OOF);
-                       }
-
-                       exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_1,
-                                      SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE |
-                                      SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE
-                               );
-                               }
-
-               status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2);
-               if (status) {
-                       dev_dbg(&sc->pdev->dev,
-                               "Framer interrupt E3 RX (REG[0x15] = %02X)\n",
-                               status);
-
-               }
-
-       }
-
-       if (block_status & SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_STATUS) {
-               status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_STATUS);
-               dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Framer interrupt E3 TX (REG[0x34] = %02X)\n",
-                       status);
-       }
-}
diff --git a/drivers/staging/sbe-2t3e3/io.c b/drivers/staging/sbe-2t3e3/io.c
deleted file mode 100644 (file)
index c9947b1..0000000
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * SBE 2T3E3 synchronous serial card driver for Linux
- *
- * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- *
- * This code is based on a driver written by SBE Inc.
- */
-
-#include <linux/ip.h>
-#include "2t3e3.h"
-#include "ctrl.h"
-
-/* All access to registers done via the 21143 on port 0 must be
- * protected via the card->bootrom_lock. */
-
-/* private define to be used here only - must be protected by card->bootrom_lock */
-#define cpld_write_nolock(channel, reg, val)                   \
-       bootrom_write((channel), CPLD_MAP_REG(reg, channel), val)
-
-u32 cpld_read(struct channel *channel, u32 reg)
-{
-       unsigned long flags;
-       u32 val;
-
-       spin_lock_irqsave(&channel->card->bootrom_lock, flags);
-       val = bootrom_read((channel), CPLD_MAP_REG(reg, channel));
-       spin_unlock_irqrestore(&channel->card->bootrom_lock, flags);
-       return val;
-}
-
-/****************************************
- * Access via BootROM port
- ****************************************/
-
-u32 bootrom_read(struct channel *channel, u32 reg)
-{
-       unsigned long addr = channel->card->bootrom_addr;
-       u32 result;
-
-       /* select BootROM address */
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_PROGRAMMING_ADDRESS, reg & 0x3FFFF);
-
-       /* select reading from BootROM */
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
-                SBE_2T3E3_21143_VAL_READ_OPERATION |
-                SBE_2T3E3_21143_VAL_BOOT_ROM_SELECT);
-
-       udelay(2); /* 20 PCI cycles */
-
-       /* read from BootROM */
-       result = dc_read(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT) & 0xff;
-
-       /* reset CSR9 */
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, 0);
-
-       return result;
-}
-
-void bootrom_write(struct channel *channel, u32 reg, u32 val)
-{
-       unsigned long addr = channel->card->bootrom_addr;
-
-       /* select BootROM address */
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_PROGRAMMING_ADDRESS, reg & 0x3FFFF);
-
-       /* select writting to BootROM */
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
-                SBE_2T3E3_21143_VAL_WRITE_OPERATION |
-                SBE_2T3E3_21143_VAL_BOOT_ROM_SELECT |
-                (val & 0xff));
-
-       udelay(2); /* 20 PCI cycles */
-
-       /* reset CSR9 */
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, 0);
-}
-
-
-/****************************************
- * Access via Serial I/O port
- ****************************************/
-
-static u32 serialrom_read_bit(struct channel *channel)
-{
-       unsigned long addr = channel->card->bootrom_addr;
-       u32 bit;
-
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
-                SBE_2T3E3_21143_VAL_READ_OPERATION |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_CLOCK |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT);   /* clock high */
-
-       bit = (dc_read(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT) &
-              SBE_2T3E3_21143_VAL_SERIAL_ROM_DATA_OUT) > 0 ? 1 : 0;
-
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
-                SBE_2T3E3_21143_VAL_READ_OPERATION |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT);   /* clock low */
-
-       return bit;
-}
-
-static void serialrom_write_bit(struct channel *channel, u32 bit)
-{
-       unsigned long addr = channel->card->bootrom_addr;
-       u32 lastbit = -1;
-
-       bit &= 1;
-
-       if (bit != lastbit) {
-               dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
-                        SBE_2T3E3_21143_VAL_WRITE_OPERATION |
-                        SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
-                        SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT |
-                        (bit << 2)); /* clock low */
-
-               lastbit = bit;
-       }
-
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
-                SBE_2T3E3_21143_VAL_WRITE_OPERATION |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_CLOCK |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT |
-                (bit << 2)); /* clock high */
-
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
-                SBE_2T3E3_21143_VAL_WRITE_OPERATION |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT |
-                (bit << 2)); /* clock low */
-}
-
-/****************************************
- * Access to SerialROM (eeprom)
- ****************************************/
-
-u32 t3e3_eeprom_read_word(struct channel *channel, u32 address)
-{
-       unsigned long addr = channel->card->bootrom_addr;
-       u32 i, val;
-       unsigned long flags;
-
-       address &= 0x3f;
-
-       spin_lock_irqsave(&channel->card->bootrom_lock, flags);
-
-       /* select correct Serial Chip */
-       cpld_write_nolock(channel, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT,
-                         SBE_2T3E3_CPLD_VAL_EEPROM_SELECT);
-
-       /* select reading from Serial I/O Bus */
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
-                SBE_2T3E3_21143_VAL_READ_OPERATION |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT);        /* clock low */
-
-       /* select read operation */
-       serialrom_write_bit(channel, 0);
-       serialrom_write_bit(channel, 1);
-       serialrom_write_bit(channel, 1);
-       serialrom_write_bit(channel, 0);
-
-       for (i = 0x20; i; i >>= 1)
-               serialrom_write_bit(channel, address & i ? 1 : 0);
-
-       val = 0;
-       for (i = 0x8000; i; i >>= 1)
-               val |= (serialrom_read_bit(channel) ? i : 0);
-
-       /* Reset 21143's CSR9 */
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
-                SBE_2T3E3_21143_VAL_READ_OPERATION |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT);        /* clock low */
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, 0);
-
-       /* Unselect Serial Chip */
-       cpld_write_nolock(channel, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT, 0);
-
-       spin_unlock_irqrestore(&channel->card->bootrom_lock, flags);
-
-       return ntohs(val);
-}
-
-
-/****************************************
- * Access to Framer
- ****************************************/
-
-u32 exar7250_read(struct channel *channel, u32 reg)
-{
-       u32 result;
-       unsigned long flags;
-
-       spin_lock_irqsave(&channel->card->bootrom_lock, flags);
-
-       result = bootrom_read(channel, cpld_reg_map[SBE_2T3E3_CPLD_REG_FRAMER_BASE_ADDRESS]
-                             [channel->h.slot] + (t3e3_framer_reg_map[reg] << 2));
-
-       spin_unlock_irqrestore(&channel->card->bootrom_lock, flags);
-
-       return result;
-}
-
-void exar7250_write(struct channel *channel, u32 reg, u32 val)
-{
-       unsigned long flags;
-
-       val &= 0xff;
-       channel->framer_regs[reg] = val;
-
-       spin_lock_irqsave(&channel->card->bootrom_lock, flags);
-
-       bootrom_write(channel, cpld_reg_map[SBE_2T3E3_CPLD_REG_FRAMER_BASE_ADDRESS]
-                     [channel->h.slot] + (t3e3_framer_reg_map[reg] << 2), val);
-
-       spin_unlock_irqrestore(&channel->card->bootrom_lock, flags);
-}
-
-
-/****************************************
- * Access to LIU
- ****************************************/
-
-u32 exar7300_read(struct channel *channel, u32 reg)
-{
-       unsigned long addr = channel->card->bootrom_addr, flags;
-       u32 i, val;
-
-       /* select correct Serial Chip */
-
-       spin_lock_irqsave(&channel->card->bootrom_lock, flags);
-
-       cpld_write_nolock(channel, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT,
-                         cpld_val_map[SBE_2T3E3_CPLD_VAL_LIU_SELECT][channel->h.slot]);
-
-       /* select reading from Serial I/O Bus */
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
-                SBE_2T3E3_21143_VAL_READ_OPERATION |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT);   /* clock low */
-
-       /* select read operation */
-       serialrom_write_bit(channel, 1);
-
-       /* Exar7300 register address is 4 bit long */
-       reg = t3e3_liu_reg_map[reg];
-       for (i = 0; i < 4; i++, reg >>= 1) /* 4 bits of SerialROM address */
-               serialrom_write_bit(channel, reg & 1);
-       for (i = 0; i < 3; i++) /* remaining 3 bits of SerialROM address */
-               serialrom_write_bit(channel, 0);
-
-       val = 0; /* Exar7300 register value is 5 bit long */
-       for (i = 0; i < 8; i++) /* 8 bits of SerialROM value */
-               val += (serialrom_read_bit(channel) << i);
-
-       /* Reset 21143's CSR9 */
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
-                SBE_2T3E3_21143_VAL_READ_OPERATION |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT);   /* clock low */
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, 0);
-
-       /* Unselect Serial Chip */
-       cpld_write_nolock(channel, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT, 0);
-
-       spin_unlock_irqrestore(&channel->card->bootrom_lock, flags);
-
-       return val;
-}
-
-void exar7300_write(struct channel *channel, u32 reg, u32 val)
-{
-       unsigned long addr = channel->card->bootrom_addr, flags;
-       u32 i;
-
-       channel->liu_regs[reg] = val;
-
-       /* select correct Serial Chip */
-
-       spin_lock_irqsave(&channel->card->bootrom_lock, flags);
-
-       cpld_write_nolock(channel, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT,
-                         cpld_val_map[SBE_2T3E3_CPLD_VAL_LIU_SELECT][channel->h.slot]);
-
-       /* select writting to Serial I/O Bus */
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
-                SBE_2T3E3_21143_VAL_WRITE_OPERATION |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT);   /* clock low */
-
-       /* select write operation */
-       serialrom_write_bit(channel, 0);
-
-       /* Exar7300 register address is 4 bit long */
-       reg = t3e3_liu_reg_map[reg];
-       for (i = 0; i < 4; i++) {       /* 4 bits */
-               serialrom_write_bit(channel, reg & 1);
-               reg >>= 1;
-       }
-       for (i = 0; i < 3; i++) /* remaining 3 bits of SerialROM address */
-               serialrom_write_bit(channel, 0);
-
-       /* Exar7300 register value is 5 bit long */
-       for (i = 0; i < 5; i++) {
-               serialrom_write_bit(channel, val & 1);
-               val >>= 1;
-       }
-       for (i = 0; i < 3; i++) /* remaining 3 bits of SerialROM value */
-               serialrom_write_bit(channel, 0);
-
-       /* Reset 21143_CSR9 */
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
-                SBE_2T3E3_21143_VAL_WRITE_OPERATION |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
-                SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT);   /* clock low */
-       dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, 0);
-
-       /* Unselect Serial Chip */
-       cpld_write_nolock(channel, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT, 0);
-
-       spin_unlock_irqrestore(&channel->card->bootrom_lock, flags);
-}
diff --git a/drivers/staging/sbe-2t3e3/main.c b/drivers/staging/sbe-2t3e3/main.c
deleted file mode 100644 (file)
index c8e0398..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * SBE 2T3E3 synchronous serial card driver for Linux
- *
- * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- *
- * This code is based on a driver written by SBE Inc.
- */
-
-#include <linux/interrupt.h>
-#include <linux/netdevice.h>
-#include "2t3e3.h"
-
-void t3e3_init(struct channel *sc)
-{
-       cpld_init(sc);
-       dc_reset(sc);
-       dc_init(sc);
-       exar7250_init(sc);
-       exar7300_init(sc);
-}
-
-int t3e3_if_start_xmit(struct sk_buff *skb, struct net_device *dev)
-{
-       struct channel *sc = dev_to_priv(dev);
-       u32 current_write, last_write;
-       unsigned long flags;
-       struct sk_buff *skb2;
-
-       if (skb == NULL) {
-               sc->s.out_errors++;
-               return 0;
-       }
-
-       if (sc->p.transmitter_on != SBE_2T3E3_ON) {
-               sc->s.out_errors++;
-               sc->s.out_dropped++;
-               dev_kfree_skb_any(skb);
-               return 0;
-       }
-
-       if (sc->s.OOF && sc->p.loopback == SBE_2T3E3_LOOPBACK_NONE) {
-               sc->s.out_dropped++;
-               dev_kfree_skb_any(skb);
-               return 0;
-       }
-
-       spin_lock_irqsave(&sc->ether.tx_lock, flags);
-
-       current_write = sc->ether.tx_ring_current_write;
-       for (skb2 = skb; skb2 != NULL; skb2 = NULL) {
-               if (skb2->len) {
-                       if ((sc->ether.tx_ring[current_write].tdes1 &
-                            SBE_2T3E3_TX_DESC_BUFFER_1_SIZE) > 0)
-                               break;
-                       current_write = (current_write + 1) % SBE_2T3E3_TX_DESC_RING_SIZE;
-                       /*
-                        * Leave at least 1 tx desc free so that dc_intr_tx() can
-                        * identify empty list
-                        */
-                       if (current_write == sc->ether.tx_ring_current_read)
-                               break;
-               }
-       }
-       if (skb2 != NULL) {
-               netif_stop_queue(sc->dev);
-               sc->ether.tx_full = 1;
-               dev_dbg(&sc->pdev->dev, "SBE 2T3E3: out of descriptors\n");
-               spin_unlock_irqrestore(&sc->ether.tx_lock, flags);
-               return NETDEV_TX_BUSY;
-       }
-
-       current_write = last_write = sc->ether.tx_ring_current_write;
-       dev_dbg(&sc->pdev->dev, "sending mbuf (current_write = %d)\n",
-               current_write);
-
-       for (skb2 = skb; skb2 != NULL; skb2 = NULL) {
-               if (skb2->len) {
-                       dev_dbg(&sc->pdev->dev,
-                               "sending mbuf (len = %d, next = %p)\n",
-                               skb2->len, NULL);
-
-                       sc->ether.tx_free_cnt--;
-                       sc->ether.tx_ring[current_write].tdes0 = 0;
-                       sc->ether.tx_ring[current_write].tdes1 &=
-                               SBE_2T3E3_TX_DESC_END_OF_RING |
-                               SBE_2T3E3_TX_DESC_SECOND_ADDRESS_CHAINED;
-/* DISABLE_PADDING sometimes gets lost somehow, hands off... */
-                       sc->ether.tx_ring[current_write].tdes1 |=
-                               SBE_2T3E3_TX_DESC_DISABLE_PADDING | skb2->len;
-
-                       if (current_write == sc->ether.tx_ring_current_write) {
-                               sc->ether.tx_ring[current_write].tdes1 |=
-                                       SBE_2T3E3_TX_DESC_FIRST_SEGMENT;
-                       } else {
-                               sc->ether.tx_ring[current_write].tdes0 =
-                                       SBE_2T3E3_TX_DESC_21143_OWN;
-                       }
-
-                       sc->ether.tx_ring[current_write].tdes2 = virt_to_phys(skb2->data);
-                       sc->ether.tx_data[current_write] = NULL;
-
-                       last_write = current_write;
-                       current_write = (current_write + 1) % SBE_2T3E3_TX_DESC_RING_SIZE;
-               }
-       }
-
-       sc->ether.tx_data[last_write] = skb;
-       sc->ether.tx_ring[last_write].tdes1 |=
-               SBE_2T3E3_TX_DESC_LAST_SEGMENT |
-               SBE_2T3E3_TX_DESC_INTERRUPT_ON_COMPLETION;
-       sc->ether.tx_ring[sc->ether.tx_ring_current_write].tdes0 |=
-               SBE_2T3E3_TX_DESC_21143_OWN;
-       sc->ether.tx_ring_current_write = current_write;
-
-       dev_dbg(&sc->pdev->dev, "txput: tdes0 = %08X        tdes1 = %08X\n",
-               sc->ether.tx_ring[last_write].tdes0,
-               sc->ether.tx_ring[last_write].tdes1);
-
-       dc_write(sc->addr, SBE_2T3E3_21143_REG_TRANSMIT_POLL_DEMAND,
-                0xffffffff);
-
-       spin_unlock_irqrestore(&sc->ether.tx_lock, flags);
-       return 0;
-}
-
-
-void t3e3_read_card_serial_number(struct channel *sc)
-{
-       u32 i;
-
-       for (i = 0; i < 3; i++)
-               sc->ether.card_serial_number[i] = t3e3_eeprom_read_word(sc, 10 + i);
-
-       netdev_info(sc->dev, "SBE wanPMC-2T3E3 serial number: %04X%04X%04X\n",
-                   sc->ether.card_serial_number[0],
-                   sc->ether.card_serial_number[1],
-                   sc->ether.card_serial_number[2]);
-}
-
-/*
-  bit 0 led1 (green)
-  bit 1 led1 (yellow)
-
-  bit 2 led2 (green)
-  bit 3 led2 (yellow)
-
-  bit 4 led3 (green)
-  bit 5 led3 (yellow)
-
-  bit 6 led4 (green)
-  bit 7 led4 (yellow)
-*/
-
-void update_led(struct channel *sc, int blinker)
-{
-       int leds;
-       if (sc->s.LOS)
-               leds = 0; /* led1 = off */
-       else if (sc->s.OOF)
-               leds = 2; /* led1 = yellow */
-       else if ((blinker & 1) && sc->rcv_count) {
-               leds = 0; /* led1 = off */
-               sc->rcv_count = 0;
-       } else
-               leds = 1; /* led1 = green */
-       cpld_write(sc, SBE_2T3E3_CPLD_REG_LEDR, leds);
-       sc->leds = leds;
-}
diff --git a/drivers/staging/sbe-2t3e3/maps.c b/drivers/staging/sbe-2t3e3/maps.c
deleted file mode 100644 (file)
index e549450..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * SBE 2T3E3 synchronous serial card driver for Linux
- *
- * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- *
- * This code is based on a driver written by SBE Inc.
- */
-
-#include <linux/kernel.h>
-#include "2t3e3.h"
-
-const u32 cpld_reg_map[][2] = {
-       { 0x0000, 0x0080 }, /* 0 - Port Control Register A (PCRA) */
-       { 0x0004, 0x0084 }, /* 1 - Port Control Register B (PCRB) */
-       { 0x0008, 0x0088 }, /* 2 - LCV Count Register (PLCR) */
-       { 0x000c, 0x008c }, /* 3 - LCV Threshold register (PLTR) */
-       { 0x0010, 0x0090 }, /* 4 - Payload Fill Register (PPFR) */
-       { 0x0200, 0x0200 }, /* 5 - Board ID / FPGA Programming Status Register */
-       { 0x0204, 0x0204 }, /* 6 - FPGA Version Register */
-       { 0x0800, 0x1000 }, /* 7 - Framer Registers Base Address */
-       { 0x2000, 0x2000 }, /* 8 - Serial Chip Select Register */
-       { 0x2004, 0x2004 }, /* 9 - Static Reset Register */
-       { 0x2008, 0x2008 }, /* 10 - Pulse Reset Register */
-       { 0x200c, 0x200c }, /* 11 - FPGA Reconfiguration Register */
-       { 0x2010, 0x2014 }, /* 12 - LED Register (LEDR) */
-       { 0x2018, 0x201c }, /* 13 - LIU Control and Status Register (PISCR) */
-       { 0x2020, 0x2024 }, /* 14 - Interrupt Enable Register (PIER) */
-       { 0x0068, 0x00e8 }, /* 15 - Port Control Register C (PCRC) */
-       { 0x006c, 0x00ec }, /* 16 - Port Bandwidth Start (PBWF) */
-       { 0x0070, 0x00f0 }, /* 17 - Port Bandwidth Stop (PBWL) */
-};
-
-const u32 cpld_val_map[][2] = {
-       { 0x01, 0x02 }, /* LIU1 / LIU2 select for Serial Chip Select */
-       { 0x04, 0x08 }, /* DAC1 / DAC2 select for Serial Chip Select */
-       { 0x00, 0x04 }, /* LOOP1 / LOOP2 - select of loop timing source */
-       { 0x01, 0x02 }  /* PORT1 / PORT2 - select LIU and Framer for reset */
-};
-
-const u32 t3e3_framer_reg_map[] = {
-       0x00, /* 0 - OPERATING_MODE */
-       0x01, /* 1 - IO_CONTROL */
-       0x04, /* 2 - BLOCK_INTERRUPT_ENABLE */
-       0x05, /* 3 - BLOCK_INTERRUPT_STATUS */
-       0x10, /* 4 - T3_RX_CONFIGURATION_STATUS, E3_RX_CONFIGURATION_STATUS_1 */
-       0x11, /* 5 - T3_RX_STATUS, E3_RX_CONFIGURATION_STATUS_2 */
-       0x12, /* 6 - T3_RX_INTERRUPT_ENABLE, E3_RX_INTERRUPT_ENABLE_1 */
-       0x13, /* 7 - T3_RX_INTERRUPT_STATUS, E3_RX_INTERRUPT_ENABLE_2 */
-       0x14, /* 8 - T3_RX_SYNC_DETECT_ENABLE, E3_RX_INTERRUPT_STATUS_1 */
-       0x15, /* 9 - E3_RX_INTERRUPT_STATUS_2 */
-       0x16, /* 10 - T3_RX_FEAC */
-       0x17, /* 11 - T3_RX_FEAC_INTERRUPT_ENABLE_STATUS */
-       0x18, /* 12 - T3_RX_LAPD_CONTROL, E3_RX_LAPD_CONTROL */
-       0x19, /* 13 - T3_RX_LAPD_STATUS, E3_RX_LAPD_STATUS */
-       0x1a, /* 14 - E3_RX_NR_BYTE, E3_RX_SERVICE_BITS */
-       0x1b, /* 15 - E3_RX_GC_BYTE */
-       0x30, /* 16 - T3_TX_CONFIGURATION, E3_TX_CONFIGURATION */
-       0x31, /* 17 - T3_TX_FEAC_CONFIGURATION_STATUS */
-       0x32, /* 18 - T3_TX_FEAC */
-       0x33, /* 19 - T3_TX_LAPD_CONFIGURATION, E3_TX_LAPD_CONFIGURATION */
-       0x34, /* 20 - T3_TX_LAPD_STATUS, E3_TX_LAPD_STATUS_INTERRUPT */
-       0x35, /* 21 - T3_TX_MBIT_MASK, E3_TX_GC_BYTE, E3_TX_SERVICE_BITS */
-       0x36, /* 22 - T3_TX_FBIT_MASK, E3_TX_MA_BYTE */
-       0x37, /* 23 - T3_TX_FBIT_MASK_2, E3_TX_NR_BYTE */
-       0x38, /* 24 - T3_TX_FBIT_MASK_3 */
-       0x48, /* 25 - E3_TX_FA1_ERROR_MASK, E3_TX_FAS_ERROR_MASK_UPPER */
-       0x49, /* 26 - E3_TX_FA2_ERROR_MASK, E3_TX_FAS_ERROR_MASK_LOWER */
-       0x4a, /* 27 - E3_TX_BIP8_MASK, E3_TX_BIP4_MASK */
-       0x50, /* 28 - PMON_LCV_EVENT_COUNT_MSB */
-       0x51, /* 29 - PMON_LCV_EVENT_COUNT_LSB */
-       0x52, /* 30 - PMON_FRAMING_BIT_ERROR_EVENT_COUNT_MSB */
-       0x53, /* 31 - PMON_FRAMING_BIT_ERROR_EVENT_COUNT_LSB */
-       0x54, /* 32 - PMON_PARITY_ERROR_EVENT_COUNT_MSB */
-       0x55, /* 33 - PMON_PARITY_ERROR_EVENT_COUNT_LSB */
-       0x56, /* 34 - PMON_FEBE_EVENT_COUNT_MSB */
-       0x57, /* 35 - PMON_FEBE_EVENT_COUNT_LSB */
-       0x58, /* 36 - PMON_CP_BIT_ERROR_EVENT_COUNT_MSB */
-       0x59, /* 37 - PMON_CP_BIT_ERROR_EVENT_COUNT_LSB */
-       0x6c, /* 38 - PMON_HOLDING_REGISTER */
-       0x6d, /* 39 - ONE_SECOND_ERROR_STATUS */
-       0x6e, /* 40 - LCV_ONE_SECOND_ACCUMULATOR_MSB */
-       0x6f, /* 41 - LCV_ONE_SECOND_ACCUMULATOR_LSB */
-       0x70, /* 42 - FRAME_PARITY_ERROR_ONE_SECOND_ACCUMULATOR_MSB */
-       0x71, /* 43 - FRAME_PARITY_ERROR_ONE_SECOND_ACCUMULATOR_LSB */
-       0x72, /* 44 - FRAME_CP_BIT_ERROR_ONE_SECOND_ACCUMULATOR_MSB */
-       0x73, /* 45 - FRAME_CP_BIT_ERROR_ONE_SECOND_ACCUMULATOR_LSB */
-       0x80, /* 46 - LINE_INTERFACE_DRIVE */
-       0x81  /* 47 - LINE_INTERFACE_SCAN */
-};
-
-const u32 t3e3_liu_reg_map[] = {
-       0x00, /* REG0 */
-       0x01, /* REG1 */
-       0x02, /* REG2 */
-       0x03, /* REG3 */
-       0x04 /* REG4 */
-};
diff --git a/drivers/staging/sbe-2t3e3/module.c b/drivers/staging/sbe-2t3e3/module.c
deleted file mode 100644 (file)
index a6f93a4..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * SBE 2T3E3 synchronous serial card driver for Linux
- *
- * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- *
- * This code is based on a driver written by SBE Inc.
- */
-
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/netdevice.h>
-#include <linux/pci.h>
-#include <linux/hdlc.h>
-#include <linux/if_arp.h>
-#include <linux/interrupt.h>
-#include "2t3e3.h"
-
-static void check_leds(unsigned long arg)
-{
-       struct card *card = (struct card *)arg;
-       struct channel *channel0 = &card->channels[0];
-       static int blinker;
-
-       update_led(channel0, ++blinker);
-       if (has_two_ports(channel0->pdev))
-               update_led(&card->channels[1], blinker);
-
-       card->timer.expires = jiffies + HZ / 10;
-       add_timer(&card->timer);
-}
-
-static void t3e3_remove_channel(struct channel *channel)
-{
-       struct pci_dev *pdev = channel->pdev;
-       struct net_device *dev = channel->dev;
-
-       /* system hangs if board asserts irq while module is unloaded */
-       cpld_stop_intr(channel);
-       free_irq(dev->irq, dev);
-       dc_drop_descriptor_list(channel);
-       unregister_hdlc_device(dev);
-       free_netdev(dev);
-       pci_release_regions(pdev);
-       pci_disable_device(pdev);
-       pci_set_drvdata(pdev, NULL);
-}
-
-static int t3e3_init_channel(struct channel *channel, struct pci_dev *pdev, struct card *card)
-{
-       struct net_device *dev;
-       unsigned int val;
-       int err;
-
-       err = pci_enable_device(pdev);
-       if (err)
-               return err;
-
-       err = pci_request_regions(pdev, "SBE 2T3E3");
-       if (err)
-               goto disable;
-
-       dev = alloc_hdlcdev(channel);
-       if (!dev) {
-               pr_err("Out of memory\n");
-               err = -ENOMEM;
-               goto free_regions;
-       }
-
-       t3e3_sc_init(channel);
-       dev_to_priv(dev) = channel;
-
-       channel->pdev = pdev;
-       channel->dev = dev;
-       channel->card = card;
-       channel->addr = pci_resource_start(pdev, 0);
-       if (pdev->subsystem_device == PCI_SUBDEVICE_ID_SBE_2T3E3_P1)
-               channel->h.slot = 1;
-       else
-               channel->h.slot = 0;
-
-       err = setup_device(dev, channel);
-       if (err)
-               goto free_dev;
-
-       pci_read_config_dword(channel->pdev, 0x40, &val); /* mask sleep mode */
-       pci_write_config_dword(channel->pdev, 0x40, val & 0x3FFFFFFF);
-
-       pci_read_config_byte(channel->pdev, PCI_CACHE_LINE_SIZE, &channel->h.cache_size);
-       pci_read_config_dword(channel->pdev, PCI_COMMAND, &channel->h.command);
-       t3e3_init(channel);
-
-       err = request_irq(dev->irq, &t3e3_intr, IRQF_SHARED, dev->name, dev);
-       if (err) {
-               netdev_warn(channel->dev, "%s: could not get irq: %d\n",
-                           dev->name, dev->irq);
-               goto unregister_dev;
-       }
-
-       pci_set_drvdata(pdev, channel);
-       return 0;
-
-unregister_dev:
-       unregister_hdlc_device(dev);
-free_dev:
-       free_netdev(dev);
-free_regions:
-       pci_release_regions(pdev);
-disable:
-       pci_disable_device(pdev);
-       return err;
-}
-
-static void t3e3_remove_card(struct pci_dev *pdev)
-{
-       struct channel *channel0 = pci_get_drvdata(pdev);
-       struct card *card = channel0->card;
-
-       del_timer_sync(&card->timer);
-       if (has_two_ports(channel0->pdev)) {
-               t3e3_remove_channel(&card->channels[1]);
-               pci_dev_put(card->channels[1].pdev);
-       }
-       t3e3_remove_channel(channel0);
-       kfree(card);
-}
-
-static int t3e3_init_card(struct pci_dev *pdev, const struct pci_device_id *ent)
-{
-       /* pdev points to channel #0 */
-       struct pci_dev *pdev1 = NULL;
-       struct card *card;
-       int channels = 1, err;
-
-       if (has_two_ports(pdev)) {
-               while ((pdev1 = pci_get_subsys(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142,
-                                              PCI_VENDOR_ID_SBE, PCI_SUBDEVICE_ID_SBE_2T3E3_P1,
-                                              pdev1)))
-                       if (pdev1->bus == pdev->bus &&
-                           pdev1->devfn == pdev->devfn + 8 /* next device on the same bus */)
-                               break; /* found the second channel */
-
-               if (!pdev1) {
-                       dev_err(&pdev->dev, "Can't find the second channel\n");
-                       return -EFAULT;
-               }
-               channels = 2;
-               /* holds the reference for pdev1 */
-       }
-
-       card = kzalloc(sizeof(struct card) + channels * sizeof(struct channel),
-                      GFP_KERNEL);
-       if (!card)
-               return -ENOBUFS;
-
-       spin_lock_init(&card->bootrom_lock);
-       card->bootrom_addr = pci_resource_start(pdev, 0);
-
-       err = t3e3_init_channel(&card->channels[0], pdev, card);
-       if (err)
-               goto free_card;
-
-       if (channels == 2) {
-               err = t3e3_init_channel(&card->channels[1], pdev1, card);
-               if (err) {
-                       t3e3_remove_channel(&card->channels[0]);
-                       goto free_card;
-               }
-       }
-
-       /* start LED timer */
-       init_timer(&card->timer);
-       card->timer.function = check_leds;
-       card->timer.expires = jiffies + HZ / 10;
-       card->timer.data = (unsigned long)card;
-       add_timer(&card->timer);
-       return 0;
-
-free_card:
-       kfree(card);
-       return err;
-}
-
-static struct pci_device_id t3e3_pci_tbl[] = {
-       { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142,
-         PCI_VENDOR_ID_SBE, PCI_SUBDEVICE_ID_SBE_T3E3, 0, 0, 0 },
-       { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142,
-         PCI_VENDOR_ID_SBE, PCI_SUBDEVICE_ID_SBE_2T3E3_P0, 0, 0, 0 },
-       /* channel 1 will be initialized after channel 0 */
-       { 0, }
-};
-
-static struct pci_driver t3e3_pci_driver = {
-       .name     = "SBE T3E3",
-       .id_table = t3e3_pci_tbl,
-       .probe    = t3e3_init_card,
-       .remove   = t3e3_remove_card,
-};
-
-module_pci_driver(t3e3_pci_driver);
-MODULE_LICENSE("GPL");
-MODULE_DEVICE_TABLE(pci, t3e3_pci_tbl);
diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
deleted file mode 100644 (file)
index fe6c951..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * SBE 2T3E3 synchronous serial card driver for Linux
- *
- * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- *
- * This code is based on a driver written by SBE Inc.
- */
-
-#include <linux/capability.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/netdevice.h>
-#include <linux/pci.h>
-#include <linux/hdlc.h>
-#include <linux/if_arp.h>
-#include <linux/interrupt.h>
-#include "2t3e3.h"
-
-static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
-{
-       struct channel *sc = dev_to_priv(dev);
-       int cmd_2t3e3, len, rlen;
-       struct t3e3_param param;
-       struct t3e3_resp resp;
-       void __user *data = ifr->ifr_data + sizeof(cmd_2t3e3) + sizeof(len);
-
-       if (cmd == SIOCWANDEV)
-               return hdlc_ioctl(dev, ifr, cmd);
-       if (!capable(CAP_SYS_ADMIN))
-               return -EPERM;
-       if (cmd != SIOCDEVPRIVATE + 15)
-               return -EINVAL;
-
-       if (copy_from_user(&cmd_2t3e3, ifr->ifr_data, sizeof(cmd_2t3e3)))
-               return -EFAULT;
-       if (copy_from_user(&len, ifr->ifr_data + sizeof(cmd_2t3e3), sizeof(len)))
-               return -EFAULT;
-
-       if (len > sizeof(param))
-               return -EFAULT;
-
-       if (len)
-               if (copy_from_user(&param, data, len))
-                       return -EFAULT;
-
-       t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
-
-       if (rlen)
-               if (copy_to_user(data, &resp, rlen))
-                       return -EFAULT;
-
-       return 0;
-}
-
-static struct net_device_stats *t3e3_get_stats(struct net_device *dev)
-{
-       struct net_device_stats *nstats = &dev->stats;
-       struct channel *sc = dev_to_priv(dev);
-       struct t3e3_stats *stats = &sc->s;
-
-       memset(nstats, 0, sizeof(struct net_device_stats));
-       nstats->rx_packets = stats->in_packets;
-       nstats->tx_packets = stats->out_packets;
-       nstats->rx_bytes = stats->in_bytes;
-       nstats->tx_bytes = stats->out_bytes;
-
-       nstats->rx_errors = stats->in_errors;
-       nstats->tx_errors = stats->out_errors;
-       nstats->rx_crc_errors = stats->in_error_crc;
-
-
-       nstats->rx_dropped = stats->in_dropped;
-       nstats->tx_dropped = stats->out_dropped;
-       nstats->tx_carrier_errors = stats->out_error_lost_carr +
-               stats->out_error_no_carr;
-
-       return nstats;
-}
-
-static int t3e3_open(struct net_device *dev)
-{
-       struct channel *sc = dev_to_priv(dev);
-       int ret = hdlc_open(dev);
-
-       if (ret)
-               return ret;
-
-       sc->r.flags |= SBE_2T3E3_FLAG_NETWORK_UP;
-       dc_start(dev_to_priv(dev));
-       netif_start_queue(dev);
-       try_module_get(THIS_MODULE);
-       return 0;
-}
-
-static int t3e3_close(struct net_device *dev)
-{
-       struct channel *sc = dev_to_priv(dev);
-       hdlc_close(dev);
-       netif_stop_queue(dev);
-       dc_stop(sc);
-       sc->r.flags &= ~SBE_2T3E3_FLAG_NETWORK_UP;
-       module_put(THIS_MODULE);
-       return 0;
-}
-
-static int t3e3_attach(struct net_device *dev, unsigned short foo1,
-                      unsigned short foo2)
-{
-       return 0;
-}
-
-static const struct net_device_ops t3e3_ops = {
-       .ndo_open       = t3e3_open,
-       .ndo_stop       = t3e3_close,
-       .ndo_change_mtu = hdlc_change_mtu,
-       .ndo_start_xmit = hdlc_start_xmit,
-       .ndo_do_ioctl   = t3e3_ioctl,
-       .ndo_get_stats  = t3e3_get_stats,
-};
-
-int setup_device(struct net_device *dev, struct channel *sc)
-{
-       hdlc_device *hdlc = dev_to_hdlc(dev);
-       int retval;
-
-       dev->base_addr = pci_resource_start(sc->pdev, 0);
-       dev->irq = sc->pdev->irq;
-       dev->netdev_ops = &t3e3_ops;
-       dev->tx_queue_len = 100;
-       hdlc->xmit = t3e3_if_start_xmit;
-       hdlc->attach = t3e3_attach;
-       retval = register_hdlc_device(dev);
-       if (retval) {
-               dev_err(&sc->pdev->dev, "error registering HDLC device\n");
-               return retval;
-       }
-       return 0;
-}
index 6b9365b28e8ac3febbf7605e66f7777d104d4b8f..7f3d884d4ddd41b94684e01b314e7acf739b6439 100644 (file)
@@ -119,7 +119,6 @@ static void if_scan_init(void);
 
 static int bypass_proc_create_dev_sd(struct bpctl_dev *pbp_device_block);
 static int bypass_proc_remove_dev_sd(struct bpctl_dev *pbp_device_block);
-static int bp_proc_create(void);
 
 static int is_bypass_fn(struct bpctl_dev *pbpctl_dev);
 static int get_dev_idx_bsf(int bus, int slot, int func);
@@ -220,8 +219,12 @@ static int bp_device_event(struct notifier_block *unused,
                        if (netif_carrier_ok(dev))
                                return NOTIFY_DONE;
 
-                       if (((dev_num = get_dev_idx(dev->ifindex)) == -1) ||
-                           (!(pbpctl_dev = &bpctl_dev_arr[dev_num])))
+                       dev_num = get_dev_idx(dev->ifindex);
+                       if (dev_num == -1)
+                               return NOTIFY_DONE;
+
+                       pbpctl_dev = &bpctl_dev_arr[dev_num];
+                       if (!pbpctl_dev)
                                return NOTIFY_DONE;
 
                        if ((is_bypass_fn(pbpctl_dev)) == 1)
@@ -6399,25 +6402,6 @@ static int __init bypass_init_module(void)
        }
 
        register_netdevice_notifier(&bp_notifier_block);
-#ifdef BP_PROC_SUPPORT
-       {
-               int i = 0;
-               /* unsigned long flags; */
-               /* rcu_read_lock(); */
-               bp_proc_create();
-               for (i = 0; i < device_num; i++) {
-                       if (bpctl_dev_arr[i].ifindex) {
-                               /* spin_lock_irqsave(&bpvm_lock, flags); */
-                               bypass_proc_remove_dev_sd(&bpctl_dev_arr[i]);
-                               bypass_proc_create_dev_sd(&bpctl_dev_arr[i]);
-                               /* spin_unlock_irqrestore(&bpvm_lock, flags); */
-                       }
-
-               }
-               /* rcu_read_unlock(); */
-       }
-#endif
-
        return 0;
 }
 
@@ -6431,13 +6415,6 @@ static void __exit bypass_cleanup_module(void)
 
        for (i = 0; i < device_num; i++) {
                /* unsigned long flags; */
-#ifdef BP_PROC_SUPPORT
-/*     spin_lock_irqsave(&bpvm_lock, flags);
-       rcu_read_lock(); */
-               bypass_proc_remove_dev_sd(&bpctl_dev_arr[i]);
-/*     spin_unlock_irqrestore(&bpvm_lock, flags);
-       rcu_read_unlock(); */
-#endif
                remove_bypass_wd_auto(&bpctl_dev_arr[i]);
                bpctl_dev_arr[i].reset_time = 0;
 
@@ -6783,18 +6760,6 @@ EXPORT_SYMBOL(bp_if_scan_sd);
 
 static struct proc_dir_entry *bp_procfs_dir;
 
-static int bp_proc_create(void)
-{
-       bp_procfs_dir = proc_mkdir(BP_PROC_DIR, init_net.proc_net);
-       if (bp_procfs_dir == (struct proc_dir_entry *)0) {
-               printk(KERN_DEBUG
-                      "Could not create procfs nicinfo directory %s\n",
-                      BP_PROC_DIR);
-               return -1;
-       }
-       return 0;
-}
-
 static int procfs_add(char *proc_name, const struct file_operations *fops,
                      struct bpctl_dev *dev)
 {
index 09e00dac04f3a81fb0516f3c65073d82fa1c37ea..a58251f5a8f8f584cd81ea9f152bab2d6759e874 100644 (file)
@@ -149,38 +149,33 @@ static int is_bypass_dev(int if_index)
 
        while ((pdev = pci_get_class(PCI_CLASS_NETWORK_ETHERNET << 8, pdev))) {
                dev = pci_get_drvdata(pdev);
-               if (dev != NULL) {
-                       dev = pci_get_drvdata(pdev);
-                       if ((dev != NULL) && (dev->ifindex == if_index)) {
-                               if ((pdev->vendor == SILICOM_VID) &&
-                                   (pdev->device >= SILICOM_BP_PID_MIN) &&
-                                   (pdev->device <= SILICOM_BP_PID_MAX)) {
-                                       goto send_cmd;
-                               }
+               if ((dev != NULL) && (dev->ifindex == if_index)) {
+                       if ((pdev->vendor == SILICOM_VID) &&
+                           (pdev->device >= SILICOM_BP_PID_MIN) &&
+                           (pdev->device <= SILICOM_BP_PID_MAX)) {
+                               goto send_cmd;
+                       }
 #if defined(BP_VENDOR_SUPPORT) && defined(ETHTOOL_GDRVINFO)
-                               else {
-                                       struct ethtool_drvinfo info;
-                                       const struct ethtool_ops *ops =
-                                           dev->ethtool_ops;
-                                       int k = 0;
-
-                                       if (ops->get_drvinfo) {
-                                               memset(&info, 0, sizeof(info));
-                                               info.cmd = ETHTOOL_GDRVINFO;
-                                               ops->get_drvinfo(dev, &info);
-                                               for (; bp_desc_array[k]; k++)
-                                                       if (!
-                                                           (strcmp
-                                                            (bp_desc_array[k],
-                                                             info.driver)))
-                                                               goto send_cmd;
-
-                                       }
+                       else {
+                               struct ethtool_drvinfo info;
+                               const struct ethtool_ops *ops =
+                                       dev->ethtool_ops;
+                               int k = 0;
+
+                               if (ops->get_drvinfo) {
+                                       memset(&info, 0, sizeof(info));
+                                       info.cmd = ETHTOOL_GDRVINFO;
+                                       ops->get_drvinfo(dev, &info);
+                                       for (; bp_desc_array[k]; k++)
+                                               if (!(strcmp(bp_desc_array[k],
+                                                            info.driver)))
+                                                       goto send_cmd;
 
                                }
-#endif
-                               return -1;
+
                        }
+#endif
+                       return -1;
                }
        }
  send_cmd:
diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
new file mode 100644 (file)
index 0000000..8f5a72a
--- /dev/null
@@ -0,0 +1,32 @@
+config CRYPTO_SKEIN
+       bool "Skein digest algorithm"
+       depends on (X86 || UML_X86) && 64BIT
+       select CRYPTO_THREEFISH
+       select CRYPTO_HASH
+       help
+         Skein secure hash algorithm is one of 5 finalists from the NIST SHA3
+         competition.
+
+         Skein is optimized for modern, 64bit processors and is highly
+         customizable.  See:
+
+         http://www.skein-hash.info/sites/default/files/skein1.3.pdf
+
+         for more information.  This module depends on the threefish block
+         cipher module.
+
+config CRYPTO_THREEFISH
+       bool "Threefish tweakable block cipher"
+       depends on (X86 || UML_X86) && 64BIT
+       select CRYPTO_ALGAPI
+       help
+         Threefish cipher algorithm is the tweakable block cipher underneath
+         the Skein family of secure hash algorithms.  Skein is one of 5
+         finalists from the NIST SHA3 competition.
+
+         Skein is optimized for modern, 64bit processors and is highly
+         customizable.  See:
+
+         http://www.skein-hash.info/sites/default/files/skein1.3.pdf
+
+         for more information.
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
new file mode 100644 (file)
index 0000000..2bb386e
--- /dev/null
@@ -0,0 +1,13 @@
+#
+# Makefile for the skein secure hash algorithm
+#
+subdir-ccflags-y := -I$(src)/include/
+
+obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
+                               skeinApi.o \
+                               skein_block.o
+
+obj-$(CONFIG_CRYPTO_THREEFISH) += threefish1024Block.o \
+                                 threefish256Block.o \
+                                 threefish512Block.o \
+                                 threefishApi.o
diff --git a/drivers/staging/skein/TODO b/drivers/staging/skein/TODO
new file mode 100644 (file)
index 0000000..f5c167a
--- /dev/null
@@ -0,0 +1,11 @@
+skein/threefish TODO
+
+ - rename camelcase vars
+ - rename camelcase functions
+ - rename files
+ - move macros into appropriate header files
+ - add / pass test vectors
+ - module support
+
+Please send patches to Jason Cooper <jason@lakedaemon.net> in addition to the
+staging tree mailinglist.
diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h
new file mode 100644 (file)
index 0000000..0a2abce
--- /dev/null
@@ -0,0 +1,344 @@
+#ifndef _SKEIN_H_
+#define _SKEIN_H_     1
+/**************************************************************************
+**
+** Interface declarations and internal definitions for Skein hashing.
+**
+** Source code author: Doug Whiting, 2008.
+**
+** This algorithm and source code is released to the public domain.
+**
+***************************************************************************
+**
+** The following compile-time switches may be defined to control some
+** tradeoffs between speed, code size, error checking, and security.
+**
+** The "default" note explains what happens when the switch is not defined.
+**
+**  SKEIN_DEBUG            -- make callouts from inside Skein code
+**                            to examine/display intermediate values.
+**                            [default: no callouts (no overhead)]
+**
+**  SKEIN_ERR_CHECK        -- how error checking is handled inside Skein
+**                            code. If not defined, most error checking
+**                            is disabled (for performance). Otherwise,
+**                            the switch value is interpreted as:
+**                                0: use assert()      to flag errors
+**                                1: return SKEIN_FAIL to flag errors
+**
+***************************************************************************/
+
+#ifndef RotL_64
+#define RotL_64(x, N)    (((x) << (N)) | ((x) >> (64-(N))))
+#endif
+
+/* below two prototype assume we are handed aligned data */
+#define Skein_Put64_LSB_First(dst08, src64, bCnt) memcpy(dst08, src64, bCnt)
+#define Skein_Get64_LSB_First(dst64, src08, wCnt) memcpy(dst64, src08, 8*(wCnt))
+#define Skein_Swap64(w64)  (w64)
+
+enum {
+       SKEIN_SUCCESS         =      0, /* return codes from Skein calls */
+       SKEIN_FAIL            =      1,
+       SKEIN_BAD_HASHLEN     =      2
+};
+
+#define  SKEIN_MODIFIER_WORDS   (2) /* number of modifier (tweak) words */
+
+#define  SKEIN_256_STATE_WORDS  (4)
+#define  SKEIN_512_STATE_WORDS  (8)
+#define  SKEIN1024_STATE_WORDS (16)
+#define  SKEIN_MAX_STATE_WORDS (16)
+
+#define  SKEIN_256_STATE_BYTES  (8*SKEIN_256_STATE_WORDS)
+#define  SKEIN_512_STATE_BYTES  (8*SKEIN_512_STATE_WORDS)
+#define  SKEIN1024_STATE_BYTES  (8*SKEIN1024_STATE_WORDS)
+
+#define  SKEIN_256_STATE_BITS  (64*SKEIN_256_STATE_WORDS)
+#define  SKEIN_512_STATE_BITS  (64*SKEIN_512_STATE_WORDS)
+#define  SKEIN1024_STATE_BITS  (64*SKEIN1024_STATE_WORDS)
+
+#define  SKEIN_256_BLOCK_BYTES  (8*SKEIN_256_STATE_WORDS)
+#define  SKEIN_512_BLOCK_BYTES  (8*SKEIN_512_STATE_WORDS)
+#define  SKEIN1024_BLOCK_BYTES  (8*SKEIN1024_STATE_WORDS)
+
+struct skein_ctx_hdr {
+       size_t  hashBitLen;             /* size of hash result, in bits */
+       size_t  bCnt;                   /* current byte count in buffer b[] */
+       u64  T[SKEIN_MODIFIER_WORDS];   /* tweak: T[0]=byte cnt, T[1]=flags */
+};
+
+struct skein_256_ctx { /* 256-bit Skein hash context structure */
+       struct skein_ctx_hdr h;         /* common header context variables */
+       u64  X[SKEIN_256_STATE_WORDS];  /* chaining variables */
+       u8  b[SKEIN_256_BLOCK_BYTES];   /* partial block buf (8-byte aligned) */
+};
+
+struct skein_512_ctx { /* 512-bit Skein hash context structure */
+       struct skein_ctx_hdr h;         /* common header context variables */
+       u64  X[SKEIN_512_STATE_WORDS];  /* chaining variables */
+       u8  b[SKEIN_512_BLOCK_BYTES];   /* partial block buf (8-byte aligned) */
+};
+
+struct skein1024_ctx { /* 1024-bit Skein hash context structure */
+       struct skein_ctx_hdr h;         /* common header context variables */
+       u64  X[SKEIN1024_STATE_WORDS];  /* chaining variables */
+       u8  b[SKEIN1024_BLOCK_BYTES];   /* partial block buf (8-byte aligned) */
+};
+
+/*   Skein APIs for (incremental) "straight hashing" */
+int  Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen);
+int  Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen);
+int  Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen);
+
+int  Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg,
+                       size_t msgByteCnt);
+int  Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg,
+                       size_t msgByteCnt);
+int  Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg,
+                       size_t msgByteCnt);
+
+int  Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal);
+int  Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal);
+int  Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal);
+
+/*
+**   Skein APIs for "extended" initialization: MAC keys, tree hashing.
+**   After an InitExt() call, just use Update/Final calls as with Init().
+**
+**   Notes: Same parameters as _Init() calls, plus treeInfo/key/keyBytes.
+**          When keyBytes == 0 and treeInfo == SKEIN_SEQUENTIAL,
+**              the results of InitExt() are identical to calling Init().
+**          The function Init() may be called once to "precompute" the IV for
+**              a given hashBitLen value, then by saving a copy of the context
+**              the IV computation may be avoided in later calls.
+**          Similarly, the function InitExt() may be called once per MAC key
+**              to precompute the MAC IV, then a copy of the context saved and
+**              reused for each new MAC computation.
+**/
+int  Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen,
+                       u64 treeInfo, const u8 *key, size_t keyBytes);
+int  Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen,
+                       u64 treeInfo, const u8 *key, size_t keyBytes);
+int  Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen,
+                       u64 treeInfo, const u8 *key, size_t keyBytes);
+
+/*
+**   Skein APIs for MAC and tree hash:
+**      Final_Pad:  pad, do final block, but no OUTPUT type
+**      Output:     do just the output stage
+*/
+int  Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal);
+int  Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal);
+int  Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal);
+
+#ifndef SKEIN_TREE_HASH
+#define SKEIN_TREE_HASH (1)
+#endif
+#if  SKEIN_TREE_HASH
+int  Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal);
+int  Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal);
+int  Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal);
+#endif
+
+/*****************************************************************
+** "Internal" Skein definitions
+**    -- not needed for sequential hashing API, but will be
+**           helpful for other uses of Skein (e.g., tree hash mode).
+**    -- included here so that they can be shared between
+**           reference and optimized code.
+******************************************************************/
+
+/* tweak word T[1]: bit field starting positions */
+#define SKEIN_T1_BIT(BIT)       ((BIT) - 64)      /* second word  */
+
+#define SKEIN_T1_POS_TREE_LVL   SKEIN_T1_BIT(112) /* 112..118 hash tree level */
+#define SKEIN_T1_POS_BIT_PAD    SKEIN_T1_BIT(119) /* 119 part. final in byte */
+#define SKEIN_T1_POS_BLK_TYPE   SKEIN_T1_BIT(120) /* 120..125 type field `*/
+#define SKEIN_T1_POS_FIRST      SKEIN_T1_BIT(126) /* 126      first blk flag */
+#define SKEIN_T1_POS_FINAL      SKEIN_T1_BIT(127) /* 127      final blk flag */
+
+/* tweak word T[1]: flag bit definition(s) */
+#define SKEIN_T1_FLAG_FIRST     (((u64)  1) << SKEIN_T1_POS_FIRST)
+#define SKEIN_T1_FLAG_FINAL     (((u64)  1) << SKEIN_T1_POS_FINAL)
+#define SKEIN_T1_FLAG_BIT_PAD   (((u64)  1) << SKEIN_T1_POS_BIT_PAD)
+
+/* tweak word T[1]: tree level bit field mask */
+#define SKEIN_T1_TREE_LVL_MASK  (((u64)0x7F) << SKEIN_T1_POS_TREE_LVL)
+#define SKEIN_T1_TREE_LEVEL(n)  (((u64) (n)) << SKEIN_T1_POS_TREE_LVL)
+
+/* tweak word T[1]: block type field */
+#define SKEIN_BLK_TYPE_KEY       (0) /* key, for MAC and KDF */
+#define SKEIN_BLK_TYPE_CFG       (4) /* configuration block */
+#define SKEIN_BLK_TYPE_PERS      (8) /* personalization string */
+#define SKEIN_BLK_TYPE_PK       (12) /* pubkey (for digital sigs) */
+#define SKEIN_BLK_TYPE_KDF      (16) /* key identifier for KDF */
+#define SKEIN_BLK_TYPE_NONCE    (20) /* nonce for PRNG */
+#define SKEIN_BLK_TYPE_MSG      (48) /* message processing */
+#define SKEIN_BLK_TYPE_OUT      (63) /* output stage */
+#define SKEIN_BLK_TYPE_MASK     (63) /* bit field mask */
+
+#define SKEIN_T1_BLK_TYPE(T)   (((u64) (SKEIN_BLK_TYPE_##T)) << \
+                                       SKEIN_T1_POS_BLK_TYPE)
+#define SKEIN_T1_BLK_TYPE_KEY   SKEIN_T1_BLK_TYPE(KEY)  /* for MAC and KDF */
+#define SKEIN_T1_BLK_TYPE_CFG   SKEIN_T1_BLK_TYPE(CFG)  /* config block */
+#define SKEIN_T1_BLK_TYPE_PERS  SKEIN_T1_BLK_TYPE(PERS) /* personalization */
+#define SKEIN_T1_BLK_TYPE_PK    SKEIN_T1_BLK_TYPE(PK)   /* pubkey (for sigs) */
+#define SKEIN_T1_BLK_TYPE_KDF   SKEIN_T1_BLK_TYPE(KDF)  /* key ident for KDF */
+#define SKEIN_T1_BLK_TYPE_NONCE SKEIN_T1_BLK_TYPE(NONCE)/* nonce for PRNG */
+#define SKEIN_T1_BLK_TYPE_MSG   SKEIN_T1_BLK_TYPE(MSG)  /* message processing */
+#define SKEIN_T1_BLK_TYPE_OUT   SKEIN_T1_BLK_TYPE(OUT)  /* output stage */
+#define SKEIN_T1_BLK_TYPE_MASK  SKEIN_T1_BLK_TYPE(MASK) /* field bit mask */
+
+#define SKEIN_T1_BLK_TYPE_CFG_FINAL    (SKEIN_T1_BLK_TYPE_CFG | \
+                                       SKEIN_T1_FLAG_FINAL)
+#define SKEIN_T1_BLK_TYPE_OUT_FINAL    (SKEIN_T1_BLK_TYPE_OUT | \
+                                       SKEIN_T1_FLAG_FINAL)
+
+#define SKEIN_VERSION           (1)
+
+#ifndef SKEIN_ID_STRING_LE      /* allow compile-time personalization */
+#define SKEIN_ID_STRING_LE      (0x33414853) /* "SHA3" (little-endian)*/
+#endif
+
+#define SKEIN_MK_64(hi32, lo32)  ((lo32) + (((u64) (hi32)) << 32))
+#define SKEIN_SCHEMA_VER        SKEIN_MK_64(SKEIN_VERSION, SKEIN_ID_STRING_LE)
+#define SKEIN_KS_PARITY         SKEIN_MK_64(0x1BD11BDA, 0xA9FC1A22)
+
+#define SKEIN_CFG_STR_LEN       (4*8)
+
+/* bit field definitions in config block treeInfo word */
+#define SKEIN_CFG_TREE_LEAF_SIZE_POS  (0)
+#define SKEIN_CFG_TREE_NODE_SIZE_POS  (8)
+#define SKEIN_CFG_TREE_MAX_LEVEL_POS  (16)
+
+#define SKEIN_CFG_TREE_LEAF_SIZE_MSK (((u64)0xFF) << \
+                                       SKEIN_CFG_TREE_LEAF_SIZE_POS)
+#define SKEIN_CFG_TREE_NODE_SIZE_MSK (((u64)0xFF) << \
+                                       SKEIN_CFG_TREE_NODE_SIZE_POS)
+#define SKEIN_CFG_TREE_MAX_LEVEL_MSK (((u64)0xFF) << \
+                                       SKEIN_CFG_TREE_MAX_LEVEL_POS)
+
+#define SKEIN_CFG_TREE_INFO(leaf, node, maxLvl)                   \
+       ((((u64)(leaf))   << SKEIN_CFG_TREE_LEAF_SIZE_POS) |    \
+        (((u64)(node))   << SKEIN_CFG_TREE_NODE_SIZE_POS) |    \
+        (((u64)(maxLvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS))
+
+/* use as treeInfo in InitExt() call for sequential processing */
+#define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0, 0, 0)
+
+/*
+**   Skein macros for getting/setting tweak words, etc.
+**   These are useful for partial input bytes, hash tree init/update, etc.
+**/
+#define Skein_Get_Tweak(ctxPtr, TWK_NUM)          ((ctxPtr)->h.T[TWK_NUM])
+#define Skein_Set_Tweak(ctxPtr, TWK_NUM, tVal) { \
+               (ctxPtr)->h.T[TWK_NUM] = (tVal); \
+       }
+
+#define Skein_Get_T0(ctxPtr)     Skein_Get_Tweak(ctxPtr, 0)
+#define Skein_Get_T1(ctxPtr)     Skein_Get_Tweak(ctxPtr, 1)
+#define Skein_Set_T0(ctxPtr, T0) Skein_Set_Tweak(ctxPtr, 0, T0)
+#define Skein_Set_T1(ctxPtr, T1) Skein_Set_Tweak(ctxPtr, 1, T1)
+
+/* set both tweak words at once */
+#define Skein_Set_T0_T1(ctxPtr, T0, T1)           \
+       {                                           \
+       Skein_Set_T0(ctxPtr, (T0));                  \
+       Skein_Set_T1(ctxPtr, (T1));                  \
+       }
+
+#define Skein_Set_Type(ctxPtr, BLK_TYPE)         \
+       Skein_Set_T1(ctxPtr, SKEIN_T1_BLK_TYPE_##BLK_TYPE)
+
+/*
+ * setup for starting with a new type:
+ * h.T[0]=0; h.T[1] = NEW_TYPE; h.bCnt=0;
+ */
+#define Skein_Start_New_Type(ctxPtr, BLK_TYPE) { \
+               Skein_Set_T0_T1(ctxPtr, 0, SKEIN_T1_FLAG_FIRST | \
+                               SKEIN_T1_BLK_TYPE_##BLK_TYPE); \
+               (ctxPtr)->h.bCnt = 0; \
+       }
+
+#define Skein_Clear_First_Flag(hdr) { \
+               (hdr).T[1] &= ~SKEIN_T1_FLAG_FIRST; \
+       }
+#define Skein_Set_Bit_Pad_Flag(hdr) { \
+               (hdr).T[1] |=  SKEIN_T1_FLAG_BIT_PAD; \
+       }
+
+#define Skein_Set_Tree_Level(hdr, height) { \
+               (hdr).T[1] |= SKEIN_T1_TREE_LEVEL(height); \
+       }
+
+/*****************************************************************
+** "Internal" Skein definitions for debugging and error checking
+******************************************************************/
+#ifdef SKEIN_DEBUG             /* examine/display intermediate values? */
+#include "skein_debug.h"
+#else                           /* default is no callouts */
+#define Skein_Show_Block(bits, ctx, X, blkPtr, wPtr, ksEvenPtr, ksOddPtr)
+#define Skein_Show_Round(bits, ctx, r, X)
+#define Skein_Show_R_Ptr(bits, ctx, r, X_ptr)
+#define Skein_Show_Final(bits, ctx, cnt, outPtr)
+#define Skein_Show_Key(bits, ctx, key, keyBytes)
+#endif
+
+#define Skein_Assert(x, retCode)/* ignore all Asserts, for performance */
+#define Skein_assert(x)
+
+/*****************************************************************
+** Skein block function constants (shared across Ref and Opt code)
+******************************************************************/
+enum {
+           /* Skein_256 round rotation constants */
+       R_256_0_0 = 14, R_256_0_1 = 16,
+       R_256_1_0 = 52, R_256_1_1 = 57,
+       R_256_2_0 = 23, R_256_2_1 = 40,
+       R_256_3_0 =  5, R_256_3_1 = 37,
+       R_256_4_0 = 25, R_256_4_1 = 33,
+       R_256_5_0 = 46, R_256_5_1 = 12,
+       R_256_6_0 = 58, R_256_6_1 = 22,
+       R_256_7_0 = 32, R_256_7_1 = 32,
+
+           /* Skein_512 round rotation constants */
+       R_512_0_0 = 46, R_512_0_1 = 36, R_512_0_2 = 19, R_512_0_3 = 37,
+       R_512_1_0 = 33, R_512_1_1 = 27, R_512_1_2 = 14, R_512_1_3 = 42,
+       R_512_2_0 = 17, R_512_2_1 = 49, R_512_2_2 = 36, R_512_2_3 = 39,
+       R_512_3_0 = 44, R_512_3_1 =  9, R_512_3_2 = 54, R_512_3_3 = 56,
+       R_512_4_0 = 39, R_512_4_1 = 30, R_512_4_2 = 34, R_512_4_3 = 24,
+       R_512_5_0 = 13, R_512_5_1 = 50, R_512_5_2 = 10, R_512_5_3 = 17,
+       R_512_6_0 = 25, R_512_6_1 = 29, R_512_6_2 = 39, R_512_6_3 = 43,
+       R_512_7_0 =  8, R_512_7_1 = 35, R_512_7_2 = 56, R_512_7_3 = 22,
+
+           /* Skein1024 round rotation constants */
+       R1024_0_0 = 24, R1024_0_1 = 13, R1024_0_2 =  8, R1024_0_3 = 47,
+       R1024_0_4 =  8, R1024_0_5 = 17, R1024_0_6 = 22, R1024_0_7 = 37,
+       R1024_1_0 = 38, R1024_1_1 = 19, R1024_1_2 = 10, R1024_1_3 = 55,
+       R1024_1_4 = 49, R1024_1_5 = 18, R1024_1_6 = 23, R1024_1_7 = 52,
+       R1024_2_0 = 33, R1024_2_1 =  4, R1024_2_2 = 51, R1024_2_3 = 13,
+       R1024_2_4 = 34, R1024_2_5 = 41, R1024_2_6 = 59, R1024_2_7 = 17,
+       R1024_3_0 =  5, R1024_3_1 = 20, R1024_3_2 = 48, R1024_3_3 = 41,
+       R1024_3_4 = 47, R1024_3_5 = 28, R1024_3_6 = 16, R1024_3_7 = 25,
+       R1024_4_0 = 41, R1024_4_1 =  9, R1024_4_2 = 37, R1024_4_3 = 31,
+       R1024_4_4 = 12, R1024_4_5 = 47, R1024_4_6 = 44, R1024_4_7 = 30,
+       R1024_5_0 = 16, R1024_5_1 = 34, R1024_5_2 = 56, R1024_5_3 = 51,
+       R1024_5_4 =  4, R1024_5_5 = 53, R1024_5_6 = 42, R1024_5_7 = 41,
+       R1024_6_0 = 31, R1024_6_1 = 44, R1024_6_2 = 47, R1024_6_3 = 46,
+       R1024_6_4 = 19, R1024_6_5 = 42, R1024_6_6 = 44, R1024_6_7 = 25,
+       R1024_7_0 =  9, R1024_7_1 = 48, R1024_7_2 = 35, R1024_7_3 = 52,
+       R1024_7_4 = 23, R1024_7_5 = 31, R1024_7_6 = 37, R1024_7_7 = 20
+};
+
+#ifndef SKEIN_ROUNDS
+#define SKEIN_256_ROUNDS_TOTAL (72)    /* # rounds for diff block sizes */
+#define SKEIN_512_ROUNDS_TOTAL (72)
+#define SKEIN1024_ROUNDS_TOTAL (80)
+#else                  /* allow command-line define in range 8*(5..14)   */
+#define SKEIN_256_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/100) + 5) % 10) + 5))
+#define SKEIN_512_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/10)  + 5) % 10) + 5))
+#define SKEIN1024_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS)     + 5) % 10) + 5))
+#endif
+
+#endif  /* ifndef _SKEIN_H_ */
diff --git a/drivers/staging/skein/include/skeinApi.h b/drivers/staging/skein/include/skeinApi.h
new file mode 100644 (file)
index 0000000..ace931a
--- /dev/null
@@ -0,0 +1,230 @@
+/*
+Copyright (c) 2010 Werner Dittmann
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+*/
+
+#ifndef SKEINAPI_H
+#define SKEINAPI_H
+
+/**
+ * @file skeinApi.h
+ * @brief A Skein API and its functions.
+ * @{
+ *
+ * This API and the functions that implement this API simplify the usage
+ * of Skein. The design and the way to use the functions follow the openSSL
+ * design but at the same time take care of some Skein specific behaviour
+ * and possibilities.
+ *
+ * The functions enable applications to create a normal Skein hashes and
+ * message authentication codes (MAC).
+ *
+ * Using these functions is simple and straight forward:
+ *
+ * @code
+ *
+ * #include <skeinApi.h>
+ *
+ * ...
+ * struct skein_ctx ctx;             // a Skein hash or MAC context
+ *
+ * // prepare context, here for a Skein with a state size of 512 bits.
+ * skeinCtxPrepare(&ctx, Skein512);
+ *
+ * // Initialize the context to set the requested hash length in bits
+ * // here request a output hash size of 31 bits (Skein supports variable
+ * // output sizes even very strange sizes)
+ * skeinInit(&ctx, 31);
+ *
+ * // Now update Skein with any number of message bits. A function that
+ * // takes a number of bytes is also available.
+ * skeinUpdateBits(&ctx, message, msgLength);
+ *
+ * // Now get the result of the Skein hash. The output buffer must be
+ * // large enough to hold the request number of output bits. The application
+ * // may now extract the bits.
+ * skeinFinal(&ctx, result);
+ * ...
+ * @endcode
+ *
+ * An application may use @c skeinReset to reset a Skein context and use
+ * it for creation of another hash with the same Skein state size and output
+ * bit length. In this case the API implementation restores some internal
+ * internal state data and saves a full Skein initialization round.
+ *
+ * To create a MAC the application just uses @c skeinMacInit instead of
+ * @c skeinInit. All other functions calls remain the same.
+ *
+ */
+
+#include <linux/types.h>
+#include <skein.h>
+
+/**
+ * Which Skein size to use
+ */
+enum skein_size {
+       Skein256 = 256,     /*!< Skein with 256 bit state */
+       Skein512 = 512,     /*!< Skein with 512 bit state */
+       Skein1024 = 1024    /*!< Skein with 1024 bit state */
+};
+
+/**
+ * Context for Skein.
+ *
+ * This structure was setup with some know-how of the internal
+ * Skein structures, in particular ordering of header and size dependent
+ * variables. If Skein implementation changes this, then adapt these
+ * structures as well.
+ */
+struct skein_ctx {
+       u64 skeinSize;
+       u64  XSave[SKEIN_MAX_STATE_WORDS];   /* save area for state variables */
+       union {
+               struct skein_ctx_hdr h;
+               struct skein_256_ctx s256;
+               struct skein_512_ctx s512;
+               struct skein1024_ctx s1024;
+       } m;
+};
+
+/**
+ * Prepare a Skein context.
+ *
+ * An application must call this function before it can use the Skein
+ * context. The functions clears memory and initializes size dependent
+ * variables.
+ *
+ * @param ctx
+ *     Pointer to a Skein context.
+ * @param size
+ *     Which Skein size to use.
+ * @return
+ *     SKEIN_SUCESS of SKEIN_FAIL
+ */
+int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size);
+
+/**
+ * Initialize a Skein context.
+ *
+ * Initializes the context with this data and saves the resulting Skein
+ * state variables for further use.
+ *
+ * @param ctx
+ *     Pointer to a Skein context.
+ * @param hashBitLen
+ *     Number of MAC hash bits to compute
+ * @return
+ *     SKEIN_SUCESS of SKEIN_FAIL
+ * @see skeinReset
+ */
+int skeinInit(struct skein_ctx *ctx, size_t hashBitLen);
+
+/**
+ * Resets a Skein context for further use.
+ *
+ * Restores the saved chaining variables to reset the Skein context.
+ * Thus applications can reuse the same setup to  process several
+ * messages. This saves a complete Skein initialization cycle.
+ *
+ * @param ctx
+ *     Pointer to a pre-initialized Skein MAC context
+ */
+void skeinReset(struct skein_ctx *ctx);
+
+/**
+ * Initializes a Skein context for MAC usage.
+ *
+ * Initializes the context with this data and saves the resulting Skein
+ * state variables for further use.
+ *
+ * Applications call the normal Skein functions to update the MAC and
+ * get the final result.
+ *
+ * @param ctx
+ *     Pointer to an empty or preinitialized Skein MAC context
+ * @param key
+ *     Pointer to key bytes or NULL
+ * @param keyLen
+ *     Length of the key in bytes or zero
+ * @param hashBitLen
+ *     Number of MAC hash bits to compute
+ * @return
+ *     SKEIN_SUCESS of SKEIN_FAIL
+ */
+int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen,
+                size_t hashBitLen);
+
+/**
+ * Update Skein with the next part of the message.
+ *
+ * @param ctx
+ *     Pointer to initialized Skein context
+ * @param msg
+ *     Pointer to the message.
+ * @param msgByteCnt
+ *     Length of the message in @b bytes
+ * @return
+ *     Success or error code.
+ */
+int skeinUpdate(struct skein_ctx *ctx, const u8 *msg,
+               size_t msgByteCnt);
+
+/**
+ * Update the hash with a message bit string.
+ *
+ * Skein can handle data not only as bytes but also as bit strings of
+ * arbitrary length (up to its maximum design size).
+ *
+ * @param ctx
+ *     Pointer to initialized Skein context
+ * @param msg
+ *     Pointer to the message.
+ * @param msgBitCnt
+ *     Length of the message in @b bits.
+ */
+int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg,
+                   size_t msgBitCnt);
+
+/**
+ * Finalize Skein and return the hash.
+ *
+ * Before an application can reuse a Skein setup the application must
+ * reset the Skein context.
+ *
+ * @param ctx
+ *     Pointer to initialized Skein context
+ * @param hash
+ *     Pointer to buffer that receives the hash. The buffer must be large
+ *     enough to store @c hashBitLen bits.
+ * @return
+ *     Success or error code.
+ * @see skeinReset
+ */
+int skeinFinal(struct skein_ctx *ctx, u8 *hash);
+
+/**
+ * @}
+ */
+#endif
diff --git a/drivers/staging/skein/include/skein_block.h b/drivers/staging/skein/include/skein_block.h
new file mode 100644 (file)
index 0000000..b15c079
--- /dev/null
@@ -0,0 +1,22 @@
+/***********************************************************************
+**
+** Implementation of the Skein hash function.
+**
+** Source code author: Doug Whiting, 2008.
+**
+** This algorithm and source code is released to the public domain.
+**
+************************************************************************/
+#ifndef _SKEIN_BLOCK_H_
+#define _SKEIN_BLOCK_H_
+
+#include <skein.h> /* get the Skein API definitions   */
+
+void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr,
+                               size_t blkCnt, size_t byteCntAdd);
+void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr,
+                               size_t blkCnt, size_t byteCntAdd);
+void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr,
+                               size_t blkCnt, size_t byteCntAdd);
+
+#endif
diff --git a/drivers/staging/skein/include/skein_iv.h b/drivers/staging/skein/include/skein_iv.h
new file mode 100644 (file)
index 0000000..8dd5e4d
--- /dev/null
@@ -0,0 +1,186 @@
+#ifndef _SKEIN_IV_H_
+#define _SKEIN_IV_H_
+
+#include <skein.h>    /* get Skein macros and types */
+
+/*
+***************** Pre-computed Skein IVs *******************
+**
+** NOTE: these values are not "magic" constants, but
+** are generated using the Threefish block function.
+** They are pre-computed here only for speed; i.e., to
+** avoid the need for a Threefish call during Init().
+**
+** The IV for any fixed hash length may be pre-computed.
+** Only the most common values are included here.
+**
+************************************************************
+**/
+
+#define MK_64 SKEIN_MK_64
+
+/* blkSize =  256 bits. hashSize =  128 bits */
+const u64 SKEIN_256_IV_128[] = {
+       MK_64(0xE1111906, 0x964D7260),
+       MK_64(0x883DAAA7, 0x7C8D811C),
+       MK_64(0x10080DF4, 0x91960F7A),
+       MK_64(0xCCF7DDE5, 0xB45BC1C2)
+};
+
+/* blkSize =  256 bits. hashSize =  160 bits */
+const u64 SKEIN_256_IV_160[] = {
+       MK_64(0x14202314, 0x72825E98),
+       MK_64(0x2AC4E9A2, 0x5A77E590),
+       MK_64(0xD47A5856, 0x8838D63E),
+       MK_64(0x2DD2E496, 0x8586AB7D)
+};
+
+/* blkSize =  256 bits. hashSize =  224 bits */
+const u64 SKEIN_256_IV_224[] = {
+       MK_64(0xC6098A8C, 0x9AE5EA0B),
+       MK_64(0x876D5686, 0x08C5191C),
+       MK_64(0x99CB88D7, 0xD7F53884),
+       MK_64(0x384BDDB1, 0xAEDDB5DE)
+};
+
+/* blkSize =  256 bits. hashSize =  256 bits */
+const u64 SKEIN_256_IV_256[] = {
+       MK_64(0xFC9DA860, 0xD048B449),
+       MK_64(0x2FCA6647, 0x9FA7D833),
+       MK_64(0xB33BC389, 0x6656840F),
+       MK_64(0x6A54E920, 0xFDE8DA69)
+};
+
+/* blkSize =  512 bits. hashSize =  128 bits */
+const u64 SKEIN_512_IV_128[] = {
+       MK_64(0xA8BC7BF3, 0x6FBF9F52),
+       MK_64(0x1E9872CE, 0xBD1AF0AA),
+       MK_64(0x309B1790, 0xB32190D3),
+       MK_64(0xBCFBB854, 0x3F94805C),
+       MK_64(0x0DA61BCD, 0x6E31B11B),
+       MK_64(0x1A18EBEA, 0xD46A32E3),
+       MK_64(0xA2CC5B18, 0xCE84AA82),
+       MK_64(0x6982AB28, 0x9D46982D)
+};
+
+/* blkSize =  512 bits. hashSize =  160 bits */
+const u64 SKEIN_512_IV_160[] = {
+       MK_64(0x28B81A2A, 0xE013BD91),
+       MK_64(0xC2F11668, 0xB5BDF78F),
+       MK_64(0x1760D8F3, 0xF6A56F12),
+       MK_64(0x4FB74758, 0x8239904F),
+       MK_64(0x21EDE07F, 0x7EAF5056),
+       MK_64(0xD908922E, 0x63ED70B8),
+       MK_64(0xB8EC76FF, 0xECCB52FA),
+       MK_64(0x01A47BB8, 0xA3F27A6E)
+};
+
+/* blkSize =  512 bits. hashSize =  224 bits */
+const u64 SKEIN_512_IV_224[] = {
+       MK_64(0xCCD06162, 0x48677224),
+       MK_64(0xCBA65CF3, 0xA92339EF),
+       MK_64(0x8CCD69D6, 0x52FF4B64),
+       MK_64(0x398AED7B, 0x3AB890B4),
+       MK_64(0x0F59D1B1, 0x457D2BD0),
+       MK_64(0x6776FE65, 0x75D4EB3D),
+       MK_64(0x99FBC70E, 0x997413E9),
+       MK_64(0x9E2CFCCF, 0xE1C41EF7)
+};
+
+/* blkSize =  512 bits. hashSize =  256 bits */
+const u64 SKEIN_512_IV_256[] = {
+       MK_64(0xCCD044A1, 0x2FDB3E13),
+       MK_64(0xE8359030, 0x1A79A9EB),
+       MK_64(0x55AEA061, 0x4F816E6F),
+       MK_64(0x2A2767A4, 0xAE9B94DB),
+       MK_64(0xEC06025E, 0x74DD7683),
+       MK_64(0xE7A436CD, 0xC4746251),
+       MK_64(0xC36FBAF9, 0x393AD185),
+       MK_64(0x3EEDBA18, 0x33EDFC13)
+};
+
+/* blkSize =  512 bits. hashSize =  384 bits */
+const u64 SKEIN_512_IV_384[] = {
+       MK_64(0xA3F6C6BF, 0x3A75EF5F),
+       MK_64(0xB0FEF9CC, 0xFD84FAA4),
+       MK_64(0x9D77DD66, 0x3D770CFE),
+       MK_64(0xD798CBF3, 0xB468FDDA),
+       MK_64(0x1BC4A666, 0x8A0E4465),
+       MK_64(0x7ED7D434, 0xE5807407),
+       MK_64(0x548FC1AC, 0xD4EC44D6),
+       MK_64(0x266E1754, 0x6AA18FF8)
+};
+
+/* blkSize =  512 bits. hashSize =  512 bits */
+const u64 SKEIN_512_IV_512[] = {
+       MK_64(0x4903ADFF, 0x749C51CE),
+       MK_64(0x0D95DE39, 0x9746DF03),
+       MK_64(0x8FD19341, 0x27C79BCE),
+       MK_64(0x9A255629, 0xFF352CB1),
+       MK_64(0x5DB62599, 0xDF6CA7B0),
+       MK_64(0xEABE394C, 0xA9D5C3F4),
+       MK_64(0x991112C7, 0x1A75B523),
+       MK_64(0xAE18A40B, 0x660FCC33)
+};
+
+/* blkSize = 1024 bits. hashSize =  384 bits */
+const u64 SKEIN1024_IV_384[] = {
+       MK_64(0x5102B6B8, 0xC1894A35),
+       MK_64(0xFEEBC9E3, 0xFE8AF11A),
+       MK_64(0x0C807F06, 0xE32BED71),
+       MK_64(0x60C13A52, 0xB41A91F6),
+       MK_64(0x9716D35D, 0xD4917C38),
+       MK_64(0xE780DF12, 0x6FD31D3A),
+       MK_64(0x797846B6, 0xC898303A),
+       MK_64(0xB172C2A8, 0xB3572A3B),
+       MK_64(0xC9BC8203, 0xA6104A6C),
+       MK_64(0x65909338, 0xD75624F4),
+       MK_64(0x94BCC568, 0x4B3F81A0),
+       MK_64(0x3EBBF51E, 0x10ECFD46),
+       MK_64(0x2DF50F0B, 0xEEB08542),
+       MK_64(0x3B5A6530, 0x0DBC6516),
+       MK_64(0x484B9CD2, 0x167BBCE1),
+       MK_64(0x2D136947, 0xD4CBAFEA)
+};
+
+/* blkSize = 1024 bits. hashSize =  512 bits */
+const u64 SKEIN1024_IV_512[] = {
+       MK_64(0xCAEC0E5D, 0x7C1B1B18),
+       MK_64(0xA01B0E04, 0x5F03E802),
+       MK_64(0x33840451, 0xED912885),
+       MK_64(0x374AFB04, 0xEAEC2E1C),
+       MK_64(0xDF25A0E2, 0x813581F7),
+       MK_64(0xE4004093, 0x8B12F9D2),
+       MK_64(0xA662D539, 0xC2ED39B6),
+       MK_64(0xFA8B85CF, 0x45D8C75A),
+       MK_64(0x8316ED8E, 0x29EDE796),
+       MK_64(0x053289C0, 0x2E9F91B8),
+       MK_64(0xC3F8EF1D, 0x6D518B73),
+       MK_64(0xBDCEC3C4, 0xD5EF332E),
+       MK_64(0x549A7E52, 0x22974487),
+       MK_64(0x67070872, 0x5B749816),
+       MK_64(0xB9CD28FB, 0xF0581BD1),
+       MK_64(0x0E2940B8, 0x15804974)
+};
+
+/* blkSize = 1024 bits. hashSize = 1024 bits */
+const u64 SKEIN1024_IV_1024[] = {
+       MK_64(0xD593DA07, 0x41E72355),
+       MK_64(0x15B5E511, 0xAC73E00C),
+       MK_64(0x5180E5AE, 0xBAF2C4F0),
+       MK_64(0x03BD41D3, 0xFCBCAFAF),
+       MK_64(0x1CAEC6FD, 0x1983A898),
+       MK_64(0x6E510B8B, 0xCDD0589F),
+       MK_64(0x77E2BDFD, 0xC6394ADA),
+       MK_64(0xC11E1DB5, 0x24DCB0A3),
+       MK_64(0xD6D14AF9, 0xC6329AB5),
+       MK_64(0x6A9B0BFC, 0x6EB67E0D),
+       MK_64(0x9243C60D, 0xCCFF1332),
+       MK_64(0x1A1F1DDE, 0x743F02D4),
+       MK_64(0x0996753C, 0x10ED0BB8),
+       MK_64(0x6572DD22, 0xF2B4969A),
+       MK_64(0x61FD3062, 0xD00A579A),
+       MK_64(0x1DE0536E, 0x8682E539)
+};
+
+#endif /* _SKEIN_IV_H_ */
diff --git a/drivers/staging/skein/include/threefishApi.h b/drivers/staging/skein/include/threefishApi.h
new file mode 100644 (file)
index 0000000..e81675d
--- /dev/null
@@ -0,0 +1,164 @@
+
+#ifndef THREEFISHAPI_H
+#define THREEFISHAPI_H
+
+/**
+ * @file threefishApi.h
+ * @brief A Threefish cipher API and its functions.
+ * @{
+ *
+ * This API and the functions that implement this API simplify the usage
+ * of the Threefish cipher. The design and the way to use the functions
+ * follow the openSSL design but at the same time take care of some Threefish
+ * specific behaviour and possibilities.
+ *
+ * These are the low level functions that deal with Threefisch blocks only.
+ * Implementations for cipher modes such as ECB, CFB, or CBC may use these
+ * functions.
+ *
+@code
+    // Threefish cipher context data
+    struct threefish_key keyCtx;
+
+    // Initialize the context
+    threefishSetKey(&keyCtx, Threefish512, key, tweak);
+
+    // Encrypt
+    threefishEncryptBlockBytes(&keyCtx, input, cipher);
+@endcode
+ */
+
+#include <linux/types.h>
+#include <skein.h>
+
+#define KeyScheduleConst 0x1BD11BDAA9FC1A22L
+
+/**
+ * Which Threefish size to use
+ */
+enum threefish_size {
+       Threefish256 = 256,     /*!< Skein with 256 bit state */
+       Threefish512 = 512,     /*!< Skein with 512 bit state */
+       Threefish1024 = 1024    /*!< Skein with 1024 bit state */
+};
+
+/**
+ * Context for Threefish key and tweak words.
+ *
+ * This structure was setup with some know-how of the internal
+ * Skein structures, in particular ordering of header and size dependent
+ * variables. If Skein implementation changes this, the adapt these
+ * structures as well.
+ */
+struct threefish_key {
+       u64 stateSize;
+       u64 key[SKEIN_MAX_STATE_WORDS+1];   /* max number of key words*/
+       u64 tweak[3];
+};
+
+/**
+ * Set Threefish key and tweak data.
+ *
+ * This function sets the key and tweak data for the Threefish cipher of
+ * the given size. The key data must have the same length (number of bits)
+ * as the state size
+ *
+ * @param keyCtx
+ *     Pointer to a Threefish key structure.
+ * @param size
+ *     Which Skein size to use.
+ * @param keyData
+ *     Pointer to the key words (word has 64 bits).
+ * @param tweak
+ *     Pointer to the two tweak words (word has 64 bits).
+ */
+void threefishSetKey(struct threefish_key *keyCtx,
+                       enum threefish_size stateSize,
+                       u64 *keyData, u64 *tweak);
+
+/**
+ * Encrypt Threefisch block (bytes).
+ *
+ * The buffer must have at least the same length (number of bits) aas the
+ * state size for this key. The function uses the first @c stateSize bits
+ * of the input buffer, encrypts them and stores the result in the output
+ * buffer.
+ *
+ * @param keyCtx
+ *     Pointer to a Threefish key structure.
+ * @param in
+ *     Poionter to plaintext data buffer.
+ * @param out
+ *     Pointer to cipher buffer.
+ */
+void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out);
+
+/**
+ * Encrypt Threefisch block (words).
+ *
+ * The buffer must have at least the same length (number of bits) aas the
+ * state size for this key. The function uses the first @c stateSize bits
+ * of the input buffer, encrypts them and stores the result in the output
+ * buffer.
+ *
+ * The wordsize ist set to 64 bits.
+ *
+ * @param keyCtx
+ *     Pointer to a Threefish key structure.
+ * @param in
+ *     Poionter to plaintext data buffer.
+ * @param out
+ *     Pointer to cipher buffer.
+ */
+void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in,
+                               u64 *out);
+
+/**
+ * Decrypt Threefisch block (bytes).
+ *
+ * The buffer must have at least the same length (number of bits) aas the
+ * state size for this key. The function uses the first @c stateSize bits
+ * of the input buffer, decrypts them and stores the result in the output
+ * buffer
+ *
+ * @param keyCtx
+ *     Pointer to a Threefish key structure.
+ * @param in
+ *     Poionter to cipher data buffer.
+ * @param out
+ *     Pointer to plaintext buffer.
+ */
+void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out);
+
+/**
+ * Decrypt Threefisch block (words).
+ *
+ * The buffer must have at least the same length (number of bits) aas the
+ * state size for this key. The function uses the first @c stateSize bits
+ * of the input buffer, encrypts them and stores the result in the output
+ * buffer.
+ *
+ * The wordsize ist set to 64 bits.
+ *
+ * @param keyCtx
+ *     Pointer to a Threefish key structure.
+ * @param in
+ *     Poionter to cipher data buffer.
+ * @param out
+ *     Pointer to plaintext buffer.
+ */
+void threefishDecryptBlockWords(struct threefish_key *keyCtx, u64 *in,
+                               u64 *out);
+
+void threefishEncrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output);
+void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output);
+void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input,
+                       u64 *output);
+void threefishDecrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output);
+void threefishDecrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output);
+void threefishDecrypt1024(struct threefish_key *keyCtx, u64 *input,
+                       u64 *output);
+/**
+ * @}
+ */
+#endif
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
new file mode 100644 (file)
index 0000000..096b86b
--- /dev/null
@@ -0,0 +1,880 @@
+/***********************************************************************
+**
+** Implementation of the Skein hash function.
+**
+** Source code author: Doug Whiting, 2008.
+**
+** This algorithm and source code is released to the public domain.
+**
+************************************************************************/
+
+#define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
+
+#include <linux/string.h>       /* get the memcpy/memset functions */
+#include <skein.h> /* get the Skein API definitions   */
+#include <skein_iv.h>    /* get precomputed IVs */
+#include <skein_block.h>
+
+/*****************************************************************/
+/*     256-bit Skein                                             */
+/*****************************************************************/
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* init the context for a straight hashing operation  */
+int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen)
+{
+       union {
+               u8  b[SKEIN_256_STATE_BYTES];
+               u64  w[SKEIN_256_STATE_WORDS];
+       } cfg;                              /* config block */
+
+       Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN);
+       ctx->h.hashBitLen = hashBitLen;         /* output hash bit count */
+
+       switch (hashBitLen) { /* use pre-computed values, where available */
+       case  256:
+               memcpy(ctx->X, SKEIN_256_IV_256, sizeof(ctx->X));
+               break;
+       case  224:
+               memcpy(ctx->X, SKEIN_256_IV_224, sizeof(ctx->X));
+               break;
+       case  160:
+               memcpy(ctx->X, SKEIN_256_IV_160, sizeof(ctx->X));
+               break;
+       case  128:
+               memcpy(ctx->X, SKEIN_256_IV_128, sizeof(ctx->X));
+               break;
+       default:
+               /* here if there is no precomputed IV value available */
+               /*
+                * build/process the config block, type == CONFIG (could be
+                * precomputed)
+                */
+               /* set tweaks: T0=0; T1=CFG | FINAL */
+               Skein_Start_New_Type(ctx, CFG_FINAL);
+
+               /* set the schema, version */
+               cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER);
+               /* hash result length in bits */
+               cfg.w[1] = Skein_Swap64(hashBitLen);
+               cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
+               /* zero pad config block */
+               memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0]));
+
+               /* compute the initial chaining values from config block */
+               /* zero the chaining variables */
+               memset(ctx->X, 0, sizeof(ctx->X));
+               Skein_256_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
+               break;
+       }
+       /* The chaining vars ctx->X are now initialized for hashBitLen. */
+       /* Set up to process the data message portion of the hash (default) */
+       Skein_Start_New_Type(ctx, MSG);              /* T0=0, T1= MSG type */
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* init the context for a MAC and/or tree hash operation */
+/* [identical to Skein_256_Init() when keyBytes == 0 && \
+ *     treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
+int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen,
+                       u64 treeInfo, const u8 *key, size_t keyBytes)
+{
+       union {
+               u8  b[SKEIN_256_STATE_BYTES];
+               u64  w[SKEIN_256_STATE_WORDS];
+       } cfg; /* config block */
+
+       Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN);
+       Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL);
+
+       /* compute the initial chaining values ctx->X[], based on key */
+       if (keyBytes == 0) { /* is there a key? */
+               /* no key: use all zeroes as key for config block */
+               memset(ctx->X, 0, sizeof(ctx->X));
+       } else { /* here to pre-process a key */
+               Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X));
+               /* do a mini-Init right here */
+               /* set output hash bit count = state size */
+               ctx->h.hashBitLen = 8*sizeof(ctx->X);
+               /* set tweaks: T0 = 0; T1 = KEY type */
+               Skein_Start_New_Type(ctx, KEY);
+               /* zero the initial chaining variables */
+               memset(ctx->X, 0, sizeof(ctx->X));
+               /* hash the key */
+               Skein_256_Update(ctx, key, keyBytes);
+               /* put result into cfg.b[] */
+               Skein_256_Final_Pad(ctx, cfg.b);
+               /* copy over into ctx->X[] */
+               memcpy(ctx->X, cfg.b, sizeof(cfg.b));
+       }
+       /*
+        * build/process the config block, type == CONFIG (could be
+        * precomputed for each key)
+        */
+       /* output hash bit count */
+       ctx->h.hashBitLen = hashBitLen;
+       Skein_Start_New_Type(ctx, CFG_FINAL);
+
+       /* pre-pad cfg.w[] with zeroes */
+       memset(&cfg.w, 0, sizeof(cfg.w));
+       cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER);
+       /* hash result length in bits */
+       cfg.w[1] = Skein_Swap64(hashBitLen);
+       /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
+       cfg.w[2] = Skein_Swap64(treeInfo);
+
+       Skein_Show_Key(256, &ctx->h, key, keyBytes);
+
+       /* compute the initial chaining values from config block */
+       Skein_256_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
+
+       /* The chaining vars ctx->X are now initialized */
+       /* Set up to process the data message portion of the hash (default) */
+       Skein_Start_New_Type(ctx, MSG);
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* process the input bytes */
+int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg,
+                       size_t msgByteCnt)
+{
+       size_t n;
+
+       /* catch uninitialized context */
+       Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* process full blocks, if any */
+       if (msgByteCnt + ctx->h.bCnt > SKEIN_256_BLOCK_BYTES) {
+               /* finish up any buffered message data */
+               if (ctx->h.bCnt) {
+                       /* # bytes free in buffer b[] */
+                       n = SKEIN_256_BLOCK_BYTES - ctx->h.bCnt;
+                       if (n) {
+                               /* check on our logic here */
+                               Skein_assert(n < msgByteCnt);
+                               memcpy(&ctx->b[ctx->h.bCnt], msg, n);
+                               msgByteCnt  -= n;
+                               msg         += n;
+                               ctx->h.bCnt += n;
+                       }
+                       Skein_assert(ctx->h.bCnt == SKEIN_256_BLOCK_BYTES);
+                       Skein_256_Process_Block(ctx, ctx->b, 1,
+                                               SKEIN_256_BLOCK_BYTES);
+                       ctx->h.bCnt = 0;
+               }
+               /*
+                * now process any remaining full blocks, directly from input
+                * message data
+                */
+               if (msgByteCnt > SKEIN_256_BLOCK_BYTES) {
+                       /* number of full blocks to process */
+                       n = (msgByteCnt-1) / SKEIN_256_BLOCK_BYTES;
+                       Skein_256_Process_Block(ctx, msg, n,
+                                               SKEIN_256_BLOCK_BYTES);
+                       msgByteCnt -= n * SKEIN_256_BLOCK_BYTES;
+                       msg        += n * SKEIN_256_BLOCK_BYTES;
+               }
+               Skein_assert(ctx->h.bCnt == 0);
+       }
+
+       /* copy any remaining source message data bytes into b[] */
+       if (msgByteCnt) {
+               Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES);
+               memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt);
+               ctx->h.bCnt += msgByteCnt;
+       }
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* finalize the hash computation and output the result */
+int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal)
+{
+       size_t i, n, byteCnt;
+       u64 X[SKEIN_256_STATE_WORDS];
+       /* catch uninitialized context */
+       Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* tag as the final block */
+       ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL;
+       /* zero pad b[] if necessary */
+       if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES)
+               memset(&ctx->b[ctx->h.bCnt], 0,
+                       SKEIN_256_BLOCK_BYTES - ctx->h.bCnt);
+
+       /* process the final block */
+       Skein_256_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt);
+
+       /* now output the result */
+       /* total number of output bytes */
+       byteCnt = (ctx->h.hashBitLen + 7) >> 3;
+
+       /* run Threefish in "counter mode" to generate output */
+       /* zero out b[], so it can hold the counter */
+       memset(ctx->b, 0, sizeof(ctx->b));
+       /* keep a local copy of counter mode "key" */
+       memcpy(X, ctx->X, sizeof(X));
+       for (i = 0; i*SKEIN_256_BLOCK_BYTES < byteCnt; i++) {
+               /* build the counter block */
+               ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i);
+               Skein_Start_New_Type(ctx, OUT_FINAL);
+               /* run "counter mode" */
+               Skein_256_Process_Block(ctx, ctx->b, 1, sizeof(u64));
+               /* number of output bytes left to go */
+               n = byteCnt - i*SKEIN_256_BLOCK_BYTES;
+               if (n >= SKEIN_256_BLOCK_BYTES)
+                       n  = SKEIN_256_BLOCK_BYTES;
+               /* "output" the ctr mode bytes */
+               Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES, ctx->X,
+                                     n);
+               Skein_Show_Final(256, &ctx->h, n,
+                                hashVal+i*SKEIN_256_BLOCK_BYTES);
+               /* restore the counter mode key for next time */
+               memcpy(ctx->X, X, sizeof(X));
+       }
+       return SKEIN_SUCCESS;
+}
+
+/*****************************************************************/
+/*     512-bit Skein                                             */
+/*****************************************************************/
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* init the context for a straight hashing operation  */
+int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen)
+{
+       union {
+               u8  b[SKEIN_512_STATE_BYTES];
+               u64  w[SKEIN_512_STATE_WORDS];
+       } cfg;                              /* config block */
+
+       Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN);
+       ctx->h.hashBitLen = hashBitLen;         /* output hash bit count */
+
+       switch (hashBitLen) { /* use pre-computed values, where available */
+       case  512:
+               memcpy(ctx->X, SKEIN_512_IV_512, sizeof(ctx->X));
+               break;
+       case  384:
+               memcpy(ctx->X, SKEIN_512_IV_384, sizeof(ctx->X));
+               break;
+       case  256:
+               memcpy(ctx->X, SKEIN_512_IV_256, sizeof(ctx->X));
+               break;
+       case  224:
+               memcpy(ctx->X, SKEIN_512_IV_224, sizeof(ctx->X));
+               break;
+       default:
+               /* here if there is no precomputed IV value available */
+               /*
+                * build/process the config block, type == CONFIG (could be
+                * precomputed)
+                */
+               /* set tweaks: T0=0; T1=CFG | FINAL */
+               Skein_Start_New_Type(ctx, CFG_FINAL);
+
+               /* set the schema, version */
+               cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER);
+               /* hash result length in bits */
+               cfg.w[1] = Skein_Swap64(hashBitLen);
+               cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
+               /* zero pad config block */
+               memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0]));
+
+               /* compute the initial chaining values from config block */
+               /* zero the chaining variables */
+               memset(ctx->X, 0, sizeof(ctx->X));
+               Skein_512_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
+               break;
+       }
+
+       /*
+        * The chaining vars ctx->X are now initialized for the given
+        * hashBitLen.
+        */
+       /* Set up to process the data message portion of the hash (default) */
+       Skein_Start_New_Type(ctx, MSG);              /* T0=0, T1= MSG type */
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* init the context for a MAC and/or tree hash operation */
+/* [identical to Skein_512_Init() when keyBytes == 0 && \
+ *     treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
+int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen,
+                       u64 treeInfo, const u8 *key, size_t keyBytes)
+{
+       union {
+               u8  b[SKEIN_512_STATE_BYTES];
+               u64  w[SKEIN_512_STATE_WORDS];
+       } cfg;                              /* config block */
+
+       Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN);
+       Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL);
+
+       /* compute the initial chaining values ctx->X[], based on key */
+       if (keyBytes == 0) { /* is there a key? */
+               /* no key: use all zeroes as key for config block */
+               memset(ctx->X, 0, sizeof(ctx->X));
+       } else { /* here to pre-process a key */
+               Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X));
+               /* do a mini-Init right here */
+               /* set output hash bit count = state size */
+               ctx->h.hashBitLen = 8*sizeof(ctx->X);
+               /* set tweaks: T0 = 0; T1 = KEY type */
+               Skein_Start_New_Type(ctx, KEY);
+               /* zero the initial chaining variables */
+               memset(ctx->X, 0, sizeof(ctx->X));
+               /* hash the key */
+               Skein_512_Update(ctx, key, keyBytes);
+               /* put result into cfg.b[] */
+               Skein_512_Final_Pad(ctx, cfg.b);
+               /* copy over into ctx->X[] */
+               memcpy(ctx->X, cfg.b, sizeof(cfg.b));
+       }
+       /*
+        * build/process the config block, type == CONFIG (could be
+        * precomputed for each key)
+        */
+       ctx->h.hashBitLen = hashBitLen;             /* output hash bit count */
+       Skein_Start_New_Type(ctx, CFG_FINAL);
+
+       /* pre-pad cfg.w[] with zeroes */
+       memset(&cfg.w, 0, sizeof(cfg.w));
+       cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER);
+       /* hash result length in bits */
+       cfg.w[1] = Skein_Swap64(hashBitLen);
+       /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
+       cfg.w[2] = Skein_Swap64(treeInfo);
+
+       Skein_Show_Key(512, &ctx->h, key, keyBytes);
+
+       /* compute the initial chaining values from config block */
+       Skein_512_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
+
+       /* The chaining vars ctx->X are now initialized */
+       /* Set up to process the data message portion of the hash (default) */
+       Skein_Start_New_Type(ctx, MSG);
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* process the input bytes */
+int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg,
+                       size_t msgByteCnt)
+{
+       size_t n;
+
+       /* catch uninitialized context */
+       Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* process full blocks, if any */
+       if (msgByteCnt + ctx->h.bCnt > SKEIN_512_BLOCK_BYTES) {
+               /* finish up any buffered message data */
+               if (ctx->h.bCnt) {
+                       /* # bytes free in buffer b[] */
+                       n = SKEIN_512_BLOCK_BYTES - ctx->h.bCnt;
+                       if (n) {
+                               /* check on our logic here */
+                               Skein_assert(n < msgByteCnt);
+                               memcpy(&ctx->b[ctx->h.bCnt], msg, n);
+                               msgByteCnt  -= n;
+                               msg         += n;
+                               ctx->h.bCnt += n;
+                       }
+                       Skein_assert(ctx->h.bCnt == SKEIN_512_BLOCK_BYTES);
+                       Skein_512_Process_Block(ctx, ctx->b, 1,
+                                               SKEIN_512_BLOCK_BYTES);
+                       ctx->h.bCnt = 0;
+               }
+               /*
+                * now process any remaining full blocks, directly from input
+                * message data
+                */
+               if (msgByteCnt > SKEIN_512_BLOCK_BYTES) {
+                       /* number of full blocks to process */
+                       n = (msgByteCnt-1) / SKEIN_512_BLOCK_BYTES;
+                       Skein_512_Process_Block(ctx, msg, n,
+                                               SKEIN_512_BLOCK_BYTES);
+                       msgByteCnt -= n * SKEIN_512_BLOCK_BYTES;
+                       msg        += n * SKEIN_512_BLOCK_BYTES;
+               }
+               Skein_assert(ctx->h.bCnt == 0);
+       }
+
+       /* copy any remaining source message data bytes into b[] */
+       if (msgByteCnt) {
+               Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES);
+               memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt);
+               ctx->h.bCnt += msgByteCnt;
+       }
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* finalize the hash computation and output the result */
+int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal)
+{
+       size_t i, n, byteCnt;
+       u64 X[SKEIN_512_STATE_WORDS];
+       /* catch uninitialized context */
+       Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* tag as the final block */
+       ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL;
+       /* zero pad b[] if necessary */
+       if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES)
+               memset(&ctx->b[ctx->h.bCnt], 0,
+                       SKEIN_512_BLOCK_BYTES - ctx->h.bCnt);
+
+       /* process the final block */
+       Skein_512_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt);
+
+       /* now output the result */
+       /* total number of output bytes */
+       byteCnt = (ctx->h.hashBitLen + 7) >> 3;
+
+       /* run Threefish in "counter mode" to generate output */
+       /* zero out b[], so it can hold the counter */
+       memset(ctx->b, 0, sizeof(ctx->b));
+       /* keep a local copy of counter mode "key" */
+       memcpy(X, ctx->X, sizeof(X));
+       for (i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++) {
+               /* build the counter block */
+               ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i);
+               Skein_Start_New_Type(ctx, OUT_FINAL);
+               /* run "counter mode" */
+               Skein_512_Process_Block(ctx, ctx->b, 1, sizeof(u64));
+               /* number of output bytes left to go */
+               n = byteCnt - i*SKEIN_512_BLOCK_BYTES;
+               if (n >= SKEIN_512_BLOCK_BYTES)
+                       n  = SKEIN_512_BLOCK_BYTES;
+               /* "output" the ctr mode bytes */
+               Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES, ctx->X,
+                                     n);
+               Skein_Show_Final(512, &ctx->h, n,
+                                hashVal+i*SKEIN_512_BLOCK_BYTES);
+               /* restore the counter mode key for next time */
+               memcpy(ctx->X, X, sizeof(X));
+       }
+       return SKEIN_SUCCESS;
+}
+
+/*****************************************************************/
+/*    1024-bit Skein                                             */
+/*****************************************************************/
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* init the context for a straight hashing operation  */
+int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen)
+{
+       union {
+               u8  b[SKEIN1024_STATE_BYTES];
+               u64  w[SKEIN1024_STATE_WORDS];
+       } cfg;                              /* config block */
+
+       Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN);
+       ctx->h.hashBitLen = hashBitLen;         /* output hash bit count */
+
+       switch (hashBitLen) { /* use pre-computed values, where available */
+       case  512:
+               memcpy(ctx->X, SKEIN1024_IV_512, sizeof(ctx->X));
+               break;
+       case  384:
+               memcpy(ctx->X, SKEIN1024_IV_384, sizeof(ctx->X));
+               break;
+       case 1024:
+               memcpy(ctx->X, SKEIN1024_IV_1024, sizeof(ctx->X));
+               break;
+       default:
+               /* here if there is no precomputed IV value available */
+               /*
+                * build/process the config block, type == CONFIG
+                * (could be precomputed)
+                */
+               /* set tweaks: T0=0; T1=CFG | FINAL */
+               Skein_Start_New_Type(ctx, CFG_FINAL);
+
+               /* set the schema, version */
+               cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER);
+               /* hash result length in bits */
+               cfg.w[1] = Skein_Swap64(hashBitLen);
+               cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
+               /* zero pad config block */
+               memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0]));
+
+               /* compute the initial chaining values from config block */
+               /* zero the chaining variables */
+               memset(ctx->X, 0, sizeof(ctx->X));
+               Skein1024_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
+               break;
+       }
+
+       /* The chaining vars ctx->X are now initialized for the hashBitLen. */
+       /* Set up to process the data message portion of the hash (default) */
+       Skein_Start_New_Type(ctx, MSG);              /* T0=0, T1= MSG type */
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* init the context for a MAC and/or tree hash operation */
+/* [identical to Skein1024_Init() when keyBytes == 0 && \
+ *     treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
+int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen,
+                       u64 treeInfo, const u8 *key, size_t keyBytes)
+{
+       union {
+               u8  b[SKEIN1024_STATE_BYTES];
+               u64  w[SKEIN1024_STATE_WORDS];
+       } cfg;                              /* config block */
+
+       Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN);
+       Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL);
+
+       /* compute the initial chaining values ctx->X[], based on key */
+       if (keyBytes == 0) { /* is there a key? */
+               /* no key: use all zeroes as key for config block */
+               memset(ctx->X, 0, sizeof(ctx->X));
+       } else { /* here to pre-process a key */
+               Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X));
+               /* do a mini-Init right here */
+               /* set output hash bit count = state size */
+               ctx->h.hashBitLen = 8*sizeof(ctx->X);
+               /* set tweaks: T0 = 0; T1 = KEY type */
+               Skein_Start_New_Type(ctx, KEY);
+               /* zero the initial chaining variables */
+               memset(ctx->X, 0, sizeof(ctx->X));
+               /* hash the key */
+               Skein1024_Update(ctx, key, keyBytes);
+               /* put result into cfg.b[] */
+               Skein1024_Final_Pad(ctx, cfg.b);
+               /* copy over into ctx->X[] */
+               memcpy(ctx->X, cfg.b, sizeof(cfg.b));
+       }
+       /*
+        * build/process the config block, type == CONFIG (could be
+        * precomputed for each key)
+        */
+       /* output hash bit count */
+       ctx->h.hashBitLen = hashBitLen;
+       Skein_Start_New_Type(ctx, CFG_FINAL);
+
+       /* pre-pad cfg.w[] with zeroes */
+       memset(&cfg.w, 0, sizeof(cfg.w));
+       cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER);
+       /* hash result length in bits */
+       cfg.w[1] = Skein_Swap64(hashBitLen);
+       /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
+       cfg.w[2] = Skein_Swap64(treeInfo);
+
+       Skein_Show_Key(1024, &ctx->h, key, keyBytes);
+
+       /* compute the initial chaining values from config block */
+       Skein1024_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
+
+       /* The chaining vars ctx->X are now initialized */
+       /* Set up to process the data message portion of the hash (default) */
+       Skein_Start_New_Type(ctx, MSG);
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* process the input bytes */
+int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg,
+                       size_t msgByteCnt)
+{
+       size_t n;
+
+       /* catch uninitialized context */
+       Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* process full blocks, if any */
+       if (msgByteCnt + ctx->h.bCnt > SKEIN1024_BLOCK_BYTES) {
+               /* finish up any buffered message data */
+               if (ctx->h.bCnt) {
+                       /* # bytes free in buffer b[] */
+                       n = SKEIN1024_BLOCK_BYTES - ctx->h.bCnt;
+                       if (n) {
+                               /* check on our logic here */
+                               Skein_assert(n < msgByteCnt);
+                               memcpy(&ctx->b[ctx->h.bCnt], msg, n);
+                               msgByteCnt  -= n;
+                               msg         += n;
+                               ctx->h.bCnt += n;
+                       }
+                       Skein_assert(ctx->h.bCnt == SKEIN1024_BLOCK_BYTES);
+                       Skein1024_Process_Block(ctx, ctx->b, 1,
+                                               SKEIN1024_BLOCK_BYTES);
+                       ctx->h.bCnt = 0;
+               }
+               /*
+                * now process any remaining full blocks, directly from input
+                * message data
+                */
+               if (msgByteCnt > SKEIN1024_BLOCK_BYTES) {
+                       /* number of full blocks to process */
+                       n = (msgByteCnt-1) / SKEIN1024_BLOCK_BYTES;
+                       Skein1024_Process_Block(ctx, msg, n,
+                                               SKEIN1024_BLOCK_BYTES);
+                       msgByteCnt -= n * SKEIN1024_BLOCK_BYTES;
+                       msg        += n * SKEIN1024_BLOCK_BYTES;
+               }
+               Skein_assert(ctx->h.bCnt == 0);
+       }
+
+       /* copy any remaining source message data bytes into b[] */
+       if (msgByteCnt) {
+               Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES);
+               memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt);
+               ctx->h.bCnt += msgByteCnt;
+       }
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* finalize the hash computation and output the result */
+int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal)
+{
+       size_t i, n, byteCnt;
+       u64 X[SKEIN1024_STATE_WORDS];
+       /* catch uninitialized context */
+       Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* tag as the final block */
+       ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL;
+       /* zero pad b[] if necessary */
+       if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES)
+               memset(&ctx->b[ctx->h.bCnt], 0,
+                       SKEIN1024_BLOCK_BYTES - ctx->h.bCnt);
+
+       /* process the final block */
+       Skein1024_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt);
+
+       /* now output the result */
+       /* total number of output bytes */
+       byteCnt = (ctx->h.hashBitLen + 7) >> 3;
+
+       /* run Threefish in "counter mode" to generate output */
+       /* zero out b[], so it can hold the counter */
+       memset(ctx->b, 0, sizeof(ctx->b));
+       /* keep a local copy of counter mode "key" */
+       memcpy(X, ctx->X, sizeof(X));
+       for (i = 0; i*SKEIN1024_BLOCK_BYTES < byteCnt; i++) {
+               /* build the counter block */
+               ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i);
+               Skein_Start_New_Type(ctx, OUT_FINAL);
+               /* run "counter mode" */
+               Skein1024_Process_Block(ctx, ctx->b, 1, sizeof(u64));
+               /* number of output bytes left to go */
+               n = byteCnt - i*SKEIN1024_BLOCK_BYTES;
+               if (n >= SKEIN1024_BLOCK_BYTES)
+                       n  = SKEIN1024_BLOCK_BYTES;
+               /* "output" the ctr mode bytes */
+               Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES, ctx->X,
+                                     n);
+               Skein_Show_Final(1024, &ctx->h, n,
+                                hashVal+i*SKEIN1024_BLOCK_BYTES);
+               /* restore the counter mode key for next time */
+               memcpy(ctx->X, X, sizeof(X));
+       }
+       return SKEIN_SUCCESS;
+}
+
+/**************** Functions to support MAC/tree hashing ***************/
+/*   (this code is identical for Optimized and Reference versions)    */
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* finalize the hash computation and output the block, no OUTPUT stage */
+int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal)
+{
+       /* catch uninitialized context */
+       Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* tag as the final block */
+       ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL;
+       /* zero pad b[] if necessary */
+       if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES)
+               memset(&ctx->b[ctx->h.bCnt], 0,
+                       SKEIN_256_BLOCK_BYTES - ctx->h.bCnt);
+       /* process the final block */
+       Skein_256_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt);
+
+       /* "output" the state bytes */
+       Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_256_BLOCK_BYTES);
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* finalize the hash computation and output the block, no OUTPUT stage */
+int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal)
+{
+       /* catch uninitialized context */
+       Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* tag as the final block */
+       ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL;
+       /* zero pad b[] if necessary */
+       if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES)
+               memset(&ctx->b[ctx->h.bCnt], 0,
+                       SKEIN_512_BLOCK_BYTES - ctx->h.bCnt);
+       /* process the final block */
+       Skein_512_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt);
+
+       /* "output" the state bytes */
+       Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_512_BLOCK_BYTES);
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* finalize the hash computation and output the block, no OUTPUT stage */
+int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal)
+{
+       /* catch uninitialized context */
+       Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* tag as the final block */
+       ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL;
+       /* zero pad b[] if necessary */
+       if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES)
+               memset(&ctx->b[ctx->h.bCnt], 0,
+                       SKEIN1024_BLOCK_BYTES - ctx->h.bCnt);
+       /* process the final block */
+       Skein1024_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt);
+
+       /* "output" the state bytes */
+       Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN1024_BLOCK_BYTES);
+
+       return SKEIN_SUCCESS;
+}
+
+#if SKEIN_TREE_HASH
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* just do the OUTPUT stage                                       */
+int Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal)
+{
+       size_t i, n, byteCnt;
+       u64 X[SKEIN_256_STATE_WORDS];
+       /* catch uninitialized context */
+       Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* now output the result */
+       /* total number of output bytes */
+       byteCnt = (ctx->h.hashBitLen + 7) >> 3;
+
+       /* run Threefish in "counter mode" to generate output */
+       /* zero out b[], so it can hold the counter */
+       memset(ctx->b, 0, sizeof(ctx->b));
+       /* keep a local copy of counter mode "key" */
+       memcpy(X, ctx->X, sizeof(X));
+       for (i = 0; i*SKEIN_256_BLOCK_BYTES < byteCnt; i++) {
+               /* build the counter block */
+               ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i);
+               Skein_Start_New_Type(ctx, OUT_FINAL);
+               /* run "counter mode" */
+               Skein_256_Process_Block(ctx, ctx->b, 1, sizeof(u64));
+               /* number of output bytes left to go */
+               n = byteCnt - i*SKEIN_256_BLOCK_BYTES;
+               if (n >= SKEIN_256_BLOCK_BYTES)
+                       n  = SKEIN_256_BLOCK_BYTES;
+               /* "output" the ctr mode bytes */
+               Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES, ctx->X,
+                                     n);
+               Skein_Show_Final(256, &ctx->h, n,
+                                hashVal+i*SKEIN_256_BLOCK_BYTES);
+               /* restore the counter mode key for next time */
+               memcpy(ctx->X, X, sizeof(X));
+       }
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* just do the OUTPUT stage                                       */
+int Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal)
+{
+       size_t i, n, byteCnt;
+       u64 X[SKEIN_512_STATE_WORDS];
+       /* catch uninitialized context */
+       Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* now output the result */
+       /* total number of output bytes */
+       byteCnt = (ctx->h.hashBitLen + 7) >> 3;
+
+       /* run Threefish in "counter mode" to generate output */
+       /* zero out b[], so it can hold the counter */
+       memset(ctx->b, 0, sizeof(ctx->b));
+       /* keep a local copy of counter mode "key" */
+       memcpy(X, ctx->X, sizeof(X));
+       for (i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++) {
+               /* build the counter block */
+               ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i);
+               Skein_Start_New_Type(ctx, OUT_FINAL);
+               /* run "counter mode" */
+               Skein_512_Process_Block(ctx, ctx->b, 1, sizeof(u64));
+               /* number of output bytes left to go */
+               n = byteCnt - i*SKEIN_512_BLOCK_BYTES;
+               if (n >= SKEIN_512_BLOCK_BYTES)
+                       n  = SKEIN_512_BLOCK_BYTES;
+               /* "output" the ctr mode bytes */
+               Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES, ctx->X,
+                                     n);
+               Skein_Show_Final(256, &ctx->h, n,
+                                hashVal+i*SKEIN_512_BLOCK_BYTES);
+               /* restore the counter mode key for next time */
+               memcpy(ctx->X, X, sizeof(X));
+       }
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* just do the OUTPUT stage                                       */
+int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal)
+{
+       size_t i, n, byteCnt;
+       u64 X[SKEIN1024_STATE_WORDS];
+       /* catch uninitialized context */
+       Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* now output the result */
+       /* total number of output bytes */
+       byteCnt = (ctx->h.hashBitLen + 7) >> 3;
+
+       /* run Threefish in "counter mode" to generate output */
+       /* zero out b[], so it can hold the counter */
+       memset(ctx->b, 0, sizeof(ctx->b));
+       /* keep a local copy of counter mode "key" */
+       memcpy(X, ctx->X, sizeof(X));
+       for (i = 0; i*SKEIN1024_BLOCK_BYTES < byteCnt; i++) {
+               /* build the counter block */
+               ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i);
+               Skein_Start_New_Type(ctx, OUT_FINAL);
+               /* run "counter mode" */
+               Skein1024_Process_Block(ctx, ctx->b, 1, sizeof(u64));
+               /* number of output bytes left to go */
+               n = byteCnt - i*SKEIN1024_BLOCK_BYTES;
+               if (n >= SKEIN1024_BLOCK_BYTES)
+                       n  = SKEIN1024_BLOCK_BYTES;
+               /* "output" the ctr mode bytes */
+               Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES, ctx->X,
+                                     n);
+               Skein_Show_Final(256, &ctx->h, n,
+                                hashVal+i*SKEIN1024_BLOCK_BYTES);
+               /* restore the counter mode key for next time */
+               memcpy(ctx->X, X, sizeof(X));
+       }
+       return SKEIN_SUCCESS;
+}
+#endif
diff --git a/drivers/staging/skein/skeinApi.c b/drivers/staging/skein/skeinApi.c
new file mode 100644 (file)
index 0000000..dd109bf
--- /dev/null
@@ -0,0 +1,237 @@
+/*
+Copyright (c) 2010 Werner Dittmann
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+*/
+
+#include <linux/string.h>
+#include <skeinApi.h>
+
+int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size)
+{
+       Skein_Assert(ctx && size, SKEIN_FAIL);
+
+       memset(ctx , 0, sizeof(struct skein_ctx));
+       ctx->skeinSize = size;
+
+       return SKEIN_SUCCESS;
+}
+
+int skeinInit(struct skein_ctx *ctx, size_t hashBitLen)
+{
+       int ret = SKEIN_FAIL;
+       size_t Xlen = 0;
+       u64 *X = NULL;
+       u64 treeInfo = SKEIN_CFG_TREE_INFO_SEQUENTIAL;
+
+       Skein_Assert(ctx, SKEIN_FAIL);
+       /*
+        * The following two lines rely of the fact that the real Skein
+        * contexts are a union in out context and thus have tha maximum
+        * memory available.  The beauty of C :-) .
+        */
+       X = ctx->m.s256.X;
+       Xlen = ctx->skeinSize/8;
+       /*
+        * If size is the same and hash bit length is zero then reuse
+        * the save chaining variables.
+        */
+       switch (ctx->skeinSize) {
+       case Skein256:
+               ret = Skein_256_InitExt(&ctx->m.s256, hashBitLen,
+                                       treeInfo, NULL, 0);
+               break;
+       case Skein512:
+               ret = Skein_512_InitExt(&ctx->m.s512, hashBitLen,
+                                       treeInfo, NULL, 0);
+               break;
+       case Skein1024:
+               ret = Skein1024_InitExt(&ctx->m.s1024, hashBitLen,
+                                       treeInfo, NULL, 0);
+               break;
+       }
+
+       if (ret == SKEIN_SUCCESS) {
+               /*
+                * Save chaining variables for this combination of size and
+                * hashBitLen
+                */
+               memcpy(ctx->XSave, X, Xlen);
+       }
+       return ret;
+}
+
+int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen,
+               size_t hashBitLen)
+{
+       int ret = SKEIN_FAIL;
+       u64 *X = NULL;
+       size_t Xlen = 0;
+       u64 treeInfo = SKEIN_CFG_TREE_INFO_SEQUENTIAL;
+
+       Skein_Assert(ctx, SKEIN_FAIL);
+
+       X = ctx->m.s256.X;
+       Xlen = ctx->skeinSize/8;
+
+       Skein_Assert(hashBitLen, SKEIN_BAD_HASHLEN);
+
+       switch (ctx->skeinSize) {
+       case Skein256:
+               ret = Skein_256_InitExt(&ctx->m.s256, hashBitLen,
+                                       treeInfo,
+                                       (const u8 *)key, keyLen);
+
+               break;
+       case Skein512:
+               ret = Skein_512_InitExt(&ctx->m.s512, hashBitLen,
+                                       treeInfo,
+                                       (const u8 *)key, keyLen);
+               break;
+       case Skein1024:
+               ret = Skein1024_InitExt(&ctx->m.s1024, hashBitLen,
+                                       treeInfo,
+                                       (const u8 *)key, keyLen);
+
+               break;
+       }
+       if (ret == SKEIN_SUCCESS) {
+               /*
+                * Save chaining variables for this combination of key,
+                * keyLen, hashBitLen
+                */
+               memcpy(ctx->XSave, X, Xlen);
+       }
+       return ret;
+}
+
+void skeinReset(struct skein_ctx *ctx)
+{
+       size_t Xlen = 0;
+       u64 *X = NULL;
+
+       /*
+        * The following two lines rely of the fact that the real Skein
+        * contexts are a union in out context and thus have tha maximum
+        * memory available.  The beautiy of C :-) .
+        */
+       X = ctx->m.s256.X;
+       Xlen = ctx->skeinSize/8;
+       /* Restore the chaing variable, reset byte counter */
+       memcpy(X, ctx->XSave, Xlen);
+
+       /* Setup context to process the message */
+       Skein_Start_New_Type(&ctx->m, MSG);
+}
+
+int skeinUpdate(struct skein_ctx *ctx, const u8 *msg,
+               size_t msgByteCnt)
+{
+       int ret = SKEIN_FAIL;
+       Skein_Assert(ctx, SKEIN_FAIL);
+
+       switch (ctx->skeinSize) {
+       case Skein256:
+               ret = Skein_256_Update(&ctx->m.s256, (const u8 *)msg,
+                                       msgByteCnt);
+               break;
+       case Skein512:
+               ret = Skein_512_Update(&ctx->m.s512, (const u8 *)msg,
+                                       msgByteCnt);
+               break;
+       case Skein1024:
+               ret = Skein1024_Update(&ctx->m.s1024, (const u8 *)msg,
+                                       msgByteCnt);
+               break;
+       }
+       return ret;
+
+}
+
+int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg,
+                       size_t msgBitCnt)
+{
+       /*
+        * I've used the bit pad implementation from skein_test.c (see NIST CD)
+        * and modified it to use the convenience functions and added some
+        * pointer arithmetic.
+        */
+       size_t length;
+       u8 mask;
+       u8 *up;
+
+       /*
+        * only the final Update() call is allowed do partial bytes, else
+        * assert an error
+        */
+       Skein_Assert((ctx->m.h.T[1] & SKEIN_T1_FLAG_BIT_PAD) == 0 ||
+                       msgBitCnt == 0, SKEIN_FAIL);
+
+       /* if number of bits is a multiple of bytes - that's easy */
+       if ((msgBitCnt & 0x7) == 0)
+               return skeinUpdate(ctx, msg, msgBitCnt >> 3);
+
+       skeinUpdate(ctx, msg, (msgBitCnt >> 3) + 1);
+
+       /*
+        * The next line rely on the fact that the real Skein contexts
+        * are a union in our context. After the addition the pointer points to
+        * Skein's real partial block buffer.
+        * If this layout ever changes we have to adapt this as well.
+        */
+       up = (u8 *)ctx->m.s256.X + ctx->skeinSize / 8;
+
+       /* set tweak flag for the skeinFinal call */
+       Skein_Set_Bit_Pad_Flag(ctx->m.h);
+
+       /* now "pad" the final partial byte the way NIST likes */
+       /* get the bCnt value (same location for all block sizes) */
+       length = ctx->m.h.bCnt;
+       /* internal sanity check: there IS a partial byte in the buffer! */
+       Skein_assert(length != 0);
+       /* partial byte bit mask */
+       mask = (u8) (1u << (7 - (msgBitCnt & 7)));
+       /* apply bit padding on final byte (in the buffer) */
+       up[length-1]  = (u8)((up[length-1] & (0-mask))|mask);
+
+       return SKEIN_SUCCESS;
+}
+
+int skeinFinal(struct skein_ctx *ctx, u8 *hash)
+{
+       int ret = SKEIN_FAIL;
+       Skein_Assert(ctx, SKEIN_FAIL);
+
+       switch (ctx->skeinSize) {
+       case Skein256:
+               ret = Skein_256_Final(&ctx->m.s256, (u8 *)hash);
+               break;
+       case Skein512:
+               ret = Skein_512_Final(&ctx->m.s512, (u8 *)hash);
+               break;
+       case Skein1024:
+               ret = Skein1024_Final(&ctx->m.s1024, (u8 *)hash);
+               break;
+       }
+       return ret;
+}
diff --git a/drivers/staging/skein/skeinBlockNo3F.c b/drivers/staging/skein/skeinBlockNo3F.c
new file mode 100644 (file)
index 0000000..6917638
--- /dev/null
@@ -0,0 +1,175 @@
+
+#include <linux/string.h>
+#include <skein.h>
+#include <threefishApi.h>
+
+
+/*****************************  Skein_256 ******************************/
+void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr,
+                               size_t blkCnt, size_t byteCntAdd)
+{
+       struct threefish_key key;
+       u64 tweak[2];
+       int i;
+       u64  w[SKEIN_256_STATE_WORDS]; /* local copy of input block */
+       u64 words[3];
+
+       Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */
+       tweak[0] = ctx->h.T[0];
+       tweak[1] = ctx->h.T[1];
+
+       do  {
+               u64 carry = byteCntAdd;
+
+               words[0] = tweak[0] & 0xffffffffL;
+               words[1] = ((tweak[0] >> 32) & 0xffffffffL);
+               words[2] = (tweak[1] & 0xffffffffL);
+
+               for (i = 0; i < 3; i++) {
+                       carry += words[i];
+                       words[i] = carry;
+                       carry >>= 32;
+               }
+               tweak[0] = words[0] & 0xffffffffL;
+               tweak[0] |= (words[1] & 0xffffffffL) << 32;
+               tweak[1] |= words[2] & 0xffffffffL;
+
+               threefishSetKey(&key, Threefish256, ctx->X, tweak);
+
+               /* get input block in little-endian format */
+               Skein_Get64_LSB_First(w, blkPtr, SKEIN_256_STATE_WORDS);
+
+               threefishEncryptBlockWords(&key, w, ctx->X);
+
+               blkPtr += SKEIN_256_BLOCK_BYTES;
+
+               /* do the final "feedforward" xor, update ctx chaining vars */
+               ctx->X[0] = ctx->X[0] ^ w[0];
+               ctx->X[1] = ctx->X[1] ^ w[1];
+               ctx->X[2] = ctx->X[2] ^ w[2];
+               ctx->X[3] = ctx->X[3] ^ w[3];
+
+               tweak[1] &= ~SKEIN_T1_FLAG_FIRST;
+       } while (--blkCnt);
+
+       ctx->h.T[0] = tweak[0];
+       ctx->h.T[1] = tweak[1];
+}
+
+void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr,
+                               size_t blkCnt, size_t byteCntAdd)
+{
+       struct threefish_key key;
+       u64 tweak[2];
+       int i;
+       u64 words[3];
+       u64  w[SKEIN_512_STATE_WORDS]; /* local copy of input block */
+
+       Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */
+       tweak[0] = ctx->h.T[0];
+       tweak[1] = ctx->h.T[1];
+
+       do  {
+               u64 carry = byteCntAdd;
+
+               words[0] = tweak[0] & 0xffffffffL;
+               words[1] = ((tweak[0] >> 32) & 0xffffffffL);
+               words[2] = (tweak[1] & 0xffffffffL);
+
+               for (i = 0; i < 3; i++) {
+                       carry += words[i];
+                       words[i] = carry;
+                       carry >>= 32;
+               }
+               tweak[0] = words[0] & 0xffffffffL;
+               tweak[0] |= (words[1] & 0xffffffffL) << 32;
+               tweak[1] |= words[2] & 0xffffffffL;
+
+               threefishSetKey(&key, Threefish512, ctx->X, tweak);
+
+               /* get input block in little-endian format */
+               Skein_Get64_LSB_First(w, blkPtr, SKEIN_512_STATE_WORDS);
+
+               threefishEncryptBlockWords(&key, w, ctx->X);
+
+               blkPtr += SKEIN_512_BLOCK_BYTES;
+
+               /* do the final "feedforward" xor, update ctx chaining vars */
+               ctx->X[0] = ctx->X[0] ^ w[0];
+               ctx->X[1] = ctx->X[1] ^ w[1];
+               ctx->X[2] = ctx->X[2] ^ w[2];
+               ctx->X[3] = ctx->X[3] ^ w[3];
+               ctx->X[4] = ctx->X[4] ^ w[4];
+               ctx->X[5] = ctx->X[5] ^ w[5];
+               ctx->X[6] = ctx->X[6] ^ w[6];
+               ctx->X[7] = ctx->X[7] ^ w[7];
+
+               tweak[1] &= ~SKEIN_T1_FLAG_FIRST;
+       } while (--blkCnt);
+
+       ctx->h.T[0] = tweak[0];
+       ctx->h.T[1] = tweak[1];
+}
+
+void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr,
+                               size_t blkCnt, size_t byteCntAdd)
+{
+       struct threefish_key key;
+       u64 tweak[2];
+       int i;
+       u64 words[3];
+       u64  w[SKEIN1024_STATE_WORDS]; /* local copy of input block */
+
+       Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */
+       tweak[0] = ctx->h.T[0];
+       tweak[1] = ctx->h.T[1];
+
+       do  {
+               u64 carry = byteCntAdd;
+
+               words[0] = tweak[0] & 0xffffffffL;
+               words[1] = ((tweak[0] >> 32) & 0xffffffffL);
+               words[2] = (tweak[1] & 0xffffffffL);
+
+               for (i = 0; i < 3; i++) {
+                       carry += words[i];
+                       words[i] = carry;
+                       carry >>= 32;
+               }
+               tweak[0] = words[0] & 0xffffffffL;
+               tweak[0] |= (words[1] & 0xffffffffL) << 32;
+               tweak[1] |= words[2] & 0xffffffffL;
+
+               threefishSetKey(&key, Threefish1024, ctx->X, tweak);
+
+               /* get input block in little-endian format */
+               Skein_Get64_LSB_First(w, blkPtr, SKEIN1024_STATE_WORDS);
+
+               threefishEncryptBlockWords(&key, w, ctx->X);
+
+               blkPtr += SKEIN1024_BLOCK_BYTES;
+
+               /* do the final "feedforward" xor, update ctx chaining vars */
+               ctx->X[0]  = ctx->X[0]  ^ w[0];
+               ctx->X[1]  = ctx->X[1]  ^ w[1];
+               ctx->X[2]  = ctx->X[2]  ^ w[2];
+               ctx->X[3]  = ctx->X[3]  ^ w[3];
+               ctx->X[4]  = ctx->X[4]  ^ w[4];
+               ctx->X[5]  = ctx->X[5]  ^ w[5];
+               ctx->X[6]  = ctx->X[6]  ^ w[6];
+               ctx->X[7]  = ctx->X[7]  ^ w[7];
+               ctx->X[8]  = ctx->X[8]  ^ w[8];
+               ctx->X[9]  = ctx->X[9]  ^ w[9];
+               ctx->X[10] = ctx->X[10] ^ w[10];
+               ctx->X[11] = ctx->X[11] ^ w[11];
+               ctx->X[12] = ctx->X[12] ^ w[12];
+               ctx->X[13] = ctx->X[13] ^ w[13];
+               ctx->X[14] = ctx->X[14] ^ w[14];
+               ctx->X[15] = ctx->X[15] ^ w[15];
+
+               tweak[1] &= ~SKEIN_T1_FLAG_FIRST;
+       } while (--blkCnt);
+
+       ctx->h.T[0] = tweak[0];
+       ctx->h.T[1] = tweak[1];
+}
diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c
new file mode 100644 (file)
index 0000000..fd96ca0
--- /dev/null
@@ -0,0 +1,770 @@
+/***********************************************************************
+**
+** Implementation of the Skein block functions.
+**
+** Source code author: Doug Whiting, 2008.
+**
+** This algorithm and source code is released to the public domain.
+**
+** Compile-time switches:
+**
+**  SKEIN_USE_ASM  -- set bits (256/512/1024) to select which
+**                    versions use ASM code for block processing
+**                    [default: use C for all block sizes]
+**
+************************************************************************/
+
+#include <linux/string.h>
+#include <skein.h>
+
+#ifndef SKEIN_USE_ASM
+#define SKEIN_USE_ASM   (0) /* default is all C code (no ASM) */
+#endif
+
+#ifndef SKEIN_LOOP
+#define SKEIN_LOOP 001 /* default: unroll 256 and 512, but not 1024 */
+#endif
+
+#define BLK_BITS        (WCNT*64) /* some useful definitions for code here */
+#define KW_TWK_BASE     (0)
+#define KW_KEY_BASE     (3)
+#define ks              (kw + KW_KEY_BASE)
+#define ts              (kw + KW_TWK_BASE)
+
+#ifdef SKEIN_DEBUG
+#define DebugSaveTweak(ctx) { ctx->h.T[0] = ts[0]; ctx->h.T[1] = ts[1]; }
+#else
+#define DebugSaveTweak(ctx)
+#endif
+
+/*****************************  Skein_256 ******************************/
+#if !(SKEIN_USE_ASM & 256)
+void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr,
+                               size_t blkCnt, size_t byteCntAdd)
+       { /* do it in C */
+       enum {
+               WCNT = SKEIN_256_STATE_WORDS
+       };
+#undef  RCNT
+#define RCNT  (SKEIN_256_ROUNDS_TOTAL/8)
+
+#ifdef SKEIN_LOOP /* configure how much to unroll the loop */
+#define SKEIN_UNROLL_256 (((SKEIN_LOOP)/100)%10)
+#else
+#define SKEIN_UNROLL_256 (0)
+#endif
+
+#if SKEIN_UNROLL_256
+#if (RCNT % SKEIN_UNROLL_256)
+#error "Invalid SKEIN_UNROLL_256" /* sanity check on unroll count */
+#endif
+       size_t  r;
+       u64  kw[WCNT+4+RCNT*2]; /* key schedule: chaining vars + tweak + "rot"*/
+#else
+       u64  kw[WCNT+4]; /* key schedule words : chaining vars + tweak */
+#endif
+       u64  X0, X1, X2, X3; /* local copy of context vars, for speed */
+       u64  w[WCNT]; /* local copy of input block */
+#ifdef SKEIN_DEBUG
+       const u64 *Xptr[4]; /* use for debugging (help cc put Xn in regs) */
+       Xptr[0] = &X0;  Xptr[1] = &X1;  Xptr[2] = &X2;  Xptr[3] = &X3;
+#endif
+       Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */
+       ts[0] = ctx->h.T[0];
+       ts[1] = ctx->h.T[1];
+       do  {
+               /*
+                * this implementation only supports 2**64 input bytes
+                * (no carry out here)
+                */
+               ts[0] += byteCntAdd; /* update processed length */
+
+               /* precompute the key schedule for this block */
+               ks[0] = ctx->X[0];
+               ks[1] = ctx->X[1];
+               ks[2] = ctx->X[2];
+               ks[3] = ctx->X[3];
+               ks[4] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ SKEIN_KS_PARITY;
+
+               ts[2] = ts[0] ^ ts[1];
+
+               /* get input block in little-endian format */
+               Skein_Get64_LSB_First(w, blkPtr, WCNT);
+               DebugSaveTweak(ctx);
+               Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blkPtr, w, ks, ts);
+
+               X0 = w[0] + ks[0]; /* do the first full key injection */
+               X1 = w[1] + ks[1] + ts[0];
+               X2 = w[2] + ks[2] + ts[1];
+               X3 = w[3] + ks[3];
+
+               /* show starting state values */
+               Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL,
+                                Xptr);
+
+               blkPtr += SKEIN_256_BLOCK_BYTES;
+
+               /* run the rounds */
+
+#define Round256(p0, p1, p2, p3, ROT, rNum)                              \
+do { \
+       X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \
+       X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \
+} while (0)
+
+#if SKEIN_UNROLL_256 == 0
+#define R256(p0, p1, p2, p3, ROT, rNum) /* fully unrolled */ \
+do { \
+       Round256(p0, p1, p2, p3, ROT, rNum) \
+       Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); \
+} while (0)
+
+#define I256(R) \
+do { \
+       /* inject the key schedule value */ \
+       X0   += ks[((R)+1) % 5]; \
+       X1   += ks[((R)+2) % 5] + ts[((R)+1) % 3]; \
+       X2   += ks[((R)+3) % 5] + ts[((R)+2) % 3]; \
+       X3   += ks[((R)+4) % 5] +     (R)+1;       \
+       Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \
+} while (0)
+#else /* looping version */
+#define R256(p0, p1, p2, p3, ROT, rNum) \
+do { \
+       Round256(p0, p1, p2, p3, ROT, rNum) \
+       Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); \
+} while (0)
+
+#define I256(R) \
+do { \
+       /* inject the key schedule value */ \
+       X0   += ks[r+(R)+0]; \
+       X1   += ks[r+(R)+1] + ts[r+(R)+0]; \
+       X2   += ks[r+(R)+2] + ts[r+(R)+1]; \
+       X3   += ks[r+(R)+3] +    r+(R);    \
+       /* rotate key schedule */ \
+       ks[r + (R) + 4]   = ks[r + (R) - 1]; \
+       ts[r + (R) + 2]   = ts[r + (R) - 1]; \
+       Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \
+} while (0)
+
+       for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_256)
+#endif
+               {
+#define R256_8_rounds(R)                  \
+do { \
+               R256(0, 1, 2, 3, R_256_0, 8 * (R) + 1);  \
+               R256(0, 3, 2, 1, R_256_1, 8 * (R) + 2);  \
+               R256(0, 1, 2, 3, R_256_2, 8 * (R) + 3);  \
+               R256(0, 3, 2, 1, R_256_3, 8 * (R) + 4);  \
+               I256(2 * (R));                      \
+               R256(0, 1, 2, 3, R_256_4, 8 * (R) + 5);  \
+               R256(0, 3, 2, 1, R_256_5, 8 * (R) + 6);  \
+               R256(0, 1, 2, 3, R_256_6, 8 * (R) + 7);  \
+               R256(0, 3, 2, 1, R_256_7, 8 * (R) + 8);  \
+               I256(2 * (R) + 1); \
+} while (0)
+
+               R256_8_rounds(0);
+
+#define R256_Unroll_R(NN) \
+       ((SKEIN_UNROLL_256 == 0 && \
+         SKEIN_256_ROUNDS_TOTAL/8 > (NN)) || \
+        (SKEIN_UNROLL_256 > (NN)))
+
+       #if   R256_Unroll_R(1)
+               R256_8_rounds(1);
+       #endif
+       #if   R256_Unroll_R(2)
+               R256_8_rounds(2);
+       #endif
+       #if   R256_Unroll_R(3)
+               R256_8_rounds(3);
+       #endif
+       #if   R256_Unroll_R(4)
+               R256_8_rounds(4);
+       #endif
+       #if   R256_Unroll_R(5)
+               R256_8_rounds(5);
+       #endif
+       #if   R256_Unroll_R(6)
+               R256_8_rounds(6);
+       #endif
+       #if   R256_Unroll_R(7)
+               R256_8_rounds(7);
+       #endif
+       #if   R256_Unroll_R(8)
+               R256_8_rounds(8);
+       #endif
+       #if   R256_Unroll_R(9)
+               R256_8_rounds(9);
+       #endif
+       #if   R256_Unroll_R(10)
+               R256_8_rounds(10);
+       #endif
+       #if   R256_Unroll_R(11)
+               R256_8_rounds(11);
+       #endif
+       #if   R256_Unroll_R(12)
+               R256_8_rounds(12);
+       #endif
+       #if   R256_Unroll_R(13)
+               R256_8_rounds(13);
+       #endif
+       #if   R256_Unroll_R(14)
+               R256_8_rounds(14);
+       #endif
+       #if  (SKEIN_UNROLL_256 > 14)
+#error  "need more unrolling in Skein_256_Process_Block"
+       #endif
+               }
+               /* do the final "feedforward" xor, update context chaining */
+               ctx->X[0] = X0 ^ w[0];
+               ctx->X[1] = X1 ^ w[1];
+               ctx->X[2] = X2 ^ w[2];
+               ctx->X[3] = X3 ^ w[3];
+
+               Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X);
+
+               ts[1] &= ~SKEIN_T1_FLAG_FIRST;
+       } while (--blkCnt);
+       ctx->h.T[0] = ts[0];
+       ctx->h.T[1] = ts[1];
+}
+
+#if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF)
+size_t Skein_256_Process_Block_CodeSize(void)
+{
+       return ((u8 *) Skein_256_Process_Block_CodeSize) -
+               ((u8 *) Skein_256_Process_Block);
+}
+unsigned int Skein_256_Unroll_Cnt(void)
+{
+       return SKEIN_UNROLL_256;
+}
+#endif
+#endif
+
+/*****************************  Skein_512 ******************************/
+#if !(SKEIN_USE_ASM & 512)
+void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr,
+                               size_t blkCnt, size_t byteCntAdd)
+{ /* do it in C */
+       enum {
+               WCNT = SKEIN_512_STATE_WORDS
+       };
+#undef  RCNT
+#define RCNT  (SKEIN_512_ROUNDS_TOTAL/8)
+
+#ifdef SKEIN_LOOP /* configure how much to unroll the loop */
+#define SKEIN_UNROLL_512 (((SKEIN_LOOP)/10)%10)
+#else
+#define SKEIN_UNROLL_512 (0)
+#endif
+
+#if SKEIN_UNROLL_512
+#if (RCNT % SKEIN_UNROLL_512)
+#error "Invalid SKEIN_UNROLL_512" /* sanity check on unroll count */
+#endif
+       size_t  r;
+       u64  kw[WCNT+4+RCNT*2]; /* key sched: chaining vars + tweak + "rot"*/
+#else
+       u64  kw[WCNT+4]; /* key schedule words : chaining vars + tweak */
+#endif
+       u64  X0, X1, X2, X3, X4, X5, X6, X7; /* local copies, for speed */
+       u64  w[WCNT]; /* local copy of input block */
+#ifdef SKEIN_DEBUG
+       const u64 *Xptr[8]; /* use for debugging (help cc put Xn in regs) */
+       Xptr[0] = &X0;  Xptr[1] = &X1;  Xptr[2] = &X2;  Xptr[3] = &X3;
+       Xptr[4] = &X4;  Xptr[5] = &X5;  Xptr[6] = &X6;  Xptr[7] = &X7;
+#endif
+
+       Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */
+       ts[0] = ctx->h.T[0];
+       ts[1] = ctx->h.T[1];
+       do  {
+               /*
+                * this implementation only supports 2**64 input bytes
+                * (no carry out here)
+                */
+               ts[0] += byteCntAdd; /* update processed length */
+
+               /* precompute the key schedule for this block */
+               ks[0] = ctx->X[0];
+               ks[1] = ctx->X[1];
+               ks[2] = ctx->X[2];
+               ks[3] = ctx->X[3];
+               ks[4] = ctx->X[4];
+               ks[5] = ctx->X[5];
+               ks[6] = ctx->X[6];
+               ks[7] = ctx->X[7];
+               ks[8] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^
+                       ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ SKEIN_KS_PARITY;
+
+               ts[2] = ts[0] ^ ts[1];
+
+               /* get input block in little-endian format */
+               Skein_Get64_LSB_First(w, blkPtr, WCNT);
+               DebugSaveTweak(ctx);
+               Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blkPtr, w, ks, ts);
+
+               X0   = w[0] + ks[0]; /* do the first full key injection */
+               X1   = w[1] + ks[1];
+               X2   = w[2] + ks[2];
+               X3   = w[3] + ks[3];
+               X4   = w[4] + ks[4];
+               X5   = w[5] + ks[5] + ts[0];
+               X6   = w[6] + ks[6] + ts[1];
+               X7   = w[7] + ks[7];
+
+               blkPtr += SKEIN_512_BLOCK_BYTES;
+
+               Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL,
+                                Xptr);
+               /* run the rounds */
+#define Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \
+do { \
+       X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \
+       X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \
+       X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4; \
+       X##p6 += X##p7; X##p7 = RotL_64(X##p7, ROT##_3); X##p7 ^= X##p6; \
+} while (0)
+
+#if SKEIN_UNROLL_512 == 0
+#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) /* unrolled */ \
+do { \
+       Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \
+       Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); \
+} while (0)
+
+#define I512(R) \
+do { \
+       /* inject the key schedule value */ \
+       X0   += ks[((R) + 1) % 9]; \
+       X1   += ks[((R) + 2) % 9]; \
+       X2   += ks[((R) + 3) % 9]; \
+       X3   += ks[((R) + 4) % 9]; \
+       X4   += ks[((R) + 5) % 9]; \
+       X5   += ks[((R) + 6) % 9] + ts[((R) + 1) % 3]; \
+       X6   += ks[((R) + 7) % 9] + ts[((R) + 2) % 3]; \
+       X7   += ks[((R) + 8) % 9] +     (R) + 1;       \
+       Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \
+} while (0)
+#else /* looping version */
+#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \
+do { \
+       Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \
+       Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); \
+} while (0)
+
+#define I512(R) \
+do { \
+       /* inject the key schedule value */ \
+       X0   += ks[r + (R) + 0]; \
+       X1   += ks[r + (R) + 1]; \
+       X2   += ks[r + (R) + 2]; \
+       X3   += ks[r + (R) + 3]; \
+       X4   += ks[r + (R) + 4]; \
+       X5   += ks[r + (R) + 5] + ts[r + (R) + 0]; \
+       X6   += ks[r + (R) + 6] + ts[r + (R) + 1]; \
+       X7   += ks[r + (R) + 7] +         r + (R); \
+       /* rotate key schedule */ \
+       ks[r +         (R) + 8] = ks[r + (R) - 1]; \
+       ts[r +         (R) + 2] = ts[r + (R) - 1]; \
+       Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \
+} while (0)
+
+               for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_512)
+#endif /* end of looped code definitions */
+               {
+#define R512_8_rounds(R)  /* do 8 full rounds */  \
+do { \
+               R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_0, 8 * (R) + 1);   \
+               R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_1, 8 * (R) + 2);   \
+               R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_2, 8 * (R) + 3);   \
+               R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_3, 8 * (R) + 4);   \
+               I512(2 * (R));                              \
+               R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_4, 8 * (R) + 5);   \
+               R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_5, 8 * (R) + 6);   \
+               R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_6, 8 * (R) + 7);   \
+               R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_7, 8 * (R) + 8);   \
+               I512(2 * (R) + 1);        /* and key injection */ \
+} while (0)
+
+                       R512_8_rounds(0);
+
+#define R512_Unroll_R(NN) \
+               ((SKEIN_UNROLL_512 == 0 && \
+                 SKEIN_512_ROUNDS_TOTAL/8 > (NN)) || \
+                (SKEIN_UNROLL_512 > (NN)))
+
+       #if   R512_Unroll_R(1)
+                       R512_8_rounds(1);
+       #endif
+       #if   R512_Unroll_R(2)
+                       R512_8_rounds(2);
+       #endif
+       #if   R512_Unroll_R(3)
+                       R512_8_rounds(3);
+       #endif
+       #if   R512_Unroll_R(4)
+                       R512_8_rounds(4);
+       #endif
+       #if   R512_Unroll_R(5)
+                       R512_8_rounds(5);
+       #endif
+       #if   R512_Unroll_R(6)
+                       R512_8_rounds(6);
+       #endif
+       #if   R512_Unroll_R(7)
+                       R512_8_rounds(7);
+       #endif
+       #if   R512_Unroll_R(8)
+                       R512_8_rounds(8);
+       #endif
+       #if   R512_Unroll_R(9)
+                       R512_8_rounds(9);
+       #endif
+       #if   R512_Unroll_R(10)
+                       R512_8_rounds(10);
+       #endif
+       #if   R512_Unroll_R(11)
+                       R512_8_rounds(11);
+       #endif
+       #if   R512_Unroll_R(12)
+                       R512_8_rounds(12);
+       #endif
+       #if   R512_Unroll_R(13)
+                       R512_8_rounds(13);
+       #endif
+       #if   R512_Unroll_R(14)
+                       R512_8_rounds(14);
+       #endif
+       #if  (SKEIN_UNROLL_512 > 14)
+#error  "need more unrolling in Skein_512_Process_Block"
+       #endif
+               }
+
+               /* do the final "feedforward" xor, update context chaining */
+               ctx->X[0] = X0 ^ w[0];
+               ctx->X[1] = X1 ^ w[1];
+               ctx->X[2] = X2 ^ w[2];
+               ctx->X[3] = X3 ^ w[3];
+               ctx->X[4] = X4 ^ w[4];
+               ctx->X[5] = X5 ^ w[5];
+               ctx->X[6] = X6 ^ w[6];
+               ctx->X[7] = X7 ^ w[7];
+               Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X);
+
+               ts[1] &= ~SKEIN_T1_FLAG_FIRST;
+       } while (--blkCnt);
+       ctx->h.T[0] = ts[0];
+       ctx->h.T[1] = ts[1];
+}
+
+#if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF)
+size_t Skein_512_Process_Block_CodeSize(void)
+{
+       return ((u8 *) Skein_512_Process_Block_CodeSize) -
+               ((u8 *) Skein_512_Process_Block);
+}
+unsigned int Skein_512_Unroll_Cnt(void)
+{
+       return SKEIN_UNROLL_512;
+}
+#endif
+#endif
+
+/*****************************  Skein1024 ******************************/
+#if !(SKEIN_USE_ASM & 1024)
+void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr,
+                               size_t blkCnt, size_t byteCntAdd)
+{ /* do it in C, always looping (unrolled is bigger AND slower!) */
+       enum {
+               WCNT = SKEIN1024_STATE_WORDS
+       };
+#undef  RCNT
+#define RCNT  (SKEIN1024_ROUNDS_TOTAL/8)
+
+#ifdef SKEIN_LOOP /* configure how much to unroll the loop */
+#define SKEIN_UNROLL_1024 ((SKEIN_LOOP)%10)
+#else
+#define SKEIN_UNROLL_1024 (0)
+#endif
+
+#if (SKEIN_UNROLL_1024 != 0)
+#if (RCNT % SKEIN_UNROLL_1024)
+#error "Invalid SKEIN_UNROLL_1024" /* sanity check on unroll count */
+#endif
+       size_t  r;
+       u64  kw[WCNT+4+RCNT*2]; /* key sched: chaining vars + tweak + "rot" */
+#else
+       u64  kw[WCNT+4]; /* key schedule words : chaining vars + tweak */
+#endif
+
+       /* local copy of vars, for speed */
+       u64  X00, X01, X02, X03, X04, X05, X06, X07,
+            X08, X09, X10, X11, X12, X13, X14, X15;
+       u64  w[WCNT]; /* local copy of input block */
+#ifdef SKEIN_DEBUG
+       const u64 *Xptr[16]; /* use for debugging (help cc put Xn in regs) */
+       Xptr[0]  = &X00;  Xptr[1]  = &X01;  Xptr[2]  = &X02;  Xptr[3]  = &X03;
+       Xptr[4]  = &X04;  Xptr[5]  = &X05;  Xptr[6]  = &X06;  Xptr[7]  = &X07;
+       Xptr[8]  = &X08;  Xptr[9]  = &X09;  Xptr[10] = &X10;  Xptr[11] = &X11;
+       Xptr[12] = &X12;  Xptr[13] = &X13;  Xptr[14] = &X14;  Xptr[15] = &X15;
+#endif
+
+       Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */
+       ts[0] = ctx->h.T[0];
+       ts[1] = ctx->h.T[1];
+       do  {
+               /*
+                * this implementation only supports 2**64 input bytes
+                * (no carry out here)
+                */
+               ts[0] += byteCntAdd; /* update processed length */
+
+               /* precompute the key schedule for this block */
+               ks[0]  = ctx->X[0];
+               ks[1]  = ctx->X[1];
+               ks[2]  = ctx->X[2];
+               ks[3]  = ctx->X[3];
+               ks[4]  = ctx->X[4];
+               ks[5]  = ctx->X[5];
+               ks[6]  = ctx->X[6];
+               ks[7]  = ctx->X[7];
+               ks[8]  = ctx->X[8];
+               ks[9]  = ctx->X[9];
+               ks[10] = ctx->X[10];
+               ks[11] = ctx->X[11];
+               ks[12] = ctx->X[12];
+               ks[13] = ctx->X[13];
+               ks[14] = ctx->X[14];
+               ks[15] = ctx->X[15];
+               ks[16] =  ks[0] ^  ks[1] ^  ks[2] ^  ks[3] ^
+                         ks[4] ^  ks[5] ^  ks[6] ^  ks[7] ^
+                         ks[8] ^  ks[9] ^ ks[10] ^ ks[11] ^
+                         ks[12] ^ ks[13] ^ ks[14] ^ ks[15] ^ SKEIN_KS_PARITY;
+
+               ts[2]  = ts[0] ^ ts[1];
+
+               /* get input block in little-endian format */
+               Skein_Get64_LSB_First(w, blkPtr, WCNT);
+               DebugSaveTweak(ctx);
+               Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blkPtr, w, ks, ts);
+
+               X00    =  w[0] +  ks[0]; /* do the first full key injection */
+               X01    =  w[1] +  ks[1];
+               X02    =  w[2] +  ks[2];
+               X03    =  w[3] +  ks[3];
+               X04    =  w[4] +  ks[4];
+               X05    =  w[5] +  ks[5];
+               X06    =  w[6] +  ks[6];
+               X07    =  w[7] +  ks[7];
+               X08    =  w[8] +  ks[8];
+               X09    =  w[9] +  ks[9];
+               X10    = w[10] + ks[10];
+               X11    = w[11] + ks[11];
+               X12    = w[12] + ks[12];
+               X13    = w[13] + ks[13] + ts[0];
+               X14    = w[14] + ks[14] + ts[1];
+               X15    = w[15] + ks[15];
+
+               Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL,
+                                Xptr);
+
+#define Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \
+                       pF, ROT, rNum) \
+do { \
+       X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0;   \
+       X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2;   \
+       X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4;   \
+       X##p6 += X##p7; X##p7 = RotL_64(X##p7, ROT##_3); X##p7 ^= X##p6;   \
+       X##p8 += X##p9; X##p9 = RotL_64(X##p9, ROT##_4); X##p9 ^= X##p8;   \
+       X##pA += X##pB; X##pB = RotL_64(X##pB, ROT##_5); X##pB ^= X##pA;   \
+       X##pC += X##pD; X##pD = RotL_64(X##pD, ROT##_6); X##pD ^= X##pC;   \
+       X##pE += X##pF; X##pF = RotL_64(X##pF, ROT##_7); X##pF ^= X##pE;   \
+} while (0)
+
+#if SKEIN_UNROLL_1024 == 0
+#define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, \
+               ROT, rn) \
+do { \
+       Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \
+                       pF, ROT, rn) \
+       Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rn, Xptr); \
+} while (0)
+
+#define I1024(R) \
+do { \
+       /* inject the key schedule value */ \
+       X00   += ks[((R) +  1) % 17]; \
+       X01   += ks[((R) +  2) % 17]; \
+       X02   += ks[((R) +  3) % 17]; \
+       X03   += ks[((R) +  4) % 17]; \
+       X04   += ks[((R) +  5) % 17]; \
+       X05   += ks[((R) +  6) % 17]; \
+       X06   += ks[((R) +  7) % 17]; \
+       X07   += ks[((R) +  8) % 17]; \
+       X08   += ks[((R) +  9) % 17]; \
+       X09   += ks[((R) + 10) % 17]; \
+       X10   += ks[((R) + 11) % 17]; \
+       X11   += ks[((R) + 12) % 17]; \
+       X12   += ks[((R) + 13) % 17]; \
+       X13   += ks[((R) + 14) % 17] + ts[((R) + 1) % 3]; \
+       X14   += ks[((R) + 15) % 17] + ts[((R) + 2) % 3]; \
+       X15   += ks[((R) + 16) % 17] +     (R) + 1;       \
+       Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \
+} while (0)
+#else /* looping version */
+#define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, \
+               ROT, rn) \
+do { \
+       Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \
+                       pF, ROT, rn) \
+       Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rn, Xptr); \
+} while (0)
+
+#define I1024(R) \
+do { \
+       /* inject the key schedule value */ \
+       X00   += ks[r + (R) +  0]; \
+       X01   += ks[r + (R) +  1]; \
+       X02   += ks[r + (R) +  2]; \
+       X03   += ks[r + (R) +  3]; \
+       X04   += ks[r + (R) +  4]; \
+       X05   += ks[r + (R) +  5]; \
+       X06   += ks[r + (R) +  6]; \
+       X07   += ks[r + (R) +  7]; \
+       X08   += ks[r + (R) +  8]; \
+       X09   += ks[r + (R) +  9]; \
+       X10   += ks[r + (R) + 10]; \
+       X11   += ks[r + (R) + 11]; \
+       X12   += ks[r + (R) + 12]; \
+       X13   += ks[r + (R) + 13] + ts[r + (R) + 0]; \
+       X14   += ks[r + (R) + 14] + ts[r + (R) + 1]; \
+       X15   += ks[r + (R) + 15] +         r + (R); \
+       /* rotate key schedule */ \
+       ks[r  +         (R) + 16] = ks[r + (R) - 1]; \
+       ts[r  +         (R) +  2] = ts[r + (R) - 1]; \
+       Skein_Show_R_Ptr(BLK_BITSi, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \
+} while (0)
+
+               for (r = 1; r <= 2 * RCNT; r += 2 * SKEIN_UNROLL_1024)
+#endif
+               {
+#define R1024_8_rounds(R) \
+do { \
+       R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, \
+               R1024_0, 8*(R) + 1); \
+       R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, \
+               R1024_1, 8*(R) + 2); \
+       R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, \
+               R1024_2, 8*(R) + 3); \
+       R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, \
+               R1024_3, 8*(R) + 4); \
+       I1024(2*(R)); \
+       R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, \
+               R1024_4, 8*(R) + 5); \
+       R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, \
+               R1024_5, 8*(R) + 6); \
+       R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, \
+               R1024_6, 8*(R) + 7); \
+       R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, \
+               R1024_7, 8*(R) + 8); \
+       I1024(2*(R)+1); \
+} while (0)
+
+                       R1024_8_rounds(0);
+
+#define R1024_Unroll_R(NN) \
+               ((SKEIN_UNROLL_1024 == 0 && \
+                 SKEIN1024_ROUNDS_TOTAL/8 > (NN)) || \
+                (SKEIN_UNROLL_1024 > (NN)))
+
+       #if   R1024_Unroll_R(1)
+                       R1024_8_rounds(1);
+       #endif
+       #if   R1024_Unroll_R(2)
+                       R1024_8_rounds(2);
+       #endif
+       #if   R1024_Unroll_R(3)
+                       R1024_8_rounds(3);
+       #endif
+       #if   R1024_Unroll_R(4)
+                       R1024_8_rounds(4);
+       #endif
+       #if   R1024_Unroll_R(5)
+                       R1024_8_rounds(5);
+       #endif
+       #if   R1024_Unroll_R(6)
+                       R1024_8_rounds(6);
+       #endif
+       #if   R1024_Unroll_R(7)
+                       R1024_8_rounds(7);
+       #endif
+       #if   R1024_Unroll_R(8)
+                       R1024_8_rounds(8);
+       #endif
+       #if   R1024_Unroll_R(9)
+                       R1024_8_rounds(9);
+       #endif
+       #if   R1024_Unroll_R(10)
+                       R1024_8_rounds(10);
+       #endif
+       #if   R1024_Unroll_R(11)
+                       R1024_8_rounds(11);
+       #endif
+       #if   R1024_Unroll_R(12)
+                       R1024_8_rounds(12);
+       #endif
+       #if   R1024_Unroll_R(13)
+                       R1024_8_rounds(13);
+       #endif
+       #if   R1024_Unroll_R(14)
+                       R1024_8_rounds(14);
+       #endif
+#if  (SKEIN_UNROLL_1024 > 14)
+#error  "need more unrolling in Skein_1024_Process_Block"
+  #endif
+               }
+               /* do the final "feedforward" xor, update context chaining */
+
+               ctx->X[0] = X00 ^ w[0];
+               ctx->X[1] = X01 ^ w[1];
+               ctx->X[2] = X02 ^ w[2];
+               ctx->X[3] = X03 ^ w[3];
+               ctx->X[4] = X04 ^ w[4];
+               ctx->X[5] = X05 ^ w[5];
+               ctx->X[6] = X06 ^ w[6];
+               ctx->X[7] = X07 ^ w[7];
+               ctx->X[8] = X08 ^ w[8];
+               ctx->X[9] = X09 ^ w[9];
+               ctx->X[10] = X10 ^ w[10];
+               ctx->X[11] = X11 ^ w[11];
+               ctx->X[12] = X12 ^ w[12];
+               ctx->X[13] = X13 ^ w[13];
+               ctx->X[14] = X14 ^ w[14];
+               ctx->X[15] = X15 ^ w[15];
+
+               Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X);
+
+               ts[1] &= ~SKEIN_T1_FLAG_FIRST;
+               blkPtr += SKEIN1024_BLOCK_BYTES;
+       } while (--blkCnt);
+       ctx->h.T[0] = ts[0];
+       ctx->h.T[1] = ts[1];
+}
+
+#if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF)
+size_t Skein1024_Process_Block_CodeSize(void)
+{
+       return ((u8 *) Skein1024_Process_Block_CodeSize) -
+               ((u8 *) Skein1024_Process_Block);
+}
+unsigned int Skein1024_Unroll_Cnt(void)
+{
+       return SKEIN_UNROLL_1024;
+}
+#endif
+#endif
diff --git a/drivers/staging/skein/threefish1024Block.c b/drivers/staging/skein/threefish1024Block.c
new file mode 100644 (file)
index 0000000..fe7517b
--- /dev/null
@@ -0,0 +1,4900 @@
+#include <linux/string.h>
+#include <threefishApi.h>
+
+
+void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output)
+{
+       u64 b0 = input[0], b1 = input[1],
+         b2 = input[2], b3 = input[3],
+         b4 = input[4], b5 = input[5],
+         b6 = input[6], b7 = input[7],
+         b8 = input[8], b9 = input[9],
+         b10 = input[10], b11 = input[11],
+         b12 = input[12], b13 = input[13],
+         b14 = input[14], b15 = input[15];
+       u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1],
+         k2 = keyCtx->key[2], k3 = keyCtx->key[3],
+         k4 = keyCtx->key[4], k5 = keyCtx->key[5],
+         k6 = keyCtx->key[6], k7 = keyCtx->key[7],
+         k8 = keyCtx->key[8], k9 = keyCtx->key[9],
+         k10 = keyCtx->key[10], k11 = keyCtx->key[11],
+         k12 = keyCtx->key[12], k13 = keyCtx->key[13],
+         k14 = keyCtx->key[14], k15 = keyCtx->key[15],
+         k16 = keyCtx->key[16];
+       u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1],
+         t2 = keyCtx->tweak[2];
+
+       b1 += k1;
+       b0 += b1 + k0;
+       b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0;
+
+       b3 += k3;
+       b2 += b3 + k2;
+       b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2;
+
+       b5 += k5;
+       b4 += b5 + k4;
+       b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4;
+
+       b7 += k7;
+       b6 += b7 + k6;
+       b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6;
+
+       b9 += k9;
+       b8 += b9 + k8;
+       b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8;
+
+       b11 += k11;
+       b10 += b11 + k10;
+       b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10;
+
+       b13 += k13 + t0;
+       b12 += b13 + k12;
+       b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12;
+
+       b15 += k15;
+       b14 += b15 + k14 + t1;
+       b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12;
+
+       b1 += k2;
+       b0 += b1 + k1;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0;
+
+       b3 += k4;
+       b2 += b3 + k3;
+       b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2;
+
+       b5 += k6;
+       b4 += b5 + k5;
+       b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4;
+
+       b7 += k8;
+       b6 += b7 + k7;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6;
+
+       b9 += k10;
+       b8 += b9 + k9;
+       b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8;
+
+       b11 += k12;
+       b10 += b11 + k11;
+       b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10;
+
+       b13 += k14 + t1;
+       b12 += b13 + k13;
+       b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12;
+
+       b15 += k16 + 1;
+       b14 += b15 + k15 + t2;
+       b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12;
+
+       b1 += k3;
+       b0 += b1 + k2;
+       b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0;
+
+       b3 += k5;
+       b2 += b3 + k4;
+       b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2;
+
+       b5 += k7;
+       b4 += b5 + k6;
+       b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4;
+
+       b7 += k9;
+       b6 += b7 + k8;
+       b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6;
+
+       b9 += k11;
+       b8 += b9 + k10;
+       b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8;
+
+       b11 += k13;
+       b10 += b11 + k12;
+       b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10;
+
+       b13 += k15 + t2;
+       b12 += b13 + k14;
+       b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12;
+
+       b15 += k0 + 2;
+       b14 += b15 + k16 + t0;
+       b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12;
+
+       b1 += k4;
+       b0 += b1 + k3;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0;
+
+       b3 += k6;
+       b2 += b3 + k5;
+       b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2;
+
+       b5 += k8;
+       b4 += b5 + k7;
+       b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4;
+
+       b7 += k10;
+       b6 += b7 + k9;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6;
+
+       b9 += k12;
+       b8 += b9 + k11;
+       b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8;
+
+       b11 += k14;
+       b10 += b11 + k13;
+       b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10;
+
+       b13 += k16 + t0;
+       b12 += b13 + k15;
+       b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12;
+
+       b15 += k1 + 3;
+       b14 += b15 + k0 + t1;
+       b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12;
+
+       b1 += k5;
+       b0 += b1 + k4;
+       b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0;
+
+       b3 += k7;
+       b2 += b3 + k6;
+       b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2;
+
+       b5 += k9;
+       b4 += b5 + k8;
+       b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4;
+
+       b7 += k11;
+       b6 += b7 + k10;
+       b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6;
+
+       b9 += k13;
+       b8 += b9 + k12;
+       b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8;
+
+       b11 += k15;
+       b10 += b11 + k14;
+       b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10;
+
+       b13 += k0 + t1;
+       b12 += b13 + k16;
+       b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12;
+
+       b15 += k2 + 4;
+       b14 += b15 + k1 + t2;
+       b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12;
+
+       b1 += k6;
+       b0 += b1 + k5;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0;
+
+       b3 += k8;
+       b2 += b3 + k7;
+       b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2;
+
+       b5 += k10;
+       b4 += b5 + k9;
+       b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4;
+
+       b7 += k12;
+       b6 += b7 + k11;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6;
+
+       b9 += k14;
+       b8 += b9 + k13;
+       b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8;
+
+       b11 += k16;
+       b10 += b11 + k15;
+       b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10;
+
+       b13 += k1 + t2;
+       b12 += b13 + k0;
+       b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12;
+
+       b15 += k3 + 5;
+       b14 += b15 + k2 + t0;
+       b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12;
+
+       b1 += k7;
+       b0 += b1 + k6;
+       b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0;
+
+       b3 += k9;
+       b2 += b3 + k8;
+       b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2;
+
+       b5 += k11;
+       b4 += b5 + k10;
+       b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4;
+
+       b7 += k13;
+       b6 += b7 + k12;
+       b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6;
+
+       b9 += k15;
+       b8 += b9 + k14;
+       b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8;
+
+       b11 += k0;
+       b10 += b11 + k16;
+       b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10;
+
+       b13 += k2 + t0;
+       b12 += b13 + k1;
+       b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12;
+
+       b15 += k4 + 6;
+       b14 += b15 + k3 + t1;
+       b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12;
+
+       b1 += k8;
+       b0 += b1 + k7;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0;
+
+       b3 += k10;
+       b2 += b3 + k9;
+       b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2;
+
+       b5 += k12;
+       b4 += b5 + k11;
+       b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4;
+
+       b7 += k14;
+       b6 += b7 + k13;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6;
+
+       b9 += k16;
+       b8 += b9 + k15;
+       b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8;
+
+       b11 += k1;
+       b10 += b11 + k0;
+       b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10;
+
+       b13 += k3 + t1;
+       b12 += b13 + k2;
+       b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12;
+
+       b15 += k5 + 7;
+       b14 += b15 + k4 + t2;
+       b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12;
+
+       b1 += k9;
+       b0 += b1 + k8;
+       b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0;
+
+       b3 += k11;
+       b2 += b3 + k10;
+       b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2;
+
+       b5 += k13;
+       b4 += b5 + k12;
+       b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4;
+
+       b7 += k15;
+       b6 += b7 + k14;
+       b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6;
+
+       b9 += k0;
+       b8 += b9 + k16;
+       b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8;
+
+       b11 += k2;
+       b10 += b11 + k1;
+       b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10;
+
+       b13 += k4 + t2;
+       b12 += b13 + k3;
+       b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12;
+
+       b15 += k6 + 8;
+       b14 += b15 + k5 + t0;
+       b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12;
+
+       b1 += k10;
+       b0 += b1 + k9;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0;
+
+       b3 += k12;
+       b2 += b3 + k11;
+       b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2;
+
+       b5 += k14;
+       b4 += b5 + k13;
+       b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4;
+
+       b7 += k16;
+       b6 += b7 + k15;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6;
+
+       b9 += k1;
+       b8 += b9 + k0;
+       b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8;
+
+       b11 += k3;
+       b10 += b11 + k2;
+       b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10;
+
+       b13 += k5 + t0;
+       b12 += b13 + k4;
+       b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12;
+
+       b15 += k7 + 9;
+       b14 += b15 + k6 + t1;
+       b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12;
+
+       b1 += k11;
+       b0 += b1 + k10;
+       b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0;
+
+       b3 += k13;
+       b2 += b3 + k12;
+       b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2;
+
+       b5 += k15;
+       b4 += b5 + k14;
+       b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4;
+
+       b7 += k0;
+       b6 += b7 + k16;
+       b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6;
+
+       b9 += k2;
+       b8 += b9 + k1;
+       b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8;
+
+       b11 += k4;
+       b10 += b11 + k3;
+       b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10;
+
+       b13 += k6 + t1;
+       b12 += b13 + k5;
+       b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12;
+
+       b15 += k8 + 10;
+       b14 += b15 + k7 + t2;
+       b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12;
+
+       b1 += k12;
+       b0 += b1 + k11;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0;
+
+       b3 += k14;
+       b2 += b3 + k13;
+       b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2;
+
+       b5 += k16;
+       b4 += b5 + k15;
+       b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4;
+
+       b7 += k1;
+       b6 += b7 + k0;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6;
+
+       b9 += k3;
+       b8 += b9 + k2;
+       b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8;
+
+       b11 += k5;
+       b10 += b11 + k4;
+       b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10;
+
+       b13 += k7 + t2;
+       b12 += b13 + k6;
+       b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12;
+
+       b15 += k9 + 11;
+       b14 += b15 + k8 + t0;
+       b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12;
+
+       b1 += k13;
+       b0 += b1 + k12;
+       b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0;
+
+       b3 += k15;
+       b2 += b3 + k14;
+       b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2;
+
+       b5 += k0;
+       b4 += b5 + k16;
+       b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4;
+
+       b7 += k2;
+       b6 += b7 + k1;
+       b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6;
+
+       b9 += k4;
+       b8 += b9 + k3;
+       b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8;
+
+       b11 += k6;
+       b10 += b11 + k5;
+       b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10;
+
+       b13 += k8 + t0;
+       b12 += b13 + k7;
+       b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12;
+
+       b15 += k10 + 12;
+       b14 += b15 + k9 + t1;
+       b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12;
+
+       b1 += k14;
+       b0 += b1 + k13;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0;
+
+       b3 += k16;
+       b2 += b3 + k15;
+       b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2;
+
+       b5 += k1;
+       b4 += b5 + k0;
+       b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4;
+
+       b7 += k3;
+       b6 += b7 + k2;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6;
+
+       b9 += k5;
+       b8 += b9 + k4;
+       b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8;
+
+       b11 += k7;
+       b10 += b11 + k6;
+       b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10;
+
+       b13 += k9 + t1;
+       b12 += b13 + k8;
+       b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12;
+
+       b15 += k11 + 13;
+       b14 += b15 + k10 + t2;
+       b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12;
+
+       b1 += k15;
+       b0 += b1 + k14;
+       b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0;
+
+       b3 += k0;
+       b2 += b3 + k16;
+       b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2;
+
+       b5 += k2;
+       b4 += b5 + k1;
+       b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4;
+
+       b7 += k4;
+       b6 += b7 + k3;
+       b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6;
+
+       b9 += k6;
+       b8 += b9 + k5;
+       b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8;
+
+       b11 += k8;
+       b10 += b11 + k7;
+       b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10;
+
+       b13 += k10 + t2;
+       b12 += b13 + k9;
+       b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12;
+
+       b15 += k12 + 14;
+       b14 += b15 + k11 + t0;
+       b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12;
+
+       b1 += k16;
+       b0 += b1 + k15;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0;
+
+       b3 += k1;
+       b2 += b3 + k0;
+       b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2;
+
+       b5 += k3;
+       b4 += b5 + k2;
+       b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4;
+
+       b7 += k5;
+       b6 += b7 + k4;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6;
+
+       b9 += k7;
+       b8 += b9 + k6;
+       b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8;
+
+       b11 += k9;
+       b10 += b11 + k8;
+       b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10;
+
+       b13 += k11 + t0;
+       b12 += b13 + k10;
+       b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12;
+
+       b15 += k13 + 15;
+       b14 += b15 + k12 + t1;
+       b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12;
+
+       b1 += k0;
+       b0 += b1 + k16;
+       b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0;
+
+       b3 += k2;
+       b2 += b3 + k1;
+       b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2;
+
+       b5 += k4;
+       b4 += b5 + k3;
+       b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4;
+
+       b7 += k6;
+       b6 += b7 + k5;
+       b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6;
+
+       b9 += k8;
+       b8 += b9 + k7;
+       b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8;
+
+       b11 += k10;
+       b10 += b11 + k9;
+       b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10;
+
+       b13 += k12 + t1;
+       b12 += b13 + k11;
+       b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12;
+
+       b15 += k14 + 16;
+       b14 += b15 + k13 + t2;
+       b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12;
+
+       b1 += k1;
+       b0 += b1 + k0;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0;
+
+       b3 += k3;
+       b2 += b3 + k2;
+       b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2;
+
+       b5 += k5;
+       b4 += b5 + k4;
+       b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4;
+
+       b7 += k7;
+       b6 += b7 + k6;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6;
+
+       b9 += k9;
+       b8 += b9 + k8;
+       b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8;
+
+       b11 += k11;
+       b10 += b11 + k10;
+       b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10;
+
+       b13 += k13 + t2;
+       b12 += b13 + k12;
+       b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12;
+
+       b15 += k15 + 17;
+       b14 += b15 + k14 + t0;
+       b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12;
+
+       b1 += k2;
+       b0 += b1 + k1;
+       b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0;
+
+       b3 += k4;
+       b2 += b3 + k3;
+       b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2;
+
+       b5 += k6;
+       b4 += b5 + k5;
+       b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4;
+
+       b7 += k8;
+       b6 += b7 + k7;
+       b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6;
+
+       b9 += k10;
+       b8 += b9 + k9;
+       b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8;
+
+       b11 += k12;
+       b10 += b11 + k11;
+       b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10;
+
+       b13 += k14 + t0;
+       b12 += b13 + k13;
+       b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12;
+
+       b15 += k16 + 18;
+       b14 += b15 + k15 + t1;
+       b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12;
+
+       b1 += k3;
+       b0 += b1 + k2;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0;
+
+       b3 += k5;
+       b2 += b3 + k4;
+       b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2;
+
+       b5 += k7;
+       b4 += b5 + k6;
+       b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4;
+
+       b7 += k9;
+       b6 += b7 + k8;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6;
+
+       b9 += k11;
+       b8 += b9 + k10;
+       b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8;
+
+       b11 += k13;
+       b10 += b11 + k12;
+       b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10;
+
+       b13 += k15 + t1;
+       b12 += b13 + k14;
+       b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12;
+
+       b15 += k0 + 19;
+       b14 += b15 + k16 + t2;
+       b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14;
+
+       b0 += b9;
+       b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0;
+
+       b2 += b13;
+       b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2;
+
+       b6 += b11;
+       b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6;
+
+       b4 += b15;
+       b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4;
+
+       b10 += b7;
+       b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10;
+
+       b12 += b3;
+       b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12;
+
+       b14 += b5;
+       b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14;
+
+       b8 += b1;
+       b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8;
+
+       b0 += b7;
+       b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4;
+
+       b6 += b1;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6;
+
+       b12 += b15;
+       b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12;
+
+       b14 += b13;
+       b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14;
+
+       b8 += b11;
+       b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8;
+
+       b10 += b9;
+       b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10;
+
+       b0 += b15;
+       b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0;
+
+       b2 += b11;
+       b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2;
+
+       b6 += b13;
+       b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6;
+
+       b4 += b9;
+       b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4;
+
+       b14 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14;
+
+       b8 += b5;
+       b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8;
+
+       b10 += b3;
+       b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10;
+
+       b12 += b7;
+       b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12;
+
+       output[0] = b0 + k3;
+       output[1] = b1 + k4;
+       output[2] = b2 + k5;
+       output[3] = b3 + k6;
+       output[4] = b4 + k7;
+       output[5] = b5 + k8;
+       output[6] = b6 + k9;
+       output[7] = b7 + k10;
+       output[8] = b8 + k11;
+       output[9] = b9 + k12;
+       output[10] = b10 + k13;
+       output[11] = b11 + k14;
+       output[12] = b12 + k15;
+       output[13] = b13 + k16 + t2;
+       output[14] = b14 + k0 + t0;
+       output[15] = b15 + k1 + 20;
+}
+
+void threefishDecrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output)
+{
+       u64 b0 = input[0], b1 = input[1],
+         b2 = input[2], b3 = input[3],
+         b4 = input[4], b5 = input[5],
+         b6 = input[6], b7 = input[7],
+         b8 = input[8], b9 = input[9],
+         b10 = input[10], b11 = input[11],
+         b12 = input[12], b13 = input[13],
+         b14 = input[14], b15 = input[15];
+       u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1],
+         k2 = keyCtx->key[2], k3 = keyCtx->key[3],
+         k4 = keyCtx->key[4], k5 = keyCtx->key[5],
+         k6 = keyCtx->key[6], k7 = keyCtx->key[7],
+         k8 = keyCtx->key[8], k9 = keyCtx->key[9],
+         k10 = keyCtx->key[10], k11 = keyCtx->key[11],
+         k12 = keyCtx->key[12], k13 = keyCtx->key[13],
+         k14 = keyCtx->key[14], k15 = keyCtx->key[15],
+         k16 = keyCtx->key[16];
+       u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1],
+         t2 = keyCtx->tweak[2];
+       u64 tmp;
+
+       b0 -= k3;
+       b1 -= k4;
+       b2 -= k5;
+       b3 -= k6;
+       b4 -= k7;
+       b5 -= k8;
+       b6 -= k9;
+       b7 -= k10;
+       b8 -= k11;
+       b9 -= k12;
+       b10 -= k13;
+       b11 -= k14;
+       b12 -= k15;
+       b13 -= k16 + t2;
+       b14 -= k0 + t0;
+       b15 -= k1 + 20;
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 20) | (tmp << (64 - 20));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 37) | (tmp << (64 - 37));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 31) | (tmp << (64 - 31));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 52) | (tmp << (64 - 52));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 35) | (tmp << (64 - 35));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 48) | (tmp << (64 - 48));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 25) | (tmp << (64 - 25));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 44) | (tmp << (64 - 44));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 19) | (tmp << (64 - 19));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 47) | (tmp << (64 - 47));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 44) | (tmp << (64 - 44));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 53) | (tmp << (64 - 53));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 4) | (tmp << (64 - 4));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 56) | (tmp << (64 - 56));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 34) | (tmp << (64 - 34));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 16) | (tmp << (64 - 16));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 30) | (tmp << (64 - 30));
+       b14 -= b15 + k16 + t2;
+       b15 -= k0 + 19;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 44) | (tmp << (64 - 44));
+       b12 -= b13 + k14;
+       b13 -= k15 + t1;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 47) | (tmp << (64 - 47));
+       b10 -= b11 + k12;
+       b11 -= k13;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 12) | (tmp << (64 - 12));
+       b8 -= b9 + k10;
+       b9 -= k11;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b6 -= b7 + k8;
+       b7 -= k9;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 37) | (tmp << (64 - 37));
+       b4 -= b5 + k6;
+       b5 -= k7;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 9) | (tmp << (64 - 9));
+       b2 -= b3 + k4;
+       b3 -= k5;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b0 -= b1 + k2;
+       b1 -= k3;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 25) | (tmp << (64 - 25));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 28) | (tmp << (64 - 28));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 47) | (tmp << (64 - 47));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 41) | (tmp << (64 - 41));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 48) | (tmp << (64 - 48));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 20) | (tmp << (64 - 20));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 59) | (tmp << (64 - 59));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 41) | (tmp << (64 - 41));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 34) | (tmp << (64 - 34));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 4) | (tmp << (64 - 4));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 33) | (tmp << (64 - 33));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 52) | (tmp << (64 - 52));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 18) | (tmp << (64 - 18));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 49) | (tmp << (64 - 49));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 55) | (tmp << (64 - 55));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 19) | (tmp << (64 - 19));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 38) | (tmp << (64 - 38));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 37) | (tmp << (64 - 37));
+       b14 -= b15 + k15 + t1;
+       b15 -= k16 + 18;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 22) | (tmp << (64 - 22));
+       b12 -= b13 + k13;
+       b13 -= k14 + t0;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b11 + k11;
+       b11 -= k12;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 8) | (tmp << (64 - 8));
+       b8 -= b9 + k9;
+       b9 -= k10;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 47) | (tmp << (64 - 47));
+       b6 -= b7 + k7;
+       b7 -= k8;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 8) | (tmp << (64 - 8));
+       b4 -= b5 + k5;
+       b5 -= k6;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b3 + k3;
+       b3 -= k4;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 24) | (tmp << (64 - 24));
+       b0 -= b1 + k1;
+       b1 -= k2;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 20) | (tmp << (64 - 20));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 37) | (tmp << (64 - 37));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 31) | (tmp << (64 - 31));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 52) | (tmp << (64 - 52));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 35) | (tmp << (64 - 35));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 48) | (tmp << (64 - 48));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 25) | (tmp << (64 - 25));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 44) | (tmp << (64 - 44));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 19) | (tmp << (64 - 19));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 47) | (tmp << (64 - 47));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 44) | (tmp << (64 - 44));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 53) | (tmp << (64 - 53));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 4) | (tmp << (64 - 4));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 56) | (tmp << (64 - 56));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 34) | (tmp << (64 - 34));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 16) | (tmp << (64 - 16));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 30) | (tmp << (64 - 30));
+       b14 -= b15 + k14 + t0;
+       b15 -= k15 + 17;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 44) | (tmp << (64 - 44));
+       b12 -= b13 + k12;
+       b13 -= k13 + t2;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 47) | (tmp << (64 - 47));
+       b10 -= b11 + k10;
+       b11 -= k11;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 12) | (tmp << (64 - 12));
+       b8 -= b9 + k8;
+       b9 -= k9;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b6 -= b7 + k6;
+       b7 -= k7;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 37) | (tmp << (64 - 37));
+       b4 -= b5 + k4;
+       b5 -= k5;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 9) | (tmp << (64 - 9));
+       b2 -= b3 + k2;
+       b3 -= k3;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b0 -= b1 + k0;
+       b1 -= k1;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 25) | (tmp << (64 - 25));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 28) | (tmp << (64 - 28));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 47) | (tmp << (64 - 47));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 41) | (tmp << (64 - 41));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 48) | (tmp << (64 - 48));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 20) | (tmp << (64 - 20));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 59) | (tmp << (64 - 59));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 41) | (tmp << (64 - 41));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 34) | (tmp << (64 - 34));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 4) | (tmp << (64 - 4));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 33) | (tmp << (64 - 33));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 52) | (tmp << (64 - 52));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 18) | (tmp << (64 - 18));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 49) | (tmp << (64 - 49));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 55) | (tmp << (64 - 55));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 19) | (tmp << (64 - 19));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 38) | (tmp << (64 - 38));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 37) | (tmp << (64 - 37));
+       b14 -= b15 + k13 + t2;
+       b15 -= k14 + 16;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 22) | (tmp << (64 - 22));
+       b12 -= b13 + k11;
+       b13 -= k12 + t1;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b11 + k9;
+       b11 -= k10;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 8) | (tmp << (64 - 8));
+       b8 -= b9 + k7;
+       b9 -= k8;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 47) | (tmp << (64 - 47));
+       b6 -= b7 + k5;
+       b7 -= k6;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 8) | (tmp << (64 - 8));
+       b4 -= b5 + k3;
+       b5 -= k4;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b3 + k1;
+       b3 -= k2;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 24) | (tmp << (64 - 24));
+       b0 -= b1 + k16;
+       b1 -= k0;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 20) | (tmp << (64 - 20));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 37) | (tmp << (64 - 37));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 31) | (tmp << (64 - 31));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 52) | (tmp << (64 - 52));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 35) | (tmp << (64 - 35));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 48) | (tmp << (64 - 48));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 25) | (tmp << (64 - 25));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 44) | (tmp << (64 - 44));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 19) | (tmp << (64 - 19));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 47) | (tmp << (64 - 47));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 44) | (tmp << (64 - 44));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 53) | (tmp << (64 - 53));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 4) | (tmp << (64 - 4));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 56) | (tmp << (64 - 56));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 34) | (tmp << (64 - 34));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 16) | (tmp << (64 - 16));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 30) | (tmp << (64 - 30));
+       b14 -= b15 + k12 + t1;
+       b15 -= k13 + 15;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 44) | (tmp << (64 - 44));
+       b12 -= b13 + k10;
+       b13 -= k11 + t0;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 47) | (tmp << (64 - 47));
+       b10 -= b11 + k8;
+       b11 -= k9;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 12) | (tmp << (64 - 12));
+       b8 -= b9 + k6;
+       b9 -= k7;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b6 -= b7 + k4;
+       b7 -= k5;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 37) | (tmp << (64 - 37));
+       b4 -= b5 + k2;
+       b5 -= k3;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 9) | (tmp << (64 - 9));
+       b2 -= b3 + k0;
+       b3 -= k1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b0 -= b1 + k15;
+       b1 -= k16;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 25) | (tmp << (64 - 25));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 28) | (tmp << (64 - 28));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 47) | (tmp << (64 - 47));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 41) | (tmp << (64 - 41));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 48) | (tmp << (64 - 48));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 20) | (tmp << (64 - 20));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 59) | (tmp << (64 - 59));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 41) | (tmp << (64 - 41));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 34) | (tmp << (64 - 34));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 4) | (tmp << (64 - 4));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 33) | (tmp << (64 - 33));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 52) | (tmp << (64 - 52));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 18) | (tmp << (64 - 18));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 49) | (tmp << (64 - 49));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 55) | (tmp << (64 - 55));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 19) | (tmp << (64 - 19));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 38) | (tmp << (64 - 38));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 37) | (tmp << (64 - 37));
+       b14 -= b15 + k11 + t0;
+       b15 -= k12 + 14;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 22) | (tmp << (64 - 22));
+       b12 -= b13 + k9;
+       b13 -= k10 + t2;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b11 + k7;
+       b11 -= k8;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 8) | (tmp << (64 - 8));
+       b8 -= b9 + k5;
+       b9 -= k6;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 47) | (tmp << (64 - 47));
+       b6 -= b7 + k3;
+       b7 -= k4;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 8) | (tmp << (64 - 8));
+       b4 -= b5 + k1;
+       b5 -= k2;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b3 + k16;
+       b3 -= k0;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 24) | (tmp << (64 - 24));
+       b0 -= b1 + k14;
+       b1 -= k15;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 20) | (tmp << (64 - 20));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 37) | (tmp << (64 - 37));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 31) | (tmp << (64 - 31));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 52) | (tmp << (64 - 52));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 35) | (tmp << (64 - 35));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 48) | (tmp << (64 - 48));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 25) | (tmp << (64 - 25));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 44) | (tmp << (64 - 44));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 19) | (tmp << (64 - 19));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 47) | (tmp << (64 - 47));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 44) | (tmp << (64 - 44));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 53) | (tmp << (64 - 53));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 4) | (tmp << (64 - 4));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 56) | (tmp << (64 - 56));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 34) | (tmp << (64 - 34));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 16) | (tmp << (64 - 16));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 30) | (tmp << (64 - 30));
+       b14 -= b15 + k10 + t2;
+       b15 -= k11 + 13;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 44) | (tmp << (64 - 44));
+       b12 -= b13 + k8;
+       b13 -= k9 + t1;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 47) | (tmp << (64 - 47));
+       b10 -= b11 + k6;
+       b11 -= k7;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 12) | (tmp << (64 - 12));
+       b8 -= b9 + k4;
+       b9 -= k5;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b6 -= b7 + k2;
+       b7 -= k3;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 37) | (tmp << (64 - 37));
+       b4 -= b5 + k0;
+       b5 -= k1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 9) | (tmp << (64 - 9));
+       b2 -= b3 + k15;
+       b3 -= k16;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b0 -= b1 + k13;
+       b1 -= k14;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 25) | (tmp << (64 - 25));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 28) | (tmp << (64 - 28));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 47) | (tmp << (64 - 47));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 41) | (tmp << (64 - 41));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 48) | (tmp << (64 - 48));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 20) | (tmp << (64 - 20));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 59) | (tmp << (64 - 59));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 41) | (tmp << (64 - 41));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 34) | (tmp << (64 - 34));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 4) | (tmp << (64 - 4));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 33) | (tmp << (64 - 33));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 52) | (tmp << (64 - 52));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 18) | (tmp << (64 - 18));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 49) | (tmp << (64 - 49));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 55) | (tmp << (64 - 55));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 19) | (tmp << (64 - 19));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 38) | (tmp << (64 - 38));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 37) | (tmp << (64 - 37));
+       b14 -= b15 + k9 + t1;
+       b15 -= k10 + 12;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 22) | (tmp << (64 - 22));
+       b12 -= b13 + k7;
+       b13 -= k8 + t0;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b11 + k5;
+       b11 -= k6;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 8) | (tmp << (64 - 8));
+       b8 -= b9 + k3;
+       b9 -= k4;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 47) | (tmp << (64 - 47));
+       b6 -= b7 + k1;
+       b7 -= k2;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 8) | (tmp << (64 - 8));
+       b4 -= b5 + k16;
+       b5 -= k0;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b3 + k14;
+       b3 -= k15;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 24) | (tmp << (64 - 24));
+       b0 -= b1 + k12;
+       b1 -= k13;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 20) | (tmp << (64 - 20));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 37) | (tmp << (64 - 37));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 31) | (tmp << (64 - 31));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 52) | (tmp << (64 - 52));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 35) | (tmp << (64 - 35));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 48) | (tmp << (64 - 48));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 25) | (tmp << (64 - 25));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 44) | (tmp << (64 - 44));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 19) | (tmp << (64 - 19));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 47) | (tmp << (64 - 47));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 44) | (tmp << (64 - 44));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 53) | (tmp << (64 - 53));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 4) | (tmp << (64 - 4));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 56) | (tmp << (64 - 56));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 34) | (tmp << (64 - 34));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 16) | (tmp << (64 - 16));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 30) | (tmp << (64 - 30));
+       b14 -= b15 + k8 + t0;
+       b15 -= k9 + 11;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 44) | (tmp << (64 - 44));
+       b12 -= b13 + k6;
+       b13 -= k7 + t2;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 47) | (tmp << (64 - 47));
+       b10 -= b11 + k4;
+       b11 -= k5;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 12) | (tmp << (64 - 12));
+       b8 -= b9 + k2;
+       b9 -= k3;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b6 -= b7 + k0;
+       b7 -= k1;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 37) | (tmp << (64 - 37));
+       b4 -= b5 + k15;
+       b5 -= k16;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 9) | (tmp << (64 - 9));
+       b2 -= b3 + k13;
+       b3 -= k14;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b0 -= b1 + k11;
+       b1 -= k12;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 25) | (tmp << (64 - 25));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 28) | (tmp << (64 - 28));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 47) | (tmp << (64 - 47));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 41) | (tmp << (64 - 41));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 48) | (tmp << (64 - 48));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 20) | (tmp << (64 - 20));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 59) | (tmp << (64 - 59));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 41) | (tmp << (64 - 41));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 34) | (tmp << (64 - 34));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 4) | (tmp << (64 - 4));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 33) | (tmp << (64 - 33));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 52) | (tmp << (64 - 52));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 18) | (tmp << (64 - 18));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 49) | (tmp << (64 - 49));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 55) | (tmp << (64 - 55));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 19) | (tmp << (64 - 19));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 38) | (tmp << (64 - 38));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 37) | (tmp << (64 - 37));
+       b14 -= b15 + k7 + t2;
+       b15 -= k8 + 10;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 22) | (tmp << (64 - 22));
+       b12 -= b13 + k5;
+       b13 -= k6 + t1;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b11 + k3;
+       b11 -= k4;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 8) | (tmp << (64 - 8));
+       b8 -= b9 + k1;
+       b9 -= k2;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 47) | (tmp << (64 - 47));
+       b6 -= b7 + k16;
+       b7 -= k0;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 8) | (tmp << (64 - 8));
+       b4 -= b5 + k14;
+       b5 -= k15;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b3 + k12;
+       b3 -= k13;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 24) | (tmp << (64 - 24));
+       b0 -= b1 + k10;
+       b1 -= k11;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 20) | (tmp << (64 - 20));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 37) | (tmp << (64 - 37));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 31) | (tmp << (64 - 31));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 52) | (tmp << (64 - 52));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 35) | (tmp << (64 - 35));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 48) | (tmp << (64 - 48));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 25) | (tmp << (64 - 25));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 44) | (tmp << (64 - 44));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 19) | (tmp << (64 - 19));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 47) | (tmp << (64 - 47));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 44) | (tmp << (64 - 44));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 53) | (tmp << (64 - 53));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 4) | (tmp << (64 - 4));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 56) | (tmp << (64 - 56));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 34) | (tmp << (64 - 34));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 16) | (tmp << (64 - 16));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 30) | (tmp << (64 - 30));
+       b14 -= b15 + k6 + t1;
+       b15 -= k7 + 9;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 44) | (tmp << (64 - 44));
+       b12 -= b13 + k4;
+       b13 -= k5 + t0;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 47) | (tmp << (64 - 47));
+       b10 -= b11 + k2;
+       b11 -= k3;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 12) | (tmp << (64 - 12));
+       b8 -= b9 + k0;
+       b9 -= k1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b6 -= b7 + k15;
+       b7 -= k16;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 37) | (tmp << (64 - 37));
+       b4 -= b5 + k13;
+       b5 -= k14;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 9) | (tmp << (64 - 9));
+       b2 -= b3 + k11;
+       b3 -= k12;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b0 -= b1 + k9;
+       b1 -= k10;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 25) | (tmp << (64 - 25));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 28) | (tmp << (64 - 28));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 47) | (tmp << (64 - 47));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 41) | (tmp << (64 - 41));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 48) | (tmp << (64 - 48));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 20) | (tmp << (64 - 20));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 59) | (tmp << (64 - 59));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 41) | (tmp << (64 - 41));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 34) | (tmp << (64 - 34));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 4) | (tmp << (64 - 4));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 33) | (tmp << (64 - 33));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 52) | (tmp << (64 - 52));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 18) | (tmp << (64 - 18));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 49) | (tmp << (64 - 49));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 55) | (tmp << (64 - 55));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 19) | (tmp << (64 - 19));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 38) | (tmp << (64 - 38));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 37) | (tmp << (64 - 37));
+       b14 -= b15 + k5 + t0;
+       b15 -= k6 + 8;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 22) | (tmp << (64 - 22));
+       b12 -= b13 + k3;
+       b13 -= k4 + t2;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b11 + k1;
+       b11 -= k2;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 8) | (tmp << (64 - 8));
+       b8 -= b9 + k16;
+       b9 -= k0;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 47) | (tmp << (64 - 47));
+       b6 -= b7 + k14;
+       b7 -= k15;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 8) | (tmp << (64 - 8));
+       b4 -= b5 + k12;
+       b5 -= k13;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b3 + k10;
+       b3 -= k11;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 24) | (tmp << (64 - 24));
+       b0 -= b1 + k8;
+       b1 -= k9;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 20) | (tmp << (64 - 20));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 37) | (tmp << (64 - 37));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 31) | (tmp << (64 - 31));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 52) | (tmp << (64 - 52));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 35) | (tmp << (64 - 35));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 48) | (tmp << (64 - 48));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 25) | (tmp << (64 - 25));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 44) | (tmp << (64 - 44));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 19) | (tmp << (64 - 19));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 47) | (tmp << (64 - 47));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 44) | (tmp << (64 - 44));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 53) | (tmp << (64 - 53));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 4) | (tmp << (64 - 4));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 56) | (tmp << (64 - 56));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 34) | (tmp << (64 - 34));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 16) | (tmp << (64 - 16));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 30) | (tmp << (64 - 30));
+       b14 -= b15 + k4 + t2;
+       b15 -= k5 + 7;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 44) | (tmp << (64 - 44));
+       b12 -= b13 + k2;
+       b13 -= k3 + t1;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 47) | (tmp << (64 - 47));
+       b10 -= b11 + k0;
+       b11 -= k1;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 12) | (tmp << (64 - 12));
+       b8 -= b9 + k15;
+       b9 -= k16;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b6 -= b7 + k13;
+       b7 -= k14;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 37) | (tmp << (64 - 37));
+       b4 -= b5 + k11;
+       b5 -= k12;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 9) | (tmp << (64 - 9));
+       b2 -= b3 + k9;
+       b3 -= k10;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b0 -= b1 + k7;
+       b1 -= k8;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 25) | (tmp << (64 - 25));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 28) | (tmp << (64 - 28));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 47) | (tmp << (64 - 47));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 41) | (tmp << (64 - 41));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 48) | (tmp << (64 - 48));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 20) | (tmp << (64 - 20));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 59) | (tmp << (64 - 59));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 41) | (tmp << (64 - 41));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 34) | (tmp << (64 - 34));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 4) | (tmp << (64 - 4));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 33) | (tmp << (64 - 33));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 52) | (tmp << (64 - 52));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 18) | (tmp << (64 - 18));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 49) | (tmp << (64 - 49));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 55) | (tmp << (64 - 55));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 19) | (tmp << (64 - 19));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 38) | (tmp << (64 - 38));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 37) | (tmp << (64 - 37));
+       b14 -= b15 + k3 + t1;
+       b15 -= k4 + 6;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 22) | (tmp << (64 - 22));
+       b12 -= b13 + k1;
+       b13 -= k2 + t0;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b11 + k16;
+       b11 -= k0;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 8) | (tmp << (64 - 8));
+       b8 -= b9 + k14;
+       b9 -= k15;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 47) | (tmp << (64 - 47));
+       b6 -= b7 + k12;
+       b7 -= k13;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 8) | (tmp << (64 - 8));
+       b4 -= b5 + k10;
+       b5 -= k11;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b3 + k8;
+       b3 -= k9;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 24) | (tmp << (64 - 24));
+       b0 -= b1 + k6;
+       b1 -= k7;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 20) | (tmp << (64 - 20));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 37) | (tmp << (64 - 37));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 31) | (tmp << (64 - 31));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 52) | (tmp << (64 - 52));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 35) | (tmp << (64 - 35));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 48) | (tmp << (64 - 48));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 25) | (tmp << (64 - 25));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 44) | (tmp << (64 - 44));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 19) | (tmp << (64 - 19));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 47) | (tmp << (64 - 47));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 44) | (tmp << (64 - 44));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 53) | (tmp << (64 - 53));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 4) | (tmp << (64 - 4));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 56) | (tmp << (64 - 56));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 34) | (tmp << (64 - 34));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 16) | (tmp << (64 - 16));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 30) | (tmp << (64 - 30));
+       b14 -= b15 + k2 + t0;
+       b15 -= k3 + 5;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 44) | (tmp << (64 - 44));
+       b12 -= b13 + k0;
+       b13 -= k1 + t2;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 47) | (tmp << (64 - 47));
+       b10 -= b11 + k15;
+       b11 -= k16;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 12) | (tmp << (64 - 12));
+       b8 -= b9 + k13;
+       b9 -= k14;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b6 -= b7 + k11;
+       b7 -= k12;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 37) | (tmp << (64 - 37));
+       b4 -= b5 + k9;
+       b5 -= k10;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 9) | (tmp << (64 - 9));
+       b2 -= b3 + k7;
+       b3 -= k8;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b0 -= b1 + k5;
+       b1 -= k6;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 25) | (tmp << (64 - 25));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 28) | (tmp << (64 - 28));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 47) | (tmp << (64 - 47));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 41) | (tmp << (64 - 41));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 48) | (tmp << (64 - 48));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 20) | (tmp << (64 - 20));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 59) | (tmp << (64 - 59));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 41) | (tmp << (64 - 41));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 34) | (tmp << (64 - 34));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 4) | (tmp << (64 - 4));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 33) | (tmp << (64 - 33));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 52) | (tmp << (64 - 52));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 18) | (tmp << (64 - 18));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 49) | (tmp << (64 - 49));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 55) | (tmp << (64 - 55));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 19) | (tmp << (64 - 19));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 38) | (tmp << (64 - 38));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 37) | (tmp << (64 - 37));
+       b14 -= b15 + k1 + t2;
+       b15 -= k2 + 4;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 22) | (tmp << (64 - 22));
+       b12 -= b13 + k16;
+       b13 -= k0 + t1;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b11 + k14;
+       b11 -= k15;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 8) | (tmp << (64 - 8));
+       b8 -= b9 + k12;
+       b9 -= k13;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 47) | (tmp << (64 - 47));
+       b6 -= b7 + k10;
+       b7 -= k11;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 8) | (tmp << (64 - 8));
+       b4 -= b5 + k8;
+       b5 -= k9;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b3 + k6;
+       b3 -= k7;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 24) | (tmp << (64 - 24));
+       b0 -= b1 + k4;
+       b1 -= k5;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 20) | (tmp << (64 - 20));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 37) | (tmp << (64 - 37));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 31) | (tmp << (64 - 31));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 52) | (tmp << (64 - 52));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 35) | (tmp << (64 - 35));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 48) | (tmp << (64 - 48));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 25) | (tmp << (64 - 25));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 44) | (tmp << (64 - 44));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 19) | (tmp << (64 - 19));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 47) | (tmp << (64 - 47));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 44) | (tmp << (64 - 44));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 53) | (tmp << (64 - 53));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 4) | (tmp << (64 - 4));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 56) | (tmp << (64 - 56));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 34) | (tmp << (64 - 34));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 16) | (tmp << (64 - 16));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 30) | (tmp << (64 - 30));
+       b14 -= b15 + k0 + t1;
+       b15 -= k1 + 3;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 44) | (tmp << (64 - 44));
+       b12 -= b13 + k15;
+       b13 -= k16 + t0;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 47) | (tmp << (64 - 47));
+       b10 -= b11 + k13;
+       b11 -= k14;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 12) | (tmp << (64 - 12));
+       b8 -= b9 + k11;
+       b9 -= k12;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b6 -= b7 + k9;
+       b7 -= k10;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 37) | (tmp << (64 - 37));
+       b4 -= b5 + k7;
+       b5 -= k8;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 9) | (tmp << (64 - 9));
+       b2 -= b3 + k5;
+       b3 -= k6;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b0 -= b1 + k3;
+       b1 -= k4;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 25) | (tmp << (64 - 25));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 28) | (tmp << (64 - 28));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 47) | (tmp << (64 - 47));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 41) | (tmp << (64 - 41));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 48) | (tmp << (64 - 48));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 20) | (tmp << (64 - 20));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 59) | (tmp << (64 - 59));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 41) | (tmp << (64 - 41));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 34) | (tmp << (64 - 34));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 4) | (tmp << (64 - 4));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 33) | (tmp << (64 - 33));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 52) | (tmp << (64 - 52));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 18) | (tmp << (64 - 18));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 49) | (tmp << (64 - 49));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 55) | (tmp << (64 - 55));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 19) | (tmp << (64 - 19));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 38) | (tmp << (64 - 38));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 37) | (tmp << (64 - 37));
+       b14 -= b15 + k16 + t0;
+       b15 -= k0 + 2;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 22) | (tmp << (64 - 22));
+       b12 -= b13 + k14;
+       b13 -= k15 + t2;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b11 + k12;
+       b11 -= k13;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 8) | (tmp << (64 - 8));
+       b8 -= b9 + k10;
+       b9 -= k11;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 47) | (tmp << (64 - 47));
+       b6 -= b7 + k8;
+       b7 -= k9;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 8) | (tmp << (64 - 8));
+       b4 -= b5 + k6;
+       b5 -= k7;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b3 + k4;
+       b3 -= k5;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 24) | (tmp << (64 - 24));
+       b0 -= b1 + k2;
+       b1 -= k3;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 20) | (tmp << (64 - 20));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 37) | (tmp << (64 - 37));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 31) | (tmp << (64 - 31));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 52) | (tmp << (64 - 52));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 35) | (tmp << (64 - 35));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 48) | (tmp << (64 - 48));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 25) | (tmp << (64 - 25));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 44) | (tmp << (64 - 44));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 19) | (tmp << (64 - 19));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 47) | (tmp << (64 - 47));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 44) | (tmp << (64 - 44));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 42) | (tmp << (64 - 42));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 53) | (tmp << (64 - 53));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 4) | (tmp << (64 - 4));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 56) | (tmp << (64 - 56));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 34) | (tmp << (64 - 34));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 16) | (tmp << (64 - 16));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 30) | (tmp << (64 - 30));
+       b14 -= b15 + k15 + t2;
+       b15 -= k16 + 1;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 44) | (tmp << (64 - 44));
+       b12 -= b13 + k13;
+       b13 -= k14 + t1;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 47) | (tmp << (64 - 47));
+       b10 -= b11 + k11;
+       b11 -= k12;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 12) | (tmp << (64 - 12));
+       b8 -= b9 + k9;
+       b9 -= k10;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 31) | (tmp << (64 - 31));
+       b6 -= b7 + k7;
+       b7 -= k8;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 37) | (tmp << (64 - 37));
+       b4 -= b5 + k5;
+       b5 -= k6;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 9) | (tmp << (64 - 9));
+       b2 -= b3 + k3;
+       b3 -= k4;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 41) | (tmp << (64 - 41));
+       b0 -= b1 + k1;
+       b1 -= k2;
+
+       tmp = b7 ^ b12;
+       b7 = (tmp >> 25) | (tmp << (64 - 25));
+       b12 -= b7;
+
+       tmp = b3 ^ b10;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b10 -= b3;
+
+       tmp = b5 ^ b8;
+       b5 = (tmp >> 28) | (tmp << (64 - 28));
+       b8 -= b5;
+
+       tmp = b1 ^ b14;
+       b1 = (tmp >> 47) | (tmp << (64 - 47));
+       b14 -= b1;
+
+       tmp = b9 ^ b4;
+       b9 = (tmp >> 41) | (tmp << (64 - 41));
+       b4 -= b9;
+
+       tmp = b13 ^ b6;
+       b13 = (tmp >> 48) | (tmp << (64 - 48));
+       b6 -= b13;
+
+       tmp = b11 ^ b2;
+       b11 = (tmp >> 20) | (tmp << (64 - 20));
+       b2 -= b11;
+
+       tmp = b15 ^ b0;
+       b15 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b15;
+
+       tmp = b9 ^ b10;
+       b9 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b9;
+
+       tmp = b11 ^ b8;
+       b11 = (tmp >> 59) | (tmp << (64 - 59));
+       b8 -= b11;
+
+       tmp = b13 ^ b14;
+       b13 = (tmp >> 41) | (tmp << (64 - 41));
+       b14 -= b13;
+
+       tmp = b15 ^ b12;
+       b15 = (tmp >> 34) | (tmp << (64 - 34));
+       b12 -= b15;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b6 -= b1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 51) | (tmp << (64 - 51));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 4) | (tmp << (64 - 4));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 33) | (tmp << (64 - 33));
+       b0 -= b7;
+
+       tmp = b1 ^ b8;
+       b1 = (tmp >> 52) | (tmp << (64 - 52));
+       b8 -= b1;
+
+       tmp = b5 ^ b14;
+       b5 = (tmp >> 23) | (tmp << (64 - 23));
+       b14 -= b5;
+
+       tmp = b3 ^ b12;
+       b3 = (tmp >> 18) | (tmp << (64 - 18));
+       b12 -= b3;
+
+       tmp = b7 ^ b10;
+       b7 = (tmp >> 49) | (tmp << (64 - 49));
+       b10 -= b7;
+
+       tmp = b15 ^ b4;
+       b15 = (tmp >> 55) | (tmp << (64 - 55));
+       b4 -= b15;
+
+       tmp = b11 ^ b6;
+       b11 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b11;
+
+       tmp = b13 ^ b2;
+       b13 = (tmp >> 19) | (tmp << (64 - 19));
+       b2 -= b13;
+
+       tmp = b9 ^ b0;
+       b9 = (tmp >> 38) | (tmp << (64 - 38));
+       b0 -= b9;
+
+       tmp = b15 ^ b14;
+       b15 = (tmp >> 37) | (tmp << (64 - 37));
+       b14 -= b15 + k14 + t1;
+       b15 -= k15;
+
+       tmp = b13 ^ b12;
+       b13 = (tmp >> 22) | (tmp << (64 - 22));
+       b12 -= b13 + k12;
+       b13 -= k13 + t0;
+
+       tmp = b11 ^ b10;
+       b11 = (tmp >> 17) | (tmp << (64 - 17));
+       b10 -= b11 + k10;
+       b11 -= k11;
+
+       tmp = b9 ^ b8;
+       b9 = (tmp >> 8) | (tmp << (64 - 8));
+       b8 -= b9 + k8;
+       b9 -= k9;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 47) | (tmp << (64 - 47));
+       b6 -= b7 + k6;
+       b7 -= k7;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 8) | (tmp << (64 - 8));
+       b4 -= b5 + k4;
+       b5 -= k5;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b3 + k2;
+       b3 -= k3;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 24) | (tmp << (64 - 24));
+       b0 -= b1 + k0;
+       b1 -= k1;
+
+       output[15] = b15;
+       output[14] = b14;
+       output[13] = b13;
+       output[12] = b12;
+       output[11] = b11;
+       output[10] = b10;
+       output[9] = b9;
+       output[8] = b8;
+       output[7] = b7;
+       output[6] = b6;
+       output[5] = b5;
+       output[4] = b4;
+       output[3] = b3;
+       output[2] = b2;
+       output[1] = b1;
+       output[0] = b0;
+}
diff --git a/drivers/staging/skein/threefish256Block.c b/drivers/staging/skein/threefish256Block.c
new file mode 100644 (file)
index 0000000..2ae746a
--- /dev/null
@@ -0,0 +1,1137 @@
+#include <linux/string.h>
+#include <threefishApi.h>
+
+
+void threefishEncrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output)
+{
+       u64 b0 = input[0], b1 = input[1],
+         b2 = input[2], b3 = input[3];
+       u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1],
+         k2 = keyCtx->key[2], k3 = keyCtx->key[3],
+         k4 = keyCtx->key[4];
+       u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1],
+         t2 = keyCtx->tweak[2];
+
+       b1 += k1 + t0;
+       b0 += b1 + k0;
+       b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0;
+
+       b3 += k3;
+       b2 += b3 + k2 + t1;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2;
+
+       b0 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0;
+
+       b2 += b3;
+       b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2;
+
+       b1 += k2 + t1;
+       b0 += b1 + k1;
+       b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0;
+
+       b3 += k4 + 1;
+       b2 += b3 + k3 + t2;
+       b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2;
+
+       b0 += b1;
+       b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0;
+
+       b2 += b3;
+       b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2;
+
+
+       b1 += k3 + t2;
+       b0 += b1 + k2;
+       b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0;
+
+       b3 += k0 + 2;
+       b2 += b3 + k4 + t0;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2;
+
+       b0 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0;
+
+       b2 += b3;
+       b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2;
+
+       b1 += k4 + t0;
+       b0 += b1 + k3;
+       b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0;
+
+       b3 += k1 + 3;
+       b2 += b3 + k0 + t1;
+       b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2;
+
+       b0 += b1;
+       b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0;
+
+       b2 += b3;
+       b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2;
+
+
+       b1 += k0 + t1;
+       b0 += b1 + k4;
+       b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0;
+
+       b3 += k2 + 4;
+       b2 += b3 + k1 + t2;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2;
+
+       b0 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0;
+
+       b2 += b3;
+       b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2;
+
+       b1 += k1 + t2;
+       b0 += b1 + k0;
+       b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0;
+
+       b3 += k3 + 5;
+       b2 += b3 + k2 + t0;
+       b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2;
+
+       b0 += b1;
+       b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0;
+
+       b2 += b3;
+       b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2;
+
+
+       b1 += k2 + t0;
+       b0 += b1 + k1;
+       b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0;
+
+       b3 += k4 + 6;
+       b2 += b3 + k3 + t1;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2;
+
+       b0 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0;
+
+       b2 += b3;
+       b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2;
+
+       b1 += k3 + t1;
+       b0 += b1 + k2;
+       b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0;
+
+       b3 += k0 + 7;
+       b2 += b3 + k4 + t2;
+       b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2;
+
+       b0 += b1;
+       b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0;
+
+       b2 += b3;
+       b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2;
+
+
+       b1 += k4 + t2;
+       b0 += b1 + k3;
+       b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0;
+
+       b3 += k1 + 8;
+       b2 += b3 + k0 + t0;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2;
+
+       b0 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0;
+
+       b2 += b3;
+       b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2;
+
+       b1 += k0 + t0;
+       b0 += b1 + k4;
+       b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0;
+
+       b3 += k2 + 9;
+       b2 += b3 + k1 + t1;
+       b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2;
+
+       b0 += b1;
+       b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0;
+
+       b2 += b3;
+       b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2;
+
+
+       b1 += k1 + t1;
+       b0 += b1 + k0;
+       b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0;
+
+       b3 += k3 + 10;
+       b2 += b3 + k2 + t2;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2;
+
+       b0 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0;
+
+       b2 += b3;
+       b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2;
+
+       b1 += k2 + t2;
+       b0 += b1 + k1;
+       b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0;
+
+       b3 += k4 + 11;
+       b2 += b3 + k3 + t0;
+       b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2;
+
+       b0 += b1;
+       b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0;
+
+       b2 += b3;
+       b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2;
+
+
+       b1 += k3 + t0;
+       b0 += b1 + k2;
+       b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0;
+
+       b3 += k0 + 12;
+       b2 += b3 + k4 + t1;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2;
+
+       b0 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0;
+
+       b2 += b3;
+       b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2;
+
+       b1 += k4 + t1;
+       b0 += b1 + k3;
+       b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0;
+
+       b3 += k1 + 13;
+       b2 += b3 + k0 + t2;
+       b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2;
+
+       b0 += b1;
+       b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0;
+
+       b2 += b3;
+       b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2;
+
+
+       b1 += k0 + t2;
+       b0 += b1 + k4;
+       b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0;
+
+       b3 += k2 + 14;
+       b2 += b3 + k1 + t0;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2;
+
+       b0 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0;
+
+       b2 += b3;
+       b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2;
+
+       b1 += k1 + t0;
+       b0 += b1 + k0;
+       b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0;
+
+       b3 += k3 + 15;
+       b2 += b3 + k2 + t1;
+       b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2;
+
+       b0 += b1;
+       b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0;
+
+       b2 += b3;
+       b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2;
+
+
+       b1 += k2 + t1;
+       b0 += b1 + k1;
+       b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0;
+
+       b3 += k4 + 16;
+       b2 += b3 + k3 + t2;
+       b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2;
+
+       b0 += b1;
+       b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0;
+
+       b2 += b3;
+       b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2;
+
+       b1 += k3 + t2;
+       b0 += b1 + k2;
+       b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0;
+
+       b3 += k0 + 17;
+       b2 += b3 + k4 + t0;
+       b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2;
+
+       b0 += b1;
+       b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0;
+
+       b2 += b3;
+       b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2;
+
+       b0 += b3;
+       b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0;
+
+       b2 += b1;
+       b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2;
+
+       output[0] = b0 + k3;
+       output[1] = b1 + k4 + t0;
+       output[2] = b2 + k0 + t1;
+       output[3] = b3 + k1 + 18;
+}
+
+void threefishDecrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output)
+{
+       u64 b0 = input[0], b1 = input[1],
+         b2 = input[2], b3 = input[3];
+       u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1],
+         k2 = keyCtx->key[2], k3 = keyCtx->key[3],
+         k4 = keyCtx->key[4];
+       u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1],
+         t2 = keyCtx->tweak[2];
+
+       u64 tmp;
+
+       b0 -= k3;
+       b1 -= k4 + t0;
+       b2 -= k0 + t1;
+       b3 -= k1 + 18;
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 32) | (tmp << (64 - 32));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 32) | (tmp << (64 - 32));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 58) | (tmp << (64 - 58));
+       b0 -= b1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 22) | (tmp << (64 - 22));
+       b2 -= b3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 46) | (tmp << (64 - 46));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 12) | (tmp << (64 - 12));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 25) | (tmp << (64 - 25));
+       b0 -= b1 + k2;
+       b1 -= k3 + t2;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 33) | (tmp << (64 - 33));
+       b2 -= b3 + k4 + t0;
+       b3 -= k0 + 17;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 37) | (tmp << (64 - 37));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b0 -= b1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 40) | (tmp << (64 - 40));
+       b2 -= b3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 52) | (tmp << (64 - 52));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 57) | (tmp << (64 - 57));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 14) | (tmp << (64 - 14));
+       b0 -= b1 + k1;
+       b1 -= k2 + t1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b2 -= b3 + k3 + t2;
+       b3 -= k4 + 16;
+
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 32) | (tmp << (64 - 32));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 32) | (tmp << (64 - 32));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 58) | (tmp << (64 - 58));
+       b0 -= b1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 22) | (tmp << (64 - 22));
+       b2 -= b3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 46) | (tmp << (64 - 46));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 12) | (tmp << (64 - 12));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 25) | (tmp << (64 - 25));
+       b0 -= b1 + k0;
+       b1 -= k1 + t0;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 33) | (tmp << (64 - 33));
+       b2 -= b3 + k2 + t1;
+       b3 -= k3 + 15;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 37) | (tmp << (64 - 37));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b0 -= b1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 40) | (tmp << (64 - 40));
+       b2 -= b3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 52) | (tmp << (64 - 52));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 57) | (tmp << (64 - 57));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 14) | (tmp << (64 - 14));
+       b0 -= b1 + k4;
+       b1 -= k0 + t2;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b2 -= b3 + k1 + t0;
+       b3 -= k2 + 14;
+
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 32) | (tmp << (64 - 32));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 32) | (tmp << (64 - 32));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 58) | (tmp << (64 - 58));
+       b0 -= b1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 22) | (tmp << (64 - 22));
+       b2 -= b3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 46) | (tmp << (64 - 46));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 12) | (tmp << (64 - 12));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 25) | (tmp << (64 - 25));
+       b0 -= b1 + k3;
+       b1 -= k4 + t1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 33) | (tmp << (64 - 33));
+       b2 -= b3 + k0 + t2;
+       b3 -= k1 + 13;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 37) | (tmp << (64 - 37));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b0 -= b1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 40) | (tmp << (64 - 40));
+       b2 -= b3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 52) | (tmp << (64 - 52));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 57) | (tmp << (64 - 57));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 14) | (tmp << (64 - 14));
+       b0 -= b1 + k2;
+       b1 -= k3 + t0;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b2 -= b3 + k4 + t1;
+       b3 -= k0 + 12;
+
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 32) | (tmp << (64 - 32));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 32) | (tmp << (64 - 32));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 58) | (tmp << (64 - 58));
+       b0 -= b1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 22) | (tmp << (64 - 22));
+       b2 -= b3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 46) | (tmp << (64 - 46));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 12) | (tmp << (64 - 12));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 25) | (tmp << (64 - 25));
+       b0 -= b1 + k1;
+       b1 -= k2 + t2;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 33) | (tmp << (64 - 33));
+       b2 -= b3 + k3 + t0;
+       b3 -= k4 + 11;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 37) | (tmp << (64 - 37));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b0 -= b1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 40) | (tmp << (64 - 40));
+       b2 -= b3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 52) | (tmp << (64 - 52));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 57) | (tmp << (64 - 57));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 14) | (tmp << (64 - 14));
+       b0 -= b1 + k0;
+       b1 -= k1 + t1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b2 -= b3 + k2 + t2;
+       b3 -= k3 + 10;
+
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 32) | (tmp << (64 - 32));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 32) | (tmp << (64 - 32));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 58) | (tmp << (64 - 58));
+       b0 -= b1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 22) | (tmp << (64 - 22));
+       b2 -= b3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 46) | (tmp << (64 - 46));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 12) | (tmp << (64 - 12));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 25) | (tmp << (64 - 25));
+       b0 -= b1 + k4;
+       b1 -= k0 + t0;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 33) | (tmp << (64 - 33));
+       b2 -= b3 + k1 + t1;
+       b3 -= k2 + 9;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 37) | (tmp << (64 - 37));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b0 -= b1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 40) | (tmp << (64 - 40));
+       b2 -= b3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 52) | (tmp << (64 - 52));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 57) | (tmp << (64 - 57));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 14) | (tmp << (64 - 14));
+       b0 -= b1 + k3;
+       b1 -= k4 + t2;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b2 -= b3 + k0 + t0;
+       b3 -= k1 + 8;
+
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 32) | (tmp << (64 - 32));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 32) | (tmp << (64 - 32));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 58) | (tmp << (64 - 58));
+       b0 -= b1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 22) | (tmp << (64 - 22));
+       b2 -= b3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 46) | (tmp << (64 - 46));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 12) | (tmp << (64 - 12));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 25) | (tmp << (64 - 25));
+       b0 -= b1 + k2;
+       b1 -= k3 + t1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 33) | (tmp << (64 - 33));
+       b2 -= b3 + k4 + t2;
+       b3 -= k0 + 7;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 37) | (tmp << (64 - 37));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b0 -= b1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 40) | (tmp << (64 - 40));
+       b2 -= b3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 52) | (tmp << (64 - 52));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 57) | (tmp << (64 - 57));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 14) | (tmp << (64 - 14));
+       b0 -= b1 + k1;
+       b1 -= k2 + t0;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b2 -= b3 + k3 + t1;
+       b3 -= k4 + 6;
+
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 32) | (tmp << (64 - 32));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 32) | (tmp << (64 - 32));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 58) | (tmp << (64 - 58));
+       b0 -= b1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 22) | (tmp << (64 - 22));
+       b2 -= b3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 46) | (tmp << (64 - 46));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 12) | (tmp << (64 - 12));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 25) | (tmp << (64 - 25));
+       b0 -= b1 + k0;
+       b1 -= k1 + t2;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 33) | (tmp << (64 - 33));
+       b2 -= b3 + k2 + t0;
+       b3 -= k3 + 5;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 37) | (tmp << (64 - 37));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b0 -= b1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 40) | (tmp << (64 - 40));
+       b2 -= b3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 52) | (tmp << (64 - 52));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 57) | (tmp << (64 - 57));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 14) | (tmp << (64 - 14));
+       b0 -= b1 + k4;
+       b1 -= k0 + t1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b2 -= b3 + k1 + t2;
+       b3 -= k2 + 4;
+
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 32) | (tmp << (64 - 32));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 32) | (tmp << (64 - 32));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 58) | (tmp << (64 - 58));
+       b0 -= b1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 22) | (tmp << (64 - 22));
+       b2 -= b3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 46) | (tmp << (64 - 46));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 12) | (tmp << (64 - 12));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 25) | (tmp << (64 - 25));
+       b0 -= b1 + k3;
+       b1 -= k4 + t0;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 33) | (tmp << (64 - 33));
+       b2 -= b3 + k0 + t1;
+       b3 -= k1 + 3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 37) | (tmp << (64 - 37));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b0 -= b1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 40) | (tmp << (64 - 40));
+       b2 -= b3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 52) | (tmp << (64 - 52));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 57) | (tmp << (64 - 57));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 14) | (tmp << (64 - 14));
+       b0 -= b1 + k2;
+       b1 -= k3 + t2;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b2 -= b3 + k4 + t0;
+       b3 -= k0 + 2;
+
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 32) | (tmp << (64 - 32));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 32) | (tmp << (64 - 32));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 58) | (tmp << (64 - 58));
+       b0 -= b1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 22) | (tmp << (64 - 22));
+       b2 -= b3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 46) | (tmp << (64 - 46));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 12) | (tmp << (64 - 12));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 25) | (tmp << (64 - 25));
+       b0 -= b1 + k1;
+       b1 -= k2 + t1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 33) | (tmp << (64 - 33));
+       b2 -= b3 + k3 + t2;
+       b3 -= k4 + 1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 5) | (tmp << (64 - 5));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 37) | (tmp << (64 - 37));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 23) | (tmp << (64 - 23));
+       b0 -= b1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 40) | (tmp << (64 - 40));
+       b2 -= b3;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 52) | (tmp << (64 - 52));
+       b0 -= b3;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 57) | (tmp << (64 - 57));
+       b2 -= b1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 14) | (tmp << (64 - 14));
+       b0 -= b1 + k0;
+       b1 -= k1 + t0;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 16) | (tmp << (64 - 16));
+       b2 -= b3 + k2 + t1;
+       b3 -= k3;
+
+       output[0] = b0;
+       output[1] = b1;
+       output[2] = b2;
+       output[3] = b3;
+}
diff --git a/drivers/staging/skein/threefish512Block.c b/drivers/staging/skein/threefish512Block.c
new file mode 100644 (file)
index 0000000..f428fd6
--- /dev/null
@@ -0,0 +1,2223 @@
+#include <linux/string.h>
+#include <threefishApi.h>
+
+
+void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output)
+{
+       u64 b0 = input[0], b1 = input[1],
+         b2 = input[2], b3 = input[3],
+         b4 = input[4], b5 = input[5],
+         b6 = input[6], b7 = input[7];
+       u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1],
+         k2 = keyCtx->key[2], k3 = keyCtx->key[3],
+         k4 = keyCtx->key[4], k5 = keyCtx->key[5],
+         k6 = keyCtx->key[6], k7 = keyCtx->key[7],
+         k8 = keyCtx->key[8];
+       u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1],
+         t2 = keyCtx->tweak[2];
+
+       b1 += k1;
+       b0 += b1 + k0;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0;
+
+       b3 += k3;
+       b2 += b3 + k2;
+       b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2;
+
+       b5 += k5 + t0;
+       b4 += b5 + k4;
+       b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4;
+
+       b7 += k7;
+       b6 += b7 + k6 + t1;
+       b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6;
+
+       b2 += b1;
+       b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2;
+
+       b4 += b7;
+       b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4;
+
+       b6 += b5;
+       b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6;
+
+       b0 += b3;
+       b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0;
+
+       b4 += b1;
+       b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4;
+
+       b6 += b3;
+       b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6;
+
+       b0 += b5;
+       b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0;
+
+       b2 += b7;
+       b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2;
+
+       b6 += b1;
+       b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6;
+
+       b0 += b7;
+       b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4;
+
+       b1 += k2;
+       b0 += b1 + k1;
+       b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0;
+
+       b3 += k4;
+       b2 += b3 + k3;
+       b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2;
+
+       b5 += k6 + t1;
+       b4 += b5 + k5;
+       b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4;
+
+       b7 += k8 + 1;
+       b6 += b7 + k7 + t2;
+       b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6;
+
+       b2 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2;
+
+       b4 += b7;
+       b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4;
+
+       b6 += b5;
+       b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6;
+
+       b0 += b3;
+       b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0;
+
+       b4 += b1;
+       b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4;
+
+       b6 += b3;
+       b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6;
+
+       b0 += b5;
+       b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0;
+
+       b2 += b7;
+       b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2;
+
+       b6 += b1;
+       b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6;
+
+       b0 += b7;
+       b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4;
+
+       b1 += k3;
+       b0 += b1 + k2;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0;
+
+       b3 += k5;
+       b2 += b3 + k4;
+       b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2;
+
+       b5 += k7 + t2;
+       b4 += b5 + k6;
+       b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4;
+
+       b7 += k0 + 2;
+       b6 += b7 + k8 + t0;
+       b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6;
+
+       b2 += b1;
+       b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2;
+
+       b4 += b7;
+       b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4;
+
+       b6 += b5;
+       b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6;
+
+       b0 += b3;
+       b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0;
+
+       b4 += b1;
+       b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4;
+
+       b6 += b3;
+       b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6;
+
+       b0 += b5;
+       b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0;
+
+       b2 += b7;
+       b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2;
+
+       b6 += b1;
+       b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6;
+
+       b0 += b7;
+       b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4;
+
+       b1 += k4;
+       b0 += b1 + k3;
+       b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0;
+
+       b3 += k6;
+       b2 += b3 + k5;
+       b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2;
+
+       b5 += k8 + t0;
+       b4 += b5 + k7;
+       b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4;
+
+       b7 += k1 + 3;
+       b6 += b7 + k0 + t1;
+       b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6;
+
+       b2 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2;
+
+       b4 += b7;
+       b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4;
+
+       b6 += b5;
+       b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6;
+
+       b0 += b3;
+       b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0;
+
+       b4 += b1;
+       b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4;
+
+       b6 += b3;
+       b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6;
+
+       b0 += b5;
+       b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0;
+
+       b2 += b7;
+       b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2;
+
+       b6 += b1;
+       b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6;
+
+       b0 += b7;
+       b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4;
+
+       b1 += k5;
+       b0 += b1 + k4;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0;
+
+       b3 += k7;
+       b2 += b3 + k6;
+       b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2;
+
+       b5 += k0 + t1;
+       b4 += b5 + k8;
+       b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4;
+
+       b7 += k2 + 4;
+       b6 += b7 + k1 + t2;
+       b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6;
+
+       b2 += b1;
+       b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2;
+
+       b4 += b7;
+       b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4;
+
+       b6 += b5;
+       b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6;
+
+       b0 += b3;
+       b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0;
+
+       b4 += b1;
+       b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4;
+
+       b6 += b3;
+       b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6;
+
+       b0 += b5;
+       b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0;
+
+       b2 += b7;
+       b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2;
+
+       b6 += b1;
+       b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6;
+
+       b0 += b7;
+       b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4;
+
+       b1 += k6;
+       b0 += b1 + k5;
+       b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0;
+
+       b3 += k8;
+       b2 += b3 + k7;
+       b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2;
+
+       b5 += k1 + t2;
+       b4 += b5 + k0;
+       b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4;
+
+       b7 += k3 + 5;
+       b6 += b7 + k2 + t0;
+       b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6;
+
+       b2 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2;
+
+       b4 += b7;
+       b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4;
+
+       b6 += b5;
+       b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6;
+
+       b0 += b3;
+       b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0;
+
+       b4 += b1;
+       b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4;
+
+       b6 += b3;
+       b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6;
+
+       b0 += b5;
+       b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0;
+
+       b2 += b7;
+       b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2;
+
+       b6 += b1;
+       b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6;
+
+       b0 += b7;
+       b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4;
+
+       b1 += k7;
+       b0 += b1 + k6;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0;
+
+       b3 += k0;
+       b2 += b3 + k8;
+       b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2;
+
+       b5 += k2 + t0;
+       b4 += b5 + k1;
+       b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4;
+
+       b7 += k4 + 6;
+       b6 += b7 + k3 + t1;
+       b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6;
+
+       b2 += b1;
+       b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2;
+
+       b4 += b7;
+       b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4;
+
+       b6 += b5;
+       b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6;
+
+       b0 += b3;
+       b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0;
+
+       b4 += b1;
+       b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4;
+
+       b6 += b3;
+       b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6;
+
+       b0 += b5;
+       b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0;
+
+       b2 += b7;
+       b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2;
+
+       b6 += b1;
+       b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6;
+
+       b0 += b7;
+       b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4;
+
+       b1 += k8;
+       b0 += b1 + k7;
+       b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0;
+
+       b3 += k1;
+       b2 += b3 + k0;
+       b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2;
+
+       b5 += k3 + t1;
+       b4 += b5 + k2;
+       b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4;
+
+       b7 += k5 + 7;
+       b6 += b7 + k4 + t2;
+       b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6;
+
+       b2 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2;
+
+       b4 += b7;
+       b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4;
+
+       b6 += b5;
+       b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6;
+
+       b0 += b3;
+       b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0;
+
+       b4 += b1;
+       b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4;
+
+       b6 += b3;
+       b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6;
+
+       b0 += b5;
+       b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0;
+
+       b2 += b7;
+       b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2;
+
+       b6 += b1;
+       b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6;
+
+       b0 += b7;
+       b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4;
+
+       b1 += k0;
+       b0 += b1 + k8;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0;
+
+       b3 += k2;
+       b2 += b3 + k1;
+       b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2;
+
+       b5 += k4 + t2;
+       b4 += b5 + k3;
+       b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4;
+
+       b7 += k6 + 8;
+       b6 += b7 + k5 + t0;
+       b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6;
+
+       b2 += b1;
+       b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2;
+
+       b4 += b7;
+       b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4;
+
+       b6 += b5;
+       b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6;
+
+       b0 += b3;
+       b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0;
+
+       b4 += b1;
+       b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4;
+
+       b6 += b3;
+       b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6;
+
+       b0 += b5;
+       b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0;
+
+       b2 += b7;
+       b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2;
+
+       b6 += b1;
+       b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6;
+
+       b0 += b7;
+       b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4;
+
+       b1 += k1;
+       b0 += b1 + k0;
+       b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0;
+
+       b3 += k3;
+       b2 += b3 + k2;
+       b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2;
+
+       b5 += k5 + t0;
+       b4 += b5 + k4;
+       b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4;
+
+       b7 += k7 + 9;
+       b6 += b7 + k6 + t1;
+       b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6;
+
+       b2 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2;
+
+       b4 += b7;
+       b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4;
+
+       b6 += b5;
+       b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6;
+
+       b0 += b3;
+       b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0;
+
+       b4 += b1;
+       b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4;
+
+       b6 += b3;
+       b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6;
+
+       b0 += b5;
+       b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0;
+
+       b2 += b7;
+       b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2;
+
+       b6 += b1;
+       b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6;
+
+       b0 += b7;
+       b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4;
+
+       b1 += k2;
+       b0 += b1 + k1;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0;
+
+       b3 += k4;
+       b2 += b3 + k3;
+       b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2;
+
+       b5 += k6 + t1;
+       b4 += b5 + k5;
+       b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4;
+
+       b7 += k8 + 10;
+       b6 += b7 + k7 + t2;
+       b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6;
+
+       b2 += b1;
+       b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2;
+
+       b4 += b7;
+       b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4;
+
+       b6 += b5;
+       b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6;
+
+       b0 += b3;
+       b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0;
+
+       b4 += b1;
+       b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4;
+
+       b6 += b3;
+       b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6;
+
+       b0 += b5;
+       b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0;
+
+       b2 += b7;
+       b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2;
+
+       b6 += b1;
+       b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6;
+
+       b0 += b7;
+       b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4;
+
+       b1 += k3;
+       b0 += b1 + k2;
+       b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0;
+
+       b3 += k5;
+       b2 += b3 + k4;
+       b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2;
+
+       b5 += k7 + t2;
+       b4 += b5 + k6;
+       b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4;
+
+       b7 += k0 + 11;
+       b6 += b7 + k8 + t0;
+       b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6;
+
+       b2 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2;
+
+       b4 += b7;
+       b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4;
+
+       b6 += b5;
+       b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6;
+
+       b0 += b3;
+       b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0;
+
+       b4 += b1;
+       b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4;
+
+       b6 += b3;
+       b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6;
+
+       b0 += b5;
+       b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0;
+
+       b2 += b7;
+       b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2;
+
+       b6 += b1;
+       b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6;
+
+       b0 += b7;
+       b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4;
+
+       b1 += k4;
+       b0 += b1 + k3;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0;
+
+       b3 += k6;
+       b2 += b3 + k5;
+       b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2;
+
+       b5 += k8 + t0;
+       b4 += b5 + k7;
+       b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4;
+
+       b7 += k1 + 12;
+       b6 += b7 + k0 + t1;
+       b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6;
+
+       b2 += b1;
+       b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2;
+
+       b4 += b7;
+       b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4;
+
+       b6 += b5;
+       b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6;
+
+       b0 += b3;
+       b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0;
+
+       b4 += b1;
+       b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4;
+
+       b6 += b3;
+       b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6;
+
+       b0 += b5;
+       b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0;
+
+       b2 += b7;
+       b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2;
+
+       b6 += b1;
+       b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6;
+
+       b0 += b7;
+       b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4;
+
+       b1 += k5;
+       b0 += b1 + k4;
+       b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0;
+
+       b3 += k7;
+       b2 += b3 + k6;
+       b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2;
+
+       b5 += k0 + t1;
+       b4 += b5 + k8;
+       b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4;
+
+       b7 += k2 + 13;
+       b6 += b7 + k1 + t2;
+       b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6;
+
+       b2 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2;
+
+       b4 += b7;
+       b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4;
+
+       b6 += b5;
+       b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6;
+
+       b0 += b3;
+       b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0;
+
+       b4 += b1;
+       b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4;
+
+       b6 += b3;
+       b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6;
+
+       b0 += b5;
+       b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0;
+
+       b2 += b7;
+       b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2;
+
+       b6 += b1;
+       b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6;
+
+       b0 += b7;
+       b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4;
+
+       b1 += k6;
+       b0 += b1 + k5;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0;
+
+       b3 += k8;
+       b2 += b3 + k7;
+       b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2;
+
+       b5 += k1 + t2;
+       b4 += b5 + k0;
+       b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4;
+
+       b7 += k3 + 14;
+       b6 += b7 + k2 + t0;
+       b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6;
+
+       b2 += b1;
+       b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2;
+
+       b4 += b7;
+       b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4;
+
+       b6 += b5;
+       b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6;
+
+       b0 += b3;
+       b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0;
+
+       b4 += b1;
+       b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4;
+
+       b6 += b3;
+       b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6;
+
+       b0 += b5;
+       b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0;
+
+       b2 += b7;
+       b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2;
+
+       b6 += b1;
+       b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6;
+
+       b0 += b7;
+       b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4;
+
+       b1 += k7;
+       b0 += b1 + k6;
+       b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0;
+
+       b3 += k0;
+       b2 += b3 + k8;
+       b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2;
+
+       b5 += k2 + t0;
+       b4 += b5 + k1;
+       b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4;
+
+       b7 += k4 + 15;
+       b6 += b7 + k3 + t1;
+       b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6;
+
+       b2 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2;
+
+       b4 += b7;
+       b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4;
+
+       b6 += b5;
+       b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6;
+
+       b0 += b3;
+       b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0;
+
+       b4 += b1;
+       b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4;
+
+       b6 += b3;
+       b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6;
+
+       b0 += b5;
+       b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0;
+
+       b2 += b7;
+       b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2;
+
+       b6 += b1;
+       b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6;
+
+       b0 += b7;
+       b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4;
+
+       b1 += k8;
+       b0 += b1 + k7;
+       b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0;
+
+       b3 += k1;
+       b2 += b3 + k0;
+       b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2;
+
+       b5 += k3 + t1;
+       b4 += b5 + k2;
+       b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4;
+
+       b7 += k5 + 16;
+       b6 += b7 + k4 + t2;
+       b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6;
+
+       b2 += b1;
+       b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2;
+
+       b4 += b7;
+       b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4;
+
+       b6 += b5;
+       b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6;
+
+       b0 += b3;
+       b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0;
+
+       b4 += b1;
+       b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4;
+
+       b6 += b3;
+       b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6;
+
+       b0 += b5;
+       b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0;
+
+       b2 += b7;
+       b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2;
+
+       b6 += b1;
+       b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6;
+
+       b0 += b7;
+       b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4;
+
+       b1 += k0;
+       b0 += b1 + k8;
+       b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0;
+
+       b3 += k2;
+       b2 += b3 + k1;
+       b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2;
+
+       b5 += k4 + t2;
+       b4 += b5 + k3;
+       b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4;
+
+       b7 += k6 + 17;
+       b6 += b7 + k5 + t0;
+       b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6;
+
+       b2 += b1;
+       b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2;
+
+       b4 += b7;
+       b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4;
+
+       b6 += b5;
+       b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6;
+
+       b0 += b3;
+       b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0;
+
+       b4 += b1;
+       b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4;
+
+       b6 += b3;
+       b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6;
+
+       b0 += b5;
+       b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0;
+
+       b2 += b7;
+       b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2;
+
+       b6 += b1;
+       b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6;
+
+       b0 += b7;
+       b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0;
+
+       b2 += b5;
+       b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2;
+
+       b4 += b3;
+       b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4;
+
+       output[0] = b0 + k0;
+       output[1] = b1 + k1;
+       output[2] = b2 + k2;
+       output[3] = b3 + k3;
+       output[4] = b4 + k4;
+       output[5] = b5 + k5 + t0;
+       output[6] = b6 + k6 + t1;
+       output[7] = b7 + k7 + 18;
+}
+
+void threefishDecrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output)
+{
+       u64 b0 = input[0], b1 = input[1],
+         b2 = input[2], b3 = input[3],
+         b4 = input[4], b5 = input[5],
+         b6 = input[6], b7 = input[7];
+       u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1],
+         k2 = keyCtx->key[2], k3 = keyCtx->key[3],
+         k4 = keyCtx->key[4], k5 = keyCtx->key[5],
+         k6 = keyCtx->key[6], k7 = keyCtx->key[7],
+         k8 = keyCtx->key[8];
+       u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1],
+         t2 = keyCtx->tweak[2];
+
+       u64 tmp;
+
+       b0 -= k0;
+       b1 -= k1;
+       b2 -= k2;
+       b3 -= k3;
+       b4 -= k4;
+       b5 -= k5 + t0;
+       b6 -= k6 + t1;
+       b7 -= k7 + 18;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 22) | (tmp << (64 - 22));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 56) | (tmp << (64 - 56));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 35) | (tmp << (64 - 35));
+       b0 -= b7;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 8) | (tmp << (64 - 8));
+       b6 -= b1;
+
+       tmp = b7 ^ b2;
+       b7 = (tmp >> 43) | (tmp << (64 - 43));
+       b2 -= b7;
+
+       tmp = b5 ^ b0;
+       b5 = (tmp >> 39) | (tmp << (64 - 39));
+       b0 -= b5;
+
+       tmp = b3 ^ b6;
+       b3 = (tmp >> 29) | (tmp << (64 - 29));
+       b6 -= b3;
+
+       tmp = b1 ^ b4;
+       b1 = (tmp >> 25) | (tmp << (64 - 25));
+       b4 -= b1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 17) | (tmp << (64 - 17));
+       b0 -= b3;
+
+       tmp = b5 ^ b6;
+       b5 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b5;
+
+       tmp = b7 ^ b4;
+       b7 = (tmp >> 50) | (tmp << (64 - 50));
+       b4 -= b7;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 24) | (tmp << (64 - 24));
+       b6 -= b7 + k5 + t0;
+       b7 -= k6 + 17;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 34) | (tmp << (64 - 34));
+       b4 -= b5 + k3;
+       b5 -= k4 + t2;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 30) | (tmp << (64 - 30));
+       b2 -= b3 + k1;
+       b3 -= k2;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 39) | (tmp << (64 - 39));
+       b0 -= b1 + k8;
+       b1 -= k0;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 56) | (tmp << (64 - 56));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 54) | (tmp << (64 - 54));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b7;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 44) | (tmp << (64 - 44));
+       b6 -= b1;
+
+       tmp = b7 ^ b2;
+       b7 = (tmp >> 39) | (tmp << (64 - 39));
+       b2 -= b7;
+
+       tmp = b5 ^ b0;
+       b5 = (tmp >> 36) | (tmp << (64 - 36));
+       b0 -= b5;
+
+       tmp = b3 ^ b6;
+       b3 = (tmp >> 49) | (tmp << (64 - 49));
+       b6 -= b3;
+
+       tmp = b1 ^ b4;
+       b1 = (tmp >> 17) | (tmp << (64 - 17));
+       b4 -= b1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 42) | (tmp << (64 - 42));
+       b0 -= b3;
+
+       tmp = b5 ^ b6;
+       b5 = (tmp >> 14) | (tmp << (64 - 14));
+       b6 -= b5;
+
+       tmp = b7 ^ b4;
+       b7 = (tmp >> 27) | (tmp << (64 - 27));
+       b4 -= b7;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 33) | (tmp << (64 - 33));
+       b2 -= b1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 37) | (tmp << (64 - 37));
+       b6 -= b7 + k4 + t2;
+       b7 -= k5 + 16;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 19) | (tmp << (64 - 19));
+       b4 -= b5 + k2;
+       b5 -= k3 + t1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 36) | (tmp << (64 - 36));
+       b2 -= b3 + k0;
+       b3 -= k1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b0 -= b1 + k7;
+       b1 -= k8;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 22) | (tmp << (64 - 22));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 56) | (tmp << (64 - 56));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 35) | (tmp << (64 - 35));
+       b0 -= b7;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 8) | (tmp << (64 - 8));
+       b6 -= b1;
+
+       tmp = b7 ^ b2;
+       b7 = (tmp >> 43) | (tmp << (64 - 43));
+       b2 -= b7;
+
+       tmp = b5 ^ b0;
+       b5 = (tmp >> 39) | (tmp << (64 - 39));
+       b0 -= b5;
+
+       tmp = b3 ^ b6;
+       b3 = (tmp >> 29) | (tmp << (64 - 29));
+       b6 -= b3;
+
+       tmp = b1 ^ b4;
+       b1 = (tmp >> 25) | (tmp << (64 - 25));
+       b4 -= b1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 17) | (tmp << (64 - 17));
+       b0 -= b3;
+
+       tmp = b5 ^ b6;
+       b5 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b5;
+
+       tmp = b7 ^ b4;
+       b7 = (tmp >> 50) | (tmp << (64 - 50));
+       b4 -= b7;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 24) | (tmp << (64 - 24));
+       b6 -= b7 + k3 + t1;
+       b7 -= k4 + 15;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 34) | (tmp << (64 - 34));
+       b4 -= b5 + k1;
+       b5 -= k2 + t0;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 30) | (tmp << (64 - 30));
+       b2 -= b3 + k8;
+       b3 -= k0;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 39) | (tmp << (64 - 39));
+       b0 -= b1 + k6;
+       b1 -= k7;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 56) | (tmp << (64 - 56));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 54) | (tmp << (64 - 54));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b7;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 44) | (tmp << (64 - 44));
+       b6 -= b1;
+
+       tmp = b7 ^ b2;
+       b7 = (tmp >> 39) | (tmp << (64 - 39));
+       b2 -= b7;
+
+       tmp = b5 ^ b0;
+       b5 = (tmp >> 36) | (tmp << (64 - 36));
+       b0 -= b5;
+
+       tmp = b3 ^ b6;
+       b3 = (tmp >> 49) | (tmp << (64 - 49));
+       b6 -= b3;
+
+       tmp = b1 ^ b4;
+       b1 = (tmp >> 17) | (tmp << (64 - 17));
+       b4 -= b1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 42) | (tmp << (64 - 42));
+       b0 -= b3;
+
+       tmp = b5 ^ b6;
+       b5 = (tmp >> 14) | (tmp << (64 - 14));
+       b6 -= b5;
+
+       tmp = b7 ^ b4;
+       b7 = (tmp >> 27) | (tmp << (64 - 27));
+       b4 -= b7;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 33) | (tmp << (64 - 33));
+       b2 -= b1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 37) | (tmp << (64 - 37));
+       b6 -= b7 + k2 + t0;
+       b7 -= k3 + 14;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 19) | (tmp << (64 - 19));
+       b4 -= b5 + k0;
+       b5 -= k1 + t2;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 36) | (tmp << (64 - 36));
+       b2 -= b3 + k7;
+       b3 -= k8;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b0 -= b1 + k5;
+       b1 -= k6;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 22) | (tmp << (64 - 22));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 56) | (tmp << (64 - 56));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 35) | (tmp << (64 - 35));
+       b0 -= b7;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 8) | (tmp << (64 - 8));
+       b6 -= b1;
+
+       tmp = b7 ^ b2;
+       b7 = (tmp >> 43) | (tmp << (64 - 43));
+       b2 -= b7;
+
+       tmp = b5 ^ b0;
+       b5 = (tmp >> 39) | (tmp << (64 - 39));
+       b0 -= b5;
+
+       tmp = b3 ^ b6;
+       b3 = (tmp >> 29) | (tmp << (64 - 29));
+       b6 -= b3;
+
+       tmp = b1 ^ b4;
+       b1 = (tmp >> 25) | (tmp << (64 - 25));
+       b4 -= b1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 17) | (tmp << (64 - 17));
+       b0 -= b3;
+
+       tmp = b5 ^ b6;
+       b5 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b5;
+
+       tmp = b7 ^ b4;
+       b7 = (tmp >> 50) | (tmp << (64 - 50));
+       b4 -= b7;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 24) | (tmp << (64 - 24));
+       b6 -= b7 + k1 + t2;
+       b7 -= k2 + 13;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 34) | (tmp << (64 - 34));
+       b4 -= b5 + k8;
+       b5 -= k0 + t1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 30) | (tmp << (64 - 30));
+       b2 -= b3 + k6;
+       b3 -= k7;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 39) | (tmp << (64 - 39));
+       b0 -= b1 + k4;
+       b1 -= k5;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 56) | (tmp << (64 - 56));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 54) | (tmp << (64 - 54));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b7;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 44) | (tmp << (64 - 44));
+       b6 -= b1;
+
+       tmp = b7 ^ b2;
+       b7 = (tmp >> 39) | (tmp << (64 - 39));
+       b2 -= b7;
+
+       tmp = b5 ^ b0;
+       b5 = (tmp >> 36) | (tmp << (64 - 36));
+       b0 -= b5;
+
+       tmp = b3 ^ b6;
+       b3 = (tmp >> 49) | (tmp << (64 - 49));
+       b6 -= b3;
+
+       tmp = b1 ^ b4;
+       b1 = (tmp >> 17) | (tmp << (64 - 17));
+       b4 -= b1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 42) | (tmp << (64 - 42));
+       b0 -= b3;
+
+       tmp = b5 ^ b6;
+       b5 = (tmp >> 14) | (tmp << (64 - 14));
+       b6 -= b5;
+
+       tmp = b7 ^ b4;
+       b7 = (tmp >> 27) | (tmp << (64 - 27));
+       b4 -= b7;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 33) | (tmp << (64 - 33));
+       b2 -= b1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 37) | (tmp << (64 - 37));
+       b6 -= b7 + k0 + t1;
+       b7 -= k1 + 12;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 19) | (tmp << (64 - 19));
+       b4 -= b5 + k7;
+       b5 -= k8 + t0;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 36) | (tmp << (64 - 36));
+       b2 -= b3 + k5;
+       b3 -= k6;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b0 -= b1 + k3;
+       b1 -= k4;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 22) | (tmp << (64 - 22));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 56) | (tmp << (64 - 56));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 35) | (tmp << (64 - 35));
+       b0 -= b7;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 8) | (tmp << (64 - 8));
+       b6 -= b1;
+
+       tmp = b7 ^ b2;
+       b7 = (tmp >> 43) | (tmp << (64 - 43));
+       b2 -= b7;
+
+       tmp = b5 ^ b0;
+       b5 = (tmp >> 39) | (tmp << (64 - 39));
+       b0 -= b5;
+
+       tmp = b3 ^ b6;
+       b3 = (tmp >> 29) | (tmp << (64 - 29));
+       b6 -= b3;
+
+       tmp = b1 ^ b4;
+       b1 = (tmp >> 25) | (tmp << (64 - 25));
+       b4 -= b1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 17) | (tmp << (64 - 17));
+       b0 -= b3;
+
+       tmp = b5 ^ b6;
+       b5 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b5;
+
+       tmp = b7 ^ b4;
+       b7 = (tmp >> 50) | (tmp << (64 - 50));
+       b4 -= b7;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 24) | (tmp << (64 - 24));
+       b6 -= b7 + k8 + t0;
+       b7 -= k0 + 11;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 34) | (tmp << (64 - 34));
+       b4 -= b5 + k6;
+       b5 -= k7 + t2;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 30) | (tmp << (64 - 30));
+       b2 -= b3 + k4;
+       b3 -= k5;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 39) | (tmp << (64 - 39));
+       b0 -= b1 + k2;
+       b1 -= k3;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 56) | (tmp << (64 - 56));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 54) | (tmp << (64 - 54));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b7;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 44) | (tmp << (64 - 44));
+       b6 -= b1;
+
+       tmp = b7 ^ b2;
+       b7 = (tmp >> 39) | (tmp << (64 - 39));
+       b2 -= b7;
+
+       tmp = b5 ^ b0;
+       b5 = (tmp >> 36) | (tmp << (64 - 36));
+       b0 -= b5;
+
+       tmp = b3 ^ b6;
+       b3 = (tmp >> 49) | (tmp << (64 - 49));
+       b6 -= b3;
+
+       tmp = b1 ^ b4;
+       b1 = (tmp >> 17) | (tmp << (64 - 17));
+       b4 -= b1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 42) | (tmp << (64 - 42));
+       b0 -= b3;
+
+       tmp = b5 ^ b6;
+       b5 = (tmp >> 14) | (tmp << (64 - 14));
+       b6 -= b5;
+
+       tmp = b7 ^ b4;
+       b7 = (tmp >> 27) | (tmp << (64 - 27));
+       b4 -= b7;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 33) | (tmp << (64 - 33));
+       b2 -= b1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 37) | (tmp << (64 - 37));
+       b6 -= b7 + k7 + t2;
+       b7 -= k8 + 10;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 19) | (tmp << (64 - 19));
+       b4 -= b5 + k5;
+       b5 -= k6 + t1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 36) | (tmp << (64 - 36));
+       b2 -= b3 + k3;
+       b3 -= k4;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b0 -= b1 + k1;
+       b1 -= k2;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 22) | (tmp << (64 - 22));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 56) | (tmp << (64 - 56));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 35) | (tmp << (64 - 35));
+       b0 -= b7;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 8) | (tmp << (64 - 8));
+       b6 -= b1;
+
+       tmp = b7 ^ b2;
+       b7 = (tmp >> 43) | (tmp << (64 - 43));
+       b2 -= b7;
+
+       tmp = b5 ^ b0;
+       b5 = (tmp >> 39) | (tmp << (64 - 39));
+       b0 -= b5;
+
+       tmp = b3 ^ b6;
+       b3 = (tmp >> 29) | (tmp << (64 - 29));
+       b6 -= b3;
+
+       tmp = b1 ^ b4;
+       b1 = (tmp >> 25) | (tmp << (64 - 25));
+       b4 -= b1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 17) | (tmp << (64 - 17));
+       b0 -= b3;
+
+       tmp = b5 ^ b6;
+       b5 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b5;
+
+       tmp = b7 ^ b4;
+       b7 = (tmp >> 50) | (tmp << (64 - 50));
+       b4 -= b7;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 24) | (tmp << (64 - 24));
+       b6 -= b7 + k6 + t1;
+       b7 -= k7 + 9;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 34) | (tmp << (64 - 34));
+       b4 -= b5 + k4;
+       b5 -= k5 + t0;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 30) | (tmp << (64 - 30));
+       b2 -= b3 + k2;
+       b3 -= k3;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 39) | (tmp << (64 - 39));
+       b0 -= b1 + k0;
+       b1 -= k1;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 56) | (tmp << (64 - 56));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 54) | (tmp << (64 - 54));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b7;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 44) | (tmp << (64 - 44));
+       b6 -= b1;
+
+       tmp = b7 ^ b2;
+       b7 = (tmp >> 39) | (tmp << (64 - 39));
+       b2 -= b7;
+
+       tmp = b5 ^ b0;
+       b5 = (tmp >> 36) | (tmp << (64 - 36));
+       b0 -= b5;
+
+       tmp = b3 ^ b6;
+       b3 = (tmp >> 49) | (tmp << (64 - 49));
+       b6 -= b3;
+
+       tmp = b1 ^ b4;
+       b1 = (tmp >> 17) | (tmp << (64 - 17));
+       b4 -= b1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 42) | (tmp << (64 - 42));
+       b0 -= b3;
+
+       tmp = b5 ^ b6;
+       b5 = (tmp >> 14) | (tmp << (64 - 14));
+       b6 -= b5;
+
+       tmp = b7 ^ b4;
+       b7 = (tmp >> 27) | (tmp << (64 - 27));
+       b4 -= b7;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 33) | (tmp << (64 - 33));
+       b2 -= b1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 37) | (tmp << (64 - 37));
+       b6 -= b7 + k5 + t0;
+       b7 -= k6 + 8;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 19) | (tmp << (64 - 19));
+       b4 -= b5 + k3;
+       b5 -= k4 + t2;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 36) | (tmp << (64 - 36));
+       b2 -= b3 + k1;
+       b3 -= k2;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b0 -= b1 + k8;
+       b1 -= k0;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 22) | (tmp << (64 - 22));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 56) | (tmp << (64 - 56));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 35) | (tmp << (64 - 35));
+       b0 -= b7;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 8) | (tmp << (64 - 8));
+       b6 -= b1;
+
+       tmp = b7 ^ b2;
+       b7 = (tmp >> 43) | (tmp << (64 - 43));
+       b2 -= b7;
+
+       tmp = b5 ^ b0;
+       b5 = (tmp >> 39) | (tmp << (64 - 39));
+       b0 -= b5;
+
+       tmp = b3 ^ b6;
+       b3 = (tmp >> 29) | (tmp << (64 - 29));
+       b6 -= b3;
+
+       tmp = b1 ^ b4;
+       b1 = (tmp >> 25) | (tmp << (64 - 25));
+       b4 -= b1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 17) | (tmp << (64 - 17));
+       b0 -= b3;
+
+       tmp = b5 ^ b6;
+       b5 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b5;
+
+       tmp = b7 ^ b4;
+       b7 = (tmp >> 50) | (tmp << (64 - 50));
+       b4 -= b7;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 24) | (tmp << (64 - 24));
+       b6 -= b7 + k4 + t2;
+       b7 -= k5 + 7;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 34) | (tmp << (64 - 34));
+       b4 -= b5 + k2;
+       b5 -= k3 + t1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 30) | (tmp << (64 - 30));
+       b2 -= b3 + k0;
+       b3 -= k1;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 39) | (tmp << (64 - 39));
+       b0 -= b1 + k7;
+       b1 -= k8;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 56) | (tmp << (64 - 56));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 54) | (tmp << (64 - 54));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b7;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 44) | (tmp << (64 - 44));
+       b6 -= b1;
+
+       tmp = b7 ^ b2;
+       b7 = (tmp >> 39) | (tmp << (64 - 39));
+       b2 -= b7;
+
+       tmp = b5 ^ b0;
+       b5 = (tmp >> 36) | (tmp << (64 - 36));
+       b0 -= b5;
+
+       tmp = b3 ^ b6;
+       b3 = (tmp >> 49) | (tmp << (64 - 49));
+       b6 -= b3;
+
+       tmp = b1 ^ b4;
+       b1 = (tmp >> 17) | (tmp << (64 - 17));
+       b4 -= b1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 42) | (tmp << (64 - 42));
+       b0 -= b3;
+
+       tmp = b5 ^ b6;
+       b5 = (tmp >> 14) | (tmp << (64 - 14));
+       b6 -= b5;
+
+       tmp = b7 ^ b4;
+       b7 = (tmp >> 27) | (tmp << (64 - 27));
+       b4 -= b7;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 33) | (tmp << (64 - 33));
+       b2 -= b1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 37) | (tmp << (64 - 37));
+       b6 -= b7 + k3 + t1;
+       b7 -= k4 + 6;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 19) | (tmp << (64 - 19));
+       b4 -= b5 + k1;
+       b5 -= k2 + t0;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 36) | (tmp << (64 - 36));
+       b2 -= b3 + k8;
+       b3 -= k0;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b0 -= b1 + k6;
+       b1 -= k7;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 22) | (tmp << (64 - 22));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 56) | (tmp << (64 - 56));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 35) | (tmp << (64 - 35));
+       b0 -= b7;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 8) | (tmp << (64 - 8));
+       b6 -= b1;
+
+       tmp = b7 ^ b2;
+       b7 = (tmp >> 43) | (tmp << (64 - 43));
+       b2 -= b7;
+
+       tmp = b5 ^ b0;
+       b5 = (tmp >> 39) | (tmp << (64 - 39));
+       b0 -= b5;
+
+       tmp = b3 ^ b6;
+       b3 = (tmp >> 29) | (tmp << (64 - 29));
+       b6 -= b3;
+
+       tmp = b1 ^ b4;
+       b1 = (tmp >> 25) | (tmp << (64 - 25));
+       b4 -= b1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 17) | (tmp << (64 - 17));
+       b0 -= b3;
+
+       tmp = b5 ^ b6;
+       b5 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b5;
+
+       tmp = b7 ^ b4;
+       b7 = (tmp >> 50) | (tmp << (64 - 50));
+       b4 -= b7;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 24) | (tmp << (64 - 24));
+       b6 -= b7 + k2 + t0;
+       b7 -= k3 + 5;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 34) | (tmp << (64 - 34));
+       b4 -= b5 + k0;
+       b5 -= k1 + t2;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 30) | (tmp << (64 - 30));
+       b2 -= b3 + k7;
+       b3 -= k8;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 39) | (tmp << (64 - 39));
+       b0 -= b1 + k5;
+       b1 -= k6;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 56) | (tmp << (64 - 56));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 54) | (tmp << (64 - 54));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b7;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 44) | (tmp << (64 - 44));
+       b6 -= b1;
+
+       tmp = b7 ^ b2;
+       b7 = (tmp >> 39) | (tmp << (64 - 39));
+       b2 -= b7;
+
+       tmp = b5 ^ b0;
+       b5 = (tmp >> 36) | (tmp << (64 - 36));
+       b0 -= b5;
+
+       tmp = b3 ^ b6;
+       b3 = (tmp >> 49) | (tmp << (64 - 49));
+       b6 -= b3;
+
+       tmp = b1 ^ b4;
+       b1 = (tmp >> 17) | (tmp << (64 - 17));
+       b4 -= b1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 42) | (tmp << (64 - 42));
+       b0 -= b3;
+
+       tmp = b5 ^ b6;
+       b5 = (tmp >> 14) | (tmp << (64 - 14));
+       b6 -= b5;
+
+       tmp = b7 ^ b4;
+       b7 = (tmp >> 27) | (tmp << (64 - 27));
+       b4 -= b7;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 33) | (tmp << (64 - 33));
+       b2 -= b1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 37) | (tmp << (64 - 37));
+       b6 -= b7 + k1 + t2;
+       b7 -= k2 + 4;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 19) | (tmp << (64 - 19));
+       b4 -= b5 + k8;
+       b5 -= k0 + t1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 36) | (tmp << (64 - 36));
+       b2 -= b3 + k6;
+       b3 -= k7;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b0 -= b1 + k4;
+       b1 -= k5;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 22) | (tmp << (64 - 22));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 56) | (tmp << (64 - 56));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 35) | (tmp << (64 - 35));
+       b0 -= b7;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 8) | (tmp << (64 - 8));
+       b6 -= b1;
+
+       tmp = b7 ^ b2;
+       b7 = (tmp >> 43) | (tmp << (64 - 43));
+       b2 -= b7;
+
+       tmp = b5 ^ b0;
+       b5 = (tmp >> 39) | (tmp << (64 - 39));
+       b0 -= b5;
+
+       tmp = b3 ^ b6;
+       b3 = (tmp >> 29) | (tmp << (64 - 29));
+       b6 -= b3;
+
+       tmp = b1 ^ b4;
+       b1 = (tmp >> 25) | (tmp << (64 - 25));
+       b4 -= b1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 17) | (tmp << (64 - 17));
+       b0 -= b3;
+
+       tmp = b5 ^ b6;
+       b5 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b5;
+
+       tmp = b7 ^ b4;
+       b7 = (tmp >> 50) | (tmp << (64 - 50));
+       b4 -= b7;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 24) | (tmp << (64 - 24));
+       b6 -= b7 + k0 + t1;
+       b7 -= k1 + 3;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 34) | (tmp << (64 - 34));
+       b4 -= b5 + k7;
+       b5 -= k8 + t0;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 30) | (tmp << (64 - 30));
+       b2 -= b3 + k5;
+       b3 -= k6;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 39) | (tmp << (64 - 39));
+       b0 -= b1 + k3;
+       b1 -= k4;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 56) | (tmp << (64 - 56));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 54) | (tmp << (64 - 54));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b7;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 44) | (tmp << (64 - 44));
+       b6 -= b1;
+
+       tmp = b7 ^ b2;
+       b7 = (tmp >> 39) | (tmp << (64 - 39));
+       b2 -= b7;
+
+       tmp = b5 ^ b0;
+       b5 = (tmp >> 36) | (tmp << (64 - 36));
+       b0 -= b5;
+
+       tmp = b3 ^ b6;
+       b3 = (tmp >> 49) | (tmp << (64 - 49));
+       b6 -= b3;
+
+       tmp = b1 ^ b4;
+       b1 = (tmp >> 17) | (tmp << (64 - 17));
+       b4 -= b1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 42) | (tmp << (64 - 42));
+       b0 -= b3;
+
+       tmp = b5 ^ b6;
+       b5 = (tmp >> 14) | (tmp << (64 - 14));
+       b6 -= b5;
+
+       tmp = b7 ^ b4;
+       b7 = (tmp >> 27) | (tmp << (64 - 27));
+       b4 -= b7;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 33) | (tmp << (64 - 33));
+       b2 -= b1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 37) | (tmp << (64 - 37));
+       b6 -= b7 + k8 + t0;
+       b7 -= k0 + 2;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 19) | (tmp << (64 - 19));
+       b4 -= b5 + k6;
+       b5 -= k7 + t2;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 36) | (tmp << (64 - 36));
+       b2 -= b3 + k4;
+       b3 -= k5;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b0 -= b1 + k2;
+       b1 -= k3;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 22) | (tmp << (64 - 22));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 56) | (tmp << (64 - 56));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 35) | (tmp << (64 - 35));
+       b0 -= b7;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 8) | (tmp << (64 - 8));
+       b6 -= b1;
+
+       tmp = b7 ^ b2;
+       b7 = (tmp >> 43) | (tmp << (64 - 43));
+       b2 -= b7;
+
+       tmp = b5 ^ b0;
+       b5 = (tmp >> 39) | (tmp << (64 - 39));
+       b0 -= b5;
+
+       tmp = b3 ^ b6;
+       b3 = (tmp >> 29) | (tmp << (64 - 29));
+       b6 -= b3;
+
+       tmp = b1 ^ b4;
+       b1 = (tmp >> 25) | (tmp << (64 - 25));
+       b4 -= b1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 17) | (tmp << (64 - 17));
+       b0 -= b3;
+
+       tmp = b5 ^ b6;
+       b5 = (tmp >> 10) | (tmp << (64 - 10));
+       b6 -= b5;
+
+       tmp = b7 ^ b4;
+       b7 = (tmp >> 50) | (tmp << (64 - 50));
+       b4 -= b7;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 13) | (tmp << (64 - 13));
+       b2 -= b1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 24) | (tmp << (64 - 24));
+       b6 -= b7 + k7 + t2;
+       b7 -= k8 + 1;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 34) | (tmp << (64 - 34));
+       b4 -= b5 + k5;
+       b5 -= k6 + t1;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 30) | (tmp << (64 - 30));
+       b2 -= b3 + k3;
+       b3 -= k4;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 39) | (tmp << (64 - 39));
+       b0 -= b1 + k1;
+       b1 -= k2;
+
+       tmp = b3 ^ b4;
+       b3 = (tmp >> 56) | (tmp << (64 - 56));
+       b4 -= b3;
+
+       tmp = b5 ^ b2;
+       b5 = (tmp >> 54) | (tmp << (64 - 54));
+       b2 -= b5;
+
+       tmp = b7 ^ b0;
+       b7 = (tmp >> 9) | (tmp << (64 - 9));
+       b0 -= b7;
+
+       tmp = b1 ^ b6;
+       b1 = (tmp >> 44) | (tmp << (64 - 44));
+       b6 -= b1;
+
+       tmp = b7 ^ b2;
+       b7 = (tmp >> 39) | (tmp << (64 - 39));
+       b2 -= b7;
+
+       tmp = b5 ^ b0;
+       b5 = (tmp >> 36) | (tmp << (64 - 36));
+       b0 -= b5;
+
+       tmp = b3 ^ b6;
+       b3 = (tmp >> 49) | (tmp << (64 - 49));
+       b6 -= b3;
+
+       tmp = b1 ^ b4;
+       b1 = (tmp >> 17) | (tmp << (64 - 17));
+       b4 -= b1;
+
+       tmp = b3 ^ b0;
+       b3 = (tmp >> 42) | (tmp << (64 - 42));
+       b0 -= b3;
+
+       tmp = b5 ^ b6;
+       b5 = (tmp >> 14) | (tmp << (64 - 14));
+       b6 -= b5;
+
+       tmp = b7 ^ b4;
+       b7 = (tmp >> 27) | (tmp << (64 - 27));
+       b4 -= b7;
+
+       tmp = b1 ^ b2;
+       b1 = (tmp >> 33) | (tmp << (64 - 33));
+       b2 -= b1;
+
+       tmp = b7 ^ b6;
+       b7 = (tmp >> 37) | (tmp << (64 - 37));
+       b6 -= b7 + k6 + t1;
+       b7 -= k7;
+
+       tmp = b5 ^ b4;
+       b5 = (tmp >> 19) | (tmp << (64 - 19));
+       b4 -= b5 + k4;
+       b5 -= k5 + t0;
+
+       tmp = b3 ^ b2;
+       b3 = (tmp >> 36) | (tmp << (64 - 36));
+       b2 -= b3 + k2;
+       b3 -= k3;
+
+       tmp = b1 ^ b0;
+       b1 = (tmp >> 46) | (tmp << (64 - 46));
+       b0 -= b1 + k0;
+       b1 -= k1;
+
+       output[0] = b0;
+       output[1] = b1;
+       output[2] = b2;
+       output[3] = b3;
+
+       output[7] = b7;
+       output[6] = b6;
+       output[5] = b5;
+       output[4] = b4;
+}
diff --git a/drivers/staging/skein/threefishApi.c b/drivers/staging/skein/threefishApi.c
new file mode 100644 (file)
index 0000000..1e70f66
--- /dev/null
@@ -0,0 +1,79 @@
+
+
+#include <linux/string.h>
+#include <threefishApi.h>
+
+void threefishSetKey(struct threefish_key *keyCtx,
+                       enum threefish_size stateSize,
+                       u64 *keyData, u64 *tweak)
+{
+       int keyWords = stateSize / 64;
+       int i;
+       u64 parity = KeyScheduleConst;
+
+       keyCtx->tweak[0] = tweak[0];
+       keyCtx->tweak[1] = tweak[1];
+       keyCtx->tweak[2] = tweak[0] ^ tweak[1];
+
+       for (i = 0; i < keyWords; i++) {
+               keyCtx->key[i] = keyData[i];
+               parity ^= keyData[i];
+       }
+       keyCtx->key[i] = parity;
+       keyCtx->stateSize = stateSize;
+}
+
+void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in,
+                               u8 *out)
+{
+       u64 plain[SKEIN_MAX_STATE_WORDS];        /* max number of words*/
+       u64 cipher[SKEIN_MAX_STATE_WORDS];
+
+       Skein_Get64_LSB_First(plain, in, keyCtx->stateSize / 64);
+       threefishEncryptBlockWords(keyCtx, plain, cipher);
+       Skein_Put64_LSB_First(out, cipher, keyCtx->stateSize / 8);
+}
+
+void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in,
+                               u64 *out)
+{
+       switch (keyCtx->stateSize) {
+       case Threefish256:
+               threefishEncrypt256(keyCtx, in, out);
+               break;
+       case Threefish512:
+               threefishEncrypt512(keyCtx, in, out);
+               break;
+       case Threefish1024:
+               threefishEncrypt1024(keyCtx, in, out);
+               break;
+       }
+}
+
+void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in,
+                               u8 *out)
+{
+       u64 plain[SKEIN_MAX_STATE_WORDS];        /* max number of words*/
+       u64 cipher[SKEIN_MAX_STATE_WORDS];
+
+       Skein_Get64_LSB_First(cipher, in, keyCtx->stateSize / 64);
+       threefishDecryptBlockWords(keyCtx, cipher, plain);
+       Skein_Put64_LSB_First(out, plain, keyCtx->stateSize / 8);
+}
+
+void threefishDecryptBlockWords(struct threefish_key *keyCtx, u64 *in,
+                               u64 *out)
+{
+       switch (keyCtx->stateSize) {
+       case Threefish256:
+               threefishDecrypt256(keyCtx, in, out);
+               break;
+       case Threefish512:
+               threefishDecrypt512(keyCtx, in, out);
+               break;
+       case Threefish1024:
+               threefishDecrypt1024(keyCtx, in, out);
+               break;
+       }
+}
+
index e27b88f02ccdb5cf778d2b2d8d597ed88d264060..f350e6028ed2362a62ca480871a4b27e1da8aa8f 100644 (file)
@@ -1422,8 +1422,7 @@ static void slic_cmdq_addcmdpage(struct adapter *adapter, u32 *page)
                spin_lock_irqsave(&adapter->handle_lock.lock,
                                adapter->handle_lock.flags);
                pslic_handle  =  adapter->pfree_slic_handles;
-               if (pslic_handle)
-                       adapter->pfree_slic_handles = pslic_handle->next;
+               adapter->pfree_slic_handles = pslic_handle->next;
                spin_unlock_irqrestore(&adapter->handle_lock.lock,
                                adapter->handle_lock.flags);
                pslic_handle->type = SLIC_HANDLE_CMD;
index 1ca91f7092b176cc8d27d4f1f36ddb694ff32d28..7495b890b6f0a50bb8b2b2253dd4dd41d75ca22c 100644 (file)
@@ -641,7 +641,7 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr,
                if (kstrtol(cp, 10, &value) == 0)
                        ret = spk_set_num_var(value, param, len);
                else
-                       pr_warn("overflow or parsing error has occured");
+                       pr_warn("overflow or parsing error has occurred");
                if (ret == -ERANGE) {
                        var_data = param->data;
                        pr_warn("value for %s out of range, expect %d to %d\n",
index f6452595b742472835ef753978ae04f607ac3b5f..7223a14082baaf57daae23c659046e770cfa1578 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index f504f49a436a0e593d6189a3f270ebad28ae940c..45ac55d3fe1c93837b12e14ece58efaf0c3d6200 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 8d727debca67049be5fa316eb245c005f1661af8..bdee5d529f6b5bb864116cf5fbbae4db46e02dfb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index aee204172b218fb71bbe730faac9b5fc481b7cec..baa0e501e6b4d8387c931c3cae64d1353d0b6c04 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
@@ -24,7 +24,7 @@
 */
 
 /* define the following to prevent include nesting in kernel header
- * files of similar abreviated content
+ * files of similar abbreviated content
  */
 #define __SUPERVISOR_CHANNEL_H__
 
index ae0dc2b2ad147e1d251a603bde3cd8f1ec8350a2..1f1f48e8f1c9eb81c8ad6bc02fa580213d7e1691 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 5126433483492c5c3cbc3cbecdfd7683bf252d21..1a1c5053fcf82bee21816058343503e8542d15a9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 47f1c4fa1e7ec5169c6647b5f0b89a66873bef73..17beec231d7098b8ecec286191df6ea6240a8436 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index c93515eb211d85650a6b4659ec4a607eb6a29bb4..83f1cc7b443ffee12e5a89b2da54980da5afeeec 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
@@ -356,7 +356,7 @@ typedef enum  {
  *IsChannelInitialized: 1 iff SignalInit was called for this channel; otherwise
  *                     0, and assume the channel is not ready for use yet.
  *
- * Reserved: Padding to allign the fields in this structure.
+ * Reserved: Padding to align the fields in this structure.
  *
  *SubsystemSeverityFilter: Level of severity on a subsystem basis that controls
  *                     whether events are logged.  Any event's severity for a
index 8de1d249d55f455ac9e80f1299cb654a92cad5cc..8cbf04d40f7865e5c725d04a612b39519d983dd2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION */
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION */
 /* All rights reserved. */
 #ifndef __IOCHANNEL_H__
 #define __IOCHANNEL_H__
@@ -192,7 +192,7 @@ typedef enum { NET_RCV_POST = 0,    /* submit buffer to hold receiving
        /* uisnic -> virtnic */
        NET_MACADDR,            /* indicates the client has requested to update
                                 * its MAC addr */
-       NET_MACADDR_ACK,        /* Mac addres  */
+       NET_MACADDR_ACK,        /* MAC address  */
 
 } NET_TYPES;
 
index 99dbbcf3d11ed5c5d30d6e5519d5c6ef3d83834c..7643042c0ce2a2a97d3ebaccbba49f1dc7054ebb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index de30d321d982d1798fd2a4f4be394676e0cdcf32..db77d6f626a12c3026b6e2cac32ebfff9ded389b 100644 (file)
@@ -1,6 +1,6 @@
 /* controlvmcompletionstatus.c
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 4c6294d206066a156a9a84b730be9bfc548ba66d..18cc9ed2748bff25b310bad275fefa8018e09e04 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 7304e9a0648ca1db2b7b43176020cc6b938b6991..fe9598c941a648eea69b556e7218c30d3893ed76 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index ae708faaa94dc918286e1395be2e5f4ca7cc93a2..8c0259a2cbce2086e587eb87581aa3f82a5ea29a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 00b0ebb09eae54bdeb60fd4dc66c6d01a323fb35..f25208fc3ed1a677fda6876cb41cc86db3af887d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 14c404367fa7ea3ad8df219dbed38c8c5984abb7..c5c10f3f1eb4dcf24f2e7ebd46a93c65d272791e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index ef12af4a72db0620d683c17eb6fc9da177b6a10d..3a8f302c87db1c187802d31165b859f19d5fa1b4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@
 #define _COMMONTYPES_H_
 
 /* define the following to prevent include nesting in kernel header files of
- * similar abreviated content */
+ * similar abbreviated content */
 #define _SUPERVISOR_COMMONTYPES_H_
 
 #ifdef __KERNEL__
index c3de8496e5d63708f12c0a02b022c082ff2804ac..efc4005368b0418185be0e0b0232272a57049ea7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@
 #define __GUESTLINUXDEBUG_H__
 
 /*
-* This file contains supporting interface for "vmcallinterface.h", particuarly
+* This file contains supporting interface for "vmcallinterface.h", particularly
 * regarding adding additional structure and functionality to linux
 * ISSUE_IO_VMCALL_POSTCODE_SEVERITY */
 
@@ -142,7 +142,7 @@ typedef enum {                      /* POSTCODE event identifier tuples */
  * Please also note that the resulting postcode is in hex, so if you are
  * searching for the __LINE__ number, convert it first to decimal.  The line
  * number combined with driver and type of call, will allow you to track down
- * exactly what line an error occured on, or where the last driver
+ * exactly what line an error occurred on, or where the last driver
  * entered/exited from.
  */
 
index 75caf929cd6d412a11e8e156a3d279813046ccbb..adeb92d8dd4dcaa5b74cb67407038bb182533826 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 6c7190bdcd66fe464e56cdb9af41be19e380f85e..418ba634e1a296d6e7f09c0ee4fd047dbe3c4ffe 100644 (file)
@@ -1,6 +1,6 @@
 /* periodic_work.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index c81d11287e685cedc8a23dbc7bfa65c7f698b6ed..1174056ec3d960e4a347a921cc581b2428daea7c 100644 (file)
@@ -1,6 +1,6 @@
 /* procobjecttree.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 3603ac607643ecda1afa184bb831a60925223233..05837399a741dadf6f8df6c4485d2d25d4368608 100644 (file)
@@ -1,6 +1,6 @@
 /* sparstop.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 5fd5ad5144645878d43df593cbf109bd4abed26e..ecf1a6fac7a141dd6bf6e4ba7e2e008815632ab3 100644 (file)
@@ -1,6 +1,6 @@
 /* timskmod.h
  *
- * Copyright ï¿½ 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 2d81d46bf11e7f6e9e9386350b779575bdf0cce9..0045d559d1b9a16ba4f83d5cee1ca3ed8dfb18ca 100644 (file)
@@ -1,6 +1,6 @@
 /* timskmodutils.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 6dab3900994a7ebe3022e6a080407fbeda0fda80..d7793a84903e8c8ea63f946169b4786a58b9a79b 100644 (file)
@@ -1,6 +1,6 @@
 /* uisqueue.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 2b1fba759098678678731ef4fba6a33473688a85..26837771b43fe9b3bfb9cac4009a6618e8cfe77b 100644 (file)
@@ -1,6 +1,6 @@
 /* uisthread.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 5fdab3a3464a42ecb48c5627774cc00d43820810..f4774c05f9098dfa50ebaddba4de07c17a4821b4 100644 (file)
@@ -1,6 +1,6 @@
 /* uisutils.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 4d7b87cefa61c7ef9cb230d9fa051880ef9dbc45..6178cc46f7c1e8a6570adffee34cbb09e67a8b75 100644 (file)
@@ -1,6 +1,6 @@
 /* uniklog.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 3152a2180c456c0d9e06ee64333f6352964ca982..0e1a58ab28b10fd1f5293405969524dbb81983b3 100644 (file)
@@ -1,6 +1,6 @@
 /* uislib.c
  *
- * Copyright ï¿½ 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 40598ff1f4f2f84680cfc056e44e3d36cb8e8a1e..d4a6074cfaf0f877593bc15858d0d880f72226c6 100644 (file)
@@ -1,6 +1,6 @@
 /* uisqueue.c
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 782b06aad56d95e8e35ffa6daa174c0ca051cd86..c93ab04c3cfc9d7d216456042311c9d597c6b314 100644 (file)
@@ -1,6 +1,6 @@
 /* uisthread.c
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 3178f75e1ebec2c8b19ec9d15f218e65382bdbf0..b49647ccc9d0970e0df40f83de2058794abb9e4c 100644 (file)
@@ -1,6 +1,6 @@
 /* uisutils.c
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 817b11dfa19c28823cd53793e93273a34cadc08b..a13e79e287f40025c08e79dd0b5d1058a695a608 100644 (file)
@@ -1,6 +1,6 @@
 /* virthba.c
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
@@ -82,6 +82,14 @@ static int virthba_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
 static int virthba_queue_command_lck(struct scsi_cmnd *scsicmd,
                                     void (*virthba_cmnd_done)(struct scsi_cmnd *));
 
+static const struct x86_cpu_id unisys_spar_ids[] = {
+       { X86_VENDOR_INTEL, 6, 62, X86_FEATURE_ANY },
+       {}
+};
+
+/* Autoload */
+MODULE_DEVICE_TABLE(x86cpu, unisys_spar_ids);
+
 #ifdef DEF_SCSI_QCMD
 DEF_SCSI_QCMD(virthba_queue_command)
 #else
@@ -1046,7 +1054,7 @@ static int
 virthba_slave_alloc(struct scsi_device *scsidev)
 {
        /* this called by the midlayer before scan for new devices -
-        * LLD can alloc any struc & do init if needed.
+        * LLD can alloc any struct & do init if needed.
         */
        struct virtdisk_info *vdisk;
        struct virtdisk_info *tmpvdisk;
@@ -1400,7 +1408,7 @@ info_proc_read(struct file *file, char __user *buf, size_t len, loff_t *offset)
                virthbainfo = VirtHbasOpen[i].virthbainfo;
                length += sprintf(vbuf + length, "CHANSOCK is not defined.\n");
 
-               length += sprintf(vbuf + length, "MaxBuffLen:%d\n", MaxBuffLen);
+               length += sprintf(vbuf + length, "MaxBuffLen:%u\n", MaxBuffLen);
 
                length += sprintf(vbuf + length, "\nvirthba result queue poll wait:%d usecs.\n",
                                  rsltq_wait_usecs);
@@ -1534,7 +1542,7 @@ virthba_serverup(struct virtpci_dev *virtpcidev)
               virtpcidev->deviceNo);
 
        if (!virthbainfo->serverdown) {
-               DBGINF("Server up message recieved while server is already up.\n");
+               DBGINF("Server up message received while server is already up.\n");
                return 1;
        }
        if (virthbainfo->serverchangingstate) {
index 88b797439a16a51aaae1041262ec44d73966d01c..d4b809b0c7bcc6091b373a2ece790ea8245417ba 100644 (file)
@@ -1,6 +1,6 @@
 /* virthba.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 8e34650b00b5c2e9c7938e6f6343a54850a15f08..21f8bd5fdff94dd0a45a7ae88faae1e2776dae67 100644 (file)
@@ -1,6 +1,6 @@
 /* virtpci.c
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index b8fd07bc543506483ff8e1d07c4abcd78d4d8c5c..b695c4b8e8bd23a5349cd6beb4447c686e095d97 100644 (file)
@@ -1,6 +1,6 @@
 /* virtpci.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 668f832ca56637451149aa6f6da1d93beea74295..07653b8dea7b0f98c0d906c7a6215295ab3dbefb 100644 (file)
@@ -1,6 +1,6 @@
 /* globals.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 62d29a233fd05d8273fe666b214a92c3be07fcc1..a8c2ebd0c99a5f59e449385144d73b2a0bc6ee95 100644 (file)
@@ -1,6 +1,6 @@
 /* visorchannel.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 053681616ba32f6511f24df662c950981e9d50a3..4427d01b1126a794769b2e0f710e889eb57d18b6 100644 (file)
@@ -1,6 +1,6 @@
 /* visorchannel_funcs.c
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 482ee0ac1c16b9d32bdb6d8dc14f33dcf1b5a476..1a092570602e7eb041355495f62c822f413bcf50 100644 (file)
@@ -1,6 +1,6 @@
 /* visorchannel_main.c
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 873fa12dfe6f45af5c5d2ecd322895df1111bd35..012891c3f21dc8ba3ed954f3f8ba04679f4ee6be 100644 (file)
@@ -1,6 +1,6 @@
 /* controlvm.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index b911ea85c093add0d7a9c3a7968c79d1608e4ca6..cd10e3a2a07f2366c5c6f4476b8fc5e72643b7fd 100644 (file)
@@ -1,6 +1,6 @@
 /* controlvm_direct.c
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index e214a115328290347f724753854a44f42d0b9e98..fccc4f0c3a49ea5d2b119d181981d52626eff4f7 100644 (file)
@@ -1,6 +1,6 @@
 /* file.c
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 597282aa9a06bd0f357ffe4aab1cde5d131a04f6..21bb906242e1618ca23f063070e416a6fe619301 100644 (file)
@@ -1,6 +1,6 @@
 /* file.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index a0e6d4fc03ae85446743706ad497782266d1c9d1..0fe14599f185c4e97fd389844157c14e0b2cab8a 100644 (file)
@@ -1,6 +1,6 @@
 /* globals.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index b408d415bd8c763e8b19a576f5d672517cc6b19b..948fbb8ed09cc0542d62441aa7dd2b72b39b23f7 100644 (file)
@@ -1,6 +1,6 @@
 /* parser.c
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index a0cc50a533cd82cd235879e600dab496f1538823..3e4aedc580ce5ae1b5f29a5819e3f55fe0c3c7db 100644 (file)
@@ -1,6 +1,6 @@
 /* parser.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index a44f5556cb21ef857cf2f3776a38e0fe928dd1b9..ad378b82cf9980f00f35ecb100935347cbadc44b 100644 (file)
@@ -1,6 +1,6 @@
 /* testing.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index d95825dc541494d7af4ca1694bbca2748c4d7289..06646e4e3f1e4bd387fdc5688759b8d97a3c50df 100644 (file)
@@ -1,6 +1,6 @@
 /* visorchipset.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index c475e256e34b639070de1dad460a7114e4327682..1895dc4596438939b39a41cf134ca5da41af0bef 100644 (file)
@@ -1,6 +1,6 @@
 /* visorchipset_main.c
  *
- * Copyright ï¿½ 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 259e840376a54a4613f8a5dbdefb390cc884e02f..06ba5b7e4254c8fcd1029f9f1c15058929ad1083 100644 (file)
@@ -1,6 +1,6 @@
 /* visorchipset_umode.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 0ceede129e8720f42cc194a987b7f55e4a1ee982..61600e1955b33fed40fc782c5a98f086d0aed2c5 100644 (file)
@@ -1,6 +1,6 @@
 /* charqueue.c
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index e82ae0bc8959f9e589160c9302b6c989eeb8bba4..d6f16587a364049eed4974ac0290470726664378 100644 (file)
@@ -1,6 +1,6 @@
 /* charqueue.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 60b6b83d1b20dce975435b1b82c11a5c7e47e8e7..43df5988f0b8db3676bf4adede16df6ba062ad49 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Â© 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 1cef1fd33d53d046b39b57af2cb4c7568b23df3e..6ce7d5eb6ad1b5a2127c9c0321d5df1f1fd38ff8 100644 (file)
@@ -1,6 +1,6 @@
 /* easyproc.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index bb122dbeafbc470ceaa7f328e3df3856aecf6bf1..796631652b7715c4923cb0d2afd32b5c5ba929e0 100644 (file)
@@ -1,6 +1,6 @@
 /* memregion.h
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 2c1061d55ee9d254cf2599bf578a0ba7d3519980..d39fde9c1a6033cc31b4a260ae966f7c89b2f4e2 100644 (file)
@@ -1,6 +1,6 @@
 /* memregion_direct.c
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 0670a3174682eecedf78379becd32e2f7200c9f6..0251b83aa55cdb14b806eeac8bae79bfa76df2d1 100644 (file)
@@ -1,6 +1,6 @@
 /* periodic_work.c
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index 67a19e1c7b0206bde456773e687682ec27540da8..2f874e0ab339369c39ebf6cad123358855652f1b 100644 (file)
@@ -1,6 +1,6 @@
 /* procobjecttree.c
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index a7d1e94ca3c30d5f572ee34aaf92331a45c24192..e802e75a46966b726e3349b166cfd6bc096d7fae 100644 (file)
@@ -1,6 +1,6 @@
 /* timskmodutils.c
  *
- * Copyright Â© 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
index ffb4eeefdddb37e5ae2447c6501b50e00e59f37f..2d8497277aae3ec0de9d6dd6d03197e2a51cfb47 100644 (file)
@@ -684,7 +684,7 @@ static int vme_user_match(struct vme_dev *vdev)
 static int vme_user_probe(struct vme_dev *vdev)
 {
        int i, err;
-       char name[12];
+       char *name;
 
        /* Save pointer to the bridge device */
        if (vme_user_bridge != NULL) {
@@ -792,15 +792,16 @@ static int vme_user_probe(struct vme_dev *vdev)
        /* Add sysfs Entries */
        for (i = 0; i < VME_DEVS; i++) {
                int num;
+
                switch (type[i]) {
                case MASTER_MINOR:
-                       sprintf(name, "bus/vme/m%%d");
+                       name = "bus/vme/m%d";
                        break;
                case CONTROL_MINOR:
-                       sprintf(name, "bus/vme/ctl");
+                       name = "bus/vme/ctl";
                        break;
                case SLAVE_MINOR:
-                       sprintf(name, "bus/vme/s%%d");
+                       name = "bus/vme/s%d";
                        break;
                default:
                        err = -EINVAL;
index db38ca05113064a8e9879b328f8ee8d272653974..e7227954f2fe88a25805b1b9a473eb348c4392d1 100644 (file)
@@ -24,7 +24,6 @@
  *      vUpdateIFS - Update slotTime,SIFS,DIFS, and EIFS
  *      CARDvUpdateBasicTopRate - Update BasicTopRate
  *      CARDbAddBasicRate - Add to BasicRateSet
- *      CARDbSetBasicRate - Set Basic Tx Rate
  *      CARDbIsOFDMinBasicRate - Check if any OFDM rate is in BasicRateSet
  *      CARDvSetLoopbackMode - Set Loopback mode
  *      CARDbSoftwareReset - Sortware reset NIC
@@ -1877,19 +1876,6 @@ void CARDvUpdateBasicTopRate(void *pDeviceHandler)
        pDevice->byTopCCKBasicRate = byTopCCK;
 }
 
-/*
- * Description: Set NIC Tx Basic Rate
- *
- * Parameters:
- *  In:
- *      pDevice         - The adapter to be set
- *      wBasicRate      - Basic Rate to be set
- *  Out:
- *      none
- *
- * Return Value: true if succeeded; false if failed.
- *
- */
 bool CARDbAddBasicRate(void *pDeviceHandler, unsigned short wRateIdx)
 {
        PSDevice pDevice = (PSDevice) pDeviceHandler;
index c9a89cd7633cfacfe6594d33e9d86cad8fff92f4..2d760da626bb474a4551933f12805e8cad81b333 100644 (file)
@@ -51,7 +51,7 @@ extern unsigned short TxRate_iwconfig; //2008-5-8 <add> by chester
 /*---------------------  Static Variables  --------------------------*/
 //static int          msglevel                =MSG_LEVEL_DEBUG;
 static int msglevel = MSG_LEVEL_INFO;
-const unsigned char acbyIERate[MAX_RATE] =
+static const unsigned char acbyIERate[MAX_RATE] =
 {0x02, 0x04, 0x0B, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
 
 #define AUTORATE_TXOK_CNT       0x0400
index 062c3a374b99f70c985e70b051fdd414cc8f974c..985c3c19a4a7b779a6f7ded62d90b337d850b4e4 100644 (file)
 
 /*---------------------  Export Types  ------------------------------*/
 
-#define DBG_PRT(l, p, args...) { if (l <= msglevel) printk(p, ##args); }
-#define PRINT_K(p, args...) { if (PRIVATE_Message) printk(p, ##args); }
+#define DBG_PRT(l, p, args...)         \
+do {                                   \
+       if (l <= msglevel)              \
+               printk(p, ##args);      \
+} while (0)
+
+#define PRINT_K(p, args...)            \
+do {                                   \
+       if (PRIVATE_Message)            \
+               printk(p, ##args);      \
+} while (0)
 
 //0:11A 1:11B 2:11G
 typedef enum _VIA_BB_TYPE
index b5cd2e44e53dac9079c9964bdbe97cc10fb2c907..1de5d2c907d2433390bf6b6870ad3254806aea9c 100644 (file)
@@ -305,7 +305,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
                        result = -EINVAL;
                        break;
                }
-               pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC);
+               pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)),
+                                            GFP_ATOMIC);
                if (pList == NULL) {
                        result = -ENOMEM;
                        break;
@@ -576,7 +577,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
                        result = -EINVAL;
                        break;
                }
-               pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC);
+               pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)),
+                                               GFP_ATOMIC);
                if (pNodeList == NULL) {
                        result = -ENOMEM;
                        break;
index ac3fc16704c1c5b54a50a9ca954bbfc58070a6d4..a601c47a3803cb5f9d67c510619ae8c1b21bee8e 100644 (file)
@@ -1835,19 +1835,14 @@ int iwctl_siwencodeext(struct net_device *dev,
        size_t seq_len = 0, key_len = 0;
 //
        // int ii;
-       u8 *buf;
-       size_t blen;
        u8 key_array[64];
        int ret = 0;
 
        PRINT_K("SIOCSIWENCODEEXT...... \n");
 
-       blen = sizeof(*param);
-       buf = kmalloc((int)blen, (int)GFP_KERNEL);
-       if (buf == NULL)
+       param = kzalloc(sizeof(*param), GFP_KERNEL);
+       if (param == NULL)
                return -ENOMEM;
-       memset(buf, 0, blen);
-       param = (struct viawget_wpa_param *)buf;
 
 //recover alg_name
        switch (ext->alg) {
index d17224f39b4d52d527e02ee53bdf71946b90854f..1f72589cf718637851d650c314baa6efe8b52bd8 100644 (file)
@@ -188,7 +188,8 @@ int wpa_set_wpadev(PSDevice pDevice, int val)
  *
  */
 
-int wpa_set_keys(PSDevice pDevice, void *ctx, bool fcpfkernel)
+int wpa_set_keys(PSDevice pDevice, void *ctx,
+                bool fcpfkernel) __must_hold(&pDevice->lock)
 {
        struct viawget_wpa_param *param = ctx;
        PSMgmtObject pMgmt = pDevice->pMgmt;
@@ -593,7 +594,7 @@ static int wpa_get_scan(PSDevice pDevice,
 
        unsigned char *ptempBSS;
 
-       ptempBSS = kmalloc(sizeof(KnownBSS), (int)GFP_ATOMIC);
+       ptempBSS = kmalloc(sizeof(KnownBSS), GFP_ATOMIC);
 
        if (ptempBSS == NULL) {
                printk(KERN_ERR "bubble sort kmalloc memory fail@@@\n");
@@ -635,7 +636,7 @@ static int wpa_get_scan(PSDevice pDevice,
                count++;
        }
 
-       pBuf = kcalloc(count, sizeof(struct viawget_scan_result), (int)GFP_ATOMIC);
+       pBuf = kcalloc(count, sizeof(struct viawget_scan_result), GFP_ATOMIC);
 
        if (pBuf == NULL) {
                ret = -ENOMEM;
@@ -679,7 +680,7 @@ static int wpa_get_scan(PSDevice pDevice,
                ret = -EFAULT;
        }
        param->u.scan_results.scan_count = count;
-       DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " param->u.scan_results.scan_count = %d\n", count)
+       DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " param->u.scan_results.scan_count = %d\n", count);
 
                kfree(pBuf);
        return ret;
@@ -857,7 +858,7 @@ int wpa_ioctl(PSDevice pDevice, struct iw_point *p)
            p->length > VIAWGET_WPA_MAX_BUF_SIZE || !p->pointer)
                return -EINVAL;
 
-       param = kmalloc((int)p->length, (int)GFP_KERNEL);
+       param = kmalloc((int)p->length, GFP_KERNEL);
        if (param == NULL)
                return -ENOMEM;
 
index e2bfa8d266cd8a68f8ef11a8b99c2710e2522a50..a9d51687db7f56e4439c4efb100902ef938c428c 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "device.h"
 #include "80211hdr.h"
+#include "aes_ccmp.h"
 
 /*
  * SBOX Table
index cd2ea76c8b1e1ee70eda84d70cdcce6117978dce..15c1e861c84b696e38da4be1764daeb99571bf91 100644 (file)
@@ -31,6 +31,7 @@
  *
  */
 
+#include <linux/compiler.h>
 #include "firmware.h"
 #include "control.h"
 #include "rndis.h"
@@ -43,7 +44,7 @@ static int msglevel = MSG_LEVEL_INFO;
 
 #define FIRMWARE_CHUNK_SIZE    0x400
 
-int FIRMWAREbDownload(struct vnt_private *pDevice)
+int FIRMWAREbDownload(struct vnt_private *pDevice) __must_hold(&pDevice->lock)
 {
        struct device *dev = &pDevice->usb->dev;
        const struct firmware *fw;
index 3840323858fcc13ffe57901f9272d0d15096ac7a..1ff14469df9967b4f26494ebe638655b05e7984c 100644 (file)
@@ -181,31 +181,31 @@ static void s_vFillTxKey(struct vnt_private *pDevice,
        struct vnt_mic_hdr *mic_hdr)
 {
        u8 *pbyBuf = (u8 *)&fifo_head->adwTxKey[0];
-       u32 *pdwIV = (u32 *)pbyIVHead;
-       u32 *pdwExtIV = (u32 *)((u8 *)pbyIVHead + 4);
+       __le32 *pdwIV = (__le32 *)pbyIVHead;
+       __le32 *pdwExtIV = (__le32 *)((u8 *)pbyIVHead + 4);
        struct ieee80211_hdr *pMACHeader = (struct ieee80211_hdr *)pbyHdrBuf;
-       u32 dwRevIVCounter;
+       __le32 rev_iv_counter;
 
        /* Fill TXKEY */
        if (pTransmitKey == NULL)
                return;
 
-       dwRevIVCounter = cpu_to_le32(pDevice->dwIVCounter);
-       *pdwIV = pDevice->dwIVCounter;
+       rev_iv_counter = cpu_to_le32(pDevice->dwIVCounter);
+       *pdwIV = cpu_to_le32(pDevice->dwIVCounter);
        pDevice->byKeyIndex = pTransmitKey->dwKeyIndex & 0xf;
 
        switch (pTransmitKey->byCipherSuite) {
        case KEY_CTL_WEP:
                if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN) {
-                       memcpy(pDevice->abyPRNG, (u8 *)&dwRevIVCounter, 3);
+                       memcpy(pDevice->abyPRNG, (u8 *)&rev_iv_counter, 3);
                        memcpy(pDevice->abyPRNG + 3, pTransmitKey->abyKey,
                                                pTransmitKey->uKeyLength);
                } else {
-                       memcpy(pbyBuf, (u8 *)&dwRevIVCounter, 3);
+                       memcpy(pbyBuf, (u8 *)&rev_iv_counter, 3);
                        memcpy(pbyBuf + 3, pTransmitKey->abyKey,
                                                pTransmitKey->uKeyLength);
                        if (pTransmitKey->uKeyLength == WLAN_WEP40_KEYLEN) {
-                               memcpy(pbyBuf+8, (u8 *)&dwRevIVCounter, 3);
+                               memcpy(pbyBuf+8, (u8 *)&rev_iv_counter, 3);
                        memcpy(pbyBuf+11, pTransmitKey->abyKey,
                                                pTransmitKey->uKeyLength);
                        }
@@ -213,9 +213,8 @@ static void s_vFillTxKey(struct vnt_private *pDevice,
                        memcpy(pDevice->abyPRNG, pbyBuf, 16);
                }
                /* Append IV after Mac Header */
-               *pdwIV &= WEP_IV_MASK;
-               *pdwIV |= (u32)pDevice->byKeyIndex << 30;
-               *pdwIV = cpu_to_le32(*pdwIV);
+               *pdwIV &= cpu_to_le32(WEP_IV_MASK);
+               *pdwIV |= cpu_to_le32((u32)pDevice->byKeyIndex << 30);
 
                pDevice->dwIVCounter++;
                if (pDevice->dwIVCounter > WEP_IV_MASK)
@@ -256,7 +255,7 @@ static void s_vFillTxKey(struct vnt_private *pDevice,
                *(pbyIVHead+3) = (u8)(((pDevice->byKeyIndex << 6) &
                                                        0xc0) | 0x20);
 
-               *pdwIV |= cpu_to_le16((u16)(pTransmitKey->wTSC15_0));
+               *pdwIV |= cpu_to_le32((u32)(pTransmitKey->wTSC15_0));
 
                /* Append IV&ExtIV after Mac Header */
                *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16);
@@ -283,9 +282,10 @@ static void s_vFillTxKey(struct vnt_private *pDevice,
 
                /* MICHDR2 */
                memcpy(mic_hdr->addr3, pMACHeader->addr3, ETH_ALEN);
-               mic_hdr->frame_control = cpu_to_le16(pMACHeader->frame_control
-                                                               & 0xc78f);
-               mic_hdr->seq_ctrl = cpu_to_le16(pMACHeader->seq_ctrl & 0xf);
+               mic_hdr->frame_control = cpu_to_le16(
+                       le16_to_cpu(pMACHeader->frame_control) & 0xc78f);
+               mic_hdr->seq_ctrl = cpu_to_le16(
+                               le16_to_cpu(pMACHeader->seq_ctrl) & 0xf);
 
                if (ieee80211_has_a4(pMACHeader->frame_control))
                        memcpy(mic_hdr->addr4, pMACHeader->addr4, ETH_ALEN);
@@ -551,7 +551,8 @@ static int vnt_fill_ieee80211_rts(struct vnt_private *priv,
                __le16 duration)
 {
        rts->duration = duration;
-       rts->frame_control = TYPE_CTL_RTS;
+       rts->frame_control =
+               cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
 
        if (priv->op_mode == NL80211_IFTYPE_ADHOC ||
                                priv->op_mode == NL80211_IFTYPE_AP)
@@ -741,7 +742,9 @@ static u16 s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx,
                        pDevice->tx_rate_fb1, bNeedAck, byFBOption);
                /* Get CTS Frame body */
                pBuf->data.duration = pBuf->duration_ba;
-               pBuf->data.frame_control = TYPE_CTL_CTS;
+               pBuf->data.frame_control =
+                       cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
+
                memcpy(pBuf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN);
 
                return vnt_rxtx_datahead_g_fb(pDevice, byPktType, wCurrentRate,
@@ -757,7 +760,9 @@ static u16 s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx,
                        wCurrentRate, bNeedAck, byFBOption);
                /*Get CTS Frame body*/
                pBuf->data.duration = pBuf->duration_ba;
-               pBuf->data.frame_control = TYPE_CTL_CTS;
+               pBuf->data.frame_control =
+                       cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
+
                memcpy(pBuf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN);
 
                return vnt_rxtx_datahead_g(pDevice, byPktType, wCurrentRate,
@@ -800,7 +805,7 @@ static u16 s_vGenerateTxParameter(struct vnt_private *pDevice,
        u16 wFifoCtl;
        u8 byFBOption = AUTO_FB_NONE;
 
-       pFifoHead->wReserved = wCurrentRate;
+       pFifoHead->current_rate = cpu_to_le16(wCurrentRate);
        wFifoCtl = pFifoHead->wFIFOCtl;
 
        if (wFifoCtl & FIFOCTL_AUTO_FB_0)
@@ -1008,7 +1013,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType,
                pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK;
        }
 
-    pTxBufHead->wTimeStamp = DEFAULT_MSDU_LIFETIME_RES_64us;
+    pTxBufHead->time_stamp = cpu_to_le16(DEFAULT_MSDU_LIFETIME_RES_64us);
 
     //Set FRAGCTL_MACHDCNT
        cbMACHdLen = WLAN_HDR_ADDR3_LEN;
@@ -1431,7 +1436,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice,
     }
 
     pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN;
-    pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us);
+    pTxBufHead->time_stamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us);
 
     if (is_multicast_ether_addr(pPacket->p80211Header->sA3.abyAddr1)) {
         bNeedACK = false;
@@ -1605,7 +1610,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice,
        }
     }
 
-    pTX_Buffer->wTxByteCount = cpu_to_le16((u16)(cbReqCount));
+    pTX_Buffer->tx_byte_count = cpu_to_le16((u16)(cbReqCount));
     pTX_Buffer->byPKTNO = (u8) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F));
     pTX_Buffer->byType = 0x00;
 
@@ -1697,7 +1702,7 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice,
 
     cbReqCount = cbHeaderSize + WLAN_HDR_ADDR3_LEN + cbFrameBodySize;
 
-    pTX_Buffer->wTxByteCount = (u16)cbReqCount;
+    pTX_Buffer->tx_byte_count = cpu_to_le16((u16)cbReqCount);
     pTX_Buffer->byPKTNO = (u8) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F));
     pTX_Buffer->byType = 0x01;
 
@@ -1800,7 +1805,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb)
     }
 
     pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN;
-    pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us);
+    pTxBufHead->time_stamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us);
 
     if (is_multicast_ether_addr(p80211Header->sA3.abyAddr1)) {
         bNeedACK = false;
@@ -2045,7 +2050,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb)
        }
     }
 
-    pTX_Buffer->wTxByteCount = cpu_to_le16((u16)(cbReqCount));
+    pTX_Buffer->tx_byte_count = cpu_to_le16((u16)(cbReqCount));
     pTX_Buffer->byPKTNO = (u8) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F));
     pTX_Buffer->byType = 0x00;
 
@@ -2437,7 +2442,7 @@ int nsDMA_tx_packet(struct vnt_private *pDevice,
     }
 
     pTX_Buffer->byPKTNO = (u8) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F));
-    pTX_Buffer->wTxByteCount = (u16)BytesToWrite;
+    pTX_Buffer->tx_byte_count = cpu_to_le16((u16)BytesToWrite);
 
     pContext->pPacket = skb;
     pContext->type = CONTEXT_DATA_PACKET;
@@ -2591,7 +2596,7 @@ int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen,
     }
 
     pTX_Buffer->byPKTNO = (u8) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F));
-    pTX_Buffer->wTxByteCount = (u16)BytesToWrite;
+    pTX_Buffer->tx_byte_count = cpu_to_le16((u16)BytesToWrite);
 
     pContext->pPacket = NULL;
     pContext->type = CONTEXT_DATA_PACKET;
index 6d6539d29d04ce5240cd467f481a892e39d74092..4dfb2e0c6ae78a6b6d30dbfccd1c3fc95d0229e3 100644 (file)
@@ -217,15 +217,15 @@ union vnt_tx_head {
 struct vnt_tx_fifo_head {
        u32 adwTxKey[4];
        u16 wFIFOCtl;
-       u16 wTimeStamp;
+       __le16 time_stamp;
        u16 wFragCtl;
-       u16 wReserved;
+       __le16 current_rate;
 } __packed;
 
 struct vnt_tx_buffer {
        u8 byType;
        u8 byPKTNO;
-       u16 wTxByteCount;
+       __le16 tx_byte_count;
        struct vnt_tx_fifo_head fifo_head;
        union vnt_tx_head tx_head;
 } __packed;
@@ -241,7 +241,7 @@ struct vnt_tx_short_buf_head {
 struct vnt_beacon_buffer {
        u8 byType;
        u8 byPKTNO;
-       u16 wTxByteCount;
+       __le16 tx_byte_count;
        struct vnt_tx_short_buf_head short_head;
        struct ieee80211_hdr hdr;
 } __packed;
index aec6b568a4a926b109441ef474296b4acb7f556c..f57fcfdc24d5665893318f38fff518e996ee0976 100644 (file)
@@ -60,8 +60,6 @@
 #define TYPE_DATE_NULL      0x4800
 
 #define TYPE_CTL_PSPOLL     0xa400
-#define TYPE_CTL_RTS        0xb400
-#define TYPE_CTL_CTS        0xc400
 #define TYPE_CTL_ACK        0xd400
 
 #else //if LITTLE_ENDIAN
@@ -91,8 +89,6 @@
 #define TYPE_DATE_NULL      0x0048
 
 #define TYPE_CTL_PSPOLL     0x00a4
-#define TYPE_CTL_RTS        0x00b4
-#define TYPE_CTL_CTS        0x00c4
 #define TYPE_CTL_ACK        0x00d4
 
 #endif //#ifdef __BIG_ENDIAN
index 4739c14d83593f96bdd845b6fc8c0f84f13d2604..e92bbc12bb0649f26b03b2d4368e5b755b448043 100644 (file)
 #include "prism2sta.c"
 #include "prism2fw.c"
 
-#define PRISM_USB_DEVICE(vid, pid, name)       \
-       USB_DEVICE(vid, pid),                   \
-       .driver_info = (unsigned long) name
+#define PRISM_DEV(vid, pid, name)              \
+       { USB_DEVICE(vid, pid),                 \
+       .driver_info = (unsigned long) name }
 
 static struct usb_device_id usb_prism_tbl[] = {
-       {PRISM_USB_DEVICE(0x04bb, 0x0922, "IOData AirPort WN-B11/USBS")},
-       {PRISM_USB_DEVICE(0x07aa, 0x0012, "Corega Wireless LAN USB Stick-11")},
-       {PRISM_USB_DEVICE(0x09aa, 0x3642, "Prism2.x 11Mbps WLAN USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x1668, 0x0408, "Actiontec Prism2.5 11Mbps WLAN USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x1668, 0x0421, "Actiontec Prism2.5 11Mbps WLAN USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x1915, 0x2236, "Linksys WUSB11v3.0 11Mbps WLAN USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x066b, 0x2212, "Linksys WUSB11v2.5 11Mbps WLAN USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x066b, 0x2213, "Linksys WUSB12v1.1 11Mbps WLAN USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x067c, 0x1022, "Siemens SpeedStream 1022 11Mbps WLAN USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x049f, 0x0033,
-        "Compaq/Intel W100 PRO/Wireless 11Mbps multiport WLAN Adapter")},
-       {PRISM_USB_DEVICE
-        (0x0411, 0x0016, "Melco WLI-USB-S11 11Mbps WLAN Adapter")},
-       {PRISM_USB_DEVICE
-        (0x08de, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x8086, 0x1111, "Intel PRO/Wireless 2011B LAN USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x0d8e, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x045e, 0x006e, "Microsoft MN510 Wireless USB Adapter")},
-       {PRISM_USB_DEVICE(0x0967, 0x0204, "Acer Warplink USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x0cde, 0x0002, "Z-Com 725/726 Prism2.5 USB/USB Integrated")},
-       {PRISM_USB_DEVICE
-        (0x0cde, 0x0005, "Z-Com Xl735 Wireless 802.11b USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x413c, 0x8100, "Dell TrueMobile 1180 Wireless USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x0b3b, 0x1601, "ALLNET 0193 11Mbps WLAN USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x0b3b, 0x1602, "ZyXEL ZyAIR B200 Wireless USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x0baf, 0x00eb, "USRobotics USR1120 Wireless USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x0411, 0x0027, "Melco WLI-USB-KS11G 11Mbps WLAN Adapter")},
-       {PRISM_USB_DEVICE
-        (0x04f1, 0x3009, "JVC MP-XP7250 Builtin USB WLAN Adapter")},
-       {PRISM_USB_DEVICE(0x0846, 0x4110, "NetGear MA111")},
-       {PRISM_USB_DEVICE(0x03f3, 0x0020, "Adaptec AWN-8020 USB WLAN Adapter")},
-       {PRISM_USB_DEVICE(0x2821, 0x3300, "ASUS-WL140 Wireless USB Adapter")},
-       {PRISM_USB_DEVICE(0x2001, 0x3700, "DWL-122 Wireless USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x2001, 0x3702, "DWL-120 Rev F Wireless USB Adapter")},
-       {PRISM_USB_DEVICE(0x50c2, 0x4013, "Averatec USB WLAN Adapter")},
-       {PRISM_USB_DEVICE(0x2c02, 0x14ea, "Planex GW-US11H WLAN USB Adapter")},
-       {PRISM_USB_DEVICE(0x124a, 0x168b, "Airvast PRISM3 WLAN USB Adapter")},
-       {PRISM_USB_DEVICE(0x083a, 0x3503, "T-Sinus 111 USB WLAN Adapter")},
-       {PRISM_USB_DEVICE(0x2821, 0x3300, "Hawking HighDB USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x0411, 0x0044, "Melco WLI-USB-KB11 11Mbps WLAN Adapter")},
-       {PRISM_USB_DEVICE(0x1668, 0x6106, "ROPEX FreeLan 802.11b USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x124a, 0x4017, "Pheenet WL-503IA 802.11b USB Adapter")},
-       {PRISM_USB_DEVICE(0x0bb2, 0x0302, "Ambit Microsystems Corp.")},
-       {PRISM_USB_DEVICE
-        (0x9016, 0x182d, "Sitecom WL-022 802.11b USB Adapter")},
-       {PRISM_USB_DEVICE
-        (0x0543, 0x0f01, "ViewSonic Airsync USB Adapter 11Mbps (Prism2.5)")},
-       { /* terminator */ }
+       PRISM_DEV(0x04bb, 0x0922, "IOData AirPort WN-B11/USBS"),
+       PRISM_DEV(0x07aa, 0x0012, "Corega Wireless LAN USB Stick-11"),
+       PRISM_DEV(0x09aa, 0x3642, "Prism2.x 11Mbps WLAN USB Adapter"),
+       PRISM_DEV(0x1668, 0x0408, "Actiontec Prism2.5 11Mbps WLAN USB Adapter"),
+       PRISM_DEV(0x1668, 0x0421, "Actiontec Prism2.5 11Mbps WLAN USB Adapter"),
+       PRISM_DEV(0x1915, 0x2236, "Linksys WUSB11v3.0 11Mbps WLAN USB Adapter"),
+       PRISM_DEV(0x066b, 0x2212, "Linksys WUSB11v2.5 11Mbps WLAN USB Adapter"),
+       PRISM_DEV(0x066b, 0x2213, "Linksys WUSB12v1.1 11Mbps WLAN USB Adapter"),
+       PRISM_DEV(0x0411, 0x0016, "Melco WLI-USB-S11 11Mbps WLAN Adapter"),
+       PRISM_DEV(0x08de, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter"),
+       PRISM_DEV(0x8086, 0x1111, "Intel PRO/Wireless 2011B LAN USB Adapter"),
+       PRISM_DEV(0x0d8e, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter"),
+       PRISM_DEV(0x045e, 0x006e, "Microsoft MN510 Wireless USB Adapter"),
+       PRISM_DEV(0x0967, 0x0204, "Acer Warplink USB Adapter"),
+       PRISM_DEV(0x0cde, 0x0002, "Z-Com 725/726 Prism2.5 USB/USB Integrated"),
+       PRISM_DEV(0x0cde, 0x0005, "Z-Com Xl735 Wireless 802.11b USB Adapter"),
+       PRISM_DEV(0x413c, 0x8100, "Dell TrueMobile 1180 Wireless USB Adapter"),
+       PRISM_DEV(0x0b3b, 0x1601, "ALLNET 0193 11Mbps WLAN USB Adapter"),
+       PRISM_DEV(0x0b3b, 0x1602, "ZyXEL ZyAIR B200 Wireless USB Adapter"),
+       PRISM_DEV(0x0baf, 0x00eb, "USRobotics USR1120 Wireless USB Adapter"),
+       PRISM_DEV(0x0411, 0x0027, "Melco WLI-USB-KS11G 11Mbps WLAN Adapter"),
+       PRISM_DEV(0x04f1, 0x3009, "JVC MP-XP7250 Builtin USB WLAN Adapter"),
+       PRISM_DEV(0x0846, 0x4110, "NetGear MA111"),
+       PRISM_DEV(0x03f3, 0x0020, "Adaptec AWN-8020 USB WLAN Adapter"),
+       PRISM_DEV(0x2821, 0x3300, "ASUS-WL140 Wireless USB Adapter"),
+       PRISM_DEV(0x2001, 0x3700, "DWL-122 Wireless USB Adapter"),
+       PRISM_DEV(0x2001, 0x3702, "DWL-120 Rev F Wireless USB Adapter"),
+       PRISM_DEV(0x50c2, 0x4013, "Averatec USB WLAN Adapter"),
+       PRISM_DEV(0x2c02, 0x14ea, "Planex GW-US11H WLAN USB Adapter"),
+       PRISM_DEV(0x124a, 0x168b, "Airvast PRISM3 WLAN USB Adapter"),
+       PRISM_DEV(0x083a, 0x3503, "T-Sinus 111 USB WLAN Adapter"),
+       PRISM_DEV(0x2821, 0x3300, "Hawking HighDB USB Adapter"),
+       PRISM_DEV(0x0411, 0x0044, "Melco WLI-USB-KB11 11Mbps WLAN Adapter"),
+       PRISM_DEV(0x1668, 0x6106, "ROPEX FreeLan 802.11b USB Adapter"),
+       PRISM_DEV(0x124a, 0x4017, "Pheenet WL-503IA 802.11b USB Adapter"),
+       PRISM_DEV(0x0bb2, 0x0302, "Ambit Microsystems Corp."),
+       PRISM_DEV(0x9016, 0x182d, "Sitecom WL-022 802.11b USB Adapter"),
+       PRISM_DEV(0x0543, 0x0f01,
+               "ViewSonic Airsync USB Adapter 11Mbps (Prism2.5)"),
+       PRISM_DEV(0x067c, 0x1022,
+               "Siemens SpeedStream 1022 11Mbps WLAN USB Adapter"),
+       PRISM_DEV(0x049f, 0x0033,
+               "Compaq/Intel W100 PRO/Wireless 11Mbps multiport WLAN Adapter"),
+       { } /* terminator */
 };
-
 MODULE_DEVICE_TABLE(usb, usb_prism_tbl);
 
-/*----------------------------------------------------------------
-* prism2sta_probe_usb
-*
-* Probe routine called by the USB subsystem.
-*
-* Arguments:
-*      dev             ptr to the usb_device struct
-*      ifnum           interface number being offered
-*
-* Returns:
-*      NULL            - we're not claiming the device+interface
-*      non-NULL        - we are claiming the device+interface and
-*                        this is a ptr to the data we want back
-*                        when disconnect is called.
-*
-* Side effects:
-*
-* Call context:
-*      I'm not sure, assume it's interrupt.
-*
-----------------------------------------------------------------*/
 static int prism2sta_probe_usb(struct usb_interface *interface,
                               const struct usb_device_id *id)
 {
@@ -141,7 +96,8 @@ static int prism2sta_probe_usb(struct usb_interface *interface,
                                           prism2_reset_settletime, 0);
                if (result != 0) {
                        result = -EIO;
-                       dev_err(&interface->dev, "hfa384x_corereset() failed.\n");
+                       dev_err(&interface->dev,
+                               "hfa384x_corereset() failed.\n");
                        goto failed_reset;
                }
        }
@@ -176,31 +132,11 @@ done:
        return result;
 }
 
-/*----------------------------------------------------------------
-* prism2sta_disconnect_usb
-*
-* Called when a device previously claimed by probe is removed
-* from the USB.
-*
-* Arguments:
-*      dev             ptr to the usb_device struct
-*      ptr             ptr returned by probe() when the device
-*                       was claimed.
-*
-* Returns:
-*      Nothing
-*
-* Side effects:
-*
-* Call context:
-*      process
-----------------------------------------------------------------*/
 static void prism2sta_disconnect_usb(struct usb_interface *interface)
 {
        wlandevice_t *wlandev;
 
        wlandev = (wlandevice_t *) usb_get_intfdata(interface);
-
        if (wlandev != NULL) {
                LIST_HEAD(cleanlist);
                struct list_head *entry;
@@ -292,6 +228,7 @@ static int prism2sta_suspend(struct usb_interface *interface,
 {
        hfa384x_t *hw = NULL;
        wlandevice_t *wlandev;
+
        wlandev = (wlandevice_t *) usb_get_intfdata(interface);
        if (!wlandev)
                return -ENODEV;
@@ -314,6 +251,7 @@ static int prism2sta_resume(struct usb_interface *interface)
        int result = 0;
        hfa384x_t *hw = NULL;
        wlandevice_t *wlandev;
+
        wlandev = (wlandevice_t *) usb_get_intfdata(interface);
        if (!wlandev)
                return -ENODEV;
index 466804687fc04cdc9156419537899f4dda8fcaee..a62d4dd4ce82608cc6095931418897d261ce502b 100644 (file)
@@ -66,6 +66,7 @@ static int XGIfb_mode_rate_to_dclock(struct vb_device_info *XGI_Pr,
        unsigned short ModeIdIndex = 0, ClockIndex = 0;
        unsigned short RefreshRateTableIndex = 0;
        int Clock;
+
        InitTo330Pointer(HwDeviceExtension->jChipType, XGI_Pr);
 
        XGI_SearchModeID(ModeNo, &ModeIdIndex);
@@ -95,6 +96,7 @@ static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr,
        unsigned short HRE, HBE, HRS, HDE;
        unsigned char sr_data, cr_data, cr_data2;
        int B, C, D, F, temp, j;
+
        InitTo330Pointer(HwDeviceExtension->jChipType, XGI_Pr);
        if (!XGI_SearchModeID(ModeNo, &ModeIdIndex))
                return 0;
index 21541720e05ce5c9a000c35dd267eb34bbb5f506..ff210ddcbf9e5c1936a0f2fb931a0ad69e4607a2 100644 (file)
@@ -130,6 +130,7 @@ static void XGINew_DDRII_Bootup_XG27(
                        unsigned long P3c4, struct vb_device_info *pVBInfo)
 {
        unsigned long P3d4 = P3c4 + 0x10;
+
        pVBInfo->ram_type = XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo);
        XGINew_SetMemoryClock(pVBInfo);
 
@@ -389,6 +390,7 @@ static void XGI_SetDRAM_Helper(unsigned long P3d4, u8 seed, u8 temp2, u8 reg,
        u8 shift_factor, u8 mask1, u8 mask2)
 {
        u8 j;
+
        for (j = 0; j < 4; j++) {
                temp2 |= (((seed >> (2 * j)) & 0x03) << shift_factor);
                xgifb_reg_set(P3d4, reg, temp2);
index 400c726753fa48170e8a0187568d7025daed2092..c638c8febee945fba00c5a13cd85e5fa8f270b28 100644 (file)
@@ -49,6 +49,7 @@ void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
 
        if (ChipType == XG27) {
                unsigned char temp;
+
                pVBInfo->MCLKData = XGI27New_MCLKData;
                pVBInfo->CR40 = XGI27_cr41;
                pVBInfo->XGINew_CR97 = 0xc1;
@@ -5222,6 +5223,7 @@ void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
        unsigned short temp;
 
        int i;
+
        xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
 
        /* to fix XG42 single LCD sense to CRT+LCD */
index 3c005eb3a0a4bab608479bd3ba7cd4d3dc65cd5f..96f51f0e00961c894c1a38b85f89873ea19d31af 100644 (file)
@@ -269,6 +269,10 @@ int st_sensors_set_enable(struct iio_dev *indio_dev, bool enable);
 
 int st_sensors_set_axis_enable(struct iio_dev *indio_dev, u8 axis_enable);
 
+void st_sensors_power_enable(struct iio_dev *indio_dev);
+
+void st_sensors_power_disable(struct iio_dev *indio_dev);
+
 int st_sensors_set_odr(struct iio_dev *indio_dev, unsigned int odr);
 
 int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable);
index 2752b1fd12be3ea8b41c58f64b408d88f1afddaa..651f9a0e2765fa17a4896321478c15b9997f416e 100644 (file)
@@ -122,6 +122,19 @@ struct iio_channel
 int iio_read_channel_raw(struct iio_channel *chan,
                         int *val);
 
+/**
+ * iio_read_channel_average_raw() - read from a given channel
+ * @chan:              The channel being queried.
+ * @val:               Value read back.
+ *
+ * Note raw reads from iio channels are in adc counts and hence
+ * scale will need to be applied if standard units required.
+ *
+ * In opposit to the normal iio_read_channel_raw this function
+ * returns the average of multiple reads.
+ */
+int iio_read_channel_average_raw(struct iio_channel *chan, int *val);
+
 /**
  * iio_read_channel_processed() - read processed value from a given channel
  * @chan:              The channel being queried.