Merge 3.18-rc3 into staging-next
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 Nov 2014 02:06:03 +0000 (18:06 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 Nov 2014 02:06:03 +0000 (18:06 -0800)
We want the upstream fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
531 files changed:
.gitignore
MAINTAINERS
drivers/Kconfig
drivers/Makefile
drivers/android/Kconfig [new file with mode: 0644]
drivers/android/Makefile [new file with mode: 0644]
drivers/android/binder.c [new file with mode: 0644]
drivers/android/binder_trace.h [new file with mode: 0644]
drivers/staging/Kconfig
drivers/staging/Makefile
drivers/staging/android/Kconfig
drivers/staging/android/Makefile
drivers/staging/android/binder.c [deleted file]
drivers/staging/android/binder.h [deleted file]
drivers/staging/android/binder_trace.h [deleted file]
drivers/staging/android/ion/ion.c
drivers/staging/android/ion/ion_page_pool.c
drivers/staging/android/sync_debug.c
drivers/staging/android/timed_gpio.c
drivers/staging/android/uapi/binder.h [deleted file]
drivers/staging/bcm/Adapter.h [deleted file]
drivers/staging/bcm/Bcmchar.c [deleted file]
drivers/staging/bcm/Bcmnet.c [deleted file]
drivers/staging/bcm/CmHost.c [deleted file]
drivers/staging/bcm/CmHost.h [deleted file]
drivers/staging/bcm/DDRInit.c [deleted file]
drivers/staging/bcm/DDRInit.h [deleted file]
drivers/staging/bcm/Debug.h [deleted file]
drivers/staging/bcm/HandleControlPacket.c [deleted file]
drivers/staging/bcm/HostMIBSInterface.h [deleted file]
drivers/staging/bcm/IPv6Protocol.c [deleted file]
drivers/staging/bcm/IPv6ProtocolHdr.h [deleted file]
drivers/staging/bcm/InterfaceAdapter.h [deleted file]
drivers/staging/bcm/InterfaceDld.c [deleted file]
drivers/staging/bcm/InterfaceIdleMode.c [deleted file]
drivers/staging/bcm/InterfaceIdleMode.h [deleted file]
drivers/staging/bcm/InterfaceInit.c [deleted file]
drivers/staging/bcm/InterfaceInit.h [deleted file]
drivers/staging/bcm/InterfaceIsr.c [deleted file]
drivers/staging/bcm/InterfaceIsr.h [deleted file]
drivers/staging/bcm/InterfaceMacros.h [deleted file]
drivers/staging/bcm/InterfaceMisc.c [deleted file]
drivers/staging/bcm/InterfaceMisc.h [deleted file]
drivers/staging/bcm/InterfaceRx.c [deleted file]
drivers/staging/bcm/InterfaceRx.h [deleted file]
drivers/staging/bcm/InterfaceTx.c [deleted file]
drivers/staging/bcm/InterfaceTx.h [deleted file]
drivers/staging/bcm/Ioctl.h [deleted file]
drivers/staging/bcm/Kconfig [deleted file]
drivers/staging/bcm/LeakyBucket.c [deleted file]
drivers/staging/bcm/Macros.h [deleted file]
drivers/staging/bcm/Makefile [deleted file]
drivers/staging/bcm/Misc.c [deleted file]
drivers/staging/bcm/PHSDefines.h [deleted file]
drivers/staging/bcm/PHSModule.c [deleted file]
drivers/staging/bcm/PHSModule.h [deleted file]
drivers/staging/bcm/Protocol.h [deleted file]
drivers/staging/bcm/Prototypes.h [deleted file]
drivers/staging/bcm/Qos.c [deleted file]
drivers/staging/bcm/Queue.h [deleted file]
drivers/staging/bcm/TODO [deleted file]
drivers/staging/bcm/Transmit.c [deleted file]
drivers/staging/bcm/Typedefs.h [deleted file]
drivers/staging/bcm/cntrl_SignalingInterface.h [deleted file]
drivers/staging/bcm/headers.h [deleted file]
drivers/staging/bcm/hostmibs.c [deleted file]
drivers/staging/bcm/led_control.c [deleted file]
drivers/staging/bcm/led_control.h [deleted file]
drivers/staging/bcm/nvm.c [deleted file]
drivers/staging/bcm/nvm.h [deleted file]
drivers/staging/bcm/sort.c [deleted file]
drivers/staging/bcm/target_params.h [deleted file]
drivers/staging/bcm/vendorspecificextn.c [deleted file]
drivers/staging/bcm/vendorspecificextn.h [deleted file]
drivers/staging/clocking-wizard/Kconfig [new file with mode: 0644]
drivers/staging/clocking-wizard/Makefile [new file with mode: 0644]
drivers/staging/clocking-wizard/TODO [new file with mode: 0644]
drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c [new file with mode: 0644]
drivers/staging/clocking-wizard/dt-binding.txt [new file with mode: 0644]
drivers/staging/comedi/Kconfig
drivers/staging/comedi/comedi.h
drivers/staging/comedi/comedi_buf.c
drivers/staging/comedi/comedi_fops.c
drivers/staging/comedi/comedidev.h
drivers/staging/comedi/drivers.c
drivers/staging/comedi/drivers/Makefile
drivers/staging/comedi/drivers/addi-data/addi_common.c [deleted file]
drivers/staging/comedi/drivers/addi-data/addi_common.h [deleted file]
drivers/staging/comedi/drivers/addi-data/addi_eeprom.c [deleted file]
drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c [deleted file]
drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.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 [deleted file]
drivers/staging/comedi/drivers/addi_apci_035.c [deleted file]
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_3200.c [deleted file]
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_common.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/cb_pcimdas.c
drivers/staging/comedi/drivers/comedi_bond.c
drivers/staging/comedi/drivers/comedi_fc.h
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/das800.c
drivers/staging/comedi/drivers/dmm32at.c
drivers/staging/comedi/drivers/dt2814.c
drivers/staging/comedi/drivers/dt282x.c
drivers/staging/comedi/drivers/dt3000.c
drivers/staging/comedi/drivers/gsc_hpdi.c
drivers/staging/comedi/drivers/me4000.c
drivers/staging/comedi/drivers/mite.c
drivers/staging/comedi/drivers/ni_6527.c
drivers/staging/comedi/drivers/ni_65xx.c
drivers/staging/comedi/drivers/ni_660x.c
drivers/staging/comedi/drivers/ni_at_a2150.c
drivers/staging/comedi/drivers/ni_atmio16d.c
drivers/staging/comedi/drivers/ni_labpc_common.c
drivers/staging/comedi/drivers/ni_labpc_isadma.c
drivers/staging/comedi/drivers/ni_mio_common.c
drivers/staging/comedi/drivers/ni_pcidio.c
drivers/staging/comedi/drivers/ni_stc.h
drivers/staging/comedi/drivers/ni_tiocmd.c
drivers/staging/comedi/drivers/pcl711.c
drivers/staging/comedi/drivers/pcl726.c
drivers/staging/comedi/drivers/pcl812.c
drivers/staging/comedi/drivers/pcl816.c
drivers/staging/comedi/drivers/pcl818.c
drivers/staging/comedi/drivers/pcmmio.c
drivers/staging/comedi/drivers/pcmuio.c
drivers/staging/comedi/drivers/quatech_daqp_cs.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/comedi/range.c
drivers/staging/cptm1217/clearpad_tm1217.c
drivers/staging/dgap/dgap.c
drivers/staging/dgnc/dgnc_cls.c
drivers/staging/dgnc/dgnc_driver.c
drivers/staging/dgnc/dgnc_driver.h
drivers/staging/dgnc/dgnc_kcompat.h
drivers/staging/dgnc/dgnc_neo.c
drivers/staging/dgnc/dgnc_sysfs.c
drivers/staging/dgnc/dgnc_tty.c
drivers/staging/dgnc/dgnc_tty.h
drivers/staging/emxx_udc/emxx_udc.c
drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c
drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
drivers/staging/ft1000/ft1000-usb/ft1000_download.c
drivers/staging/gdm724x/gdm_lte.c
drivers/staging/gdm724x/gdm_mux.h
drivers/staging/gdm72xx/gdm_wimax.c
drivers/staging/gs_fpgaboot/gs_fpgaboot.c
drivers/staging/iio/Documentation/generic_buffer.c
drivers/staging/iio/Documentation/iio_event_monitor.c
drivers/staging/iio/Documentation/iio_utils.h
drivers/staging/iio/Documentation/lsiio.c
drivers/staging/iio/accel/Kconfig
drivers/staging/iio/adc/ad7192.c
drivers/staging/iio/adc/ad7280a.c
drivers/staging/iio/adc/ad7606_spi.c
drivers/staging/iio/adc/ad7816.c
drivers/staging/iio/adc/lpc32xx_adc.c
drivers/staging/iio/adc/mxs-lradc.c
drivers/staging/iio/adc/spear_adc.c
drivers/staging/iio/addac/Kconfig
drivers/staging/iio/addac/adt7316.h
drivers/staging/iio/gyro/Kconfig
drivers/staging/iio/light/tsl2x7x_core.c
drivers/staging/iio/meter/Kconfig
drivers/staging/iio/trigger/Kconfig
drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
drivers/staging/imx-drm/imx-drm-core.c
drivers/staging/imx-drm/imx-tve.c
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
drivers/staging/lustre/lnet/lnet/api-ni.c
drivers/staging/lustre/lnet/lnet/lib-md.c
drivers/staging/lustre/lnet/lnet/lib-move.c
drivers/staging/lustre/lnet/lnet/lo.c
drivers/staging/lustre/lnet/lnet/module.c
drivers/staging/lustre/lnet/lnet/router_proc.c
drivers/staging/lustre/lnet/selftest/brw_test.c
drivers/staging/lustre/lnet/selftest/conctl.c
drivers/staging/lustre/lnet/selftest/conrpc.c
drivers/staging/lustre/lnet/selftest/framework.c
drivers/staging/lustre/lnet/selftest/module.c
drivers/staging/lustre/lnet/selftest/ping_test.c
drivers/staging/lustre/lnet/selftest/rpc.c
drivers/staging/lustre/lnet/selftest/timer.c
drivers/staging/lustre/lustre/include/dt_object.h
drivers/staging/lustre/lustre/include/linux/lustre_compat25.h
drivers/staging/lustre/lustre/include/lprocfs_status.h
drivers/staging/lustre/lustre/include/lu_object.h
drivers/staging/lustre/lustre/include/lustre_capa.h
drivers/staging/lustre/lustre/include/lustre_dlm.h
drivers/staging/lustre/lustre/include/lustre_eacl.h
drivers/staging/lustre/lustre/include/lustre_lib.h
drivers/staging/lustre/lustre/include/lustre_net.h
drivers/staging/lustre/lustre/include/obd_class.h
drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
drivers/staging/lustre/lustre/libcfs/debug.c
drivers/staging/lustre/lustre/libcfs/fail.c
drivers/staging/lustre/lustre/libcfs/hash.c
drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c
drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
drivers/staging/lustre/lustre/llite/dir.c
drivers/staging/lustre/lustre/llite/file.c
drivers/staging/lustre/lustre/llite/llite_internal.h
drivers/staging/lustre/lustre/llite/llite_lib.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/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/vvp_io.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/lov/lov_obd.c
drivers/staging/lustre/lustre/lov/lov_pack.c
drivers/staging/lustre/lustre/mgc/mgc_request.c
drivers/staging/lustre/lustre/obdclass/acl.c
drivers/staging/lustre/lustre/obdclass/capa.c
drivers/staging/lustre/lustre/obdclass/dt_object.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/lprocfs_status.c
drivers/staging/lustre/lustre/obdclass/obd_config.c
drivers/staging/lustre/lustre/obdecho/echo_client.c
drivers/staging/lustre/lustre/osc/osc_cache.c
drivers/staging/lustre/lustre/osc/osc_cl_internal.h
drivers/staging/lustre/lustre/osc/osc_request.c
drivers/staging/lustre/lustre/ptlrpc/layout.c
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
drivers/staging/lustre/lustre/ptlrpc/pinger.c
drivers/staging/lustre/lustre/ptlrpc/sec.c
drivers/staging/lustre/lustre/ptlrpc/sec_null.c
drivers/staging/media/cxd2099/cxd2099.c
drivers/staging/media/davinci_vpfe/dm365_ipipe.h
drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h
drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
drivers/staging/media/davinci_vpfe/dm365_ipipeif.h
drivers/staging/media/davinci_vpfe/dm365_isif.c
drivers/staging/media/davinci_vpfe/dm365_isif.h
drivers/staging/media/davinci_vpfe/dm365_resizer.c
drivers/staging/media/davinci_vpfe/dm365_resizer.h
drivers/staging/media/lirc/lirc_bt829.c
drivers/staging/media/lirc/lirc_igorplugusb.c
drivers/staging/media/lirc/lirc_imon.c
drivers/staging/media/lirc/lirc_sasem.c
drivers/staging/media/lirc/lirc_sir.c
drivers/staging/media/lirc/lirc_zilog.c
drivers/staging/media/omap24xx/omap24xxcam.c
drivers/staging/media/omap24xx/tcm825x.c
drivers/staging/media/omap4iss/iss.c
drivers/staging/media/omap4iss/iss_csi2.c
drivers/staging/octeon-usb/octeon-hcd.c
drivers/staging/octeon/ethernet-rx.c
drivers/staging/octeon/ethernet-tx.c
drivers/staging/octeon/ethernet.c
drivers/staging/ozwpan/ozhcd.c
drivers/staging/ozwpan/ozusbsvc1.c
drivers/staging/panel/panel.c
drivers/staging/rtl8188eu/core/rtw_ap.c
drivers/staging/rtl8188eu/core/rtw_cmd.c
drivers/staging/rtl8188eu/core/rtw_debug.c
drivers/staging/rtl8188eu/core/rtw_efuse.c
drivers/staging/rtl8188eu/core/rtw_ioctl_set.c
drivers/staging/rtl8188eu/core/rtw_led.c
drivers/staging/rtl8188eu/core/rtw_mlme.c
drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
drivers/staging/rtl8188eu/core/rtw_recv.c
drivers/staging/rtl8188eu/core/rtw_security.c
drivers/staging/rtl8188eu/core/rtw_wlan_util.c
drivers/staging/rtl8188eu/hal/bb_cfg.c
drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c
drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c
drivers/staging/rtl8188eu/hal/usb_halinit.c
drivers/staging/rtl8188eu/include/odm_debug.h
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
drivers/staging/rtl8188eu/os_dep/osdep_service.c
drivers/staging/rtl8188eu/os_dep/usb_intf.c
drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
drivers/staging/rtl8192e/rtl819x_BAProc.c
drivers/staging/rtl8192e/rtllib.h
drivers/staging/rtl8192e/rtllib_rx.c
drivers/staging/rtl8192e/rtllib_softmac.c
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c
drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
drivers/staging/rtl8192u/r8192U_core.c
drivers/staging/rtl8192u/r8192U_dm.c
drivers/staging/rtl8192u/r8192U_wx.c
drivers/staging/rtl8192u/r819xU_firmware.c
drivers/staging/rtl8192u/r819xU_firmware.h
drivers/staging/rtl8192u/r819xU_phy.c
drivers/staging/rtl8712/hal_init.c
drivers/staging/rtl8712/ieee80211.c
drivers/staging/rtl8712/osdep_service.h
drivers/staging/rtl8712/recv_linux.c
drivers/staging/rtl8712/rtl8712_cmd.c
drivers/staging/rtl8712/rtl8712_efuse.c
drivers/staging/rtl8712/rtl8712_recv.c
drivers/staging/rtl8712/rtl871x_cmd.c
drivers/staging/rtl8712/rtl871x_io.c
drivers/staging/rtl8712/rtl871x_ioctl_linux.c
drivers/staging/rtl8712/rtl871x_ioctl_set.c
drivers/staging/rtl8712/rtl871x_mlme.c
drivers/staging/rtl8712/rtl871x_mp.c
drivers/staging/rtl8712/rtl871x_mp_ioctl.c
drivers/staging/rtl8712/rtl871x_pwrctrl.c
drivers/staging/rtl8712/rtl871x_recv.c
drivers/staging/rtl8712/rtl871x_recv.h
drivers/staging/rtl8712/rtl871x_security.c
drivers/staging/rtl8712/rtl871x_sta_mgt.c
drivers/staging/rtl8712/rtl871x_xmit.c
drivers/staging/rtl8712/usb_intf.c
drivers/staging/rtl8712/usb_ops_linux.c
drivers/staging/rtl8712/xmit_linux.c
drivers/staging/rtl8723au/core/rtw_ap.c
drivers/staging/rtl8723au/core/rtw_cmd.c
drivers/staging/rtl8723au/core/rtw_efuse.c
drivers/staging/rtl8723au/core/rtw_ieee80211.c
drivers/staging/rtl8723au/core/rtw_led.c
drivers/staging/rtl8723au/core/rtw_mlme.c
drivers/staging/rtl8723au/core/rtw_mlme_ext.c
drivers/staging/rtl8723au/core/rtw_pwrctrl.c
drivers/staging/rtl8723au/core/rtw_recv.c
drivers/staging/rtl8723au/core/rtw_security.c
drivers/staging/rtl8723au/core/rtw_sreset.c
drivers/staging/rtl8723au/core/rtw_wlan_util.c
drivers/staging/rtl8723au/core/rtw_xmit.c
drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c
drivers/staging/rtl8723au/hal/hal_com.c
drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c
drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c
drivers/staging/rtl8723au/hal/usb_halinit.c
drivers/staging/rtl8723au/include/Hal8723UHWImg_CE.h
drivers/staging/rtl8723au/include/odm_debug.h
drivers/staging/rtl8723au/include/rtl8723a_dm.h
drivers/staging/rtl8723au/include/rtl8723a_recv.h
drivers/staging/rtl8723au/include/rtw_cmd.h
drivers/staging/rtl8723au/include/rtw_ht.h
drivers/staging/rtl8723au/include/rtw_mlme.h
drivers/staging/rtl8723au/include/rtw_mlme_ext.h
drivers/staging/rtl8723au/include/rtw_xmit.h
drivers/staging/rtl8723au/include/wlan_bssdef.h
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
drivers/staging/rtl8723au/os_dep/os_intfs.c
drivers/staging/rtl8723au/os_dep/usb_intf.c
drivers/staging/rtl8723au/os_dep/usb_ops_linux.c
drivers/staging/rts5208/ms.c
drivers/staging/rts5208/rtsx.c
drivers/staging/rts5208/rtsx_chip.c
drivers/staging/rts5208/rtsx_scsi.c
drivers/staging/rts5208/rtsx_transport.c
drivers/staging/rts5208/rtsx_transport.h
drivers/staging/skein/Kconfig
drivers/staging/skein/Makefile
drivers/staging/skein/skein.c [deleted file]
drivers/staging/skein/skein.h [deleted file]
drivers/staging/skein/skein_api.c
drivers/staging/skein/skein_api.h
drivers/staging/skein/skein_base.c [new file with mode: 0644]
drivers/staging/skein/skein_base.h [new file with mode: 0644]
drivers/staging/skein/skein_block.c
drivers/staging/skein/skein_block.h
drivers/staging/skein/skein_generic.c [new file with mode: 0644]
drivers/staging/skein/skein_iv.h
drivers/staging/skein/threefish_api.h
drivers/staging/slicoss/slicoss.c
drivers/staging/speakup/kobjects.c
drivers/staging/speakup/main.c
drivers/staging/speakup/speakup_dtlk.c
drivers/staging/speakup/speakup_keypc.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/vbusdeviceinfo.h
drivers/staging/unisys/common-spar/include/vmcallinterface.h
drivers/staging/unisys/include/timskmod.h
drivers/staging/unisys/include/uisqueue.h
drivers/staging/unisys/include/uisutils.h
drivers/staging/unisys/include/vbushelper.h
drivers/staging/unisys/uislib/uislib.c
drivers/staging/unisys/uislib/uisqueue.c
drivers/staging/unisys/uislib/uisutils.c
drivers/staging/unisys/virthba/virthba.c
drivers/staging/unisys/virtpci/virtpci.c
drivers/staging/unisys/virtpci/virtpci.h
drivers/staging/unisys/visorchannel/visorchannel_funcs.c
drivers/staging/unisys/visorchipset/file.c
drivers/staging/unisys/visorchipset/parser.c
drivers/staging/unisys/visorchipset/testing.h
drivers/staging/unisys/visorchipset/visorchipset.h
drivers/staging/unisys/visorchipset/visorchipset_main.c
drivers/staging/unisys/visorutil/easyproc.c
drivers/staging/unisys/visorutil/procobjecttree.c
drivers/staging/unisys/visorutil/visorkmodutils.c
drivers/staging/vme/devices/Kconfig
drivers/staging/vme/devices/vme_pio2_gpio.c
drivers/staging/vt6655/80211hdr.h [deleted file]
drivers/staging/vt6655/80211mgr.c [deleted file]
drivers/staging/vt6655/80211mgr.h [deleted file]
drivers/staging/vt6655/IEEE11h.c [deleted file]
drivers/staging/vt6655/IEEE11h.h [deleted file]
drivers/staging/vt6655/Kconfig
drivers/staging/vt6655/Makefile
drivers/staging/vt6655/aes_ccmp.c [deleted file]
drivers/staging/vt6655/aes_ccmp.h [deleted file]
drivers/staging/vt6655/baseband.c
drivers/staging/vt6655/baseband.h
drivers/staging/vt6655/bssdb.c [deleted file]
drivers/staging/vt6655/bssdb.h [deleted file]
drivers/staging/vt6655/card.c
drivers/staging/vt6655/card.h
drivers/staging/vt6655/channel.c
drivers/staging/vt6655/channel.h
drivers/staging/vt6655/country.h [deleted file]
drivers/staging/vt6655/datarate.c [deleted file]
drivers/staging/vt6655/datarate.h [deleted file]
drivers/staging/vt6655/desc.h
drivers/staging/vt6655/device.h
drivers/staging/vt6655/device_cfg.h
drivers/staging/vt6655/device_main.c
drivers/staging/vt6655/dpc.c
drivers/staging/vt6655/dpc.h
drivers/staging/vt6655/hostap.c [deleted file]
drivers/staging/vt6655/hostap.h [deleted file]
drivers/staging/vt6655/iocmd.h [deleted file]
drivers/staging/vt6655/ioctl.c [deleted file]
drivers/staging/vt6655/ioctl.h [deleted file]
drivers/staging/vt6655/iowpa.h [deleted file]
drivers/staging/vt6655/iwctl.c [deleted file]
drivers/staging/vt6655/iwctl.h [deleted file]
drivers/staging/vt6655/key.c
drivers/staging/vt6655/key.h
drivers/staging/vt6655/mac.c
drivers/staging/vt6655/mac.h
drivers/staging/vt6655/mib.c
drivers/staging/vt6655/mib.h
drivers/staging/vt6655/michael.c [deleted file]
drivers/staging/vt6655/michael.h [deleted file]
drivers/staging/vt6655/power.c
drivers/staging/vt6655/power.h
drivers/staging/vt6655/rc4.c [deleted file]
drivers/staging/vt6655/rc4.h [deleted file]
drivers/staging/vt6655/rf.h
drivers/staging/vt6655/rxtx.c
drivers/staging/vt6655/rxtx.h
drivers/staging/vt6655/srom.c
drivers/staging/vt6655/srom.h
drivers/staging/vt6655/tcrc.c [deleted file]
drivers/staging/vt6655/tcrc.h [deleted file]
drivers/staging/vt6655/tether.c [deleted file]
drivers/staging/vt6655/tether.h [deleted file]
drivers/staging/vt6655/tkip.c [deleted file]
drivers/staging/vt6655/tkip.h [deleted file]
drivers/staging/vt6655/tmacro.h
drivers/staging/vt6655/ttype.h [deleted file]
drivers/staging/vt6655/upc.h
drivers/staging/vt6655/vntconfiguration.dat [deleted file]
drivers/staging/vt6655/vntwifi.c [deleted file]
drivers/staging/vt6655/vntwifi.h [deleted file]
drivers/staging/vt6655/wcmd.c [deleted file]
drivers/staging/vt6655/wcmd.h [deleted file]
drivers/staging/vt6655/wctl.c [deleted file]
drivers/staging/vt6655/wctl.h [deleted file]
drivers/staging/vt6655/wmgr.c [deleted file]
drivers/staging/vt6655/wmgr.h [deleted file]
drivers/staging/vt6655/wpa.c [deleted file]
drivers/staging/vt6655/wpa.h [deleted file]
drivers/staging/vt6655/wpa2.c [deleted file]
drivers/staging/vt6655/wpa2.h [deleted file]
drivers/staging/vt6655/wpactl.c [deleted file]
drivers/staging/vt6655/wpactl.h [deleted file]
drivers/staging/vt6655/wroute.c [deleted file]
drivers/staging/vt6655/wroute.h [deleted file]
drivers/staging/vt6656/main_usb.c
drivers/staging/wlan-ng/hfa384x.h
drivers/staging/wlan-ng/hfa384x_usb.c
drivers/staging/wlan-ng/p80211conv.c
drivers/staging/wlan-ng/p80211hdr.h
drivers/staging/wlan-ng/p80211netdev.c
drivers/staging/wlan-ng/prism2fw.c
drivers/staging/xgifb/XGI_main_26.c
drivers/staging/xgifb/vb_setmode.c
drivers/staging/xgifb/vb_util.c
include/uapi/linux/Kbuild
include/uapi/linux/android/Kbuild [new file with mode: 0644]
include/uapi/linux/android/binder.h [new file with mode: 0644]

index e213b27..6bfac06 100644 (file)
@@ -96,3 +96,7 @@ x509.genkey
 
 # Kconfig presets
 all.config
+
+#eclipse files
+.project
+.cproject
index 3c64271..df2aecf 100644 (file)
@@ -1890,13 +1890,6 @@ W:       http://bcache.evilpiepirate.org
 S:     Maintained:
 F:     drivers/md/bcache/
 
-BECEEM BCS200/BCS220-3/BCSM250 WIMAX SUPPORT
-M: Kevin McKinney <klmckinney1@gmail.com>
-M: Matthias Beyer <mail@beyermatthias.de>
-L: devel@driverdev.osuosl.org
-S: Maintained
-F: drivers/staging/bcm*
-
 BEFS FILE SYSTEM
 S:     Orphan
 F:     Documentation/filesystems/befs.txt
index 1a693d3..569ff78 100644 (file)
@@ -182,4 +182,6 @@ source "drivers/ras/Kconfig"
 
 source "drivers/thunderbolt/Kconfig"
 
+source "drivers/android/Kconfig"
+
 endmenu
index ebee555..60d1982 100644 (file)
@@ -161,3 +161,4 @@ obj-$(CONFIG_POWERCAP)              += powercap/
 obj-$(CONFIG_MCB)              += mcb/
 obj-$(CONFIG_RAS)              += ras/
 obj-$(CONFIG_THUNDERBOLT)      += thunderbolt/
+obj-$(CONFIG_ANDROID)          += android/
diff --git a/drivers/android/Kconfig b/drivers/android/Kconfig
new file mode 100644 (file)
index 0000000..bdfc6c6
--- /dev/null
@@ -0,0 +1,37 @@
+menu "Android"
+
+config ANDROID
+       bool "Android Drivers"
+       ---help---
+         Enable support for various drivers needed on the Android platform
+
+if ANDROID
+
+config ANDROID_BINDER_IPC
+       bool "Android Binder IPC Driver"
+       depends on MMU
+       default n
+       ---help---
+         Binder is used in Android for both communication between processes,
+         and remote method invocation.
+
+         This means one Android process can call a method/routine in another
+         Android process, using Binder to identify, invoke and pass arguments
+         between said processes.
+
+config ANDROID_BINDER_IPC_32BIT
+       bool
+       depends on !64BIT && ANDROID_BINDER_IPC
+       default y
+       ---help---
+         The Binder API has been changed to support both 32 and 64bit
+         applications in a mixed environment.
+
+         Enable this to support an old 32-bit Android user-space (v4.4 and
+         earlier).
+
+         Note that enabling this will break newer Android user-space.
+
+endif # if ANDROID
+
+endmenu
diff --git a/drivers/android/Makefile b/drivers/android/Makefile
new file mode 100644 (file)
index 0000000..3b7e4b0
--- /dev/null
@@ -0,0 +1,3 @@
+ccflags-y += -I$(src)                  # needed for trace events
+
+obj-$(CONFIG_ANDROID_BINDER_IPC)       += binder.o
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
new file mode 100644 (file)
index 0000000..8c43521
--- /dev/null
@@ -0,0 +1,3677 @@
+/* binder.c
+ *
+ * Android IPC Subsystem
+ *
+ * Copyright (C) 2007-2008 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.
+ *
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <asm/cacheflush.h>
+#include <linux/fdtable.h>
+#include <linux/file.h>
+#include <linux/freezer.h>
+#include <linux/fs.h>
+#include <linux/list.h>
+#include <linux/miscdevice.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/nsproxy.h>
+#include <linux/poll.h>
+#include <linux/debugfs.h>
+#include <linux/rbtree.h>
+#include <linux/sched.h>
+#include <linux/seq_file.h>
+#include <linux/uaccess.h>
+#include <linux/vmalloc.h>
+#include <linux/slab.h>
+#include <linux/pid_namespace.h>
+
+#ifdef CONFIG_ANDROID_BINDER_IPC_32BIT
+#define BINDER_IPC_32BIT 1
+#endif
+
+#include <uapi/linux/android/binder.h>
+#include "binder_trace.h"
+
+static DEFINE_MUTEX(binder_main_lock);
+static DEFINE_MUTEX(binder_deferred_lock);
+static DEFINE_MUTEX(binder_mmap_lock);
+
+static HLIST_HEAD(binder_procs);
+static HLIST_HEAD(binder_deferred_list);
+static HLIST_HEAD(binder_dead_nodes);
+
+static struct dentry *binder_debugfs_dir_entry_root;
+static struct dentry *binder_debugfs_dir_entry_proc;
+static struct binder_node *binder_context_mgr_node;
+static kuid_t binder_context_mgr_uid = INVALID_UID;
+static int binder_last_id;
+static struct workqueue_struct *binder_deferred_workqueue;
+
+#define BINDER_DEBUG_ENTRY(name) \
+static int binder_##name##_open(struct inode *inode, struct file *file) \
+{ \
+       return single_open(file, binder_##name##_show, inode->i_private); \
+} \
+\
+static const struct file_operations binder_##name##_fops = { \
+       .owner = THIS_MODULE, \
+       .open = binder_##name##_open, \
+       .read = seq_read, \
+       .llseek = seq_lseek, \
+       .release = single_release, \
+}
+
+static int binder_proc_show(struct seq_file *m, void *unused);
+BINDER_DEBUG_ENTRY(proc);
+
+/* This is only defined in include/asm-arm/sizes.h */
+#ifndef SZ_1K
+#define SZ_1K                               0x400
+#endif
+
+#ifndef SZ_4M
+#define SZ_4M                               0x400000
+#endif
+
+#define FORBIDDEN_MMAP_FLAGS                (VM_WRITE)
+
+#define BINDER_SMALL_BUF_SIZE (PAGE_SIZE * 64)
+
+enum {
+       BINDER_DEBUG_USER_ERROR             = 1U << 0,
+       BINDER_DEBUG_FAILED_TRANSACTION     = 1U << 1,
+       BINDER_DEBUG_DEAD_TRANSACTION       = 1U << 2,
+       BINDER_DEBUG_OPEN_CLOSE             = 1U << 3,
+       BINDER_DEBUG_DEAD_BINDER            = 1U << 4,
+       BINDER_DEBUG_DEATH_NOTIFICATION     = 1U << 5,
+       BINDER_DEBUG_READ_WRITE             = 1U << 6,
+       BINDER_DEBUG_USER_REFS              = 1U << 7,
+       BINDER_DEBUG_THREADS                = 1U << 8,
+       BINDER_DEBUG_TRANSACTION            = 1U << 9,
+       BINDER_DEBUG_TRANSACTION_COMPLETE   = 1U << 10,
+       BINDER_DEBUG_FREE_BUFFER            = 1U << 11,
+       BINDER_DEBUG_INTERNAL_REFS          = 1U << 12,
+       BINDER_DEBUG_BUFFER_ALLOC           = 1U << 13,
+       BINDER_DEBUG_PRIORITY_CAP           = 1U << 14,
+       BINDER_DEBUG_BUFFER_ALLOC_ASYNC     = 1U << 15,
+};
+static uint32_t binder_debug_mask = BINDER_DEBUG_USER_ERROR |
+       BINDER_DEBUG_FAILED_TRANSACTION | BINDER_DEBUG_DEAD_TRANSACTION;
+module_param_named(debug_mask, binder_debug_mask, uint, S_IWUSR | S_IRUGO);
+
+static bool binder_debug_no_lock;
+module_param_named(proc_no_lock, binder_debug_no_lock, bool, S_IWUSR | S_IRUGO);
+
+static DECLARE_WAIT_QUEUE_HEAD(binder_user_error_wait);
+static int binder_stop_on_user_error;
+
+static int binder_set_stop_on_user_error(const char *val,
+                                        struct kernel_param *kp)
+{
+       int ret;
+
+       ret = param_set_int(val, kp);
+       if (binder_stop_on_user_error < 2)
+               wake_up(&binder_user_error_wait);
+       return ret;
+}
+module_param_call(stop_on_user_error, binder_set_stop_on_user_error,
+       param_get_int, &binder_stop_on_user_error, S_IWUSR | S_IRUGO);
+
+#define binder_debug(mask, x...) \
+       do { \
+               if (binder_debug_mask & mask) \
+                       pr_info(x); \
+       } while (0)
+
+#define binder_user_error(x...) \
+       do { \
+               if (binder_debug_mask & BINDER_DEBUG_USER_ERROR) \
+                       pr_info(x); \
+               if (binder_stop_on_user_error) \
+                       binder_stop_on_user_error = 2; \
+       } while (0)
+
+enum binder_stat_types {
+       BINDER_STAT_PROC,
+       BINDER_STAT_THREAD,
+       BINDER_STAT_NODE,
+       BINDER_STAT_REF,
+       BINDER_STAT_DEATH,
+       BINDER_STAT_TRANSACTION,
+       BINDER_STAT_TRANSACTION_COMPLETE,
+       BINDER_STAT_COUNT
+};
+
+struct binder_stats {
+       int br[_IOC_NR(BR_FAILED_REPLY) + 1];
+       int bc[_IOC_NR(BC_DEAD_BINDER_DONE) + 1];
+       int obj_created[BINDER_STAT_COUNT];
+       int obj_deleted[BINDER_STAT_COUNT];
+};
+
+static struct binder_stats binder_stats;
+
+static inline void binder_stats_deleted(enum binder_stat_types type)
+{
+       binder_stats.obj_deleted[type]++;
+}
+
+static inline void binder_stats_created(enum binder_stat_types type)
+{
+       binder_stats.obj_created[type]++;
+}
+
+struct binder_transaction_log_entry {
+       int debug_id;
+       int call_type;
+       int from_proc;
+       int from_thread;
+       int target_handle;
+       int to_proc;
+       int to_thread;
+       int to_node;
+       int data_size;
+       int offsets_size;
+};
+struct binder_transaction_log {
+       int next;
+       int full;
+       struct binder_transaction_log_entry entry[32];
+};
+static struct binder_transaction_log binder_transaction_log;
+static struct binder_transaction_log binder_transaction_log_failed;
+
+static struct binder_transaction_log_entry *binder_transaction_log_add(
+       struct binder_transaction_log *log)
+{
+       struct binder_transaction_log_entry *e;
+
+       e = &log->entry[log->next];
+       memset(e, 0, sizeof(*e));
+       log->next++;
+       if (log->next == ARRAY_SIZE(log->entry)) {
+               log->next = 0;
+               log->full = 1;
+       }
+       return e;
+}
+
+struct binder_work {
+       struct list_head entry;
+       enum {
+               BINDER_WORK_TRANSACTION = 1,
+               BINDER_WORK_TRANSACTION_COMPLETE,
+               BINDER_WORK_NODE,
+               BINDER_WORK_DEAD_BINDER,
+               BINDER_WORK_DEAD_BINDER_AND_CLEAR,
+               BINDER_WORK_CLEAR_DEATH_NOTIFICATION,
+       } type;
+};
+
+struct binder_node {
+       int debug_id;
+       struct binder_work work;
+       union {
+               struct rb_node rb_node;
+               struct hlist_node dead_node;
+       };
+       struct binder_proc *proc;
+       struct hlist_head refs;
+       int internal_strong_refs;
+       int local_weak_refs;
+       int local_strong_refs;
+       binder_uintptr_t ptr;
+       binder_uintptr_t cookie;
+       unsigned has_strong_ref:1;
+       unsigned pending_strong_ref:1;
+       unsigned has_weak_ref:1;
+       unsigned pending_weak_ref:1;
+       unsigned has_async_transaction:1;
+       unsigned accept_fds:1;
+       unsigned min_priority:8;
+       struct list_head async_todo;
+};
+
+struct binder_ref_death {
+       struct binder_work work;
+       binder_uintptr_t cookie;
+};
+
+struct binder_ref {
+       /* Lookups needed: */
+       /*   node + proc => ref (transaction) */
+       /*   desc + proc => ref (transaction, inc/dec ref) */
+       /*   node => refs + procs (proc exit) */
+       int debug_id;
+       struct rb_node rb_node_desc;
+       struct rb_node rb_node_node;
+       struct hlist_node node_entry;
+       struct binder_proc *proc;
+       struct binder_node *node;
+       uint32_t desc;
+       int strong;
+       int weak;
+       struct binder_ref_death *death;
+};
+
+struct binder_buffer {
+       struct list_head entry; /* free and allocated entries by address */
+       struct rb_node rb_node; /* free entry by size or allocated entry */
+                               /* by address */
+       unsigned free:1;
+       unsigned allow_user_free:1;
+       unsigned async_transaction:1;
+       unsigned debug_id:29;
+
+       struct binder_transaction *transaction;
+
+       struct binder_node *target_node;
+       size_t data_size;
+       size_t offsets_size;
+       uint8_t data[0];
+};
+
+enum binder_deferred_state {
+       BINDER_DEFERRED_PUT_FILES    = 0x01,
+       BINDER_DEFERRED_FLUSH        = 0x02,
+       BINDER_DEFERRED_RELEASE      = 0x04,
+};
+
+struct binder_proc {
+       struct hlist_node proc_node;
+       struct rb_root threads;
+       struct rb_root nodes;
+       struct rb_root refs_by_desc;
+       struct rb_root refs_by_node;
+       int pid;
+       struct vm_area_struct *vma;
+       struct mm_struct *vma_vm_mm;
+       struct task_struct *tsk;
+       struct files_struct *files;
+       struct hlist_node deferred_work_node;
+       int deferred_work;
+       void *buffer;
+       ptrdiff_t user_buffer_offset;
+
+       struct list_head buffers;
+       struct rb_root free_buffers;
+       struct rb_root allocated_buffers;
+       size_t free_async_space;
+
+       struct page **pages;
+       size_t buffer_size;
+       uint32_t buffer_free;
+       struct list_head todo;
+       wait_queue_head_t wait;
+       struct binder_stats stats;
+       struct list_head delivered_death;
+       int max_threads;
+       int requested_threads;
+       int requested_threads_started;
+       int ready_threads;
+       long default_priority;
+       struct dentry *debugfs_entry;
+};
+
+enum {
+       BINDER_LOOPER_STATE_REGISTERED  = 0x01,
+       BINDER_LOOPER_STATE_ENTERED     = 0x02,
+       BINDER_LOOPER_STATE_EXITED      = 0x04,
+       BINDER_LOOPER_STATE_INVALID     = 0x08,
+       BINDER_LOOPER_STATE_WAITING     = 0x10,
+       BINDER_LOOPER_STATE_NEED_RETURN = 0x20
+};
+
+struct binder_thread {
+       struct binder_proc *proc;
+       struct rb_node rb_node;
+       int pid;
+       int looper;
+       struct binder_transaction *transaction_stack;
+       struct list_head todo;
+       uint32_t return_error; /* Write failed, return error code in read buf */
+       uint32_t return_error2; /* Write failed, return error code in read */
+               /* buffer. Used when sending a reply to a dead process that */
+               /* we are also waiting on */
+       wait_queue_head_t wait;
+       struct binder_stats stats;
+};
+
+struct binder_transaction {
+       int debug_id;
+       struct binder_work work;
+       struct binder_thread *from;
+       struct binder_transaction *from_parent;
+       struct binder_proc *to_proc;
+       struct binder_thread *to_thread;
+       struct binder_transaction *to_parent;
+       unsigned need_reply:1;
+       /* unsigned is_dead:1; */       /* not used at the moment */
+
+       struct binder_buffer *buffer;
+       unsigned int    code;
+       unsigned int    flags;
+       long    priority;
+       long    saved_priority;
+       kuid_t  sender_euid;
+};
+
+static void
+binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer);
+
+static int task_get_unused_fd_flags(struct binder_proc *proc, int flags)
+{
+       struct files_struct *files = proc->files;
+       unsigned long rlim_cur;
+       unsigned long irqs;
+
+       if (files == NULL)
+               return -ESRCH;
+
+       if (!lock_task_sighand(proc->tsk, &irqs))
+               return -EMFILE;
+
+       rlim_cur = task_rlimit(proc->tsk, RLIMIT_NOFILE);
+       unlock_task_sighand(proc->tsk, &irqs);
+
+       return __alloc_fd(files, 0, rlim_cur, flags);
+}
+
+/*
+ * copied from fd_install
+ */
+static void task_fd_install(
+       struct binder_proc *proc, unsigned int fd, struct file *file)
+{
+       if (proc->files)
+               __fd_install(proc->files, fd, file);
+}
+
+/*
+ * copied from sys_close
+ */
+static long task_close_fd(struct binder_proc *proc, unsigned int fd)
+{
+       int retval;
+
+       if (proc->files == NULL)
+               return -ESRCH;
+
+       retval = __close_fd(proc->files, fd);
+       /* can't restart close syscall because file table entry was cleared */
+       if (unlikely(retval == -ERESTARTSYS ||
+                    retval == -ERESTARTNOINTR ||
+                    retval == -ERESTARTNOHAND ||
+                    retval == -ERESTART_RESTARTBLOCK))
+               retval = -EINTR;
+
+       return retval;
+}
+
+static inline void binder_lock(const char *tag)
+{
+       trace_binder_lock(tag);
+       mutex_lock(&binder_main_lock);
+       trace_binder_locked(tag);
+}
+
+static inline void binder_unlock(const char *tag)
+{
+       trace_binder_unlock(tag);
+       mutex_unlock(&binder_main_lock);
+}
+
+static void binder_set_nice(long nice)
+{
+       long min_nice;
+
+       if (can_nice(current, nice)) {
+               set_user_nice(current, nice);
+               return;
+       }
+       min_nice = rlimit_to_nice(current->signal->rlim[RLIMIT_NICE].rlim_cur);
+       binder_debug(BINDER_DEBUG_PRIORITY_CAP,
+                    "%d: nice value %ld not allowed use %ld instead\n",
+                     current->pid, nice, min_nice);
+       set_user_nice(current, min_nice);
+       if (min_nice <= MAX_NICE)
+               return;
+       binder_user_error("%d RLIMIT_NICE not set\n", current->pid);
+}
+
+static size_t binder_buffer_size(struct binder_proc *proc,
+                                struct binder_buffer *buffer)
+{
+       if (list_is_last(&buffer->entry, &proc->buffers))
+               return proc->buffer + proc->buffer_size - (void *)buffer->data;
+       return (size_t)list_entry(buffer->entry.next,
+                         struct binder_buffer, entry) - (size_t)buffer->data;
+}
+
+static void binder_insert_free_buffer(struct binder_proc *proc,
+                                     struct binder_buffer *new_buffer)
+{
+       struct rb_node **p = &proc->free_buffers.rb_node;
+       struct rb_node *parent = NULL;
+       struct binder_buffer *buffer;
+       size_t buffer_size;
+       size_t new_buffer_size;
+
+       BUG_ON(!new_buffer->free);
+
+       new_buffer_size = binder_buffer_size(proc, new_buffer);
+
+       binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+                    "%d: add free buffer, size %zd, at %p\n",
+                     proc->pid, new_buffer_size, new_buffer);
+
+       while (*p) {
+               parent = *p;
+               buffer = rb_entry(parent, struct binder_buffer, rb_node);
+               BUG_ON(!buffer->free);
+
+               buffer_size = binder_buffer_size(proc, buffer);
+
+               if (new_buffer_size < buffer_size)
+                       p = &parent->rb_left;
+               else
+                       p = &parent->rb_right;
+       }
+       rb_link_node(&new_buffer->rb_node, parent, p);
+       rb_insert_color(&new_buffer->rb_node, &proc->free_buffers);
+}
+
+static void binder_insert_allocated_buffer(struct binder_proc *proc,
+                                          struct binder_buffer *new_buffer)
+{
+       struct rb_node **p = &proc->allocated_buffers.rb_node;
+       struct rb_node *parent = NULL;
+       struct binder_buffer *buffer;
+
+       BUG_ON(new_buffer->free);
+
+       while (*p) {
+               parent = *p;
+               buffer = rb_entry(parent, struct binder_buffer, rb_node);
+               BUG_ON(buffer->free);
+
+               if (new_buffer < buffer)
+                       p = &parent->rb_left;
+               else if (new_buffer > buffer)
+                       p = &parent->rb_right;
+               else
+                       BUG();
+       }
+       rb_link_node(&new_buffer->rb_node, parent, p);
+       rb_insert_color(&new_buffer->rb_node, &proc->allocated_buffers);
+}
+
+static struct binder_buffer *binder_buffer_lookup(struct binder_proc *proc,
+                                                 uintptr_t user_ptr)
+{
+       struct rb_node *n = proc->allocated_buffers.rb_node;
+       struct binder_buffer *buffer;
+       struct binder_buffer *kern_ptr;
+
+       kern_ptr = (struct binder_buffer *)(user_ptr - proc->user_buffer_offset
+               - offsetof(struct binder_buffer, data));
+
+       while (n) {
+               buffer = rb_entry(n, struct binder_buffer, rb_node);
+               BUG_ON(buffer->free);
+
+               if (kern_ptr < buffer)
+                       n = n->rb_left;
+               else if (kern_ptr > buffer)
+                       n = n->rb_right;
+               else
+                       return buffer;
+       }
+       return NULL;
+}
+
+static int binder_update_page_range(struct binder_proc *proc, int allocate,
+                                   void *start, void *end,
+                                   struct vm_area_struct *vma)
+{
+       void *page_addr;
+       unsigned long user_page_addr;
+       struct vm_struct tmp_area;
+       struct page **page;
+       struct mm_struct *mm;
+
+       binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+                    "%d: %s pages %p-%p\n", proc->pid,
+                    allocate ? "allocate" : "free", start, end);
+
+       if (end <= start)
+               return 0;
+
+       trace_binder_update_page_range(proc, allocate, start, end);
+
+       if (vma)
+               mm = NULL;
+       else
+               mm = get_task_mm(proc->tsk);
+
+       if (mm) {
+               down_write(&mm->mmap_sem);
+               vma = proc->vma;
+               if (vma && mm != proc->vma_vm_mm) {
+                       pr_err("%d: vma mm and task mm mismatch\n",
+                               proc->pid);
+                       vma = NULL;
+               }
+       }
+
+       if (allocate == 0)
+               goto free_range;
+
+       if (vma == NULL) {
+               pr_err("%d: binder_alloc_buf failed to map pages in userspace, no vma\n",
+                       proc->pid);
+               goto err_no_vma;
+       }
+
+       for (page_addr = start; page_addr < end; page_addr += PAGE_SIZE) {
+               int ret;
+
+               page = &proc->pages[(page_addr - proc->buffer) / PAGE_SIZE];
+
+               BUG_ON(*page);
+               *page = alloc_page(GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO);
+               if (*page == NULL) {
+                       pr_err("%d: binder_alloc_buf failed for page at %p\n",
+                               proc->pid, page_addr);
+                       goto err_alloc_page_failed;
+               }
+               tmp_area.addr = page_addr;
+               tmp_area.size = PAGE_SIZE + PAGE_SIZE /* guard page? */;
+               ret = map_vm_area(&tmp_area, PAGE_KERNEL, page);
+               if (ret) {
+                       pr_err("%d: binder_alloc_buf failed to map page at %p in kernel\n",
+                              proc->pid, page_addr);
+                       goto err_map_kernel_failed;
+               }
+               user_page_addr =
+                       (uintptr_t)page_addr + proc->user_buffer_offset;
+               ret = vm_insert_page(vma, user_page_addr, page[0]);
+               if (ret) {
+                       pr_err("%d: binder_alloc_buf failed to map page at %lx in userspace\n",
+                              proc->pid, user_page_addr);
+                       goto err_vm_insert_page_failed;
+               }
+               /* vm_insert_page does not seem to increment the refcount */
+       }
+       if (mm) {
+               up_write(&mm->mmap_sem);
+               mmput(mm);
+       }
+       return 0;
+
+free_range:
+       for (page_addr = end - PAGE_SIZE; page_addr >= start;
+            page_addr -= PAGE_SIZE) {
+               page = &proc->pages[(page_addr - proc->buffer) / PAGE_SIZE];
+               if (vma)
+                       zap_page_range(vma, (uintptr_t)page_addr +
+                               proc->user_buffer_offset, PAGE_SIZE, NULL);
+err_vm_insert_page_failed:
+               unmap_kernel_range((unsigned long)page_addr, PAGE_SIZE);
+err_map_kernel_failed:
+               __free_page(*page);
+               *page = NULL;
+err_alloc_page_failed:
+               ;
+       }
+err_no_vma:
+       if (mm) {
+               up_write(&mm->mmap_sem);
+               mmput(mm);
+       }
+       return -ENOMEM;
+}
+
+static struct binder_buffer *binder_alloc_buf(struct binder_proc *proc,
+                                             size_t data_size,
+                                             size_t offsets_size, int is_async)
+{
+       struct rb_node *n = proc->free_buffers.rb_node;
+       struct binder_buffer *buffer;
+       size_t buffer_size;
+       struct rb_node *best_fit = NULL;
+       void *has_page_addr;
+       void *end_page_addr;
+       size_t size;
+
+       if (proc->vma == NULL) {
+               pr_err("%d: binder_alloc_buf, no vma\n",
+                      proc->pid);
+               return NULL;
+       }
+
+       size = ALIGN(data_size, sizeof(void *)) +
+               ALIGN(offsets_size, sizeof(void *));
+
+       if (size < data_size || size < offsets_size) {
+               binder_user_error("%d: got transaction with invalid size %zd-%zd\n",
+                               proc->pid, data_size, offsets_size);
+               return NULL;
+       }
+
+       if (is_async &&
+           proc->free_async_space < size + sizeof(struct binder_buffer)) {
+               binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+                            "%d: binder_alloc_buf size %zd failed, no async space left\n",
+                             proc->pid, size);
+               return NULL;
+       }
+
+       while (n) {
+               buffer = rb_entry(n, struct binder_buffer, rb_node);
+               BUG_ON(!buffer->free);
+               buffer_size = binder_buffer_size(proc, buffer);
+
+               if (size < buffer_size) {
+                       best_fit = n;
+                       n = n->rb_left;
+               } else if (size > buffer_size)
+                       n = n->rb_right;
+               else {
+                       best_fit = n;
+                       break;
+               }
+       }
+       if (best_fit == NULL) {
+               pr_err("%d: binder_alloc_buf size %zd failed, no address space\n",
+                       proc->pid, size);
+               return NULL;
+       }
+       if (n == NULL) {
+               buffer = rb_entry(best_fit, struct binder_buffer, rb_node);
+               buffer_size = binder_buffer_size(proc, buffer);
+       }
+
+       binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+                    "%d: binder_alloc_buf size %zd got buffer %p size %zd\n",
+                     proc->pid, size, buffer, buffer_size);
+
+       has_page_addr =
+               (void *)(((uintptr_t)buffer->data + buffer_size) & PAGE_MASK);
+       if (n == NULL) {
+               if (size + sizeof(struct binder_buffer) + 4 >= buffer_size)
+                       buffer_size = size; /* no room for other buffers */
+               else
+                       buffer_size = size + sizeof(struct binder_buffer);
+       }
+       end_page_addr =
+               (void *)PAGE_ALIGN((uintptr_t)buffer->data + buffer_size);
+       if (end_page_addr > has_page_addr)
+               end_page_addr = has_page_addr;
+       if (binder_update_page_range(proc, 1,
+           (void *)PAGE_ALIGN((uintptr_t)buffer->data), end_page_addr, NULL))
+               return NULL;
+
+       rb_erase(best_fit, &proc->free_buffers);
+       buffer->free = 0;
+       binder_insert_allocated_buffer(proc, buffer);
+       if (buffer_size != size) {
+               struct binder_buffer *new_buffer = (void *)buffer->data + size;
+
+               list_add(&new_buffer->entry, &buffer->entry);
+               new_buffer->free = 1;
+               binder_insert_free_buffer(proc, new_buffer);
+       }
+       binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+                    "%d: binder_alloc_buf size %zd got %p\n",
+                     proc->pid, size, buffer);
+       buffer->data_size = data_size;
+       buffer->offsets_size = offsets_size;
+       buffer->async_transaction = is_async;
+       if (is_async) {
+               proc->free_async_space -= size + sizeof(struct binder_buffer);
+               binder_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC,
+                            "%d: binder_alloc_buf size %zd async free %zd\n",
+                             proc->pid, size, proc->free_async_space);
+       }
+
+       return buffer;
+}
+
+static void *buffer_start_page(struct binder_buffer *buffer)
+{
+       return (void *)((uintptr_t)buffer & PAGE_MASK);
+}
+
+static void *buffer_end_page(struct binder_buffer *buffer)
+{
+       return (void *)(((uintptr_t)(buffer + 1) - 1) & PAGE_MASK);
+}
+
+static void binder_delete_free_buffer(struct binder_proc *proc,
+                                     struct binder_buffer *buffer)
+{
+       struct binder_buffer *prev, *next = NULL;
+       int free_page_end = 1;
+       int free_page_start = 1;
+
+       BUG_ON(proc->buffers.next == &buffer->entry);
+       prev = list_entry(buffer->entry.prev, struct binder_buffer, entry);
+       BUG_ON(!prev->free);
+       if (buffer_end_page(prev) == buffer_start_page(buffer)) {
+               free_page_start = 0;
+               if (buffer_end_page(prev) == buffer_end_page(buffer))
+                       free_page_end = 0;
+               binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+                            "%d: merge free, buffer %p share page with %p\n",
+                             proc->pid, buffer, prev);
+       }
+
+       if (!list_is_last(&buffer->entry, &proc->buffers)) {
+               next = list_entry(buffer->entry.next,
+                                 struct binder_buffer, entry);
+               if (buffer_start_page(next) == buffer_end_page(buffer)) {
+                       free_page_end = 0;
+                       if (buffer_start_page(next) ==
+                           buffer_start_page(buffer))
+                               free_page_start = 0;
+                       binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+                                    "%d: merge free, buffer %p share page with %p\n",
+                                     proc->pid, buffer, prev);
+               }
+       }
+       list_del(&buffer->entry);
+       if (free_page_start || free_page_end) {
+               binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+                            "%d: merge free, buffer %p do not share page%s%s with %p or %p\n",
+                            proc->pid, buffer, free_page_start ? "" : " end",
+                            free_page_end ? "" : " start", prev, next);
+               binder_update_page_range(proc, 0, free_page_start ?
+                       buffer_start_page(buffer) : buffer_end_page(buffer),
+                       (free_page_end ? buffer_end_page(buffer) :
+                       buffer_start_page(buffer)) + PAGE_SIZE, NULL);
+       }
+}
+
+static void binder_free_buf(struct binder_proc *proc,
+                           struct binder_buffer *buffer)
+{
+       size_t size, buffer_size;
+
+       buffer_size = binder_buffer_size(proc, buffer);
+
+       size = ALIGN(buffer->data_size, sizeof(void *)) +
+               ALIGN(buffer->offsets_size, sizeof(void *));
+
+       binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+                    "%d: binder_free_buf %p size %zd buffer_size %zd\n",
+                     proc->pid, buffer, size, buffer_size);
+
+       BUG_ON(buffer->free);
+       BUG_ON(size > buffer_size);
+       BUG_ON(buffer->transaction != NULL);
+       BUG_ON((void *)buffer < proc->buffer);
+       BUG_ON((void *)buffer > proc->buffer + proc->buffer_size);
+
+       if (buffer->async_transaction) {
+               proc->free_async_space += size + sizeof(struct binder_buffer);
+
+               binder_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC,
+                            "%d: binder_free_buf size %zd async free %zd\n",
+                             proc->pid, size, proc->free_async_space);
+       }
+
+       binder_update_page_range(proc, 0,
+               (void *)PAGE_ALIGN((uintptr_t)buffer->data),
+               (void *)(((uintptr_t)buffer->data + buffer_size) & PAGE_MASK),
+               NULL);
+       rb_erase(&buffer->rb_node, &proc->allocated_buffers);
+       buffer->free = 1;
+       if (!list_is_last(&buffer->entry, &proc->buffers)) {
+               struct binder_buffer *next = list_entry(buffer->entry.next,
+                                               struct binder_buffer, entry);
+
+               if (next->free) {
+                       rb_erase(&next->rb_node, &proc->free_buffers);
+                       binder_delete_free_buffer(proc, next);
+               }
+       }
+       if (proc->buffers.next != &buffer->entry) {
+               struct binder_buffer *prev = list_entry(buffer->entry.prev,
+                                               struct binder_buffer, entry);
+
+               if (prev->free) {
+                       binder_delete_free_buffer(proc, buffer);
+                       rb_erase(&prev->rb_node, &proc->free_buffers);
+                       buffer = prev;
+               }
+       }
+       binder_insert_free_buffer(proc, buffer);
+}
+
+static struct binder_node *binder_get_node(struct binder_proc *proc,
+                                          binder_uintptr_t ptr)
+{
+       struct rb_node *n = proc->nodes.rb_node;
+       struct binder_node *node;
+
+       while (n) {
+               node = rb_entry(n, struct binder_node, rb_node);
+
+               if (ptr < node->ptr)
+                       n = n->rb_left;
+               else if (ptr > node->ptr)
+                       n = n->rb_right;
+               else
+                       return node;
+       }
+       return NULL;
+}
+
+static struct binder_node *binder_new_node(struct binder_proc *proc,
+                                          binder_uintptr_t ptr,
+                                          binder_uintptr_t cookie)
+{
+       struct rb_node **p = &proc->nodes.rb_node;
+       struct rb_node *parent = NULL;
+       struct binder_node *node;
+
+       while (*p) {
+               parent = *p;
+               node = rb_entry(parent, struct binder_node, rb_node);
+
+               if (ptr < node->ptr)
+                       p = &(*p)->rb_left;
+               else if (ptr > node->ptr)
+                       p = &(*p)->rb_right;
+               else
+                       return NULL;
+       }
+
+       node = kzalloc(sizeof(*node), GFP_KERNEL);
+       if (node == NULL)
+               return NULL;
+       binder_stats_created(BINDER_STAT_NODE);
+       rb_link_node(&node->rb_node, parent, p);
+       rb_insert_color(&node->rb_node, &proc->nodes);
+       node->debug_id = ++binder_last_id;
+       node->proc = proc;
+       node->ptr = ptr;
+       node->cookie = cookie;
+       node->work.type = BINDER_WORK_NODE;
+       INIT_LIST_HEAD(&node->work.entry);
+       INIT_LIST_HEAD(&node->async_todo);
+       binder_debug(BINDER_DEBUG_INTERNAL_REFS,
+                    "%d:%d node %d u%016llx c%016llx created\n",
+                    proc->pid, current->pid, node->debug_id,
+                    (u64)node->ptr, (u64)node->cookie);
+       return node;
+}
+
+static int binder_inc_node(struct binder_node *node, int strong, int internal,
+                          struct list_head *target_list)
+{
+       if (strong) {
+               if (internal) {
+                       if (target_list == NULL &&
+                           node->internal_strong_refs == 0 &&
+                           !(node == binder_context_mgr_node &&
+                           node->has_strong_ref)) {
+                               pr_err("invalid inc strong node for %d\n",
+                                       node->debug_id);
+                               return -EINVAL;
+                       }
+                       node->internal_strong_refs++;
+               } else
+                       node->local_strong_refs++;
+               if (!node->has_strong_ref && target_list) {
+                       list_del_init(&node->work.entry);
+                       list_add_tail(&node->work.entry, target_list);
+               }
+       } else {
+               if (!internal)
+                       node->local_weak_refs++;
+               if (!node->has_weak_ref && list_empty(&node->work.entry)) {
+                       if (target_list == NULL) {
+                               pr_err("invalid inc weak node for %d\n",
+                                       node->debug_id);
+                               return -EINVAL;
+                       }
+                       list_add_tail(&node->work.entry, target_list);
+               }
+       }
+       return 0;
+}
+
+static int binder_dec_node(struct binder_node *node, int strong, int internal)
+{
+       if (strong) {
+               if (internal)
+                       node->internal_strong_refs--;
+               else
+                       node->local_strong_refs--;
+               if (node->local_strong_refs || node->internal_strong_refs)
+                       return 0;
+       } else {
+               if (!internal)
+                       node->local_weak_refs--;
+               if (node->local_weak_refs || !hlist_empty(&node->refs))
+                       return 0;
+       }
+       if (node->proc && (node->has_strong_ref || node->has_weak_ref)) {
+               if (list_empty(&node->work.entry)) {
+                       list_add_tail(&node->work.entry, &node->proc->todo);
+                       wake_up_interruptible(&node->proc->wait);
+               }
+       } else {
+               if (hlist_empty(&node->refs) && !node->local_strong_refs &&
+                   !node->local_weak_refs) {
+                       list_del_init(&node->work.entry);
+                       if (node->proc) {
+                               rb_erase(&node->rb_node, &node->proc->nodes);
+                               binder_debug(BINDER_DEBUG_INTERNAL_REFS,
+                                            "refless node %d deleted\n",
+                                            node->debug_id);
+                       } else {
+                               hlist_del(&node->dead_node);
+                               binder_debug(BINDER_DEBUG_INTERNAL_REFS,
+                                            "dead node %d deleted\n",
+                                            node->debug_id);
+                       }
+                       kfree(node);
+                       binder_stats_deleted(BINDER_STAT_NODE);
+               }
+       }
+
+       return 0;
+}
+
+
+static struct binder_ref *binder_get_ref(struct binder_proc *proc,
+                                        uint32_t desc)
+{
+       struct rb_node *n = proc->refs_by_desc.rb_node;
+       struct binder_ref *ref;
+
+       while (n) {
+               ref = rb_entry(n, struct binder_ref, rb_node_desc);
+
+               if (desc < ref->desc)
+                       n = n->rb_left;
+               else if (desc > ref->desc)
+                       n = n->rb_right;
+               else
+                       return ref;
+       }
+       return NULL;
+}
+
+static struct binder_ref *binder_get_ref_for_node(struct binder_proc *proc,
+                                                 struct binder_node *node)
+{
+       struct rb_node *n;
+       struct rb_node **p = &proc->refs_by_node.rb_node;
+       struct rb_node *parent = NULL;
+       struct binder_ref *ref, *new_ref;
+
+       while (*p) {
+               parent = *p;
+               ref = rb_entry(parent, struct binder_ref, rb_node_node);
+
+               if (node < ref->node)
+                       p = &(*p)->rb_left;
+               else if (node > ref->node)
+                       p = &(*p)->rb_right;
+               else
+                       return ref;
+       }
+       new_ref = kzalloc(sizeof(*ref), GFP_KERNEL);
+       if (new_ref == NULL)
+               return NULL;
+       binder_stats_created(BINDER_STAT_REF);
+       new_ref->debug_id = ++binder_last_id;
+       new_ref->proc = proc;
+       new_ref->node = node;
+       rb_link_node(&new_ref->rb_node_node, parent, p);
+       rb_insert_color(&new_ref->rb_node_node, &proc->refs_by_node);
+
+       new_ref->desc = (node == binder_context_mgr_node) ? 0 : 1;
+       for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) {
+               ref = rb_entry(n, struct binder_ref, rb_node_desc);
+               if (ref->desc > new_ref->desc)
+                       break;
+               new_ref->desc = ref->desc + 1;
+       }
+
+       p = &proc->refs_by_desc.rb_node;
+       while (*p) {
+               parent = *p;
+               ref = rb_entry(parent, struct binder_ref, rb_node_desc);
+
+               if (new_ref->desc < ref->desc)
+                       p = &(*p)->rb_left;
+               else if (new_ref->desc > ref->desc)
+                       p = &(*p)->rb_right;
+               else
+                       BUG();
+       }
+       rb_link_node(&new_ref->rb_node_desc, parent, p);
+       rb_insert_color(&new_ref->rb_node_desc, &proc->refs_by_desc);
+       if (node) {
+               hlist_add_head(&new_ref->node_entry, &node->refs);
+
+               binder_debug(BINDER_DEBUG_INTERNAL_REFS,
+                            "%d new ref %d desc %d for node %d\n",
+                             proc->pid, new_ref->debug_id, new_ref->desc,
+                             node->debug_id);
+       } else {
+               binder_debug(BINDER_DEBUG_INTERNAL_REFS,
+                            "%d new ref %d desc %d for dead node\n",
+                             proc->pid, new_ref->debug_id, new_ref->desc);
+       }
+       return new_ref;
+}
+
+static void binder_delete_ref(struct binder_ref *ref)
+{
+       binder_debug(BINDER_DEBUG_INTERNAL_REFS,
+                    "%d delete ref %d desc %d for node %d\n",
+                     ref->proc->pid, ref->debug_id, ref->desc,
+                     ref->node->debug_id);
+
+       rb_erase(&ref->rb_node_desc, &ref->proc->refs_by_desc);
+       rb_erase(&ref->rb_node_node, &ref->proc->refs_by_node);
+       if (ref->strong)
+               binder_dec_node(ref->node, 1, 1);
+       hlist_del(&ref->node_entry);
+       binder_dec_node(ref->node, 0, 1);
+       if (ref->death) {
+               binder_debug(BINDER_DEBUG_DEAD_BINDER,
+                            "%d delete ref %d desc %d has death notification\n",
+                             ref->proc->pid, ref->debug_id, ref->desc);
+               list_del(&ref->death->work.entry);
+               kfree(ref->death);
+               binder_stats_deleted(BINDER_STAT_DEATH);
+       }
+       kfree(ref);
+       binder_stats_deleted(BINDER_STAT_REF);
+}
+
+static int binder_inc_ref(struct binder_ref *ref, int strong,
+                         struct list_head *target_list)
+{
+       int ret;
+
+       if (strong) {
+               if (ref->strong == 0) {
+                       ret = binder_inc_node(ref->node, 1, 1, target_list);
+                       if (ret)
+                               return ret;
+               }
+               ref->strong++;
+       } else {
+               if (ref->weak == 0) {
+                       ret = binder_inc_node(ref->node, 0, 1, target_list);
+                       if (ret)
+                               return ret;
+               }
+               ref->weak++;
+       }
+       return 0;
+}
+
+
+static int binder_dec_ref(struct binder_ref *ref, int strong)
+{
+       if (strong) {
+               if (ref->strong == 0) {
+                       binder_user_error("%d invalid dec strong, ref %d desc %d s %d w %d\n",
+                                         ref->proc->pid, ref->debug_id,
+                                         ref->desc, ref->strong, ref->weak);
+                       return -EINVAL;
+               }
+               ref->strong--;
+               if (ref->strong == 0) {
+                       int ret;
+
+                       ret = binder_dec_node(ref->node, strong, 1);
+                       if (ret)
+                               return ret;
+               }
+       } else {
+               if (ref->weak == 0) {
+                       binder_user_error("%d invalid dec weak, ref %d desc %d s %d w %d\n",
+                                         ref->proc->pid, ref->debug_id,
+                                         ref->desc, ref->strong, ref->weak);
+                       return -EINVAL;
+               }
+               ref->weak--;
+       }
+       if (ref->strong == 0 && ref->weak == 0)
+               binder_delete_ref(ref);
+       return 0;
+}
+
+static void binder_pop_transaction(struct binder_thread *target_thread,
+                                  struct binder_transaction *t)
+{
+       if (target_thread) {
+               BUG_ON(target_thread->transaction_stack != t);
+               BUG_ON(target_thread->transaction_stack->from != target_thread);
+               target_thread->transaction_stack =
+                       target_thread->transaction_stack->from_parent;
+               t->from = NULL;
+       }
+       t->need_reply = 0;
+       if (t->buffer)
+               t->buffer->transaction = NULL;
+       kfree(t);
+       binder_stats_deleted(BINDER_STAT_TRANSACTION);
+}
+
+static void binder_send_failed_reply(struct binder_transaction *t,
+                                    uint32_t error_code)
+{
+       struct binder_thread *target_thread;
+       struct binder_transaction *next;
+
+       BUG_ON(t->flags & TF_ONE_WAY);
+       while (1) {
+               target_thread = t->from;
+               if (target_thread) {
+                       if (target_thread->return_error != BR_OK &&
+                          target_thread->return_error2 == BR_OK) {
+                               target_thread->return_error2 =
+                                       target_thread->return_error;
+                               target_thread->return_error = BR_OK;
+                       }
+                       if (target_thread->return_error == BR_OK) {
+                               binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
+                                            "send failed reply for transaction %d to %d:%d\n",
+                                             t->debug_id,
+                                             target_thread->proc->pid,
+                                             target_thread->pid);
+
+                               binder_pop_transaction(target_thread, t);
+                               target_thread->return_error = error_code;
+                               wake_up_interruptible(&target_thread->wait);
+                       } else {
+                               pr_err("reply failed, target thread, %d:%d, has error code %d already\n",
+                                       target_thread->proc->pid,
+                                       target_thread->pid,
+                                       target_thread->return_error);
+                       }
+                       return;
+               }
+               next = t->from_parent;
+
+               binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
+                            "send failed reply for transaction %d, target dead\n",
+                            t->debug_id);
+
+               binder_pop_transaction(target_thread, t);
+               if (next == NULL) {
+                       binder_debug(BINDER_DEBUG_DEAD_BINDER,
+                                    "reply failed, no target thread at root\n");
+                       return;
+               }
+               t = next;
+               binder_debug(BINDER_DEBUG_DEAD_BINDER,
+                            "reply failed, no target thread -- retry %d\n",
+                             t->debug_id);
+       }
+}
+
+static void binder_transaction_buffer_release(struct binder_proc *proc,
+                                             struct binder_buffer *buffer,
+                                             binder_size_t *failed_at)
+{
+       binder_size_t *offp, *off_end;
+       int debug_id = buffer->debug_id;
+
+       binder_debug(BINDER_DEBUG_TRANSACTION,
+                    "%d buffer release %d, size %zd-%zd, failed at %p\n",
+                    proc->pid, buffer->debug_id,
+                    buffer->data_size, buffer->offsets_size, failed_at);
+
+       if (buffer->target_node)
+               binder_dec_node(buffer->target_node, 1, 0);
+
+       offp = (binder_size_t *)(buffer->data +
+                                ALIGN(buffer->data_size, sizeof(void *)));
+       if (failed_at)
+               off_end = failed_at;
+       else
+               off_end = (void *)offp + buffer->offsets_size;
+       for (; offp < off_end; offp++) {
+               struct flat_binder_object *fp;
+
+               if (*offp > buffer->data_size - sizeof(*fp) ||
+                   buffer->data_size < sizeof(*fp) ||
+                   !IS_ALIGNED(*offp, sizeof(u32))) {
+                       pr_err("transaction release %d bad offset %lld, size %zd\n",
+                              debug_id, (u64)*offp, buffer->data_size);
+                       continue;
+               }
+               fp = (struct flat_binder_object *)(buffer->data + *offp);
+               switch (fp->type) {
+               case BINDER_TYPE_BINDER:
+               case BINDER_TYPE_WEAK_BINDER: {
+                       struct binder_node *node = binder_get_node(proc, fp->binder);
+
+                       if (node == NULL) {
+                               pr_err("transaction release %d bad node %016llx\n",
+                                      debug_id, (u64)fp->binder);
+                               break;
+                       }
+                       binder_debug(BINDER_DEBUG_TRANSACTION,
+                                    "        node %d u%016llx\n",
+                                    node->debug_id, (u64)node->ptr);
+                       binder_dec_node(node, fp->type == BINDER_TYPE_BINDER, 0);
+               } break;
+               case BINDER_TYPE_HANDLE:
+               case BINDER_TYPE_WEAK_HANDLE: {
+                       struct binder_ref *ref = binder_get_ref(proc, fp->handle);
+
+                       if (ref == NULL) {
+                               pr_err("transaction release %d bad handle %d\n",
+                                debug_id, fp->handle);
+                               break;
+                       }
+                       binder_debug(BINDER_DEBUG_TRANSACTION,
+                                    "        ref %d desc %d (node %d)\n",
+                                    ref->debug_id, ref->desc, ref->node->debug_id);
+                       binder_dec_ref(ref, fp->type == BINDER_TYPE_HANDLE);
+               } break;
+
+               case BINDER_TYPE_FD:
+                       binder_debug(BINDER_DEBUG_TRANSACTION,
+                                    "        fd %d\n", fp->handle);
+                       if (failed_at)
+                               task_close_fd(proc, fp->handle);
+                       break;
+
+               default:
+                       pr_err("transaction release %d bad object type %x\n",
+                               debug_id, fp->type);
+                       break;
+               }
+       }
+}
+
+static void binder_transaction(struct binder_proc *proc,
+                              struct binder_thread *thread,
+                              struct binder_transaction_data *tr, int reply)
+{
+       struct binder_transaction *t;
+       struct binder_work *tcomplete;
+       binder_size_t *offp, *off_end;
+       struct binder_proc *target_proc;
+       struct binder_thread *target_thread = NULL;
+       struct binder_node *target_node = NULL;
+       struct list_head *target_list;
+       wait_queue_head_t *target_wait;
+       struct binder_transaction *in_reply_to = NULL;
+       struct binder_transaction_log_entry *e;
+       uint32_t return_error;
+
+       e = binder_transaction_log_add(&binder_transaction_log);
+       e->call_type = reply ? 2 : !!(tr->flags & TF_ONE_WAY);
+       e->from_proc = proc->pid;
+       e->from_thread = thread->pid;
+       e->target_handle = tr->target.handle;
+       e->data_size = tr->data_size;
+       e->offsets_size = tr->offsets_size;
+
+       if (reply) {
+               in_reply_to = thread->transaction_stack;
+               if (in_reply_to == NULL) {
+                       binder_user_error("%d:%d got reply transaction with no transaction stack\n",
+                                         proc->pid, thread->pid);
+                       return_error = BR_FAILED_REPLY;
+                       goto err_empty_call_stack;
+               }
+               binder_set_nice(in_reply_to->saved_priority);
+               if (in_reply_to->to_thread != thread) {
+                       binder_user_error("%d:%d got reply transaction with bad transaction stack, transaction %d has target %d:%d\n",
+                               proc->pid, thread->pid, in_reply_to->debug_id,
+                               in_reply_to->to_proc ?
+                               in_reply_to->to_proc->pid : 0,
+                               in_reply_to->to_thread ?
+                               in_reply_to->to_thread->pid : 0);
+                       return_error = BR_FAILED_REPLY;
+                       in_reply_to = NULL;
+                       goto err_bad_call_stack;
+               }
+               thread->transaction_stack = in_reply_to->to_parent;
+               target_thread = in_reply_to->from;
+               if (target_thread == NULL) {
+                       return_error = BR_DEAD_REPLY;
+                       goto err_dead_binder;
+               }
+               if (target_thread->transaction_stack != in_reply_to) {
+                       binder_user_error("%d:%d got reply transaction with bad target transaction stack %d, expected %d\n",
+                               proc->pid, thread->pid,
+                               target_thread->transaction_stack ?
+                               target_thread->transaction_stack->debug_id : 0,
+                               in_reply_to->debug_id);
+                       return_error = BR_FAILED_REPLY;
+                       in_reply_to = NULL;
+                       target_thread = NULL;
+                       goto err_dead_binder;
+               }
+               target_proc = target_thread->proc;
+       } else {
+               if (tr->target.handle) {
+                       struct binder_ref *ref;
+
+                       ref = binder_get_ref(proc, tr->target.handle);
+                       if (ref == NULL) {
+                               binder_user_error("%d:%d got transaction to invalid handle\n",
+                                       proc->pid, thread->pid);
+                               return_error = BR_FAILED_REPLY;
+                               goto err_invalid_target_handle;
+                       }
+                       target_node = ref->node;
+               } else {
+                       target_node = binder_context_mgr_node;
+                       if (target_node == NULL) {
+                               return_error = BR_DEAD_REPLY;
+                               goto err_no_context_mgr_node;
+                       }
+               }
+               e->to_node = target_node->debug_id;
+               target_proc = target_node->proc;
+               if (target_proc == NULL) {
+                       return_error = BR_DEAD_REPLY;
+                       goto err_dead_binder;
+               }
+               if (!(tr->flags & TF_ONE_WAY) && thread->transaction_stack) {
+                       struct binder_transaction *tmp;
+
+                       tmp = thread->transaction_stack;
+                       if (tmp->to_thread != thread) {
+                               binder_user_error("%d:%d got new transaction with bad transaction stack, transaction %d has target %d:%d\n",
+                                       proc->pid, thread->pid, tmp->debug_id,
+                                       tmp->to_proc ? tmp->to_proc->pid : 0,
+                                       tmp->to_thread ?
+                                       tmp->to_thread->pid : 0);
+                               return_error = BR_FAILED_REPLY;
+                               goto err_bad_call_stack;
+                       }
+                       while (tmp) {
+                               if (tmp->from && tmp->from->proc == target_proc)
+                                       target_thread = tmp->from;
+                               tmp = tmp->from_parent;
+                       }
+               }
+       }
+       if (target_thread) {
+               e->to_thread = target_thread->pid;
+               target_list = &target_thread->todo;
+               target_wait = &target_thread->wait;
+       } else {
+               target_list = &target_proc->todo;
+               target_wait = &target_proc->wait;
+       }
+       e->to_proc = target_proc->pid;
+
+       /* TODO: reuse incoming transaction for reply */
+       t = kzalloc(sizeof(*t), GFP_KERNEL);
+       if (t == NULL) {
+               return_error = BR_FAILED_REPLY;
+               goto err_alloc_t_failed;
+       }
+       binder_stats_created(BINDER_STAT_TRANSACTION);
+
+       tcomplete = kzalloc(sizeof(*tcomplete), GFP_KERNEL);
+       if (tcomplete == NULL) {
+               return_error = BR_FAILED_REPLY;
+               goto err_alloc_tcomplete_failed;
+       }
+       binder_stats_created(BINDER_STAT_TRANSACTION_COMPLETE);
+
+       t->debug_id = ++binder_last_id;
+       e->debug_id = t->debug_id;
+
+       if (reply)
+               binder_debug(BINDER_DEBUG_TRANSACTION,
+                            "%d:%d BC_REPLY %d -> %d:%d, data %016llx-%016llx size %lld-%lld\n",
+                            proc->pid, thread->pid, t->debug_id,
+                            target_proc->pid, target_thread->pid,
+                            (u64)tr->data.ptr.buffer,
+                            (u64)tr->data.ptr.offsets,
+                            (u64)tr->data_size, (u64)tr->offsets_size);
+       else
+               binder_debug(BINDER_DEBUG_TRANSACTION,
+                            "%d:%d BC_TRANSACTION %d -> %d - node %d, data %016llx-%016llx size %lld-%lld\n",
+                            proc->pid, thread->pid, t->debug_id,
+                            target_proc->pid, target_node->debug_id,
+                            (u64)tr->data.ptr.buffer,
+                            (u64)tr->data.ptr.offsets,
+                            (u64)tr->data_size, (u64)tr->offsets_size);
+
+       if (!reply && !(tr->flags & TF_ONE_WAY))
+               t->from = thread;
+       else
+               t->from = NULL;
+       t->sender_euid = task_euid(proc->tsk);
+       t->to_proc = target_proc;
+       t->to_thread = target_thread;
+       t->code = tr->code;
+       t->flags = tr->flags;
+       t->priority = task_nice(current);
+
+       trace_binder_transaction(reply, t, target_node);
+
+       t->buffer = binder_alloc_buf(target_proc, tr->data_size,
+               tr->offsets_size, !reply && (t->flags & TF_ONE_WAY));
+       if (t->buffer == NULL) {
+               return_error = BR_FAILED_REPLY;
+               goto err_binder_alloc_buf_failed;
+       }
+       t->buffer->allow_user_free = 0;
+       t->buffer->debug_id = t->debug_id;
+       t->buffer->transaction = t;
+       t->buffer->target_node = target_node;
+       trace_binder_transaction_alloc_buf(t->buffer);
+       if (target_node)
+               binder_inc_node(target_node, 1, 0, NULL);
+
+       offp = (binder_size_t *)(t->buffer->data +
+                                ALIGN(tr->data_size, sizeof(void *)));
+
+       if (copy_from_user(t->buffer->data, (const void __user *)(uintptr_t)
+                          tr->data.ptr.buffer, tr->data_size)) {
+               binder_user_error("%d:%d got transaction with invalid data ptr\n",
+                               proc->pid, thread->pid);
+               return_error = BR_FAILED_REPLY;
+               goto err_copy_data_failed;
+       }
+       if (copy_from_user(offp, (const void __user *)(uintptr_t)
+                          tr->data.ptr.offsets, tr->offsets_size)) {
+               binder_user_error("%d:%d got transaction with invalid offsets ptr\n",
+                               proc->pid, thread->pid);
+               return_error = BR_FAILED_REPLY;
+               goto err_copy_data_failed;
+       }
+       if (!IS_ALIGNED(tr->offsets_size, sizeof(binder_size_t))) {
+               binder_user_error("%d:%d got transaction with invalid offsets size, %lld\n",
+                               proc->pid, thread->pid, (u64)tr->offsets_size);
+               return_error = BR_FAILED_REPLY;
+               goto err_bad_offset;
+       }
+       off_end = (void *)offp + tr->offsets_size;
+       for (; offp < off_end; offp++) {
+               struct flat_binder_object *fp;
+
+               if (*offp > t->buffer->data_size - sizeof(*fp) ||
+                   t->buffer->data_size < sizeof(*fp) ||
+                   !IS_ALIGNED(*offp, sizeof(u32))) {
+                       binder_user_error("%d:%d got transaction with invalid offset, %lld\n",
+                                         proc->pid, thread->pid, (u64)*offp);
+                       return_error = BR_FAILED_REPLY;
+                       goto err_bad_offset;
+               }
+               fp = (struct flat_binder_object *)(t->buffer->data + *offp);
+               switch (fp->type) {
+               case BINDER_TYPE_BINDER:
+               case BINDER_TYPE_WEAK_BINDER: {
+                       struct binder_ref *ref;
+                       struct binder_node *node = binder_get_node(proc, fp->binder);
+
+                       if (node == NULL) {
+                               node = binder_new_node(proc, fp->binder, fp->cookie);
+                               if (node == NULL) {
+                                       return_error = BR_FAILED_REPLY;
+                                       goto err_binder_new_node_failed;
+                               }
+                               node->min_priority = fp->flags & FLAT_BINDER_FLAG_PRIORITY_MASK;
+                               node->accept_fds = !!(fp->flags & FLAT_BINDER_FLAG_ACCEPTS_FDS);
+                       }
+                       if (fp->cookie != node->cookie) {
+                               binder_user_error("%d:%d sending u%016llx node %d, cookie mismatch %016llx != %016llx\n",
+                                       proc->pid, thread->pid,
+                                       (u64)fp->binder, node->debug_id,
+                                       (u64)fp->cookie, (u64)node->cookie);
+                               return_error = BR_FAILED_REPLY;
+                               goto err_binder_get_ref_for_node_failed;
+                       }
+                       ref = binder_get_ref_for_node(target_proc, node);
+                       if (ref == NULL) {
+                               return_error = BR_FAILED_REPLY;
+                               goto err_binder_get_ref_for_node_failed;
+                       }
+                       if (fp->type == BINDER_TYPE_BINDER)
+                               fp->type = BINDER_TYPE_HANDLE;
+                       else
+                               fp->type = BINDER_TYPE_WEAK_HANDLE;
+                       fp->handle = ref->desc;
+                       binder_inc_ref(ref, fp->type == BINDER_TYPE_HANDLE,
+                                      &thread->todo);
+
+                       trace_binder_transaction_node_to_ref(t, node, ref);
+                       binder_debug(BINDER_DEBUG_TRANSACTION,
+                                    "        node %d u%016llx -> ref %d desc %d\n",
+                                    node->debug_id, (u64)node->ptr,
+                                    ref->debug_id, ref->desc);
+               } break;
+               case BINDER_TYPE_HANDLE:
+               case BINDER_TYPE_WEAK_HANDLE: {
+                       struct binder_ref *ref = binder_get_ref(proc, fp->handle);
+
+                       if (ref == NULL) {
+                               binder_user_error("%d:%d got transaction with invalid handle, %d\n",
+                                               proc->pid,
+                                               thread->pid, fp->handle);
+                               return_error = BR_FAILED_REPLY;
+                               goto err_binder_get_ref_failed;
+                       }
+                       if (ref->node->proc == target_proc) {
+                               if (fp->type == BINDER_TYPE_HANDLE)
+                                       fp->type = BINDER_TYPE_BINDER;
+                               else
+                                       fp->type = BINDER_TYPE_WEAK_BINDER;
+                               fp->binder = ref->node->ptr;
+                               fp->cookie = ref->node->cookie;
+                               binder_inc_node(ref->node, fp->type == BINDER_TYPE_BINDER, 0, NULL);
+                               trace_binder_transaction_ref_to_node(t, ref);
+                               binder_debug(BINDER_DEBUG_TRANSACTION,
+                                            "        ref %d desc %d -> node %d u%016llx\n",
+                                            ref->debug_id, ref->desc, ref->node->debug_id,
+                                            (u64)ref->node->ptr);
+                       } else {
+                               struct binder_ref *new_ref;
+
+                               new_ref = binder_get_ref_for_node(target_proc, ref->node);
+                               if (new_ref == NULL) {
+                                       return_error = BR_FAILED_REPLY;
+                                       goto err_binder_get_ref_for_node_failed;
+                               }
+                               fp->handle = new_ref->desc;
+                               binder_inc_ref(new_ref, fp->type == BINDER_TYPE_HANDLE, NULL);
+                               trace_binder_transaction_ref_to_ref(t, ref,
+                                                                   new_ref);
+                               binder_debug(BINDER_DEBUG_TRANSACTION,
+                                            "        ref %d desc %d -> ref %d desc %d (node %d)\n",
+                                            ref->debug_id, ref->desc, new_ref->debug_id,
+                                            new_ref->desc, ref->node->debug_id);
+                       }
+               } break;
+
+               case BINDER_TYPE_FD: {
+                       int target_fd;
+                       struct file *file;
+
+                       if (reply) {
+                               if (!(in_reply_to->flags & TF_ACCEPT_FDS)) {
+                                       binder_user_error("%d:%d got reply with fd, %d, but target does not allow fds\n",
+                                               proc->pid, thread->pid, fp->handle);
+                                       return_error = BR_FAILED_REPLY;
+                                       goto err_fd_not_allowed;
+                               }
+                       } else if (!target_node->accept_fds) {
+                               binder_user_error("%d:%d got transaction with fd, %d, but target does not allow fds\n",
+                                       proc->pid, thread->pid, fp->handle);
+                               return_error = BR_FAILED_REPLY;
+                               goto err_fd_not_allowed;
+                       }
+
+                       file = fget(fp->handle);
+                       if (file == NULL) {
+                               binder_user_error("%d:%d got transaction with invalid fd, %d\n",
+                                       proc->pid, thread->pid, fp->handle);
+                               return_error = BR_FAILED_REPLY;
+                               goto err_fget_failed;
+                       }
+                       target_fd = task_get_unused_fd_flags(target_proc, O_CLOEXEC);
+                       if (target_fd < 0) {
+                               fput(file);
+                               return_error = BR_FAILED_REPLY;
+                               goto err_get_unused_fd_failed;
+                       }
+                       task_fd_install(target_proc, target_fd, file);
+                       trace_binder_transaction_fd(t, fp->handle, target_fd);
+                       binder_debug(BINDER_DEBUG_TRANSACTION,
+                                    "        fd %d -> %d\n", fp->handle, target_fd);
+                       /* TODO: fput? */
+                       fp->handle = target_fd;
+               } break;
+
+               default:
+                       binder_user_error("%d:%d got transaction with invalid object type, %x\n",
+                               proc->pid, thread->pid, fp->type);
+                       return_error = BR_FAILED_REPLY;
+                       goto err_bad_object_type;
+               }
+       }
+       if (reply) {
+               BUG_ON(t->buffer->async_transaction != 0);
+               binder_pop_transaction(target_thread, in_reply_to);
+       } else if (!(t->flags & TF_ONE_WAY)) {
+               BUG_ON(t->buffer->async_transaction != 0);
+               t->need_reply = 1;
+               t->from_parent = thread->transaction_stack;
+               thread->transaction_stack = t;
+       } else {
+               BUG_ON(target_node == NULL);
+               BUG_ON(t->buffer->async_transaction != 1);
+               if (target_node->has_async_transaction) {
+                       target_list = &target_node->async_todo;
+                       target_wait = NULL;
+               } else
+                       target_node->has_async_transaction = 1;
+       }
+       t->work.type = BINDER_WORK_TRANSACTION;
+       list_add_tail(&t->work.entry, target_list);
+       tcomplete->type = BINDER_WORK_TRANSACTION_COMPLETE;
+       list_add_tail(&tcomplete->entry, &thread->todo);
+       if (target_wait)
+               wake_up_interruptible(target_wait);
+       return;
+
+err_get_unused_fd_failed:
+err_fget_failed:
+err_fd_not_allowed:
+err_binder_get_ref_for_node_failed:
+err_binder_get_ref_failed:
+err_binder_new_node_failed:
+err_bad_object_type:
+err_bad_offset:
+err_copy_data_failed:
+       trace_binder_transaction_failed_buffer_release(t->buffer);
+       binder_transaction_buffer_release(target_proc, t->buffer, offp);
+       t->buffer->transaction = NULL;
+       binder_free_buf(target_proc, t->buffer);
+err_binder_alloc_buf_failed:
+       kfree(tcomplete);
+       binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE);
+err_alloc_tcomplete_failed:
+       kfree(t);
+       binder_stats_deleted(BINDER_STAT_TRANSACTION);
+err_alloc_t_failed:
+err_bad_call_stack:
+err_empty_call_stack:
+err_dead_binder:
+err_invalid_target_handle:
+err_no_context_mgr_node:
+       binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
+                    "%d:%d transaction failed %d, size %lld-%lld\n",
+                    proc->pid, thread->pid, return_error,
+                    (u64)tr->data_size, (u64)tr->offsets_size);
+
+       {
+               struct binder_transaction_log_entry *fe;
+
+               fe = binder_transaction_log_add(&binder_transaction_log_failed);
+               *fe = *e;
+       }
+
+       BUG_ON(thread->return_error != BR_OK);
+       if (in_reply_to) {
+               thread->return_error = BR_TRANSACTION_COMPLETE;
+               binder_send_failed_reply(in_reply_to, return_error);
+       } else
+               thread->return_error = return_error;
+}
+
+static int binder_thread_write(struct binder_proc *proc,
+                       struct binder_thread *thread,
+                       binder_uintptr_t binder_buffer, size_t size,
+                       binder_size_t *consumed)
+{
+       uint32_t cmd;
+       void __user *buffer = (void __user *)(uintptr_t)binder_buffer;
+       void __user *ptr = buffer + *consumed;
+       void __user *end = buffer + size;
+
+       while (ptr < end && thread->return_error == BR_OK) {
+               if (get_user(cmd, (uint32_t __user *)ptr))
+                       return -EFAULT;
+               ptr += sizeof(uint32_t);
+               trace_binder_command(cmd);
+               if (_IOC_NR(cmd) < ARRAY_SIZE(binder_stats.bc)) {
+                       binder_stats.bc[_IOC_NR(cmd)]++;
+                       proc->stats.bc[_IOC_NR(cmd)]++;
+                       thread->stats.bc[_IOC_NR(cmd)]++;
+               }
+               switch (cmd) {
+               case BC_INCREFS:
+               case BC_ACQUIRE:
+               case BC_RELEASE:
+               case BC_DECREFS: {
+                       uint32_t target;
+                       struct binder_ref *ref;
+                       const char *debug_string;
+
+                       if (get_user(target, (uint32_t __user *)ptr))
+                               return -EFAULT;
+                       ptr += sizeof(uint32_t);
+                       if (target == 0 && binder_context_mgr_node &&
+                           (cmd == BC_INCREFS || cmd == BC_ACQUIRE)) {
+                               ref = binder_get_ref_for_node(proc,
+                                              binder_context_mgr_node);
+                               if (ref->desc != target) {
+                                       binder_user_error("%d:%d tried to acquire reference to desc 0, got %d instead\n",
+                                               proc->pid, thread->pid,
+                                               ref->desc);
+                               }
+                       } else
+                               ref = binder_get_ref(proc, target);
+                       if (ref == NULL) {
+                               binder_user_error("%d:%d refcount change on invalid ref %d\n",
+                                       proc->pid, thread->pid, target);
+                               break;
+                       }
+                       switch (cmd) {
+                       case BC_INCREFS:
+                               debug_string = "IncRefs";
+                               binder_inc_ref(ref, 0, NULL);
+                               break;
+                       case BC_ACQUIRE:
+                               debug_string = "Acquire";
+                               binder_inc_ref(ref, 1, NULL);
+                               break;
+                       case BC_RELEASE:
+                               debug_string = "Release";
+                               binder_dec_ref(ref, 1);
+                               break;
+                       case BC_DECREFS:
+                       default:
+                               debug_string = "DecRefs";
+                               binder_dec_ref(ref, 0);
+                               break;
+                       }
+                       binder_debug(BINDER_DEBUG_USER_REFS,
+                                    "%d:%d %s ref %d desc %d s %d w %d for node %d\n",
+                                    proc->pid, thread->pid, debug_string, ref->debug_id,
+                                    ref->desc, ref->strong, ref->weak, ref->node->debug_id);
+                       break;
+               }
+               case BC_INCREFS_DONE:
+               case BC_ACQUIRE_DONE: {
+                       binder_uintptr_t node_ptr;
+                       binder_uintptr_t cookie;
+                       struct binder_node *node;
+
+                       if (get_user(node_ptr, (binder_uintptr_t __user *)ptr))
+                               return -EFAULT;
+                       ptr += sizeof(binder_uintptr_t);
+                       if (get_user(cookie, (binder_uintptr_t __user *)ptr))
+                               return -EFAULT;
+                       ptr += sizeof(binder_uintptr_t);
+                       node = binder_get_node(proc, node_ptr);
+                       if (node == NULL) {
+                               binder_user_error("%d:%d %s u%016llx no match\n",
+                                       proc->pid, thread->pid,
+                                       cmd == BC_INCREFS_DONE ?
+                                       "BC_INCREFS_DONE" :
+                                       "BC_ACQUIRE_DONE",
+                                       (u64)node_ptr);
+                               break;
+                       }
+                       if (cookie != node->cookie) {
+                               binder_user_error("%d:%d %s u%016llx node %d cookie mismatch %016llx != %016llx\n",
+                                       proc->pid, thread->pid,
+                                       cmd == BC_INCREFS_DONE ?
+                                       "BC_INCREFS_DONE" : "BC_ACQUIRE_DONE",
+                                       (u64)node_ptr, node->debug_id,
+                                       (u64)cookie, (u64)node->cookie);
+                               break;
+                       }
+                       if (cmd == BC_ACQUIRE_DONE) {
+                               if (node->pending_strong_ref == 0) {
+                                       binder_user_error("%d:%d BC_ACQUIRE_DONE node %d has no pending acquire request\n",
+                                               proc->pid, thread->pid,
+                                               node->debug_id);
+                                       break;
+                               }
+                               node->pending_strong_ref = 0;
+                       } else {
+                               if (node->pending_weak_ref == 0) {
+                                       binder_user_error("%d:%d BC_INCREFS_DONE node %d has no pending increfs request\n",
+                                               proc->pid, thread->pid,
+                                               node->debug_id);
+                                       break;
+                               }
+                               node->pending_weak_ref = 0;
+                       }
+                       binder_dec_node(node, cmd == BC_ACQUIRE_DONE, 0);
+                       binder_debug(BINDER_DEBUG_USER_REFS,
+                                    "%d:%d %s node %d ls %d lw %d\n",
+                                    proc->pid, thread->pid,
+                                    cmd == BC_INCREFS_DONE ? "BC_INCREFS_DONE" : "BC_ACQUIRE_DONE",
+                                    node->debug_id, node->local_strong_refs, node->local_weak_refs);
+                       break;
+               }
+               case BC_ATTEMPT_ACQUIRE:
+                       pr_err("BC_ATTEMPT_ACQUIRE not supported\n");
+                       return -EINVAL;
+               case BC_ACQUIRE_RESULT:
+                       pr_err("BC_ACQUIRE_RESULT not supported\n");
+                       return -EINVAL;
+
+               case BC_FREE_BUFFER: {
+                       binder_uintptr_t data_ptr;
+                       struct binder_buffer *buffer;
+
+                       if (get_user(data_ptr, (binder_uintptr_t __user *)ptr))
+                               return -EFAULT;
+                       ptr += sizeof(binder_uintptr_t);
+
+                       buffer = binder_buffer_lookup(proc, data_ptr);
+                       if (buffer == NULL) {
+                               binder_user_error("%d:%d BC_FREE_BUFFER u%016llx no match\n",
+                                       proc->pid, thread->pid, (u64)data_ptr);
+                               break;
+                       }
+                       if (!buffer->allow_user_free) {
+                               binder_user_error("%d:%d BC_FREE_BUFFER u%016llx matched unreturned buffer\n",
+                                       proc->pid, thread->pid, (u64)data_ptr);
+                               break;
+                       }
+                       binder_debug(BINDER_DEBUG_FREE_BUFFER,
+                                    "%d:%d BC_FREE_BUFFER u%016llx found buffer %d for %s transaction\n",
+                                    proc->pid, thread->pid, (u64)data_ptr,
+                                    buffer->debug_id,
+                                    buffer->transaction ? "active" : "finished");
+
+                       if (buffer->transaction) {
+                               buffer->transaction->buffer = NULL;
+                               buffer->transaction = NULL;
+                       }
+                       if (buffer->async_transaction && buffer->target_node) {
+                               BUG_ON(!buffer->target_node->has_async_transaction);
+                               if (list_empty(&buffer->target_node->async_todo))
+                                       buffer->target_node->has_async_transaction = 0;
+                               else
+                                       list_move_tail(buffer->target_node->async_todo.next, &thread->todo);
+                       }
+                       trace_binder_transaction_buffer_release(buffer);
+                       binder_transaction_buffer_release(proc, buffer, NULL);
+                       binder_free_buf(proc, buffer);
+                       break;
+               }
+
+               case BC_TRANSACTION:
+               case BC_REPLY: {
+                       struct binder_transaction_data tr;
+
+                       if (copy_from_user(&tr, ptr, sizeof(tr)))
+                               return -EFAULT;
+                       ptr += sizeof(tr);
+                       binder_transaction(proc, thread, &tr, cmd == BC_REPLY);
+                       break;
+               }
+
+               case BC_REGISTER_LOOPER:
+                       binder_debug(BINDER_DEBUG_THREADS,
+                                    "%d:%d BC_REGISTER_LOOPER\n",
+                                    proc->pid, thread->pid);
+                       if (thread->looper & BINDER_LOOPER_STATE_ENTERED) {
+                               thread->looper |= BINDER_LOOPER_STATE_INVALID;
+                               binder_user_error("%d:%d ERROR: BC_REGISTER_LOOPER called after BC_ENTER_LOOPER\n",
+                                       proc->pid, thread->pid);
+                       } else if (proc->requested_threads == 0) {
+                               thread->looper |= BINDER_LOOPER_STATE_INVALID;
+                               binder_user_error("%d:%d ERROR: BC_REGISTER_LOOPER called without request\n",
+                                       proc->pid, thread->pid);
+                       } else {
+                               proc->requested_threads--;
+                               proc->requested_threads_started++;
+                       }
+                       thread->looper |= BINDER_LOOPER_STATE_REGISTERED;
+                       break;
+               case BC_ENTER_LOOPER:
+                       binder_debug(BINDER_DEBUG_THREADS,
+                                    "%d:%d BC_ENTER_LOOPER\n",
+                                    proc->pid, thread->pid);
+                       if (thread->looper & BINDER_LOOPER_STATE_REGISTERED) {
+                               thread->looper |= BINDER_LOOPER_STATE_INVALID;
+                               binder_user_error("%d:%d ERROR: BC_ENTER_LOOPER called after BC_REGISTER_LOOPER\n",
+                                       proc->pid, thread->pid);
+                       }
+                       thread->looper |= BINDER_LOOPER_STATE_ENTERED;
+                       break;
+               case BC_EXIT_LOOPER:
+                       binder_debug(BINDER_DEBUG_THREADS,
+                                    "%d:%d BC_EXIT_LOOPER\n",
+                                    proc->pid, thread->pid);
+                       thread->looper |= BINDER_LOOPER_STATE_EXITED;
+                       break;
+
+               case BC_REQUEST_DEATH_NOTIFICATION:
+               case BC_CLEAR_DEATH_NOTIFICATION: {
+                       uint32_t target;
+                       binder_uintptr_t cookie;
+                       struct binder_ref *ref;
+                       struct binder_ref_death *death;
+
+                       if (get_user(target, (uint32_t __user *)ptr))
+                               return -EFAULT;
+                       ptr += sizeof(uint32_t);
+                       if (get_user(cookie, (binder_uintptr_t __user *)ptr))
+                               return -EFAULT;
+                       ptr += sizeof(binder_uintptr_t);
+                       ref = binder_get_ref(proc, target);
+                       if (ref == NULL) {
+                               binder_user_error("%d:%d %s invalid ref %d\n",
+                                       proc->pid, thread->pid,
+                                       cmd == BC_REQUEST_DEATH_NOTIFICATION ?
+                                       "BC_REQUEST_DEATH_NOTIFICATION" :
+                                       "BC_CLEAR_DEATH_NOTIFICATION",
+                                       target);
+                               break;
+                       }
+
+                       binder_debug(BINDER_DEBUG_DEATH_NOTIFICATION,
+                                    "%d:%d %s %016llx ref %d desc %d s %d w %d for node %d\n",
+                                    proc->pid, thread->pid,
+                                    cmd == BC_REQUEST_DEATH_NOTIFICATION ?
+                                    "BC_REQUEST_DEATH_NOTIFICATION" :
+                                    "BC_CLEAR_DEATH_NOTIFICATION",
+                                    (u64)cookie, ref->debug_id, ref->desc,
+                                    ref->strong, ref->weak, ref->node->debug_id);
+
+                       if (cmd == BC_REQUEST_DEATH_NOTIFICATION) {
+                               if (ref->death) {
+                                       binder_user_error("%d:%d BC_REQUEST_DEATH_NOTIFICATION death notification already set\n",
+                                               proc->pid, thread->pid);
+                                       break;
+                               }
+                               death = kzalloc(sizeof(*death), GFP_KERNEL);
+                               if (death == NULL) {
+                                       thread->return_error = BR_ERROR;
+                                       binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
+                                                    "%d:%d BC_REQUEST_DEATH_NOTIFICATION failed\n",
+                                                    proc->pid, thread->pid);
+                                       break;
+                               }
+                               binder_stats_created(BINDER_STAT_DEATH);
+                               INIT_LIST_HEAD(&death->work.entry);
+                               death->cookie = cookie;
+                               ref->death = death;
+                               if (ref->node->proc == NULL) {
+                                       ref->death->work.type = BINDER_WORK_DEAD_BINDER;
+                                       if (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | BINDER_LOOPER_STATE_ENTERED)) {
+                                               list_add_tail(&ref->death->work.entry, &thread->todo);
+                                       } else {
+                                               list_add_tail(&ref->death->work.entry, &proc->todo);
+                                               wake_up_interruptible(&proc->wait);
+                                       }
+                               }
+                       } else {
+                               if (ref->death == NULL) {
+                                       binder_user_error("%d:%d BC_CLEAR_DEATH_NOTIFICATION death notification not active\n",
+                                               proc->pid, thread->pid);
+                                       break;
+                               }
+                               death = ref->death;
+                               if (death->cookie != cookie) {
+                                       binder_user_error("%d:%d BC_CLEAR_DEATH_NOTIFICATION death notification cookie mismatch %016llx != %016llx\n",
+                                               proc->pid, thread->pid,
+                                               (u64)death->cookie,
+                                               (u64)cookie);
+                                       break;
+                               }
+                               ref->death = NULL;
+                               if (list_empty(&death->work.entry)) {
+                                       death->work.type = BINDER_WORK_CLEAR_DEATH_NOTIFICATION;
+                                       if (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | BINDER_LOOPER_STATE_ENTERED)) {
+                                               list_add_tail(&death->work.entry, &thread->todo);
+                                       } else {
+                                               list_add_tail(&death->work.entry, &proc->todo);
+                                               wake_up_interruptible(&proc->wait);
+                                       }
+                               } else {
+                                       BUG_ON(death->work.type != BINDER_WORK_DEAD_BINDER);
+                                       death->work.type = BINDER_WORK_DEAD_BINDER_AND_CLEAR;
+                               }
+                       }
+               } break;
+               case BC_DEAD_BINDER_DONE: {
+                       struct binder_work *w;
+                       binder_uintptr_t cookie;
+                       struct binder_ref_death *death = NULL;
+
+                       if (get_user(cookie, (binder_uintptr_t __user *)ptr))
+                               return -EFAULT;
+
+                       ptr += sizeof(void *);
+                       list_for_each_entry(w, &proc->delivered_death, entry) {
+                               struct binder_ref_death *tmp_death = container_of(w, struct binder_ref_death, work);
+
+                               if (tmp_death->cookie == cookie) {
+                                       death = tmp_death;
+                                       break;
+                               }
+                       }
+                       binder_debug(BINDER_DEBUG_DEAD_BINDER,
+                                    "%d:%d BC_DEAD_BINDER_DONE %016llx found %p\n",
+                                    proc->pid, thread->pid, (u64)cookie,
+                                    death);
+                       if (death == NULL) {
+                               binder_user_error("%d:%d BC_DEAD_BINDER_DONE %016llx not found\n",
+                                       proc->pid, thread->pid, (u64)cookie);
+                               break;
+                       }
+
+                       list_del_init(&death->work.entry);
+                       if (death->work.type == BINDER_WORK_DEAD_BINDER_AND_CLEAR) {
+                               death->work.type = BINDER_WORK_CLEAR_DEATH_NOTIFICATION;
+                               if (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | BINDER_LOOPER_STATE_ENTERED)) {
+                                       list_add_tail(&death->work.entry, &thread->todo);
+                               } else {
+                                       list_add_tail(&death->work.entry, &proc->todo);
+                                       wake_up_interruptible(&proc->wait);
+                               }
+                       }
+               } break;
+
+               default:
+                       pr_err("%d:%d unknown command %d\n",
+                              proc->pid, thread->pid, cmd);
+                       return -EINVAL;
+               }
+               *consumed = ptr - buffer;
+       }
+       return 0;
+}
+
+static void binder_stat_br(struct binder_proc *proc,
+                          struct binder_thread *thread, uint32_t cmd)
+{
+       trace_binder_return(cmd);
+       if (_IOC_NR(cmd) < ARRAY_SIZE(binder_stats.br)) {
+               binder_stats.br[_IOC_NR(cmd)]++;
+               proc->stats.br[_IOC_NR(cmd)]++;
+               thread->stats.br[_IOC_NR(cmd)]++;
+       }
+}
+
+static int binder_has_proc_work(struct binder_proc *proc,
+                               struct binder_thread *thread)
+{
+       return !list_empty(&proc->todo) ||
+               (thread->looper & BINDER_LOOPER_STATE_NEED_RETURN);
+}
+
+static int binder_has_thread_work(struct binder_thread *thread)
+{
+       return !list_empty(&thread->todo) || thread->return_error != BR_OK ||
+               (thread->looper & BINDER_LOOPER_STATE_NEED_RETURN);
+}
+
+static int binder_thread_read(struct binder_proc *proc,
+                             struct binder_thread *thread,
+                             binder_uintptr_t binder_buffer, size_t size,
+                             binder_size_t *consumed, int non_block)
+{
+       void __user *buffer = (void __user *)(uintptr_t)binder_buffer;
+       void __user *ptr = buffer + *consumed;
+       void __user *end = buffer + size;
+
+       int ret = 0;
+       int wait_for_proc_work;
+
+       if (*consumed == 0) {
+               if (put_user(BR_NOOP, (uint32_t __user *)ptr))
+                       return -EFAULT;
+               ptr += sizeof(uint32_t);
+       }
+
+retry:
+       wait_for_proc_work = thread->transaction_stack == NULL &&
+                               list_empty(&thread->todo);
+
+       if (thread->return_error != BR_OK && ptr < end) {
+               if (thread->return_error2 != BR_OK) {
+                       if (put_user(thread->return_error2, (uint32_t __user *)ptr))
+                               return -EFAULT;
+                       ptr += sizeof(uint32_t);
+                       binder_stat_br(proc, thread, thread->return_error2);
+                       if (ptr == end)
+                               goto done;
+                       thread->return_error2 = BR_OK;
+               }
+               if (put_user(thread->return_error, (uint32_t __user *)ptr))
+                       return -EFAULT;
+               ptr += sizeof(uint32_t);
+               binder_stat_br(proc, thread, thread->return_error);
+               thread->return_error = BR_OK;
+               goto done;
+       }
+
+
+       thread->looper |= BINDER_LOOPER_STATE_WAITING;
+       if (wait_for_proc_work)
+               proc->ready_threads++;
+
+       binder_unlock(__func__);
+
+       trace_binder_wait_for_work(wait_for_proc_work,
+                                  !!thread->transaction_stack,
+                                  !list_empty(&thread->todo));
+       if (wait_for_proc_work) {
+               if (!(thread->looper & (BINDER_LOOPER_STATE_REGISTERED |
+                                       BINDER_LOOPER_STATE_ENTERED))) {
+                       binder_user_error("%d:%d ERROR: Thread waiting for process work before calling BC_REGISTER_LOOPER or BC_ENTER_LOOPER (state %x)\n",
+                               proc->pid, thread->pid, thread->looper);
+                       wait_event_interruptible(binder_user_error_wait,
+                                                binder_stop_on_user_error < 2);
+               }
+               binder_set_nice(proc->default_priority);
+               if (non_block) {
+                       if (!binder_has_proc_work(proc, thread))
+                               ret = -EAGAIN;
+               } else
+                       ret = wait_event_freezable_exclusive(proc->wait, binder_has_proc_work(proc, thread));
+       } else {
+               if (non_block) {
+                       if (!binder_has_thread_work(thread))
+                               ret = -EAGAIN;
+               } else
+                       ret = wait_event_freezable(thread->wait, binder_has_thread_work(thread));
+       }
+
+       binder_lock(__func__);
+
+       if (wait_for_proc_work)
+               proc->ready_threads--;
+       thread->looper &= ~BINDER_LOOPER_STATE_WAITING;
+
+       if (ret)
+               return ret;
+
+       while (1) {
+               uint32_t cmd;
+               struct binder_transaction_data tr;
+               struct binder_work *w;
+               struct binder_transaction *t = NULL;
+
+               if (!list_empty(&thread->todo)) {
+                       w = list_first_entry(&thread->todo, struct binder_work,
+                                            entry);
+               } else if (!list_empty(&proc->todo) && wait_for_proc_work) {
+                       w = list_first_entry(&proc->todo, struct binder_work,
+                                            entry);
+               } else {
+                       /* no data added */
+                       if (ptr - buffer == 4 &&
+                           !(thread->looper & BINDER_LOOPER_STATE_NEED_RETURN))
+                               goto retry;
+                       break;
+               }
+
+               if (end - ptr < sizeof(tr) + 4)
+                       break;
+
+               switch (w->type) {
+               case BINDER_WORK_TRANSACTION: {
+                       t = container_of(w, struct binder_transaction, work);
+               } break;
+               case BINDER_WORK_TRANSACTION_COMPLETE: {
+                       cmd = BR_TRANSACTION_COMPLETE;
+                       if (put_user(cmd, (uint32_t __user *)ptr))
+                               return -EFAULT;
+                       ptr += sizeof(uint32_t);
+
+                       binder_stat_br(proc, thread, cmd);
+                       binder_debug(BINDER_DEBUG_TRANSACTION_COMPLETE,
+                                    "%d:%d BR_TRANSACTION_COMPLETE\n",
+                                    proc->pid, thread->pid);
+
+                       list_del(&w->entry);
+                       kfree(w);
+                       binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE);
+               } break;
+               case BINDER_WORK_NODE: {
+                       struct binder_node *node = container_of(w, struct binder_node, work);
+                       uint32_t cmd = BR_NOOP;
+                       const char *cmd_name;
+                       int strong = node->internal_strong_refs || node->local_strong_refs;
+                       int weak = !hlist_empty(&node->refs) || node->local_weak_refs || strong;
+
+                       if (weak && !node->has_weak_ref) {
+                               cmd = BR_INCREFS;
+                               cmd_name = "BR_INCREFS";
+                               node->has_weak_ref = 1;
+                               node->pending_weak_ref = 1;
+                               node->local_weak_refs++;
+                       } else if (strong && !node->has_strong_ref) {
+                               cmd = BR_ACQUIRE;
+                               cmd_name = "BR_ACQUIRE";
+                               node->has_strong_ref = 1;
+                               node->pending_strong_ref = 1;
+                               node->local_strong_refs++;
+                       } else if (!strong && node->has_strong_ref) {
+                               cmd = BR_RELEASE;
+                               cmd_name = "BR_RELEASE";
+                               node->has_strong_ref = 0;
+                       } else if (!weak && node->has_weak_ref) {
+                               cmd = BR_DECREFS;
+                               cmd_name = "BR_DECREFS";
+                               node->has_weak_ref = 0;
+                       }
+                       if (cmd != BR_NOOP) {
+                               if (put_user(cmd, (uint32_t __user *)ptr))
+                                       return -EFAULT;
+                               ptr += sizeof(uint32_t);
+                               if (put_user(node->ptr,
+                                            (binder_uintptr_t __user *)ptr))
+                                       return -EFAULT;
+                               ptr += sizeof(binder_uintptr_t);
+                               if (put_user(node->cookie,
+                                            (binder_uintptr_t __user *)ptr))
+                                       return -EFAULT;
+                               ptr += sizeof(binder_uintptr_t);
+
+                               binder_stat_br(proc, thread, cmd);
+                               binder_debug(BINDER_DEBUG_USER_REFS,
+                                            "%d:%d %s %d u%016llx c%016llx\n",
+                                            proc->pid, thread->pid, cmd_name,
+                                            node->debug_id,
+                                            (u64)node->ptr, (u64)node->cookie);
+                       } else {
+                               list_del_init(&w->entry);
+                               if (!weak && !strong) {
+                                       binder_debug(BINDER_DEBUG_INTERNAL_REFS,
+                                                    "%d:%d node %d u%016llx c%016llx deleted\n",
+                                                    proc->pid, thread->pid,
+                                                    node->debug_id,
+                                                    (u64)node->ptr,
+                                                    (u64)node->cookie);
+                                       rb_erase(&node->rb_node, &proc->nodes);
+                                       kfree(node);
+                                       binder_stats_deleted(BINDER_STAT_NODE);
+                               } else {
+                                       binder_debug(BINDER_DEBUG_INTERNAL_REFS,
+                                                    "%d:%d node %d u%016llx c%016llx state unchanged\n",
+                                                    proc->pid, thread->pid,
+                                                    node->debug_id,
+                                                    (u64)node->ptr,
+                                                    (u64)node->cookie);
+                               }
+                       }
+               } break;
+               case BINDER_WORK_DEAD_BINDER:
+               case BINDER_WORK_DEAD_BINDER_AND_CLEAR:
+               case BINDER_WORK_CLEAR_DEATH_NOTIFICATION: {
+                       struct binder_ref_death *death;
+                       uint32_t cmd;
+
+                       death = container_of(w, struct binder_ref_death, work);
+                       if (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION)
+                               cmd = BR_CLEAR_DEATH_NOTIFICATION_DONE;
+                       else
+                               cmd = BR_DEAD_BINDER;
+                       if (put_user(cmd, (uint32_t __user *)ptr))
+                               return -EFAULT;
+                       ptr += sizeof(uint32_t);
+                       if (put_user(death->cookie,
+                                    (binder_uintptr_t __user *)ptr))
+                               return -EFAULT;
+                       ptr += sizeof(binder_uintptr_t);
+                       binder_stat_br(proc, thread, cmd);
+                       binder_debug(BINDER_DEBUG_DEATH_NOTIFICATION,
+                                    "%d:%d %s %016llx\n",
+                                     proc->pid, thread->pid,
+                                     cmd == BR_DEAD_BINDER ?
+                                     "BR_DEAD_BINDER" :
+                                     "BR_CLEAR_DEATH_NOTIFICATION_DONE",
+                                     (u64)death->cookie);
+
+                       if (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION) {
+                               list_del(&w->entry);
+                               kfree(death);
+                               binder_stats_deleted(BINDER_STAT_DEATH);
+                       } else
+                               list_move(&w->entry, &proc->delivered_death);
+                       if (cmd == BR_DEAD_BINDER)
+                               goto done; /* DEAD_BINDER notifications can cause transactions */
+               } break;
+               }
+
+               if (!t)
+                       continue;
+
+               BUG_ON(t->buffer == NULL);
+               if (t->buffer->target_node) {
+                       struct binder_node *target_node = t->buffer->target_node;
+
+                       tr.target.ptr = target_node->ptr;
+                       tr.cookie =  target_node->cookie;
+                       t->saved_priority = task_nice(current);
+                       if (t->priority < target_node->min_priority &&
+                           !(t->flags & TF_ONE_WAY))
+                               binder_set_nice(t->priority);
+                       else if (!(t->flags & TF_ONE_WAY) ||
+                                t->saved_priority > target_node->min_priority)
+                               binder_set_nice(target_node->min_priority);
+                       cmd = BR_TRANSACTION;
+               } else {
+                       tr.target.ptr = 0;
+                       tr.cookie = 0;
+                       cmd = BR_REPLY;
+               }
+               tr.code = t->code;
+               tr.flags = t->flags;
+               tr.sender_euid = from_kuid(current_user_ns(), t->sender_euid);
+
+               if (t->from) {
+                       struct task_struct *sender = t->from->proc->tsk;
+
+                       tr.sender_pid = task_tgid_nr_ns(sender,
+                                                       task_active_pid_ns(current));
+               } else {
+                       tr.sender_pid = 0;
+               }
+
+               tr.data_size = t->buffer->data_size;
+               tr.offsets_size = t->buffer->offsets_size;
+               tr.data.ptr.buffer = (binder_uintptr_t)(
+                                       (uintptr_t)t->buffer->data +
+                                       proc->user_buffer_offset);
+               tr.data.ptr.offsets = tr.data.ptr.buffer +
+                                       ALIGN(t->buffer->data_size,
+                                           sizeof(void *));
+
+               if (put_user(cmd, (uint32_t __user *)ptr))
+                       return -EFAULT;
+               ptr += sizeof(uint32_t);
+               if (copy_to_user(ptr, &tr, sizeof(tr)))
+                       return -EFAULT;
+               ptr += sizeof(tr);
+
+               trace_binder_transaction_received(t);
+               binder_stat_br(proc, thread, cmd);
+               binder_debug(BINDER_DEBUG_TRANSACTION,
+                            "%d:%d %s %d %d:%d, cmd %d size %zd-%zd ptr %016llx-%016llx\n",
+                            proc->pid, thread->pid,
+                            (cmd == BR_TRANSACTION) ? "BR_TRANSACTION" :
+                            "BR_REPLY",
+                            t->debug_id, t->from ? t->from->proc->pid : 0,
+                            t->from ? t->from->pid : 0, cmd,
+                            t->buffer->data_size, t->buffer->offsets_size,
+                            (u64)tr.data.ptr.buffer, (u64)tr.data.ptr.offsets);
+
+               list_del(&t->work.entry);
+               t->buffer->allow_user_free = 1;
+               if (cmd == BR_TRANSACTION && !(t->flags & TF_ONE_WAY)) {
+                       t->to_parent = thread->transaction_stack;
+                       t->to_thread = thread;
+                       thread->transaction_stack = t;
+               } else {
+                       t->buffer->transaction = NULL;
+                       kfree(t);
+                       binder_stats_deleted(BINDER_STAT_TRANSACTION);
+               }
+               break;
+       }
+
+done:
+
+       *consumed = ptr - buffer;
+       if (proc->requested_threads + proc->ready_threads == 0 &&
+           proc->requested_threads_started < proc->max_threads &&
+           (thread->looper & (BINDER_LOOPER_STATE_REGISTERED |
+            BINDER_LOOPER_STATE_ENTERED)) /* the user-space code fails to */
+            /*spawn a new thread if we leave this out */) {
+               proc->requested_threads++;
+               binder_debug(BINDER_DEBUG_THREADS,
+                            "%d:%d BR_SPAWN_LOOPER\n",
+                            proc->pid, thread->pid);
+               if (put_user(BR_SPAWN_LOOPER, (uint32_t __user *)buffer))
+                       return -EFAULT;
+               binder_stat_br(proc, thread, BR_SPAWN_LOOPER);
+       }
+       return 0;
+}
+
+static void binder_release_work(struct list_head *list)
+{
+       struct binder_work *w;
+
+       while (!list_empty(list)) {
+               w = list_first_entry(list, struct binder_work, entry);
+               list_del_init(&w->entry);
+               switch (w->type) {
+               case BINDER_WORK_TRANSACTION: {
+                       struct binder_transaction *t;
+
+                       t = container_of(w, struct binder_transaction, work);
+                       if (t->buffer->target_node &&
+                           !(t->flags & TF_ONE_WAY)) {
+                               binder_send_failed_reply(t, BR_DEAD_REPLY);
+                       } else {
+                               binder_debug(BINDER_DEBUG_DEAD_TRANSACTION,
+                                       "undelivered transaction %d\n",
+                                       t->debug_id);
+                               t->buffer->transaction = NULL;
+                               kfree(t);
+                               binder_stats_deleted(BINDER_STAT_TRANSACTION);
+                       }
+               } break;
+               case BINDER_WORK_TRANSACTION_COMPLETE: {
+                       binder_debug(BINDER_DEBUG_DEAD_TRANSACTION,
+                               "undelivered TRANSACTION_COMPLETE\n");
+                       kfree(w);
+                       binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE);
+               } break;
+               case BINDER_WORK_DEAD_BINDER_AND_CLEAR:
+               case BINDER_WORK_CLEAR_DEATH_NOTIFICATION: {
+                       struct binder_ref_death *death;
+
+                       death = container_of(w, struct binder_ref_death, work);
+                       binder_debug(BINDER_DEBUG_DEAD_TRANSACTION,
+                               "undelivered death notification, %016llx\n",
+                               (u64)death->cookie);
+                       kfree(death);
+                       binder_stats_deleted(BINDER_STAT_DEATH);
+               } break;
+               default:
+                       pr_err("unexpected work type, %d, not freed\n",
+                              w->type);
+                       break;
+               }
+       }
+
+}
+
+static struct binder_thread *binder_get_thread(struct binder_proc *proc)
+{
+       struct binder_thread *thread = NULL;
+       struct rb_node *parent = NULL;
+       struct rb_node **p = &proc->threads.rb_node;
+
+       while (*p) {
+               parent = *p;
+               thread = rb_entry(parent, struct binder_thread, rb_node);
+
+               if (current->pid < thread->pid)
+                       p = &(*p)->rb_left;
+               else if (current->pid > thread->pid)
+                       p = &(*p)->rb_right;
+               else
+                       break;
+       }
+       if (*p == NULL) {
+               thread = kzalloc(sizeof(*thread), GFP_KERNEL);
+               if (thread == NULL)
+                       return NULL;
+               binder_stats_created(BINDER_STAT_THREAD);
+               thread->proc = proc;
+               thread->pid = current->pid;
+               init_waitqueue_head(&thread->wait);
+               INIT_LIST_HEAD(&thread->todo);
+               rb_link_node(&thread->rb_node, parent, p);
+               rb_insert_color(&thread->rb_node, &proc->threads);
+               thread->looper |= BINDER_LOOPER_STATE_NEED_RETURN;
+               thread->return_error = BR_OK;
+               thread->return_error2 = BR_OK;
+       }
+       return thread;
+}
+
+static int binder_free_thread(struct binder_proc *proc,
+                             struct binder_thread *thread)
+{
+       struct binder_transaction *t;
+       struct binder_transaction *send_reply = NULL;
+       int active_transactions = 0;
+
+       rb_erase(&thread->rb_node, &proc->threads);
+       t = thread->transaction_stack;
+       if (t && t->to_thread == thread)
+               send_reply = t;
+       while (t) {
+               active_transactions++;
+               binder_debug(BINDER_DEBUG_DEAD_TRANSACTION,
+                            "release %d:%d transaction %d %s, still active\n",
+                             proc->pid, thread->pid,
+                            t->debug_id,
+                            (t->to_thread == thread) ? "in" : "out");
+
+               if (t->to_thread == thread) {
+                       t->to_proc = NULL;
+                       t->to_thread = NULL;
+                       if (t->buffer) {
+                               t->buffer->transaction = NULL;
+                               t->buffer = NULL;
+                       }
+                       t = t->to_parent;
+               } else if (t->from == thread) {
+                       t->from = NULL;
+                       t = t->from_parent;
+               } else
+                       BUG();
+       }
+       if (send_reply)
+               binder_send_failed_reply(send_reply, BR_DEAD_REPLY);
+       binder_release_work(&thread->todo);
+       kfree(thread);
+       binder_stats_deleted(BINDER_STAT_THREAD);
+       return active_transactions;
+}
+
+static unsigned int binder_poll(struct file *filp,
+                               struct poll_table_struct *wait)
+{
+       struct binder_proc *proc = filp->private_data;
+       struct binder_thread *thread = NULL;
+       int wait_for_proc_work;
+
+       binder_lock(__func__);
+
+       thread = binder_get_thread(proc);
+
+       wait_for_proc_work = thread->transaction_stack == NULL &&
+               list_empty(&thread->todo) && thread->return_error == BR_OK;
+
+       binder_unlock(__func__);
+
+       if (wait_for_proc_work) {
+               if (binder_has_proc_work(proc, thread))
+                       return POLLIN;
+               poll_wait(filp, &proc->wait, wait);
+               if (binder_has_proc_work(proc, thread))
+                       return POLLIN;
+       } else {
+               if (binder_has_thread_work(thread))
+                       return POLLIN;
+               poll_wait(filp, &thread->wait, wait);
+               if (binder_has_thread_work(thread))
+                       return POLLIN;
+       }
+       return 0;
+}
+
+static int binder_ioctl_write_read(struct file *filp,
+                               unsigned int cmd, unsigned long arg,
+                               struct binder_thread *thread)
+{
+       int ret = 0;
+       struct binder_proc *proc = filp->private_data;
+       unsigned int size = _IOC_SIZE(cmd);
+       void __user *ubuf = (void __user *)arg;
+       struct binder_write_read bwr;
+
+       if (size != sizeof(struct binder_write_read)) {
+               ret = -EINVAL;
+               goto out;
+       }
+       if (copy_from_user(&bwr, ubuf, sizeof(bwr))) {
+               ret = -EFAULT;
+               goto out;
+       }
+       binder_debug(BINDER_DEBUG_READ_WRITE,
+                    "%d:%d write %lld at %016llx, read %lld at %016llx\n",
+                    proc->pid, thread->pid,
+                    (u64)bwr.write_size, (u64)bwr.write_buffer,
+                    (u64)bwr.read_size, (u64)bwr.read_buffer);
+
+       if (bwr.write_size > 0) {
+               ret = binder_thread_write(proc, thread,
+                                         bwr.write_buffer,
+                                         bwr.write_size,
+                                         &bwr.write_consumed);
+               trace_binder_write_done(ret);
+               if (ret < 0) {
+                       bwr.read_consumed = 0;
+                       if (copy_to_user(ubuf, &bwr, sizeof(bwr)))
+                               ret = -EFAULT;
+                       goto out;
+               }
+       }
+       if (bwr.read_size > 0) {
+               ret = binder_thread_read(proc, thread, bwr.read_buffer,
+                                        bwr.read_size,
+                                        &bwr.read_consumed,
+                                        filp->f_flags & O_NONBLOCK);
+               trace_binder_read_done(ret);
+               if (!list_empty(&proc->todo))
+                       wake_up_interruptible(&proc->wait);
+               if (ret < 0) {
+                       if (copy_to_user(ubuf, &bwr, sizeof(bwr)))
+                               ret = -EFAULT;
+                       goto out;
+               }
+       }
+       binder_debug(BINDER_DEBUG_READ_WRITE,
+                    "%d:%d wrote %lld of %lld, read return %lld of %lld\n",
+                    proc->pid, thread->pid,
+                    (u64)bwr.write_consumed, (u64)bwr.write_size,
+                    (u64)bwr.read_consumed, (u64)bwr.read_size);
+       if (copy_to_user(ubuf, &bwr, sizeof(bwr))) {
+               ret = -EFAULT;
+               goto out;
+       }
+out:
+       return ret;
+}
+
+static int binder_ioctl_set_ctx_mgr(struct file *filp)
+{
+       int ret = 0;
+       struct binder_proc *proc = filp->private_data;
+       kuid_t curr_euid = current_euid();
+
+       if (binder_context_mgr_node != NULL) {
+               pr_err("BINDER_SET_CONTEXT_MGR already set\n");
+               ret = -EBUSY;
+               goto out;
+       }
+       if (uid_valid(binder_context_mgr_uid)) {
+               if (!uid_eq(binder_context_mgr_uid, curr_euid)) {
+                       pr_err("BINDER_SET_CONTEXT_MGR bad uid %d != %d\n",
+                              from_kuid(&init_user_ns, curr_euid),
+                              from_kuid(&init_user_ns,
+                                       binder_context_mgr_uid));
+                       ret = -EPERM;
+                       goto out;
+               }
+       } else {
+               binder_context_mgr_uid = curr_euid;
+       }
+       binder_context_mgr_node = binder_new_node(proc, 0, 0);
+       if (binder_context_mgr_node == NULL) {
+               ret = -ENOMEM;
+               goto out;
+       }
+       binder_context_mgr_node->local_weak_refs++;
+       binder_context_mgr_node->local_strong_refs++;
+       binder_context_mgr_node->has_strong_ref = 1;
+       binder_context_mgr_node->has_weak_ref = 1;
+out:
+       return ret;
+}
+
+static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+       int ret;
+       struct binder_proc *proc = filp->private_data;
+       struct binder_thread *thread;
+       unsigned int size = _IOC_SIZE(cmd);
+       void __user *ubuf = (void __user *)arg;
+
+       /*pr_info("binder_ioctl: %d:%d %x %lx\n",
+                       proc->pid, current->pid, cmd, arg);*/
+
+       trace_binder_ioctl(cmd, arg);
+
+       ret = wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2);
+       if (ret)
+               goto err_unlocked;
+
+       binder_lock(__func__);
+       thread = binder_get_thread(proc);
+       if (thread == NULL) {
+               ret = -ENOMEM;
+               goto err;
+       }
+
+       switch (cmd) {
+       case BINDER_WRITE_READ:
+               ret = binder_ioctl_write_read(filp, cmd, arg, thread);
+               if (ret)
+                       goto err;
+               break;
+       case BINDER_SET_MAX_THREADS:
+               if (copy_from_user(&proc->max_threads, ubuf, sizeof(proc->max_threads))) {
+                       ret = -EINVAL;
+                       goto err;
+               }
+               break;
+       case BINDER_SET_CONTEXT_MGR:
+               ret = binder_ioctl_set_ctx_mgr(filp);
+               if (ret)
+                       goto err;
+               break;
+       case BINDER_THREAD_EXIT:
+               binder_debug(BINDER_DEBUG_THREADS, "%d:%d exit\n",
+                            proc->pid, thread->pid);
+               binder_free_thread(proc, thread);
+               thread = NULL;
+               break;
+       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,
+                            &ver->protocol_version)) {
+                       ret = -EINVAL;
+                       goto err;
+               }
+               break;
+       }
+       default:
+               ret = -EINVAL;
+               goto err;
+       }
+       ret = 0;
+err:
+       if (thread)
+               thread->looper &= ~BINDER_LOOPER_STATE_NEED_RETURN;
+       binder_unlock(__func__);
+       wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2);
+       if (ret && ret != -ERESTARTSYS)
+               pr_info("%d:%d ioctl %x %lx returned %d\n", proc->pid, current->pid, cmd, arg, ret);
+err_unlocked:
+       trace_binder_ioctl_done(ret);
+       return ret;
+}
+
+static void binder_vma_open(struct vm_area_struct *vma)
+{
+       struct binder_proc *proc = vma->vm_private_data;
+
+       binder_debug(BINDER_DEBUG_OPEN_CLOSE,
+                    "%d open vm area %lx-%lx (%ld K) vma %lx pagep %lx\n",
+                    proc->pid, vma->vm_start, vma->vm_end,
+                    (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
+                    (unsigned long)pgprot_val(vma->vm_page_prot));
+}
+
+static void binder_vma_close(struct vm_area_struct *vma)
+{
+       struct binder_proc *proc = vma->vm_private_data;
+
+       binder_debug(BINDER_DEBUG_OPEN_CLOSE,
+                    "%d close vm area %lx-%lx (%ld K) vma %lx pagep %lx\n",
+                    proc->pid, vma->vm_start, vma->vm_end,
+                    (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
+                    (unsigned long)pgprot_val(vma->vm_page_prot));
+       proc->vma = NULL;
+       proc->vma_vm_mm = NULL;
+       binder_defer_work(proc, BINDER_DEFERRED_PUT_FILES);
+}
+
+static int binder_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
+{
+       return VM_FAULT_SIGBUS;
+}
+
+static struct vm_operations_struct binder_vm_ops = {
+       .open = binder_vma_open,
+       .close = binder_vma_close,
+       .fault = binder_vm_fault,
+};
+
+static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
+{
+       int ret;
+       struct vm_struct *area;
+       struct binder_proc *proc = filp->private_data;
+       const char *failure_string;
+       struct binder_buffer *buffer;
+
+       if (proc->tsk != current)
+               return -EINVAL;
+
+       if ((vma->vm_end - vma->vm_start) > SZ_4M)
+               vma->vm_end = vma->vm_start + SZ_4M;
+
+       binder_debug(BINDER_DEBUG_OPEN_CLOSE,
+                    "binder_mmap: %d %lx-%lx (%ld K) vma %lx pagep %lx\n",
+                    proc->pid, vma->vm_start, vma->vm_end,
+                    (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
+                    (unsigned long)pgprot_val(vma->vm_page_prot));
+
+       if (vma->vm_flags & FORBIDDEN_MMAP_FLAGS) {
+               ret = -EPERM;
+               failure_string = "bad vm_flags";
+               goto err_bad_arg;
+       }
+       vma->vm_flags = (vma->vm_flags | VM_DONTCOPY) & ~VM_MAYWRITE;
+
+       mutex_lock(&binder_mmap_lock);
+       if (proc->buffer) {
+               ret = -EBUSY;
+               failure_string = "already mapped";
+               goto err_already_mapped;
+       }
+
+       area = get_vm_area(vma->vm_end - vma->vm_start, VM_IOREMAP);
+       if (area == NULL) {
+               ret = -ENOMEM;
+               failure_string = "get_vm_area";
+               goto err_get_vm_area_failed;
+       }
+       proc->buffer = area->addr;
+       proc->user_buffer_offset = vma->vm_start - (uintptr_t)proc->buffer;
+       mutex_unlock(&binder_mmap_lock);
+
+#ifdef CONFIG_CPU_CACHE_VIPT
+       if (cache_is_vipt_aliasing()) {
+               while (CACHE_COLOUR((vma->vm_start ^ (uint32_t)proc->buffer))) {
+                       pr_info("binder_mmap: %d %lx-%lx maps %p bad alignment\n", proc->pid, vma->vm_start, vma->vm_end, proc->buffer);
+                       vma->vm_start += PAGE_SIZE;
+               }
+       }
+#endif
+       proc->pages = kzalloc(sizeof(proc->pages[0]) * ((vma->vm_end - vma->vm_start) / PAGE_SIZE), GFP_KERNEL);
+       if (proc->pages == NULL) {
+               ret = -ENOMEM;
+               failure_string = "alloc page array";
+               goto err_alloc_pages_failed;
+       }
+       proc->buffer_size = vma->vm_end - vma->vm_start;
+
+       vma->vm_ops = &binder_vm_ops;
+       vma->vm_private_data = proc;
+
+       if (binder_update_page_range(proc, 1, proc->buffer, proc->buffer + PAGE_SIZE, vma)) {
+               ret = -ENOMEM;
+               failure_string = "alloc small buf";
+               goto err_alloc_small_buf_failed;
+       }
+       buffer = proc->buffer;
+       INIT_LIST_HEAD(&proc->buffers);
+       list_add(&buffer->entry, &proc->buffers);
+       buffer->free = 1;
+       binder_insert_free_buffer(proc, buffer);
+       proc->free_async_space = proc->buffer_size / 2;
+       barrier();
+       proc->files = get_files_struct(current);
+       proc->vma = vma;
+       proc->vma_vm_mm = vma->vm_mm;
+
+       /*pr_info("binder_mmap: %d %lx-%lx maps %p\n",
+                proc->pid, vma->vm_start, vma->vm_end, proc->buffer);*/
+       return 0;
+
+err_alloc_small_buf_failed:
+       kfree(proc->pages);
+       proc->pages = NULL;
+err_alloc_pages_failed:
+       mutex_lock(&binder_mmap_lock);
+       vfree(proc->buffer);
+       proc->buffer = NULL;
+err_get_vm_area_failed:
+err_already_mapped:
+       mutex_unlock(&binder_mmap_lock);
+err_bad_arg:
+       pr_err("binder_mmap: %d %lx-%lx %s failed %d\n",
+              proc->pid, vma->vm_start, vma->vm_end, failure_string, ret);
+       return ret;
+}
+
+static int binder_open(struct inode *nodp, struct file *filp)
+{
+       struct binder_proc *proc;
+
+       binder_debug(BINDER_DEBUG_OPEN_CLOSE, "binder_open: %d:%d\n",
+                    current->group_leader->pid, current->pid);
+
+       proc = kzalloc(sizeof(*proc), GFP_KERNEL);
+       if (proc == NULL)
+               return -ENOMEM;
+       get_task_struct(current);
+       proc->tsk = current;
+       INIT_LIST_HEAD(&proc->todo);
+       init_waitqueue_head(&proc->wait);
+       proc->default_priority = task_nice(current);
+
+       binder_lock(__func__);
+
+       binder_stats_created(BINDER_STAT_PROC);
+       hlist_add_head(&proc->proc_node, &binder_procs);
+       proc->pid = current->group_leader->pid;
+       INIT_LIST_HEAD(&proc->delivered_death);
+       filp->private_data = proc;
+
+       binder_unlock(__func__);
+
+       if (binder_debugfs_dir_entry_proc) {
+               char strbuf[11];
+
+               snprintf(strbuf, sizeof(strbuf), "%u", proc->pid);
+               proc->debugfs_entry = debugfs_create_file(strbuf, S_IRUGO,
+                       binder_debugfs_dir_entry_proc, proc, &binder_proc_fops);
+       }
+
+       return 0;
+}
+
+static int binder_flush(struct file *filp, fl_owner_t id)
+{
+       struct binder_proc *proc = filp->private_data;
+
+       binder_defer_work(proc, BINDER_DEFERRED_FLUSH);
+
+       return 0;
+}
+
+static void binder_deferred_flush(struct binder_proc *proc)
+{
+       struct rb_node *n;
+       int wake_count = 0;
+
+       for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) {
+               struct binder_thread *thread = rb_entry(n, struct binder_thread, rb_node);
+
+               thread->looper |= BINDER_LOOPER_STATE_NEED_RETURN;
+               if (thread->looper & BINDER_LOOPER_STATE_WAITING) {
+                       wake_up_interruptible(&thread->wait);
+                       wake_count++;
+               }
+       }
+       wake_up_interruptible_all(&proc->wait);
+
+       binder_debug(BINDER_DEBUG_OPEN_CLOSE,
+                    "binder_flush: %d woke %d threads\n", proc->pid,
+                    wake_count);
+}
+
+static int binder_release(struct inode *nodp, struct file *filp)
+{
+       struct binder_proc *proc = filp->private_data;
+
+       debugfs_remove(proc->debugfs_entry);
+       binder_defer_work(proc, BINDER_DEFERRED_RELEASE);
+
+       return 0;
+}
+
+static int binder_node_release(struct binder_node *node, int refs)
+{
+       struct binder_ref *ref;
+       int death = 0;
+
+       list_del_init(&node->work.entry);
+       binder_release_work(&node->async_todo);
+
+       if (hlist_empty(&node->refs)) {
+               kfree(node);
+               binder_stats_deleted(BINDER_STAT_NODE);
+
+               return refs;
+       }
+
+       node->proc = NULL;
+       node->local_strong_refs = 0;
+       node->local_weak_refs = 0;
+       hlist_add_head(&node->dead_node, &binder_dead_nodes);
+
+       hlist_for_each_entry(ref, &node->refs, node_entry) {
+               refs++;
+
+               if (!ref->death)
+                       continue;
+
+               death++;
+
+               if (list_empty(&ref->death->work.entry)) {
+                       ref->death->work.type = BINDER_WORK_DEAD_BINDER;
+                       list_add_tail(&ref->death->work.entry,
+                                     &ref->proc->todo);
+                       wake_up_interruptible(&ref->proc->wait);
+               } else
+                       BUG();
+       }
+
+       binder_debug(BINDER_DEBUG_DEAD_BINDER,
+                    "node %d now dead, refs %d, death %d\n",
+                    node->debug_id, refs, death);
+
+       return refs;
+}
+
+static void binder_deferred_release(struct binder_proc *proc)
+{
+       struct binder_transaction *t;
+       struct rb_node *n;
+       int threads, nodes, incoming_refs, outgoing_refs, buffers,
+               active_transactions, page_count;
+
+       BUG_ON(proc->vma);
+       BUG_ON(proc->files);
+
+       hlist_del(&proc->proc_node);
+
+       if (binder_context_mgr_node && binder_context_mgr_node->proc == proc) {
+               binder_debug(BINDER_DEBUG_DEAD_BINDER,
+                            "%s: %d context_mgr_node gone\n",
+                            __func__, proc->pid);
+               binder_context_mgr_node = NULL;
+       }
+
+       threads = 0;
+       active_transactions = 0;
+       while ((n = rb_first(&proc->threads))) {
+               struct binder_thread *thread;
+
+               thread = rb_entry(n, struct binder_thread, rb_node);
+               threads++;
+               active_transactions += binder_free_thread(proc, thread);
+       }
+
+       nodes = 0;
+       incoming_refs = 0;
+       while ((n = rb_first(&proc->nodes))) {
+               struct binder_node *node;
+
+               node = rb_entry(n, struct binder_node, rb_node);
+               nodes++;
+               rb_erase(&node->rb_node, &proc->nodes);
+               incoming_refs = binder_node_release(node, incoming_refs);
+       }
+
+       outgoing_refs = 0;
+       while ((n = rb_first(&proc->refs_by_desc))) {
+               struct binder_ref *ref;
+
+               ref = rb_entry(n, struct binder_ref, rb_node_desc);
+               outgoing_refs++;
+               binder_delete_ref(ref);
+       }
+
+       binder_release_work(&proc->todo);
+       binder_release_work(&proc->delivered_death);
+
+       buffers = 0;
+       while ((n = rb_first(&proc->allocated_buffers))) {
+               struct binder_buffer *buffer;
+
+               buffer = rb_entry(n, struct binder_buffer, rb_node);
+
+               t = buffer->transaction;
+               if (t) {
+                       t->buffer = NULL;
+                       buffer->transaction = NULL;
+                       pr_err("release proc %d, transaction %d, not freed\n",
+                              proc->pid, t->debug_id);
+                       /*BUG();*/
+               }
+
+               binder_free_buf(proc, buffer);
+               buffers++;
+       }
+
+       binder_stats_deleted(BINDER_STAT_PROC);
+
+       page_count = 0;
+       if (proc->pages) {
+               int i;
+
+               for (i = 0; i < proc->buffer_size / PAGE_SIZE; i++) {
+                       void *page_addr;
+
+                       if (!proc->pages[i])
+                               continue;
+
+                       page_addr = proc->buffer + i * PAGE_SIZE;
+                       binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+                                    "%s: %d: page %d at %p not freed\n",
+                                    __func__, proc->pid, i, page_addr);
+                       unmap_kernel_range((unsigned long)page_addr, PAGE_SIZE);
+                       __free_page(proc->pages[i]);
+                       page_count++;
+               }
+               kfree(proc->pages);
+               vfree(proc->buffer);
+       }
+
+       put_task_struct(proc->tsk);
+
+       binder_debug(BINDER_DEBUG_OPEN_CLOSE,
+                    "%s: %d threads %d, nodes %d (ref %d), refs %d, active transactions %d, buffers %d, pages %d\n",
+                    __func__, proc->pid, threads, nodes, incoming_refs,
+                    outgoing_refs, active_transactions, buffers, page_count);
+
+       kfree(proc);
+}
+
+static void binder_deferred_func(struct work_struct *work)
+{
+       struct binder_proc *proc;
+       struct files_struct *files;
+
+       int defer;
+
+       do {
+               binder_lock(__func__);
+               mutex_lock(&binder_deferred_lock);
+               if (!hlist_empty(&binder_deferred_list)) {
+                       proc = hlist_entry(binder_deferred_list.first,
+                                       struct binder_proc, deferred_work_node);
+                       hlist_del_init(&proc->deferred_work_node);
+                       defer = proc->deferred_work;
+                       proc->deferred_work = 0;
+               } else {
+                       proc = NULL;
+                       defer = 0;
+               }
+               mutex_unlock(&binder_deferred_lock);
+
+               files = NULL;
+               if (defer & BINDER_DEFERRED_PUT_FILES) {
+                       files = proc->files;
+                       if (files)
+                               proc->files = NULL;
+               }
+
+               if (defer & BINDER_DEFERRED_FLUSH)
+                       binder_deferred_flush(proc);
+
+               if (defer & BINDER_DEFERRED_RELEASE)
+                       binder_deferred_release(proc); /* frees proc */
+
+               binder_unlock(__func__);
+               if (files)
+                       put_files_struct(files);
+       } while (proc);
+}
+static DECLARE_WORK(binder_deferred_work, binder_deferred_func);
+
+static void
+binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer)
+{
+       mutex_lock(&binder_deferred_lock);
+       proc->deferred_work |= defer;
+       if (hlist_unhashed(&proc->deferred_work_node)) {
+               hlist_add_head(&proc->deferred_work_node,
+                               &binder_deferred_list);
+               queue_work(binder_deferred_workqueue, &binder_deferred_work);
+       }
+       mutex_unlock(&binder_deferred_lock);
+}
+
+static void print_binder_transaction(struct seq_file *m, const char *prefix,
+                                    struct binder_transaction *t)
+{
+       seq_printf(m,
+                  "%s %d: %p from %d:%d to %d:%d code %x flags %x pri %ld r%d",
+                  prefix, t->debug_id, t,
+                  t->from ? t->from->proc->pid : 0,
+                  t->from ? t->from->pid : 0,
+                  t->to_proc ? t->to_proc->pid : 0,
+                  t->to_thread ? t->to_thread->pid : 0,
+                  t->code, t->flags, t->priority, t->need_reply);
+       if (t->buffer == NULL) {
+               seq_puts(m, " buffer free\n");
+               return;
+       }
+       if (t->buffer->target_node)
+               seq_printf(m, " node %d",
+                          t->buffer->target_node->debug_id);
+       seq_printf(m, " size %zd:%zd data %p\n",
+                  t->buffer->data_size, t->buffer->offsets_size,
+                  t->buffer->data);
+}
+
+static void print_binder_buffer(struct seq_file *m, const char *prefix,
+                               struct binder_buffer *buffer)
+{
+       seq_printf(m, "%s %d: %p size %zd:%zd %s\n",
+                  prefix, buffer->debug_id, buffer->data,
+                  buffer->data_size, buffer->offsets_size,
+                  buffer->transaction ? "active" : "delivered");
+}
+
+static void print_binder_work(struct seq_file *m, const char *prefix,
+                             const char *transaction_prefix,
+                             struct binder_work *w)
+{
+       struct binder_node *node;
+       struct binder_transaction *t;
+
+       switch (w->type) {
+       case BINDER_WORK_TRANSACTION:
+               t = container_of(w, struct binder_transaction, work);
+               print_binder_transaction(m, transaction_prefix, t);
+               break;
+       case BINDER_WORK_TRANSACTION_COMPLETE:
+               seq_printf(m, "%stransaction complete\n", prefix);
+               break;
+       case BINDER_WORK_NODE:
+               node = container_of(w, struct binder_node, work);
+               seq_printf(m, "%snode work %d: u%016llx c%016llx\n",
+                          prefix, node->debug_id,
+                          (u64)node->ptr, (u64)node->cookie);
+               break;
+       case BINDER_WORK_DEAD_BINDER:
+               seq_printf(m, "%shas dead binder\n", prefix);
+               break;
+       case BINDER_WORK_DEAD_BINDER_AND_CLEAR:
+               seq_printf(m, "%shas cleared dead binder\n", prefix);
+               break;
+       case BINDER_WORK_CLEAR_DEATH_NOTIFICATION:
+               seq_printf(m, "%shas cleared death notification\n", prefix);
+               break;
+       default:
+               seq_printf(m, "%sunknown work: type %d\n", prefix, w->type);
+               break;
+       }
+}
+
+static void print_binder_thread(struct seq_file *m,
+                               struct binder_thread *thread,
+                               int print_always)
+{
+       struct binder_transaction *t;
+       struct binder_work *w;
+       size_t start_pos = m->count;
+       size_t header_pos;
+
+       seq_printf(m, "  thread %d: l %02x\n", thread->pid, thread->looper);
+       header_pos = m->count;
+       t = thread->transaction_stack;
+       while (t) {
+               if (t->from == thread) {
+                       print_binder_transaction(m,
+                                                "    outgoing transaction", t);
+                       t = t->from_parent;
+               } else if (t->to_thread == thread) {
+                       print_binder_transaction(m,
+                                                "    incoming transaction", t);
+                       t = t->to_parent;
+               } else {
+                       print_binder_transaction(m, "    bad transaction", t);
+                       t = NULL;
+               }
+       }
+       list_for_each_entry(w, &thread->todo, entry) {
+               print_binder_work(m, "    ", "    pending transaction", w);
+       }
+       if (!print_always && m->count == header_pos)
+               m->count = start_pos;
+}
+
+static void print_binder_node(struct seq_file *m, struct binder_node *node)
+{
+       struct binder_ref *ref;
+       struct binder_work *w;
+       int count;
+
+       count = 0;
+       hlist_for_each_entry(ref, &node->refs, node_entry)
+               count++;
+
+       seq_printf(m, "  node %d: u%016llx c%016llx hs %d hw %d ls %d lw %d is %d iw %d",
+                  node->debug_id, (u64)node->ptr, (u64)node->cookie,
+                  node->has_strong_ref, node->has_weak_ref,
+                  node->local_strong_refs, node->local_weak_refs,
+                  node->internal_strong_refs, count);
+       if (count) {
+               seq_puts(m, " proc");
+               hlist_for_each_entry(ref, &node->refs, node_entry)
+                       seq_printf(m, " %d", ref->proc->pid);
+       }
+       seq_puts(m, "\n");
+       list_for_each_entry(w, &node->async_todo, entry)
+               print_binder_work(m, "    ",
+                                 "    pending async transaction", w);
+}
+
+static void print_binder_ref(struct seq_file *m, struct binder_ref *ref)
+{
+       seq_printf(m, "  ref %d: desc %d %snode %d s %d w %d d %p\n",
+                  ref->debug_id, ref->desc, ref->node->proc ? "" : "dead ",
+                  ref->node->debug_id, ref->strong, ref->weak, ref->death);
+}
+
+static void print_binder_proc(struct seq_file *m,
+                             struct binder_proc *proc, int print_all)
+{
+       struct binder_work *w;
+       struct rb_node *n;
+       size_t start_pos = m->count;
+       size_t header_pos;
+
+       seq_printf(m, "proc %d\n", proc->pid);
+       header_pos = m->count;
+
+       for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n))
+               print_binder_thread(m, rb_entry(n, struct binder_thread,
+                                               rb_node), print_all);
+       for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) {
+               struct binder_node *node = rb_entry(n, struct binder_node,
+                                                   rb_node);
+               if (print_all || node->has_async_transaction)
+                       print_binder_node(m, node);
+       }
+       if (print_all) {
+               for (n = rb_first(&proc->refs_by_desc);
+                    n != NULL;
+                    n = rb_next(n))
+                       print_binder_ref(m, rb_entry(n, struct binder_ref,
+                                                    rb_node_desc));
+       }
+       for (n = rb_first(&proc->allocated_buffers); n != NULL; n = rb_next(n))
+               print_binder_buffer(m, "  buffer",
+                                   rb_entry(n, struct binder_buffer, rb_node));
+       list_for_each_entry(w, &proc->todo, entry)
+               print_binder_work(m, "  ", "  pending transaction", w);
+       list_for_each_entry(w, &proc->delivered_death, entry) {
+               seq_puts(m, "  has delivered dead binder\n");
+               break;
+       }
+       if (!print_all && m->count == header_pos)
+               m->count = start_pos;
+}
+
+static const char * const binder_return_strings[] = {
+       "BR_ERROR",
+       "BR_OK",
+       "BR_TRANSACTION",
+       "BR_REPLY",
+       "BR_ACQUIRE_RESULT",
+       "BR_DEAD_REPLY",
+       "BR_TRANSACTION_COMPLETE",
+       "BR_INCREFS",
+       "BR_ACQUIRE",
+       "BR_RELEASE",
+       "BR_DECREFS",
+       "BR_ATTEMPT_ACQUIRE",
+       "BR_NOOP",
+       "BR_SPAWN_LOOPER",
+       "BR_FINISHED",
+       "BR_DEAD_BINDER",
+       "BR_CLEAR_DEATH_NOTIFICATION_DONE",
+       "BR_FAILED_REPLY"
+};
+
+static const char * const binder_command_strings[] = {
+       "BC_TRANSACTION",
+       "BC_REPLY",
+       "BC_ACQUIRE_RESULT",
+       "BC_FREE_BUFFER",
+       "BC_INCREFS",
+       "BC_ACQUIRE",
+       "BC_RELEASE",
+       "BC_DECREFS",
+       "BC_INCREFS_DONE",
+       "BC_ACQUIRE_DONE",
+       "BC_ATTEMPT_ACQUIRE",
+       "BC_REGISTER_LOOPER",
+       "BC_ENTER_LOOPER",
+       "BC_EXIT_LOOPER",
+       "BC_REQUEST_DEATH_NOTIFICATION",
+       "BC_CLEAR_DEATH_NOTIFICATION",
+       "BC_DEAD_BINDER_DONE"
+};
+
+static const char * const binder_objstat_strings[] = {
+       "proc",
+       "thread",
+       "node",
+       "ref",
+       "death",
+       "transaction",
+       "transaction_complete"
+};
+
+static void print_binder_stats(struct seq_file *m, const char *prefix,
+                              struct binder_stats *stats)
+{
+       int i;
+
+       BUILD_BUG_ON(ARRAY_SIZE(stats->bc) !=
+                    ARRAY_SIZE(binder_command_strings));
+       for (i = 0; i < ARRAY_SIZE(stats->bc); i++) {
+               if (stats->bc[i])
+                       seq_printf(m, "%s%s: %d\n", prefix,
+                                  binder_command_strings[i], stats->bc[i]);
+       }
+
+       BUILD_BUG_ON(ARRAY_SIZE(stats->br) !=
+                    ARRAY_SIZE(binder_return_strings));
+       for (i = 0; i < ARRAY_SIZE(stats->br); i++) {
+               if (stats->br[i])
+                       seq_printf(m, "%s%s: %d\n", prefix,
+                                  binder_return_strings[i], stats->br[i]);
+       }
+
+       BUILD_BUG_ON(ARRAY_SIZE(stats->obj_created) !=
+                    ARRAY_SIZE(binder_objstat_strings));
+       BUILD_BUG_ON(ARRAY_SIZE(stats->obj_created) !=
+                    ARRAY_SIZE(stats->obj_deleted));
+       for (i = 0; i < ARRAY_SIZE(stats->obj_created); i++) {
+               if (stats->obj_created[i] || stats->obj_deleted[i])
+                       seq_printf(m, "%s%s: active %d total %d\n", prefix,
+                               binder_objstat_strings[i],
+                               stats->obj_created[i] - stats->obj_deleted[i],
+                               stats->obj_created[i]);
+       }
+}
+
+static void print_binder_proc_stats(struct seq_file *m,
+                                   struct binder_proc *proc)
+{
+       struct binder_work *w;
+       struct rb_node *n;
+       int count, strong, weak;
+
+       seq_printf(m, "proc %d\n", proc->pid);
+       count = 0;
+       for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n))
+               count++;
+       seq_printf(m, "  threads: %d\n", count);
+       seq_printf(m, "  requested threads: %d+%d/%d\n"
+                       "  ready threads %d\n"
+                       "  free async space %zd\n", proc->requested_threads,
+                       proc->requested_threads_started, proc->max_threads,
+                       proc->ready_threads, proc->free_async_space);
+       count = 0;
+       for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n))
+               count++;
+       seq_printf(m, "  nodes: %d\n", count);
+       count = 0;
+       strong = 0;
+       weak = 0;
+       for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) {
+               struct binder_ref *ref = rb_entry(n, struct binder_ref,
+                                                 rb_node_desc);
+               count++;
+               strong += ref->strong;
+               weak += ref->weak;
+       }
+       seq_printf(m, "  refs: %d s %d w %d\n", count, strong, weak);
+
+       count = 0;
+       for (n = rb_first(&proc->allocated_buffers); n != NULL; n = rb_next(n))
+               count++;
+       seq_printf(m, "  buffers: %d\n", count);
+
+       count = 0;
+       list_for_each_entry(w, &proc->todo, entry) {
+               switch (w->type) {
+               case BINDER_WORK_TRANSACTION:
+                       count++;
+                       break;
+               default:
+                       break;
+               }
+       }
+       seq_printf(m, "  pending transactions: %d\n", count);
+
+       print_binder_stats(m, "  ", &proc->stats);
+}
+
+
+static int binder_state_show(struct seq_file *m, void *unused)
+{
+       struct binder_proc *proc;
+       struct binder_node *node;
+       int do_lock = !binder_debug_no_lock;
+
+       if (do_lock)
+               binder_lock(__func__);
+
+       seq_puts(m, "binder state:\n");
+
+       if (!hlist_empty(&binder_dead_nodes))
+               seq_puts(m, "dead nodes:\n");
+       hlist_for_each_entry(node, &binder_dead_nodes, dead_node)
+               print_binder_node(m, node);
+
+       hlist_for_each_entry(proc, &binder_procs, proc_node)
+               print_binder_proc(m, proc, 1);
+       if (do_lock)
+               binder_unlock(__func__);
+       return 0;
+}
+
+static int binder_stats_show(struct seq_file *m, void *unused)
+{
+       struct binder_proc *proc;
+       int do_lock = !binder_debug_no_lock;
+
+       if (do_lock)
+               binder_lock(__func__);
+
+       seq_puts(m, "binder stats:\n");
+
+       print_binder_stats(m, "", &binder_stats);
+
+       hlist_for_each_entry(proc, &binder_procs, proc_node)
+               print_binder_proc_stats(m, proc);
+       if (do_lock)
+               binder_unlock(__func__);
+       return 0;
+}
+
+static int binder_transactions_show(struct seq_file *m, void *unused)
+{
+       struct binder_proc *proc;
+       int do_lock = !binder_debug_no_lock;
+
+       if (do_lock)
+               binder_lock(__func__);
+
+       seq_puts(m, "binder transactions:\n");
+       hlist_for_each_entry(proc, &binder_procs, proc_node)
+               print_binder_proc(m, proc, 0);
+       if (do_lock)
+               binder_unlock(__func__);
+       return 0;
+}
+
+static int binder_proc_show(struct seq_file *m, void *unused)
+{
+       struct binder_proc *proc = m->private;
+       int do_lock = !binder_debug_no_lock;
+
+       if (do_lock)
+               binder_lock(__func__);
+       seq_puts(m, "binder proc state:\n");
+       print_binder_proc(m, proc, 1);
+       if (do_lock)
+               binder_unlock(__func__);
+       return 0;
+}
+
+static void print_binder_transaction_log_entry(struct seq_file *m,
+                                       struct binder_transaction_log_entry *e)
+{
+       seq_printf(m,
+                  "%d: %s from %d:%d to %d:%d node %d handle %d size %d:%d\n",
+                  e->debug_id, (e->call_type == 2) ? "reply" :
+                  ((e->call_type == 1) ? "async" : "call "), e->from_proc,
+                  e->from_thread, e->to_proc, e->to_thread, e->to_node,
+                  e->target_handle, e->data_size, e->offsets_size);
+}
+
+static int binder_transaction_log_show(struct seq_file *m, void *unused)
+{
+       struct binder_transaction_log *log = m->private;
+       int i;
+
+       if (log->full) {
+               for (i = log->next; i < ARRAY_SIZE(log->entry); i++)
+                       print_binder_transaction_log_entry(m, &log->entry[i]);
+       }
+       for (i = 0; i < log->next; i++)
+               print_binder_transaction_log_entry(m, &log->entry[i]);
+       return 0;
+}
+
+static const struct file_operations binder_fops = {
+       .owner = THIS_MODULE,
+       .poll = binder_poll,
+       .unlocked_ioctl = binder_ioctl,
+       .compat_ioctl = binder_ioctl,
+       .mmap = binder_mmap,
+       .open = binder_open,
+       .flush = binder_flush,
+       .release = binder_release,
+};
+
+static struct miscdevice binder_miscdev = {
+       .minor = MISC_DYNAMIC_MINOR,
+       .name = "binder",
+       .fops = &binder_fops
+};
+
+BINDER_DEBUG_ENTRY(state);
+BINDER_DEBUG_ENTRY(stats);
+BINDER_DEBUG_ENTRY(transactions);
+BINDER_DEBUG_ENTRY(transaction_log);
+
+static int __init binder_init(void)
+{
+       int ret;
+
+       binder_deferred_workqueue = create_singlethread_workqueue("binder");
+       if (!binder_deferred_workqueue)
+               return -ENOMEM;
+
+       binder_debugfs_dir_entry_root = debugfs_create_dir("binder", NULL);
+       if (binder_debugfs_dir_entry_root)
+               binder_debugfs_dir_entry_proc = debugfs_create_dir("proc",
+                                                binder_debugfs_dir_entry_root);
+       ret = misc_register(&binder_miscdev);
+       if (binder_debugfs_dir_entry_root) {
+               debugfs_create_file("state",
+                                   S_IRUGO,
+                                   binder_debugfs_dir_entry_root,
+                                   NULL,
+                                   &binder_state_fops);
+               debugfs_create_file("stats",
+                                   S_IRUGO,
+                                   binder_debugfs_dir_entry_root,
+                                   NULL,
+                                   &binder_stats_fops);
+               debugfs_create_file("transactions",
+                                   S_IRUGO,
+                                   binder_debugfs_dir_entry_root,
+                                   NULL,
+                                   &binder_transactions_fops);
+               debugfs_create_file("transaction_log",
+                                   S_IRUGO,
+                                   binder_debugfs_dir_entry_root,
+                                   &binder_transaction_log,
+                                   &binder_transaction_log_fops);
+               debugfs_create_file("failed_transaction_log",
+                                   S_IRUGO,
+                                   binder_debugfs_dir_entry_root,
+                                   &binder_transaction_log_failed,
+                                   &binder_transaction_log_fops);
+       }
+       return ret;
+}
+
+device_initcall(binder_init);
+
+#define CREATE_TRACE_POINTS
+#include "binder_trace.h"
+
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/android/binder_trace.h b/drivers/android/binder_trace.h
new file mode 100644 (file)
index 0000000..7f20f3d
--- /dev/null
@@ -0,0 +1,329 @@
+/*
+ * Copyright (C) 2012 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.
+ *
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM binder
+
+#if !defined(_BINDER_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _BINDER_TRACE_H
+
+#include <linux/tracepoint.h>
+
+struct binder_buffer;
+struct binder_node;
+struct binder_proc;
+struct binder_ref;
+struct binder_thread;
+struct binder_transaction;
+
+TRACE_EVENT(binder_ioctl,
+       TP_PROTO(unsigned int cmd, unsigned long arg),
+       TP_ARGS(cmd, arg),
+
+       TP_STRUCT__entry(
+               __field(unsigned int, cmd)
+               __field(unsigned long, arg)
+       ),
+       TP_fast_assign(
+               __entry->cmd = cmd;
+               __entry->arg = arg;
+       ),
+       TP_printk("cmd=0x%x arg=0x%lx", __entry->cmd, __entry->arg)
+);
+
+DECLARE_EVENT_CLASS(binder_lock_class,
+       TP_PROTO(const char *tag),
+       TP_ARGS(tag),
+       TP_STRUCT__entry(
+               __field(const char *, tag)
+       ),
+       TP_fast_assign(
+               __entry->tag = tag;
+       ),
+       TP_printk("tag=%s", __entry->tag)
+);
+
+#define DEFINE_BINDER_LOCK_EVENT(name) \
+DEFINE_EVENT(binder_lock_class, name,  \
+       TP_PROTO(const char *func), \
+       TP_ARGS(func))
+
+DEFINE_BINDER_LOCK_EVENT(binder_lock);
+DEFINE_BINDER_LOCK_EVENT(binder_locked);
+DEFINE_BINDER_LOCK_EVENT(binder_unlock);
+
+DECLARE_EVENT_CLASS(binder_function_return_class,
+       TP_PROTO(int ret),
+       TP_ARGS(ret),
+       TP_STRUCT__entry(
+               __field(int, ret)
+       ),
+       TP_fast_assign(
+               __entry->ret = ret;
+       ),
+       TP_printk("ret=%d", __entry->ret)
+);
+
+#define DEFINE_BINDER_FUNCTION_RETURN_EVENT(name)      \
+DEFINE_EVENT(binder_function_return_class, name,       \
+       TP_PROTO(int ret), \
+       TP_ARGS(ret))
+
+DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_ioctl_done);
+DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_write_done);
+DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_read_done);
+
+TRACE_EVENT(binder_wait_for_work,
+       TP_PROTO(bool proc_work, bool transaction_stack, bool thread_todo),
+       TP_ARGS(proc_work, transaction_stack, thread_todo),
+
+       TP_STRUCT__entry(
+               __field(bool, proc_work)
+               __field(bool, transaction_stack)
+               __field(bool, thread_todo)
+       ),
+       TP_fast_assign(
+               __entry->proc_work = proc_work;
+               __entry->transaction_stack = transaction_stack;
+               __entry->thread_todo = thread_todo;
+       ),
+       TP_printk("proc_work=%d transaction_stack=%d thread_todo=%d",
+                 __entry->proc_work, __entry->transaction_stack,
+                 __entry->thread_todo)
+);
+
+TRACE_EVENT(binder_transaction,
+       TP_PROTO(bool reply, struct binder_transaction *t,
+                struct binder_node *target_node),
+       TP_ARGS(reply, t, target_node),
+       TP_STRUCT__entry(
+               __field(int, debug_id)
+               __field(int, target_node)
+               __field(int, to_proc)
+               __field(int, to_thread)
+               __field(int, reply)
+               __field(unsigned int, code)
+               __field(unsigned int, flags)
+       ),
+       TP_fast_assign(
+               __entry->debug_id = t->debug_id;
+               __entry->target_node = target_node ? target_node->debug_id : 0;
+               __entry->to_proc = t->to_proc->pid;
+               __entry->to_thread = t->to_thread ? t->to_thread->pid : 0;
+               __entry->reply = reply;
+               __entry->code = t->code;
+               __entry->flags = t->flags;
+       ),
+       TP_printk("transaction=%d dest_node=%d dest_proc=%d dest_thread=%d reply=%d flags=0x%x code=0x%x",
+                 __entry->debug_id, __entry->target_node,
+                 __entry->to_proc, __entry->to_thread,
+                 __entry->reply, __entry->flags, __entry->code)
+);
+
+TRACE_EVENT(binder_transaction_received,
+       TP_PROTO(struct binder_transaction *t),
+       TP_ARGS(t),
+
+       TP_STRUCT__entry(
+               __field(int, debug_id)
+       ),
+       TP_fast_assign(
+               __entry->debug_id = t->debug_id;
+       ),
+       TP_printk("transaction=%d", __entry->debug_id)
+);
+
+TRACE_EVENT(binder_transaction_node_to_ref,
+       TP_PROTO(struct binder_transaction *t, struct binder_node *node,
+                struct binder_ref *ref),
+       TP_ARGS(t, node, ref),
+
+       TP_STRUCT__entry(
+               __field(int, debug_id)
+               __field(int, node_debug_id)
+               __field(binder_uintptr_t, node_ptr)
+               __field(int, ref_debug_id)
+               __field(uint32_t, ref_desc)
+       ),
+       TP_fast_assign(
+               __entry->debug_id = t->debug_id;
+               __entry->node_debug_id = node->debug_id;
+               __entry->node_ptr = node->ptr;
+               __entry->ref_debug_id = ref->debug_id;
+               __entry->ref_desc = ref->desc;
+       ),
+       TP_printk("transaction=%d node=%d src_ptr=0x%016llx ==> dest_ref=%d dest_desc=%d",
+                 __entry->debug_id, __entry->node_debug_id,
+                 (u64)__entry->node_ptr,
+                 __entry->ref_debug_id, __entry->ref_desc)
+);
+
+TRACE_EVENT(binder_transaction_ref_to_node,
+       TP_PROTO(struct binder_transaction *t, struct binder_ref *ref),
+       TP_ARGS(t, ref),
+
+       TP_STRUCT__entry(
+               __field(int, debug_id)
+               __field(int, ref_debug_id)
+               __field(uint32_t, ref_desc)
+               __field(int, node_debug_id)
+               __field(binder_uintptr_t, node_ptr)
+       ),
+       TP_fast_assign(
+               __entry->debug_id = t->debug_id;
+               __entry->ref_debug_id = ref->debug_id;
+               __entry->ref_desc = ref->desc;
+               __entry->node_debug_id = ref->node->debug_id;
+               __entry->node_ptr = ref->node->ptr;
+       ),
+       TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ptr=0x%016llx",
+                 __entry->debug_id, __entry->node_debug_id,
+                 __entry->ref_debug_id, __entry->ref_desc,
+                 (u64)__entry->node_ptr)
+);
+
+TRACE_EVENT(binder_transaction_ref_to_ref,
+       TP_PROTO(struct binder_transaction *t, struct binder_ref *src_ref,
+                struct binder_ref *dest_ref),
+       TP_ARGS(t, src_ref, dest_ref),
+
+       TP_STRUCT__entry(
+               __field(int, debug_id)
+               __field(int, node_debug_id)
+               __field(int, src_ref_debug_id)
+               __field(uint32_t, src_ref_desc)
+               __field(int, dest_ref_debug_id)
+               __field(uint32_t, dest_ref_desc)
+       ),
+       TP_fast_assign(
+               __entry->debug_id = t->debug_id;
+               __entry->node_debug_id = src_ref->node->debug_id;
+               __entry->src_ref_debug_id = src_ref->debug_id;
+               __entry->src_ref_desc = src_ref->desc;
+               __entry->dest_ref_debug_id = dest_ref->debug_id;
+               __entry->dest_ref_desc = dest_ref->desc;
+       ),
+       TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ref=%d dest_desc=%d",
+                 __entry->debug_id, __entry->node_debug_id,
+                 __entry->src_ref_debug_id, __entry->src_ref_desc,
+                 __entry->dest_ref_debug_id, __entry->dest_ref_desc)
+);
+
+TRACE_EVENT(binder_transaction_fd,
+       TP_PROTO(struct binder_transaction *t, int src_fd, int dest_fd),
+       TP_ARGS(t, src_fd, dest_fd),
+
+       TP_STRUCT__entry(
+               __field(int, debug_id)
+               __field(int, src_fd)
+               __field(int, dest_fd)
+       ),
+       TP_fast_assign(
+               __entry->debug_id = t->debug_id;
+               __entry->src_fd = src_fd;
+               __entry->dest_fd = dest_fd;
+       ),
+       TP_printk("transaction=%d src_fd=%d ==> dest_fd=%d",
+                 __entry->debug_id, __entry->src_fd, __entry->dest_fd)
+);
+
+DECLARE_EVENT_CLASS(binder_buffer_class,
+       TP_PROTO(struct binder_buffer *buf),
+       TP_ARGS(buf),
+       TP_STRUCT__entry(
+               __field(int, debug_id)
+               __field(size_t, data_size)
+               __field(size_t, offsets_size)
+       ),
+       TP_fast_assign(
+               __entry->debug_id = buf->debug_id;
+               __entry->data_size = buf->data_size;
+               __entry->offsets_size = buf->offsets_size;
+       ),
+       TP_printk("transaction=%d data_size=%zd offsets_size=%zd",
+                 __entry->debug_id, __entry->data_size, __entry->offsets_size)
+);
+
+DEFINE_EVENT(binder_buffer_class, binder_transaction_alloc_buf,
+       TP_PROTO(struct binder_buffer *buffer),
+       TP_ARGS(buffer));
+
+DEFINE_EVENT(binder_buffer_class, binder_transaction_buffer_release,
+       TP_PROTO(struct binder_buffer *buffer),
+       TP_ARGS(buffer));
+
+DEFINE_EVENT(binder_buffer_class, binder_transaction_failed_buffer_release,
+       TP_PROTO(struct binder_buffer *buffer),
+       TP_ARGS(buffer));
+
+TRACE_EVENT(binder_update_page_range,
+       TP_PROTO(struct binder_proc *proc, bool allocate,
+                void *start, void *end),
+       TP_ARGS(proc, allocate, start, end),
+       TP_STRUCT__entry(
+               __field(int, proc)
+               __field(bool, allocate)
+               __field(size_t, offset)
+               __field(size_t, size)
+       ),
+       TP_fast_assign(
+               __entry->proc = proc->pid;
+               __entry->allocate = allocate;
+               __entry->offset = start - proc->buffer;
+               __entry->size = end - start;
+       ),
+       TP_printk("proc=%d allocate=%d offset=%zu size=%zu",
+                 __entry->proc, __entry->allocate,
+                 __entry->offset, __entry->size)
+);
+
+TRACE_EVENT(binder_command,
+       TP_PROTO(uint32_t cmd),
+       TP_ARGS(cmd),
+       TP_STRUCT__entry(
+               __field(uint32_t, cmd)
+       ),
+       TP_fast_assign(
+               __entry->cmd = cmd;
+       ),
+       TP_printk("cmd=0x%x %s",
+                 __entry->cmd,
+                 _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_command_strings) ?
+                         binder_command_strings[_IOC_NR(__entry->cmd)] :
+                         "unknown")
+);
+
+TRACE_EVENT(binder_return,
+       TP_PROTO(uint32_t cmd),
+       TP_ARGS(cmd),
+       TP_STRUCT__entry(
+               __field(uint32_t, cmd)
+       ),
+       TP_fast_assign(
+               __entry->cmd = cmd;
+       ),
+       TP_printk("cmd=0x%x %s",
+                 __entry->cmd,
+                 _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_return_strings) ?
+                         binder_return_strings[_IOC_NR(__entry->cmd)] :
+                         "unknown")
+);
+
+#endif /* _BINDER_TRACE_H */
+
+#undef TRACE_INCLUDE_PATH
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_PATH .
+#define TRACE_INCLUDE_FILE binder_trace
+#include <trace/define_trace.h>
index 4690ae9..3b01fef 100644 (file)
@@ -62,8 +62,6 @@ source "drivers/staging/xgifb/Kconfig"
 
 source "drivers/staging/emxx_udc/Kconfig"
 
-source "drivers/staging/bcm/Kconfig"
-
 source "drivers/staging/ft1000/Kconfig"
 
 source "drivers/staging/speakup/Kconfig"
@@ -108,4 +106,6 @@ source "drivers/staging/skein/Kconfig"
 
 source "drivers/staging/unisys/Kconfig"
 
+source "drivers/staging/clocking-wizard/Kconfig"
+
 endif # STAGING
index c780a0e..26ecead 100644 (file)
@@ -25,7 +25,6 @@ obj-$(CONFIG_VME_BUS)         += vme/
 obj-$(CONFIG_IIO)              += iio/
 obj-$(CONFIG_FB_XGI)           += xgifb/
 obj-$(CONFIG_USB_EMXX)         += emxx_udc/
-obj-$(CONFIG_BCM_WIMAX)                += bcm/
 obj-$(CONFIG_FT1000)           += ft1000/
 obj-$(CONFIG_SPEAKUP)          += speakup/
 obj-$(CONFIG_TOUCHSCREEN_CLEARPAD_TM1217)      += cptm1217/
@@ -46,3 +45,4 @@ obj-$(CONFIG_MTD_SPINAND_MT29F)       += mt29f_spinand/
 obj-$(CONFIG_GS_FPGABOOT)      += gs_fpgaboot/
 obj-$(CONFIG_CRYPTO_SKEIN)     += skein/
 obj-$(CONFIG_UNISYSSPAR)       += unisys/
+obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD)  += clocking-wizard/
index 7a0e288..7e012f3 100644 (file)
@@ -1,37 +1,7 @@
 menu "Android"
 
-config ANDROID
-       bool "Android Drivers"
-       ---help---
-         Enable support for various drivers needed on the Android platform
-
 if ANDROID
 
-config ANDROID_BINDER_IPC
-       bool "Android Binder IPC Driver"
-       depends on MMU
-       default n
-       ---help---
-         Binder is used in Android for both communication between processes,
-         and remote method invocation.
-
-         This means one Android process can call a method/routine in another
-         Android process, using Binder to identify, invoke and pass arguments
-         between said processes.
-
-config ANDROID_BINDER_IPC_32BIT
-       bool
-       depends on !64BIT && ANDROID_BINDER_IPC
-       default y
-       ---help---
-         The Binder API has been changed to support both 32 and 64bit
-         applications in a mixed environment.
-
-         Enable this to support an old 32-bit Android user-space (v4.4 and
-         earlier).
-
-         Note that enabling this will break newer Android user-space.
-
 config ASHMEM
        bool "Enable the Anonymous Shared Memory Subsystem"
        default n
index 517ad5f..479b2b8 100644 (file)
@@ -2,7 +2,6 @@ ccflags-y += -I$(src)                   # needed for trace events
 
 obj-y                                  += ion/
 
-obj-$(CONFIG_ANDROID_BINDER_IPC)       += binder.o
 obj-$(CONFIG_ASHMEM)                   += ashmem.o
 obj-$(CONFIG_ANDROID_LOGGER)           += logger.o
 obj-$(CONFIG_ANDROID_TIMED_OUTPUT)     += timed_output.o
diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
deleted file mode 100644 (file)
index c69c40d..0000000
+++ /dev/null
@@ -1,3673 +0,0 @@
-/* binder.c
- *
- * Android IPC Subsystem
- *
- * Copyright (C) 2007-2008 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.
- *
- */
-
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <asm/cacheflush.h>
-#include <linux/fdtable.h>
-#include <linux/file.h>
-#include <linux/freezer.h>
-#include <linux/fs.h>
-#include <linux/list.h>
-#include <linux/miscdevice.h>
-#include <linux/mm.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/nsproxy.h>
-#include <linux/poll.h>
-#include <linux/debugfs.h>
-#include <linux/rbtree.h>
-#include <linux/sched.h>
-#include <linux/seq_file.h>
-#include <linux/uaccess.h>
-#include <linux/vmalloc.h>
-#include <linux/slab.h>
-#include <linux/pid_namespace.h>
-
-#include "binder.h"
-#include "binder_trace.h"
-
-static DEFINE_MUTEX(binder_main_lock);
-static DEFINE_MUTEX(binder_deferred_lock);
-static DEFINE_MUTEX(binder_mmap_lock);
-
-static HLIST_HEAD(binder_procs);
-static HLIST_HEAD(binder_deferred_list);
-static HLIST_HEAD(binder_dead_nodes);
-
-static struct dentry *binder_debugfs_dir_entry_root;
-static struct dentry *binder_debugfs_dir_entry_proc;
-static struct binder_node *binder_context_mgr_node;
-static kuid_t binder_context_mgr_uid = INVALID_UID;
-static int binder_last_id;
-static struct workqueue_struct *binder_deferred_workqueue;
-
-#define BINDER_DEBUG_ENTRY(name) \
-static int binder_##name##_open(struct inode *inode, struct file *file) \
-{ \
-       return single_open(file, binder_##name##_show, inode->i_private); \
-} \
-\
-static const struct file_operations binder_##name##_fops = { \
-       .owner = THIS_MODULE, \
-       .open = binder_##name##_open, \
-       .read = seq_read, \
-       .llseek = seq_lseek, \
-       .release = single_release, \
-}
-
-static int binder_proc_show(struct seq_file *m, void *unused);
-BINDER_DEBUG_ENTRY(proc);
-
-/* This is only defined in include/asm-arm/sizes.h */
-#ifndef SZ_1K
-#define SZ_1K                               0x400
-#endif
-
-#ifndef SZ_4M
-#define SZ_4M                               0x400000
-#endif
-
-#define FORBIDDEN_MMAP_FLAGS                (VM_WRITE)
-
-#define BINDER_SMALL_BUF_SIZE (PAGE_SIZE * 64)
-
-enum {
-       BINDER_DEBUG_USER_ERROR             = 1U << 0,
-       BINDER_DEBUG_FAILED_TRANSACTION     = 1U << 1,
-       BINDER_DEBUG_DEAD_TRANSACTION       = 1U << 2,
-       BINDER_DEBUG_OPEN_CLOSE             = 1U << 3,
-       BINDER_DEBUG_DEAD_BINDER            = 1U << 4,
-       BINDER_DEBUG_DEATH_NOTIFICATION     = 1U << 5,
-       BINDER_DEBUG_READ_WRITE             = 1U << 6,
-       BINDER_DEBUG_USER_REFS              = 1U << 7,
-       BINDER_DEBUG_THREADS                = 1U << 8,
-       BINDER_DEBUG_TRANSACTION            = 1U << 9,
-       BINDER_DEBUG_TRANSACTION_COMPLETE   = 1U << 10,
-       BINDER_DEBUG_FREE_BUFFER            = 1U << 11,
-       BINDER_DEBUG_INTERNAL_REFS          = 1U << 12,
-       BINDER_DEBUG_BUFFER_ALLOC           = 1U << 13,
-       BINDER_DEBUG_PRIORITY_CAP           = 1U << 14,
-       BINDER_DEBUG_BUFFER_ALLOC_ASYNC     = 1U << 15,
-};
-static uint32_t binder_debug_mask = BINDER_DEBUG_USER_ERROR |
-       BINDER_DEBUG_FAILED_TRANSACTION | BINDER_DEBUG_DEAD_TRANSACTION;
-module_param_named(debug_mask, binder_debug_mask, uint, S_IWUSR | S_IRUGO);
-
-static bool binder_debug_no_lock;
-module_param_named(proc_no_lock, binder_debug_no_lock, bool, S_IWUSR | S_IRUGO);
-
-static DECLARE_WAIT_QUEUE_HEAD(binder_user_error_wait);
-static int binder_stop_on_user_error;
-
-static int binder_set_stop_on_user_error(const char *val,
-                                        struct kernel_param *kp)
-{
-       int ret;
-
-       ret = param_set_int(val, kp);
-       if (binder_stop_on_user_error < 2)
-               wake_up(&binder_user_error_wait);
-       return ret;
-}
-module_param_call(stop_on_user_error, binder_set_stop_on_user_error,
-       param_get_int, &binder_stop_on_user_error, S_IWUSR | S_IRUGO);
-
-#define binder_debug(mask, x...) \
-       do { \
-               if (binder_debug_mask & mask) \
-                       pr_info(x); \
-       } while (0)
-
-#define binder_user_error(x...) \
-       do { \
-               if (binder_debug_mask & BINDER_DEBUG_USER_ERROR) \
-                       pr_info(x); \
-               if (binder_stop_on_user_error) \
-                       binder_stop_on_user_error = 2; \
-       } while (0)
-
-enum binder_stat_types {
-       BINDER_STAT_PROC,
-       BINDER_STAT_THREAD,
-       BINDER_STAT_NODE,
-       BINDER_STAT_REF,
-       BINDER_STAT_DEATH,
-       BINDER_STAT_TRANSACTION,
-       BINDER_STAT_TRANSACTION_COMPLETE,
-       BINDER_STAT_COUNT
-};
-
-struct binder_stats {
-       int br[_IOC_NR(BR_FAILED_REPLY) + 1];
-       int bc[_IOC_NR(BC_DEAD_BINDER_DONE) + 1];
-       int obj_created[BINDER_STAT_COUNT];
-       int obj_deleted[BINDER_STAT_COUNT];
-};
-
-static struct binder_stats binder_stats;
-
-static inline void binder_stats_deleted(enum binder_stat_types type)
-{
-       binder_stats.obj_deleted[type]++;
-}
-
-static inline void binder_stats_created(enum binder_stat_types type)
-{
-       binder_stats.obj_created[type]++;
-}
-
-struct binder_transaction_log_entry {
-       int debug_id;
-       int call_type;
-       int from_proc;
-       int from_thread;
-       int target_handle;
-       int to_proc;
-       int to_thread;
-       int to_node;
-       int data_size;
-       int offsets_size;
-};
-struct binder_transaction_log {
-       int next;
-       int full;
-       struct binder_transaction_log_entry entry[32];
-};
-static struct binder_transaction_log binder_transaction_log;
-static struct binder_transaction_log binder_transaction_log_failed;
-
-static struct binder_transaction_log_entry *binder_transaction_log_add(
-       struct binder_transaction_log *log)
-{
-       struct binder_transaction_log_entry *e;
-
-       e = &log->entry[log->next];
-       memset(e, 0, sizeof(*e));
-       log->next++;
-       if (log->next == ARRAY_SIZE(log->entry)) {
-               log->next = 0;
-               log->full = 1;
-       }
-       return e;
-}
-
-struct binder_work {
-       struct list_head entry;
-       enum {
-               BINDER_WORK_TRANSACTION = 1,
-               BINDER_WORK_TRANSACTION_COMPLETE,
-               BINDER_WORK_NODE,
-               BINDER_WORK_DEAD_BINDER,
-               BINDER_WORK_DEAD_BINDER_AND_CLEAR,
-               BINDER_WORK_CLEAR_DEATH_NOTIFICATION,
-       } type;
-};
-
-struct binder_node {
-       int debug_id;
-       struct binder_work work;
-       union {
-               struct rb_node rb_node;
-               struct hlist_node dead_node;
-       };
-       struct binder_proc *proc;
-       struct hlist_head refs;
-       int internal_strong_refs;
-       int local_weak_refs;
-       int local_strong_refs;
-       binder_uintptr_t ptr;
-       binder_uintptr_t cookie;
-       unsigned has_strong_ref:1;
-       unsigned pending_strong_ref:1;
-       unsigned has_weak_ref:1;
-       unsigned pending_weak_ref:1;
-       unsigned has_async_transaction:1;
-       unsigned accept_fds:1;
-       unsigned min_priority:8;
-       struct list_head async_todo;
-};
-
-struct binder_ref_death {
-       struct binder_work work;
-       binder_uintptr_t cookie;
-};
-
-struct binder_ref {
-       /* Lookups needed: */
-       /*   node + proc => ref (transaction) */
-       /*   desc + proc => ref (transaction, inc/dec ref) */
-       /*   node => refs + procs (proc exit) */
-       int debug_id;
-       struct rb_node rb_node_desc;
-       struct rb_node rb_node_node;
-       struct hlist_node node_entry;
-       struct binder_proc *proc;
-       struct binder_node *node;
-       uint32_t desc;
-       int strong;
-       int weak;
-       struct binder_ref_death *death;
-};
-
-struct binder_buffer {
-       struct list_head entry; /* free and allocated entries by address */
-       struct rb_node rb_node; /* free entry by size or allocated entry */
-                               /* by address */
-       unsigned free:1;
-       unsigned allow_user_free:1;
-       unsigned async_transaction:1;
-       unsigned debug_id:29;
-
-       struct binder_transaction *transaction;
-
-       struct binder_node *target_node;
-       size_t data_size;
-       size_t offsets_size;
-       uint8_t data[0];
-};
-
-enum binder_deferred_state {
-       BINDER_DEFERRED_PUT_FILES    = 0x01,
-       BINDER_DEFERRED_FLUSH        = 0x02,
-       BINDER_DEFERRED_RELEASE      = 0x04,
-};
-
-struct binder_proc {
-       struct hlist_node proc_node;
-       struct rb_root threads;
-       struct rb_root nodes;
-       struct rb_root refs_by_desc;
-       struct rb_root refs_by_node;
-       int pid;
-       struct vm_area_struct *vma;
-       struct mm_struct *vma_vm_mm;
-       struct task_struct *tsk;
-       struct files_struct *files;
-       struct hlist_node deferred_work_node;
-       int deferred_work;
-       void *buffer;
-       ptrdiff_t user_buffer_offset;
-
-       struct list_head buffers;
-       struct rb_root free_buffers;
-       struct rb_root allocated_buffers;
-       size_t free_async_space;
-
-       struct page **pages;
-       size_t buffer_size;
-       uint32_t buffer_free;
-       struct list_head todo;
-       wait_queue_head_t wait;
-       struct binder_stats stats;
-       struct list_head delivered_death;
-       int max_threads;
-       int requested_threads;
-       int requested_threads_started;
-       int ready_threads;
-       long default_priority;
-       struct dentry *debugfs_entry;
-};
-
-enum {
-       BINDER_LOOPER_STATE_REGISTERED  = 0x01,
-       BINDER_LOOPER_STATE_ENTERED     = 0x02,
-       BINDER_LOOPER_STATE_EXITED      = 0x04,
-       BINDER_LOOPER_STATE_INVALID     = 0x08,
-       BINDER_LOOPER_STATE_WAITING     = 0x10,
-       BINDER_LOOPER_STATE_NEED_RETURN = 0x20
-};
-
-struct binder_thread {
-       struct binder_proc *proc;
-       struct rb_node rb_node;
-       int pid;
-       int looper;
-       struct binder_transaction *transaction_stack;
-       struct list_head todo;
-       uint32_t return_error; /* Write failed, return error code in read buf */
-       uint32_t return_error2; /* Write failed, return error code in read */
-               /* buffer. Used when sending a reply to a dead process that */
-               /* we are also waiting on */
-       wait_queue_head_t wait;
-       struct binder_stats stats;
-};
-
-struct binder_transaction {
-       int debug_id;
-       struct binder_work work;
-       struct binder_thread *from;
-       struct binder_transaction *from_parent;
-       struct binder_proc *to_proc;
-       struct binder_thread *to_thread;
-       struct binder_transaction *to_parent;
-       unsigned need_reply:1;
-       /* unsigned is_dead:1; */       /* not used at the moment */
-
-       struct binder_buffer *buffer;
-       unsigned int    code;
-       unsigned int    flags;
-       long    priority;
-       long    saved_priority;
-       kuid_t  sender_euid;
-};
-
-static void
-binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer);
-
-static int task_get_unused_fd_flags(struct binder_proc *proc, int flags)
-{
-       struct files_struct *files = proc->files;
-       unsigned long rlim_cur;
-       unsigned long irqs;
-
-       if (files == NULL)
-               return -ESRCH;
-
-       if (!lock_task_sighand(proc->tsk, &irqs))
-               return -EMFILE;
-
-       rlim_cur = task_rlimit(proc->tsk, RLIMIT_NOFILE);
-       unlock_task_sighand(proc->tsk, &irqs);
-
-       return __alloc_fd(files, 0, rlim_cur, flags);
-}
-
-/*
- * copied from fd_install
- */
-static void task_fd_install(
-       struct binder_proc *proc, unsigned int fd, struct file *file)
-{
-       if (proc->files)
-               __fd_install(proc->files, fd, file);
-}
-
-/*
- * copied from sys_close
- */
-static long task_close_fd(struct binder_proc *proc, unsigned int fd)
-{
-       int retval;
-
-       if (proc->files == NULL)
-               return -ESRCH;
-
-       retval = __close_fd(proc->files, fd);
-       /* can't restart close syscall because file table entry was cleared */
-       if (unlikely(retval == -ERESTARTSYS ||
-                    retval == -ERESTARTNOINTR ||
-                    retval == -ERESTARTNOHAND ||
-                    retval == -ERESTART_RESTARTBLOCK))
-               retval = -EINTR;
-
-       return retval;
-}
-
-static inline void binder_lock(const char *tag)
-{
-       trace_binder_lock(tag);
-       mutex_lock(&binder_main_lock);
-       trace_binder_locked(tag);
-}
-
-static inline void binder_unlock(const char *tag)
-{
-       trace_binder_unlock(tag);
-       mutex_unlock(&binder_main_lock);
-}
-
-static void binder_set_nice(long nice)
-{
-       long min_nice;
-
-       if (can_nice(current, nice)) {
-               set_user_nice(current, nice);
-               return;
-       }
-       min_nice = rlimit_to_nice(current->signal->rlim[RLIMIT_NICE].rlim_cur);
-       binder_debug(BINDER_DEBUG_PRIORITY_CAP,
-                    "%d: nice value %ld not allowed use %ld instead\n",
-                     current->pid, nice, min_nice);
-       set_user_nice(current, min_nice);
-       if (min_nice <= MAX_NICE)
-               return;
-       binder_user_error("%d RLIMIT_NICE not set\n", current->pid);
-}
-
-static size_t binder_buffer_size(struct binder_proc *proc,
-                                struct binder_buffer *buffer)
-{
-       if (list_is_last(&buffer->entry, &proc->buffers))
-               return proc->buffer + proc->buffer_size - (void *)buffer->data;
-       return (size_t)list_entry(buffer->entry.next,
-                         struct binder_buffer, entry) - (size_t)buffer->data;
-}
-
-static void binder_insert_free_buffer(struct binder_proc *proc,
-                                     struct binder_buffer *new_buffer)
-{
-       struct rb_node **p = &proc->free_buffers.rb_node;
-       struct rb_node *parent = NULL;
-       struct binder_buffer *buffer;
-       size_t buffer_size;
-       size_t new_buffer_size;
-
-       BUG_ON(!new_buffer->free);
-
-       new_buffer_size = binder_buffer_size(proc, new_buffer);
-
-       binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
-                    "%d: add free buffer, size %zd, at %p\n",
-                     proc->pid, new_buffer_size, new_buffer);
-
-       while (*p) {
-               parent = *p;
-               buffer = rb_entry(parent, struct binder_buffer, rb_node);
-               BUG_ON(!buffer->free);
-
-               buffer_size = binder_buffer_size(proc, buffer);
-
-               if (new_buffer_size < buffer_size)
-                       p = &parent->rb_left;
-               else
-                       p = &parent->rb_right;
-       }
-       rb_link_node(&new_buffer->rb_node, parent, p);
-       rb_insert_color(&new_buffer->rb_node, &proc->free_buffers);
-}
-
-static void binder_insert_allocated_buffer(struct binder_proc *proc,
-                                          struct binder_buffer *new_buffer)
-{
-       struct rb_node **p = &proc->allocated_buffers.rb_node;
-       struct rb_node *parent = NULL;
-       struct binder_buffer *buffer;
-
-       BUG_ON(new_buffer->free);
-
-       while (*p) {
-               parent = *p;
-               buffer = rb_entry(parent, struct binder_buffer, rb_node);
-               BUG_ON(buffer->free);
-
-               if (new_buffer < buffer)
-                       p = &parent->rb_left;
-               else if (new_buffer > buffer)
-                       p = &parent->rb_right;
-               else
-                       BUG();
-       }
-       rb_link_node(&new_buffer->rb_node, parent, p);
-       rb_insert_color(&new_buffer->rb_node, &proc->allocated_buffers);
-}
-
-static struct binder_buffer *binder_buffer_lookup(struct binder_proc *proc,
-                                                 uintptr_t user_ptr)
-{
-       struct rb_node *n = proc->allocated_buffers.rb_node;
-       struct binder_buffer *buffer;
-       struct binder_buffer *kern_ptr;
-
-       kern_ptr = (struct binder_buffer *)(user_ptr - proc->user_buffer_offset
-               - offsetof(struct binder_buffer, data));
-
-       while (n) {
-               buffer = rb_entry(n, struct binder_buffer, rb_node);
-               BUG_ON(buffer->free);
-
-               if (kern_ptr < buffer)
-                       n = n->rb_left;
-               else if (kern_ptr > buffer)
-                       n = n->rb_right;
-               else
-                       return buffer;
-       }
-       return NULL;
-}
-
-static int binder_update_page_range(struct binder_proc *proc, int allocate,
-                                   void *start, void *end,
-                                   struct vm_area_struct *vma)
-{
-       void *page_addr;
-       unsigned long user_page_addr;
-       struct vm_struct tmp_area;
-       struct page **page;
-       struct mm_struct *mm;
-
-       binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
-                    "%d: %s pages %p-%p\n", proc->pid,
-                    allocate ? "allocate" : "free", start, end);
-
-       if (end <= start)
-               return 0;
-
-       trace_binder_update_page_range(proc, allocate, start, end);
-
-       if (vma)
-               mm = NULL;
-       else
-               mm = get_task_mm(proc->tsk);
-
-       if (mm) {
-               down_write(&mm->mmap_sem);
-               vma = proc->vma;
-               if (vma && mm != proc->vma_vm_mm) {
-                       pr_err("%d: vma mm and task mm mismatch\n",
-                               proc->pid);
-                       vma = NULL;
-               }
-       }
-
-       if (allocate == 0)
-               goto free_range;
-
-       if (vma == NULL) {
-               pr_err("%d: binder_alloc_buf failed to map pages in userspace, no vma\n",
-                       proc->pid);
-               goto err_no_vma;
-       }
-
-       for (page_addr = start; page_addr < end; page_addr += PAGE_SIZE) {
-               int ret;
-
-               page = &proc->pages[(page_addr - proc->buffer) / PAGE_SIZE];
-
-               BUG_ON(*page);
-               *page = alloc_page(GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO);
-               if (*page == NULL) {
-                       pr_err("%d: binder_alloc_buf failed for page at %p\n",
-                               proc->pid, page_addr);
-                       goto err_alloc_page_failed;
-               }
-               tmp_area.addr = page_addr;
-               tmp_area.size = PAGE_SIZE + PAGE_SIZE /* guard page? */;
-               ret = map_vm_area(&tmp_area, PAGE_KERNEL, page);
-               if (ret) {
-                       pr_err("%d: binder_alloc_buf failed to map page at %p in kernel\n",
-                              proc->pid, page_addr);
-                       goto err_map_kernel_failed;
-               }
-               user_page_addr =
-                       (uintptr_t)page_addr + proc->user_buffer_offset;
-               ret = vm_insert_page(vma, user_page_addr, page[0]);
-               if (ret) {
-                       pr_err("%d: binder_alloc_buf failed to map page at %lx in userspace\n",
-                              proc->pid, user_page_addr);
-                       goto err_vm_insert_page_failed;
-               }
-               /* vm_insert_page does not seem to increment the refcount */
-       }
-       if (mm) {
-               up_write(&mm->mmap_sem);
-               mmput(mm);
-       }
-       return 0;
-
-free_range:
-       for (page_addr = end - PAGE_SIZE; page_addr >= start;
-            page_addr -= PAGE_SIZE) {
-               page = &proc->pages[(page_addr - proc->buffer) / PAGE_SIZE];
-               if (vma)
-                       zap_page_range(vma, (uintptr_t)page_addr +
-                               proc->user_buffer_offset, PAGE_SIZE, NULL);
-err_vm_insert_page_failed:
-               unmap_kernel_range((unsigned long)page_addr, PAGE_SIZE);
-err_map_kernel_failed:
-               __free_page(*page);
-               *page = NULL;
-err_alloc_page_failed:
-               ;
-       }
-err_no_vma:
-       if (mm) {
-               up_write(&mm->mmap_sem);
-               mmput(mm);
-       }
-       return -ENOMEM;
-}
-
-static struct binder_buffer *binder_alloc_buf(struct binder_proc *proc,
-                                             size_t data_size,
-                                             size_t offsets_size, int is_async)
-{
-       struct rb_node *n = proc->free_buffers.rb_node;
-       struct binder_buffer *buffer;
-       size_t buffer_size;
-       struct rb_node *best_fit = NULL;
-       void *has_page_addr;
-       void *end_page_addr;
-       size_t size;
-
-       if (proc->vma == NULL) {
-               pr_err("%d: binder_alloc_buf, no vma\n",
-                      proc->pid);
-               return NULL;
-       }
-
-       size = ALIGN(data_size, sizeof(void *)) +
-               ALIGN(offsets_size, sizeof(void *));
-
-       if (size < data_size || size < offsets_size) {
-               binder_user_error("%d: got transaction with invalid size %zd-%zd\n",
-                               proc->pid, data_size, offsets_size);
-               return NULL;
-       }
-
-       if (is_async &&
-           proc->free_async_space < size + sizeof(struct binder_buffer)) {
-               binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
-                            "%d: binder_alloc_buf size %zd failed, no async space left\n",
-                             proc->pid, size);
-               return NULL;
-       }
-
-       while (n) {
-               buffer = rb_entry(n, struct binder_buffer, rb_node);
-               BUG_ON(!buffer->free);
-               buffer_size = binder_buffer_size(proc, buffer);
-
-               if (size < buffer_size) {
-                       best_fit = n;
-                       n = n->rb_left;
-               } else if (size > buffer_size)
-                       n = n->rb_right;
-               else {
-                       best_fit = n;
-                       break;
-               }
-       }
-       if (best_fit == NULL) {
-               pr_err("%d: binder_alloc_buf size %zd failed, no address space\n",
-                       proc->pid, size);
-               return NULL;
-       }
-       if (n == NULL) {
-               buffer = rb_entry(best_fit, struct binder_buffer, rb_node);
-               buffer_size = binder_buffer_size(proc, buffer);
-       }
-
-       binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
-                    "%d: binder_alloc_buf size %zd got buffer %p size %zd\n",
-                     proc->pid, size, buffer, buffer_size);
-
-       has_page_addr =
-               (void *)(((uintptr_t)buffer->data + buffer_size) & PAGE_MASK);
-       if (n == NULL) {
-               if (size + sizeof(struct binder_buffer) + 4 >= buffer_size)
-                       buffer_size = size; /* no room for other buffers */
-               else
-                       buffer_size = size + sizeof(struct binder_buffer);
-       }
-       end_page_addr =
-               (void *)PAGE_ALIGN((uintptr_t)buffer->data + buffer_size);
-       if (end_page_addr > has_page_addr)
-               end_page_addr = has_page_addr;
-       if (binder_update_page_range(proc, 1,
-           (void *)PAGE_ALIGN((uintptr_t)buffer->data), end_page_addr, NULL))
-               return NULL;
-
-       rb_erase(best_fit, &proc->free_buffers);
-       buffer->free = 0;
-       binder_insert_allocated_buffer(proc, buffer);
-       if (buffer_size != size) {
-               struct binder_buffer *new_buffer = (void *)buffer->data + size;
-
-               list_add(&new_buffer->entry, &buffer->entry);
-               new_buffer->free = 1;
-               binder_insert_free_buffer(proc, new_buffer);
-       }
-       binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
-                    "%d: binder_alloc_buf size %zd got %p\n",
-                     proc->pid, size, buffer);
-       buffer->data_size = data_size;
-       buffer->offsets_size = offsets_size;
-       buffer->async_transaction = is_async;
-       if (is_async) {
-               proc->free_async_space -= size + sizeof(struct binder_buffer);
-               binder_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC,
-                            "%d: binder_alloc_buf size %zd async free %zd\n",
-                             proc->pid, size, proc->free_async_space);
-       }
-
-       return buffer;
-}
-
-static void *buffer_start_page(struct binder_buffer *buffer)
-{
-       return (void *)((uintptr_t)buffer & PAGE_MASK);
-}
-
-static void *buffer_end_page(struct binder_buffer *buffer)
-{
-       return (void *)(((uintptr_t)(buffer + 1) - 1) & PAGE_MASK);
-}
-
-static void binder_delete_free_buffer(struct binder_proc *proc,
-                                     struct binder_buffer *buffer)
-{
-       struct binder_buffer *prev, *next = NULL;
-       int free_page_end = 1;
-       int free_page_start = 1;
-
-       BUG_ON(proc->buffers.next == &buffer->entry);
-       prev = list_entry(buffer->entry.prev, struct binder_buffer, entry);
-       BUG_ON(!prev->free);
-       if (buffer_end_page(prev) == buffer_start_page(buffer)) {
-               free_page_start = 0;
-               if (buffer_end_page(prev) == buffer_end_page(buffer))
-                       free_page_end = 0;
-               binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
-                            "%d: merge free, buffer %p share page with %p\n",
-                             proc->pid, buffer, prev);
-       }
-
-       if (!list_is_last(&buffer->entry, &proc->buffers)) {
-               next = list_entry(buffer->entry.next,
-                                 struct binder_buffer, entry);
-               if (buffer_start_page(next) == buffer_end_page(buffer)) {
-                       free_page_end = 0;
-                       if (buffer_start_page(next) ==
-                           buffer_start_page(buffer))
-                               free_page_start = 0;
-                       binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
-                                    "%d: merge free, buffer %p share page with %p\n",
-                                     proc->pid, buffer, prev);
-               }
-       }
-       list_del(&buffer->entry);
-       if (free_page_start || free_page_end) {
-               binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
-                            "%d: merge free, buffer %p do not share page%s%s with %p or %p\n",
-                            proc->pid, buffer, free_page_start ? "" : " end",
-                            free_page_end ? "" : " start", prev, next);
-               binder_update_page_range(proc, 0, free_page_start ?
-                       buffer_start_page(buffer) : buffer_end_page(buffer),
-                       (free_page_end ? buffer_end_page(buffer) :
-                       buffer_start_page(buffer)) + PAGE_SIZE, NULL);
-       }
-}
-
-static void binder_free_buf(struct binder_proc *proc,
-                           struct binder_buffer *buffer)
-{
-       size_t size, buffer_size;
-
-       buffer_size = binder_buffer_size(proc, buffer);
-
-       size = ALIGN(buffer->data_size, sizeof(void *)) +
-               ALIGN(buffer->offsets_size, sizeof(void *));
-
-       binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
-                    "%d: binder_free_buf %p size %zd buffer_size %zd\n",
-                     proc->pid, buffer, size, buffer_size);
-
-       BUG_ON(buffer->free);
-       BUG_ON(size > buffer_size);
-       BUG_ON(buffer->transaction != NULL);
-       BUG_ON((void *)buffer < proc->buffer);
-       BUG_ON((void *)buffer > proc->buffer + proc->buffer_size);
-
-       if (buffer->async_transaction) {
-               proc->free_async_space += size + sizeof(struct binder_buffer);
-
-               binder_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC,
-                            "%d: binder_free_buf size %zd async free %zd\n",
-                             proc->pid, size, proc->free_async_space);
-       }
-
-       binder_update_page_range(proc, 0,
-               (void *)PAGE_ALIGN((uintptr_t)buffer->data),
-               (void *)(((uintptr_t)buffer->data + buffer_size) & PAGE_MASK),
-               NULL);
-       rb_erase(&buffer->rb_node, &proc->allocated_buffers);
-       buffer->free = 1;
-       if (!list_is_last(&buffer->entry, &proc->buffers)) {
-               struct binder_buffer *next = list_entry(buffer->entry.next,
-                                               struct binder_buffer, entry);
-
-               if (next->free) {
-                       rb_erase(&next->rb_node, &proc->free_buffers);
-                       binder_delete_free_buffer(proc, next);
-               }
-       }
-       if (proc->buffers.next != &buffer->entry) {
-               struct binder_buffer *prev = list_entry(buffer->entry.prev,
-                                               struct binder_buffer, entry);
-
-               if (prev->free) {
-                       binder_delete_free_buffer(proc, buffer);
-                       rb_erase(&prev->rb_node, &proc->free_buffers);
-                       buffer = prev;
-               }
-       }
-       binder_insert_free_buffer(proc, buffer);
-}
-
-static struct binder_node *binder_get_node(struct binder_proc *proc,
-                                          binder_uintptr_t ptr)
-{
-       struct rb_node *n = proc->nodes.rb_node;
-       struct binder_node *node;
-
-       while (n) {
-               node = rb_entry(n, struct binder_node, rb_node);
-
-               if (ptr < node->ptr)
-                       n = n->rb_left;
-               else if (ptr > node->ptr)
-                       n = n->rb_right;
-               else
-                       return node;
-       }
-       return NULL;
-}
-
-static struct binder_node *binder_new_node(struct binder_proc *proc,
-                                          binder_uintptr_t ptr,
-                                          binder_uintptr_t cookie)
-{
-       struct rb_node **p = &proc->nodes.rb_node;
-       struct rb_node *parent = NULL;
-       struct binder_node *node;
-
-       while (*p) {
-               parent = *p;
-               node = rb_entry(parent, struct binder_node, rb_node);
-
-               if (ptr < node->ptr)
-                       p = &(*p)->rb_left;
-               else if (ptr > node->ptr)
-                       p = &(*p)->rb_right;
-               else
-                       return NULL;
-       }
-
-       node = kzalloc(sizeof(*node), GFP_KERNEL);
-       if (node == NULL)
-               return NULL;
-       binder_stats_created(BINDER_STAT_NODE);
-       rb_link_node(&node->rb_node, parent, p);
-       rb_insert_color(&node->rb_node, &proc->nodes);
-       node->debug_id = ++binder_last_id;
-       node->proc = proc;
-       node->ptr = ptr;
-       node->cookie = cookie;
-       node->work.type = BINDER_WORK_NODE;
-       INIT_LIST_HEAD(&node->work.entry);
-       INIT_LIST_HEAD(&node->async_todo);
-       binder_debug(BINDER_DEBUG_INTERNAL_REFS,
-                    "%d:%d node %d u%016llx c%016llx created\n",
-                    proc->pid, current->pid, node->debug_id,
-                    (u64)node->ptr, (u64)node->cookie);
-       return node;
-}
-
-static int binder_inc_node(struct binder_node *node, int strong, int internal,
-                          struct list_head *target_list)
-{
-       if (strong) {
-               if (internal) {
-                       if (target_list == NULL &&
-                           node->internal_strong_refs == 0 &&
-                           !(node == binder_context_mgr_node &&
-                           node->has_strong_ref)) {
-                               pr_err("invalid inc strong node for %d\n",
-                                       node->debug_id);
-                               return -EINVAL;
-                       }
-                       node->internal_strong_refs++;
-               } else
-                       node->local_strong_refs++;
-               if (!node->has_strong_ref && target_list) {
-                       list_del_init(&node->work.entry);
-                       list_add_tail(&node->work.entry, target_list);
-               }
-       } else {
-               if (!internal)
-                       node->local_weak_refs++;
-               if (!node->has_weak_ref && list_empty(&node->work.entry)) {
-                       if (target_list == NULL) {
-                               pr_err("invalid inc weak node for %d\n",
-                                       node->debug_id);
-                               return -EINVAL;
-                       }
-                       list_add_tail(&node->work.entry, target_list);
-               }
-       }
-       return 0;
-}
-
-static int binder_dec_node(struct binder_node *node, int strong, int internal)
-{
-       if (strong) {
-               if (internal)
-                       node->internal_strong_refs--;
-               else
-                       node->local_strong_refs--;
-               if (node->local_strong_refs || node->internal_strong_refs)
-                       return 0;
-       } else {
-               if (!internal)
-                       node->local_weak_refs--;
-               if (node->local_weak_refs || !hlist_empty(&node->refs))
-                       return 0;
-       }
-       if (node->proc && (node->has_strong_ref || node->has_weak_ref)) {
-               if (list_empty(&node->work.entry)) {
-                       list_add_tail(&node->work.entry, &node->proc->todo);
-                       wake_up_interruptible(&node->proc->wait);
-               }
-       } else {
-               if (hlist_empty(&node->refs) && !node->local_strong_refs &&
-                   !node->local_weak_refs) {
-                       list_del_init(&node->work.entry);
-                       if (node->proc) {
-                               rb_erase(&node->rb_node, &node->proc->nodes);
-                               binder_debug(BINDER_DEBUG_INTERNAL_REFS,
-                                            "refless node %d deleted\n",
-                                            node->debug_id);
-                       } else {
-                               hlist_del(&node->dead_node);
-                               binder_debug(BINDER_DEBUG_INTERNAL_REFS,
-                                            "dead node %d deleted\n",
-                                            node->debug_id);
-                       }
-                       kfree(node);
-                       binder_stats_deleted(BINDER_STAT_NODE);
-               }
-       }
-
-       return 0;
-}
-
-
-static struct binder_ref *binder_get_ref(struct binder_proc *proc,
-                                        uint32_t desc)
-{
-       struct rb_node *n = proc->refs_by_desc.rb_node;
-       struct binder_ref *ref;
-
-       while (n) {
-               ref = rb_entry(n, struct binder_ref, rb_node_desc);
-
-               if (desc < ref->desc)
-                       n = n->rb_left;
-               else if (desc > ref->desc)
-                       n = n->rb_right;
-               else
-                       return ref;
-       }
-       return NULL;
-}
-
-static struct binder_ref *binder_get_ref_for_node(struct binder_proc *proc,
-                                                 struct binder_node *node)
-{
-       struct rb_node *n;
-       struct rb_node **p = &proc->refs_by_node.rb_node;
-       struct rb_node *parent = NULL;
-       struct binder_ref *ref, *new_ref;
-
-       while (*p) {
-               parent = *p;
-               ref = rb_entry(parent, struct binder_ref, rb_node_node);
-
-               if (node < ref->node)
-                       p = &(*p)->rb_left;
-               else if (node > ref->node)
-                       p = &(*p)->rb_right;
-               else
-                       return ref;
-       }
-       new_ref = kzalloc(sizeof(*ref), GFP_KERNEL);
-       if (new_ref == NULL)
-               return NULL;
-       binder_stats_created(BINDER_STAT_REF);
-       new_ref->debug_id = ++binder_last_id;
-       new_ref->proc = proc;
-       new_ref->node = node;
-       rb_link_node(&new_ref->rb_node_node, parent, p);
-       rb_insert_color(&new_ref->rb_node_node, &proc->refs_by_node);
-
-       new_ref->desc = (node == binder_context_mgr_node) ? 0 : 1;
-       for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) {
-               ref = rb_entry(n, struct binder_ref, rb_node_desc);
-               if (ref->desc > new_ref->desc)
-                       break;
-               new_ref->desc = ref->desc + 1;
-       }
-
-       p = &proc->refs_by_desc.rb_node;
-       while (*p) {
-               parent = *p;
-               ref = rb_entry(parent, struct binder_ref, rb_node_desc);
-
-               if (new_ref->desc < ref->desc)
-                       p = &(*p)->rb_left;
-               else if (new_ref->desc > ref->desc)
-                       p = &(*p)->rb_right;
-               else
-                       BUG();
-       }
-       rb_link_node(&new_ref->rb_node_desc, parent, p);
-       rb_insert_color(&new_ref->rb_node_desc, &proc->refs_by_desc);
-       if (node) {
-               hlist_add_head(&new_ref->node_entry, &node->refs);
-
-               binder_debug(BINDER_DEBUG_INTERNAL_REFS,
-                            "%d new ref %d desc %d for node %d\n",
-                             proc->pid, new_ref->debug_id, new_ref->desc,
-                             node->debug_id);
-       } else {
-               binder_debug(BINDER_DEBUG_INTERNAL_REFS,
-                            "%d new ref %d desc %d for dead node\n",
-                             proc->pid, new_ref->debug_id, new_ref->desc);
-       }
-       return new_ref;
-}
-
-static void binder_delete_ref(struct binder_ref *ref)
-{
-       binder_debug(BINDER_DEBUG_INTERNAL_REFS,
-                    "%d delete ref %d desc %d for node %d\n",
-                     ref->proc->pid, ref->debug_id, ref->desc,
-                     ref->node->debug_id);
-
-       rb_erase(&ref->rb_node_desc, &ref->proc->refs_by_desc);
-       rb_erase(&ref->rb_node_node, &ref->proc->refs_by_node);
-       if (ref->strong)
-               binder_dec_node(ref->node, 1, 1);
-       hlist_del(&ref->node_entry);
-       binder_dec_node(ref->node, 0, 1);
-       if (ref->death) {
-               binder_debug(BINDER_DEBUG_DEAD_BINDER,
-                            "%d delete ref %d desc %d has death notification\n",
-                             ref->proc->pid, ref->debug_id, ref->desc);
-               list_del(&ref->death->work.entry);
-               kfree(ref->death);
-               binder_stats_deleted(BINDER_STAT_DEATH);
-       }
-       kfree(ref);
-       binder_stats_deleted(BINDER_STAT_REF);
-}
-
-static int binder_inc_ref(struct binder_ref *ref, int strong,
-                         struct list_head *target_list)
-{
-       int ret;
-
-       if (strong) {
-               if (ref->strong == 0) {
-                       ret = binder_inc_node(ref->node, 1, 1, target_list);
-                       if (ret)
-                               return ret;
-               }
-               ref->strong++;
-       } else {
-               if (ref->weak == 0) {
-                       ret = binder_inc_node(ref->node, 0, 1, target_list);
-                       if (ret)
-                               return ret;
-               }
-               ref->weak++;
-       }
-       return 0;
-}
-
-
-static int binder_dec_ref(struct binder_ref *ref, int strong)
-{
-       if (strong) {
-               if (ref->strong == 0) {
-                       binder_user_error("%d invalid dec strong, ref %d desc %d s %d w %d\n",
-                                         ref->proc->pid, ref->debug_id,
-                                         ref->desc, ref->strong, ref->weak);
-                       return -EINVAL;
-               }
-               ref->strong--;
-               if (ref->strong == 0) {
-                       int ret;
-
-                       ret = binder_dec_node(ref->node, strong, 1);
-                       if (ret)
-                               return ret;
-               }
-       } else {
-               if (ref->weak == 0) {
-                       binder_user_error("%d invalid dec weak, ref %d desc %d s %d w %d\n",
-                                         ref->proc->pid, ref->debug_id,
-                                         ref->desc, ref->strong, ref->weak);
-                       return -EINVAL;
-               }
-               ref->weak--;
-       }
-       if (ref->strong == 0 && ref->weak == 0)
-               binder_delete_ref(ref);
-       return 0;
-}
-
-static void binder_pop_transaction(struct binder_thread *target_thread,
-                                  struct binder_transaction *t)
-{
-       if (target_thread) {
-               BUG_ON(target_thread->transaction_stack != t);
-               BUG_ON(target_thread->transaction_stack->from != target_thread);
-               target_thread->transaction_stack =
-                       target_thread->transaction_stack->from_parent;
-               t->from = NULL;
-       }
-       t->need_reply = 0;
-       if (t->buffer)
-               t->buffer->transaction = NULL;
-       kfree(t);
-       binder_stats_deleted(BINDER_STAT_TRANSACTION);
-}
-
-static void binder_send_failed_reply(struct binder_transaction *t,
-                                    uint32_t error_code)
-{
-       struct binder_thread *target_thread;
-       struct binder_transaction *next;
-
-       BUG_ON(t->flags & TF_ONE_WAY);
-       while (1) {
-               target_thread = t->from;
-               if (target_thread) {
-                       if (target_thread->return_error != BR_OK &&
-                          target_thread->return_error2 == BR_OK) {
-                               target_thread->return_error2 =
-                                       target_thread->return_error;
-                               target_thread->return_error = BR_OK;
-                       }
-                       if (target_thread->return_error == BR_OK) {
-                               binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
-                                            "send failed reply for transaction %d to %d:%d\n",
-                                             t->debug_id,
-                                             target_thread->proc->pid,
-                                             target_thread->pid);
-
-                               binder_pop_transaction(target_thread, t);
-                               target_thread->return_error = error_code;
-                               wake_up_interruptible(&target_thread->wait);
-                       } else {
-                               pr_err("reply failed, target thread, %d:%d, has error code %d already\n",
-                                       target_thread->proc->pid,
-                                       target_thread->pid,
-                                       target_thread->return_error);
-                       }
-                       return;
-               }
-               next = t->from_parent;
-
-               binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
-                            "send failed reply for transaction %d, target dead\n",
-                            t->debug_id);
-
-               binder_pop_transaction(target_thread, t);
-               if (next == NULL) {
-                       binder_debug(BINDER_DEBUG_DEAD_BINDER,
-                                    "reply failed, no target thread at root\n");
-                       return;
-               }
-               t = next;
-               binder_debug(BINDER_DEBUG_DEAD_BINDER,
-                            "reply failed, no target thread -- retry %d\n",
-                             t->debug_id);
-       }
-}
-
-static void binder_transaction_buffer_release(struct binder_proc *proc,
-                                             struct binder_buffer *buffer,
-                                             binder_size_t *failed_at)
-{
-       binder_size_t *offp, *off_end;
-       int debug_id = buffer->debug_id;
-
-       binder_debug(BINDER_DEBUG_TRANSACTION,
-                    "%d buffer release %d, size %zd-%zd, failed at %p\n",
-                    proc->pid, buffer->debug_id,
-                    buffer->data_size, buffer->offsets_size, failed_at);
-
-       if (buffer->target_node)
-               binder_dec_node(buffer->target_node, 1, 0);
-
-       offp = (binder_size_t *)(buffer->data +
-                                ALIGN(buffer->data_size, sizeof(void *)));
-       if (failed_at)
-               off_end = failed_at;
-       else
-               off_end = (void *)offp + buffer->offsets_size;
-       for (; offp < off_end; offp++) {
-               struct flat_binder_object *fp;
-
-               if (*offp > buffer->data_size - sizeof(*fp) ||
-                   buffer->data_size < sizeof(*fp) ||
-                   !IS_ALIGNED(*offp, sizeof(u32))) {
-                       pr_err("transaction release %d bad offset %lld, size %zd\n",
-                              debug_id, (u64)*offp, buffer->data_size);
-                       continue;
-               }
-               fp = (struct flat_binder_object *)(buffer->data + *offp);
-               switch (fp->type) {
-               case BINDER_TYPE_BINDER:
-               case BINDER_TYPE_WEAK_BINDER: {
-                       struct binder_node *node = binder_get_node(proc, fp->binder);
-
-                       if (node == NULL) {
-                               pr_err("transaction release %d bad node %016llx\n",
-                                      debug_id, (u64)fp->binder);
-                               break;
-                       }
-                       binder_debug(BINDER_DEBUG_TRANSACTION,
-                                    "        node %d u%016llx\n",
-                                    node->debug_id, (u64)node->ptr);
-                       binder_dec_node(node, fp->type == BINDER_TYPE_BINDER, 0);
-               } break;
-               case BINDER_TYPE_HANDLE:
-               case BINDER_TYPE_WEAK_HANDLE: {
-                       struct binder_ref *ref = binder_get_ref(proc, fp->handle);
-
-                       if (ref == NULL) {
-                               pr_err("transaction release %d bad handle %d\n",
-                                debug_id, fp->handle);
-                               break;
-                       }
-                       binder_debug(BINDER_DEBUG_TRANSACTION,
-                                    "        ref %d desc %d (node %d)\n",
-                                    ref->debug_id, ref->desc, ref->node->debug_id);
-                       binder_dec_ref(ref, fp->type == BINDER_TYPE_HANDLE);
-               } break;
-
-               case BINDER_TYPE_FD:
-                       binder_debug(BINDER_DEBUG_TRANSACTION,
-                                    "        fd %d\n", fp->handle);
-                       if (failed_at)
-                               task_close_fd(proc, fp->handle);
-                       break;
-
-               default:
-                       pr_err("transaction release %d bad object type %x\n",
-                               debug_id, fp->type);
-                       break;
-               }
-       }
-}
-
-static void binder_transaction(struct binder_proc *proc,
-                              struct binder_thread *thread,
-                              struct binder_transaction_data *tr, int reply)
-{
-       struct binder_transaction *t;
-       struct binder_work *tcomplete;
-       binder_size_t *offp, *off_end;
-       struct binder_proc *target_proc;
-       struct binder_thread *target_thread = NULL;
-       struct binder_node *target_node = NULL;
-       struct list_head *target_list;
-       wait_queue_head_t *target_wait;
-       struct binder_transaction *in_reply_to = NULL;
-       struct binder_transaction_log_entry *e;
-       uint32_t return_error;
-
-       e = binder_transaction_log_add(&binder_transaction_log);
-       e->call_type = reply ? 2 : !!(tr->flags & TF_ONE_WAY);
-       e->from_proc = proc->pid;
-       e->from_thread = thread->pid;
-       e->target_handle = tr->target.handle;
-       e->data_size = tr->data_size;
-       e->offsets_size = tr->offsets_size;
-
-       if (reply) {
-               in_reply_to = thread->transaction_stack;
-               if (in_reply_to == NULL) {
-                       binder_user_error("%d:%d got reply transaction with no transaction stack\n",
-                                         proc->pid, thread->pid);
-                       return_error = BR_FAILED_REPLY;
-                       goto err_empty_call_stack;
-               }
-               binder_set_nice(in_reply_to->saved_priority);
-               if (in_reply_to->to_thread != thread) {
-                       binder_user_error("%d:%d got reply transaction with bad transaction stack, transaction %d has target %d:%d\n",
-                               proc->pid, thread->pid, in_reply_to->debug_id,
-                               in_reply_to->to_proc ?
-                               in_reply_to->to_proc->pid : 0,
-                               in_reply_to->to_thread ?
-                               in_reply_to->to_thread->pid : 0);
-                       return_error = BR_FAILED_REPLY;
-                       in_reply_to = NULL;
-                       goto err_bad_call_stack;
-               }
-               thread->transaction_stack = in_reply_to->to_parent;
-               target_thread = in_reply_to->from;
-               if (target_thread == NULL) {
-                       return_error = BR_DEAD_REPLY;
-                       goto err_dead_binder;
-               }
-               if (target_thread->transaction_stack != in_reply_to) {
-                       binder_user_error("%d:%d got reply transaction with bad target transaction stack %d, expected %d\n",
-                               proc->pid, thread->pid,
-                               target_thread->transaction_stack ?
-                               target_thread->transaction_stack->debug_id : 0,
-                               in_reply_to->debug_id);
-                       return_error = BR_FAILED_REPLY;
-                       in_reply_to = NULL;
-                       target_thread = NULL;
-                       goto err_dead_binder;
-               }
-               target_proc = target_thread->proc;
-       } else {
-               if (tr->target.handle) {
-                       struct binder_ref *ref;
-
-                       ref = binder_get_ref(proc, tr->target.handle);
-                       if (ref == NULL) {
-                               binder_user_error("%d:%d got transaction to invalid handle\n",
-                                       proc->pid, thread->pid);
-                               return_error = BR_FAILED_REPLY;
-                               goto err_invalid_target_handle;
-                       }
-                       target_node = ref->node;
-               } else {
-                       target_node = binder_context_mgr_node;
-                       if (target_node == NULL) {
-                               return_error = BR_DEAD_REPLY;
-                               goto err_no_context_mgr_node;
-                       }
-               }
-               e->to_node = target_node->debug_id;
-               target_proc = target_node->proc;
-               if (target_proc == NULL) {
-                       return_error = BR_DEAD_REPLY;
-                       goto err_dead_binder;
-               }
-               if (!(tr->flags & TF_ONE_WAY) && thread->transaction_stack) {
-                       struct binder_transaction *tmp;
-
-                       tmp = thread->transaction_stack;
-                       if (tmp->to_thread != thread) {
-                               binder_user_error("%d:%d got new transaction with bad transaction stack, transaction %d has target %d:%d\n",
-                                       proc->pid, thread->pid, tmp->debug_id,
-                                       tmp->to_proc ? tmp->to_proc->pid : 0,
-                                       tmp->to_thread ?
-                                       tmp->to_thread->pid : 0);
-                               return_error = BR_FAILED_REPLY;
-                               goto err_bad_call_stack;
-                       }
-                       while (tmp) {
-                               if (tmp->from && tmp->from->proc == target_proc)
-                                       target_thread = tmp->from;
-                               tmp = tmp->from_parent;
-                       }
-               }
-       }
-       if (target_thread) {
-               e->to_thread = target_thread->pid;
-               target_list = &target_thread->todo;
-               target_wait = &target_thread->wait;
-       } else {
-               target_list = &target_proc->todo;
-               target_wait = &target_proc->wait;
-       }
-       e->to_proc = target_proc->pid;
-
-       /* TODO: reuse incoming transaction for reply */
-       t = kzalloc(sizeof(*t), GFP_KERNEL);
-       if (t == NULL) {
-               return_error = BR_FAILED_REPLY;
-               goto err_alloc_t_failed;
-       }
-       binder_stats_created(BINDER_STAT_TRANSACTION);
-
-       tcomplete = kzalloc(sizeof(*tcomplete), GFP_KERNEL);
-       if (tcomplete == NULL) {
-               return_error = BR_FAILED_REPLY;
-               goto err_alloc_tcomplete_failed;
-       }
-       binder_stats_created(BINDER_STAT_TRANSACTION_COMPLETE);
-
-       t->debug_id = ++binder_last_id;
-       e->debug_id = t->debug_id;
-
-       if (reply)
-               binder_debug(BINDER_DEBUG_TRANSACTION,
-                            "%d:%d BC_REPLY %d -> %d:%d, data %016llx-%016llx size %lld-%lld\n",
-                            proc->pid, thread->pid, t->debug_id,
-                            target_proc->pid, target_thread->pid,
-                            (u64)tr->data.ptr.buffer,
-                            (u64)tr->data.ptr.offsets,
-                            (u64)tr->data_size, (u64)tr->offsets_size);
-       else
-               binder_debug(BINDER_DEBUG_TRANSACTION,
-                            "%d:%d BC_TRANSACTION %d -> %d - node %d, data %016llx-%016llx size %lld-%lld\n",
-                            proc->pid, thread->pid, t->debug_id,
-                            target_proc->pid, target_node->debug_id,
-                            (u64)tr->data.ptr.buffer,
-                            (u64)tr->data.ptr.offsets,
-                            (u64)tr->data_size, (u64)tr->offsets_size);
-
-       if (!reply && !(tr->flags & TF_ONE_WAY))
-               t->from = thread;
-       else
-               t->from = NULL;
-       t->sender_euid = task_euid(proc->tsk);
-       t->to_proc = target_proc;
-       t->to_thread = target_thread;
-       t->code = tr->code;
-       t->flags = tr->flags;
-       t->priority = task_nice(current);
-
-       trace_binder_transaction(reply, t, target_node);
-
-       t->buffer = binder_alloc_buf(target_proc, tr->data_size,
-               tr->offsets_size, !reply && (t->flags & TF_ONE_WAY));
-       if (t->buffer == NULL) {
-               return_error = BR_FAILED_REPLY;
-               goto err_binder_alloc_buf_failed;
-       }
-       t->buffer->allow_user_free = 0;
-       t->buffer->debug_id = t->debug_id;
-       t->buffer->transaction = t;
-       t->buffer->target_node = target_node;
-       trace_binder_transaction_alloc_buf(t->buffer);
-       if (target_node)
-               binder_inc_node(target_node, 1, 0, NULL);
-
-       offp = (binder_size_t *)(t->buffer->data +
-                                ALIGN(tr->data_size, sizeof(void *)));
-
-       if (copy_from_user(t->buffer->data, (const void __user *)(uintptr_t)
-                          tr->data.ptr.buffer, tr->data_size)) {
-               binder_user_error("%d:%d got transaction with invalid data ptr\n",
-                               proc->pid, thread->pid);
-               return_error = BR_FAILED_REPLY;
-               goto err_copy_data_failed;
-       }
-       if (copy_from_user(offp, (const void __user *)(uintptr_t)
-                          tr->data.ptr.offsets, tr->offsets_size)) {
-               binder_user_error("%d:%d got transaction with invalid offsets ptr\n",
-                               proc->pid, thread->pid);
-               return_error = BR_FAILED_REPLY;
-               goto err_copy_data_failed;
-       }
-       if (!IS_ALIGNED(tr->offsets_size, sizeof(binder_size_t))) {
-               binder_user_error("%d:%d got transaction with invalid offsets size, %lld\n",
-                               proc->pid, thread->pid, (u64)tr->offsets_size);
-               return_error = BR_FAILED_REPLY;
-               goto err_bad_offset;
-       }
-       off_end = (void *)offp + tr->offsets_size;
-       for (; offp < off_end; offp++) {
-               struct flat_binder_object *fp;
-
-               if (*offp > t->buffer->data_size - sizeof(*fp) ||
-                   t->buffer->data_size < sizeof(*fp) ||
-                   !IS_ALIGNED(*offp, sizeof(u32))) {
-                       binder_user_error("%d:%d got transaction with invalid offset, %lld\n",
-                                         proc->pid, thread->pid, (u64)*offp);
-                       return_error = BR_FAILED_REPLY;
-                       goto err_bad_offset;
-               }
-               fp = (struct flat_binder_object *)(t->buffer->data + *offp);
-               switch (fp->type) {
-               case BINDER_TYPE_BINDER:
-               case BINDER_TYPE_WEAK_BINDER: {
-                       struct binder_ref *ref;
-                       struct binder_node *node = binder_get_node(proc, fp->binder);
-
-                       if (node == NULL) {
-                               node = binder_new_node(proc, fp->binder, fp->cookie);
-                               if (node == NULL) {
-                                       return_error = BR_FAILED_REPLY;
-                                       goto err_binder_new_node_failed;
-                               }
-                               node->min_priority = fp->flags & FLAT_BINDER_FLAG_PRIORITY_MASK;
-                               node->accept_fds = !!(fp->flags & FLAT_BINDER_FLAG_ACCEPTS_FDS);
-                       }
-                       if (fp->cookie != node->cookie) {
-                               binder_user_error("%d:%d sending u%016llx node %d, cookie mismatch %016llx != %016llx\n",
-                                       proc->pid, thread->pid,
-                                       (u64)fp->binder, node->debug_id,
-                                       (u64)fp->cookie, (u64)node->cookie);
-                               return_error = BR_FAILED_REPLY;
-                               goto err_binder_get_ref_for_node_failed;
-                       }
-                       ref = binder_get_ref_for_node(target_proc, node);
-                       if (ref == NULL) {
-                               return_error = BR_FAILED_REPLY;
-                               goto err_binder_get_ref_for_node_failed;
-                       }
-                       if (fp->type == BINDER_TYPE_BINDER)
-                               fp->type = BINDER_TYPE_HANDLE;
-                       else
-                               fp->type = BINDER_TYPE_WEAK_HANDLE;
-                       fp->handle = ref->desc;
-                       binder_inc_ref(ref, fp->type == BINDER_TYPE_HANDLE,
-                                      &thread->todo);
-
-                       trace_binder_transaction_node_to_ref(t, node, ref);
-                       binder_debug(BINDER_DEBUG_TRANSACTION,
-                                    "        node %d u%016llx -> ref %d desc %d\n",
-                                    node->debug_id, (u64)node->ptr,
-                                    ref->debug_id, ref->desc);
-               } break;
-               case BINDER_TYPE_HANDLE:
-               case BINDER_TYPE_WEAK_HANDLE: {
-                       struct binder_ref *ref = binder_get_ref(proc, fp->handle);
-
-                       if (ref == NULL) {
-                               binder_user_error("%d:%d got transaction with invalid handle, %d\n",
-                                               proc->pid,
-                                               thread->pid, fp->handle);
-                               return_error = BR_FAILED_REPLY;
-                               goto err_binder_get_ref_failed;
-                       }
-                       if (ref->node->proc == target_proc) {
-                               if (fp->type == BINDER_TYPE_HANDLE)
-                                       fp->type = BINDER_TYPE_BINDER;
-                               else
-                                       fp->type = BINDER_TYPE_WEAK_BINDER;
-                               fp->binder = ref->node->ptr;
-                               fp->cookie = ref->node->cookie;
-                               binder_inc_node(ref->node, fp->type == BINDER_TYPE_BINDER, 0, NULL);
-                               trace_binder_transaction_ref_to_node(t, ref);
-                               binder_debug(BINDER_DEBUG_TRANSACTION,
-                                            "        ref %d desc %d -> node %d u%016llx\n",
-                                            ref->debug_id, ref->desc, ref->node->debug_id,
-                                            (u64)ref->node->ptr);
-                       } else {
-                               struct binder_ref *new_ref;
-
-                               new_ref = binder_get_ref_for_node(target_proc, ref->node);
-                               if (new_ref == NULL) {
-                                       return_error = BR_FAILED_REPLY;
-                                       goto err_binder_get_ref_for_node_failed;
-                               }
-                               fp->handle = new_ref->desc;
-                               binder_inc_ref(new_ref, fp->type == BINDER_TYPE_HANDLE, NULL);
-                               trace_binder_transaction_ref_to_ref(t, ref,
-                                                                   new_ref);
-                               binder_debug(BINDER_DEBUG_TRANSACTION,
-                                            "        ref %d desc %d -> ref %d desc %d (node %d)\n",
-                                            ref->debug_id, ref->desc, new_ref->debug_id,
-                                            new_ref->desc, ref->node->debug_id);
-                       }
-               } break;
-
-               case BINDER_TYPE_FD: {
-                       int target_fd;
-                       struct file *file;
-
-                       if (reply) {
-                               if (!(in_reply_to->flags & TF_ACCEPT_FDS)) {
-                                       binder_user_error("%d:%d got reply with fd, %d, but target does not allow fds\n",
-                                               proc->pid, thread->pid, fp->handle);
-                                       return_error = BR_FAILED_REPLY;
-                                       goto err_fd_not_allowed;
-                               }
-                       } else if (!target_node->accept_fds) {
-                               binder_user_error("%d:%d got transaction with fd, %d, but target does not allow fds\n",
-                                       proc->pid, thread->pid, fp->handle);
-                               return_error = BR_FAILED_REPLY;
-                               goto err_fd_not_allowed;
-                       }
-
-                       file = fget(fp->handle);
-                       if (file == NULL) {
-                               binder_user_error("%d:%d got transaction with invalid fd, %d\n",
-                                       proc->pid, thread->pid, fp->handle);
-                               return_error = BR_FAILED_REPLY;
-                               goto err_fget_failed;
-                       }
-                       target_fd = task_get_unused_fd_flags(target_proc, O_CLOEXEC);
-                       if (target_fd < 0) {
-                               fput(file);
-                               return_error = BR_FAILED_REPLY;
-                               goto err_get_unused_fd_failed;
-                       }
-                       task_fd_install(target_proc, target_fd, file);
-                       trace_binder_transaction_fd(t, fp->handle, target_fd);
-                       binder_debug(BINDER_DEBUG_TRANSACTION,
-                                    "        fd %d -> %d\n", fp->handle, target_fd);
-                       /* TODO: fput? */
-                       fp->handle = target_fd;
-               } break;
-
-               default:
-                       binder_user_error("%d:%d got transaction with invalid object type, %x\n",
-                               proc->pid, thread->pid, fp->type);
-                       return_error = BR_FAILED_REPLY;
-                       goto err_bad_object_type;
-               }
-       }
-       if (reply) {
-               BUG_ON(t->buffer->async_transaction != 0);
-               binder_pop_transaction(target_thread, in_reply_to);
-       } else if (!(t->flags & TF_ONE_WAY)) {
-               BUG_ON(t->buffer->async_transaction != 0);
-               t->need_reply = 1;
-               t->from_parent = thread->transaction_stack;
-               thread->transaction_stack = t;
-       } else {
-               BUG_ON(target_node == NULL);
-               BUG_ON(t->buffer->async_transaction != 1);
-               if (target_node->has_async_transaction) {
-                       target_list = &target_node->async_todo;
-                       target_wait = NULL;
-               } else
-                       target_node->has_async_transaction = 1;
-       }
-       t->work.type = BINDER_WORK_TRANSACTION;
-       list_add_tail(&t->work.entry, target_list);
-       tcomplete->type = BINDER_WORK_TRANSACTION_COMPLETE;
-       list_add_tail(&tcomplete->entry, &thread->todo);
-       if (target_wait)
-               wake_up_interruptible(target_wait);
-       return;
-
-err_get_unused_fd_failed:
-err_fget_failed:
-err_fd_not_allowed:
-err_binder_get_ref_for_node_failed:
-err_binder_get_ref_failed:
-err_binder_new_node_failed:
-err_bad_object_type:
-err_bad_offset:
-err_copy_data_failed:
-       trace_binder_transaction_failed_buffer_release(t->buffer);
-       binder_transaction_buffer_release(target_proc, t->buffer, offp);
-       t->buffer->transaction = NULL;
-       binder_free_buf(target_proc, t->buffer);
-err_binder_alloc_buf_failed:
-       kfree(tcomplete);
-       binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE);
-err_alloc_tcomplete_failed:
-       kfree(t);
-       binder_stats_deleted(BINDER_STAT_TRANSACTION);
-err_alloc_t_failed:
-err_bad_call_stack:
-err_empty_call_stack:
-err_dead_binder:
-err_invalid_target_handle:
-err_no_context_mgr_node:
-       binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
-                    "%d:%d transaction failed %d, size %lld-%lld\n",
-                    proc->pid, thread->pid, return_error,
-                    (u64)tr->data_size, (u64)tr->offsets_size);
-
-       {
-               struct binder_transaction_log_entry *fe;
-
-               fe = binder_transaction_log_add(&binder_transaction_log_failed);
-               *fe = *e;
-       }
-
-       BUG_ON(thread->return_error != BR_OK);
-       if (in_reply_to) {
-               thread->return_error = BR_TRANSACTION_COMPLETE;
-               binder_send_failed_reply(in_reply_to, return_error);
-       } else
-               thread->return_error = return_error;
-}
-
-static int binder_thread_write(struct binder_proc *proc,
-                       struct binder_thread *thread,
-                       binder_uintptr_t binder_buffer, size_t size,
-                       binder_size_t *consumed)
-{
-       uint32_t cmd;
-       void __user *buffer = (void __user *)(uintptr_t)binder_buffer;
-       void __user *ptr = buffer + *consumed;
-       void __user *end = buffer + size;
-
-       while (ptr < end && thread->return_error == BR_OK) {
-               if (get_user(cmd, (uint32_t __user *)ptr))
-                       return -EFAULT;
-               ptr += sizeof(uint32_t);
-               trace_binder_command(cmd);
-               if (_IOC_NR(cmd) < ARRAY_SIZE(binder_stats.bc)) {
-                       binder_stats.bc[_IOC_NR(cmd)]++;
-                       proc->stats.bc[_IOC_NR(cmd)]++;
-                       thread->stats.bc[_IOC_NR(cmd)]++;
-               }
-               switch (cmd) {
-               case BC_INCREFS:
-               case BC_ACQUIRE:
-               case BC_RELEASE:
-               case BC_DECREFS: {
-                       uint32_t target;
-                       struct binder_ref *ref;
-                       const char *debug_string;
-
-                       if (get_user(target, (uint32_t __user *)ptr))
-                               return -EFAULT;
-                       ptr += sizeof(uint32_t);
-                       if (target == 0 && binder_context_mgr_node &&
-                           (cmd == BC_INCREFS || cmd == BC_ACQUIRE)) {
-                               ref = binder_get_ref_for_node(proc,
-                                              binder_context_mgr_node);
-                               if (ref->desc != target) {
-                                       binder_user_error("%d:%d tried to acquire reference to desc 0, got %d instead\n",
-                                               proc->pid, thread->pid,
-                                               ref->desc);
-                               }
-                       } else
-                               ref = binder_get_ref(proc, target);
-                       if (ref == NULL) {
-                               binder_user_error("%d:%d refcount change on invalid ref %d\n",
-                                       proc->pid, thread->pid, target);
-                               break;
-                       }
-                       switch (cmd) {
-                       case BC_INCREFS:
-                               debug_string = "IncRefs";
-                               binder_inc_ref(ref, 0, NULL);
-                               break;
-                       case BC_ACQUIRE:
-                               debug_string = "Acquire";
-                               binder_inc_ref(ref, 1, NULL);
-                               break;
-                       case BC_RELEASE:
-                               debug_string = "Release";
-                               binder_dec_ref(ref, 1);
-                               break;
-                       case BC_DECREFS:
-                       default:
-                               debug_string = "DecRefs";
-                               binder_dec_ref(ref, 0);
-                               break;
-                       }
-                       binder_debug(BINDER_DEBUG_USER_REFS,
-                                    "%d:%d %s ref %d desc %d s %d w %d for node %d\n",
-                                    proc->pid, thread->pid, debug_string, ref->debug_id,
-                                    ref->desc, ref->strong, ref->weak, ref->node->debug_id);
-                       break;
-               }
-               case BC_INCREFS_DONE:
-               case BC_ACQUIRE_DONE: {
-                       binder_uintptr_t node_ptr;
-                       binder_uintptr_t cookie;
-                       struct binder_node *node;
-
-                       if (get_user(node_ptr, (binder_uintptr_t __user *)ptr))
-                               return -EFAULT;
-                       ptr += sizeof(binder_uintptr_t);
-                       if (get_user(cookie, (binder_uintptr_t __user *)ptr))
-                               return -EFAULT;
-                       ptr += sizeof(binder_uintptr_t);
-                       node = binder_get_node(proc, node_ptr);
-                       if (node == NULL) {
-                               binder_user_error("%d:%d %s u%016llx no match\n",
-                                       proc->pid, thread->pid,
-                                       cmd == BC_INCREFS_DONE ?
-                                       "BC_INCREFS_DONE" :
-                                       "BC_ACQUIRE_DONE",
-                                       (u64)node_ptr);
-                               break;
-                       }
-                       if (cookie != node->cookie) {
-                               binder_user_error("%d:%d %s u%016llx node %d cookie mismatch %016llx != %016llx\n",
-                                       proc->pid, thread->pid,
-                                       cmd == BC_INCREFS_DONE ?
-                                       "BC_INCREFS_DONE" : "BC_ACQUIRE_DONE",
-                                       (u64)node_ptr, node->debug_id,
-                                       (u64)cookie, (u64)node->cookie);
-                               break;
-                       }
-                       if (cmd == BC_ACQUIRE_DONE) {
-                               if (node->pending_strong_ref == 0) {
-                                       binder_user_error("%d:%d BC_ACQUIRE_DONE node %d has no pending acquire request\n",
-                                               proc->pid, thread->pid,
-                                               node->debug_id);
-                                       break;
-                               }
-                               node->pending_strong_ref = 0;
-                       } else {
-                               if (node->pending_weak_ref == 0) {
-                                       binder_user_error("%d:%d BC_INCREFS_DONE node %d has no pending increfs request\n",
-                                               proc->pid, thread->pid,
-                                               node->debug_id);
-                                       break;
-                               }
-                               node->pending_weak_ref = 0;
-                       }
-                       binder_dec_node(node, cmd == BC_ACQUIRE_DONE, 0);
-                       binder_debug(BINDER_DEBUG_USER_REFS,
-                                    "%d:%d %s node %d ls %d lw %d\n",
-                                    proc->pid, thread->pid,
-                                    cmd == BC_INCREFS_DONE ? "BC_INCREFS_DONE" : "BC_ACQUIRE_DONE",
-                                    node->debug_id, node->local_strong_refs, node->local_weak_refs);
-                       break;
-               }
-               case BC_ATTEMPT_ACQUIRE:
-                       pr_err("BC_ATTEMPT_ACQUIRE not supported\n");
-                       return -EINVAL;
-               case BC_ACQUIRE_RESULT:
-                       pr_err("BC_ACQUIRE_RESULT not supported\n");
-                       return -EINVAL;
-
-               case BC_FREE_BUFFER: {
-                       binder_uintptr_t data_ptr;
-                       struct binder_buffer *buffer;
-
-                       if (get_user(data_ptr, (binder_uintptr_t __user *)ptr))
-                               return -EFAULT;
-                       ptr += sizeof(binder_uintptr_t);
-
-                       buffer = binder_buffer_lookup(proc, data_ptr);
-                       if (buffer == NULL) {
-                               binder_user_error("%d:%d BC_FREE_BUFFER u%016llx no match\n",
-                                       proc->pid, thread->pid, (u64)data_ptr);
-                               break;
-                       }
-                       if (!buffer->allow_user_free) {
-                               binder_user_error("%d:%d BC_FREE_BUFFER u%016llx matched unreturned buffer\n",
-                                       proc->pid, thread->pid, (u64)data_ptr);
-                               break;
-                       }
-                       binder_debug(BINDER_DEBUG_FREE_BUFFER,
-                                    "%d:%d BC_FREE_BUFFER u%016llx found buffer %d for %s transaction\n",
-                                    proc->pid, thread->pid, (u64)data_ptr,
-                                    buffer->debug_id,
-                                    buffer->transaction ? "active" : "finished");
-
-                       if (buffer->transaction) {
-                               buffer->transaction->buffer = NULL;
-                               buffer->transaction = NULL;
-                       }
-                       if (buffer->async_transaction && buffer->target_node) {
-                               BUG_ON(!buffer->target_node->has_async_transaction);
-                               if (list_empty(&buffer->target_node->async_todo))
-                                       buffer->target_node->has_async_transaction = 0;
-                               else
-                                       list_move_tail(buffer->target_node->async_todo.next, &thread->todo);
-                       }
-                       trace_binder_transaction_buffer_release(buffer);
-                       binder_transaction_buffer_release(proc, buffer, NULL);
-                       binder_free_buf(proc, buffer);
-                       break;
-               }
-
-               case BC_TRANSACTION:
-               case BC_REPLY: {
-                       struct binder_transaction_data tr;
-
-                       if (copy_from_user(&tr, ptr, sizeof(tr)))
-                               return -EFAULT;
-                       ptr += sizeof(tr);
-                       binder_transaction(proc, thread, &tr, cmd == BC_REPLY);
-                       break;
-               }
-
-               case BC_REGISTER_LOOPER:
-                       binder_debug(BINDER_DEBUG_THREADS,
-                                    "%d:%d BC_REGISTER_LOOPER\n",
-                                    proc->pid, thread->pid);
-                       if (thread->looper & BINDER_LOOPER_STATE_ENTERED) {
-                               thread->looper |= BINDER_LOOPER_STATE_INVALID;
-                               binder_user_error("%d:%d ERROR: BC_REGISTER_LOOPER called after BC_ENTER_LOOPER\n",
-                                       proc->pid, thread->pid);
-                       } else if (proc->requested_threads == 0) {
-                               thread->looper |= BINDER_LOOPER_STATE_INVALID;
-                               binder_user_error("%d:%d ERROR: BC_REGISTER_LOOPER called without request\n",
-                                       proc->pid, thread->pid);
-                       } else {
-                               proc->requested_threads--;
-                               proc->requested_threads_started++;
-                       }
-                       thread->looper |= BINDER_LOOPER_STATE_REGISTERED;
-                       break;
-               case BC_ENTER_LOOPER:
-                       binder_debug(BINDER_DEBUG_THREADS,
-                                    "%d:%d BC_ENTER_LOOPER\n",
-                                    proc->pid, thread->pid);
-                       if (thread->looper & BINDER_LOOPER_STATE_REGISTERED) {
-                               thread->looper |= BINDER_LOOPER_STATE_INVALID;
-                               binder_user_error("%d:%d ERROR: BC_ENTER_LOOPER called after BC_REGISTER_LOOPER\n",
-                                       proc->pid, thread->pid);
-                       }
-                       thread->looper |= BINDER_LOOPER_STATE_ENTERED;
-                       break;
-               case BC_EXIT_LOOPER:
-                       binder_debug(BINDER_DEBUG_THREADS,
-                                    "%d:%d BC_EXIT_LOOPER\n",
-                                    proc->pid, thread->pid);
-                       thread->looper |= BINDER_LOOPER_STATE_EXITED;
-                       break;
-
-               case BC_REQUEST_DEATH_NOTIFICATION:
-               case BC_CLEAR_DEATH_NOTIFICATION: {
-                       uint32_t target;
-                       binder_uintptr_t cookie;
-                       struct binder_ref *ref;
-                       struct binder_ref_death *death;
-
-                       if (get_user(target, (uint32_t __user *)ptr))
-                               return -EFAULT;
-                       ptr += sizeof(uint32_t);
-                       if (get_user(cookie, (binder_uintptr_t __user *)ptr))
-                               return -EFAULT;
-                       ptr += sizeof(binder_uintptr_t);
-                       ref = binder_get_ref(proc, target);
-                       if (ref == NULL) {
-                               binder_user_error("%d:%d %s invalid ref %d\n",
-                                       proc->pid, thread->pid,
-                                       cmd == BC_REQUEST_DEATH_NOTIFICATION ?
-                                       "BC_REQUEST_DEATH_NOTIFICATION" :
-                                       "BC_CLEAR_DEATH_NOTIFICATION",
-                                       target);
-                               break;
-                       }
-
-                       binder_debug(BINDER_DEBUG_DEATH_NOTIFICATION,
-                                    "%d:%d %s %016llx ref %d desc %d s %d w %d for node %d\n",
-                                    proc->pid, thread->pid,
-                                    cmd == BC_REQUEST_DEATH_NOTIFICATION ?
-                                    "BC_REQUEST_DEATH_NOTIFICATION" :
-                                    "BC_CLEAR_DEATH_NOTIFICATION",
-                                    (u64)cookie, ref->debug_id, ref->desc,
-                                    ref->strong, ref->weak, ref->node->debug_id);
-
-                       if (cmd == BC_REQUEST_DEATH_NOTIFICATION) {
-                               if (ref->death) {
-                                       binder_user_error("%d:%d BC_REQUEST_DEATH_NOTIFICATION death notification already set\n",
-                                               proc->pid, thread->pid);
-                                       break;
-                               }
-                               death = kzalloc(sizeof(*death), GFP_KERNEL);
-                               if (death == NULL) {
-                                       thread->return_error = BR_ERROR;
-                                       binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
-                                                    "%d:%d BC_REQUEST_DEATH_NOTIFICATION failed\n",
-                                                    proc->pid, thread->pid);
-                                       break;
-                               }
-                               binder_stats_created(BINDER_STAT_DEATH);
-                               INIT_LIST_HEAD(&death->work.entry);
-                               death->cookie = cookie;
-                               ref->death = death;
-                               if (ref->node->proc == NULL) {
-                                       ref->death->work.type = BINDER_WORK_DEAD_BINDER;
-                                       if (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | BINDER_LOOPER_STATE_ENTERED)) {
-                                               list_add_tail(&ref->death->work.entry, &thread->todo);
-                                       } else {
-                                               list_add_tail(&ref->death->work.entry, &proc->todo);
-                                               wake_up_interruptible(&proc->wait);
-                                       }
-                               }
-                       } else {
-                               if (ref->death == NULL) {
-                                       binder_user_error("%d:%d BC_CLEAR_DEATH_NOTIFICATION death notification not active\n",
-                                               proc->pid, thread->pid);
-                                       break;
-                               }
-                               death = ref->death;
-                               if (death->cookie != cookie) {
-                                       binder_user_error("%d:%d BC_CLEAR_DEATH_NOTIFICATION death notification cookie mismatch %016llx != %016llx\n",
-                                               proc->pid, thread->pid,
-                                               (u64)death->cookie,
-                                               (u64)cookie);
-                                       break;
-                               }
-                               ref->death = NULL;
-                               if (list_empty(&death->work.entry)) {
-                                       death->work.type = BINDER_WORK_CLEAR_DEATH_NOTIFICATION;
-                                       if (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | BINDER_LOOPER_STATE_ENTERED)) {
-                                               list_add_tail(&death->work.entry, &thread->todo);
-                                       } else {
-                                               list_add_tail(&death->work.entry, &proc->todo);
-                                               wake_up_interruptible(&proc->wait);
-                                       }
-                               } else {
-                                       BUG_ON(death->work.type != BINDER_WORK_DEAD_BINDER);
-                                       death->work.type = BINDER_WORK_DEAD_BINDER_AND_CLEAR;
-                               }
-                       }
-               } break;
-               case BC_DEAD_BINDER_DONE: {
-                       struct binder_work *w;
-                       binder_uintptr_t cookie;
-                       struct binder_ref_death *death = NULL;
-
-                       if (get_user(cookie, (binder_uintptr_t __user *)ptr))
-                               return -EFAULT;
-
-                       ptr += sizeof(void *);
-                       list_for_each_entry(w, &proc->delivered_death, entry) {
-                               struct binder_ref_death *tmp_death = container_of(w, struct binder_ref_death, work);
-
-                               if (tmp_death->cookie == cookie) {
-                                       death = tmp_death;
-                                       break;
-                               }
-                       }
-                       binder_debug(BINDER_DEBUG_DEAD_BINDER,
-                                    "%d:%d BC_DEAD_BINDER_DONE %016llx found %p\n",
-                                    proc->pid, thread->pid, (u64)cookie,
-                                    death);
-                       if (death == NULL) {
-                               binder_user_error("%d:%d BC_DEAD_BINDER_DONE %016llx not found\n",
-                                       proc->pid, thread->pid, (u64)cookie);
-                               break;
-                       }
-
-                       list_del_init(&death->work.entry);
-                       if (death->work.type == BINDER_WORK_DEAD_BINDER_AND_CLEAR) {
-                               death->work.type = BINDER_WORK_CLEAR_DEATH_NOTIFICATION;
-                               if (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | BINDER_LOOPER_STATE_ENTERED)) {
-                                       list_add_tail(&death->work.entry, &thread->todo);
-                               } else {
-                                       list_add_tail(&death->work.entry, &proc->todo);
-                                       wake_up_interruptible(&proc->wait);
-                               }
-                       }
-               } break;
-
-               default:
-                       pr_err("%d:%d unknown command %d\n",
-                              proc->pid, thread->pid, cmd);
-                       return -EINVAL;
-               }
-               *consumed = ptr - buffer;
-       }
-       return 0;
-}
-
-static void binder_stat_br(struct binder_proc *proc,
-                          struct binder_thread *thread, uint32_t cmd)
-{
-       trace_binder_return(cmd);
-       if (_IOC_NR(cmd) < ARRAY_SIZE(binder_stats.br)) {
-               binder_stats.br[_IOC_NR(cmd)]++;
-               proc->stats.br[_IOC_NR(cmd)]++;
-               thread->stats.br[_IOC_NR(cmd)]++;
-       }
-}
-
-static int binder_has_proc_work(struct binder_proc *proc,
-                               struct binder_thread *thread)
-{
-       return !list_empty(&proc->todo) ||
-               (thread->looper & BINDER_LOOPER_STATE_NEED_RETURN);
-}
-
-static int binder_has_thread_work(struct binder_thread *thread)
-{
-       return !list_empty(&thread->todo) || thread->return_error != BR_OK ||
-               (thread->looper & BINDER_LOOPER_STATE_NEED_RETURN);
-}
-
-static int binder_thread_read(struct binder_proc *proc,
-                             struct binder_thread *thread,
-                             binder_uintptr_t binder_buffer, size_t size,
-                             binder_size_t *consumed, int non_block)
-{
-       void __user *buffer = (void __user *)(uintptr_t)binder_buffer;
-       void __user *ptr = buffer + *consumed;
-       void __user *end = buffer + size;
-
-       int ret = 0;
-       int wait_for_proc_work;
-
-       if (*consumed == 0) {
-               if (put_user(BR_NOOP, (uint32_t __user *)ptr))
-                       return -EFAULT;
-               ptr += sizeof(uint32_t);
-       }
-
-retry:
-       wait_for_proc_work = thread->transaction_stack == NULL &&
-                               list_empty(&thread->todo);
-
-       if (thread->return_error != BR_OK && ptr < end) {
-               if (thread->return_error2 != BR_OK) {
-                       if (put_user(thread->return_error2, (uint32_t __user *)ptr))
-                               return -EFAULT;
-                       ptr += sizeof(uint32_t);
-                       binder_stat_br(proc, thread, thread->return_error2);
-                       if (ptr == end)
-                               goto done;
-                       thread->return_error2 = BR_OK;
-               }
-               if (put_user(thread->return_error, (uint32_t __user *)ptr))
-                       return -EFAULT;
-               ptr += sizeof(uint32_t);
-               binder_stat_br(proc, thread, thread->return_error);
-               thread->return_error = BR_OK;
-               goto done;
-       }
-
-
-       thread->looper |= BINDER_LOOPER_STATE_WAITING;
-       if (wait_for_proc_work)
-               proc->ready_threads++;
-
-       binder_unlock(__func__);
-
-       trace_binder_wait_for_work(wait_for_proc_work,
-                                  !!thread->transaction_stack,
-                                  !list_empty(&thread->todo));
-       if (wait_for_proc_work) {
-               if (!(thread->looper & (BINDER_LOOPER_STATE_REGISTERED |
-                                       BINDER_LOOPER_STATE_ENTERED))) {
-                       binder_user_error("%d:%d ERROR: Thread waiting for process work before calling BC_REGISTER_LOOPER or BC_ENTER_LOOPER (state %x)\n",
-                               proc->pid, thread->pid, thread->looper);
-                       wait_event_interruptible(binder_user_error_wait,
-                                                binder_stop_on_user_error < 2);
-               }
-               binder_set_nice(proc->default_priority);
-               if (non_block) {
-                       if (!binder_has_proc_work(proc, thread))
-                               ret = -EAGAIN;
-               } else
-                       ret = wait_event_freezable_exclusive(proc->wait, binder_has_proc_work(proc, thread));
-       } else {
-               if (non_block) {
-                       if (!binder_has_thread_work(thread))
-                               ret = -EAGAIN;
-               } else
-                       ret = wait_event_freezable(thread->wait, binder_has_thread_work(thread));
-       }
-
-       binder_lock(__func__);
-
-       if (wait_for_proc_work)
-               proc->ready_threads--;
-       thread->looper &= ~BINDER_LOOPER_STATE_WAITING;
-
-       if (ret)
-               return ret;
-
-       while (1) {
-               uint32_t cmd;
-               struct binder_transaction_data tr;
-               struct binder_work *w;
-               struct binder_transaction *t = NULL;
-
-               if (!list_empty(&thread->todo)) {
-                       w = list_first_entry(&thread->todo, struct binder_work,
-                                            entry);
-               } else if (!list_empty(&proc->todo) && wait_for_proc_work) {
-                       w = list_first_entry(&proc->todo, struct binder_work,
-                                            entry);
-               } else {
-                       /* no data added */
-                       if (ptr - buffer == 4 &&
-                           !(thread->looper & BINDER_LOOPER_STATE_NEED_RETURN))
-                               goto retry;
-                       break;
-               }
-
-               if (end - ptr < sizeof(tr) + 4)
-                       break;
-
-               switch (w->type) {
-               case BINDER_WORK_TRANSACTION: {
-                       t = container_of(w, struct binder_transaction, work);
-               } break;
-               case BINDER_WORK_TRANSACTION_COMPLETE: {
-                       cmd = BR_TRANSACTION_COMPLETE;
-                       if (put_user(cmd, (uint32_t __user *)ptr))
-                               return -EFAULT;
-                       ptr += sizeof(uint32_t);
-
-                       binder_stat_br(proc, thread, cmd);
-                       binder_debug(BINDER_DEBUG_TRANSACTION_COMPLETE,
-                                    "%d:%d BR_TRANSACTION_COMPLETE\n",
-                                    proc->pid, thread->pid);
-
-                       list_del(&w->entry);
-                       kfree(w);
-                       binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE);
-               } break;
-               case BINDER_WORK_NODE: {
-                       struct binder_node *node = container_of(w, struct binder_node, work);
-                       uint32_t cmd = BR_NOOP;
-                       const char *cmd_name;
-                       int strong = node->internal_strong_refs || node->local_strong_refs;
-                       int weak = !hlist_empty(&node->refs) || node->local_weak_refs || strong;
-
-                       if (weak && !node->has_weak_ref) {
-                               cmd = BR_INCREFS;
-                               cmd_name = "BR_INCREFS";
-                               node->has_weak_ref = 1;
-                               node->pending_weak_ref = 1;
-                               node->local_weak_refs++;
-                       } else if (strong && !node->has_strong_ref) {
-                               cmd = BR_ACQUIRE;
-                               cmd_name = "BR_ACQUIRE";
-                               node->has_strong_ref = 1;
-                               node->pending_strong_ref = 1;
-                               node->local_strong_refs++;
-                       } else if (!strong && node->has_strong_ref) {
-                               cmd = BR_RELEASE;
-                               cmd_name = "BR_RELEASE";
-                               node->has_strong_ref = 0;
-                       } else if (!weak && node->has_weak_ref) {
-                               cmd = BR_DECREFS;
-                               cmd_name = "BR_DECREFS";
-                               node->has_weak_ref = 0;
-                       }
-                       if (cmd != BR_NOOP) {
-                               if (put_user(cmd, (uint32_t __user *)ptr))
-                                       return -EFAULT;
-                               ptr += sizeof(uint32_t);
-                               if (put_user(node->ptr,
-                                            (binder_uintptr_t __user *)ptr))
-                                       return -EFAULT;
-                               ptr += sizeof(binder_uintptr_t);
-                               if (put_user(node->cookie,
-                                            (binder_uintptr_t __user *)ptr))
-                                       return -EFAULT;
-                               ptr += sizeof(binder_uintptr_t);
-
-                               binder_stat_br(proc, thread, cmd);
-                               binder_debug(BINDER_DEBUG_USER_REFS,
-                                            "%d:%d %s %d u%016llx c%016llx\n",
-                                            proc->pid, thread->pid, cmd_name,
-                                            node->debug_id,
-                                            (u64)node->ptr, (u64)node->cookie);
-                       } else {
-                               list_del_init(&w->entry);
-                               if (!weak && !strong) {
-                                       binder_debug(BINDER_DEBUG_INTERNAL_REFS,
-                                                    "%d:%d node %d u%016llx c%016llx deleted\n",
-                                                    proc->pid, thread->pid,
-                                                    node->debug_id,
-                                                    (u64)node->ptr,
-                                                    (u64)node->cookie);
-                                       rb_erase(&node->rb_node, &proc->nodes);
-                                       kfree(node);
-                                       binder_stats_deleted(BINDER_STAT_NODE);
-                               } else {
-                                       binder_debug(BINDER_DEBUG_INTERNAL_REFS,
-                                                    "%d:%d node %d u%016llx c%016llx state unchanged\n",
-                                                    proc->pid, thread->pid,
-                                                    node->debug_id,
-                                                    (u64)node->ptr,
-                                                    (u64)node->cookie);
-                               }
-                       }
-               } break;
-               case BINDER_WORK_DEAD_BINDER:
-               case BINDER_WORK_DEAD_BINDER_AND_CLEAR:
-               case BINDER_WORK_CLEAR_DEATH_NOTIFICATION: {
-                       struct binder_ref_death *death;
-                       uint32_t cmd;
-
-                       death = container_of(w, struct binder_ref_death, work);
-                       if (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION)
-                               cmd = BR_CLEAR_DEATH_NOTIFICATION_DONE;
-                       else
-                               cmd = BR_DEAD_BINDER;
-                       if (put_user(cmd, (uint32_t __user *)ptr))
-                               return -EFAULT;
-                       ptr += sizeof(uint32_t);
-                       if (put_user(death->cookie,
-                                    (binder_uintptr_t __user *)ptr))
-                               return -EFAULT;
-                       ptr += sizeof(binder_uintptr_t);
-                       binder_stat_br(proc, thread, cmd);
-                       binder_debug(BINDER_DEBUG_DEATH_NOTIFICATION,
-                                    "%d:%d %s %016llx\n",
-                                     proc->pid, thread->pid,
-                                     cmd == BR_DEAD_BINDER ?
-                                     "BR_DEAD_BINDER" :
-                                     "BR_CLEAR_DEATH_NOTIFICATION_DONE",
-                                     (u64)death->cookie);
-
-                       if (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION) {
-                               list_del(&w->entry);
-                               kfree(death);
-                               binder_stats_deleted(BINDER_STAT_DEATH);
-                       } else
-                               list_move(&w->entry, &proc->delivered_death);
-                       if (cmd == BR_DEAD_BINDER)
-                               goto done; /* DEAD_BINDER notifications can cause transactions */
-               } break;
-               }
-
-               if (!t)
-                       continue;
-
-               BUG_ON(t->buffer == NULL);
-               if (t->buffer->target_node) {
-                       struct binder_node *target_node = t->buffer->target_node;
-
-                       tr.target.ptr = target_node->ptr;
-                       tr.cookie =  target_node->cookie;
-                       t->saved_priority = task_nice(current);
-                       if (t->priority < target_node->min_priority &&
-                           !(t->flags & TF_ONE_WAY))
-                               binder_set_nice(t->priority);
-                       else if (!(t->flags & TF_ONE_WAY) ||
-                                t->saved_priority > target_node->min_priority)
-                               binder_set_nice(target_node->min_priority);
-                       cmd = BR_TRANSACTION;
-               } else {
-                       tr.target.ptr = 0;
-                       tr.cookie = 0;
-                       cmd = BR_REPLY;
-               }
-               tr.code = t->code;
-               tr.flags = t->flags;
-               tr.sender_euid = from_kuid(current_user_ns(), t->sender_euid);
-
-               if (t->from) {
-                       struct task_struct *sender = t->from->proc->tsk;
-
-                       tr.sender_pid = task_tgid_nr_ns(sender,
-                                                       task_active_pid_ns(current));
-               } else {
-                       tr.sender_pid = 0;
-               }
-
-               tr.data_size = t->buffer->data_size;
-               tr.offsets_size = t->buffer->offsets_size;
-               tr.data.ptr.buffer = (binder_uintptr_t)(
-                                       (uintptr_t)t->buffer->data +
-                                       proc->user_buffer_offset);
-               tr.data.ptr.offsets = tr.data.ptr.buffer +
-                                       ALIGN(t->buffer->data_size,
-                                           sizeof(void *));
-
-               if (put_user(cmd, (uint32_t __user *)ptr))
-                       return -EFAULT;
-               ptr += sizeof(uint32_t);
-               if (copy_to_user(ptr, &tr, sizeof(tr)))
-                       return -EFAULT;
-               ptr += sizeof(tr);
-
-               trace_binder_transaction_received(t);
-               binder_stat_br(proc, thread, cmd);
-               binder_debug(BINDER_DEBUG_TRANSACTION,
-                            "%d:%d %s %d %d:%d, cmd %d size %zd-%zd ptr %016llx-%016llx\n",
-                            proc->pid, thread->pid,
-                            (cmd == BR_TRANSACTION) ? "BR_TRANSACTION" :
-                            "BR_REPLY",
-                            t->debug_id, t->from ? t->from->proc->pid : 0,
-                            t->from ? t->from->pid : 0, cmd,
-                            t->buffer->data_size, t->buffer->offsets_size,
-                            (u64)tr.data.ptr.buffer, (u64)tr.data.ptr.offsets);
-
-               list_del(&t->work.entry);
-               t->buffer->allow_user_free = 1;
-               if (cmd == BR_TRANSACTION && !(t->flags & TF_ONE_WAY)) {
-                       t->to_parent = thread->transaction_stack;
-                       t->to_thread = thread;
-                       thread->transaction_stack = t;
-               } else {
-                       t->buffer->transaction = NULL;
-                       kfree(t);
-                       binder_stats_deleted(BINDER_STAT_TRANSACTION);
-               }
-               break;
-       }
-
-done:
-
-       *consumed = ptr - buffer;
-       if (proc->requested_threads + proc->ready_threads == 0 &&
-           proc->requested_threads_started < proc->max_threads &&
-           (thread->looper & (BINDER_LOOPER_STATE_REGISTERED |
-            BINDER_LOOPER_STATE_ENTERED)) /* the user-space code fails to */
-            /*spawn a new thread if we leave this out */) {
-               proc->requested_threads++;
-               binder_debug(BINDER_DEBUG_THREADS,
-                            "%d:%d BR_SPAWN_LOOPER\n",
-                            proc->pid, thread->pid);
-               if (put_user(BR_SPAWN_LOOPER, (uint32_t __user *)buffer))
-                       return -EFAULT;
-               binder_stat_br(proc, thread, BR_SPAWN_LOOPER);
-       }
-       return 0;
-}
-
-static void binder_release_work(struct list_head *list)
-{
-       struct binder_work *w;
-
-       while (!list_empty(list)) {
-               w = list_first_entry(list, struct binder_work, entry);
-               list_del_init(&w->entry);
-               switch (w->type) {
-               case BINDER_WORK_TRANSACTION: {
-                       struct binder_transaction *t;
-
-                       t = container_of(w, struct binder_transaction, work);
-                       if (t->buffer->target_node &&
-                           !(t->flags & TF_ONE_WAY)) {
-                               binder_send_failed_reply(t, BR_DEAD_REPLY);
-                       } else {
-                               binder_debug(BINDER_DEBUG_DEAD_TRANSACTION,
-                                       "undelivered transaction %d\n",
-                                       t->debug_id);
-                               t->buffer->transaction = NULL;
-                               kfree(t);
-                               binder_stats_deleted(BINDER_STAT_TRANSACTION);
-                       }
-               } break;
-               case BINDER_WORK_TRANSACTION_COMPLETE: {
-                       binder_debug(BINDER_DEBUG_DEAD_TRANSACTION,
-                               "undelivered TRANSACTION_COMPLETE\n");
-                       kfree(w);
-                       binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE);
-               } break;
-               case BINDER_WORK_DEAD_BINDER_AND_CLEAR:
-               case BINDER_WORK_CLEAR_DEATH_NOTIFICATION: {
-                       struct binder_ref_death *death;
-
-                       death = container_of(w, struct binder_ref_death, work);
-                       binder_debug(BINDER_DEBUG_DEAD_TRANSACTION,
-                               "undelivered death notification, %016llx\n",
-                               (u64)death->cookie);
-                       kfree(death);
-                       binder_stats_deleted(BINDER_STAT_DEATH);
-               } break;
-               default:
-                       pr_err("unexpected work type, %d, not freed\n",
-                              w->type);
-                       break;
-               }
-       }
-
-}
-
-static struct binder_thread *binder_get_thread(struct binder_proc *proc)
-{
-       struct binder_thread *thread = NULL;
-       struct rb_node *parent = NULL;
-       struct rb_node **p = &proc->threads.rb_node;
-
-       while (*p) {
-               parent = *p;
-               thread = rb_entry(parent, struct binder_thread, rb_node);
-
-               if (current->pid < thread->pid)
-                       p = &(*p)->rb_left;
-               else if (current->pid > thread->pid)
-                       p = &(*p)->rb_right;
-               else
-                       break;
-       }
-       if (*p == NULL) {
-               thread = kzalloc(sizeof(*thread), GFP_KERNEL);
-               if (thread == NULL)
-                       return NULL;
-               binder_stats_created(BINDER_STAT_THREAD);
-               thread->proc = proc;
-               thread->pid = current->pid;
-               init_waitqueue_head(&thread->wait);
-               INIT_LIST_HEAD(&thread->todo);
-               rb_link_node(&thread->rb_node, parent, p);
-               rb_insert_color(&thread->rb_node, &proc->threads);
-               thread->looper |= BINDER_LOOPER_STATE_NEED_RETURN;
-               thread->return_error = BR_OK;
-               thread->return_error2 = BR_OK;
-       }
-       return thread;
-}
-
-static int binder_free_thread(struct binder_proc *proc,
-                             struct binder_thread *thread)
-{
-       struct binder_transaction *t;
-       struct binder_transaction *send_reply = NULL;
-       int active_transactions = 0;
-
-       rb_erase(&thread->rb_node, &proc->threads);
-       t = thread->transaction_stack;
-       if (t && t->to_thread == thread)
-               send_reply = t;
-       while (t) {
-               active_transactions++;
-               binder_debug(BINDER_DEBUG_DEAD_TRANSACTION,
-                            "release %d:%d transaction %d %s, still active\n",
-                             proc->pid, thread->pid,
-                            t->debug_id,
-                            (t->to_thread == thread) ? "in" : "out");
-
-               if (t->to_thread == thread) {
-                       t->to_proc = NULL;
-                       t->to_thread = NULL;
-                       if (t->buffer) {
-                               t->buffer->transaction = NULL;
-                               t->buffer = NULL;
-                       }
-                       t = t->to_parent;
-               } else if (t->from == thread) {
-                       t->from = NULL;
-                       t = t->from_parent;
-               } else
-                       BUG();
-       }
-       if (send_reply)
-               binder_send_failed_reply(send_reply, BR_DEAD_REPLY);
-       binder_release_work(&thread->todo);
-       kfree(thread);
-       binder_stats_deleted(BINDER_STAT_THREAD);
-       return active_transactions;
-}
-
-static unsigned int binder_poll(struct file *filp,
-                               struct poll_table_struct *wait)
-{
-       struct binder_proc *proc = filp->private_data;
-       struct binder_thread *thread = NULL;
-       int wait_for_proc_work;
-
-       binder_lock(__func__);
-
-       thread = binder_get_thread(proc);
-
-       wait_for_proc_work = thread->transaction_stack == NULL &&
-               list_empty(&thread->todo) && thread->return_error == BR_OK;
-
-       binder_unlock(__func__);
-
-       if (wait_for_proc_work) {
-               if (binder_has_proc_work(proc, thread))
-                       return POLLIN;
-               poll_wait(filp, &proc->wait, wait);
-               if (binder_has_proc_work(proc, thread))
-                       return POLLIN;
-       } else {
-               if (binder_has_thread_work(thread))
-                       return POLLIN;
-               poll_wait(filp, &thread->wait, wait);
-               if (binder_has_thread_work(thread))
-                       return POLLIN;
-       }
-       return 0;
-}
-
-static int binder_ioctl_write_read(struct file *filp,
-                               unsigned int cmd, unsigned long arg,
-                               struct binder_thread *thread)
-{
-       int ret = 0;
-       struct binder_proc *proc = filp->private_data;
-       unsigned int size = _IOC_SIZE(cmd);
-       void __user *ubuf = (void __user *)arg;
-       struct binder_write_read bwr;
-
-       if (size != sizeof(struct binder_write_read)) {
-               ret = -EINVAL;
-               goto out;
-       }
-       if (copy_from_user(&bwr, ubuf, sizeof(bwr))) {
-               ret = -EFAULT;
-               goto out;
-       }
-       binder_debug(BINDER_DEBUG_READ_WRITE,
-                    "%d:%d write %lld at %016llx, read %lld at %016llx\n",
-                    proc->pid, thread->pid,
-                    (u64)bwr.write_size, (u64)bwr.write_buffer,
-                    (u64)bwr.read_size, (u64)bwr.read_buffer);
-
-       if (bwr.write_size > 0) {
-               ret = binder_thread_write(proc, thread,
-                                         bwr.write_buffer,
-                                         bwr.write_size,
-                                         &bwr.write_consumed);
-               trace_binder_write_done(ret);
-               if (ret < 0) {
-                       bwr.read_consumed = 0;
-                       if (copy_to_user(ubuf, &bwr, sizeof(bwr)))
-                               ret = -EFAULT;
-                       goto out;
-               }
-       }
-       if (bwr.read_size > 0) {
-               ret = binder_thread_read(proc, thread, bwr.read_buffer,
-                                        bwr.read_size,
-                                        &bwr.read_consumed,
-                                        filp->f_flags & O_NONBLOCK);
-               trace_binder_read_done(ret);
-               if (!list_empty(&proc->todo))
-                       wake_up_interruptible(&proc->wait);
-               if (ret < 0) {
-                       if (copy_to_user(ubuf, &bwr, sizeof(bwr)))
-                               ret = -EFAULT;
-                       goto out;
-               }
-       }
-       binder_debug(BINDER_DEBUG_READ_WRITE,
-                    "%d:%d wrote %lld of %lld, read return %lld of %lld\n",
-                    proc->pid, thread->pid,
-                    (u64)bwr.write_consumed, (u64)bwr.write_size,
-                    (u64)bwr.read_consumed, (u64)bwr.read_size);
-       if (copy_to_user(ubuf, &bwr, sizeof(bwr))) {
-               ret = -EFAULT;
-               goto out;
-       }
-out:
-       return ret;
-}
-
-static int binder_ioctl_set_ctx_mgr(struct file *filp)
-{
-       int ret = 0;
-       struct binder_proc *proc = filp->private_data;
-       kuid_t curr_euid = current_euid();
-
-       if (binder_context_mgr_node != NULL) {
-               pr_err("BINDER_SET_CONTEXT_MGR already set\n");
-               ret = -EBUSY;
-               goto out;
-       }
-       if (uid_valid(binder_context_mgr_uid)) {
-               if (!uid_eq(binder_context_mgr_uid, curr_euid)) {
-                       pr_err("BINDER_SET_CONTEXT_MGR bad uid %d != %d\n",
-                              from_kuid(&init_user_ns, curr_euid),
-                              from_kuid(&init_user_ns,
-                                       binder_context_mgr_uid));
-                       ret = -EPERM;
-                       goto out;
-               }
-       } else {
-               binder_context_mgr_uid = curr_euid;
-       }
-       binder_context_mgr_node = binder_new_node(proc, 0, 0);
-       if (binder_context_mgr_node == NULL) {
-               ret = -ENOMEM;
-               goto out;
-       }
-       binder_context_mgr_node->local_weak_refs++;
-       binder_context_mgr_node->local_strong_refs++;
-       binder_context_mgr_node->has_strong_ref = 1;
-       binder_context_mgr_node->has_weak_ref = 1;
-out:
-       return ret;
-}
-
-static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
-{
-       int ret;
-       struct binder_proc *proc = filp->private_data;
-       struct binder_thread *thread;
-       unsigned int size = _IOC_SIZE(cmd);
-       void __user *ubuf = (void __user *)arg;
-
-       /*pr_info("binder_ioctl: %d:%d %x %lx\n",
-                       proc->pid, current->pid, cmd, arg);*/
-
-       trace_binder_ioctl(cmd, arg);
-
-       ret = wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2);
-       if (ret)
-               goto err_unlocked;
-
-       binder_lock(__func__);
-       thread = binder_get_thread(proc);
-       if (thread == NULL) {
-               ret = -ENOMEM;
-               goto err;
-       }
-
-       switch (cmd) {
-       case BINDER_WRITE_READ:
-               ret = binder_ioctl_write_read(filp, cmd, arg, thread);
-               if (ret)
-                       goto err;
-               break;
-       case BINDER_SET_MAX_THREADS:
-               if (copy_from_user(&proc->max_threads, ubuf, sizeof(proc->max_threads))) {
-                       ret = -EINVAL;
-                       goto err;
-               }
-               break;
-       case BINDER_SET_CONTEXT_MGR:
-               ret = binder_ioctl_set_ctx_mgr(filp);
-               if (ret)
-                       goto err;
-               break;
-       case BINDER_THREAD_EXIT:
-               binder_debug(BINDER_DEBUG_THREADS, "%d:%d exit\n",
-                            proc->pid, thread->pid);
-               binder_free_thread(proc, thread);
-               thread = NULL;
-               break;
-       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,
-                            &ver->protocol_version)) {
-                       ret = -EINVAL;
-                       goto err;
-               }
-               break;
-       }
-       default:
-               ret = -EINVAL;
-               goto err;
-       }
-       ret = 0;
-err:
-       if (thread)
-               thread->looper &= ~BINDER_LOOPER_STATE_NEED_RETURN;
-       binder_unlock(__func__);
-       wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2);
-       if (ret && ret != -ERESTARTSYS)
-               pr_info("%d:%d ioctl %x %lx returned %d\n", proc->pid, current->pid, cmd, arg, ret);
-err_unlocked:
-       trace_binder_ioctl_done(ret);
-       return ret;
-}
-
-static void binder_vma_open(struct vm_area_struct *vma)
-{
-       struct binder_proc *proc = vma->vm_private_data;
-
-       binder_debug(BINDER_DEBUG_OPEN_CLOSE,
-                    "%d open vm area %lx-%lx (%ld K) vma %lx pagep %lx\n",
-                    proc->pid, vma->vm_start, vma->vm_end,
-                    (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
-                    (unsigned long)pgprot_val(vma->vm_page_prot));
-}
-
-static void binder_vma_close(struct vm_area_struct *vma)
-{
-       struct binder_proc *proc = vma->vm_private_data;
-
-       binder_debug(BINDER_DEBUG_OPEN_CLOSE,
-                    "%d close vm area %lx-%lx (%ld K) vma %lx pagep %lx\n",
-                    proc->pid, vma->vm_start, vma->vm_end,
-                    (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
-                    (unsigned long)pgprot_val(vma->vm_page_prot));
-       proc->vma = NULL;
-       proc->vma_vm_mm = NULL;
-       binder_defer_work(proc, BINDER_DEFERRED_PUT_FILES);
-}
-
-static int binder_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
-{
-       return VM_FAULT_SIGBUS;
-}
-
-static struct vm_operations_struct binder_vm_ops = {
-       .open = binder_vma_open,
-       .close = binder_vma_close,
-       .fault = binder_vm_fault,
-};
-
-static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
-{
-       int ret;
-       struct vm_struct *area;
-       struct binder_proc *proc = filp->private_data;
-       const char *failure_string;
-       struct binder_buffer *buffer;
-
-       if (proc->tsk != current)
-               return -EINVAL;
-
-       if ((vma->vm_end - vma->vm_start) > SZ_4M)
-               vma->vm_end = vma->vm_start + SZ_4M;
-
-       binder_debug(BINDER_DEBUG_OPEN_CLOSE,
-                    "binder_mmap: %d %lx-%lx (%ld K) vma %lx pagep %lx\n",
-                    proc->pid, vma->vm_start, vma->vm_end,
-                    (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
-                    (unsigned long)pgprot_val(vma->vm_page_prot));
-
-       if (vma->vm_flags & FORBIDDEN_MMAP_FLAGS) {
-               ret = -EPERM;
-               failure_string = "bad vm_flags";
-               goto err_bad_arg;
-       }
-       vma->vm_flags = (vma->vm_flags | VM_DONTCOPY) & ~VM_MAYWRITE;
-
-       mutex_lock(&binder_mmap_lock);
-       if (proc->buffer) {
-               ret = -EBUSY;
-               failure_string = "already mapped";
-               goto err_already_mapped;
-       }
-
-       area = get_vm_area(vma->vm_end - vma->vm_start, VM_IOREMAP);
-       if (area == NULL) {
-               ret = -ENOMEM;
-               failure_string = "get_vm_area";
-               goto err_get_vm_area_failed;
-       }
-       proc->buffer = area->addr;
-       proc->user_buffer_offset = vma->vm_start - (uintptr_t)proc->buffer;
-       mutex_unlock(&binder_mmap_lock);
-
-#ifdef CONFIG_CPU_CACHE_VIPT
-       if (cache_is_vipt_aliasing()) {
-               while (CACHE_COLOUR((vma->vm_start ^ (uint32_t)proc->buffer))) {
-                       pr_info("binder_mmap: %d %lx-%lx maps %p bad alignment\n", proc->pid, vma->vm_start, vma->vm_end, proc->buffer);
-                       vma->vm_start += PAGE_SIZE;
-               }
-       }
-#endif
-       proc->pages = kzalloc(sizeof(proc->pages[0]) * ((vma->vm_end - vma->vm_start) / PAGE_SIZE), GFP_KERNEL);
-       if (proc->pages == NULL) {
-               ret = -ENOMEM;
-               failure_string = "alloc page array";
-               goto err_alloc_pages_failed;
-       }
-       proc->buffer_size = vma->vm_end - vma->vm_start;
-
-       vma->vm_ops = &binder_vm_ops;
-       vma->vm_private_data = proc;
-
-       if (binder_update_page_range(proc, 1, proc->buffer, proc->buffer + PAGE_SIZE, vma)) {
-               ret = -ENOMEM;
-               failure_string = "alloc small buf";
-               goto err_alloc_small_buf_failed;
-       }
-       buffer = proc->buffer;
-       INIT_LIST_HEAD(&proc->buffers);
-       list_add(&buffer->entry, &proc->buffers);
-       buffer->free = 1;
-       binder_insert_free_buffer(proc, buffer);
-       proc->free_async_space = proc->buffer_size / 2;
-       barrier();
-       proc->files = get_files_struct(current);
-       proc->vma = vma;
-       proc->vma_vm_mm = vma->vm_mm;
-
-       /*pr_info("binder_mmap: %d %lx-%lx maps %p\n",
-                proc->pid, vma->vm_start, vma->vm_end, proc->buffer);*/
-       return 0;
-
-err_alloc_small_buf_failed:
-       kfree(proc->pages);
-       proc->pages = NULL;
-err_alloc_pages_failed:
-       mutex_lock(&binder_mmap_lock);
-       vfree(proc->buffer);
-       proc->buffer = NULL;
-err_get_vm_area_failed:
-err_already_mapped:
-       mutex_unlock(&binder_mmap_lock);
-err_bad_arg:
-       pr_err("binder_mmap: %d %lx-%lx %s failed %d\n",
-              proc->pid, vma->vm_start, vma->vm_end, failure_string, ret);
-       return ret;
-}
-
-static int binder_open(struct inode *nodp, struct file *filp)
-{
-       struct binder_proc *proc;
-
-       binder_debug(BINDER_DEBUG_OPEN_CLOSE, "binder_open: %d:%d\n",
-                    current->group_leader->pid, current->pid);
-
-       proc = kzalloc(sizeof(*proc), GFP_KERNEL);
-       if (proc == NULL)
-               return -ENOMEM;
-       get_task_struct(current);
-       proc->tsk = current;
-       INIT_LIST_HEAD(&proc->todo);
-       init_waitqueue_head(&proc->wait);
-       proc->default_priority = task_nice(current);
-
-       binder_lock(__func__);
-
-       binder_stats_created(BINDER_STAT_PROC);
-       hlist_add_head(&proc->proc_node, &binder_procs);
-       proc->pid = current->group_leader->pid;
-       INIT_LIST_HEAD(&proc->delivered_death);
-       filp->private_data = proc;
-
-       binder_unlock(__func__);
-
-       if (binder_debugfs_dir_entry_proc) {
-               char strbuf[11];
-
-               snprintf(strbuf, sizeof(strbuf), "%u", proc->pid);
-               proc->debugfs_entry = debugfs_create_file(strbuf, S_IRUGO,
-                       binder_debugfs_dir_entry_proc, proc, &binder_proc_fops);
-       }
-
-       return 0;
-}
-
-static int binder_flush(struct file *filp, fl_owner_t id)
-{
-       struct binder_proc *proc = filp->private_data;
-
-       binder_defer_work(proc, BINDER_DEFERRED_FLUSH);
-
-       return 0;
-}
-
-static void binder_deferred_flush(struct binder_proc *proc)
-{
-       struct rb_node *n;
-       int wake_count = 0;
-
-       for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) {
-               struct binder_thread *thread = rb_entry(n, struct binder_thread, rb_node);
-
-               thread->looper |= BINDER_LOOPER_STATE_NEED_RETURN;
-               if (thread->looper & BINDER_LOOPER_STATE_WAITING) {
-                       wake_up_interruptible(&thread->wait);
-                       wake_count++;
-               }
-       }
-       wake_up_interruptible_all(&proc->wait);
-
-       binder_debug(BINDER_DEBUG_OPEN_CLOSE,
-                    "binder_flush: %d woke %d threads\n", proc->pid,
-                    wake_count);
-}
-
-static int binder_release(struct inode *nodp, struct file *filp)
-{
-       struct binder_proc *proc = filp->private_data;
-
-       debugfs_remove(proc->debugfs_entry);
-       binder_defer_work(proc, BINDER_DEFERRED_RELEASE);
-
-       return 0;
-}
-
-static int binder_node_release(struct binder_node *node, int refs)
-{
-       struct binder_ref *ref;
-       int death = 0;
-
-       list_del_init(&node->work.entry);
-       binder_release_work(&node->async_todo);
-
-       if (hlist_empty(&node->refs)) {
-               kfree(node);
-               binder_stats_deleted(BINDER_STAT_NODE);
-
-               return refs;
-       }
-
-       node->proc = NULL;
-       node->local_strong_refs = 0;
-       node->local_weak_refs = 0;
-       hlist_add_head(&node->dead_node, &binder_dead_nodes);
-
-       hlist_for_each_entry(ref, &node->refs, node_entry) {
-               refs++;
-
-               if (!ref->death)
-                       continue;
-
-               death++;
-
-               if (list_empty(&ref->death->work.entry)) {
-                       ref->death->work.type = BINDER_WORK_DEAD_BINDER;
-                       list_add_tail(&ref->death->work.entry,
-                                     &ref->proc->todo);
-                       wake_up_interruptible(&ref->proc->wait);
-               } else
-                       BUG();
-       }
-
-       binder_debug(BINDER_DEBUG_DEAD_BINDER,
-                    "node %d now dead, refs %d, death %d\n",
-                    node->debug_id, refs, death);
-
-       return refs;
-}
-
-static void binder_deferred_release(struct binder_proc *proc)
-{
-       struct binder_transaction *t;
-       struct rb_node *n;
-       int threads, nodes, incoming_refs, outgoing_refs, buffers,
-               active_transactions, page_count;
-
-       BUG_ON(proc->vma);
-       BUG_ON(proc->files);
-
-       hlist_del(&proc->proc_node);
-
-       if (binder_context_mgr_node && binder_context_mgr_node->proc == proc) {
-               binder_debug(BINDER_DEBUG_DEAD_BINDER,
-                            "%s: %d context_mgr_node gone\n",
-                            __func__, proc->pid);
-               binder_context_mgr_node = NULL;
-       }
-
-       threads = 0;
-       active_transactions = 0;
-       while ((n = rb_first(&proc->threads))) {
-               struct binder_thread *thread;
-
-               thread = rb_entry(n, struct binder_thread, rb_node);
-               threads++;
-               active_transactions += binder_free_thread(proc, thread);
-       }
-
-       nodes = 0;
-       incoming_refs = 0;
-       while ((n = rb_first(&proc->nodes))) {
-               struct binder_node *node;
-
-               node = rb_entry(n, struct binder_node, rb_node);
-               nodes++;
-               rb_erase(&node->rb_node, &proc->nodes);
-               incoming_refs = binder_node_release(node, incoming_refs);
-       }
-
-       outgoing_refs = 0;
-       while ((n = rb_first(&proc->refs_by_desc))) {
-               struct binder_ref *ref;
-
-               ref = rb_entry(n, struct binder_ref, rb_node_desc);
-               outgoing_refs++;
-               binder_delete_ref(ref);
-       }
-
-       binder_release_work(&proc->todo);
-       binder_release_work(&proc->delivered_death);
-
-       buffers = 0;
-       while ((n = rb_first(&proc->allocated_buffers))) {
-               struct binder_buffer *buffer;
-
-               buffer = rb_entry(n, struct binder_buffer, rb_node);
-
-               t = buffer->transaction;
-               if (t) {
-                       t->buffer = NULL;
-                       buffer->transaction = NULL;
-                       pr_err("release proc %d, transaction %d, not freed\n",
-                              proc->pid, t->debug_id);
-                       /*BUG();*/
-               }
-
-               binder_free_buf(proc, buffer);
-               buffers++;
-       }
-
-       binder_stats_deleted(BINDER_STAT_PROC);
-
-       page_count = 0;
-       if (proc->pages) {
-               int i;
-
-               for (i = 0; i < proc->buffer_size / PAGE_SIZE; i++) {
-                       void *page_addr;
-
-                       if (!proc->pages[i])
-                               continue;
-
-                       page_addr = proc->buffer + i * PAGE_SIZE;
-                       binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
-                                    "%s: %d: page %d at %p not freed\n",
-                                    __func__, proc->pid, i, page_addr);
-                       unmap_kernel_range((unsigned long)page_addr, PAGE_SIZE);
-                       __free_page(proc->pages[i]);
-                       page_count++;
-               }
-               kfree(proc->pages);
-               vfree(proc->buffer);
-       }
-
-       put_task_struct(proc->tsk);
-
-       binder_debug(BINDER_DEBUG_OPEN_CLOSE,
-                    "%s: %d threads %d, nodes %d (ref %d), refs %d, active transactions %d, buffers %d, pages %d\n",
-                    __func__, proc->pid, threads, nodes, incoming_refs,
-                    outgoing_refs, active_transactions, buffers, page_count);
-
-       kfree(proc);
-}
-
-static void binder_deferred_func(struct work_struct *work)
-{
-       struct binder_proc *proc;
-       struct files_struct *files;
-
-       int defer;
-
-       do {
-               binder_lock(__func__);
-               mutex_lock(&binder_deferred_lock);
-               if (!hlist_empty(&binder_deferred_list)) {
-                       proc = hlist_entry(binder_deferred_list.first,
-                                       struct binder_proc, deferred_work_node);
-                       hlist_del_init(&proc->deferred_work_node);
-                       defer = proc->deferred_work;
-                       proc->deferred_work = 0;
-               } else {
-                       proc = NULL;
-                       defer = 0;
-               }
-               mutex_unlock(&binder_deferred_lock);
-
-               files = NULL;
-               if (defer & BINDER_DEFERRED_PUT_FILES) {
-                       files = proc->files;
-                       if (files)
-                               proc->files = NULL;
-               }
-
-               if (defer & BINDER_DEFERRED_FLUSH)
-                       binder_deferred_flush(proc);
-
-               if (defer & BINDER_DEFERRED_RELEASE)
-                       binder_deferred_release(proc); /* frees proc */
-
-               binder_unlock(__func__);
-               if (files)
-                       put_files_struct(files);
-       } while (proc);
-}
-static DECLARE_WORK(binder_deferred_work, binder_deferred_func);
-
-static void
-binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer)
-{
-       mutex_lock(&binder_deferred_lock);
-       proc->deferred_work |= defer;
-       if (hlist_unhashed(&proc->deferred_work_node)) {
-               hlist_add_head(&proc->deferred_work_node,
-                               &binder_deferred_list);
-               queue_work(binder_deferred_workqueue, &binder_deferred_work);
-       }
-       mutex_unlock(&binder_deferred_lock);
-}
-
-static void print_binder_transaction(struct seq_file *m, const char *prefix,
-                                    struct binder_transaction *t)
-{
-       seq_printf(m,
-                  "%s %d: %p from %d:%d to %d:%d code %x flags %x pri %ld r%d",
-                  prefix, t->debug_id, t,
-                  t->from ? t->from->proc->pid : 0,
-                  t->from ? t->from->pid : 0,
-                  t->to_proc ? t->to_proc->pid : 0,
-                  t->to_thread ? t->to_thread->pid : 0,
-                  t->code, t->flags, t->priority, t->need_reply);
-       if (t->buffer == NULL) {
-               seq_puts(m, " buffer free\n");
-               return;
-       }
-       if (t->buffer->target_node)
-               seq_printf(m, " node %d",
-                          t->buffer->target_node->debug_id);
-       seq_printf(m, " size %zd:%zd data %p\n",
-                  t->buffer->data_size, t->buffer->offsets_size,
-                  t->buffer->data);
-}
-
-static void print_binder_buffer(struct seq_file *m, const char *prefix,
-                               struct binder_buffer *buffer)
-{
-       seq_printf(m, "%s %d: %p size %zd:%zd %s\n",
-                  prefix, buffer->debug_id, buffer->data,
-                  buffer->data_size, buffer->offsets_size,
-                  buffer->transaction ? "active" : "delivered");
-}
-
-static void print_binder_work(struct seq_file *m, const char *prefix,
-                             const char *transaction_prefix,
-                             struct binder_work *w)
-{
-       struct binder_node *node;
-       struct binder_transaction *t;
-
-       switch (w->type) {
-       case BINDER_WORK_TRANSACTION:
-               t = container_of(w, struct binder_transaction, work);
-               print_binder_transaction(m, transaction_prefix, t);
-               break;
-       case BINDER_WORK_TRANSACTION_COMPLETE:
-               seq_printf(m, "%stransaction complete\n", prefix);
-               break;
-       case BINDER_WORK_NODE:
-               node = container_of(w, struct binder_node, work);
-               seq_printf(m, "%snode work %d: u%016llx c%016llx\n",
-                          prefix, node->debug_id,
-                          (u64)node->ptr, (u64)node->cookie);
-               break;
-       case BINDER_WORK_DEAD_BINDER:
-               seq_printf(m, "%shas dead binder\n", prefix);
-               break;
-       case BINDER_WORK_DEAD_BINDER_AND_CLEAR:
-               seq_printf(m, "%shas cleared dead binder\n", prefix);
-               break;
-       case BINDER_WORK_CLEAR_DEATH_NOTIFICATION:
-               seq_printf(m, "%shas cleared death notification\n", prefix);
-               break;
-       default:
-               seq_printf(m, "%sunknown work: type %d\n", prefix, w->type);
-               break;
-       }
-}
-
-static void print_binder_thread(struct seq_file *m,
-                               struct binder_thread *thread,
-                               int print_always)
-{
-       struct binder_transaction *t;
-       struct binder_work *w;
-       size_t start_pos = m->count;
-       size_t header_pos;
-
-       seq_printf(m, "  thread %d: l %02x\n", thread->pid, thread->looper);
-       header_pos = m->count;
-       t = thread->transaction_stack;
-       while (t) {
-               if (t->from == thread) {
-                       print_binder_transaction(m,
-                                                "    outgoing transaction", t);
-                       t = t->from_parent;
-               } else if (t->to_thread == thread) {
-                       print_binder_transaction(m,
-                                                "    incoming transaction", t);
-                       t = t->to_parent;
-               } else {
-                       print_binder_transaction(m, "    bad transaction", t);
-                       t = NULL;
-               }
-       }
-       list_for_each_entry(w, &thread->todo, entry) {
-               print_binder_work(m, "    ", "    pending transaction", w);
-       }
-       if (!print_always && m->count == header_pos)
-               m->count = start_pos;
-}
-
-static void print_binder_node(struct seq_file *m, struct binder_node *node)
-{
-       struct binder_ref *ref;
-       struct binder_work *w;
-       int count;
-
-       count = 0;
-       hlist_for_each_entry(ref, &node->refs, node_entry)
-               count++;
-
-       seq_printf(m, "  node %d: u%016llx c%016llx hs %d hw %d ls %d lw %d is %d iw %d",
-                  node->debug_id, (u64)node->ptr, (u64)node->cookie,
-                  node->has_strong_ref, node->has_weak_ref,
-                  node->local_strong_refs, node->local_weak_refs,
-                  node->internal_strong_refs, count);
-       if (count) {
-               seq_puts(m, " proc");
-               hlist_for_each_entry(ref, &node->refs, node_entry)
-                       seq_printf(m, " %d", ref->proc->pid);
-       }
-       seq_puts(m, "\n");
-       list_for_each_entry(w, &node->async_todo, entry)
-               print_binder_work(m, "    ",
-                                 "    pending async transaction", w);
-}
-
-static void print_binder_ref(struct seq_file *m, struct binder_ref *ref)
-{
-       seq_printf(m, "  ref %d: desc %d %snode %d s %d w %d d %p\n",
-                  ref->debug_id, ref->desc, ref->node->proc ? "" : "dead ",
-                  ref->node->debug_id, ref->strong, ref->weak, ref->death);
-}
-
-static void print_binder_proc(struct seq_file *m,
-                             struct binder_proc *proc, int print_all)
-{
-       struct binder_work *w;
-       struct rb_node *n;
-       size_t start_pos = m->count;
-       size_t header_pos;
-
-       seq_printf(m, "proc %d\n", proc->pid);
-       header_pos = m->count;
-
-       for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n))
-               print_binder_thread(m, rb_entry(n, struct binder_thread,
-                                               rb_node), print_all);
-       for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) {
-               struct binder_node *node = rb_entry(n, struct binder_node,
-                                                   rb_node);
-               if (print_all || node->has_async_transaction)
-                       print_binder_node(m, node);
-       }
-       if (print_all) {
-               for (n = rb_first(&proc->refs_by_desc);
-                    n != NULL;
-                    n = rb_next(n))
-                       print_binder_ref(m, rb_entry(n, struct binder_ref,
-                                                    rb_node_desc));
-       }
-       for (n = rb_first(&proc->allocated_buffers); n != NULL; n = rb_next(n))
-               print_binder_buffer(m, "  buffer",
-                                   rb_entry(n, struct binder_buffer, rb_node));
-       list_for_each_entry(w, &proc->todo, entry)
-               print_binder_work(m, "  ", "  pending transaction", w);
-       list_for_each_entry(w, &proc->delivered_death, entry) {
-               seq_puts(m, "  has delivered dead binder\n");
-               break;
-       }
-       if (!print_all && m->count == header_pos)
-               m->count = start_pos;
-}
-
-static const char * const binder_return_strings[] = {
-       "BR_ERROR",
-       "BR_OK",
-       "BR_TRANSACTION",
-       "BR_REPLY",
-       "BR_ACQUIRE_RESULT",
-       "BR_DEAD_REPLY",
-       "BR_TRANSACTION_COMPLETE",
-       "BR_INCREFS",
-       "BR_ACQUIRE",
-       "BR_RELEASE",
-       "BR_DECREFS",
-       "BR_ATTEMPT_ACQUIRE",
-       "BR_NOOP",
-       "BR_SPAWN_LOOPER",
-       "BR_FINISHED",
-       "BR_DEAD_BINDER",
-       "BR_CLEAR_DEATH_NOTIFICATION_DONE",
-       "BR_FAILED_REPLY"
-};
-
-static const char * const binder_command_strings[] = {
-       "BC_TRANSACTION",
-       "BC_REPLY",
-       "BC_ACQUIRE_RESULT",
-       "BC_FREE_BUFFER",
-       "BC_INCREFS",
-       "BC_ACQUIRE",
-       "BC_RELEASE",
-       "BC_DECREFS",
-       "BC_INCREFS_DONE",
-       "BC_ACQUIRE_DONE",
-       "BC_ATTEMPT_ACQUIRE",
-       "BC_REGISTER_LOOPER",
-       "BC_ENTER_LOOPER",
-       "BC_EXIT_LOOPER",
-       "BC_REQUEST_DEATH_NOTIFICATION",
-       "BC_CLEAR_DEATH_NOTIFICATION",
-       "BC_DEAD_BINDER_DONE"
-};
-
-static const char * const binder_objstat_strings[] = {
-       "proc",
-       "thread",
-       "node",
-       "ref",
-       "death",
-       "transaction",
-       "transaction_complete"
-};
-
-static void print_binder_stats(struct seq_file *m, const char *prefix,
-                              struct binder_stats *stats)
-{
-       int i;
-
-       BUILD_BUG_ON(ARRAY_SIZE(stats->bc) !=
-                    ARRAY_SIZE(binder_command_strings));
-       for (i = 0; i < ARRAY_SIZE(stats->bc); i++) {
-               if (stats->bc[i])
-                       seq_printf(m, "%s%s: %d\n", prefix,
-                                  binder_command_strings[i], stats->bc[i]);
-       }
-
-       BUILD_BUG_ON(ARRAY_SIZE(stats->br) !=
-                    ARRAY_SIZE(binder_return_strings));
-       for (i = 0; i < ARRAY_SIZE(stats->br); i++) {
-               if (stats->br[i])
-                       seq_printf(m, "%s%s: %d\n", prefix,
-                                  binder_return_strings[i], stats->br[i]);
-       }
-
-       BUILD_BUG_ON(ARRAY_SIZE(stats->obj_created) !=
-                    ARRAY_SIZE(binder_objstat_strings));
-       BUILD_BUG_ON(ARRAY_SIZE(stats->obj_created) !=
-                    ARRAY_SIZE(stats->obj_deleted));
-       for (i = 0; i < ARRAY_SIZE(stats->obj_created); i++) {
-               if (stats->obj_created[i] || stats->obj_deleted[i])
-                       seq_printf(m, "%s%s: active %d total %d\n", prefix,
-                               binder_objstat_strings[i],
-                               stats->obj_created[i] - stats->obj_deleted[i],
-                               stats->obj_created[i]);
-       }
-}
-
-static void print_binder_proc_stats(struct seq_file *m,
-                                   struct binder_proc *proc)
-{
-       struct binder_work *w;
-       struct rb_node *n;
-       int count, strong, weak;
-
-       seq_printf(m, "proc %d\n", proc->pid);
-       count = 0;
-       for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n))
-               count++;
-       seq_printf(m, "  threads: %d\n", count);
-       seq_printf(m, "  requested threads: %d+%d/%d\n"
-                       "  ready threads %d\n"
-                       "  free async space %zd\n", proc->requested_threads,
-                       proc->requested_threads_started, proc->max_threads,
-                       proc->ready_threads, proc->free_async_space);
-       count = 0;
-       for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n))
-               count++;
-       seq_printf(m, "  nodes: %d\n", count);
-       count = 0;
-       strong = 0;
-       weak = 0;
-       for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) {
-               struct binder_ref *ref = rb_entry(n, struct binder_ref,
-                                                 rb_node_desc);
-               count++;
-               strong += ref->strong;
-               weak += ref->weak;
-       }
-       seq_printf(m, "  refs: %d s %d w %d\n", count, strong, weak);
-
-       count = 0;
-       for (n = rb_first(&proc->allocated_buffers); n != NULL; n = rb_next(n))
-               count++;
-       seq_printf(m, "  buffers: %d\n", count);
-
-       count = 0;
-       list_for_each_entry(w, &proc->todo, entry) {
-               switch (w->type) {
-               case BINDER_WORK_TRANSACTION:
-                       count++;
-                       break;
-               default:
-                       break;
-               }
-       }
-       seq_printf(m, "  pending transactions: %d\n", count);
-
-       print_binder_stats(m, "  ", &proc->stats);
-}
-
-
-static int binder_state_show(struct seq_file *m, void *unused)
-{
-       struct binder_proc *proc;
-       struct binder_node *node;
-       int do_lock = !binder_debug_no_lock;
-
-       if (do_lock)
-               binder_lock(__func__);
-
-       seq_puts(m, "binder state:\n");
-
-       if (!hlist_empty(&binder_dead_nodes))
-               seq_puts(m, "dead nodes:\n");
-       hlist_for_each_entry(node, &binder_dead_nodes, dead_node)
-               print_binder_node(m, node);
-
-       hlist_for_each_entry(proc, &binder_procs, proc_node)
-               print_binder_proc(m, proc, 1);
-       if (do_lock)
-               binder_unlock(__func__);
-       return 0;
-}
-
-static int binder_stats_show(struct seq_file *m, void *unused)
-{
-       struct binder_proc *proc;
-       int do_lock = !binder_debug_no_lock;
-
-       if (do_lock)
-               binder_lock(__func__);
-
-       seq_puts(m, "binder stats:\n");
-
-       print_binder_stats(m, "", &binder_stats);
-
-       hlist_for_each_entry(proc, &binder_procs, proc_node)
-               print_binder_proc_stats(m, proc);
-       if (do_lock)
-               binder_unlock(__func__);
-       return 0;
-}
-
-static int binder_transactions_show(struct seq_file *m, void *unused)
-{
-       struct binder_proc *proc;
-       int do_lock = !binder_debug_no_lock;
-
-       if (do_lock)
-               binder_lock(__func__);
-
-       seq_puts(m, "binder transactions:\n");
-       hlist_for_each_entry(proc, &binder_procs, proc_node)
-               print_binder_proc(m, proc, 0);
-       if (do_lock)
-               binder_unlock(__func__);
-       return 0;
-}
-
-static int binder_proc_show(struct seq_file *m, void *unused)
-{
-       struct binder_proc *proc = m->private;
-       int do_lock = !binder_debug_no_lock;
-
-       if (do_lock)
-               binder_lock(__func__);
-       seq_puts(m, "binder proc state:\n");
-       print_binder_proc(m, proc, 1);
-       if (do_lock)
-               binder_unlock(__func__);
-       return 0;
-}
-
-static void print_binder_transaction_log_entry(struct seq_file *m,
-                                       struct binder_transaction_log_entry *e)
-{
-       seq_printf(m,
-                  "%d: %s from %d:%d to %d:%d node %d handle %d size %d:%d\n",
-                  e->debug_id, (e->call_type == 2) ? "reply" :
-                  ((e->call_type == 1) ? "async" : "call "), e->from_proc,
-                  e->from_thread, e->to_proc, e->to_thread, e->to_node,
-                  e->target_handle, e->data_size, e->offsets_size);
-}
-
-static int binder_transaction_log_show(struct seq_file *m, void *unused)
-{
-       struct binder_transaction_log *log = m->private;
-       int i;
-
-       if (log->full) {
-               for (i = log->next; i < ARRAY_SIZE(log->entry); i++)
-                       print_binder_transaction_log_entry(m, &log->entry[i]);
-       }
-       for (i = 0; i < log->next; i++)
-               print_binder_transaction_log_entry(m, &log->entry[i]);
-       return 0;
-}
-
-static const struct file_operations binder_fops = {
-       .owner = THIS_MODULE,
-       .poll = binder_poll,
-       .unlocked_ioctl = binder_ioctl,
-       .compat_ioctl = binder_ioctl,
-       .mmap = binder_mmap,
-       .open = binder_open,
-       .flush = binder_flush,
-       .release = binder_release,
-};
-
-static struct miscdevice binder_miscdev = {
-       .minor = MISC_DYNAMIC_MINOR,
-       .name = "binder",
-       .fops = &binder_fops
-};
-
-BINDER_DEBUG_ENTRY(state);
-BINDER_DEBUG_ENTRY(stats);
-BINDER_DEBUG_ENTRY(transactions);
-BINDER_DEBUG_ENTRY(transaction_log);
-
-static int __init binder_init(void)
-{
-       int ret;
-
-       binder_deferred_workqueue = create_singlethread_workqueue("binder");
-       if (!binder_deferred_workqueue)
-               return -ENOMEM;
-
-       binder_debugfs_dir_entry_root = debugfs_create_dir("binder", NULL);
-       if (binder_debugfs_dir_entry_root)
-               binder_debugfs_dir_entry_proc = debugfs_create_dir("proc",
-                                                binder_debugfs_dir_entry_root);
-       ret = misc_register(&binder_miscdev);
-       if (binder_debugfs_dir_entry_root) {
-               debugfs_create_file("state",
-                                   S_IRUGO,
-                                   binder_debugfs_dir_entry_root,
-                                   NULL,
-                                   &binder_state_fops);
-               debugfs_create_file("stats",
-                                   S_IRUGO,
-                                   binder_debugfs_dir_entry_root,
-                                   NULL,
-                                   &binder_stats_fops);
-               debugfs_create_file("transactions",
-                                   S_IRUGO,
-                                   binder_debugfs_dir_entry_root,
-                                   NULL,
-                                   &binder_transactions_fops);
-               debugfs_create_file("transaction_log",
-                                   S_IRUGO,
-                                   binder_debugfs_dir_entry_root,
-                                   &binder_transaction_log,
-                                   &binder_transaction_log_fops);
-               debugfs_create_file("failed_transaction_log",
-                                   S_IRUGO,
-                                   binder_debugfs_dir_entry_root,
-                                   &binder_transaction_log_failed,
-                                   &binder_transaction_log_fops);
-       }
-       return ret;
-}
-
-device_initcall(binder_init);
-
-#define CREATE_TRACE_POINTS
-#include "binder_trace.h"
-
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/android/binder.h b/drivers/staging/android/binder.h
deleted file mode 100644 (file)
index eb08346..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2008 Google, Inc.
- *
- * Based on, but no longer compatible with, the original
- * OpenBinder.org binder driver interface, which is:
- *
- * Copyright (c) 2005 Palmsource, 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 _LINUX_BINDER_H
-#define _LINUX_BINDER_H
-
-#ifdef CONFIG_ANDROID_BINDER_IPC_32BIT
-#define BINDER_IPC_32BIT 1
-#endif
-
-#include "uapi/binder.h"
-
-#endif /* _LINUX_BINDER_H */
-
diff --git a/drivers/staging/android/binder_trace.h b/drivers/staging/android/binder_trace.h
deleted file mode 100644 (file)
index 7f20f3d..0000000
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- *
- */
-
-#undef TRACE_SYSTEM
-#define TRACE_SYSTEM binder
-
-#if !defined(_BINDER_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
-#define _BINDER_TRACE_H
-
-#include <linux/tracepoint.h>
-
-struct binder_buffer;
-struct binder_node;
-struct binder_proc;
-struct binder_ref;
-struct binder_thread;
-struct binder_transaction;
-
-TRACE_EVENT(binder_ioctl,
-       TP_PROTO(unsigned int cmd, unsigned long arg),
-       TP_ARGS(cmd, arg),
-
-       TP_STRUCT__entry(
-               __field(unsigned int, cmd)
-               __field(unsigned long, arg)
-       ),
-       TP_fast_assign(
-               __entry->cmd = cmd;
-               __entry->arg = arg;
-       ),
-       TP_printk("cmd=0x%x arg=0x%lx", __entry->cmd, __entry->arg)
-);
-
-DECLARE_EVENT_CLASS(binder_lock_class,
-       TP_PROTO(const char *tag),
-       TP_ARGS(tag),
-       TP_STRUCT__entry(
-               __field(const char *, tag)
-       ),
-       TP_fast_assign(
-               __entry->tag = tag;
-       ),
-       TP_printk("tag=%s", __entry->tag)
-);
-
-#define DEFINE_BINDER_LOCK_EVENT(name) \
-DEFINE_EVENT(binder_lock_class, name,  \
-       TP_PROTO(const char *func), \
-       TP_ARGS(func))
-
-DEFINE_BINDER_LOCK_EVENT(binder_lock);
-DEFINE_BINDER_LOCK_EVENT(binder_locked);
-DEFINE_BINDER_LOCK_EVENT(binder_unlock);
-
-DECLARE_EVENT_CLASS(binder_function_return_class,
-       TP_PROTO(int ret),
-       TP_ARGS(ret),
-       TP_STRUCT__entry(
-               __field(int, ret)
-       ),
-       TP_fast_assign(
-               __entry->ret = ret;
-       ),
-       TP_printk("ret=%d", __entry->ret)
-);
-
-#define DEFINE_BINDER_FUNCTION_RETURN_EVENT(name)      \
-DEFINE_EVENT(binder_function_return_class, name,       \
-       TP_PROTO(int ret), \
-       TP_ARGS(ret))
-
-DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_ioctl_done);
-DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_write_done);
-DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_read_done);
-
-TRACE_EVENT(binder_wait_for_work,
-       TP_PROTO(bool proc_work, bool transaction_stack, bool thread_todo),
-       TP_ARGS(proc_work, transaction_stack, thread_todo),
-
-       TP_STRUCT__entry(
-               __field(bool, proc_work)
-               __field(bool, transaction_stack)
-               __field(bool, thread_todo)
-       ),
-       TP_fast_assign(
-               __entry->proc_work = proc_work;
-               __entry->transaction_stack = transaction_stack;
-               __entry->thread_todo = thread_todo;
-       ),
-       TP_printk("proc_work=%d transaction_stack=%d thread_todo=%d",
-                 __entry->proc_work, __entry->transaction_stack,
-                 __entry->thread_todo)
-);
-
-TRACE_EVENT(binder_transaction,
-       TP_PROTO(bool reply, struct binder_transaction *t,
-                struct binder_node *target_node),
-       TP_ARGS(reply, t, target_node),
-       TP_STRUCT__entry(
-               __field(int, debug_id)
-               __field(int, target_node)
-               __field(int, to_proc)
-               __field(int, to_thread)
-               __field(int, reply)
-               __field(unsigned int, code)
-               __field(unsigned int, flags)
-       ),
-       TP_fast_assign(
-               __entry->debug_id = t->debug_id;
-               __entry->target_node = target_node ? target_node->debug_id : 0;
-               __entry->to_proc = t->to_proc->pid;
-               __entry->to_thread = t->to_thread ? t->to_thread->pid : 0;
-               __entry->reply = reply;
-               __entry->code = t->code;
-               __entry->flags = t->flags;
-       ),
-       TP_printk("transaction=%d dest_node=%d dest_proc=%d dest_thread=%d reply=%d flags=0x%x code=0x%x",
-                 __entry->debug_id, __entry->target_node,
-                 __entry->to_proc, __entry->to_thread,
-                 __entry->reply, __entry->flags, __entry->code)
-);
-
-TRACE_EVENT(binder_transaction_received,
-       TP_PROTO(struct binder_transaction *t),
-       TP_ARGS(t),
-
-       TP_STRUCT__entry(
-               __field(int, debug_id)
-       ),
-       TP_fast_assign(
-               __entry->debug_id = t->debug_id;
-       ),
-       TP_printk("transaction=%d", __entry->debug_id)
-);
-
-TRACE_EVENT(binder_transaction_node_to_ref,
-       TP_PROTO(struct binder_transaction *t, struct binder_node *node,
-                struct binder_ref *ref),
-       TP_ARGS(t, node, ref),
-
-       TP_STRUCT__entry(
-               __field(int, debug_id)
-               __field(int, node_debug_id)
-               __field(binder_uintptr_t, node_ptr)
-               __field(int, ref_debug_id)
-               __field(uint32_t, ref_desc)
-       ),
-       TP_fast_assign(
-               __entry->debug_id = t->debug_id;
-               __entry->node_debug_id = node->debug_id;
-               __entry->node_ptr = node->ptr;
-               __entry->ref_debug_id = ref->debug_id;
-               __entry->ref_desc = ref->desc;
-       ),
-       TP_printk("transaction=%d node=%d src_ptr=0x%016llx ==> dest_ref=%d dest_desc=%d",
-                 __entry->debug_id, __entry->node_debug_id,
-                 (u64)__entry->node_ptr,
-                 __entry->ref_debug_id, __entry->ref_desc)
-);
-
-TRACE_EVENT(binder_transaction_ref_to_node,
-       TP_PROTO(struct binder_transaction *t, struct binder_ref *ref),
-       TP_ARGS(t, ref),
-
-       TP_STRUCT__entry(
-               __field(int, debug_id)
-               __field(int, ref_debug_id)
-               __field(uint32_t, ref_desc)
-               __field(int, node_debug_id)
-               __field(binder_uintptr_t, node_ptr)
-       ),
-       TP_fast_assign(
-               __entry->debug_id = t->debug_id;
-               __entry->ref_debug_id = ref->debug_id;
-               __entry->ref_desc = ref->desc;
-               __entry->node_debug_id = ref->node->debug_id;
-               __entry->node_ptr = ref->node->ptr;
-       ),
-       TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ptr=0x%016llx",
-                 __entry->debug_id, __entry->node_debug_id,
-                 __entry->ref_debug_id, __entry->ref_desc,
-                 (u64)__entry->node_ptr)
-);
-
-TRACE_EVENT(binder_transaction_ref_to_ref,
-       TP_PROTO(struct binder_transaction *t, struct binder_ref *src_ref,
-                struct binder_ref *dest_ref),
-       TP_ARGS(t, src_ref, dest_ref),
-
-       TP_STRUCT__entry(
-               __field(int, debug_id)
-               __field(int, node_debug_id)
-               __field(int, src_ref_debug_id)
-               __field(uint32_t, src_ref_desc)
-               __field(int, dest_ref_debug_id)
-               __field(uint32_t, dest_ref_desc)
-       ),
-       TP_fast_assign(
-               __entry->debug_id = t->debug_id;
-               __entry->node_debug_id = src_ref->node->debug_id;
-               __entry->src_ref_debug_id = src_ref->debug_id;
-               __entry->src_ref_desc = src_ref->desc;
-               __entry->dest_ref_debug_id = dest_ref->debug_id;
-               __entry->dest_ref_desc = dest_ref->desc;
-       ),
-       TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ref=%d dest_desc=%d",
-                 __entry->debug_id, __entry->node_debug_id,
-                 __entry->src_ref_debug_id, __entry->src_ref_desc,
-                 __entry->dest_ref_debug_id, __entry->dest_ref_desc)
-);
-
-TRACE_EVENT(binder_transaction_fd,
-       TP_PROTO(struct binder_transaction *t, int src_fd, int dest_fd),
-       TP_ARGS(t, src_fd, dest_fd),
-
-       TP_STRUCT__entry(
-               __field(int, debug_id)
-               __field(int, src_fd)
-               __field(int, dest_fd)
-       ),
-       TP_fast_assign(
-               __entry->debug_id = t->debug_id;
-               __entry->src_fd = src_fd;
-               __entry->dest_fd = dest_fd;
-       ),
-       TP_printk("transaction=%d src_fd=%d ==> dest_fd=%d",
-                 __entry->debug_id, __entry->src_fd, __entry->dest_fd)
-);
-
-DECLARE_EVENT_CLASS(binder_buffer_class,
-       TP_PROTO(struct binder_buffer *buf),
-       TP_ARGS(buf),
-       TP_STRUCT__entry(
-               __field(int, debug_id)
-               __field(size_t, data_size)
-               __field(size_t, offsets_size)
-       ),
-       TP_fast_assign(
-               __entry->debug_id = buf->debug_id;
-               __entry->data_size = buf->data_size;
-               __entry->offsets_size = buf->offsets_size;
-       ),
-       TP_printk("transaction=%d data_size=%zd offsets_size=%zd",
-                 __entry->debug_id, __entry->data_size, __entry->offsets_size)
-);
-
-DEFINE_EVENT(binder_buffer_class, binder_transaction_alloc_buf,
-       TP_PROTO(struct binder_buffer *buffer),
-       TP_ARGS(buffer));
-
-DEFINE_EVENT(binder_buffer_class, binder_transaction_buffer_release,
-       TP_PROTO(struct binder_buffer *buffer),
-       TP_ARGS(buffer));
-
-DEFINE_EVENT(binder_buffer_class, binder_transaction_failed_buffer_release,
-       TP_PROTO(struct binder_buffer *buffer),
-       TP_ARGS(buffer));
-
-TRACE_EVENT(binder_update_page_range,
-       TP_PROTO(struct binder_proc *proc, bool allocate,
-                void *start, void *end),
-       TP_ARGS(proc, allocate, start, end),
-       TP_STRUCT__entry(
-               __field(int, proc)
-               __field(bool, allocate)
-               __field(size_t, offset)
-               __field(size_t, size)
-       ),
-       TP_fast_assign(
-               __entry->proc = proc->pid;
-               __entry->allocate = allocate;
-               __entry->offset = start - proc->buffer;
-               __entry->size = end - start;
-       ),
-       TP_printk("proc=%d allocate=%d offset=%zu size=%zu",
-                 __entry->proc, __entry->allocate,
-                 __entry->offset, __entry->size)
-);
-
-TRACE_EVENT(binder_command,
-       TP_PROTO(uint32_t cmd),
-       TP_ARGS(cmd),
-       TP_STRUCT__entry(
-               __field(uint32_t, cmd)
-       ),
-       TP_fast_assign(
-               __entry->cmd = cmd;
-       ),
-       TP_printk("cmd=0x%x %s",
-                 __entry->cmd,
-                 _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_command_strings) ?
-                         binder_command_strings[_IOC_NR(__entry->cmd)] :
-                         "unknown")
-);
-
-TRACE_EVENT(binder_return,
-       TP_PROTO(uint32_t cmd),
-       TP_ARGS(cmd),
-       TP_STRUCT__entry(
-               __field(uint32_t, cmd)
-       ),
-       TP_fast_assign(
-               __entry->cmd = cmd;
-       ),
-       TP_printk("cmd=0x%x %s",
-                 __entry->cmd,
-                 _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_return_strings) ?
-                         binder_return_strings[_IOC_NR(__entry->cmd)] :
-                         "unknown")
-);
-
-#endif /* _BINDER_TRACE_H */
-
-#undef TRACE_INCLUDE_PATH
-#undef TRACE_INCLUDE_FILE
-#define TRACE_INCLUDE_PATH .
-#define TRACE_INCLUDE_FILE binder_trace
-#include <trace/define_trace.h>
index 56604f4..290d4d2 100644 (file)
@@ -902,7 +902,7 @@ void ion_pages_sync_for_device(struct device *dev, struct page *page,
        sg_set_page(&sg, page, size, 0);
        /*
         * This is not correct - sg_dma_address needs a dma_addr_t that is valid
-        * for the the targeted device, but this works on the currently targeted
+        * for the targeted device, but this works on the currently targeted
         * hardware.
         */
        sg_dma_address(&sg) = page_to_phys(page);
index 5864f3d..4b88f11 100644 (file)
@@ -120,7 +120,7 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask,
        bool high;
 
        if (current_is_kswapd())
-               high = 1;
+               high = true;
        else
                high = !!(gfp_mask & __GFP_HIGHMEM);
 
index 257fc91..1532a86 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/slab.h>
 #include <linux/uaccess.h>
 #include <linux/anon_inodes.h>
+#include <linux/time64.h>
 #include "sync.h"
 
 #ifdef CONFIG_DEBUG_FS
@@ -95,9 +96,9 @@ static void sync_print_pt(struct seq_file *s, struct sync_pt *pt, bool fence)
                   sync_status_str(status));
 
        if (status <= 0) {
-               struct timeval tv = ktime_to_timeval(pt->base.timestamp);
+               struct timespec64 ts64 = ktime_to_timespec64(pt->base.timestamp);
 
-               seq_printf(s, "@%ld.%06ld", tv.tv_sec, tv.tv_usec);
+               seq_printf(s, "@%lld.%09ld", (s64)ts64.tv_sec, ts64.tv_nsec);
        }
 
        if (parent->ops->timeline_value_str &&
index 8fa4758..12d5514 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/hrtimer.h>
 #include <linux/err.h>
 #include <linux/gpio.h>
+#include <linux/ktime.h>
 
 #include "timed_output.h"
 #include "timed_gpio.h"
@@ -46,16 +47,16 @@ static enum hrtimer_restart gpio_timer_func(struct hrtimer *timer)
 static int gpio_get_time(struct timed_output_dev *dev)
 {
        struct timed_gpio_data *data;
-       struct timeval t;
+       ktime_t t;
 
        data = container_of(dev, struct timed_gpio_data, dev);
 
        if (!hrtimer_active(&data->timer))
                return 0;
 
-       t = ktime_to_timeval(hrtimer_get_remaining(&data->timer));
+       t = hrtimer_get_remaining(&data->timer);
 
-       return t.tv_sec * 1000 + t.tv_usec / 1000;
+       return ktime_to_ms(t);
 }
 
 static void gpio_enable(struct timed_output_dev *dev, int value)
diff --git a/drivers/staging/android/uapi/binder.h b/drivers/staging/android/uapi/binder.h
deleted file mode 100644 (file)
index dba4cef..0000000
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * Copyright (C) 2008 Google, Inc.
- *
- * Based on, but no longer compatible with, the original
- * OpenBinder.org binder driver interface, which is:
- *
- * Copyright (c) 2005 Palmsource, 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 _UAPI_LINUX_BINDER_H
-#define _UAPI_LINUX_BINDER_H
-
-#include <linux/ioctl.h>
-
-#define B_PACK_CHARS(c1, c2, c3, c4) \
-       ((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4))
-#define B_TYPE_LARGE 0x85
-
-enum {
-       BINDER_TYPE_BINDER      = B_PACK_CHARS('s', 'b', '*', B_TYPE_LARGE),
-       BINDER_TYPE_WEAK_BINDER = B_PACK_CHARS('w', 'b', '*', B_TYPE_LARGE),
-       BINDER_TYPE_HANDLE      = B_PACK_CHARS('s', 'h', '*', B_TYPE_LARGE),
-       BINDER_TYPE_WEAK_HANDLE = B_PACK_CHARS('w', 'h', '*', B_TYPE_LARGE),
-       BINDER_TYPE_FD          = B_PACK_CHARS('f', 'd', '*', B_TYPE_LARGE),
-};
-
-enum {
-       FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff,
-       FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100,
-};
-
-#ifdef BINDER_IPC_32BIT
-typedef __u32 binder_size_t;
-typedef __u32 binder_uintptr_t;
-#else
-typedef __u64 binder_size_t;
-typedef __u64 binder_uintptr_t;
-#endif
-
-/*
- * This is the flattened representation of a Binder object for transfer
- * between processes.  The 'offsets' supplied as part of a binder transaction
- * contains offsets into the data where these structures occur.  The Binder
- * driver takes care of re-writing the structure type and data as it moves
- * between processes.
- */
-struct flat_binder_object {
-       /* 8 bytes for large_flat_header. */
-       __u32           type;
-       __u32           flags;
-
-       /* 8 bytes of data. */
-       union {
-               binder_uintptr_t        binder; /* local object */
-               __u32                   handle; /* remote object */
-       };
-
-       /* extra data associated with local object */
-       binder_uintptr_t        cookie;
-};
-
-/*
- * On 64-bit platforms where user code may run in 32-bits the driver must
- * translate the buffer (and local binder) addresses appropriately.
- */
-
-struct binder_write_read {
-       binder_size_t           write_size;     /* bytes to write */
-       binder_size_t           write_consumed; /* bytes consumed by driver */
-       binder_uintptr_t        write_buffer;
-       binder_size_t           read_size;      /* bytes to read */
-       binder_size_t           read_consumed;  /* bytes consumed by driver */
-       binder_uintptr_t        read_buffer;
-};
-
-/* Use with BINDER_VERSION, driver fills in fields. */
-struct binder_version {
-       /* driver protocol version -- increment with incompatible change */
-       __s32       protocol_version;
-};
-
-/* This is the current protocol version. */
-#ifdef BINDER_IPC_32BIT
-#define BINDER_CURRENT_PROTOCOL_VERSION 7
-#else
-#define BINDER_CURRENT_PROTOCOL_VERSION 8
-#endif
-
-#define BINDER_WRITE_READ              _IOWR('b', 1, struct binder_write_read)
-#define BINDER_SET_IDLE_TIMEOUT                _IOW('b', 3, __s64)
-#define BINDER_SET_MAX_THREADS         _IOW('b', 5, __u32)
-#define BINDER_SET_IDLE_PRIORITY       _IOW('b', 6, __s32)
-#define BINDER_SET_CONTEXT_MGR         _IOW('b', 7, __s32)
-#define BINDER_THREAD_EXIT             _IOW('b', 8, __s32)
-#define BINDER_VERSION                 _IOWR('b', 9, struct binder_version)
-
-/*
- * NOTE: Two special error codes you should check for when calling
- * in to the driver are:
- *
- * EINTR -- The operation has been interupted.  This should be
- * handled by retrying the ioctl() until a different error code
- * is returned.
- *
- * ECONNREFUSED -- The driver is no longer accepting operations
- * from your process.  That is, the process is being destroyed.
- * You should handle this by exiting from your process.  Note
- * that once this error code is returned, all further calls to
- * the driver from any thread will return this same code.
- */
-
-enum transaction_flags {
-       TF_ONE_WAY      = 0x01, /* this is a one-way call: async, no return */
-       TF_ROOT_OBJECT  = 0x04, /* contents are the component's root object */
-       TF_STATUS_CODE  = 0x08, /* contents are a 32-bit status code */
-       TF_ACCEPT_FDS   = 0x10, /* allow replies with file descriptors */
-};
-
-struct binder_transaction_data {
-       /* The first two are only used for bcTRANSACTION and brTRANSACTION,
-        * identifying the target and contents of the transaction.
-        */
-       union {
-               /* target descriptor of command transaction */
-               __u32   handle;
-               /* target descriptor of return transaction */
-               binder_uintptr_t ptr;
-       } target;
-       binder_uintptr_t        cookie; /* target object cookie */
-       __u32           code;           /* transaction command */
-
-       /* General information about the transaction. */
-       __u32           flags;
-       pid_t           sender_pid;
-       uid_t           sender_euid;
-       binder_size_t   data_size;      /* number of bytes of data */
-       binder_size_t   offsets_size;   /* number of bytes of offsets */
-
-       /* If this transaction is inline, the data immediately
-        * follows here; otherwise, it ends with a pointer to
-        * the data buffer.
-        */
-       union {
-               struct {
-                       /* transaction data */
-                       binder_uintptr_t        buffer;
-                       /* offsets from buffer to flat_binder_object structs */
-                       binder_uintptr_t        offsets;
-               } ptr;
-               __u8    buf[8];
-       } data;
-};
-
-struct binder_ptr_cookie {
-       binder_uintptr_t ptr;
-       binder_uintptr_t cookie;
-};
-
-struct binder_handle_cookie {
-       __u32 handle;
-       binder_uintptr_t cookie;
-} __packed;
-
-struct binder_pri_desc {
-       __s32 priority;
-       __u32 desc;
-};
-
-struct binder_pri_ptr_cookie {
-       __s32 priority;
-       binder_uintptr_t ptr;
-       binder_uintptr_t cookie;
-};
-
-enum binder_driver_return_protocol {
-       BR_ERROR = _IOR('r', 0, __s32),
-       /*
-        * int: error code
-        */
-
-       BR_OK = _IO('r', 1),
-       /* No parameters! */
-
-       BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data),
-       BR_REPLY = _IOR('r', 3, struct binder_transaction_data),
-       /*
-        * binder_transaction_data: the received command.
-        */
-
-       BR_ACQUIRE_RESULT = _IOR('r', 4, __s32),
-       /*
-        * not currently supported
-        * int: 0 if the last bcATTEMPT_ACQUIRE was not successful.
-        * Else the remote object has acquired a primary reference.
-        */
-
-       BR_DEAD_REPLY = _IO('r', 5),
-       /*
-        * The target of the last transaction (either a bcTRANSACTION or
-        * a bcATTEMPT_ACQUIRE) is no longer with us.  No parameters.
-        */
-
-       BR_TRANSACTION_COMPLETE = _IO('r', 6),
-       /*
-        * No parameters... always refers to the last transaction requested
-        * (including replies).  Note that this will be sent even for
-        * asynchronous transactions.
-        */
-
-       BR_INCREFS = _IOR('r', 7, struct binder_ptr_cookie),
-       BR_ACQUIRE = _IOR('r', 8, struct binder_ptr_cookie),
-       BR_RELEASE = _IOR('r', 9, struct binder_ptr_cookie),
-       BR_DECREFS = _IOR('r', 10, struct binder_ptr_cookie),
-       /*
-        * void *:      ptr to binder
-        * void *: cookie for binder
-        */
-
-       BR_ATTEMPT_ACQUIRE = _IOR('r', 11, struct binder_pri_ptr_cookie),
-       /*
-        * not currently supported
-        * int: priority
-        * void *: ptr to binder
-        * void *: cookie for binder
-        */
-
-       BR_NOOP = _IO('r', 12),
-       /*
-        * No parameters.  Do nothing and examine the next command.  It exists
-        * primarily so that we can replace it with a BR_SPAWN_LOOPER command.
-        */
-
-       BR_SPAWN_LOOPER = _IO('r', 13),
-       /*
-        * No parameters.  The driver has determined that a process has no
-        * threads waiting to service incoming transactions.  When a process
-        * receives this command, it must spawn a new service thread and
-        * register it via bcENTER_LOOPER.
-        */
-
-       BR_FINISHED = _IO('r', 14),
-       /*
-        * not currently supported
-        * stop threadpool thread
-        */
-
-       BR_DEAD_BINDER = _IOR('r', 15, binder_uintptr_t),
-       /*
-        * void *: cookie
-        */
-       BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, binder_uintptr_t),
-       /*
-        * void *: cookie
-        */
-
-       BR_FAILED_REPLY = _IO('r', 17),
-       /*
-        * The the last transaction (either a bcTRANSACTION or
-        * a bcATTEMPT_ACQUIRE) failed (e.g. out of memory).  No parameters.
-        */
-};
-
-enum binder_driver_command_protocol {
-       BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data),
-       BC_REPLY = _IOW('c', 1, struct binder_transaction_data),
-       /*
-        * binder_transaction_data: the sent command.
-        */
-
-       BC_ACQUIRE_RESULT = _IOW('c', 2, __s32),
-       /*
-        * not currently supported
-        * int:  0 if the last BR_ATTEMPT_ACQUIRE was not successful.
-        * Else you have acquired a primary reference on the object.
-        */
-
-       BC_FREE_BUFFER = _IOW('c', 3, binder_uintptr_t),
-       /*
-        * void *: ptr to transaction data received on a read
-        */
-
-       BC_INCREFS = _IOW('c', 4, __u32),
-       BC_ACQUIRE = _IOW('c', 5, __u32),
-       BC_RELEASE = _IOW('c', 6, __u32),
-       BC_DECREFS = _IOW('c', 7, __u32),
-       /*
-        * int: descriptor
-        */
-
-       BC_INCREFS_DONE = _IOW('c', 8, struct binder_ptr_cookie),
-       BC_ACQUIRE_DONE = _IOW('c', 9, struct binder_ptr_cookie),
-       /*
-        * void *: ptr to binder
-        * void *: cookie for binder
-        */
-
-       BC_ATTEMPT_ACQUIRE = _IOW('c', 10, struct binder_pri_desc),
-       /*
-        * not currently supported
-        * int: priority
-        * int: descriptor
-        */
-
-       BC_REGISTER_LOOPER = _IO('c', 11),
-       /*
-        * No parameters.
-        * Register a spawned looper thread with the device.
-        */
-
-       BC_ENTER_LOOPER = _IO('c', 12),
-       BC_EXIT_LOOPER = _IO('c', 13),
-       /*
-        * No parameters.
-        * These two commands are sent as an application-level thread
-        * enters and exits the binder loop, respectively.  They are
-        * used so the binder can have an accurate count of the number
-        * of looping threads it has available.
-        */
-
-       BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14,
-                                               struct binder_handle_cookie),
-       /*
-        * int: handle
-        * void *: cookie
-        */
-
-       BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15,
-                                               struct binder_handle_cookie),
-       /*
-        * int: handle
-        * void *: cookie
-        */
-
-       BC_DEAD_BINDER_DONE = _IOW('c', 16, binder_uintptr_t),
-       /*
-        * void *: cookie
-        */
-};
-
-#endif /* _UAPI_LINUX_BINDER_H */
-
diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h
deleted file mode 100644 (file)
index 940c852..0000000
+++ /dev/null
@@ -1,474 +0,0 @@
-/***********************************
-*      Adapter.h
-************************************/
-#ifndef        __ADAPTER_H__
-#define        __ADAPTER_H__
-
-#define MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES 256
-#include "Debug.h"
-
-struct bcm_leader {
-       USHORT  Vcid;
-       USHORT  PLength;
-       UCHAR   Status;
-       UCHAR   Unused[3];
-} __packed;
-
-struct bcm_packettosend {
-       struct bcm_leader Leader;
-       UCHAR   ucPayload;
-} __packed;
-
-struct bcm_control_packet {
-       PVOID   ControlBuff;
-       UINT    ControlBuffLen;
-       struct bcm_control_packet *next;
-} __packed;
-
-struct bcm_link_request {
-       struct bcm_leader Leader;
-       UCHAR   szData[4];
-} __packed;
-
-#define MAX_IP_RANGE_LENGTH 4
-#define MAX_PORT_RANGE 4
-#define MAX_PROTOCOL_LENGTH   32
-#define IPV6_ADDRESS_SIZEINBYTES 0x10
-
-union u_ip_address {
-       struct {
-               /* Source Ip Address Range */
-               ULONG ulIpv4Addr[MAX_IP_RANGE_LENGTH];
-                /* Source Ip Mask Address Range */
-               ULONG ulIpv4Mask[MAX_IP_RANGE_LENGTH];
-       };
-       struct {
-               /* Source Ip Address Range */
-               ULONG ulIpv6Addr[MAX_IP_RANGE_LENGTH * 4];
-               /* Source Ip Mask Address Range */
-               ULONG ulIpv6Mask[MAX_IP_RANGE_LENGTH * 4];
-       };
-       struct {
-               UCHAR ucIpv4Address[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
-               UCHAR ucIpv4Mask[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
-       };
-       struct {
-               UCHAR ucIpv6Address[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES];
-               UCHAR ucIpv6Mask[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES];
-       };
-};
-
-struct bcm_hdr_suppression_contextinfo {
-       /* Intermediate buffer to accumulate pkt Header for PHS */
-       UCHAR ucaHdrSuppressionInBuf[MAX_PHS_LENGTHS];
-       /* Intermediate buffer containing pkt Header after PHS */
-       UCHAR ucaHdrSuppressionOutBuf[MAX_PHS_LENGTHS + PHSI_LEN];
-};
-
-struct bcm_classifier_rule {
-       ULONG           ulSFID;
-       UCHAR           ucReserved[2];
-       B_UINT16        uiClassifierRuleIndex;
-       bool            bUsed;
-       USHORT          usVCID_Value;
-       /* This field detemines the Classifier Priority */
-       B_UINT8         u8ClassifierRulePriority;
-       union u_ip_address      stSrcIpAddress;
-       UCHAR           ucIPSourceAddressLength; /* Ip Source Address Length */
-
-       union u_ip_address      stDestIpAddress;
-       /* Ip Destination Address Length */
-       UCHAR           ucIPDestinationAddressLength;
-       UCHAR           ucIPTypeOfServiceLength; /* Type of service Length */
-       UCHAR           ucTosLow; /* Tos Low */
-       UCHAR           ucTosHigh; /* Tos High */
-       UCHAR           ucTosMask; /* Tos Mask */
-
-       UCHAR           ucProtocolLength; /* protocol Length */
-       UCHAR           ucProtocol[MAX_PROTOCOL_LENGTH]; /* protocol Length */
-       USHORT          usSrcPortRangeLo[MAX_PORT_RANGE];
-       USHORT          usSrcPortRangeHi[MAX_PORT_RANGE];
-       UCHAR           ucSrcPortRangeLength;
-
-       USHORT          usDestPortRangeLo[MAX_PORT_RANGE];
-       USHORT          usDestPortRangeHi[MAX_PORT_RANGE];
-       UCHAR           ucDestPortRangeLength;
-
-       bool            bProtocolValid;
-       bool            bTOSValid;
-       bool            bDestIpValid;
-       bool            bSrcIpValid;
-
-       /* For IPv6 Addressing */
-       UCHAR           ucDirection;
-       bool            bIpv6Protocol;
-       UINT32          u32PHSRuleID;
-       struct bcm_phs_rule sPhsRule;
-       UCHAR           u8AssociatedPHSI;
-
-       /* Classification fields for ETH CS */
-       UCHAR           ucEthCSSrcMACLen;
-       UCHAR           au8EThCSSrcMAC[MAC_ADDRESS_SIZE];
-       UCHAR           au8EThCSSrcMACMask[MAC_ADDRESS_SIZE];
-       UCHAR           ucEthCSDestMACLen;
-       UCHAR           au8EThCSDestMAC[MAC_ADDRESS_SIZE];
-       UCHAR           au8EThCSDestMACMask[MAC_ADDRESS_SIZE];
-       UCHAR           ucEtherTypeLen;
-       UCHAR           au8EthCSEtherType[NUM_ETHERTYPE_BYTES];
-       UCHAR           usUserPriority[2];
-       USHORT          usVLANID;
-       USHORT          usValidityBitMap;
-};
-
-struct bcm_fragmented_packet_info {
-       bool                    bUsed;
-       ULONG                   ulSrcIpAddress;
-       USHORT                  usIpIdentification;
-       struct bcm_classifier_rule *pstMatchedClassifierEntry;
-       bool                    bOutOfOrderFragment;
-};
-
-struct bcm_packet_info {
-       /* classification extension Rule */
-       ULONG           ulSFID;
-       USHORT          usVCID_Value;
-       UINT            uiThreshold;
-       /* This field determines the priority of the SF Queues */
-       B_UINT8         u8TrafficPriority;
-
-       bool            bValid;
-       bool            bActive;
-       bool            bActivateRequestSent;
-
-       B_UINT8         u8QueueType; /* BE or rtPS */
-
-       /* maximum size of the bucket for the queue */
-       UINT            uiMaxBucketSize;
-       UINT            uiCurrentQueueDepthOnTarget;
-       UINT            uiCurrentBytesOnHost;
-       UINT            uiCurrentPacketsOnHost;
-       UINT            uiDroppedCountBytes;
-       UINT            uiDroppedCountPackets;
-       UINT            uiSentBytes;
-       UINT            uiSentPackets;
-       UINT            uiCurrentDrainRate;
-       UINT            uiThisPeriodSentBytes;
-       LARGE_INTEGER   liDrainCalculated;
-       UINT            uiCurrentTokenCount;
-       LARGE_INTEGER   liLastUpdateTokenAt;
-       UINT            uiMaxAllowedRate;
-       UINT            NumOfPacketsSent;
-       UCHAR           ucDirection;
-       USHORT          usCID;
-       struct bcm_mibs_parameters stMibsExtServiceFlowTable;
-       UINT            uiCurrentRxRate;
-       UINT            uiThisPeriodRxBytes;
-       UINT            uiTotalRxBytes;
-       UINT            uiTotalTxBytes;
-       UINT            uiPendedLast;
-       UCHAR           ucIpVersion;
-
-       union {
-               struct {
-                       struct sk_buff *FirstTxQueue;
-                       struct sk_buff *LastTxQueue;
-               };
-               struct {
-                       struct sk_buff *ControlHead;
-                       struct sk_buff *ControlTail;
-               };
-       };
-
-       bool            bProtocolValid;
-       bool            bTOSValid;
-       bool            bDestIpValid;
-       bool            bSrcIpValid;
-
-       bool            bActiveSet;
-       bool            bAdmittedSet;
-       bool            bAuthorizedSet;
-       bool            bClassifierPriority;
-       UCHAR           ucServiceClassName[MAX_CLASS_NAME_LENGTH];
-       bool            bHeaderSuppressionEnabled;
-       spinlock_t      SFQueueLock;
-       void            *pstSFIndication;
-       struct timeval  stLastUpdateTokenAt;
-       atomic_t        uiPerSFTxResourceCount;
-       UINT            uiMaxLatency;
-       UCHAR           bIPCSSupport;
-       UCHAR           bEthCSSupport;
-};
-
-struct bcm_tarang_data {
-       struct bcm_tarang_data  *next;
-       struct bcm_mini_adapter *Adapter;
-       struct sk_buff          *RxAppControlHead;
-       struct sk_buff          *RxAppControlTail;
-       int                     AppCtrlQueueLen;
-       bool                    MacTracingEnabled;
-       bool                    bApplicationToExit;
-       struct bcm_mibs_dropped_cntrl_msg stDroppedAppCntrlMsgs;
-       ULONG                   RxCntrlMsgBitMask;
-};
-
-struct bcm_targetdsx_buffer {
-       ULONG           ulTargetDsxBuffer;
-       B_UINT16        tid;
-       bool            valid;
-};
-
-typedef int (*FP_FLASH_WRITE)(struct bcm_mini_adapter *, UINT, PVOID);
-
-typedef int (*FP_FLASH_WRITE_STATUS)(struct bcm_mini_adapter *, UINT, PVOID);
-
-/*
- * Driver adapter data structure
- */
-struct bcm_mini_adapter {
-       struct bcm_mini_adapter *next;
-       struct net_device       *dev;
-       u32                     msg_enable;
-       CHAR                    *caDsxReqResp;
-       atomic_t                ApplicationRunning;
-       bool                    AppCtrlQueueOverFlow;
-       atomic_t                CurrentApplicationCount;
-       atomic_t                RegisteredApplicationCount;
-       bool                    LinkUpStatus;
-       bool                    TimerActive;
-       u32                     StatisticsPointer;
-       struct sk_buff          *RxControlHead;
-       struct sk_buff          *RxControlTail;
-       struct semaphore        RxAppControlQueuelock;
-       struct semaphore        fw_download_sema;
-       struct bcm_tarang_data  *pTarangs;
-       spinlock_t              control_queue_lock;
-       wait_queue_head_t       process_read_wait_queue;
-
-       /* the pointer to the first packet we have queued in send
-        * deserialized miniport support variables
-        */
-       atomic_t                TotalPacketCount;
-       atomic_t                TxPktAvail;
-
-       /* this to keep track of the Tx and Rx MailBox Registers. */
-       atomic_t                CurrNumFreeTxDesc;
-       /* to keep track the no of byte received */
-       USHORT                  PrevNumRecvDescs;
-       USHORT                  CurrNumRecvDescs;
-       UINT                    u32TotalDSD;
-       struct bcm_packet_info  PackInfo[NO_OF_QUEUES];
-       struct bcm_classifier_rule astClassifierTable[MAX_CLASSIFIERS];
-       bool                    TransferMode;
-
-       /*************** qos ******************/
-       bool                    bETHCSEnabled;
-       ULONG                   BEBucketSize;
-       ULONG                   rtPSBucketSize;
-       UCHAR                   LinkStatus;
-       bool                    AutoLinkUp;
-       bool                    AutoSyncup;
-
-       int                     major;
-       int                     minor;
-       wait_queue_head_t       tx_packet_wait_queue;
-       wait_queue_head_t       process_rx_cntrlpkt;
-       atomic_t                process_waiting;
-       bool                    fw_download_done;
-
-       char                    *txctlpacket[MAX_CNTRL_PKTS];
-       atomic_t                cntrlpktCnt;
-       atomic_t                index_app_read_cntrlpkt;
-       atomic_t                index_wr_txcntrlpkt;
-       atomic_t                index_rd_txcntrlpkt;
-       UINT                    index_datpkt;
-       struct semaphore        rdmwrmsync;
-
-       struct bcm_targetdsx_buffer     astTargetDsxBuffer[MAX_TARGET_DSX_BUFFERS];
-       ULONG                   ulFreeTargetBufferCnt;
-       ULONG                   ulCurrentTargetBuffer;
-       ULONG                   ulTotalTargetBuffersAvailable;
-       unsigned long           chip_id;
-       wait_queue_head_t       lowpower_mode_wait_queue;
-       bool                    bFlashBoot;
-       bool                    bBinDownloaded;
-       bool                    bCfgDownloaded;
-       bool                    bSyncUpRequestSent;
-       USHORT                  usBestEffortQueueIndex;
-       wait_queue_head_t       ioctl_fw_dnld_wait_queue;
-       bool                    waiting_to_fw_download_done;
-       pid_t                   fw_download_process_pid;
-       struct bcm_target_params *pstargetparams;
-       bool                    device_removed;
-       bool                    DeviceAccess;
-       bool                    bIsAutoCorrectEnabled;
-       bool                    bDDRInitDone;
-       int                     DDRSetting;
-       ULONG                   ulPowerSaveMode;
-       spinlock_t              txtransmitlock;
-       B_UINT8                 txtransmit_running;
-       /* Thread for control packet handling */
-       struct task_struct      *control_packet_handler;
-       /* thread for transmitting packets. */
-       struct task_struct      *transmit_packet_thread;
-
-       /* LED Related Structures */
-       struct bcm_led_info     LEDInfo;
-
-       /* Driver State for LED Blinking */
-       enum bcm_led_events     DriverState;
-       /* Interface Specific */
-       PVOID                   pvInterfaceAdapter;
-       int (*bcm_file_download)(PVOID,
-                               struct file *,
-                               unsigned int);
-       int (*bcm_file_readback_from_chip)(PVOID,
-                                       struct file *,
-                                       unsigned int);
-       int (*interface_rdm)(PVOID,
-                       UINT,
-                       PVOID,
-                       int);
-       int (*interface_wrm)(PVOID,
-                       UINT,
-                       PVOID,
-                       int);
-       int (*interface_transmit)(PVOID, PVOID , UINT);
-       bool                    IdleMode;
-       bool                    bDregRequestSentInIdleMode;
-       bool                    bTriedToWakeUpFromlowPowerMode;
-       bool                    bShutStatus;
-       bool                    bWakeUpDevice;
-       unsigned int            usIdleModePattern;
-       /* BOOLEAN                      bTriedToWakeUpFromShutdown; */
-       bool                    bLinkDownRequested;
-       int                     downloadDDR;
-       struct bcm_phs_extension stBCMPhsContext;
-       struct bcm_hdr_suppression_contextinfo stPhsTxContextInfo;
-       uint8_t                 ucaPHSPktRestoreBuf[2048];
-       uint8_t                 bPHSEnabled;
-       bool                    AutoFirmDld;
-       bool                    bMipsConfig;
-       bool                    bDPLLConfig;
-       UINT32                  aTxPktSizeHist[MIBS_MAX_HIST_ENTRIES];
-       UINT32                  aRxPktSizeHist[MIBS_MAX_HIST_ENTRIES];
-       struct bcm_fragmented_packet_info
-               astFragmentedPktClassifierTable[MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES];
-       atomic_t                uiMBupdate;
-       UINT32                  PmuMode;
-       enum bcm_nvm_type       eNVMType;
-       UINT                    uiSectorSize;
-       UINT                    uiSectorSizeInCFG;
-       bool                    bSectorSizeOverride;
-       bool                    bStatusWrite;
-       UINT                    uiNVMDSDSize;
-       UINT                    uiVendorExtnFlag;
-       /* it will always represent chosen DSD at any point of time.
-        * Generally it is Active DSD but in case of NVM RD/WR it
-        * might be different.
-        */
-       UINT                    ulFlashCalStart;
-       ULONG                   ulFlashControlSectionStart;
-       ULONG                   ulFlashWriteSize;
-       ULONG                   ulFlashID;
-       FP_FLASH_WRITE          fpFlashWrite;
-       FP_FLASH_WRITE_STATUS   fpFlashWriteWithStatusCheck;
-
-       struct semaphore        NVMRdmWrmLock;
-       struct device           *pstCreatedClassDevice;
-
-       /*      BOOLEAN                         InterfaceUpStatus; */
-       struct bcm_flash2x_cs_info *psFlash2xCSInfo;
-       struct bcm_flash_cs_info *psFlashCSInfo;
-       struct bcm_flash2x_vendor_info *psFlash2xVendorInfo;
-       UINT                    uiFlashBaseAdd; /* Flash start address */
-       /* Active ISO offset chosen before f/w download */
-       UINT                    uiActiveISOOffset;
-       enum bcm_flash2x_section_val eActiveISO; /* Active ISO section val */
-       /* Active DSD val chosen before f/w download */
-       enum bcm_flash2x_section_val eActiveDSD;
-       /* For accessing Active DSD chosen before f/w download */
-       UINT                    uiActiveDSDOffsetAtFwDld;
-       UINT                    uiFlashLayoutMajorVersion;
-       UINT                    uiFlashLayoutMinorVersion;
-       bool                    bAllDSDWriteAllow;
-       bool                    bSigCorrupted;
-       /* this should be set who so ever want to change the Headers.
-        * after Write it should be reset immediately.
-        */
-       bool                    bHeaderChangeAllowed;
-       int                     SelectedChip;
-       bool                    bEndPointHalted;
-       /* while bFlashRawRead will be true, Driver
-        * ignore map lay out and consider flash as of without any map.
-        */
-       bool                    bFlashRawRead;
-       bool                    bPreparingForLowPowerMode;
-       bool                    bDoSuspend;
-       UINT                    syscfgBefFwDld;
-       bool                    StopAllXaction;
-       /* Used to Support extended CAPI requirements from */
-       UINT32                  liTimeSinceLastNetEntry;
-       struct semaphore        LowPowerModeSync;
-       ULONG                   liDrainCalculated;
-       UINT                    gpioBitMap;
-       struct bcm_debug_state  stDebugState;
-};
-
-#define GET_BCM_ADAPTER(net_dev) netdev_priv(net_dev)
-
-struct bcm_eth_header {
-       UCHAR   au8DestinationAddress[6];
-       UCHAR   au8SourceAddress[6];
-       USHORT  u16Etype;
-} __packed;
-
-struct bcm_firmware_info {
-       void    __user *pvMappedFirmwareAddress;
-       ULONG   u32FirmwareLength;
-       ULONG   u32StartingAddress;
-} __packed;
-
-/* holds the value of net_device structure.. */
-extern struct net_device *gblpnetdev;
-
-struct bcm_ddr_setting {
-       UINT ulRegAddress;
-       UINT ulRegValue;
-};
-int InitAdapter(struct bcm_mini_adapter *psAdapter);
-
-/* =====================================================================
- * Beceem vendor request codes for EP0
- * =====================================================================
- */
-
-#define BCM_REQUEST_READ       0x2
-#define BCM_REQUEST_WRITE      0x1
-#define EP2_MPS_REG            0x0F0110A0
-#define EP2_MPS                        0x40
-
-#define EP2_CFG_REG    0x0F0110A8
-#define EP2_CFG_INT    0x27
-#define EP2_CFG_BULK   0x25
-
-#define EP4_MPS_REG    0x0F0110F0
-#define EP4_MPS                0x8C
-
-#define EP4_CFG_REG    0x0F0110F8
-
-#define ISO_MPS_REG    0x0F0110C8
-#define ISO_MPS                0x00000000
-
-#define EP1 0
-#define EP2 1
-#define EP3 2
-#define EP4 3
-#define EP5 4
-#define EP6 5
-
-enum bcm_einterface_setting {
-       DEFAULT_SETTING_0  = 0,
-       ALTERNATE_SETTING_1 = 1,
-};
-
-#endif /* __ADAPTER_H__ */
diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c
deleted file mode 100644 (file)
index 88ce2da..0000000
+++ /dev/null
@@ -1,2652 +0,0 @@
-#include <linux/fs.h>
-
-#include "headers.h"
-
-static int bcm_handle_nvm_read_cmd(struct bcm_mini_adapter *ad,
-                                  PUCHAR read_data,
-                                  struct bcm_nvm_readwrite *nvm_rw)
-{
-       INT status = STATUS_FAILURE;
-
-       down(&ad->NVMRdmWrmLock);
-
-       if ((ad->IdleMode == TRUE) || (ad->bShutStatus == TRUE) ||
-                       (ad->bPreparingForLowPowerMode == TRUE)) {
-
-               BCM_DEBUG_PRINT(ad,
-                       DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "Device is in Idle/Shutdown Mode\n");
-               up(&ad->NVMRdmWrmLock);
-               kfree(read_data);
-               return -EACCES;
-       }
-
-       status = BeceemNVMRead(ad, (PUINT)read_data,
-                              nvm_rw->uiOffset,
-                              nvm_rw->uiNumBytes);
-       up(&ad->NVMRdmWrmLock);
-
-       if (status != STATUS_SUCCESS) {
-               kfree(read_data);
-               return status;
-       }
-
-       if (copy_to_user(nvm_rw->pBuffer, read_data, nvm_rw->uiNumBytes)) {
-               kfree(read_data);
-               return -EFAULT;
-       }
-
-       return STATUS_SUCCESS;
-}
-
-static int handle_flash2x_adapter(struct bcm_mini_adapter *ad,
-                                 PUCHAR read_data,
-                                 struct bcm_nvm_readwrite *nvm_rw)
-{
-       /*
-        * New Requirement:-
-        * DSD section updation will be allowed in two case:-
-        * 1.  if DSD sig is present in DSD header means dongle
-        * is ok and updation is fruitfull
-        * 2.  if point 1 failes then user buff should have
-        * DSD sig. this point ensures that if dongle is
-        * corrupted then user space program first modify
-        * the DSD header with valid DSD sig so that this
-        * as well as further write may be worthwhile.
-        *
-        * This restriction has been put assuming that
-        * if DSD sig is corrupted, DSD data won't be
-        * considered valid.
-        */
-       INT status;
-       ULONG dsd_magic_num_in_usr_buff = 0;
-
-       status = BcmFlash2xCorruptSig(ad, ad->eActiveDSD);
-       if (status == STATUS_SUCCESS)
-               return STATUS_SUCCESS;
-
-       if (((nvm_rw->uiOffset + nvm_rw->uiNumBytes) !=
-                       ad->uiNVMDSDSize) ||
-                       (nvm_rw->uiNumBytes < SIGNATURE_SIZE)) {
-
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "DSD Sig is present neither in Flash nor User provided Input..");
-               up(&ad->NVMRdmWrmLock);
-               kfree(read_data);
-               return status;
-       }
-
-       dsd_magic_num_in_usr_buff =
-               ntohl(*(PUINT)(read_data + nvm_rw->uiNumBytes -
-                     SIGNATURE_SIZE));
-       if (dsd_magic_num_in_usr_buff != DSD_IMAGE_MAGIC_NUMBER) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "DSD Sig is present neither in Flash nor User provided Input..");
-               up(&ad->NVMRdmWrmLock);
-               kfree(read_data);
-               return status;
-       }
-
-       return STATUS_SUCCESS;
-}
-
-/***************************************************************
-* Function       - bcm_char_open()
-*
-* Description - This is the "open" entry point for the character
-*                              driver.
-*
-* Parameters  - inode: Pointer to the Inode structure of char device
-*                              filp : File pointer of the char device
-*
-* Returns        - Zero(Success)
-****************************************************************/
-
-static int bcm_char_open(struct inode *inode, struct file *filp)
-{
-       struct bcm_mini_adapter *ad = NULL;
-       struct bcm_tarang_data *tarang = NULL;
-
-       ad = GET_BCM_ADAPTER(gblpnetdev);
-       tarang = kzalloc(sizeof(struct bcm_tarang_data), GFP_KERNEL);
-       if (!tarang)
-               return -ENOMEM;
-
-       tarang->Adapter = ad;
-       tarang->RxCntrlMsgBitMask = 0xFFFFFFFF & ~(1 << 0xB);
-
-       down(&ad->RxAppControlQueuelock);
-       tarang->next = ad->pTarangs;
-       ad->pTarangs = tarang;
-       up(&ad->RxAppControlQueuelock);
-
-       /* Store the Adapter structure */
-       filp->private_data = tarang;
-
-       /* Start Queuing the control response Packets */
-       atomic_inc(&ad->ApplicationRunning);
-
-       nonseekable_open(inode, filp);
-       return 0;
-}
-
-static int bcm_char_release(struct inode *inode, struct file *filp)
-{
-       struct bcm_tarang_data *tarang, *tmp, *ptmp;
-       struct bcm_mini_adapter *ad = NULL;
-       struct sk_buff *pkt, *npkt;
-
-       tarang = (struct bcm_tarang_data *)filp->private_data;
-
-       if (tarang == NULL)
-               return 0;
-
-       ad = tarang->Adapter;
-
-       down(&ad->RxAppControlQueuelock);
-
-       tmp = ad->pTarangs;
-       for (ptmp = NULL; tmp; ptmp = tmp, tmp = tmp->next) {
-               if (tmp == tarang)
-                       break;
-       }
-
-       if (tmp) {
-               if (!ptmp)
-                       ad->pTarangs = tmp->next;
-               else
-                       ptmp->next = tmp->next;
-       } else {
-               up(&ad->RxAppControlQueuelock);
-               return 0;
-       }
-
-       pkt = tarang->RxAppControlHead;
-       while (pkt) {
-               npkt = pkt->next;
-               kfree_skb(pkt);
-               pkt = npkt;
-       }
-
-       up(&ad->RxAppControlQueuelock);
-
-       /* Stop Queuing the control response Packets */
-       atomic_dec(&ad->ApplicationRunning);
-
-       kfree(tarang);
-
-       /* remove this filp from the asynchronously notified filp's */
-       filp->private_data = NULL;
-       return 0;
-}
-
-static ssize_t bcm_char_read(struct file *filp,
-                            char __user *buf,
-                            size_t size,
-                            loff_t *f_pos)
-{
-       struct bcm_tarang_data *tarang = filp->private_data;
-       struct bcm_mini_adapter *ad = tarang->Adapter;
-       struct sk_buff *packet = NULL;
-       ssize_t pkt_len = 0;
-       int wait_ret_val = 0;
-       unsigned long ret = 0;
-
-       wait_ret_val = wait_event_interruptible(
-                               ad->process_read_wait_queue,
-                               (tarang->RxAppControlHead ||
-                               ad->device_removed));
-
-       if ((wait_ret_val == -ERESTARTSYS)) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "Exiting as i've been asked to exit!!!\n");
-               return wait_ret_val;
-       }
-
-       if (ad->device_removed) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "Device Removed... Killing the Apps...\n");
-               return -ENODEV;
-       }
-
-       if (false == ad->fw_download_done)
-               return -EACCES;
-
-       down(&ad->RxAppControlQueuelock);
-
-       if (tarang->RxAppControlHead) {
-               packet = tarang->RxAppControlHead;
-               DEQUEUEPACKET(tarang->RxAppControlHead,
-                             tarang->RxAppControlTail);
-               tarang->AppCtrlQueueLen--;
-       }
-
-       up(&ad->RxAppControlQueuelock);
-
-       if (packet) {
-               pkt_len = packet->len;
-               ret = copy_to_user(buf, packet->data,
-                                  min_t(size_t, pkt_len, size));
-               if (ret) {
-                       dev_kfree_skb(packet);
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                                       "Returning from copy to user failure\n");
-                       return -EFAULT;
-               }
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "Read %zd Bytes From Adapter packet = %p by process %d!\n",
-                               pkt_len, packet, current->pid);
-               dev_kfree_skb(packet);
-       }
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "<\n");
-       return pkt_len;
-}
-
-static int bcm_char_ioctl_reg_read_private(void __user *argp,
-                                          struct bcm_mini_adapter *ad)
-{
-       struct bcm_rdm_buffer rdm_buff = {0};
-       struct bcm_ioctl_buffer io_buff;
-       PCHAR temp_buff;
-       INT status = STATUS_FAILURE;
-       UINT buff_len;
-       u16 temp_value;
-       int bytes;
-
-       /* Copy Ioctl Buffer structure */
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (io_buff.InputLength > sizeof(rdm_buff))
-               return -EINVAL;
-
-       if (copy_from_user(&rdm_buff, io_buff.InputBuffer,
-               io_buff.InputLength))
-               return -EFAULT;
-
-       if (io_buff.OutputLength > USHRT_MAX ||
-               io_buff.OutputLength == 0) {
-               return -EINVAL;
-       }
-
-       buff_len = io_buff.OutputLength;
-       temp_value = 4 - (buff_len % 4);
-       buff_len += temp_value % 4;
-
-       temp_buff = kmalloc(buff_len, GFP_KERNEL);
-       if (!temp_buff)
-               return -ENOMEM;
-
-       bytes = rdmalt(ad, (UINT)rdm_buff.Register,
-                       (PUINT)temp_buff, buff_len);
-       if (bytes > 0) {
-               status = STATUS_SUCCESS;
-               if (copy_to_user(io_buff.OutputBuffer, temp_buff, bytes)) {
-                       kfree(temp_buff);
-                       return -EFAULT;
-               }
-       } else {
-               status = bytes;
-       }
-
-       kfree(temp_buff);
-       return status;
-}
-
-static int bcm_char_ioctl_reg_write_private(void __user *argp,
-                                           struct bcm_mini_adapter *ad)
-{
-       struct bcm_wrm_buffer wrm_buff = {0};
-       struct bcm_ioctl_buffer io_buff;
-       UINT tmp = 0;
-       INT status;
-
-       /* Copy Ioctl Buffer structure */
-
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (io_buff.InputLength > sizeof(wrm_buff))
-               return -EINVAL;
-
-       /* Get WrmBuffer structure */
-       if (copy_from_user(&wrm_buff, io_buff.InputBuffer,
-               io_buff.InputLength))
-               return -EFAULT;
-
-       tmp = wrm_buff.Register & EEPROM_REJECT_MASK;
-       if (!((ad->pstargetparams->m_u32Customize) & VSG_MODE) &&
-               ((tmp == EEPROM_REJECT_REG_1) ||
-                       (tmp == EEPROM_REJECT_REG_2) ||
-                       (tmp == EEPROM_REJECT_REG_3) ||
-                       (tmp == EEPROM_REJECT_REG_4))) {
-
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "EEPROM Access Denied, not in VSG Mode\n");
-               return -EFAULT;
-       }
-
-       status = wrmalt(ad, (UINT)wrm_buff.Register,
-                       (PUINT)wrm_buff.Data, sizeof(ULONG));
-
-       if (status == STATUS_SUCCESS) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
-                               DBG_LVL_ALL, "WRM Done\n");
-       } else {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
-                               DBG_LVL_ALL, "WRM Failed\n");
-               status = -EFAULT;
-       }
-       return status;
-}
-
-static int bcm_char_ioctl_eeprom_reg_read(void __user *argp,
-                                         struct bcm_mini_adapter *ad)
-{
-       struct bcm_rdm_buffer rdm_buff = {0};
-       struct bcm_ioctl_buffer io_buff;
-       PCHAR temp_buff = NULL;
-       UINT tmp = 0;
-       INT status;
-       int bytes;
-
-       if ((ad->IdleMode == TRUE) ||
-               (ad->bShutStatus == TRUE) ||
-               (ad->bPreparingForLowPowerMode == TRUE)) {
-
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Device in Idle Mode, Blocking Rdms\n");
-               return -EACCES;
-       }
-
-       /* Copy Ioctl Buffer structure */
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (io_buff.InputLength > sizeof(rdm_buff))
-               return -EINVAL;
-
-       if (copy_from_user(&rdm_buff, io_buff.InputBuffer,
-               io_buff.InputLength))
-               return -EFAULT;
-
-       if (io_buff.OutputLength > USHRT_MAX ||
-               io_buff.OutputLength == 0) {
-               return -EINVAL;
-       }
-
-       temp_buff = kmalloc(io_buff.OutputLength, GFP_KERNEL);
-       if (!temp_buff)
-               return STATUS_FAILURE;
-
-       if ((((ULONG)rdm_buff.Register & 0x0F000000) != 0x0F000000) ||
-               ((ULONG)rdm_buff.Register & 0x3)) {
-
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "RDM Done On invalid Address : %x Access Denied.\n",
-                               (int)rdm_buff.Register);
-
-               kfree(temp_buff);
-               return -EINVAL;
-       }
-
-       tmp = rdm_buff.Register & EEPROM_REJECT_MASK;
-       bytes = rdmaltWithLock(ad, (UINT)rdm_buff.Register,
-                              (PUINT)temp_buff, io_buff.OutputLength);
-
-       if (bytes > 0) {
-               status = STATUS_SUCCESS;
-               if (copy_to_user(io_buff.OutputBuffer, temp_buff, bytes)) {
-                       kfree(temp_buff);
-                       return -EFAULT;
-               }
-       } else {
-               status = bytes;
-       }
-
-       kfree(temp_buff);
-       return status;
-}
-
-static int bcm_char_ioctl_eeprom_reg_write(void __user *argp,
-                                          struct bcm_mini_adapter *ad,
-                                          UINT cmd)
-{
-       struct bcm_wrm_buffer wrm_buff = {0};
-       struct bcm_ioctl_buffer io_buff;
-       UINT tmp = 0;
-       INT status;
-
-       if ((ad->IdleMode == TRUE) ||
-               (ad->bShutStatus == TRUE) ||
-               (ad->bPreparingForLowPowerMode == TRUE)) {
-
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Device in Idle Mode, Blocking Wrms\n");
-               return -EACCES;
-       }
-
-       /* Copy Ioctl Buffer structure */
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (io_buff.InputLength > sizeof(wrm_buff))
-               return -EINVAL;
-
-       /* Get WrmBuffer structure */
-       if (copy_from_user(&wrm_buff, io_buff.InputBuffer,
-               io_buff.InputLength))
-               return -EFAULT;
-
-       if ((((ULONG)wrm_buff.Register & 0x0F000000) != 0x0F000000) ||
-               ((ULONG)wrm_buff.Register & 0x3)) {
-
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "WRM Done On invalid Address : %x Access Denied.\n",
-                               (int)wrm_buff.Register);
-               return -EINVAL;
-       }
-
-       tmp = wrm_buff.Register & EEPROM_REJECT_MASK;
-       if (!((ad->pstargetparams->m_u32Customize) & VSG_MODE) &&
-                       ((tmp == EEPROM_REJECT_REG_1) ||
-                       (tmp == EEPROM_REJECT_REG_2) ||
-                       (tmp == EEPROM_REJECT_REG_3) ||
-                       (tmp == EEPROM_REJECT_REG_4)) &&
-                       (cmd == IOCTL_BCM_REGISTER_WRITE)) {
-
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                                       "EEPROM Access Denied, not in VSG Mode\n");
-                       return -EFAULT;
-       }
-
-       status = wrmaltWithLock(ad, (UINT)wrm_buff.Register,
-                               (PUINT)wrm_buff.Data,
-                               wrm_buff.Length);
-
-       if (status == STATUS_SUCCESS) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, OSAL_DBG,
-                               DBG_LVL_ALL, "WRM Done\n");
-       } else {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
-                               DBG_LVL_ALL, "WRM Failed\n");
-               status = -EFAULT;
-       }
-       return status;
-}
-
-static int bcm_char_ioctl_gpio_set_request(void __user *argp,
-                                          struct bcm_mini_adapter *ad)
-{
-       struct bcm_gpio_info gpio_info = {0};
-       struct bcm_ioctl_buffer io_buff;
-       UCHAR reset_val[4];
-       UINT value = 0;
-       UINT bit = 0;
-       UINT operation = 0;
-       INT status;
-       int bytes;
-
-       if ((ad->IdleMode == TRUE) ||
-               (ad->bShutStatus == TRUE) ||
-               (ad->bPreparingForLowPowerMode == TRUE)) {
-
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
-                               DBG_LVL_ALL,
-                               "GPIO Can't be set/clear in Low power Mode");
-               return -EACCES;
-       }
-
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (io_buff.InputLength > sizeof(gpio_info))
-               return -EINVAL;
-
-       if (copy_from_user(&gpio_info, io_buff.InputBuffer,
-                          io_buff.InputLength))
-               return -EFAULT;
-
-       bit  = gpio_info.uiGpioNumber;
-       operation = gpio_info.uiGpioValue;
-       value = (1<<bit);
-
-       if (IsReqGpioIsLedInNVM(ad, value) == false) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
-                               DBG_LVL_ALL,
-                               "Sorry, Requested GPIO<0x%X> is not correspond to LED !!!",
-                               value);
-               return -EINVAL;
-       }
-
-       /* Set - setting 1 */
-       if (operation) {
-               /* Set the gpio output register */
-               status = wrmaltWithLock(ad,
-                                       BCM_GPIO_OUTPUT_SET_REG,
-                                       (PUINT)(&value), sizeof(UINT));
-
-               if (status == STATUS_SUCCESS) {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS,
-                                       OSAL_DBG, DBG_LVL_ALL,
-                                       "Set the GPIO bit\n");
-               } else {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS,
-                                       OSAL_DBG, DBG_LVL_ALL,
-                                       "Failed to set the %dth GPIO\n",
-                                       bit);
-                       return status;
-               }
-       } else {
-               /* Set the gpio output register */
-               status = wrmaltWithLock(ad,
-                                       BCM_GPIO_OUTPUT_CLR_REG,
-                                       (PUINT)(&value), sizeof(UINT));
-
-               if (status == STATUS_SUCCESS) {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS,
-                                       OSAL_DBG, DBG_LVL_ALL,
-                                       "Set the GPIO bit\n");
-               } else {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS,
-                                       OSAL_DBG, DBG_LVL_ALL,
-                                       "Failed to clear the %dth GPIO\n",
-                                       bit);
-                       return status;
-               }
-       }
-
-       bytes = rdmaltWithLock(ad, (UINT)GPIO_MODE_REGISTER,
-                              (PUINT)reset_val, sizeof(UINT));
-       if (bytes < 0) {
-               status = bytes;
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "GPIO_MODE_REGISTER read failed");
-               return status;
-       }
-       status = STATUS_SUCCESS;
-
-       /* Set the gpio mode register to output */
-       *(UINT *)reset_val |= (1<<bit);
-       status = wrmaltWithLock(ad, GPIO_MODE_REGISTER,
-                               (PUINT)reset_val, sizeof(UINT));
-
-       if (status == STATUS_SUCCESS) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
-                               DBG_LVL_ALL,
-                               "Set the GPIO to output Mode\n");
-       } else {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
-                               DBG_LVL_ALL,
-                               "Failed to put GPIO in Output Mode\n");
-       }
-
-       return status;
-}
-
-static int bcm_char_ioctl_led_thread_state_change_req(void __user *argp,
-               struct bcm_mini_adapter *ad)
-{
-       struct bcm_user_thread_req thread_req = {0};
-       struct bcm_ioctl_buffer io_buff;
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "User made LED thread InActive");
-
-       if ((ad->IdleMode == TRUE) ||
-               (ad->bShutStatus == TRUE) ||
-               (ad->bPreparingForLowPowerMode == TRUE)) {
-
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
-                               DBG_LVL_ALL,
-                               "GPIO Can't be set/clear in Low power Mode");
-               return -EACCES;
-       }
-
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (io_buff.InputLength > sizeof(thread_req))
-               return -EINVAL;
-
-       if (copy_from_user(&thread_req, io_buff.InputBuffer,
-                          io_buff.InputLength))
-               return -EFAULT;
-
-       /* if LED thread is running(Actively or Inactively)
-        * set it state to make inactive
-        */
-       if (ad->LEDInfo.led_thread_running) {
-               if (thread_req.ThreadState == LED_THREAD_ACTIVATION_REQ) {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS,
-                                       OSAL_DBG, DBG_LVL_ALL,
-                                       "Activating thread req");
-                       ad->DriverState = LED_THREAD_ACTIVE;
-               } else {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS,
-                                       OSAL_DBG, DBG_LVL_ALL,
-                                       "DeActivating Thread req.....");
-                       ad->DriverState = LED_THREAD_INACTIVE;
-               }
-
-               /* signal thread. */
-               wake_up(&ad->LEDInfo.notify_led_event);
-       }
-       return STATUS_SUCCESS;
-}
-
-static int bcm_char_ioctl_gpio_status_request(void __user *argp,
-                                             struct bcm_mini_adapter *ad)
-{
-       struct bcm_gpio_info gpio_info = {0};
-       struct bcm_ioctl_buffer io_buff;
-       ULONG bit = 0;
-       UCHAR read[4];
-       INT status;
-       int bytes;
-
-       if ((ad->IdleMode == TRUE) ||
-               (ad->bShutStatus == TRUE) ||
-               (ad->bPreparingForLowPowerMode == TRUE))
-               return -EACCES;
-
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (io_buff.InputLength > sizeof(gpio_info))
-               return -EINVAL;
-
-       if (copy_from_user(&gpio_info, io_buff.InputBuffer,
-               io_buff.InputLength))
-               return -EFAULT;
-
-       bit = gpio_info.uiGpioNumber;
-
-       /* Set the gpio output register */
-       bytes = rdmaltWithLock(ad, (UINT)GPIO_PIN_STATE_REGISTER,
-                               (PUINT)read, sizeof(UINT));
-
-       if (bytes < 0) {
-               status = bytes;
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "RDM Failed\n");
-               return status;
-       }
-       status = STATUS_SUCCESS;
-       return status;
-}
-
-static int bcm_char_ioctl_gpio_multi_request(void __user *argp,
-                                            struct bcm_mini_adapter *ad)
-{
-       struct bcm_gpio_multi_info gpio_multi_info[MAX_IDX];
-       struct bcm_gpio_multi_info *pgpio_multi_info =
-               (struct bcm_gpio_multi_info *)gpio_multi_info;
-       struct bcm_ioctl_buffer io_buff;
-       UCHAR reset_val[4];
-       INT status = STATUS_FAILURE;
-       int bytes;
-
-       memset(pgpio_multi_info, 0,
-              MAX_IDX * sizeof(struct bcm_gpio_multi_info));
-
-       if ((ad->IdleMode == TRUE) ||
-               (ad->bShutStatus == TRUE) ||
-               (ad->bPreparingForLowPowerMode == TRUE))
-               return -EINVAL;
-
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (io_buff.InputLength > sizeof(gpio_multi_info))
-               return -EINVAL;
-       if (io_buff.OutputLength > sizeof(gpio_multi_info))
-               io_buff.OutputLength = sizeof(gpio_multi_info);
-
-       if (copy_from_user(&gpio_multi_info, io_buff.InputBuffer,
-                          io_buff.InputLength))
-               return -EFAULT;
-
-       if (IsReqGpioIsLedInNVM(ad, pgpio_multi_info[WIMAX_IDX].uiGPIOMask)
-                       == false) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
-                               DBG_LVL_ALL,
-                               "Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!",
-                               pgpio_multi_info[WIMAX_IDX].uiGPIOMask,
-                               ad->gpioBitMap);
-               return -EINVAL;
-       }
-
-       /* Set the gpio output register */
-       if ((pgpio_multi_info[WIMAX_IDX].uiGPIOMask) &
-               (pgpio_multi_info[WIMAX_IDX].uiGPIOCommand)) {
-               /* Set 1's in GPIO OUTPUT REGISTER */
-               *(UINT *)reset_val = pgpio_multi_info[WIMAX_IDX].uiGPIOMask &
-                       pgpio_multi_info[WIMAX_IDX].uiGPIOCommand &
-                       pgpio_multi_info[WIMAX_IDX].uiGPIOValue;
-
-               if (*(UINT *) reset_val)
-                       status = wrmaltWithLock(ad,
-                               BCM_GPIO_OUTPUT_SET_REG,
-                               (PUINT)reset_val, sizeof(ULONG));
-
-               if (status != STATUS_SUCCESS) {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "WRM to BCM_GPIO_OUTPUT_SET_REG Failed.");
-                       return status;
-               }
-
-               /* Clear to 0's in GPIO OUTPUT REGISTER */
-               *(UINT *)reset_val =
-                       (pgpio_multi_info[WIMAX_IDX].uiGPIOMask &
-                       pgpio_multi_info[WIMAX_IDX].uiGPIOCommand &
-                       (~(pgpio_multi_info[WIMAX_IDX].uiGPIOValue)));
-
-               if (*(UINT *) reset_val)
-                       status = wrmaltWithLock(ad,
-                               BCM_GPIO_OUTPUT_CLR_REG, (PUINT)reset_val,
-                               sizeof(ULONG));
-
-               if (status != STATUS_SUCCESS) {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                                       "WRM to BCM_GPIO_OUTPUT_CLR_REG Failed.");
-                       return status;
-               }
-       }
-
-       if (pgpio_multi_info[WIMAX_IDX].uiGPIOMask) {
-               bytes = rdmaltWithLock(ad, (UINT)GPIO_PIN_STATE_REGISTER,
-                                      (PUINT)reset_val, sizeof(UINT));
-
-               if (bytes < 0) {
-                       status = bytes;
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                                       "RDM to GPIO_PIN_STATE_REGISTER Failed.");
-                       return status;
-               }
-               status = STATUS_SUCCESS;
-
-               pgpio_multi_info[WIMAX_IDX].uiGPIOValue =
-                       (*(UINT *)reset_val &
-                       pgpio_multi_info[WIMAX_IDX].uiGPIOMask);
-       }
-
-       status = copy_to_user(io_buff.OutputBuffer, &gpio_multi_info,
-               io_buff.OutputLength);
-       if (status) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                       "Failed while copying Content to IOBufer for user space err:%d",
-                       status);
-               return -EFAULT;
-       }
-       return status;
-}
-
-static int bcm_char_ioctl_gpio_mode_request(void __user *argp,
-                                           struct bcm_mini_adapter *ad)
-{
-       struct bcm_gpio_multi_mode gpio_multi_mode[MAX_IDX];
-       struct bcm_gpio_multi_mode *pgpio_multi_mode =
-               (struct bcm_gpio_multi_mode *)gpio_multi_mode;
-       struct bcm_ioctl_buffer io_buff;
-       UCHAR reset_val[4];
-       INT status;
-       int bytes;
-
-       if ((ad->IdleMode == TRUE) ||
-               (ad->bShutStatus == TRUE) ||
-               (ad->bPreparingForLowPowerMode == TRUE))
-               return -EINVAL;
-
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (io_buff.InputLength > sizeof(gpio_multi_mode))
-               return -EINVAL;
-       if (io_buff.OutputLength > sizeof(gpio_multi_mode))
-               io_buff.OutputLength = sizeof(gpio_multi_mode);
-
-       if (copy_from_user(&gpio_multi_mode, io_buff.InputBuffer,
-               io_buff.InputLength))
-               return -EFAULT;
-
-       bytes = rdmaltWithLock(ad, (UINT)GPIO_MODE_REGISTER,
-               (PUINT)reset_val, sizeof(UINT));
-
-       if (bytes < 0) {
-               status = bytes;
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                       "Read of GPIO_MODE_REGISTER failed");
-               return status;
-       }
-       status = STATUS_SUCCESS;
-
-       /* Validating the request */
-       if (IsReqGpioIsLedInNVM(ad, pgpio_multi_mode[WIMAX_IDX].uiGPIOMask)
-                       == false) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!",
-                               pgpio_multi_mode[WIMAX_IDX].uiGPIOMask,
-                               ad->gpioBitMap);
-               return -EINVAL;
-       }
-
-       if (pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) {
-               /* write all OUT's (1's) */
-               *(UINT *) reset_val |=
-                       (pgpio_multi_mode[WIMAX_IDX].uiGPIOMode &
-                                       pgpio_multi_mode[WIMAX_IDX].uiGPIOMask);
-
-               /* write all IN's (0's) */
-               *(UINT *) reset_val &=
-                       ~((~pgpio_multi_mode[WIMAX_IDX].uiGPIOMode) &
-                                       pgpio_multi_mode[WIMAX_IDX].uiGPIOMask);
-
-               /* Currently implemented return the modes of all GPIO's
-                * else needs to bit AND with  mask
-                */
-               pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT *)reset_val;
-
-               status = wrmaltWithLock(ad, GPIO_MODE_REGISTER,
-                       (PUINT)reset_val, sizeof(ULONG));
-               if (status == STATUS_SUCCESS) {
-                       BCM_DEBUG_PRINT(ad,
-                               DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "WRM to GPIO_MODE_REGISTER Done");
-               } else {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                                       "WRM to GPIO_MODE_REGISTER Failed");
-                       return -EFAULT;
-               }
-       } else {
-               /* if uiGPIOMask is 0 then return mode register configuration */
-               pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT *)reset_val;
-       }
-
-       status = copy_to_user(io_buff.OutputBuffer, &gpio_multi_mode,
-               io_buff.OutputLength);
-       if (status) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                       "Failed while copying Content to IOBufer for user space err:%d",
-                       status);
-               return -EFAULT;
-       }
-       return status;
-}
-
-static int bcm_char_ioctl_misc_request(void __user *argp,
-                                      struct bcm_mini_adapter *ad)
-{
-       struct bcm_ioctl_buffer io_buff;
-       PVOID buff = NULL;
-       INT status;
-
-       /* Copy Ioctl Buffer structure */
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (io_buff.InputLength < sizeof(struct bcm_link_request))
-               return -EINVAL;
-
-       if (io_buff.InputLength > MAX_CNTL_PKT_SIZE)
-               return -EINVAL;
-
-       buff = memdup_user(io_buff.InputBuffer,
-                              io_buff.InputLength);
-       if (IS_ERR(buff))
-               return PTR_ERR(buff);
-
-       down(&ad->LowPowerModeSync);
-       status = wait_event_interruptible_timeout(
-                       ad->lowpower_mode_wait_queue,
-                       !ad->bPreparingForLowPowerMode,
-                       (1 * HZ));
-
-       if (status == -ERESTARTSYS)
-               goto cntrlEnd;
-
-       if (ad->bPreparingForLowPowerMode) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "Preparing Idle Mode is still True - Hence Rejecting control message\n");
-               status = STATUS_FAILURE;
-               goto cntrlEnd;
-       }
-       status = CopyBufferToControlPacket(ad, (PVOID)buff);
-
-cntrlEnd:
-       up(&ad->LowPowerModeSync);
-       kfree(buff);
-       return status;
-}
-
-static int bcm_char_ioctl_buffer_download_start(
-               struct bcm_mini_adapter *ad)
-{
-       INT status;
-
-       if (down_trylock(&ad->NVMRdmWrmLock)) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n");
-               return -EACCES;
-       }
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                       "Starting the firmware download PID =0x%x!!!!\n",
-                       current->pid);
-
-       if (down_trylock(&ad->fw_download_sema))
-               return -EBUSY;
-
-       ad->bBinDownloaded = false;
-       ad->fw_download_process_pid = current->pid;
-       ad->bCfgDownloaded = false;
-       ad->fw_download_done = false;
-       netif_carrier_off(ad->dev);
-       netif_stop_queue(ad->dev);
-       status = reset_card_proc(ad);
-       if (status) {
-               pr_err(PFX "%s: reset_card_proc Failed!\n", ad->dev->name);
-               up(&ad->fw_download_sema);
-               up(&ad->NVMRdmWrmLock);
-               return status;
-       }
-       mdelay(10);
-
-       up(&ad->NVMRdmWrmLock);
-       return status;
-}
-
-static int bcm_char_ioctl_buffer_download(void __user *argp,
-                                         struct bcm_mini_adapter *ad)
-{
-       struct bcm_firmware_info *fw_info = NULL;
-       struct bcm_ioctl_buffer io_buff;
-       INT status;
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-               "Starting the firmware download PID =0x%x!!!!\n", current->pid);
-
-       if (!down_trylock(&ad->fw_download_sema)) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Invalid way to download buffer. Use Start and then call this!!!\n");
-               up(&ad->fw_download_sema);
-               return -EINVAL;
-       }
-
-       /* Copy Ioctl Buffer structure */
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) {
-               up(&ad->fw_download_sema);
-               return -EFAULT;
-       }
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                       "Length for FW DLD is : %lx\n", io_buff.InputLength);
-
-       if (io_buff.InputLength > sizeof(struct bcm_firmware_info)) {
-               up(&ad->fw_download_sema);
-               return -EINVAL;
-       }
-
-       fw_info = kmalloc(sizeof(*fw_info), GFP_KERNEL);
-       if (!fw_info) {
-               up(&ad->fw_download_sema);
-               return -ENOMEM;
-       }
-
-       if (copy_from_user(fw_info, io_buff.InputBuffer,
-               io_buff.InputLength)) {
-               up(&ad->fw_download_sema);
-               kfree(fw_info);
-               return -EFAULT;
-       }
-
-       if (!fw_info->pvMappedFirmwareAddress ||
-               (fw_info->u32FirmwareLength == 0)) {
-
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Something else is wrong %lu\n",
-                               fw_info->u32FirmwareLength);
-               up(&ad->fw_download_sema);
-               kfree(fw_info);
-               status = -EINVAL;
-               return status;
-       }
-
-       status = bcm_ioctl_fw_download(ad, fw_info);
-
-       if (status != STATUS_SUCCESS) {
-               if (fw_info->u32StartingAddress == CONFIG_BEGIN_ADDR)
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "IOCTL: Configuration File Upload Failed\n");
-               else
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "IOCTL: Firmware File Upload Failed\n");
-
-               /* up(&ad->fw_download_sema); */
-
-               if (ad->LEDInfo.led_thread_running &
-                       BCM_LED_THREAD_RUNNING_ACTIVELY) {
-                       ad->DriverState = DRIVER_INIT;
-                       ad->LEDInfo.bLedInitDone = false;
-                       wake_up(&ad->LEDInfo.notify_led_event);
-               }
-       }
-
-       if (status != STATUS_SUCCESS)
-               up(&ad->fw_download_sema);
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL,
-               "IOCTL: Firmware File Uploaded\n");
-       kfree(fw_info);
-       return status;
-}
-
-static int bcm_char_ioctl_buffer_download_stop(void __user *argp,
-                                              struct bcm_mini_adapter *ad)
-{
-       INT status;
-       int timeout = 0;
-
-       if (!down_trylock(&ad->fw_download_sema)) {
-               up(&ad->fw_download_sema);
-               return -EINVAL;
-       }
-
-       if (down_trylock(&ad->NVMRdmWrmLock)) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "FW download blocked as EEPROM Read/Write is in progress\n");
-               up(&ad->fw_download_sema);
-               return -EACCES;
-       }
-
-       ad->bBinDownloaded = TRUE;
-       ad->bCfgDownloaded = TRUE;
-       atomic_set(&ad->CurrNumFreeTxDesc, 0);
-       ad->CurrNumRecvDescs = 0;
-       ad->downloadDDR = 0;
-
-       /* setting the Mips to Run */
-       status = run_card_proc(ad);
-
-       if (status) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                       "Firm Download Failed\n");
-               up(&ad->fw_download_sema);
-               up(&ad->NVMRdmWrmLock);
-               return status;
-       }
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
-                       DBG_LVL_ALL, "Firm Download Over...\n");
-
-       mdelay(10);
-
-       /* Wait for MailBox Interrupt */
-       if (StartInterruptUrb((struct bcm_interface_adapter *)ad->pvInterfaceAdapter))
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                       "Unable to send interrupt...\n");
-
-       timeout = 5*HZ;
-       ad->waiting_to_fw_download_done = false;
-       wait_event_timeout(ad->ioctl_fw_dnld_wait_queue,
-                       ad->waiting_to_fw_download_done, timeout);
-       ad->fw_download_process_pid = INVALID_PID;
-       ad->fw_download_done = TRUE;
-       atomic_set(&ad->CurrNumFreeTxDesc, 0);
-       ad->CurrNumRecvDescs = 0;
-       ad->PrevNumRecvDescs = 0;
-       atomic_set(&ad->cntrlpktCnt, 0);
-       ad->LinkUpStatus = 0;
-       ad->LinkStatus = 0;
-
-       if (ad->LEDInfo.led_thread_running &
-               BCM_LED_THREAD_RUNNING_ACTIVELY) {
-               ad->DriverState = FW_DOWNLOAD_DONE;
-               wake_up(&ad->LEDInfo.notify_led_event);
-       }
-
-       if (!timeout)
-               status = -ENODEV;
-
-       up(&ad->fw_download_sema);
-       up(&ad->NVMRdmWrmLock);
-       return status;
-}
-
-static int bcm_char_ioctl_chip_reset(struct bcm_mini_adapter *ad)
-{
-       INT status;
-       INT nvm_access;
-
-       nvm_access = down_trylock(&ad->NVMRdmWrmLock);
-       if (nvm_access) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                       " IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n");
-               return -EACCES;
-       }
-
-       down(&ad->RxAppControlQueuelock);
-       status = reset_card_proc(ad);
-       flushAllAppQ();
-       up(&ad->RxAppControlQueuelock);
-       up(&ad->NVMRdmWrmLock);
-       ResetCounters(ad);
-       return status;
-}
-
-static int bcm_char_ioctl_qos_threshold(ULONG arg,
-                                       struct bcm_mini_adapter *ad)
-{
-       USHORT i;
-
-       for (i = 0; i < NO_OF_QUEUES; i++) {
-               if (get_user(ad->PackInfo[i].uiThreshold,
-                               (unsigned long __user *)arg)) {
-                       return -EFAULT;
-               }
-       }
-       return 0;
-}
-
-static int bcm_char_ioctl_switch_transfer_mode(void __user *argp,
-                                              struct bcm_mini_adapter *ad)
-{
-       UINT data = 0;
-
-       if (copy_from_user(&data, argp, sizeof(UINT)))
-               return -EFAULT;
-
-       if (data) {
-               /* Allow All Packets */
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "IOCTL_BCM_SWITCH_TRANSFER_MODE: ETH_PACKET_TUNNELING_MODE\n");
-                       ad->TransferMode = ETH_PACKET_TUNNELING_MODE;
-       } else {
-               /* Allow IP only Packets */
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "IOCTL_BCM_SWITCH_TRANSFER_MODE: IP_PACKET_ONLY_MODE\n");
-               ad->TransferMode = IP_PACKET_ONLY_MODE;
-       }
-       return STATUS_SUCCESS;
-}
-
-static int bcm_char_ioctl_get_driver_version(void __user *argp)
-{
-       struct bcm_ioctl_buffer io_buff;
-       ulong len;
-
-       /* Copy Ioctl Buffer structure */
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       len = min_t(ulong, io_buff.OutputLength, strlen(DRV_VERSION) + 1);
-
-       if (copy_to_user(io_buff.OutputBuffer, DRV_VERSION, len))
-               return -EFAULT;
-
-       return STATUS_SUCCESS;
-}
-
-static int bcm_char_ioctl_get_current_status(void __user *argp,
-                                            struct bcm_mini_adapter *ad)
-{
-       struct bcm_link_state link_state;
-       struct bcm_ioctl_buffer io_buff;
-
-       /* Copy Ioctl Buffer structure */
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                       "copy_from_user failed..\n");
-               return -EFAULT;
-       }
-
-       if (io_buff.OutputLength != sizeof(link_state))
-               return -EINVAL;
-
-       memset(&link_state, 0, sizeof(link_state));
-       link_state.bIdleMode = ad->IdleMode;
-       link_state.bShutdownMode = ad->bShutStatus;
-       link_state.ucLinkStatus = ad->LinkStatus;
-
-       if (copy_to_user(io_buff.OutputBuffer, &link_state, min_t(size_t,
-               sizeof(link_state), io_buff.OutputLength))) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                       "Copy_to_user Failed..\n");
-               return -EFAULT;
-       }
-       return STATUS_SUCCESS;
-}
-
-
-static int bcm_char_ioctl_set_mac_tracing(void __user *argp,
-                                         struct bcm_mini_adapter *ad)
-{
-       struct bcm_ioctl_buffer io_buff;
-       UINT tracing_flag;
-
-       /* copy ioctl Buffer structure */
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (copy_from_user(&tracing_flag, io_buff.InputBuffer, sizeof(UINT)))
-               return -EFAULT;
-
-       if (tracing_flag)
-               ad->pTarangs->MacTracingEnabled = TRUE;
-       else
-               ad->pTarangs->MacTracingEnabled = false;
-
-       return STATUS_SUCCESS;
-}
-
-static int bcm_char_ioctl_get_dsx_indication(void __user *argp,
-                                            struct bcm_mini_adapter *ad)
-{
-       struct bcm_ioctl_buffer io_buff;
-       ULONG sf_id = 0;
-
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (io_buff.OutputLength < sizeof(struct bcm_add_indication_alt)) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                       "Mismatch req: %lx needed is =0x%zx!!!",
-                       io_buff.OutputLength,
-                       sizeof(struct bcm_add_indication_alt));
-               return -EINVAL;
-       }
-
-       if (copy_from_user(&sf_id, io_buff.InputBuffer, sizeof(sf_id)))
-               return -EFAULT;
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-               "Get DSX Data SF ID is =%lx\n", sf_id);
-       get_dsx_sf_data_to_application(ad, sf_id, io_buff.OutputBuffer);
-       return STATUS_SUCCESS;
-}
-
-static int bcm_char_ioctl_get_host_mibs(void __user *argp,
-                                       struct bcm_mini_adapter *ad,
-                                       struct bcm_tarang_data *tarang)
-{
-       struct bcm_ioctl_buffer io_buff;
-       INT status = STATUS_FAILURE;
-       PVOID temp_buff;
-
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (io_buff.OutputLength != sizeof(struct bcm_host_stats_mibs)) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                       "Length Check failed %lu %zd\n", io_buff.OutputLength,
-                       sizeof(struct bcm_host_stats_mibs));
-               return -EINVAL;
-       }
-
-       /* FIXME: HOST_STATS are too big for kmalloc (122048)! */
-       temp_buff = kzalloc(sizeof(struct bcm_host_stats_mibs), GFP_KERNEL);
-       if (!temp_buff)
-               return STATUS_FAILURE;
-
-       status = ProcessGetHostMibs(ad, temp_buff);
-       GetDroppedAppCntrlPktMibs(temp_buff, tarang);
-
-       if (status != STATUS_FAILURE) {
-               if (copy_to_user(io_buff.OutputBuffer, temp_buff,
-                       sizeof(struct bcm_host_stats_mibs))) {
-                       kfree(temp_buff);
-                       return -EFAULT;
-               }
-       }
-
-       kfree(temp_buff);
-       return status;
-}
-
-static int bcm_char_ioctl_bulk_wrm(void __user *argp,
-                                  struct bcm_mini_adapter *ad, UINT cmd)
-{
-       struct bcm_bulk_wrm_buffer *bulk_buff;
-       struct bcm_ioctl_buffer io_buff;
-       UINT tmp = 0;
-       INT status = STATUS_FAILURE;
-       PCHAR buff = NULL;
-
-       if ((ad->IdleMode == TRUE) ||
-               (ad->bShutStatus == TRUE) ||
-               (ad->bPreparingForLowPowerMode == TRUE)) {
-
-               BCM_DEBUG_PRINT (ad, DBG_TYPE_PRINTK, 0, 0,
-                       "Device in Idle/Shutdown Mode, Blocking Wrms\n");
-               return -EACCES;
-       }
-
-       /* Copy Ioctl Buffer structure */
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (io_buff.InputLength < sizeof(ULONG) * 2)
-               return -EINVAL;
-
-       buff = memdup_user(io_buff.InputBuffer,
-                              io_buff.InputLength);
-       if (IS_ERR(buff))
-               return PTR_ERR(buff);
-
-       bulk_buff = (struct bcm_bulk_wrm_buffer *)buff;
-
-       if (((ULONG)bulk_buff->Register & 0x0F000000) != 0x0F000000 ||
-               ((ULONG)bulk_buff->Register & 0x3)) {
-               BCM_DEBUG_PRINT (ad, DBG_TYPE_PRINTK, 0, 0,
-                       "WRM Done On invalid Address : %x Access Denied.\n",
-                       (int)bulk_buff->Register);
-               kfree(buff);
-               return -EINVAL;
-       }
-
-       tmp = bulk_buff->Register & EEPROM_REJECT_MASK;
-       if (!((ad->pstargetparams->m_u32Customize)&VSG_MODE) &&
-               ((tmp == EEPROM_REJECT_REG_1) ||
-                       (tmp == EEPROM_REJECT_REG_2) ||
-                       (tmp == EEPROM_REJECT_REG_3) ||
-                       (tmp == EEPROM_REJECT_REG_4)) &&
-               (cmd == IOCTL_BCM_REGISTER_WRITE)) {
-
-               kfree(buff);
-               BCM_DEBUG_PRINT (ad, DBG_TYPE_PRINTK, 0, 0,
-                       "EEPROM Access Denied, not in VSG Mode\n");
-               return -EFAULT;
-       }
-
-       if (bulk_buff->SwapEndian == false)
-               status = wrmWithLock(ad, (UINT)bulk_buff->Register,
-                       (PCHAR)bulk_buff->Values,
-                       io_buff.InputLength - 2*sizeof(ULONG));
-       else
-               status = wrmaltWithLock(ad, (UINT)bulk_buff->Register,
-                       (PUINT)bulk_buff->Values,
-                       io_buff.InputLength - 2*sizeof(ULONG));
-
-       if (status != STATUS_SUCCESS)
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, "WRM Failed\n");
-
-       kfree(buff);
-       return status;
-}
-
-static int bcm_char_ioctl_get_nvm_size(void __user *argp,
-                                      struct bcm_mini_adapter *ad)
-{
-       struct bcm_ioctl_buffer io_buff;
-
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (ad->eNVMType == NVM_EEPROM || ad->eNVMType == NVM_FLASH) {
-               if (copy_to_user(io_buff.OutputBuffer, &ad->uiNVMDSDSize,
-                       sizeof(UINT)))
-                       return -EFAULT;
-       }
-
-       return STATUS_SUCCESS;
-}
-
-static int bcm_char_ioctl_cal_init(void __user *argp,
-                                  struct bcm_mini_adapter *ad)
-{
-       struct bcm_ioctl_buffer io_buff;
-       UINT sector_size = 0;
-       INT status = STATUS_FAILURE;
-
-       if (ad->eNVMType == NVM_FLASH) {
-               if (copy_from_user(&io_buff, argp,
-                       sizeof(struct bcm_ioctl_buffer)))
-                       return -EFAULT;
-
-               if (copy_from_user(&sector_size, io_buff.InputBuffer,
-                       sizeof(UINT)))
-                       return -EFAULT;
-
-               if ((sector_size < MIN_SECTOR_SIZE) ||
-                       (sector_size > MAX_SECTOR_SIZE)) {
-                       if (copy_to_user(io_buff.OutputBuffer,
-                               &ad->uiSectorSize, sizeof(UINT)))
-                               return -EFAULT;
-               } else {
-                       if (IsFlash2x(ad)) {
-                               if (copy_to_user(io_buff.OutputBuffer,
-                                       &ad->uiSectorSize, sizeof(UINT)))
-                                       return -EFAULT;
-                       } else {
-                               if ((TRUE == ad->bShutStatus) ||
-                                       (TRUE == ad->IdleMode)) {
-                                       BCM_DEBUG_PRINT(ad,
-                                               DBG_TYPE_PRINTK, 0, 0,
-                                               "Device is in Idle/Shutdown Mode\n");
-                                       return -EACCES;
-                               }
-
-                               ad->uiSectorSize = sector_size;
-                               BcmUpdateSectorSize(ad,
-                                       ad->uiSectorSize);
-                       }
-               }
-               status = STATUS_SUCCESS;
-       } else {
-               status = STATUS_FAILURE;
-       }
-       return status;
-}
-
-static int bcm_char_ioctl_set_debug(void __user *argp,
-                                   struct bcm_mini_adapter *ad)
-{
-#ifdef DEBUG
-       struct bcm_ioctl_buffer io_buff;
-       struct bcm_user_debug_state user_debug_state;
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-               "In SET_DEBUG ioctl\n");
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (copy_from_user(&user_debug_state, io_buff.InputBuffer,
-               sizeof(struct bcm_user_debug_state)))
-               return -EFAULT;
-
-       BCM_DEBUG_PRINT (ad, DBG_TYPE_PRINTK, 0, 0,
-                       "IOCTL_BCM_SET_DEBUG: OnOff=%d Type = 0x%x ",
-                       user_debug_state.OnOff, user_debug_state.Type);
-       /* user_debug_state.Subtype <<= 1; */
-       user_debug_state.Subtype = 1 << user_debug_state.Subtype;
-       BCM_DEBUG_PRINT (ad, DBG_TYPE_PRINTK, 0, 0,
-               "actual Subtype=0x%x\n", user_debug_state.Subtype);
-
-       /* Update new 'DebugState' in the ad */
-       ad->stDebugState.type |= user_debug_state.Type;
-       /* Subtype: A bitmap of 32 bits for Subtype per Type.
-        * Valid indexes in 'subtype' array: 1,2,4,8
-        * corresponding to valid Type values. Hence we can use the 'Type' field
-        * as the index value, ignoring the array entries 0,3,5,6,7 !
-        */
-       if (user_debug_state.OnOff)
-               ad->stDebugState.subtype[user_debug_state.Type] |=
-                       user_debug_state.Subtype;
-       else
-               ad->stDebugState.subtype[user_debug_state.Type] &=
-                       ~user_debug_state.Subtype;
-
-       BCM_SHOW_DEBUG_BITMAP(ad);
-#endif
-       return STATUS_SUCCESS;
-}
-
-static int bcm_char_ioctl_nvm_rw(void __user *argp,
-                                struct bcm_mini_adapter *ad, UINT cmd)
-{
-       struct bcm_nvm_readwrite nvm_rw;
-       struct timeval tv0, tv1;
-       struct bcm_ioctl_buffer io_buff;
-       PUCHAR read_data = NULL;
-       INT status = STATUS_FAILURE;
-
-       memset(&tv0, 0, sizeof(struct timeval));
-       memset(&tv1, 0, sizeof(struct timeval));
-       if ((ad->eNVMType == NVM_FLASH) &&
-               (ad->uiFlashLayoutMajorVersion == 0)) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                       "The Flash Control Section is Corrupted. Hence Rejection on NVM Read/Write\n");
-               return -EFAULT;
-       }
-
-       if (IsFlash2x(ad)) {
-               if ((ad->eActiveDSD != DSD0) &&
-                       (ad->eActiveDSD != DSD1) &&
-                       (ad->eActiveDSD != DSD2)) {
-
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "No DSD is active..hence NVM Command is blocked");
-                       return STATUS_FAILURE;
-               }
-       }
-
-       /* Copy Ioctl Buffer structure */
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (copy_from_user(&nvm_rw,
-                               (IOCTL_BCM_NVM_READ == cmd) ?
-                               io_buff.OutputBuffer : io_buff.InputBuffer,
-                               sizeof(struct bcm_nvm_readwrite)))
-               return -EFAULT;
-
-       /*
-        * Deny the access if the offset crosses the cal area limit.
-        */
-       if (nvm_rw.uiNumBytes > ad->uiNVMDSDSize)
-               return STATUS_FAILURE;
-
-       if (nvm_rw.uiOffset >
-               ad->uiNVMDSDSize - nvm_rw.uiNumBytes)
-               return STATUS_FAILURE;
-
-       read_data = memdup_user(nvm_rw.pBuffer,
-                               nvm_rw.uiNumBytes);
-       if (IS_ERR(read_data))
-               return PTR_ERR(read_data);
-
-       do_gettimeofday(&tv0);
-       if (IOCTL_BCM_NVM_READ == cmd) {
-               int ret = bcm_handle_nvm_read_cmd(ad, read_data,
-                               &nvm_rw);
-               if (ret != STATUS_SUCCESS)
-                       return ret;
-       } else {
-               down(&ad->NVMRdmWrmLock);
-
-               if ((ad->IdleMode == TRUE) ||
-                       (ad->bShutStatus == TRUE) ||
-                       (ad->bPreparingForLowPowerMode == TRUE)) {
-
-                       BCM_DEBUG_PRINT(ad,
-                               DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "Device is in Idle/Shutdown Mode\n");
-                       up(&ad->NVMRdmWrmLock);
-                       kfree(read_data);
-                       return -EACCES;
-               }
-
-               ad->bHeaderChangeAllowed = TRUE;
-               if (IsFlash2x(ad)) {
-                       int ret = handle_flash2x_adapter(ad,
-                                                       read_data,
-                                                       &nvm_rw);
-                       if (ret != STATUS_SUCCESS)
-                               return ret;
-               }
-
-               status = BeceemNVMWrite(ad, (PUINT)read_data,
-                       nvm_rw.uiOffset, nvm_rw.uiNumBytes,
-                       nvm_rw.bVerify);
-               if (IsFlash2x(ad))
-                       BcmFlash2xWriteSig(ad, ad->eActiveDSD);
-
-               ad->bHeaderChangeAllowed = false;
-
-               up(&ad->NVMRdmWrmLock);
-
-               if (status != STATUS_SUCCESS) {
-                       kfree(read_data);
-                       return status;
-               }
-       }
-
-       do_gettimeofday(&tv1);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-               " timetaken by Write/read :%ld msec\n",
-               (tv1.tv_sec - tv0.tv_sec)*1000 +
-               (tv1.tv_usec - tv0.tv_usec)/1000);
-
-       kfree(read_data);
-       return STATUS_SUCCESS;
-}
-
-static int bcm_char_ioctl_flash2x_section_read(void __user *argp,
-       struct bcm_mini_adapter *ad)
-{
-       struct bcm_flash2x_readwrite flash_2x_read = {0};
-       struct bcm_ioctl_buffer io_buff;
-       PUCHAR read_buff = NULL;
-       UINT nob = 0;
-       UINT buff_size = 0;
-       UINT read_bytes = 0;
-       UINT read_offset = 0;
-       INT status = STATUS_FAILURE;
-       void __user *OutPutBuff;
-
-       if (IsFlash2x(ad) != TRUE)      {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                       "Flash Does not have 2.x map");
-               return -EINVAL;
-       }
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
-               DBG_LVL_ALL, "IOCTL_BCM_FLASH2X_SECTION_READ Called");
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       /* Reading FLASH 2.x READ structure */
-       if (copy_from_user(&flash_2x_read, io_buff.InputBuffer,
-               sizeof(struct bcm_flash2x_readwrite)))
-               return -EFAULT;
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "\nflash_2x_read.Section :%x",
-                       flash_2x_read.Section);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "\nflash_2x_read.offset :%x",
-                       flash_2x_read.offset);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "\nflash_2x_read.numOfBytes :%x",
-                       flash_2x_read.numOfBytes);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "\nflash_2x_read.bVerify :%x\n",
-                       flash_2x_read.bVerify);
-
-       /* This was internal to driver for raw read.
-        * now it has ben exposed to user space app.
-        */
-       if (validateFlash2xReadWrite(ad, &flash_2x_read) == false)
-               return STATUS_FAILURE;
-
-       nob = flash_2x_read.numOfBytes;
-       if (nob > ad->uiSectorSize)
-               buff_size = ad->uiSectorSize;
-       else
-               buff_size = nob;
-
-       read_offset = flash_2x_read.offset;
-       OutPutBuff = io_buff.OutputBuffer;
-       read_buff = kzalloc(buff_size , GFP_KERNEL);
-
-       if (read_buff == NULL) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Memory allocation failed for Flash 2.x Read Structure");
-               return -ENOMEM;
-       }
-       down(&ad->NVMRdmWrmLock);
-
-       if ((ad->IdleMode == TRUE) ||
-               (ad->bShutStatus == TRUE) ||
-               (ad->bPreparingForLowPowerMode == TRUE)) {
-
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG,
-                               DBG_LVL_ALL,
-                               "Device is in Idle/Shutdown Mode\n");
-               up(&ad->NVMRdmWrmLock);
-               kfree(read_buff);
-               return -EACCES;
-       }
-
-       while (nob) {
-               if (nob > ad->uiSectorSize)
-                       read_bytes = ad->uiSectorSize;
-               else
-                       read_bytes = nob;
-
-               /* Reading the data from Flash 2.x */
-               status = BcmFlash2xBulkRead(ad, (PUINT)read_buff,
-                       flash_2x_read.Section, read_offset, read_bytes);
-               if (status) {
-                       BCM_DEBUG_PRINT(ad,
-                               DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "Flash 2x read err with status :%d",
-                               status);
-                       break;
-               }
-
-               BCM_DEBUG_PRINT_BUFFER(ad, DBG_TYPE_OTHERS, OSAL_DBG,
-                       DBG_LVL_ALL, read_buff, read_bytes);
-
-               status = copy_to_user(OutPutBuff, read_buff, read_bytes);
-               if (status) {
-                       BCM_DEBUG_PRINT(ad,
-                               DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "Copy to use failed with status :%d", status);
-                       up(&ad->NVMRdmWrmLock);
-                       kfree(read_buff);
-                       return -EFAULT;
-               }
-               nob = nob - read_bytes;
-               if (nob) {
-                       read_offset = read_offset + read_bytes;
-                       OutPutBuff = OutPutBuff + read_bytes;
-               }
-       }
-
-       up(&ad->NVMRdmWrmLock);
-       kfree(read_buff);
-       return status;
-}
-
-static int bcm_char_ioctl_flash2x_section_write(void __user *argp,
-       struct bcm_mini_adapter *ad)
-{
-       struct bcm_flash2x_readwrite sFlash2xWrite = {0};
-       struct bcm_ioctl_buffer io_buff;
-       PUCHAR write_buff;
-       void __user *input_addr;
-       UINT nob = 0;
-       UINT buff_size = 0;
-       UINT write_off = 0;
-       UINT write_bytes = 0;
-       INT status = STATUS_FAILURE;
-
-       if (IsFlash2x(ad) != TRUE) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                       "Flash Does not have 2.x map");
-               return -EINVAL;
-       }
-
-       /* First make this False so that we can enable the Sector
-        * Permission Check in BeceemFlashBulkWrite
-        */
-       ad->bAllDSDWriteAllow = false;
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-               "IOCTL_BCM_FLASH2X_SECTION_WRITE Called");
-
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       /* Reading FLASH 2.x READ structure */
-       if (copy_from_user(&sFlash2xWrite, io_buff.InputBuffer,
-               sizeof(struct bcm_flash2x_readwrite)))
-               return -EFAULT;
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-               "\nsFlash2xWrite.Section :%x", sFlash2xWrite.Section);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-               "\nsFlash2xWrite.offset :%d", sFlash2xWrite.offset);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-               "\nsFlash2xWrite.numOfBytes :%x", sFlash2xWrite.numOfBytes);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-               "\nsFlash2xWrite.bVerify :%x\n", sFlash2xWrite.bVerify);
-
-       if ((sFlash2xWrite.Section != VSA0) && (sFlash2xWrite.Section != VSA1)
-               && (sFlash2xWrite.Section != VSA2)) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "Only VSA write is allowed");
-               return -EINVAL;
-       }
-
-       if (validateFlash2xReadWrite(ad, &sFlash2xWrite) == false)
-               return STATUS_FAILURE;
-
-       input_addr = sFlash2xWrite.pDataBuff;
-       write_off = sFlash2xWrite.offset;
-       nob = sFlash2xWrite.numOfBytes;
-
-       if (nob > ad->uiSectorSize)
-               buff_size = ad->uiSectorSize;
-       else
-               buff_size = nob;
-
-       write_buff = kmalloc(buff_size, GFP_KERNEL);
-
-       if (write_buff == NULL)
-               return -ENOMEM;
-
-       /* extracting the remainder of the given offset. */
-       write_bytes = ad->uiSectorSize;
-       if (write_off % ad->uiSectorSize) {
-               write_bytes = ad->uiSectorSize -
-                       (write_off % ad->uiSectorSize);
-       }
-
-       if (nob < write_bytes)
-               write_bytes = nob;
-
-       down(&ad->NVMRdmWrmLock);
-
-       if ((ad->IdleMode == TRUE) ||
-               (ad->bShutStatus == TRUE) ||
-               (ad->bPreparingForLowPowerMode == TRUE)) {
-
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "Device is in Idle/Shutdown Mode\n");
-               up(&ad->NVMRdmWrmLock);
-               kfree(write_buff);
-               return -EACCES;
-       }
-
-       BcmFlash2xCorruptSig(ad, sFlash2xWrite.Section);
-       do {
-               status = copy_from_user(write_buff, input_addr, write_bytes);
-               if (status) {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Copy to user failed with status :%d", status);
-                       up(&ad->NVMRdmWrmLock);
-                       kfree(write_buff);
-                       return -EFAULT;
-               }
-               BCM_DEBUG_PRINT_BUFFER(ad, DBG_TYPE_OTHERS,
-                       OSAL_DBG, DBG_LVL_ALL, write_buff, write_bytes);
-
-               /* Writing the data from Flash 2.x */
-               status = BcmFlash2xBulkWrite(ad, (PUINT)write_buff,
-                                            sFlash2xWrite.Section,
-                                            write_off,
-                                            write_bytes,
-                                            sFlash2xWrite.bVerify);
-
-               if (status) {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Flash 2x read err with status :%d", status);
-                       break;
-               }
-
-               nob = nob - write_bytes;
-               if (nob) {
-                       write_off = write_off + write_bytes;
-                       input_addr = input_addr + write_bytes;
-                       if (nob > ad->uiSectorSize)
-                               write_bytes = ad->uiSectorSize;
-                       else
-                               write_bytes = nob;
-               }
-       } while (nob > 0);
-
-       BcmFlash2xWriteSig(ad, sFlash2xWrite.Section);
-       up(&ad->NVMRdmWrmLock);
-       kfree(write_buff);
-       return status;
-}
-
-static int bcm_char_ioctl_flash2x_section_bitmap(void __user *argp,
-       struct bcm_mini_adapter *ad)
-{
-       struct bcm_flash2x_bitmap *flash_2x_bit_map;
-       struct bcm_ioctl_buffer io_buff;
-
-BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-       "IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP Called");
-
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (io_buff.OutputLength != sizeof(struct bcm_flash2x_bitmap))
-               return -EINVAL;
-
-       flash_2x_bit_map = kzalloc(sizeof(struct bcm_flash2x_bitmap),
-                       GFP_KERNEL);
-
-       if (flash_2x_bit_map == NULL) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                       "Memory is not available");
-               return -ENOMEM;
-       }
-
-       /* Reading the Flash Sectio Bit map */
-       down(&ad->NVMRdmWrmLock);
-
-       if ((ad->IdleMode == TRUE) ||
-               (ad->bShutStatus == TRUE) ||
-               (ad->bPreparingForLowPowerMode == TRUE)) {
-
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "Device is in Idle/Shutdown Mode\n");
-               up(&ad->NVMRdmWrmLock);
-               kfree(flash_2x_bit_map);
-               return -EACCES;
-       }
-
-       BcmGetFlash2xSectionalBitMap(ad, flash_2x_bit_map);
-       up(&ad->NVMRdmWrmLock);
-       if (copy_to_user(io_buff.OutputBuffer, flash_2x_bit_map,
-               sizeof(struct bcm_flash2x_bitmap))) {
-               kfree(flash_2x_bit_map);
-               return -EFAULT;
-       }
-
-       kfree(flash_2x_bit_map);
-       return STATUS_FAILURE;
-}
-
-static int bcm_char_ioctl_set_active_section(void __user *argp,
-                                            struct bcm_mini_adapter *ad)
-{
-       enum bcm_flash2x_section_val flash_2x_section_val = 0;
-       INT status = STATUS_FAILURE;
-       struct bcm_ioctl_buffer io_buff;
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "IOCTL_BCM_SET_ACTIVE_SECTION Called");
-
-       if (IsFlash2x(ad) != TRUE) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Flash Does not have 2.x map");
-               return -EINVAL;
-       }
-
-       status = copy_from_user(&io_buff, argp,
-                               sizeof(struct bcm_ioctl_buffer));
-       if (status) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Copy of IOCTL BUFFER failed");
-               return -EFAULT;
-       }
-
-       status = copy_from_user(&flash_2x_section_val,
-                               io_buff.InputBuffer, sizeof(INT));
-       if (status) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                       "Copy of flash section val failed");
-               return -EFAULT;
-       }
-
-       down(&ad->NVMRdmWrmLock);
-
-       if ((ad->IdleMode == TRUE) ||
-               (ad->bShutStatus == TRUE) ||
-               (ad->bPreparingForLowPowerMode == TRUE)) {
-
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "Device is in Idle/Shutdown Mode\n");
-               up(&ad->NVMRdmWrmLock);
-               return -EACCES;
-       }
-
-       status = BcmSetActiveSection(ad, flash_2x_section_val);
-       if (status)
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Failed to make it's priority Highest. status %d",
-                               status);
-
-       up(&ad->NVMRdmWrmLock);
-
-       return status;
-}
-
-static int bcm_char_ioctl_copy_section(void __user *argp,
-                                      struct bcm_mini_adapter *ad)
-{
-       struct bcm_flash2x_copy_section copy_sect_strut = {0};
-       struct bcm_ioctl_buffer io_buff;
-       INT status = STATUS_SUCCESS;
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "IOCTL_BCM_COPY_SECTION  Called");
-
-       ad->bAllDSDWriteAllow = false;
-       if (IsFlash2x(ad) != TRUE) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Flash Does not have 2.x map");
-               return -EINVAL;
-       }
-
-       status = copy_from_user(&io_buff, argp,
-                               sizeof(struct bcm_ioctl_buffer));
-       if (status) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Copy of IOCTL BUFFER failed status :%d",
-                               status);
-               return -EFAULT;
-       }
-
-       status = copy_from_user(&copy_sect_strut, io_buff.InputBuffer,
-                               sizeof(struct bcm_flash2x_copy_section));
-       if (status) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Copy of Copy_Section_Struct failed with status :%d",
-                               status);
-               return -EFAULT;
-       }
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "Source SEction :%x", copy_sect_strut.SrcSection);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "Destination SEction :%x", copy_sect_strut.DstSection);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "offset :%x", copy_sect_strut.offset);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "nob :%x", copy_sect_strut.numOfBytes);
-
-       if (IsSectionExistInFlash(ad, copy_sect_strut.SrcSection) == false) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Source Section<%x> does not exist in Flash ",
-                               copy_sect_strut.SrcSection);
-               return -EINVAL;
-       }
-
-       if (IsSectionExistInFlash(ad, copy_sect_strut.DstSection) == false) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Destinatio Section<%x> does not exist in Flash ",
-                               copy_sect_strut.DstSection);
-               return -EINVAL;
-       }
-
-       if (copy_sect_strut.SrcSection == copy_sect_strut.DstSection) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "Source and Destination section should be different");
-               return -EINVAL;
-       }
-
-       down(&ad->NVMRdmWrmLock);
-
-       if ((ad->IdleMode == TRUE) ||
-               (ad->bShutStatus == TRUE) ||
-               (ad->bPreparingForLowPowerMode == TRUE)) {
-
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "Device is in Idle/Shutdown Mode\n");
-               up(&ad->NVMRdmWrmLock);
-               return -EACCES;
-       }
-
-       if (copy_sect_strut.SrcSection == ISO_IMAGE1 ||
-               copy_sect_strut.SrcSection == ISO_IMAGE2) {
-               if (IsNonCDLessDevice(ad)) {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                                       "Device is Non-CDLess hence won't have ISO !!");
-                       status = -EINVAL;
-               } else if (copy_sect_strut.numOfBytes == 0) {
-                       status = BcmCopyISO(ad, copy_sect_strut);
-               } else {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                                       "Partial Copy of ISO section is not Allowed..");
-                       status = STATUS_FAILURE;
-               }
-               up(&ad->NVMRdmWrmLock);
-               return status;
-       }
-
-       status = BcmCopySection(ad, copy_sect_strut.SrcSection,
-                               copy_sect_strut.DstSection,
-                               copy_sect_strut.offset,
-                               copy_sect_strut.numOfBytes);
-       up(&ad->NVMRdmWrmLock);
-       return status;
-}
-
-static int bcm_char_ioctl_get_flash_cs_info(void __user *argp,
-                                           struct bcm_mini_adapter *ad)
-{
-       struct bcm_ioctl_buffer io_buff;
-       INT status = STATUS_SUCCESS;
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       " IOCTL_BCM_GET_FLASH_CS_INFO Called");
-
-       status = copy_from_user(&io_buff, argp,
-                       sizeof(struct bcm_ioctl_buffer));
-       if (status) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Copy of IOCTL BUFFER failed");
-               return -EFAULT;
-       }
-
-       if (ad->eNVMType != NVM_FLASH) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Connected device does not have flash");
-               return -EINVAL;
-       }
-
-       if (IsFlash2x(ad) == TRUE) {
-               if (io_buff.OutputLength < sizeof(struct bcm_flash2x_cs_info))
-                       return -EINVAL;
-
-               if (copy_to_user(io_buff.OutputBuffer,
-                                ad->psFlash2xCSInfo,
-                                sizeof(struct bcm_flash2x_cs_info)))
-                       return -EFAULT;
-       } else {
-               if (io_buff.OutputLength < sizeof(struct bcm_flash_cs_info))
-                       return -EINVAL;
-
-               if (copy_to_user(io_buff.OutputBuffer, ad->psFlashCSInfo,
-                                sizeof(struct bcm_flash_cs_info)))
-                       return -EFAULT;
-       }
-       return status;
-}
-
-static int bcm_char_ioctl_select_dsd(void __user *argp,
-                                    struct bcm_mini_adapter *ad)
-{
-       struct bcm_ioctl_buffer io_buff;
-       INT status = STATUS_FAILURE;
-       UINT sect_offset = 0;
-       enum bcm_flash2x_section_val flash_2x_section_val;
-
-       flash_2x_section_val = NO_SECTION_VAL;
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "IOCTL_BCM_SELECT_DSD Called");
-
-       if (IsFlash2x(ad) != TRUE) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Flash Does not have 2.x map");
-               return -EINVAL;
-       }
-
-       status = copy_from_user(&io_buff, argp,
-                               sizeof(struct bcm_ioctl_buffer));
-       if (status) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Copy of IOCTL BUFFER failed");
-               return -EFAULT;
-       }
-       status = copy_from_user(&flash_2x_section_val, io_buff.InputBuffer,
-               sizeof(INT));
-       if (status) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Copy of flash section val failed");
-               return -EFAULT;
-       }
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "Read Section :%d", flash_2x_section_val);
-       if ((flash_2x_section_val != DSD0) &&
-               (flash_2x_section_val != DSD1) &&
-               (flash_2x_section_val != DSD2)) {
-
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Passed section<%x> is not DSD section",
-                               flash_2x_section_val);
-               return STATUS_FAILURE;
-       }
-
-       sect_offset = BcmGetSectionValStartOffset(ad, flash_2x_section_val);
-       if (sect_offset == INVALID_OFFSET) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Provided Section val <%d> does not exist in Flash 2.x",
-                               flash_2x_section_val);
-               return -EINVAL;
-       }
-
-       ad->bAllDSDWriteAllow = TRUE;
-       ad->ulFlashCalStart = sect_offset;
-       ad->eActiveDSD = flash_2x_section_val;
-
-       return STATUS_SUCCESS;
-}
-
-static int bcm_char_ioctl_nvm_raw_read(void __user *argp,
-                                      struct bcm_mini_adapter *ad)
-{
-       struct bcm_nvm_readwrite nvm_read;
-       struct bcm_ioctl_buffer io_buff;
-       unsigned int nob;
-       INT buff_size;
-       INT read_offset = 0;
-       UINT read_bytes = 0;
-       PUCHAR read_buff;
-       void __user *OutPutBuff;
-       INT status = STATUS_FAILURE;
-
-       if (ad->eNVMType != NVM_FLASH) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "NVM TYPE is not Flash");
-               return -EINVAL;
-       }
-
-       /* Copy Ioctl Buffer structure */
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "copy_from_user 1 failed\n");
-               return -EFAULT;
-       }
-
-       if (copy_from_user(&nvm_read, io_buff.OutputBuffer,
-               sizeof(struct bcm_nvm_readwrite)))
-               return -EFAULT;
-
-       nob = nvm_read.uiNumBytes;
-       /* In Raw-Read max Buff size : 64MB */
-
-       if (nob > DEFAULT_BUFF_SIZE)
-               buff_size = DEFAULT_BUFF_SIZE;
-       else
-               buff_size = nob;
-
-       read_offset = nvm_read.uiOffset;
-       OutPutBuff = nvm_read.pBuffer;
-
-       read_buff = kzalloc(buff_size , GFP_KERNEL);
-       if (read_buff == NULL) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                               "Memory allocation failed for Flash 2.x Read Structure");
-               return -ENOMEM;
-       }
-       down(&ad->NVMRdmWrmLock);
-
-       if ((ad->IdleMode == TRUE) ||
-               (ad->bShutStatus == TRUE) ||
-               (ad->bPreparingForLowPowerMode == TRUE)) {
-
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "Device is in Idle/Shutdown Mode\n");
-               kfree(read_buff);
-               up(&ad->NVMRdmWrmLock);
-               return -EACCES;
-       }
-
-       ad->bFlashRawRead = TRUE;
-
-       while (nob) {
-               if (nob > DEFAULT_BUFF_SIZE)
-                       read_bytes = DEFAULT_BUFF_SIZE;
-               else
-                       read_bytes = nob;
-
-               /* Reading the data from Flash 2.x */
-               status = BeceemNVMRead(ad, (PUINT)read_buff,
-                       read_offset, read_bytes);
-               if (status) {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                                       "Flash 2x read err with status :%d",
-                                       status);
-                       break;
-               }
-
-               BCM_DEBUG_PRINT_BUFFER(ad, DBG_TYPE_OTHERS, OSAL_DBG,
-                                      DBG_LVL_ALL, read_buff, read_bytes);
-
-               status = copy_to_user(OutPutBuff, read_buff, read_bytes);
-               if (status) {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0,
-                                       "Copy to use failed with status :%d",
-                                       status);
-                       up(&ad->NVMRdmWrmLock);
-                       kfree(read_buff);
-                       return -EFAULT;
-               }
-               nob = nob - read_bytes;
-               if (nob) {
-                       read_offset = read_offset + read_bytes;
-                       OutPutBuff = OutPutBuff + read_bytes;
-               }
-       }
-       ad->bFlashRawRead = false;
-       up(&ad->NVMRdmWrmLock);
-       kfree(read_buff);
-       return status;
-}
-
-static int bcm_char_ioctl_cntrlmsg_mask(void __user *argp,
-                                       struct bcm_mini_adapter *ad,
-                                       struct bcm_tarang_data *tarang)
-{
-       struct bcm_ioctl_buffer io_buff;
-       INT status = STATUS_FAILURE;
-       ULONG rx_cntrl_msg_bit_mask = 0;
-
-       /* Copy Ioctl Buffer structure */
-       status = copy_from_user(&io_buff, argp,
-                       sizeof(struct bcm_ioctl_buffer));
-       if (status) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "copy of Ioctl buffer is failed from user space");
-               return -EFAULT;
-       }
-
-       if (io_buff.InputLength != sizeof(unsigned long))
-               return -EINVAL;
-
-       status = copy_from_user(&rx_cntrl_msg_bit_mask, io_buff.InputBuffer,
-                               io_buff.InputLength);
-       if (status) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "copy of control bit mask failed from user space");
-               return -EFAULT;
-       }
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "\n Got user defined cntrl msg bit mask :%lx",
-                       rx_cntrl_msg_bit_mask);
-       tarang->RxCntrlMsgBitMask = rx_cntrl_msg_bit_mask;
-
-       return status;
-}
-
-static int bcm_char_ioctl_get_device_driver_info(void __user *argp,
-       struct bcm_mini_adapter *ad)
-{
-       struct bcm_driver_info dev_info;
-       struct bcm_ioctl_buffer io_buff;
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "Called IOCTL_BCM_GET_DEVICE_DRIVER_INFO\n");
-
-       memset(&dev_info, 0, sizeof(dev_info));
-       dev_info.MaxRDMBufferSize = BUFFER_4K;
-       dev_info.u32DSDStartOffset = EEPROM_CALPARAM_START;
-       dev_info.u32RxAlignmentCorrection = 0;
-       dev_info.u32NVMType = ad->eNVMType;
-       dev_info.u32InterfaceType = BCM_USB;
-
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (io_buff.OutputLength < sizeof(dev_info))
-               return -EINVAL;
-
-       if (copy_to_user(io_buff.OutputBuffer, &dev_info, sizeof(dev_info)))
-               return -EFAULT;
-
-       return STATUS_SUCCESS;
-}
-
-static int bcm_char_ioctl_time_since_net_entry(void __user *argp,
-       struct bcm_mini_adapter *ad)
-{
-       struct bcm_time_elapsed time_elapsed_since_net_entry = {0};
-       struct bcm_ioctl_buffer io_buff;
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "IOCTL_BCM_TIME_SINCE_NET_ENTRY called");
-
-       if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer)))
-               return -EFAULT;
-
-       if (io_buff.OutputLength < sizeof(struct bcm_time_elapsed))
-               return -EINVAL;
-
-       time_elapsed_since_net_entry.ul64TimeElapsedSinceNetEntry =
-               get_seconds() - ad->liTimeSinceLastNetEntry;
-
-       if (copy_to_user(io_buff.OutputBuffer, &time_elapsed_since_net_entry,
-                        sizeof(struct bcm_time_elapsed)))
-               return -EFAULT;
-
-       return STATUS_SUCCESS;
-}
-
-
-static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
-{
-       struct bcm_tarang_data *tarang = filp->private_data;
-       void __user *argp = (void __user *)arg;
-       struct bcm_mini_adapter *ad = tarang->Adapter;
-       INT status = STATUS_FAILURE;
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                       "Parameters Passed to control IOCTL cmd=0x%X arg=0x%lX",
-                       cmd, arg);
-
-       if (_IOC_TYPE(cmd) != BCM_IOCTL)
-               return -EFAULT;
-       if (_IOC_DIR(cmd) & _IOC_READ)
-               status = !access_ok(VERIFY_WRITE, argp, _IOC_SIZE(cmd));
-       else if (_IOC_DIR(cmd) & _IOC_WRITE)
-               status = !access_ok(VERIFY_READ, argp, _IOC_SIZE(cmd));
-       else if (_IOC_NONE == (_IOC_DIR(cmd) & _IOC_NONE))
-               status = STATUS_SUCCESS;
-
-       if (status)
-               return -EFAULT;
-
-       if (ad->device_removed)
-               return -EFAULT;
-
-       if (false == ad->fw_download_done) {
-               switch (cmd) {
-               case IOCTL_MAC_ADDR_REQ:
-               case IOCTL_LINK_REQ:
-               case IOCTL_CM_REQUEST:
-               case IOCTL_SS_INFO_REQ:
-               case IOCTL_SEND_CONTROL_MESSAGE:
-               case IOCTL_IDLE_REQ:
-               case IOCTL_BCM_GPIO_SET_REQUEST:
-               case IOCTL_BCM_GPIO_STATUS_REQUEST:
-                       return -EACCES;
-               default:
-                       break;
-               }
-       }
-
-       status = vendorextnIoctl(ad, cmd, arg);
-       if (status != CONTINUE_COMMON_PATH)
-               return status;
-
-       switch (cmd) {
-       /* Rdms for Swin Idle... */
-       case IOCTL_BCM_REGISTER_READ_PRIVATE:
-               status = bcm_char_ioctl_reg_read_private(argp, ad);
-               return status;
-
-       case IOCTL_BCM_REGISTER_WRITE_PRIVATE:
-               status = bcm_char_ioctl_reg_write_private(argp, ad);
-               return status;
-
-       case IOCTL_BCM_REGISTER_READ:
-       case IOCTL_BCM_EEPROM_REGISTER_READ:
-               status = bcm_char_ioctl_eeprom_reg_read(argp, ad);
-               return status;
-
-       case IOCTL_BCM_REGISTER_WRITE:
-       case IOCTL_BCM_EEPROM_REGISTER_WRITE:
-               status = bcm_char_ioctl_eeprom_reg_write(argp, ad, cmd);
-               return status;
-
-       case IOCTL_BCM_GPIO_SET_REQUEST:
-               status = bcm_char_ioctl_gpio_set_request(argp, ad);
-               return status;
-
-       case BCM_LED_THREAD_STATE_CHANGE_REQ:
-               status = bcm_char_ioctl_led_thread_state_change_req(argp,
-                                                                   ad);
-               return status;
-
-       case IOCTL_BCM_GPIO_STATUS_REQUEST:
-               status = bcm_char_ioctl_gpio_status_request(argp, ad);
-               return status;
-
-       case IOCTL_BCM_GPIO_MULTI_REQUEST:
-               status = bcm_char_ioctl_gpio_multi_request(argp, ad);
-               return status;
-
-       case IOCTL_BCM_GPIO_MODE_REQUEST:
-               status = bcm_char_ioctl_gpio_mode_request(argp, ad);
-               return status;
-
-       case IOCTL_MAC_ADDR_REQ:
-       case IOCTL_LINK_REQ:
-       case IOCTL_CM_REQUEST:
-       case IOCTL_SS_INFO_REQ:
-       case IOCTL_SEND_CONTROL_MESSAGE:
-       case IOCTL_IDLE_REQ:
-               status = bcm_char_ioctl_misc_request(argp, ad);
-               return status;
-
-       case IOCTL_BCM_BUFFER_DOWNLOAD_START:
-               status = bcm_char_ioctl_buffer_download_start(ad);
-               return status;
-
-       case IOCTL_BCM_BUFFER_DOWNLOAD:
-               status = bcm_char_ioctl_buffer_download(argp, ad);
-               return status;
-
-       case IOCTL_BCM_BUFFER_DOWNLOAD_STOP:
-               status = bcm_char_ioctl_buffer_download_stop(argp, ad);
-               return status;
-
-
-       case IOCTL_BE_BUCKET_SIZE:
-               status = 0;
-               if (get_user(ad->BEBucketSize,
-                            (unsigned long __user *)arg))
-                       status = -EFAULT;
-               break;
-
-       case IOCTL_RTPS_BUCKET_SIZE:
-               status = 0;
-               if (get_user(ad->rtPSBucketSize,
-                            (unsigned long __user *)arg))
-                       status = -EFAULT;
-               break;
-
-       case IOCTL_CHIP_RESET:
-               status = bcm_char_ioctl_chip_reset(ad);
-               return status;
-
-       case IOCTL_QOS_THRESHOLD:
-               status = bcm_char_ioctl_qos_threshold(arg, ad);
-               return status;
-
-       case IOCTL_DUMP_PACKET_INFO:
-               DumpPackInfo(ad);
-               DumpPhsRules(&ad->stBCMPhsContext);
-               status = STATUS_SUCCESS;
-               break;
-
-       case IOCTL_GET_PACK_INFO:
-               if (copy_to_user(argp, &ad->PackInfo,
-                                sizeof(struct bcm_packet_info)*NO_OF_QUEUES))
-                       return -EFAULT;
-               status = STATUS_SUCCESS;
-               break;
-
-       case IOCTL_BCM_SWITCH_TRANSFER_MODE:
-               status = bcm_char_ioctl_switch_transfer_mode(argp, ad);
-               return status;
-
-       case IOCTL_BCM_GET_DRIVER_VERSION:
-               status = bcm_char_ioctl_get_driver_version(argp);
-               return status;
-
-       case IOCTL_BCM_GET_CURRENT_STATUS:
-               status = bcm_char_ioctl_get_current_status(argp, ad);
-               return status;
-
-       case IOCTL_BCM_SET_MAC_TRACING:
-               status = bcm_char_ioctl_set_mac_tracing(argp, ad);
-               return status;
-
-       case IOCTL_BCM_GET_DSX_INDICATION:
-               status = bcm_char_ioctl_get_dsx_indication(argp, ad);
-               return status;
-
-       case IOCTL_BCM_GET_HOST_MIBS:
-               status = bcm_char_ioctl_get_host_mibs(argp, ad, tarang);
-               return status;
-
-       case IOCTL_BCM_WAKE_UP_DEVICE_FROM_IDLE:
-               if ((false == ad->bTriedToWakeUpFromlowPowerMode) &&
-                               (TRUE == ad->IdleMode)) {
-                       ad->usIdleModePattern = ABORT_IDLE_MODE;
-                       ad->bWakeUpDevice = TRUE;
-                       wake_up(&ad->process_rx_cntrlpkt);
-               }
-
-               status = STATUS_SUCCESS;
-               break;
-
-       case IOCTL_BCM_BULK_WRM:
-               status = bcm_char_ioctl_bulk_wrm(argp, ad, cmd);
-               return status;
-
-       case IOCTL_BCM_GET_NVM_SIZE:
-               status = bcm_char_ioctl_get_nvm_size(argp, ad);
-               return status;
-
-       case IOCTL_BCM_CAL_INIT:
-               status = bcm_char_ioctl_cal_init(argp, ad);
-               return status;
-
-       case IOCTL_BCM_SET_DEBUG:
-               status = bcm_char_ioctl_set_debug(argp, ad);
-               return status;
-
-       case IOCTL_BCM_NVM_READ:
-       case IOCTL_BCM_NVM_WRITE:
-               status = bcm_char_ioctl_nvm_rw(argp, ad, cmd);
-               return status;
-
-       case IOCTL_BCM_FLASH2X_SECTION_READ:
-               status = bcm_char_ioctl_flash2x_section_read(argp, ad);
-               return status;
-
-       case IOCTL_BCM_FLASH2X_SECTION_WRITE:
-               status = bcm_char_ioctl_flash2x_section_write(argp, ad);
-               return status;
-
-       case IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP:
-               status = bcm_char_ioctl_flash2x_section_bitmap(argp, ad);
-               return status;
-
-       case IOCTL_BCM_SET_ACTIVE_SECTION:
-               status = bcm_char_ioctl_set_active_section(argp, ad);
-               return status;
-
-       case IOCTL_BCM_IDENTIFY_ACTIVE_SECTION:
-               /* Right Now we are taking care of only DSD */
-               ad->bAllDSDWriteAllow = false;
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "IOCTL_BCM_IDENTIFY_ACTIVE_SECTION called");
-               status = STATUS_SUCCESS;
-               break;
-
-       case IOCTL_BCM_COPY_SECTION:
-               status = bcm_char_ioctl_copy_section(argp, ad);
-               return status;
-
-       case IOCTL_BCM_GET_FLASH_CS_INFO:
-               status = bcm_char_ioctl_get_flash_cs_info(argp, ad);
-               return status;
-
-       case IOCTL_BCM_SELECT_DSD:
-               status = bcm_char_ioctl_select_dsd(argp, ad);
-               return status;
-
-       case IOCTL_BCM_NVM_RAW_READ:
-               status = bcm_char_ioctl_nvm_raw_read(argp, ad);
-               return status;
-
-       case IOCTL_BCM_CNTRLMSG_MASK:
-               status = bcm_char_ioctl_cntrlmsg_mask(argp, ad, tarang);
-               return status;
-
-       case IOCTL_BCM_GET_DEVICE_DRIVER_INFO:
-               status = bcm_char_ioctl_get_device_driver_info(argp, ad);
-               return status;
-
-       case IOCTL_BCM_TIME_SINCE_NET_ENTRY:
-               status = bcm_char_ioctl_time_since_net_entry(argp, ad);
-               return status;
-
-       case IOCTL_CLOSE_NOTIFICATION:
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
-                               "IOCTL_CLOSE_NOTIFICATION");
-               break;
-
-       default:
-               pr_info(DRV_NAME ": unknown ioctl cmd=%#x\n", cmd);
-               status = STATUS_FAILURE;
-               break;
-       }
-       return status;
-}
-
-
-static const struct file_operations bcm_fops = {
-       .owner    = THIS_MODULE,
-       .open     = bcm_char_open,
-       .release  = bcm_char_release,
-       .read     = bcm_char_read,
-       .unlocked_ioctl    = bcm_char_ioctl,
-       .llseek = no_llseek,
-};
-
-int register_control_device_interface(struct bcm_mini_adapter *ad)
-{
-
-       if (ad->major > 0)
-               return ad->major;
-
-       ad->major = register_chrdev(0, DEV_NAME, &bcm_fops);
-       if (ad->major < 0) {
-               pr_err(DRV_NAME ": could not created character device\n");
-               return ad->major;
-       }
-
-       ad->pstCreatedClassDevice = device_create(bcm_class, NULL,
-                                                      MKDEV(ad->major, 0),
-                                                      ad, DEV_NAME);
-
-       if (IS_ERR(ad->pstCreatedClassDevice)) {
-               pr_err(DRV_NAME ": class device create failed\n");
-               unregister_chrdev(ad->major, DEV_NAME);
-               return PTR_ERR(ad->pstCreatedClassDevice);
-       }
-
-       return 0;
-}
-
-void unregister_control_device_interface(struct bcm_mini_adapter *ad)
-{
-       if (ad->major > 0) {
-               device_destroy(bcm_class, MKDEV(ad->major, 0));
-               unregister_chrdev(ad->major, DEV_NAME);
-       }
-}
-
diff --git a/drivers/staging/bcm/Bcmnet.c b/drivers/staging/bcm/Bcmnet.c
deleted file mode 100644 (file)
index e577676..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-#include "headers.h"
-
-struct net_device *gblpnetdev;
-
-static INT bcm_open(struct net_device *dev)
-{
-       struct bcm_mini_adapter *ad = GET_BCM_ADAPTER(dev);
-
-       if (ad->fw_download_done == false) {
-               pr_notice(PFX "%s: link up failed (download in progress)\n",
-                         dev->name);
-               return -EBUSY;
-       }
-
-       if (netif_msg_ifup(ad))
-               pr_info(PFX "%s: enabling interface\n", dev->name);
-
-       if (ad->LinkUpStatus) {
-               if (netif_msg_link(ad))
-                       pr_info(PFX "%s: link up\n", dev->name);
-
-               netif_carrier_on(ad->dev);
-               netif_start_queue(ad->dev);
-       }
-
-       return 0;
-}
-
-static INT bcm_close(struct net_device *dev)
-{
-       struct bcm_mini_adapter *ad = GET_BCM_ADAPTER(dev);
-
-       if (netif_msg_ifdown(ad))
-               pr_info(PFX "%s: disabling interface\n", dev->name);
-
-       netif_carrier_off(dev);
-       netif_stop_queue(dev);
-
-       return 0;
-}
-
-static u16 bcm_select_queue(struct net_device *dev, struct sk_buff *skb,
-                           void *accel_priv, select_queue_fallback_t fallback)
-{
-       return ClassifyPacket(netdev_priv(dev), skb);
-}
-
-/*******************************************************************
-* Function    -        bcm_transmit()
-*
-* Description - This is the main transmit function for our virtual
-*              interface(eth0). It handles the ARP packets. It
-*              clones this packet and then Queue it to a suitable
-*              Queue. Then calls the transmit_packet().
-*
-* Parameter   -         skb - Pointer to the socket buffer structure
-*               dev - Pointer to the virtual net device structure
-*
-*********************************************************************/
-
-static netdev_tx_t bcm_transmit(struct sk_buff *skb, struct net_device *dev)
-{
-       struct bcm_mini_adapter *ad = GET_BCM_ADAPTER(dev);
-       u16 qindex = skb_get_queue_mapping(skb);
-
-
-       if (ad->device_removed || !ad->LinkUpStatus)
-               goto drop;
-
-       if (ad->TransferMode != IP_PACKET_ONLY_MODE)
-               goto drop;
-
-       if (INVALID_QUEUE_INDEX == qindex)
-               goto drop;
-
-       if (ad->PackInfo[qindex].uiCurrentPacketsOnHost >=
-           SF_MAX_ALLOWED_PACKETS_TO_BACKUP)
-               return NETDEV_TX_BUSY;
-
-       /* Now Enqueue the packet */
-       if (netif_msg_tx_queued(ad))
-               pr_info(PFX "%s: enqueueing packet to queue %d\n",
-                       dev->name, qindex);
-
-       spin_lock(&ad->PackInfo[qindex].SFQueueLock);
-       ad->PackInfo[qindex].uiCurrentBytesOnHost += skb->len;
-       ad->PackInfo[qindex].uiCurrentPacketsOnHost++;
-
-       *((B_UINT32 *) skb->cb + SKB_CB_LATENCY_OFFSET) = jiffies;
-       ENQUEUEPACKET(ad->PackInfo[qindex].FirstTxQueue,
-                     ad->PackInfo[qindex].LastTxQueue, skb);
-       atomic_inc(&ad->TotalPacketCount);
-       spin_unlock(&ad->PackInfo[qindex].SFQueueLock);
-
-       /* FIXME - this is racy and incorrect, replace with work queue */
-       if (!atomic_read(&ad->TxPktAvail)) {
-               atomic_set(&ad->TxPktAvail, 1);
-               wake_up(&ad->tx_packet_wait_queue);
-       }
-       return NETDEV_TX_OK;
-
- drop:
-       dev_kfree_skb(skb);
-       return NETDEV_TX_OK;
-}
-
-
-
-/**
-@ingroup init_functions
-Register other driver entry points with the kernel
-*/
-static const struct net_device_ops bcmNetDevOps = {
-       .ndo_open               = bcm_open,
-       .ndo_stop               = bcm_close,
-       .ndo_start_xmit         = bcm_transmit,
-       .ndo_change_mtu         = eth_change_mtu,
-       .ndo_set_mac_address    = eth_mac_addr,
-       .ndo_validate_addr      = eth_validate_addr,
-       .ndo_select_queue       = bcm_select_queue,
-};
-
-static struct device_type wimax_type = {
-       .name   = "wimax",
-};
-
-static int bcm_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
-{
-       cmd->supported          = 0;
-       cmd->advertising        = 0;
-       cmd->speed              = SPEED_10000;
-       cmd->duplex             = DUPLEX_FULL;
-       cmd->port               = PORT_TP;
-       cmd->phy_address        = 0;
-       cmd->transceiver        = XCVR_INTERNAL;
-       cmd->autoneg            = AUTONEG_DISABLE;
-       cmd->maxtxpkt           = 0;
-       cmd->maxrxpkt           = 0;
-       return 0;
-}
-
-static void bcm_get_drvinfo(struct net_device *dev,
-                           struct ethtool_drvinfo *info)
-{
-       struct bcm_mini_adapter *ad = GET_BCM_ADAPTER(dev);
-       struct bcm_interface_adapter *intf_ad = ad->pvInterfaceAdapter;
-       struct usb_device *udev = interface_to_usbdev(intf_ad->interface);
-
-       strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
-       strlcpy(info->version, DRV_VERSION, sizeof(info->version));
-       snprintf(info->fw_version, sizeof(info->fw_version), "%u.%u",
-                ad->uiFlashLayoutMajorVersion,
-                ad->uiFlashLayoutMinorVersion);
-
-       usb_make_path(udev, info->bus_info, sizeof(info->bus_info));
-}
-
-static u32 bcm_get_link(struct net_device *dev)
-{
-       struct bcm_mini_adapter *ad = GET_BCM_ADAPTER(dev);
-
-       return ad->LinkUpStatus;
-}
-
-static u32 bcm_get_msglevel(struct net_device *dev)
-{
-       struct bcm_mini_adapter *ad = GET_BCM_ADAPTER(dev);
-
-       return ad->msg_enable;
-}
-
-static void bcm_set_msglevel(struct net_device *dev, u32 level)
-{
-       struct bcm_mini_adapter *ad = GET_BCM_ADAPTER(dev);
-
-       ad->msg_enable = level;
-}
-
-static const struct ethtool_ops bcm_ethtool_ops = {
-       .get_settings   = bcm_get_settings,
-       .get_drvinfo    = bcm_get_drvinfo,
-       .get_link       = bcm_get_link,
-       .get_msglevel   = bcm_get_msglevel,
-       .set_msglevel   = bcm_set_msglevel,
-};
-
-int register_networkdev(struct bcm_mini_adapter *ad)
-{
-       struct net_device *net = ad->dev;
-       struct bcm_interface_adapter *intf_ad = ad->pvInterfaceAdapter;
-       struct usb_interface *udev = intf_ad->interface;
-       struct usb_device *xdev = intf_ad->udev;
-
-       int result;
-
-       net->netdev_ops = &bcmNetDevOps;
-       net->ethtool_ops = &bcm_ethtool_ops;
-       net->mtu = MTU_SIZE;    /* 1400 Bytes */
-       net->tx_queue_len = TX_QLEN;
-       net->flags |= IFF_NOARP;
-
-       netif_carrier_off(net);
-
-       SET_NETDEV_DEVTYPE(net, &wimax_type);
-
-       /* Read the MAC Address from EEPROM */
-       result = ReadMacAddressFromNVM(ad);
-       if (result != STATUS_SUCCESS) {
-               dev_err(&udev->dev,
-                       PFX "Error in Reading the mac Address: %d", result);
-               return -EIO;
-       }
-
-       result = register_netdev(net);
-       if (result)
-               return result;
-
-       gblpnetdev = ad->dev;
-
-       if (netif_msg_probe(ad))
-               dev_info(&udev->dev, PFX "%s: register usb-%s-%s %pM\n",
-                        net->name, xdev->bus->bus_name, xdev->devpath,
-                        net->dev_addr);
-
-       return 0;
-}
-
-void unregister_networkdev(struct bcm_mini_adapter *ad)
-{
-       struct net_device *net = ad->dev;
-       struct bcm_interface_adapter *intf_ad = ad->pvInterfaceAdapter;
-       struct usb_interface *udev = intf_ad->interface;
-       struct usb_device *xdev = intf_ad->udev;
-
-       if (netif_msg_probe(ad))
-               dev_info(&udev->dev, PFX "%s: unregister usb-%s%s\n",
-                        net->name, xdev->bus->bus_name, xdev->devpath);
-
-       unregister_netdev(ad->dev);
-}
diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c
deleted file mode 100644 (file)
index adca0ce..0000000
+++ /dev/null
@@ -1,2254 +0,0 @@
-/************************************************************
- * CMHOST.C
- * This file contains the routines for handling Connection
- * Management.
- ************************************************************/
-
-#include "headers.h"
-
-enum E_CLASSIFIER_ACTION {
-       eInvalidClassifierAction,
-       eAddClassifier,
-       eReplaceClassifier,
-       eDeleteClassifier
-};
-
-static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter,
-               B_UINT16 tid);
-static void restore_endianess_of_pstClassifierEntry(
-               struct bcm_classifier_rule *pstClassifierEntry,
-               enum bcm_ipaddr_context eIpAddrContext);
-
-static void apply_phs_rule_to_all_classifiers(
-               register struct bcm_mini_adapter *Adapter,
-               register UINT uiSearchRuleIndex,
-               USHORT uVCID,
-               struct bcm_phs_rule *sPhsRule,
-               struct bcm_phs_rules *cPhsRule,
-               struct bcm_add_indication_alt *pstAddIndication);
-
-/************************************************************
- * Function - SearchSfid
- *
- * Description - This routinue would search QOS queues having
- *  specified SFID as input parameter.
- *
- * Parameters -        Adapter: Pointer to the Adapter structure
- *  uiSfid : Given SFID for matching
- *
- * Returns - Queue index for this SFID(If matched)
- *  Else Invalid Queue Index(If Not matched)
- ************************************************************/
-int SearchSfid(struct bcm_mini_adapter *Adapter, UINT uiSfid)
-{
-       int i;
-
-       for (i = (NO_OF_QUEUES-1); i >= 0; i--)
-               if (Adapter->PackInfo[i].ulSFID == uiSfid)
-                       return i;
-
-       return NO_OF_QUEUES+1;
-}
-
-/***************************************************************
- * Function -SearchFreeSfid
- *
- * Description - This routinue would search Free available SFID.
- *
- * Parameter - Adapter: Pointer to the Adapter structure
- *
- * Returns - Queue index for the free SFID
- *  Else returns Invalid Index.
- ****************************************************************/
-static int SearchFreeSfid(struct bcm_mini_adapter *Adapter)
-{
-       int i;
-
-       for (i = 0; i < (NO_OF_QUEUES-1); i++)
-               if (Adapter->PackInfo[i].ulSFID == 0)
-                       return i;
-
-       return NO_OF_QUEUES+1;
-}
-
-/*
- * Function: SearchClsid
- * Description:        This routinue would search Classifier  having specified ClassifierID as input parameter
- * Input parameters: struct bcm_mini_adapter *Adapter - Adapter Context
- *  unsigned int uiSfid   - The SF in which the classifier is to searched
- *  B_UINT16  uiClassifierID - The classifier ID to be searched
- * Return: int :Classifier table index of matching entry
- */
-static int SearchClsid(struct bcm_mini_adapter *Adapter,
-               ULONG ulSFID,
-               B_UINT16 uiClassifierID)
-{
-       int i;
-
-       for (i = 0; i < MAX_CLASSIFIERS; i++) {
-               if ((Adapter->astClassifierTable[i].bUsed) &&
-                       (Adapter->astClassifierTable[i].uiClassifierRuleIndex
-                               == uiClassifierID) &&
-                       (Adapter->astClassifierTable[i].ulSFID == ulSFID))
-                       return i;
-       }
-
-       return MAX_CLASSIFIERS+1;
-}
-
-/*
- * @ingroup ctrl_pkt_functions
- * This routinue would search Free available Classifier entry in classifier table.
- * @return free Classifier Entry index in classifier table for specified SF
- */
-static int SearchFreeClsid(struct bcm_mini_adapter *Adapter /**Adapter Context*/)
-{
-       int i;
-
-       for (i = 0; i < MAX_CLASSIFIERS; i++) {
-               if (!Adapter->astClassifierTable[i].bUsed)
-                       return i;
-       }
-
-       return MAX_CLASSIFIERS+1;
-}
-
-static VOID deleteSFBySfid(struct bcm_mini_adapter *Adapter,
-               UINT uiSearchRuleIndex)
-{
-       /* deleting all the packet held in the SF */
-       flush_queue(Adapter, uiSearchRuleIndex);
-
-       /* Deleting the all classifiers for this SF */
-       DeleteAllClassifiersForSF(Adapter, uiSearchRuleIndex);
-
-       /* Resetting only MIBS related entries in the SF */
-       memset((PVOID)&Adapter->PackInfo[uiSearchRuleIndex], 0,
-                       sizeof(struct bcm_mibs_table));
-}
-
-static inline VOID
-CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry,
-               B_UINT8 u8IpAddressLen, B_UINT8 *pu8IpAddressMaskSrc,
-               bool bIpVersion6, enum bcm_ipaddr_context eIpAddrContext)
-{
-       int i = 0;
-       UINT nSizeOfIPAddressInBytes = IP_LENGTH_OF_ADDRESS;
-       UCHAR *ptrClassifierIpAddress = NULL;
-       UCHAR *ptrClassifierIpMask = NULL;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       if (bIpVersion6)
-               nSizeOfIPAddressInBytes = IPV6_ADDRESS_SIZEINBYTES;
-
-       /* Destination Ip Address */
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "Ip Address Range Length:0x%X ", u8IpAddressLen);
-       if ((bIpVersion6 ? (IPV6_ADDRESS_SIZEINBYTES * MAX_IP_RANGE_LENGTH * 2) :
-                       (TOTAL_MASKED_ADDRESS_IN_BYTES)) >= u8IpAddressLen) {
-
-               union u_ip_address *st_dest_ip =
-                       &pstClassifierEntry->stDestIpAddress;
-
-               union u_ip_address *st_src_ip =
-                       &pstClassifierEntry->stSrcIpAddress;
-
-               /*
-                * checking both the mask and address togethor in Classification.
-                * So length will be : TotalLengthInBytes/nSizeOfIPAddressInBytes * 2
-                * (nSizeOfIPAddressInBytes for address and nSizeOfIPAddressInBytes for mask)
-                */
-               if (eIpAddrContext == eDestIpAddress) {
-                       pstClassifierEntry->ucIPDestinationAddressLength =
-                               u8IpAddressLen/(nSizeOfIPAddressInBytes * 2);
-                       if (bIpVersion6) {
-                               ptrClassifierIpAddress =
-                                       st_dest_ip->ucIpv6Address;
-                               ptrClassifierIpMask =
-                                       st_dest_ip->ucIpv6Mask;
-                       } else {
-                               ptrClassifierIpAddress =
-                                       st_dest_ip->ucIpv4Address;
-                               ptrClassifierIpMask =
-                                       st_dest_ip->ucIpv4Mask;
-                       }
-               } else if (eIpAddrContext == eSrcIpAddress) {
-                       pstClassifierEntry->ucIPSourceAddressLength =
-                               u8IpAddressLen/(nSizeOfIPAddressInBytes * 2);
-                       if (bIpVersion6) {
-                               ptrClassifierIpAddress =
-                                       st_src_ip->ucIpv6Address;
-                               ptrClassifierIpMask = st_src_ip->ucIpv6Mask;
-                       } else {
-                               ptrClassifierIpAddress =
-                                       st_src_ip->ucIpv4Address;
-                               ptrClassifierIpMask = st_src_ip->ucIpv4Mask;
-                       }
-               }
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                               "Address Length:0x%X\n",
-                               pstClassifierEntry->ucIPDestinationAddressLength);
-               while ((u8IpAddressLen >= nSizeOfIPAddressInBytes)
-                               && (i < MAX_IP_RANGE_LENGTH)) {
-                       memcpy(ptrClassifierIpAddress +
-                               (i * nSizeOfIPAddressInBytes),
-                               (pu8IpAddressMaskSrc
-                                       + (i * nSizeOfIPAddressInBytes * 2)),
-                               nSizeOfIPAddressInBytes);
-
-                       if (!bIpVersion6) {
-                               if (eIpAddrContext == eSrcIpAddress) {
-                                       st_src_ip->ulIpv4Addr[i] =
-                                               ntohl(st_src_ip->ulIpv4Addr[i]);
-                                       BCM_DEBUG_PRINT(Adapter,
-                                                       DBG_TYPE_OTHERS,
-                                                       CONN_MSG,
-                                                       DBG_LVL_ALL,
-                                                       "Src Ip Address:0x%luX ",
-                                                       st_src_ip->ulIpv4Addr[i]);
-                               } else if (eIpAddrContext == eDestIpAddress) {
-                                       st_dest_ip->ulIpv4Addr[i] =
-                                               ntohl(st_dest_ip->ulIpv4Addr[i]);
-                                       BCM_DEBUG_PRINT(Adapter,
-                                                       DBG_TYPE_OTHERS,
-                                                       CONN_MSG,
-                                                       DBG_LVL_ALL,
-                                                       "Dest Ip Address:0x%luX ",
-                                                       st_dest_ip->ulIpv4Addr[i]);
-                               }
-                       }
-                       u8IpAddressLen -= nSizeOfIPAddressInBytes;
-                       if (u8IpAddressLen >= nSizeOfIPAddressInBytes) {
-                               memcpy(ptrClassifierIpMask +
-                                       (i * nSizeOfIPAddressInBytes),
-                                       (pu8IpAddressMaskSrc
-                                               + nSizeOfIPAddressInBytes
-                                               + (i * nSizeOfIPAddressInBytes * 2)),
-                                       nSizeOfIPAddressInBytes);
-
-                               if (!bIpVersion6) {
-                                       if (eIpAddrContext == eSrcIpAddress) {
-                                               st_src_ip->ulIpv4Mask[i] =
-                                                       ntohl(st_src_ip->ulIpv4Mask[i]);
-                                               BCM_DEBUG_PRINT(Adapter,
-                                                               DBG_TYPE_OTHERS,
-                                                               CONN_MSG,
-                                                               DBG_LVL_ALL,
-                                                               "Src Ip Mask Address:0x%luX ",
-                                                               st_src_ip->ulIpv4Mask[i]);
-                                       } else if (eIpAddrContext == eDestIpAddress) {
-                                               st_dest_ip->ulIpv4Mask[i] =
-                                                       ntohl(st_dest_ip->ulIpv4Mask[i]);
-                                               BCM_DEBUG_PRINT(Adapter,
-                                                               DBG_TYPE_OTHERS,
-                                                               CONN_MSG,
-                                                               DBG_LVL_ALL,
-                                                               "Dest Ip Mask Address:0x%luX ",
-                                                               st_dest_ip->ulIpv4Mask[i]);
-                                       }
-                               }
-                               u8IpAddressLen -= nSizeOfIPAddressInBytes;
-                       }
-                       if (u8IpAddressLen == 0)
-                               pstClassifierEntry->bDestIpValid = TRUE;
-
-                       i++;
-               }
-               if (bIpVersion6) {
-                       /* Restore EndianNess of Struct */
-                       restore_endianess_of_pstClassifierEntry(
-                                       pstClassifierEntry,
-                                       eIpAddrContext
-                                       );
-               }
-       }
-}
-
-void ClearTargetDSXBuffer(struct bcm_mini_adapter *Adapter, B_UINT16 TID, bool bFreeAll)
-{
-       int i;
-       struct bcm_targetdsx_buffer *curr_buf;
-
-       for (i = 0; i < Adapter->ulTotalTargetBuffersAvailable; i++) {
-               curr_buf = &Adapter->astTargetDsxBuffer[i];
-
-               if (curr_buf->valid)
-                       continue;
-
-               if ((bFreeAll) || (curr_buf->tid == TID)) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,
-                                       "ClearTargetDSXBuffer: found tid %d buffer cleared %lx\n",
-                                       TID, curr_buf->ulTargetDsxBuffer);
-                       curr_buf->valid = 1;
-                       curr_buf->tid = 0;
-                       Adapter->ulFreeTargetBufferCnt++;
-               }
-       }
-}
-
-/*
- * @ingroup ctrl_pkt_functions
- * copy classifier rule into the specified SF index
- */
-static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter,
-               struct bcm_convergence_types *psfCSType,
-               UINT uiSearchRuleIndex,
-               UINT nClassifierIndex)
-{
-       struct bcm_classifier_rule *pstClassifierEntry = NULL;
-       /* VOID *pvPhsContext = NULL; */
-       int i;
-       /* UCHAR ucProtocolLength=0; */
-       /* ULONG ulPhsStatus; */
-
-       struct bcm_packet_class_rules *pack_class_rule =
-               &psfCSType->cCPacketClassificationRule;
-
-       if (Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value == 0 ||
-               nClassifierIndex > (MAX_CLASSIFIERS-1))
-               return;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "Storing Classifier Rule Index : %X",
-                       ntohs(pack_class_rule->u16PacketClassificationRuleIndex));
-
-       if (nClassifierIndex > MAX_CLASSIFIERS-1)
-               return;
-
-       pstClassifierEntry = &Adapter->astClassifierTable[nClassifierIndex];
-       if (pstClassifierEntry) {
-               /* Store if Ipv6 */
-               pstClassifierEntry->bIpv6Protocol =
-                       (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6) ? TRUE : false;
-
-               /* Destinaiton Port */
-               pstClassifierEntry->ucDestPortRangeLength =
-                       pack_class_rule->u8ProtocolDestPortRangeLength / 4;
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                               "Destination Port Range Length:0x%X ",
-                               pstClassifierEntry->ucDestPortRangeLength);
-
-               if (pack_class_rule->u8ProtocolDestPortRangeLength <= MAX_PORT_RANGE) {
-                       for (i = 0; i < (pstClassifierEntry->ucDestPortRangeLength); i++) {
-                               pstClassifierEntry->usDestPortRangeLo[i] =
-                                       *((PUSHORT)(pack_class_rule->u8ProtocolDestPortRange+i));
-                               pstClassifierEntry->usDestPortRangeHi[i] =
-                                       *((PUSHORT)(pack_class_rule->u8ProtocolDestPortRange+2+i));
-                               pstClassifierEntry->usDestPortRangeLo[i] =
-                                       ntohs(pstClassifierEntry->usDestPortRangeLo[i]);
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
-                                               CONN_MSG, DBG_LVL_ALL,
-                                               "Destination Port Range Lo:0x%X ",
-                                               pstClassifierEntry->usDestPortRangeLo[i]);
-                               pstClassifierEntry->usDestPortRangeHi[i] =
-                                       ntohs(pstClassifierEntry->usDestPortRangeHi[i]);
-                       }
-               } else {
-                       pstClassifierEntry->ucDestPortRangeLength = 0;
-               }
-
-               /* Source Port */
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                               "Source Port Range Length:0x%X ",
-                               pack_class_rule->u8ProtocolSourcePortRangeLength);
-               if (pack_class_rule->u8ProtocolSourcePortRangeLength <= MAX_PORT_RANGE) {
-                       pstClassifierEntry->ucSrcPortRangeLength =
-                               pack_class_rule->u8ProtocolSourcePortRangeLength/4;
-                       for (i = 0; i < (pstClassifierEntry->ucSrcPortRangeLength); i++) {
-                               pstClassifierEntry->usSrcPortRangeLo[i] =
-                                       *((PUSHORT)(pack_class_rule->
-                                                       u8ProtocolSourcePortRange+i));
-                               pstClassifierEntry->usSrcPortRangeHi[i] =
-                                       *((PUSHORT)(pack_class_rule->
-                                                       u8ProtocolSourcePortRange+2+i));
-                               pstClassifierEntry->usSrcPortRangeLo[i] =
-                                       ntohs(pstClassifierEntry->usSrcPortRangeLo[i]);
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
-                                               CONN_MSG, DBG_LVL_ALL,
-                                               "Source Port Range Lo:0x%X ",
-                                               pstClassifierEntry->usSrcPortRangeLo[i]);
-                               pstClassifierEntry->usSrcPortRangeHi[i] =
-                                       ntohs(pstClassifierEntry->usSrcPortRangeHi[i]);
-                       }
-               }
-               /* Destination Ip Address and Mask */
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                               "Ip Destination Parameters : ");
-               CopyIpAddrToClassifier(pstClassifierEntry,
-                               pack_class_rule->u8IPDestinationAddressLength,
-                               pack_class_rule->u8IPDestinationAddress,
-                               (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6) ?
-                       TRUE : false, eDestIpAddress);
-
-               /* Source Ip Address and Mask */
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                               "Ip Source Parameters : ");
-
-               CopyIpAddrToClassifier(pstClassifierEntry,
-                               pack_class_rule->u8IPMaskedSourceAddressLength,
-                               pack_class_rule->u8IPMaskedSourceAddress,
-                               (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6) ? TRUE : false,
-                               eSrcIpAddress);
-
-               /* TOS */
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                               "TOS Length:0x%X ",
-                               pack_class_rule->u8IPTypeOfServiceLength);
-               if (pack_class_rule->u8IPTypeOfServiceLength == 3) {
-                       pstClassifierEntry->ucIPTypeOfServiceLength =
-                               pack_class_rule->u8IPTypeOfServiceLength;
-                       pstClassifierEntry->ucTosLow =
-                               pack_class_rule->u8IPTypeOfService[0];
-                       pstClassifierEntry->ucTosHigh =
-                               pack_class_rule->u8IPTypeOfService[1];
-                       pstClassifierEntry->ucTosMask =
-                               pack_class_rule->u8IPTypeOfService[2];
-                       pstClassifierEntry->bTOSValid = TRUE;
-               }
-               if (pack_class_rule->u8Protocol == 0) {
-                       /* we didn't get protocol field filled in by the BS */
-                       pstClassifierEntry->ucProtocolLength = 0;
-               } else {
-                       pstClassifierEntry->ucProtocolLength = 1; /* 1 valid protocol */
-               }
-
-               pstClassifierEntry->ucProtocol[0] = pack_class_rule->u8Protocol;
-               pstClassifierEntry->u8ClassifierRulePriority =
-                       pack_class_rule->u8ClassifierRulePriority;
-
-               /* store the classifier rule ID and set this classifier entry as valid */
-               pstClassifierEntry->ucDirection =
-                       Adapter->PackInfo[uiSearchRuleIndex].ucDirection;
-               pstClassifierEntry->uiClassifierRuleIndex =
-                       ntohs(pack_class_rule->u16PacketClassificationRuleIndex);
-               pstClassifierEntry->usVCID_Value =
-                       Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value;
-               pstClassifierEntry->ulSFID =
-                       Adapter->PackInfo[uiSearchRuleIndex].ulSFID;
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                               "Search Index %d Dir: %d, Index: %d, Vcid: %d\n",
-                               uiSearchRuleIndex,
-                               pstClassifierEntry->ucDirection,
-                               pstClassifierEntry->uiClassifierRuleIndex,
-                               pstClassifierEntry->usVCID_Value);
-
-               if (pack_class_rule->u8AssociatedPHSI)
-                       pstClassifierEntry->u8AssociatedPHSI =
-                               pack_class_rule->u8AssociatedPHSI;
-
-               /* Copy ETH CS Parameters */
-               pstClassifierEntry->ucEthCSSrcMACLen =
-                       (pack_class_rule->u8EthernetSourceMACAddressLength);
-               memcpy(pstClassifierEntry->au8EThCSSrcMAC,
-                               pack_class_rule->u8EthernetSourceMACAddress,
-                               MAC_ADDRESS_SIZE);
-               memcpy(pstClassifierEntry->au8EThCSSrcMACMask,
-                               pack_class_rule->u8EthernetSourceMACAddress
-                               + MAC_ADDRESS_SIZE, MAC_ADDRESS_SIZE);
-               pstClassifierEntry->ucEthCSDestMACLen =
-                       (pack_class_rule->u8EthernetDestMacAddressLength);
-               memcpy(pstClassifierEntry->au8EThCSDestMAC,
-                               pack_class_rule->u8EthernetDestMacAddress,
-                               MAC_ADDRESS_SIZE);
-               memcpy(pstClassifierEntry->au8EThCSDestMACMask,
-                               pack_class_rule->u8EthernetDestMacAddress
-                               + MAC_ADDRESS_SIZE, MAC_ADDRESS_SIZE);
-               pstClassifierEntry->ucEtherTypeLen =
-                       (pack_class_rule->u8EthertypeLength);
-               memcpy(pstClassifierEntry->au8EthCSEtherType,
-                               pack_class_rule->u8Ethertype,
-                               NUM_ETHERTYPE_BYTES);
-               memcpy(pstClassifierEntry->usUserPriority,
-                               &pack_class_rule->u16UserPriority, 2);
-               pstClassifierEntry->usVLANID =
-                       ntohs(pack_class_rule->u16VLANID);
-               pstClassifierEntry->usValidityBitMap =
-                       ntohs(pack_class_rule->u16ValidityBitMap);
-
-               pstClassifierEntry->bUsed = TRUE;
-       }
-}
-
-/*
- * @ingroup ctrl_pkt_functions
- */
-static inline VOID DeleteClassifierRuleFromSF(struct bcm_mini_adapter *Adapter,
-               UINT uiSearchRuleIndex, UINT nClassifierIndex)
-{
-       struct bcm_classifier_rule *pstClassifierEntry = NULL;
-       B_UINT16 u16PacketClassificationRuleIndex;
-       USHORT usVCID;
-       /* VOID *pvPhsContext = NULL; */
-       /*ULONG ulPhsStatus; */
-
-       usVCID = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value;
-
-       if (nClassifierIndex > MAX_CLASSIFIERS-1)
-               return;
-
-       if (usVCID == 0)
-               return;
-
-       u16PacketClassificationRuleIndex =
-               Adapter->astClassifierTable[nClassifierIndex].uiClassifierRuleIndex;
-       pstClassifierEntry = &Adapter->astClassifierTable[nClassifierIndex];
-       if (pstClassifierEntry) {
-               pstClassifierEntry->bUsed = false;
-               pstClassifierEntry->uiClassifierRuleIndex = 0;
-               memset(pstClassifierEntry, 0,
-                               sizeof(struct bcm_classifier_rule));
-
-               /* Delete the PHS Rule for this classifier */
-               PhsDeleteClassifierRule(&Adapter->stBCMPhsContext, usVCID,
-                               u16PacketClassificationRuleIndex);
-       }
-}
-
-/*
- * @ingroup ctrl_pkt_functions
- */
-VOID DeleteAllClassifiersForSF(struct bcm_mini_adapter *Adapter,
-               UINT uiSearchRuleIndex)
-{
-       struct bcm_classifier_rule *pstClassifierEntry = NULL;
-       int i;
-       /* B_UINT16  u16PacketClassificationRuleIndex; */
-       USHORT ulVCID;
-       /* VOID *pvPhsContext = NULL; */
-       /* ULONG ulPhsStatus; */
-
-       ulVCID = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value;
-
-       if (ulVCID == 0)
-               return;
-
-       for (i = 0; i < MAX_CLASSIFIERS; i++) {
-               if (Adapter->astClassifierTable[i].usVCID_Value == ulVCID) {
-                       pstClassifierEntry = &Adapter->astClassifierTable[i];
-
-                       if (pstClassifierEntry->bUsed)
-                               DeleteClassifierRuleFromSF(Adapter,
-                                               uiSearchRuleIndex, i);
-               }
-       }
-
-       /* Delete All Phs Rules Associated with this SF */
-       PhsDeleteSFRules(&Adapter->stBCMPhsContext, ulVCID);
-}
-
-/*
- * This routinue  copies the Connection Management
- * related data into the Adapter structure.
- * @ingroup ctrl_pkt_functions
- */
-static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer to the Adapter structure */
-                       register struct bcm_connect_mgr_params *psfLocalSet, /* Pointer to the connection manager parameters structure */
-                       register UINT uiSearchRuleIndex, /* <Index of Queue, to which this data belongs */
-                       register UCHAR ucDsxType,
-                       struct bcm_add_indication_alt *pstAddIndication) {
-
-       /* UCHAR ucProtocolLength = 0; */
-       ULONG ulSFID;
-       UINT nClassifierIndex = 0;
-       enum E_CLASSIFIER_ACTION eClassifierAction = eInvalidClassifierAction;
-       B_UINT16 u16PacketClassificationRuleIndex = 0;
-       int i;
-       struct bcm_convergence_types *psfCSType = NULL;
-       struct bcm_phs_rule sPhsRule;
-       struct bcm_packet_info *curr_packinfo =
-               &Adapter->PackInfo[uiSearchRuleIndex];
-       USHORT uVCID = curr_packinfo->usVCID_Value;
-       UINT UGIValue = 0;
-
-       curr_packinfo->bValid = TRUE;
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "Search Rule Index = %d\n", uiSearchRuleIndex);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "%s: SFID= %x ", __func__, ntohl(psfLocalSet->u32SFID));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "Updating Queue %d", uiSearchRuleIndex);
-
-       ulSFID = ntohl(psfLocalSet->u32SFID);
-       /* Store IP Version used */
-       /* Get The Version Of IP used (IPv6 or IPv4) from CSSpecification field of SF */
-
-       curr_packinfo->bIPCSSupport = 0;
-       curr_packinfo->bEthCSSupport = 0;
-
-       /* Enable IP/ETh CS Support As Required */
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "CopyToAdapter : u8CSSpecification : %X\n",
-                       psfLocalSet->u8CSSpecification);
-       switch (psfLocalSet->u8CSSpecification) {
-       case eCSPacketIPV4:
-               curr_packinfo->bIPCSSupport = IPV4_CS;
-               break;
-       case eCSPacketIPV6:
-               curr_packinfo->bIPCSSupport = IPV6_CS;
-               break;
-       case eCS802_3PacketEthernet:
-       case eCS802_1QPacketVLAN:
-               curr_packinfo->bEthCSSupport = ETH_CS_802_3;
-               break;
-       case eCSPacketIPV4Over802_1QVLAN:
-       case eCSPacketIPV4Over802_3Ethernet:
-               curr_packinfo->bIPCSSupport = IPV4_CS;
-               curr_packinfo->bEthCSSupport = ETH_CS_802_3;
-               break;
-       case eCSPacketIPV6Over802_1QVLAN:
-       case eCSPacketIPV6Over802_3Ethernet:
-               curr_packinfo->bIPCSSupport = IPV6_CS;
-               curr_packinfo->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");
-               curr_packinfo->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,
-                       curr_packinfo->bEthCSSupport,
-                       curr_packinfo->bIPCSSupport);
-
-       /* Store IP Version used */
-       /* Get The Version Of IP used (IPv6 or IPv4) from CSSpecification field of SF */
-       if (curr_packinfo->bIPCSSupport == IPV6_CS)
-               curr_packinfo->ucIpVersion = IPV6;
-       else
-               curr_packinfo->ucIpVersion = IPV4;
-
-       /* To ensure that the ETH CS code doesn't gets executed if the BS doesn't supports ETH CS */
-       if (!Adapter->bETHCSEnabled)
-               curr_packinfo->bEthCSSupport = 0;
-
-       if (psfLocalSet->u8ServiceClassNameLength > 0 && psfLocalSet->u8ServiceClassNameLength < 32)
-               memcpy(curr_packinfo->ucServiceClassName,
-                               psfLocalSet->u8ServiceClassName,
-                               psfLocalSet->u8ServiceClassNameLength);
-
-       curr_packinfo->u8QueueType = psfLocalSet->u8ServiceFlowSchedulingType;
-
-       if (curr_packinfo->u8QueueType == BE && curr_packinfo->ucDirection)
-               Adapter->usBestEffortQueueIndex = uiSearchRuleIndex;
-
-       curr_packinfo->ulSFID = ntohl(psfLocalSet->u32SFID);
-
-       curr_packinfo->u8TrafficPriority = psfLocalSet->u8TrafficPriority;
-
-       /* copy all the classifier in the Service Flow param  structure */
-       for (i = 0; i < psfLocalSet->u8TotalClassifiers; i++) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                               "Classifier index =%d", i);
-               psfCSType = &psfLocalSet->cConvergenceSLTypes[i];
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                               "Classifier index =%d", i);
-
-               if (psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority)
-                       curr_packinfo->bClassifierPriority = TRUE;
-
-               if (psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority)
-                       curr_packinfo->bClassifierPriority = TRUE;
-
-               if (ucDsxType == DSA_ACK) {
-                       eClassifierAction = eAddClassifier;
-               } else if (ucDsxType == DSC_ACK) {
-                       switch (psfCSType->u8ClassfierDSCAction) {
-                       case 0: /* DSC Add Classifier */
-                               eClassifierAction = eAddClassifier;
-                               break;
-                       case 1: /* DSC Replace Classifier */
-                               eClassifierAction = eReplaceClassifier;
-                               break;
-                       case 2: /* DSC Delete Classifier */
-                               eClassifierAction = eDeleteClassifier;
-                               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);
-
-                       if (nClassifierIndex > MAX_CLASSIFIERS) {
-                               nClassifierIndex = SearchFreeClsid(Adapter);
-                               if (nClassifierIndex > MAX_CLASSIFIERS) {
-                                       /* Failed To get a free Entry */
-                                       BCM_DEBUG_PRINT(Adapter,
-                                                       DBG_TYPE_OTHERS,
-                                                       CONN_MSG,
-                                                       DBG_LVL_ALL,
-                                                       "Error Failed To get a free Classifier Entry");
-                                       break;
-                               }
-                               /* Copy the Classifier Rule for this service flow into our Classifier table maintained per SF. */
-                               CopyClassifierRuleToSF(Adapter, psfCSType,
-                                               uiSearchRuleIndex,
-                                               nClassifierIndex);
-                       } else {
-                               /* This Classifier Already Exists and it is invalid to Add Classifier with existing PCRI */
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
-                                               CONN_MSG,
-                                               DBG_LVL_ALL,
-                                               "CopyToAdapter: Error The Specified Classifier Already Exists and attempted To Add Classifier with Same PCRI : 0x%x\n",
-                                               u16PacketClassificationRuleIndex);
-                       }
-                       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);
-                       if (nClassifierIndex > MAX_CLASSIFIERS) {
-                               /* Failed To search the classifier */
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
-                                               CONN_MSG, DBG_LVL_ALL,
-                                               "Error Search for Classifier To be replaced failed");
-                               break;
-                       }
-                       /* Copy the Classifier Rule for this service flow into our Classifier table maintained per SF. */
-                       CopyClassifierRuleToSF(Adapter, psfCSType,
-                                       uiSearchRuleIndex, nClassifierIndex);
-                       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);
-                       if (nClassifierIndex > MAX_CLASSIFIERS) {
-                               /* Failed To search the classifier */
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
-                                               CONN_MSG, DBG_LVL_ALL,
-                                               "Error Search for Classifier To be deleted failed");
-                               break;
-                       }
-
-                       /* Delete This classifier */
-                       DeleteClassifierRuleFromSF(Adapter, uiSearchRuleIndex,
-                                       nClassifierIndex);
-                       break;
-               default:
-                       /* Invalid Action for classifier */
-                       break;
-               }
-       }
-
-       /* Repeat parsing Classification Entries to process PHS Rules */
-       for (i = 0; i < psfLocalSet->u8TotalClassifiers; i++) {
-               psfCSType = &psfLocalSet->cConvergenceSLTypes[i];
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                               "psfCSType->u8PhsDSCAction : 0x%x\n",
-                               psfCSType->u8PhsDSCAction);
-
-               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 */
-                               apply_phs_rule_to_all_classifiers(Adapter,
-                                               uiSearchRuleIndex,
-                                               uVCID,
-                                               &sPhsRule,
-                                               &psfCSType->cPhsRule,
-                                               pstAddIndication);
-                       }
-                       break;
-               }
-       }
-
-       if (psfLocalSet->u32MaxSustainedTrafficRate == 0) {
-               /* No Rate Limit . Set Max Sustained Traffic Rate to Maximum */
-               curr_packinfo->uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE;
-       } else if (ntohl(psfLocalSet->u32MaxSustainedTrafficRate) > WIMAX_MAX_ALLOWED_RATE) {
-               /* Too large Allowed Rate specified. Limiting to Wi Max  Allowed rate */
-               curr_packinfo->uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE;
-       } else {
-               curr_packinfo->uiMaxAllowedRate =
-                       ntohl(psfLocalSet->u32MaxSustainedTrafficRate);
-       }
-
-       curr_packinfo->uiMaxLatency = ntohl(psfLocalSet->u32MaximumLatency);
-       if (curr_packinfo->uiMaxLatency == 0) /* 0 should be treated as infinite */
-               curr_packinfo->uiMaxLatency = MAX_LATENCY_ALLOWED;
-
-       if ((curr_packinfo->u8QueueType == ERTPS ||
-                       curr_packinfo->u8QueueType == UGS))
-               UGIValue = ntohs(psfLocalSet->u16UnsolicitedGrantInterval);
-
-       if (UGIValue == 0)
-               UGIValue = DEFAULT_UG_INTERVAL;
-
-       /*
-        * For UGI based connections...
-        * DEFAULT_UGI_FACTOR*UGIInterval worth of data is the max token count at host...
-        * The extra amount of token is to ensure that a large amount of jitter won't have loss in throughput...
-        * In case of non-UGI based connection, 200 frames worth of data is the max token count at host...
-        */
-       curr_packinfo->uiMaxBucketSize =
-               (DEFAULT_UGI_FACTOR*curr_packinfo->uiMaxAllowedRate*UGIValue)/1000;
-
-       if (curr_packinfo->uiMaxBucketSize < WIMAX_MAX_MTU*8) {
-               UINT UGIFactor = 0;
-               /* Special Handling to ensure the biggest size of packet can go out from host to FW as follows:
-                * 1. Any packet from Host to FW can go out in different packet size.
-                * 2. So in case the Bucket count is smaller than MTU, the packets of size (Size > TokenCount), will get dropped.
-                * 3. We can allow packets of MaxSize from Host->FW that can go out from FW in multiple SDUs by fragmentation at Wimax Layer
-                */
-               UGIFactor = (curr_packinfo->uiMaxLatency/UGIValue + 1);
-
-               if (UGIFactor > DEFAULT_UGI_FACTOR)
-                       curr_packinfo->uiMaxBucketSize =
-                               (UGIFactor*curr_packinfo->uiMaxAllowedRate*UGIValue)/1000;
-
-               if (curr_packinfo->uiMaxBucketSize > WIMAX_MAX_MTU*8)
-                       curr_packinfo->uiMaxBucketSize = WIMAX_MAX_MTU*8;
-       }
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "LAT: %d, UGI: %d\n", curr_packinfo->uiMaxLatency,
-                       UGIValue);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "uiMaxAllowedRate: 0x%x, u32MaxSustainedTrafficRate: 0x%x ,uiMaxBucketSize: 0x%x",
-                       curr_packinfo->uiMaxAllowedRate,
-                       ntohl(psfLocalSet->u32MaxSustainedTrafficRate),
-                       curr_packinfo->uiMaxBucketSize);
-
-       /* copy the extended SF Parameters to Support MIBS */
-       CopyMIBSExtendedSFParameters(Adapter, psfLocalSet, uiSearchRuleIndex);
-
-       /* store header suppression enabled flag per SF */
-       curr_packinfo->bHeaderSuppressionEnabled =
-               !(psfLocalSet->u8RequesttransmissionPolicy &
-                       MASK_DISABLE_HEADER_SUPPRESSION);
-
-       kfree(curr_packinfo->pstSFIndication);
-       curr_packinfo->pstSFIndication = pstAddIndication;
-
-       /* Re Sort the SF list in PackInfo according to Traffic Priority */
-       SortPackInfo(Adapter);
-
-       /* Re Sort the Classifier Rules table and re - arrange
-        * according to Classifier Rule Priority
-        */
-       SortClassifiers(Adapter);
-       DumpPhsRules(&Adapter->stBCMPhsContext);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "%s <=====", __func__);
-}
-
-/***********************************************************************
- * Function - DumpCmControlPacket
- *
- * Description - This routinue Dumps the Contents of the AddIndication
- *  Structure in the Connection Management Control Packet
- *
- * Parameter - pvBuffer: Pointer to the buffer containing the
- *  AddIndication data.
- *
- * Returns - None
- *************************************************************************/
-static VOID DumpCmControlPacket(PVOID pvBuffer)
-{
-       int uiLoopIndex;
-       int nIndex;
-       struct bcm_add_indication_alt *pstAddIndication;
-       UINT nCurClassifierCnt;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       pstAddIndication = pvBuffer;
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "======>");
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Type: 0x%X", pstAddIndication->u8Type);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Direction: 0x%X", pstAddIndication->u8Direction);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TID: 0x%X", ntohs(pstAddIndication->u16TID));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID: 0x%X", ntohs(pstAddIndication->u16CID));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16VCID: 0x%X", ntohs(pstAddIndication->u16VCID));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " AuthorizedSet--->");
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32SFID: 0x%X", htonl(pstAddIndication->sfAuthorizedSet.u32SFID));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID: 0x%X", htons(pstAddIndication->sfAuthorizedSet.u16CID));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassNameLength: 0x%X",
-                       pstAddIndication->sfAuthorizedSet.u8ServiceClassNameLength);
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassName: 0x%X ,0x%X , 0x%X, 0x%X, 0x%X, 0x%X",
-                       pstAddIndication->sfAuthorizedSet.u8ServiceClassName[0],
-                       pstAddIndication->sfAuthorizedSet.u8ServiceClassName[1],
-                       pstAddIndication->sfAuthorizedSet.u8ServiceClassName[2],
-                       pstAddIndication->sfAuthorizedSet.u8ServiceClassName[3],
-                       pstAddIndication->sfAuthorizedSet.u8ServiceClassName[4],
-                       pstAddIndication->sfAuthorizedSet.u8ServiceClassName[5]);
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8MBSService: 0x%X", pstAddIndication->sfAuthorizedSet.u8MBSService);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8QosParamSet: 0x%X", pstAddIndication->sfAuthorizedSet.u8QosParamSet);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority: 0x%X, %p",
-                       pstAddIndication->sfAuthorizedSet.u8TrafficPriority, &pstAddIndication->sfAuthorizedSet.u8TrafficPriority);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxSustainedTrafficRate: 0x%X 0x%p",
-                       pstAddIndication->sfAuthorizedSet.u32MaxSustainedTrafficRate,
-                       &pstAddIndication->sfAuthorizedSet.u32MaxSustainedTrafficRate);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst: 0x%X", pstAddIndication->sfAuthorizedSet.u32MaxTrafficBurst);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X",
-                       pstAddIndication->sfAuthorizedSet.u32MinReservedTrafficRate);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength: 0x%X",
-                       pstAddIndication->sfAuthorizedSet.u8VendorSpecificQoSParamLength);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam: 0x%X",
-                       pstAddIndication->sfAuthorizedSet.u8VendorSpecificQoSParam[0]);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceFlowSchedulingType: 0x%X",
-                       pstAddIndication->sfAuthorizedSet.u8ServiceFlowSchedulingType);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32ToleratedJitter: 0x%X", pstAddIndication->sfAuthorizedSet.u32ToleratedJitter);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaximumLatency: 0x%X", pstAddIndication->sfAuthorizedSet.u32MaximumLatency);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8FixedLengthVSVariableLengthSDUIndicator: 0x%X",
-                       pstAddIndication->sfAuthorizedSet.u8FixedLengthVSVariableLengthSDUIndicator);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8SDUSize: 0x%X", pstAddIndication->sfAuthorizedSet.u8SDUSize);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TargetSAID: 0x%X", pstAddIndication->sfAuthorizedSet.u16TargetSAID);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQEnable: 0x%X", pstAddIndication->sfAuthorizedSet.u8ARQEnable);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQWindowSize: 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQWindowSize);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryTxTimeOut: 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQRetryTxTimeOut);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryRxTimeOut: 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQRetryRxTimeOut);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockLifeTime: 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQBlockLifeTime);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQSyncLossTimeOut: 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQSyncLossTimeOut);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQDeliverInOrder: 0x%X", pstAddIndication->sfAuthorizedSet.u8ARQDeliverInOrder);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRxPurgeTimeOut: 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQRxPurgeTimeOut);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockSize: 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQBlockSize);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8CSSpecification: 0x%X", pstAddIndication->sfAuthorizedSet.u8CSSpecification);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TypeOfDataDeliveryService: 0x%X",
-                       pstAddIndication->sfAuthorizedSet.u8TypeOfDataDeliveryService);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16SDUInterArrivalTime: 0x%X", pstAddIndication->sfAuthorizedSet.u16SDUInterArrivalTime);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TimeBase: 0x%X", pstAddIndication->sfAuthorizedSet.u16TimeBase);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8PagingPreference: 0x%X", pstAddIndication->sfAuthorizedSet.u8PagingPreference);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16UnsolicitedPollingInterval: 0x%X",
-                       pstAddIndication->sfAuthorizedSet.u16UnsolicitedPollingInterval);
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "sfAuthorizedSet.u8HARQChannelMapping %x  %x %x ",
-                       *(unsigned int *)pstAddIndication->sfAuthorizedSet.u8HARQChannelMapping,
-                       *(unsigned int *)&pstAddIndication->sfAuthorizedSet.u8HARQChannelMapping[4],
-                       *(USHORT *)&pstAddIndication->sfAuthorizedSet.u8HARQChannelMapping[8]);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficIndicationPreference: 0x%X",
-                       pstAddIndication->sfAuthorizedSet.u8TrafficIndicationPreference);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " Total Classifiers Received: 0x%X", pstAddIndication->sfAuthorizedSet.u8TotalClassifiers);
-
-       nCurClassifierCnt = pstAddIndication->sfAuthorizedSet.u8TotalClassifiers;
-       if (nCurClassifierCnt > MAX_CLASSIFIERS_IN_SF)
-               nCurClassifierCnt = MAX_CLASSIFIERS_IN_SF;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL,  "pstAddIndication->sfAuthorizedSet.bValid %d", pstAddIndication->sfAuthorizedSet.bValid);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL,  "pstAddIndication->sfAuthorizedSet.u16MacOverhead %x", pstAddIndication->sfAuthorizedSet.u16MacOverhead);
-       if (!pstAddIndication->sfAuthorizedSet.bValid)
-               pstAddIndication->sfAuthorizedSet.bValid = 1;
-       for (nIndex = 0; nIndex < nCurClassifierCnt; nIndex++) {
-               struct bcm_convergence_types *psfCSType = NULL;
-
-               psfCSType =  &pstAddIndication->sfAuthorizedSet.cConvergenceSLTypes[nIndex];
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "psfCSType = %p", psfCSType);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "CCPacketClassificationRuleSI====>");
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ClassifierRulePriority: 0x%X ",
-                               psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL,  "u8IPTypeOfServiceLength: 0x%X ",
-                               psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPTypeOfService[3]: 0x%X ,0x%X ,0x%X ",
-                               psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0],
-                               psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1],
-                               psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]);
-
-               for (uiLoopIndex = 0; uiLoopIndex < 1; uiLoopIndex++)
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Protocol: 0x%02X ",
-                                       psfCSType->cCPacketClassificationRule.u8Protocol);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddressLength: 0x%X ",
-                               psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength);
-
-               for (uiLoopIndex = 0; uiLoopIndex < 32; uiLoopIndex++)
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddress[32]: 0x%02X ",
-                                       psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress[uiLoopIndex]);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddressLength: 0x%X ",
-                               psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength);
-
-               for (uiLoopIndex = 0; uiLoopIndex < 32; uiLoopIndex++)
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddress[32]: 0x%02X ",
-                                       psfCSType->cCPacketClassificationRule.u8IPDestinationAddress[uiLoopIndex]);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolSourcePortRangeLength:0x%X ",
-                               psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolSourcePortRange[4]: 0x%02X ,0x%02X ,0x%02X ,0x%02X ",
-                               psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[0],
-                               psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[1],
-                               psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[2],
-                               psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[3]);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRangeLength: 0x%02X ",
-                               psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRange[4]: 0x%02X ,0x%02X ,0x%02X ,0x%02X ",
-                               psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[0],
-                               psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[1],
-                               psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[2],
-                               psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[3]);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddressLength: 0x%02X ",
-                               psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL, "u8EthernetDestMacAddress[6]: %pM",
-                               psfCSType->cCPacketClassificationRule.
-                                               u8EthernetDestMacAddress);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddressLength: 0x%02X ",
-                               psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: %pM",
-                               psfCSType->cCPacketClassificationRule.
-                                               u8EthernetSourceMACAddress);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthertypeLength: 0x%02X ",
-                               psfCSType->cCPacketClassificationRule.u8EthertypeLength);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Ethertype[3]: 0x%02X ,0x%02X ,0x%02X ",
-                               psfCSType->cCPacketClassificationRule.u8Ethertype[0],
-                               psfCSType->cCPacketClassificationRule.u8Ethertype[1],
-                               psfCSType->cCPacketClassificationRule.u8Ethertype[2]);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16UserPriority: 0x%X ", psfCSType->cCPacketClassificationRule.u16UserPriority);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16VLANID: 0x%X ", psfCSType->cCPacketClassificationRule.u16VLANID);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8AssociatedPHSI: 0x%02X ", psfCSType->cCPacketClassificationRule.u8AssociatedPHSI);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16PacketClassificationRuleIndex: 0x%X ",
-                               psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParamLength: 0x%X ",
-                               psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParamLength);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParam[1]: 0x%X ",
-                               psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParam[0]);
-#ifdef VERSION_D5
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPv6FlowLableLength: 0x%X ",
-                               psfCSType->cCPacketClassificationRule.u8IPv6FlowLableLength);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL, "u8IPv6FlowLable[6]: 0x%*ph ",
-                               6, psfCSType->cCPacketClassificationRule.
-                                             u8IPv6FlowLable);
-#endif
-       }
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "bValid: 0x%02X", pstAddIndication->sfAuthorizedSet.bValid);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "AdmittedSet--->");
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32SFID: 0x%X", pstAddIndication->sfAdmittedSet.u32SFID);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID: 0x%X", pstAddIndication->sfAdmittedSet.u16CID);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassNameLength: 0x%X",
-                       pstAddIndication->sfAdmittedSet.u8ServiceClassNameLength);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL,
-                       "u8ServiceClassName: 0x%*ph",
-                       6, pstAddIndication->sfAdmittedSet.u8ServiceClassName);
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8MBSService: 0x%02X", pstAddIndication->sfAdmittedSet.u8MBSService);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8QosParamSet: 0x%02X", pstAddIndication->sfAdmittedSet.u8QosParamSet);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority: 0x%02X", pstAddIndication->sfAdmittedSet.u8TrafficPriority);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst: 0x%X", pstAddIndication->sfAdmittedSet.u32MaxTrafficBurst);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate: 0x%X",
-                       pstAddIndication->sfAdmittedSet.u32MinReservedTrafficRate);
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength: 0x%02X",
-                       pstAddIndication->sfAdmittedSet.u8VendorSpecificQoSParamLength);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam: 0x%02X",
-                       pstAddIndication->sfAdmittedSet.u8VendorSpecificQoSParam[0]);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceFlowSchedulingType: 0x%02X",
-                       pstAddIndication->sfAdmittedSet.u8ServiceFlowSchedulingType);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32ToleratedJitter: 0x%X", pstAddIndication->sfAdmittedSet.u32ToleratedJitter);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaximumLatency: 0x%X", pstAddIndication->sfAdmittedSet.u32MaximumLatency);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8FixedLengthVSVariableLengthSDUIndicator: 0x%02X",
-                       pstAddIndication->sfAdmittedSet.u8FixedLengthVSVariableLengthSDUIndicator);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8SDUSize: 0x%02X", pstAddIndication->sfAdmittedSet.u8SDUSize);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TargetSAID: 0x%02X", pstAddIndication->sfAdmittedSet.u16TargetSAID);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQEnable: 0x%02X", pstAddIndication->sfAdmittedSet.u8ARQEnable);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQWindowSize: 0x%X", pstAddIndication->sfAdmittedSet.u16ARQWindowSize);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryTxTimeOut: 0x%X", pstAddIndication->sfAdmittedSet.u16ARQRetryTxTimeOut);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryRxTimeOut: 0x%X", pstAddIndication->sfAdmittedSet.u16ARQRetryRxTimeOut);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockLifeTime: 0x%X", pstAddIndication->sfAdmittedSet.u16ARQBlockLifeTime);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQSyncLossTimeOut: 0x%X", pstAddIndication->sfAdmittedSet.u16ARQSyncLossTimeOut);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQDeliverInOrder: 0x%02X", pstAddIndication->sfAdmittedSet.u8ARQDeliverInOrder);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRxPurgeTimeOut: 0x%X", pstAddIndication->sfAdmittedSet.u16ARQRxPurgeTimeOut);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockSize: 0x%X", pstAddIndication->sfAdmittedSet.u16ARQBlockSize);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8CSSpecification: 0x%02X", pstAddIndication->sfAdmittedSet.u8CSSpecification);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TypeOfDataDeliveryService: 0x%02X",
-                       pstAddIndication->sfAdmittedSet.u8TypeOfDataDeliveryService);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16SDUInterArrivalTime: 0x%X", pstAddIndication->sfAdmittedSet.u16SDUInterArrivalTime);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TimeBase: 0x%X", pstAddIndication->sfAdmittedSet.u16TimeBase);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8PagingPreference: 0x%X", pstAddIndication->sfAdmittedSet.u8PagingPreference);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficIndicationPreference: 0x%02X",
-                       pstAddIndication->sfAdmittedSet.u8TrafficIndicationPreference);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " Total Classifiers Received: 0x%X", pstAddIndication->sfAdmittedSet.u8TotalClassifiers);
-
-       nCurClassifierCnt = pstAddIndication->sfAdmittedSet.u8TotalClassifiers;
-       if (nCurClassifierCnt > MAX_CLASSIFIERS_IN_SF)
-               nCurClassifierCnt = MAX_CLASSIFIERS_IN_SF;
-
-       for (nIndex = 0; nIndex < nCurClassifierCnt; nIndex++) {
-               struct bcm_convergence_types *psfCSType = NULL;
-
-               psfCSType =  &pstAddIndication->sfAdmittedSet.cConvergenceSLTypes[nIndex];
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " CCPacketClassificationRuleSI====>");
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ClassifierRulePriority: 0x%02X ",
-                               psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPTypeOfServiceLength: 0x%02X",
-                               psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL, "u8IPTypeOfService[3]: 0x%*ph",
-                               3, psfCSType->cCPacketClassificationRule.
-                                             u8IPTypeOfService);
-               for (uiLoopIndex = 0; uiLoopIndex < 1; uiLoopIndex++)
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Protocol: 0x%02X ", psfCSType->cCPacketClassificationRule.u8Protocol);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddressLength: 0x%02X ",
-                               psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength);
-
-               for (uiLoopIndex = 0; uiLoopIndex < 32; uiLoopIndex++)
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddress[32]: 0x%02X ",
-                                       psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress[uiLoopIndex]);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddressLength: 0x%02X ",
-                               psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength);
-
-               for (uiLoopIndex = 0; uiLoopIndex < 32; uiLoopIndex++)
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddress[32]: 0x%02X ",
-                                       psfCSType->cCPacketClassificationRule.u8IPDestinationAddress[uiLoopIndex]);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolSourcePortRangeLength: 0x%02X ",
-                               psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL, "u8ProtocolSourcePortRange[4]: 0x%*ph ",
-                               4, psfCSType->cCPacketClassificationRule.
-                                               u8ProtocolSourcePortRange);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRangeLength: 0x%02X ",
-                               psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL, "u8ProtocolDestPortRange[4]: 0x%*ph ",
-                               4, psfCSType->cCPacketClassificationRule.
-                                               u8ProtocolDestPortRange);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddressLength: 0x%02X ",
-                               psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL, "u8EthernetDestMacAddress[6]: %pM",
-                               psfCSType->cCPacketClassificationRule.
-                                               u8EthernetDestMacAddress);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddressLength: 0x%02X ",
-                               psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: %pM",
-                               psfCSType->cCPacketClassificationRule.
-                                               u8EthernetSourceMACAddress);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthertypeLength: 0x%02X ", psfCSType->cCPacketClassificationRule.u8EthertypeLength);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL, "u8Ethertype[3]: 0x%*ph",
-                               3, psfCSType->cCPacketClassificationRule.
-                                             u8Ethertype);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16UserPriority: 0x%X ", psfCSType->cCPacketClassificationRule.u16UserPriority);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16VLANID: 0x%X ", psfCSType->cCPacketClassificationRule.u16VLANID);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8AssociatedPHSI: 0x%02X ", psfCSType->cCPacketClassificationRule.u8AssociatedPHSI);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16PacketClassificationRuleIndex: 0x%X ",
-                               psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParamLength: 0x%02X",
-                               psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParamLength);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParam[1]: 0x%02X ",
-                               psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParam[0]);
-#ifdef VERSION_D5
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPv6FlowLableLength: 0x%X ",
-                               psfCSType->cCPacketClassificationRule.u8IPv6FlowLableLength);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL, "u8IPv6FlowLable[6]: 0x%*ph ",
-                               6, psfCSType->cCPacketClassificationRule.
-                                             u8IPv6FlowLable);
-#endif
-       }
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "bValid: 0x%X", pstAddIndication->sfAdmittedSet.bValid);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " ActiveSet--->");
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32SFID: 0x%X", pstAddIndication->sfActiveSet.u32SFID);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID: 0x%X", pstAddIndication->sfActiveSet.u16CID);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassNameLength: 0x%X", pstAddIndication->sfActiveSet.u8ServiceClassNameLength);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL,
-                       "u8ServiceClassName: 0x%*ph",
-                       6, pstAddIndication->sfActiveSet.u8ServiceClassName);
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8MBSService: 0x%02X", pstAddIndication->sfActiveSet.u8MBSService);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8QosParamSet: 0x%02X", pstAddIndication->sfActiveSet.u8QosParamSet);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority: 0x%02X", pstAddIndication->sfActiveSet.u8TrafficPriority);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst: 0x%X", pstAddIndication->sfActiveSet.u32MaxTrafficBurst);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate: 0x%X",
-                       pstAddIndication->sfActiveSet.u32MinReservedTrafficRate);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength: 0x%02X",
-                       pstAddIndication->sfActiveSet.u8VendorSpecificQoSParamLength);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam: 0x%02X",
-                       pstAddIndication->sfActiveSet.u8VendorSpecificQoSParam[0]);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceFlowSchedulingType: 0x%02X",
-                       pstAddIndication->sfActiveSet.u8ServiceFlowSchedulingType);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32ToleratedJitter: 0x%X", pstAddIndication->sfActiveSet.u32ToleratedJitter);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaximumLatency: 0x%X", pstAddIndication->sfActiveSet.u32MaximumLatency);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8FixedLengthVSVariableLengthSDUIndicator: 0x%02X",
-                       pstAddIndication->sfActiveSet.u8FixedLengthVSVariableLengthSDUIndicator);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8SDUSize: 0x%X", pstAddIndication->sfActiveSet.u8SDUSize);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16TargetSAID: 0x%X", pstAddIndication->sfActiveSet.u16TargetSAID);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ARQEnable: 0x%X", pstAddIndication->sfActiveSet.u8ARQEnable);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQWindowSize: 0x%X", pstAddIndication->sfActiveSet.u16ARQWindowSize);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQRetryTxTimeOut: 0x%X", pstAddIndication->sfActiveSet.u16ARQRetryTxTimeOut);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQRetryRxTimeOut: 0x%X", pstAddIndication->sfActiveSet.u16ARQRetryRxTimeOut);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQBlockLifeTime: 0x%X", pstAddIndication->sfActiveSet.u16ARQBlockLifeTime);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQSyncLossTimeOut: 0x%X", pstAddIndication->sfActiveSet.u16ARQSyncLossTimeOut);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ARQDeliverInOrder: 0x%X", pstAddIndication->sfActiveSet.u8ARQDeliverInOrder);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQRxPurgeTimeOut: 0x%X", pstAddIndication->sfActiveSet.u16ARQRxPurgeTimeOut);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQBlockSize: 0x%X", pstAddIndication->sfActiveSet.u16ARQBlockSize);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8CSSpecification: 0x%X", pstAddIndication->sfActiveSet.u8CSSpecification);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8TypeOfDataDeliveryService: 0x%X",
-                       pstAddIndication->sfActiveSet.u8TypeOfDataDeliveryService);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16SDUInterArrivalTime: 0x%X", pstAddIndication->sfActiveSet.u16SDUInterArrivalTime);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16TimeBase: 0x%X", pstAddIndication->sfActiveSet.u16TimeBase);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8PagingPreference: 0x%X", pstAddIndication->sfActiveSet.u8PagingPreference);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8TrafficIndicationPreference: 0x%X",
-                       pstAddIndication->sfActiveSet.u8TrafficIndicationPreference);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " Total Classifiers Received: 0x%X", pstAddIndication->sfActiveSet.u8TotalClassifiers);
-
-       nCurClassifierCnt = pstAddIndication->sfActiveSet.u8TotalClassifiers;
-       if (nCurClassifierCnt > MAX_CLASSIFIERS_IN_SF)
-               nCurClassifierCnt = MAX_CLASSIFIERS_IN_SF;
-
-       for (nIndex = 0; nIndex < nCurClassifierCnt; nIndex++)  {
-               struct bcm_convergence_types *psfCSType = NULL;
-               struct bcm_packet_class_rules *clsRule = NULL;
-
-               psfCSType = &pstAddIndication->sfActiveSet.cConvergenceSLTypes[nIndex];
-               clsRule = &psfCSType->cCPacketClassificationRule;
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL, " CCPacketClassificationRuleSI====>");
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL, " u8ClassifierRulePriority: 0x%X ",
-                               clsRule->u8ClassifierRulePriority);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL, " u8IPTypeOfServiceLength: 0x%X ",
-                               clsRule->u8IPTypeOfServiceLength);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL,
-                               " u8IPTypeOfService[3]: 0x%X ,0x%X ,0x%X ",
-                               clsRule->u8IPTypeOfService[0],
-                               clsRule->u8IPTypeOfService[1],
-                               clsRule->u8IPTypeOfService[2]);
-
-               for (uiLoopIndex = 0; uiLoopIndex < 1; uiLoopIndex++)
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                                       DBG_LVL_ALL,
-                                       " u8Protocol: 0x%X ",
-                                       clsRule->u8Protocol);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL,
-                               "u8IPMaskedSourceAddressLength: 0x%X ",
-                               clsRule->u8IPMaskedSourceAddressLength);
-
-               for (uiLoopIndex = 0; uiLoopIndex < 32; uiLoopIndex++)
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                                       DBG_LVL_ALL,
-                                       "u8IPMaskedSourceAddress[32]: 0x%X ",
-                                       clsRule->u8IPMaskedSourceAddress[uiLoopIndex]);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL,
-                               "u8IPDestinationAddressLength: 0x%02X ",
-                               clsRule->u8IPDestinationAddressLength);
-
-               for (uiLoopIndex = 0; uiLoopIndex < 32; uiLoopIndex++)
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                                       DBG_LVL_ALL,
-                                       " u8IPDestinationAddress[32]:0x%X ",
-                                       clsRule->u8IPDestinationAddress[uiLoopIndex]);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL,
-                               " u8ProtocolSourcePortRangeLength: 0x%X ",
-                               clsRule->u8ProtocolSourcePortRangeLength);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL,
-                               " u8ProtocolSourcePortRange[4]: 0x%X ,0x%X ,0x%X ,0x%X ",
-                               clsRule->u8ProtocolSourcePortRange[0],
-                               clsRule->u8ProtocolSourcePortRange[1],
-                               clsRule->u8ProtocolSourcePortRange[2],
-                               clsRule->u8ProtocolSourcePortRange[3]);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL,
-                               " u8ProtocolDestPortRangeLength: 0x%X ",
-                               clsRule->u8ProtocolDestPortRangeLength);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL,
-                               " u8ProtocolDestPortRange[4]: 0x%X ,0x%X ,0x%X ,0x%X ",
-                               clsRule->u8ProtocolDestPortRange[0],
-                               clsRule->u8ProtocolDestPortRange[1],
-                               clsRule->u8ProtocolDestPortRange[2],
-                               clsRule->u8ProtocolDestPortRange[3]);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL,
-                               " u8EthernetDestMacAddressLength: 0x%X ",
-                               clsRule->u8EthernetDestMacAddressLength);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL,
-                               " u8EthernetDestMacAddress[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X",
-                               clsRule->u8EthernetDestMacAddress[0],
-                               clsRule->u8EthernetDestMacAddress[1],
-                               clsRule->u8EthernetDestMacAddress[2],
-                               clsRule->u8EthernetDestMacAddress[3],
-                               clsRule->u8EthernetDestMacAddress[4],
-                               clsRule->u8EthernetDestMacAddress[5]);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL,
-                               " u8EthernetSourceMACAddressLength: 0x%X ",
-                               clsRule->u8EthernetDestMacAddressLength);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL,
-                               "u8EthernetSourceMACAddress[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X",
-                               clsRule->u8EthernetSourceMACAddress[0],
-                               clsRule->u8EthernetSourceMACAddress[1],
-                               clsRule->u8EthernetSourceMACAddress[2],
-                               clsRule->u8EthernetSourceMACAddress[3],
-                               clsRule->u8EthernetSourceMACAddress[4],
-                               clsRule->u8EthernetSourceMACAddress[5]);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL, " u8EthertypeLength: 0x%X ",
-                               clsRule->u8EthertypeLength);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL,
-                               " u8Ethertype[3]: 0x%X ,0x%X ,0x%X ",
-                               clsRule->u8Ethertype[0],
-                               clsRule->u8Ethertype[1],
-                               clsRule->u8Ethertype[2]);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL, " u16UserPriority: 0x%X ",
-                               clsRule->u16UserPriority);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL, " u16VLANID: 0x%X ",
-                               clsRule->u16VLANID);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL, " u8AssociatedPHSI: 0x%X ",
-                               clsRule->u8AssociatedPHSI);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL,
-                               " u16PacketClassificationRuleIndex:0x%X ",
-                               clsRule->u16PacketClassificationRuleIndex);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL,
-                               " u8VendorSpecificClassifierParamLength:0x%X ",
-                               clsRule->u8VendorSpecificClassifierParamLength);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL,
-                               " u8VendorSpecificClassifierParam[1]:0x%X ",
-                               clsRule->u8VendorSpecificClassifierParam[0]);
-#ifdef VERSION_D5
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL, " u8IPv6FlowLableLength: 0x%X ",
-                               clsRule->u8IPv6FlowLableLength);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
-                               DBG_LVL_ALL,
-                               " u8IPv6FlowLable[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X ",
-                               clsRule->u8IPv6FlowLable[0],
-                               clsRule->u8IPv6FlowLable[1],
-                               clsRule->u8IPv6FlowLable[2],
-                               clsRule->u8IPv6FlowLable[3],
-                               clsRule->u8IPv6FlowLable[4],
-                               clsRule->u8IPv6FlowLable[5]);
-#endif
-       }
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL,
-                       " bValid: 0x%X", pstAddIndication->sfActiveSet.bValid);
-}
-
-static inline ULONG RestoreSFParam(struct bcm_mini_adapter *Adapter,
-               ULONG ulAddrSFParamSet, PUCHAR pucDestBuffer)
-{
-       UINT  nBytesToRead = sizeof(struct bcm_connect_mgr_params);
-
-       if (ulAddrSFParamSet == 0 || NULL == pucDestBuffer) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                               "Got Param address as 0!!");
-               return 0;
-       }
-       ulAddrSFParamSet = ntohl(ulAddrSFParamSet);
-
-       /* Read out the SF Param Set At the indicated Location */
-       if (rdm(Adapter, ulAddrSFParamSet, (PUCHAR)pucDestBuffer, nBytesToRead) < 0)
-               return STATUS_FAILURE;
-
-       return 1;
-}
-
-static ULONG StoreSFParam(struct bcm_mini_adapter *Adapter, PUCHAR pucSrcBuffer,
-               ULONG ulAddrSFParamSet)
-{
-       UINT nBytesToWrite = sizeof(struct bcm_connect_mgr_params);
-       int ret = 0;
-
-       if (ulAddrSFParamSet == 0 || NULL == pucSrcBuffer)
-               return 0;
-
-       ret = wrm(Adapter, ulAddrSFParamSet, (u8 *)pucSrcBuffer, nBytesToWrite);
-       if (ret < 0) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                               "%s:%d WRM failed", __func__, __LINE__);
-               return ret;
-       }
-       return 1;
-}
-
-ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter,
-               PVOID pvBuffer, UINT *puBufferLength)
-{
-       struct bcm_add_indication_alt *pstAddIndicationAlt = NULL;
-       struct bcm_add_indication *pstAddIndication = NULL;
-       struct bcm_del_request *pstDeletionRequest;
-       UINT uiSearchRuleIndex;
-       ULONG ulSFID;
-
-       pstAddIndicationAlt = pvBuffer;
-
-       /*
-        * In case of DSD Req By MS, we should immediately delete this SF so that
-        * we can stop the further classifying the pkt for this SF.
-        */
-       if (pstAddIndicationAlt->u8Type == DSD_REQ) {
-               pstDeletionRequest = pvBuffer;
-
-               ulSFID = ntohl(pstDeletionRequest->u32SFID);
-               uiSearchRuleIndex = SearchSfid(Adapter, ulSFID);
-
-               if (uiSearchRuleIndex < NO_OF_QUEUES) {
-                       deleteSFBySfid(Adapter, uiSearchRuleIndex);
-                       Adapter->u32TotalDSD++;
-               }
-               return 1;
-       }
-
-       if ((pstAddIndicationAlt->u8Type == DSD_RSP) ||
-               (pstAddIndicationAlt->u8Type == DSD_ACK)) {
-               /* No Special handling send the message as it is */
-               return 1;
-       }
-       /* For DSA_REQ, only up to "psfAuthorizedSet" parameter should be accessed by driver! */
-
-       pstAddIndication = kmalloc(sizeof(struct bcm_add_indication),
-                       GFP_KERNEL);
-       if (pstAddIndication == NULL)
-               return 0;
-
-       /* AUTHORIZED SET */
-       pstAddIndication->psfAuthorizedSet = (struct bcm_connect_mgr_params *)
-                       GetNextTargetBufferLocation(Adapter,
-                                       pstAddIndicationAlt->u16TID);
-       if (!pstAddIndication->psfAuthorizedSet) {
-               kfree(pstAddIndication);
-               return 0;
-       }
-
-       if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfAuthorizedSet,
-                               (ULONG)pstAddIndication->psfAuthorizedSet) != 1) {
-               kfree(pstAddIndication);
-               return 0;
-       }
-
-       /* this can't possibly be right */
-       pstAddIndication->psfAuthorizedSet =
-               (struct bcm_connect_mgr_params *) ntohl(
-                               (ULONG)pstAddIndication->psfAuthorizedSet);
-
-       if (pstAddIndicationAlt->u8Type == DSA_REQ) {
-               struct bcm_add_request AddRequest;
-
-               AddRequest.u8Type = pstAddIndicationAlt->u8Type;
-               AddRequest.eConnectionDir = pstAddIndicationAlt->u8Direction;
-               AddRequest.u16TID = pstAddIndicationAlt->u16TID;
-               AddRequest.u16CID = pstAddIndicationAlt->u16CID;
-               AddRequest.u16VCID = pstAddIndicationAlt->u16VCID;
-               AddRequest.psfParameterSet = pstAddIndication->psfAuthorizedSet;
-               (*puBufferLength) = sizeof(struct bcm_add_request);
-               memcpy(pvBuffer, &AddRequest, sizeof(struct bcm_add_request));
-               kfree(pstAddIndication);
-               return 1;
-       }
-
-       /* Since it's not DSA_REQ, we can access all field in pstAddIndicationAlt */
-       /* We need to extract the structure from the buffer and pack it differently */
-
-       pstAddIndication->u8Type = pstAddIndicationAlt->u8Type;
-       pstAddIndication->eConnectionDir = pstAddIndicationAlt->u8Direction;
-       pstAddIndication->u16TID = pstAddIndicationAlt->u16TID;
-       pstAddIndication->u16CID = pstAddIndicationAlt->u16CID;
-       pstAddIndication->u16VCID = pstAddIndicationAlt->u16VCID;
-       pstAddIndication->u8CC = pstAddIndicationAlt->u8CC;
-
-       /* ADMITTED SET */
-       pstAddIndication->psfAdmittedSet = (struct bcm_connect_mgr_params *)
-               GetNextTargetBufferLocation(Adapter,
-                               pstAddIndicationAlt->u16TID);
-       if (!pstAddIndication->psfAdmittedSet) {
-               kfree(pstAddIndication);
-               return 0;
-       }
-       if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfAdmittedSet,
-                               (ULONG)pstAddIndication->psfAdmittedSet) != 1) {
-               kfree(pstAddIndication);
-               return 0;
-       }
-
-       pstAddIndication->psfAdmittedSet =
-               (struct bcm_connect_mgr_params *) ntohl(
-                               (ULONG) pstAddIndication->psfAdmittedSet);
-
-       /* ACTIVE SET */
-       pstAddIndication->psfActiveSet = (struct bcm_connect_mgr_params *)
-               GetNextTargetBufferLocation(Adapter,
-                               pstAddIndicationAlt->u16TID);
-       if (!pstAddIndication->psfActiveSet) {
-               kfree(pstAddIndication);
-               return 0;
-       }
-       if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfActiveSet,
-                               (ULONG)pstAddIndication->psfActiveSet) != 1) {
-               kfree(pstAddIndication);
-               return 0;
-       }
-
-       pstAddIndication->psfActiveSet =
-               (struct bcm_connect_mgr_params *) ntohl(
-                               (ULONG)pstAddIndication->psfActiveSet);
-
-       (*puBufferLength) = sizeof(struct bcm_add_indication);
-       *(struct bcm_add_indication *)pvBuffer = *pstAddIndication;
-       kfree(pstAddIndication);
-       return 1;
-}
-
-static inline struct bcm_add_indication_alt
-*RestoreCmControlResponseMessage(register struct bcm_mini_adapter *Adapter,
-               register PVOID pvBuffer)
-{
-       ULONG ulStatus = 0;
-       struct bcm_add_indication *pstAddIndication = NULL;
-       struct bcm_add_indication_alt *pstAddIndicationDest = NULL;
-
-       pstAddIndication = pvBuffer;
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "=====>");
-       if ((pstAddIndication->u8Type == DSD_REQ) ||
-               (pstAddIndication->u8Type == DSD_RSP) ||
-               (pstAddIndication->u8Type == DSD_ACK))
-               return pvBuffer;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "Inside RestoreCmControlResponseMessage ");
-       /*
-        * Need to Allocate memory to contain the SUPER Large structures
-        * Our driver can't create these structures on Stack :(
-        */
-       pstAddIndicationDest = kmalloc(sizeof(struct bcm_add_indication_alt),
-                       GFP_KERNEL);
-
-       if (pstAddIndicationDest) {
-               memset(pstAddIndicationDest, 0,
-                               sizeof(struct bcm_add_indication_alt));
-       } else {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG,
-                               DBG_LVL_ALL,
-                               "Failed to allocate memory for SF Add Indication Structure ");
-               return NULL;
-       }
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "AddIndication-u8Type : 0x%X",
-                       pstAddIndication->u8Type);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "AddIndication-u8Direction : 0x%X",
-                       pstAddIndication->eConnectionDir);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "AddIndication-u8TID : 0x%X",
-                       ntohs(pstAddIndication->u16TID));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "AddIndication-u8CID : 0x%X",
-                       ntohs(pstAddIndication->u16CID));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "AddIndication-u16VCID : 0x%X",
-                       ntohs(pstAddIndication->u16VCID));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "AddIndication-autorized set loc : %p",
-                       pstAddIndication->psfAuthorizedSet);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "AddIndication-admitted set loc : %p",
-                       pstAddIndication->psfAdmittedSet);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "AddIndication-Active set loc : %p",
-                       pstAddIndication->psfActiveSet);
-
-       pstAddIndicationDest->u8Type = pstAddIndication->u8Type;
-       pstAddIndicationDest->u8Direction = pstAddIndication->eConnectionDir;
-       pstAddIndicationDest->u16TID = pstAddIndication->u16TID;
-       pstAddIndicationDest->u16CID = pstAddIndication->u16CID;
-       pstAddIndicationDest->u16VCID = pstAddIndication->u16VCID;
-       pstAddIndicationDest->u8CC = pstAddIndication->u8CC;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "Restoring Active Set ");
-       ulStatus = RestoreSFParam(Adapter,
-                       (ULONG)pstAddIndication->psfActiveSet,
-                       (PUCHAR)&pstAddIndicationDest->sfActiveSet);
-       if (ulStatus != 1)
-               goto failed_restore_sf_param;
-
-       if (pstAddIndicationDest->sfActiveSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF)
-               pstAddIndicationDest->sfActiveSet.u8TotalClassifiers =
-                       MAX_CLASSIFIERS_IN_SF;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "Restoring Admitted Set ");
-       ulStatus = RestoreSFParam(Adapter,
-                       (ULONG)pstAddIndication->psfAdmittedSet,
-                       (PUCHAR)&pstAddIndicationDest->sfAdmittedSet);
-       if (ulStatus != 1)
-               goto failed_restore_sf_param;
-
-       if (pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF)
-               pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers =
-                       MAX_CLASSIFIERS_IN_SF;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "Restoring Authorized Set ");
-       ulStatus = RestoreSFParam(Adapter,
-                       (ULONG)pstAddIndication->psfAuthorizedSet,
-                       (PUCHAR)&pstAddIndicationDest->sfAuthorizedSet);
-       if (ulStatus != 1)
-               goto failed_restore_sf_param;
-
-       if (pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF)
-               pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers =
-                       MAX_CLASSIFIERS_IN_SF;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "Dumping the whole raw packet");
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-               "============================================================");
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       " pstAddIndicationDest->sfActiveSet size  %zx %p",
-                       sizeof(*pstAddIndicationDest), pstAddIndicationDest);
-       /* BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, CONN_MSG,
-        *              DBG_LVL_ALL, (unsigned char *)pstAddIndicationDest,
-        *              sizeof(*pstAddIndicationDest));
-        */
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "============================================================");
-       return pstAddIndicationDest;
-failed_restore_sf_param:
-       kfree(pstAddIndicationDest);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "<=====");
-       return NULL;
-}
-
-ULONG SetUpTargetDsxBuffers(struct bcm_mini_adapter *Adapter)
-{
-       ULONG ulTargetDsxBuffersBase = 0;
-       ULONG ulCntTargetBuffers;
-       ULONG i;
-       int Status;
-
-       if (!Adapter) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                               "Adapter was NULL!!!");
-               return 0;
-       }
-
-       if (Adapter->astTargetDsxBuffer[0].ulTargetDsxBuffer)
-               return 1;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "Size of Each DSX Buffer(Also size of connection manager parameters): %zx ",
-                       sizeof(struct bcm_connect_mgr_params));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "Reading DSX buffer From Target location %x ",
-                       DSX_MESSAGE_EXCHANGE_BUFFER);
-
-       Status = rdmalt(Adapter, DSX_MESSAGE_EXCHANGE_BUFFER,
-                       (PUINT)&ulTargetDsxBuffersBase, sizeof(UINT));
-       if (Status < 0) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                               "RDM failed!!");
-               return 0;
-       }
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "Base Address Of DSX  Target Buffer : 0x%lx",
-                       ulTargetDsxBuffersBase);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "Tgt Buffer is Now %lx :", ulTargetDsxBuffersBase);
-       ulCntTargetBuffers = DSX_MESSAGE_EXCHANGE_BUFFER_SIZE /
-               sizeof(struct bcm_connect_mgr_params);
-
-       Adapter->ulTotalTargetBuffersAvailable =
-               ulCntTargetBuffers > MAX_TARGET_DSX_BUFFERS ?
-               MAX_TARGET_DSX_BUFFERS : ulCntTargetBuffers;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       " Total Target DSX Buffer setup %lx ",
-                       Adapter->ulTotalTargetBuffersAvailable);
-
-       for (i = 0; i < Adapter->ulTotalTargetBuffersAvailable; i++) {
-               Adapter->astTargetDsxBuffer[i].ulTargetDsxBuffer = ulTargetDsxBuffersBase;
-               Adapter->astTargetDsxBuffer[i].valid = 1;
-               Adapter->astTargetDsxBuffer[i].tid = 0;
-               ulTargetDsxBuffersBase += sizeof(struct bcm_connect_mgr_params);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "  Target DSX Buffer %lx setup at 0x%lx",
-                               i, Adapter->astTargetDsxBuffer[i].ulTargetDsxBuffer);
-       }
-       Adapter->ulCurrentTargetBuffer = 0;
-       Adapter->ulFreeTargetBufferCnt = Adapter->ulTotalTargetBuffersAvailable;
-       return 1;
-}
-
-static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter,
-               B_UINT16 tid)
-{
-       ULONG dsx_buf;
-       ULONG idx, max_try;
-
-       if ((Adapter->ulTotalTargetBuffersAvailable == 0)
-                       || (Adapter->ulFreeTargetBufferCnt == 0)) {
-               ClearTargetDSXBuffer(Adapter, tid, false);
-               return 0;
-       }
-
-       idx = Adapter->ulCurrentTargetBuffer;
-       max_try = Adapter->ulTotalTargetBuffersAvailable;
-       while ((max_try) && (Adapter->astTargetDsxBuffer[idx].valid != 1)) {
-               idx = (idx+1) % Adapter->ulTotalTargetBuffersAvailable;
-               max_try--;
-       }
-
-       if (max_try == 0) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,
-                               "\n GetNextTargetBufferLocation : Error No Free Target DSX Buffers FreeCnt : %lx ",
-                               Adapter->ulFreeTargetBufferCnt);
-               ClearTargetDSXBuffer(Adapter, tid, false);
-               return 0;
-       }
-
-       dsx_buf = Adapter->astTargetDsxBuffer[idx].ulTargetDsxBuffer;
-       Adapter->astTargetDsxBuffer[idx].valid = 0;
-       Adapter->astTargetDsxBuffer[idx].tid = tid;
-       Adapter->ulFreeTargetBufferCnt--;
-       idx = (idx+1)%Adapter->ulTotalTargetBuffersAvailable;
-       Adapter->ulCurrentTargetBuffer = idx;
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,
-                       "GetNextTargetBufferLocation :Returning address %lx tid %d\n",
-                       dsx_buf, tid);
-
-       return dsx_buf;
-}
-
-int AllocAdapterDsxBuffer(struct bcm_mini_adapter *Adapter)
-{
-       /*
-        * Need to Allocate memory to contain the SUPER Large structures
-        * Our driver can't create these structures on Stack
-        */
-       Adapter->caDsxReqResp = kmalloc(sizeof(struct bcm_add_indication_alt)
-                       + LEADER_SIZE, GFP_KERNEL);
-       if (!Adapter->caDsxReqResp)
-               return -ENOMEM;
-
-       return 0;
-}
-
-int FreeAdapterDsxBuffer(struct bcm_mini_adapter *Adapter)
-{
-       kfree(Adapter->caDsxReqResp);
-       return 0;
-}
-
-/*
- * @ingroup ctrl_pkt_functions
- * This routinue would process the Control responses
- * for the Connection Management.
- * @return - Queue index for the free SFID else returns Invalid Index.
- */
-bool CmControlResponseMessage(struct bcm_mini_adapter *Adapter,  /* <Pointer to the Adapter structure */
-                               PVOID pvBuffer /* Starting Address of the Buffer, that contains the AddIndication Data */)
-{
-       struct bcm_connect_mgr_params *psfLocalSet = NULL;
-       struct bcm_add_indication_alt *pstAddIndication = NULL;
-       struct bcm_change_indication *pstChangeIndication = NULL;
-       struct bcm_leader *pLeader = NULL;
-       INT uiSearchRuleIndex = 0;
-       ULONG ulSFID;
-
-       /*
-        * Otherwise the message contains a target address from where we need to
-        * read out the rest of the service flow param structure
-        */
-       pstAddIndication = RestoreCmControlResponseMessage(Adapter, pvBuffer);
-       if (pstAddIndication == NULL) {
-               ClearTargetDSXBuffer(Adapter, ((struct bcm_add_indication *)pvBuffer)->u16TID, false);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Error in restoring Service Flow param structure from DSx message");
-               return false;
-       }
-
-       DumpCmControlPacket(pstAddIndication);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "====>");
-       pLeader = (struct bcm_leader *)Adapter->caDsxReqResp;
-
-       pLeader->Status = CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ;
-       pLeader->Vcid = 0;
-
-       ClearTargetDSXBuffer(Adapter, pstAddIndication->u16TID, false);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "### TID RECEIVED %d\n", pstAddIndication->u16TID);
-       switch (pstAddIndication->u8Type) {
-       case DSA_REQ:
-               pLeader->PLength = sizeof(struct bcm_add_indication_alt);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Sending DSA Response....\n");
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSA RESPONSE TO MAC %d", pLeader->PLength);
-               *((struct bcm_add_indication_alt *)&(Adapter->caDsxReqResp[LEADER_SIZE]))
-                       = *pstAddIndication;
-               ((struct bcm_add_indication_alt *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSA_RSP;
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " VCID = %x", ntohs(pstAddIndication->u16VCID));
-               CopyBufferToControlPacket(Adapter, (PVOID)Adapter->caDsxReqResp);
-               kfree(pstAddIndication);
-               break;
-       case DSA_RSP:
-               pLeader->PLength = sizeof(struct bcm_add_indication_alt);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSA ACK TO MAC %d",
-                               pLeader->PLength);
-               *((struct bcm_add_indication_alt *)&(Adapter->caDsxReqResp[LEADER_SIZE]))
-                       = *pstAddIndication;
-               ((struct bcm_add_indication_alt *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSA_ACK;
-               /* FALLTHROUGH */
-       case DSA_ACK:
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "VCID:0x%X",
-                               ntohs(pstAddIndication->u16VCID));
-               uiSearchRuleIndex = SearchFreeSfid(Adapter);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "uiSearchRuleIndex:0x%X ",
-                               uiSearchRuleIndex);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Direction:0x%X ",
-                               pstAddIndication->u8Direction);
-               if (uiSearchRuleIndex < NO_OF_QUEUES) {
-                       Adapter->PackInfo[uiSearchRuleIndex].ucDirection =
-                               pstAddIndication->u8Direction;
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "bValid:0x%X ",
-                                       pstAddIndication->sfActiveSet.bValid);
-                       if (pstAddIndication->sfActiveSet.bValid == TRUE)
-                               Adapter->PackInfo[uiSearchRuleIndex].bActiveSet = TRUE;
-
-                       if (pstAddIndication->sfAuthorizedSet.bValid == TRUE)
-                               Adapter->PackInfo[uiSearchRuleIndex].bAuthorizedSet = TRUE;
-
-                       if (pstAddIndication->sfAdmittedSet.bValid == TRUE)
-                               Adapter->PackInfo[uiSearchRuleIndex].bAdmittedSet = TRUE;
-
-                       if (pstAddIndication->sfActiveSet.bValid == false) {
-                               Adapter->PackInfo[uiSearchRuleIndex].bActive = false;
-                               Adapter->PackInfo[uiSearchRuleIndex].bActivateRequestSent = false;
-                               if (pstAddIndication->sfAdmittedSet.bValid)
-                                       psfLocalSet = &pstAddIndication->sfAdmittedSet;
-                               else if (pstAddIndication->sfAuthorizedSet.bValid)
-                                       psfLocalSet = &pstAddIndication->sfAuthorizedSet;
-                       } else {
-                               psfLocalSet = &pstAddIndication->sfActiveSet;
-                               Adapter->PackInfo[uiSearchRuleIndex].bActive = TRUE;
-                       }
-
-                       if (!psfLocalSet) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "No set is valid\n");
-                               Adapter->PackInfo[uiSearchRuleIndex].bActive = false;
-                               Adapter->PackInfo[uiSearchRuleIndex].bValid = false;
-                               Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = 0;
-                               kfree(pstAddIndication);
-                       } else if (psfLocalSet->bValid && (pstAddIndication->u8CC == 0)) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "DSA ACK");
-                               Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = ntohs(pstAddIndication->u16VCID);
-                               Adapter->PackInfo[uiSearchRuleIndex].usCID = ntohs(pstAddIndication->u16CID);
-
-                               if (UPLINK_DIR == pstAddIndication->u8Direction)
-                                       atomic_set(&Adapter->PackInfo[uiSearchRuleIndex].uiPerSFTxResourceCount, DEFAULT_PERSFCOUNT);
-
-                               CopyToAdapter(Adapter, psfLocalSet, uiSearchRuleIndex, DSA_ACK, pstAddIndication);
-                               /* don't free pstAddIndication */
-
-                               /* Inside CopyToAdapter, Sorting of all the SFs take place.
-                                * Hence any access to the newly added SF through uiSearchRuleIndex is invalid.
-                                * SHOULD BE STRICTLY AVOIDED.
-                                */
-                               /* *(PULONG)(((PUCHAR)pvBuffer)+1)=psfLocalSet->u32SFID; */
-                               memcpy((((PUCHAR)pvBuffer)+1), &psfLocalSet->u32SFID, 4);
-
-                               if (pstAddIndication->sfActiveSet.bValid == TRUE) {
-                                       if (UPLINK_DIR == pstAddIndication->u8Direction) {
-                                               if (!Adapter->LinkUpStatus) {
-                                                       netif_carrier_on(Adapter->dev);
-                                                       netif_start_queue(Adapter->dev);
-                                                       Adapter->LinkUpStatus = 1;
-                                                       if (netif_msg_link(Adapter))
-                                                               pr_info(PFX "%s: link up\n", Adapter->dev->name);
-                                                       atomic_set(&Adapter->TxPktAvail, 1);
-                                                       wake_up(&Adapter->tx_packet_wait_queue);
-                                                       Adapter->liTimeSinceLastNetEntry = get_seconds();
-                                               }
-                                       }
-                               }
-                       } else {
-                               Adapter->PackInfo[uiSearchRuleIndex].bActive = false;
-                               Adapter->PackInfo[uiSearchRuleIndex].bValid = false;
-                               Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = 0;
-                               kfree(pstAddIndication);
-                       }
-               } else {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "DSA ACK did not get valid SFID");
-                       kfree(pstAddIndication);
-                       return false;
-               }
-               break;
-       case DSC_REQ:
-               pLeader->PLength = sizeof(struct bcm_change_indication);
-               pstChangeIndication = (struct bcm_change_indication *)pstAddIndication;
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSC RESPONSE TO MAC %d", pLeader->PLength);
-
-               *((struct bcm_change_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstChangeIndication;
-               ((struct bcm_change_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSC_RSP;
-
-               CopyBufferToControlPacket(Adapter, (PVOID)Adapter->caDsxReqResp);
-               kfree(pstAddIndication);
-               break;
-       case DSC_RSP:
-               pLeader->PLength = sizeof(struct bcm_change_indication);
-               pstChangeIndication = (struct bcm_change_indication *)pstAddIndication;
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSC ACK TO MAC %d", pLeader->PLength);
-               *((struct bcm_change_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstChangeIndication;
-               ((struct bcm_change_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSC_ACK;
-               /* FALLTHROUGH */
-       case DSC_ACK:
-               pstChangeIndication = (struct bcm_change_indication *)pstAddIndication;
-               uiSearchRuleIndex = SearchSfid(Adapter, ntohl(pstChangeIndication->sfActiveSet.u32SFID));
-               if (uiSearchRuleIndex > NO_OF_QUEUES-1)
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "SF doesn't exist for which DSC_ACK is received");
-
-               if (uiSearchRuleIndex < NO_OF_QUEUES) {
-                       Adapter->PackInfo[uiSearchRuleIndex].ucDirection = pstChangeIndication->u8Direction;
-                       if (pstChangeIndication->sfActiveSet.bValid == TRUE)
-                               Adapter->PackInfo[uiSearchRuleIndex].bActiveSet = TRUE;
-
-                       if (pstChangeIndication->sfAuthorizedSet.bValid == TRUE)
-                               Adapter->PackInfo[uiSearchRuleIndex].bAuthorizedSet = TRUE;
-
-                       if (pstChangeIndication->sfAdmittedSet.bValid == TRUE)
-                               Adapter->PackInfo[uiSearchRuleIndex].bAdmittedSet = TRUE;
-
-                       if (pstChangeIndication->sfActiveSet.bValid == false) {
-                               Adapter->PackInfo[uiSearchRuleIndex].bActive = false;
-                               Adapter->PackInfo[uiSearchRuleIndex].bActivateRequestSent = false;
-
-                               if (pstChangeIndication->sfAdmittedSet.bValid)
-                                       psfLocalSet = &pstChangeIndication->sfAdmittedSet;
-                               else if (pstChangeIndication->sfAuthorizedSet.bValid)
-                                       psfLocalSet = &pstChangeIndication->sfAuthorizedSet;
-                       } else {
-                               psfLocalSet = &pstChangeIndication->sfActiveSet;
-                               Adapter->PackInfo[uiSearchRuleIndex].bActive = TRUE;
-                       }
-
-                       if (!psfLocalSet) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "No set is valid\n");
-                               Adapter->PackInfo[uiSearchRuleIndex].bActive = false;
-                               Adapter->PackInfo[uiSearchRuleIndex].bValid = false;
-                               Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = 0;
-                               kfree(pstAddIndication);
-                       } else if (psfLocalSet->bValid && (pstChangeIndication->u8CC == 0)) {
-                               Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = ntohs(pstChangeIndication->u16VCID);
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "CC field is %d bvalid = %d\n",
-                                               pstChangeIndication->u8CC, psfLocalSet->bValid);
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "VCID= %d\n", ntohs(pstChangeIndication->u16VCID));
-                               Adapter->PackInfo[uiSearchRuleIndex].usCID = ntohs(pstChangeIndication->u16CID);
-                               CopyToAdapter(Adapter, psfLocalSet, uiSearchRuleIndex, DSC_ACK, pstAddIndication);
-
-                               *(PULONG)(((PUCHAR)pvBuffer)+1) = psfLocalSet->u32SFID;
-                       } else if (pstChangeIndication->u8CC == 6) {
-                               deleteSFBySfid(Adapter, uiSearchRuleIndex);
-                               kfree(pstAddIndication);
-                       }
-               } else {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "DSC ACK did not get valid SFID");
-                       kfree(pstAddIndication);
-                       return false;
-               }
-               break;
-       case DSD_REQ:
-               pLeader->PLength = sizeof(struct bcm_del_indication);
-               *((struct bcm_del_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *((struct bcm_del_indication *)pstAddIndication);
-
-               ulSFID = ntohl(((struct bcm_del_indication *)pstAddIndication)->u32SFID);
-               uiSearchRuleIndex = SearchSfid(Adapter, ulSFID);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "DSD - Removing connection %x", uiSearchRuleIndex);
-
-               if (uiSearchRuleIndex < NO_OF_QUEUES) {
-                       /* Delete All Classifiers Associated with this SFID */
-                       deleteSFBySfid(Adapter, uiSearchRuleIndex);
-                       Adapter->u32TotalDSD++;
-               }
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSD RESPONSE TO MAC");
-               ((struct bcm_del_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSD_RSP;
-               CopyBufferToControlPacket(Adapter, (PVOID)Adapter->caDsxReqResp);
-               /* FALLTHROUGH */
-       case DSD_RSP:
-               /* Do nothing as SF has already got Deleted */
-               break;
-       case DSD_ACK:
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "DSD ACK Rcd, let App handle it\n");
-               break;
-       default:
-               kfree(pstAddIndication);
-               return false;
-       }
-       return TRUE;
-}
-
-int get_dsx_sf_data_to_application(struct bcm_mini_adapter *Adapter,
-               UINT uiSFId, void __user *user_buffer)
-{
-       int status = 0;
-       struct bcm_packet_info *psSfInfo = NULL;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "status =%d", status);
-       status = SearchSfid(Adapter, uiSFId);
-       if (status >= NO_OF_QUEUES) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                               "SFID %d not present in queue !!!", uiSFId);
-               return -EINVAL;
-       }
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "status =%d", status);
-       psSfInfo = &Adapter->PackInfo[status];
-       if (psSfInfo->pstSFIndication
-                       && copy_to_user(user_buffer, psSfInfo->pstSFIndication,
-                               sizeof(struct bcm_add_indication_alt))) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,
-                               "copy to user failed SFID %d, present in queue !!!",
-                               uiSFId);
-               status = -EFAULT;
-               return status;
-       }
-       return STATUS_SUCCESS;
-}
-
-VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter,
-               PUINT puiBuffer)
-{
-       B_UINT32 u32NumofSFsinMsg = ntohl(*(puiBuffer + 1));
-       struct bcm_stim_sfhostnotify *pHostInfo = NULL;
-       UINT uiSearchRuleIndex = 0;
-       ULONG ulSFID = 0;
-
-       puiBuffer += 2;
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                       "u32NumofSFsinMsg: 0x%x\n", u32NumofSFsinMsg);
-
-       while (u32NumofSFsinMsg != 0 && u32NumofSFsinMsg < NO_OF_QUEUES) {
-               u32NumofSFsinMsg--;
-               pHostInfo = (struct bcm_stim_sfhostnotify *)puiBuffer;
-               puiBuffer = (PUINT)(pHostInfo + 1);
-
-               ulSFID = ntohl(pHostInfo->SFID);
-               uiSearchRuleIndex = SearchSfid(Adapter, ulSFID);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                               "SFID: 0x%lx\n", ulSFID);
-
-               if (uiSearchRuleIndex >= NO_OF_QUEUES
-                               || uiSearchRuleIndex == HiPriority) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG,
-                                       DBG_LVL_ALL,
-                                       "The SFID <%lx> doesn't exist in host entry or is Invalid\n",
-                                       ulSFID);
-                       continue;
-               }
-
-               if (pHostInfo->RetainSF == false) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG,
-                                       DBG_LVL_ALL, "Going to Delete SF");
-                       deleteSFBySfid(Adapter, uiSearchRuleIndex);
-               } else {
-                       struct bcm_packet_info *packinfo =
-                               &Adapter->PackInfo[uiSearchRuleIndex];
-
-                       packinfo->usVCID_Value = ntohs(pHostInfo->VCID);
-                       packinfo->usCID = ntohs(pHostInfo->newCID);
-                       packinfo->bActive = false;
-
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG,
-                                       DBG_LVL_ALL,
-                                       "pHostInfo->QoSParamSet: 0x%x\n",
-                                       pHostInfo->QoSParamSet);
-
-                       if (pHostInfo->QoSParamSet & 0x1)
-                               packinfo->bAuthorizedSet = TRUE;
-                       if (pHostInfo->QoSParamSet & 0x2)
-                               packinfo->bAdmittedSet = TRUE;
-                       if (pHostInfo->QoSParamSet & 0x4) {
-                               packinfo->bActiveSet = TRUE;
-                               packinfo->bActive = TRUE;
-                       }
-               }
-       }
-}
-
-static void restore_endianess_of_pstClassifierEntry(
-               struct bcm_classifier_rule *pstClassifierEntry,
-               enum bcm_ipaddr_context eIpAddrContext)
-{
-       int i;
-       union u_ip_address *stSrc  = &pstClassifierEntry->stSrcIpAddress;
-       union u_ip_address *stDest = &pstClassifierEntry->stDestIpAddress;
-
-       for (i = 0; i < MAX_IP_RANGE_LENGTH * 4; i++) {
-               if (eIpAddrContext == eSrcIpAddress) {
-                       stSrc->ulIpv6Addr[i] = ntohl(stSrc->ulIpv6Addr[i]);
-                       stSrc->ulIpv6Mask[i] = ntohl(stSrc->ulIpv6Mask[i]);
-               } else if (eIpAddrContext == eDestIpAddress) {
-                       stDest->ulIpv6Addr[i] = ntohl(stDest->ulIpv6Addr[i]);
-                       stDest->ulIpv6Mask[i] = ntohl(stDest->ulIpv6Mask[i]);
-               }
-       }
-}
-
-static void apply_phs_rule_to_all_classifiers(
-               register struct bcm_mini_adapter *Adapter,              /* <Pointer to the Adapter structure */
-               register UINT uiSearchRuleIndex,                        /* <Index of Queue, to which this data belongs */
-               USHORT uVCID,
-               struct bcm_phs_rule *sPhsRule,
-               struct bcm_phs_rules *cPhsRule,
-               struct bcm_add_indication_alt *pstAddIndication)
-{
-       unsigned int uiClassifierIndex = 0;
-       struct bcm_classifier_rule *curr_classifier = NULL;
-
-       if (pstAddIndication->u8Direction == UPLINK_DIR) {
-               for (uiClassifierIndex = 0; uiClassifierIndex < MAX_CLASSIFIERS; uiClassifierIndex++) {
-                       curr_classifier =
-                               &Adapter->astClassifierTable[uiClassifierIndex];
-                       if ((curr_classifier->bUsed) &&
-                               (curr_classifier->ulSFID == Adapter->PackInfo[uiSearchRuleIndex].ulSFID) &&
-                               (curr_classifier->u8AssociatedPHSI == cPhsRule->u8PHSI)) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,
-                                               "Adding PHS Rule For Classifier: 0x%x cPhsRule.u8PHSI: 0x%x\n",
-                                               curr_classifier->uiClassifierRuleIndex,
-                                               cPhsRule->u8PHSI);
-                               /* Update The PHS Rule for this classifier as Associated PHSI id defined */
-
-                               /* Copy the PHS Rule */
-                               sPhsRule->u8PHSI = cPhsRule->u8PHSI;
-                               sPhsRule->u8PHSFLength = cPhsRule->u8PHSFLength;
-                               sPhsRule->u8PHSMLength = cPhsRule->u8PHSMLength;
-                               sPhsRule->u8PHSS = cPhsRule->u8PHSS;
-                               sPhsRule->u8PHSV = cPhsRule->u8PHSV;
-                               memcpy(sPhsRule->u8PHSF, cPhsRule->u8PHSF, MAX_PHS_LENGTHS);
-                               memcpy(sPhsRule->u8PHSM, cPhsRule->u8PHSM, MAX_PHS_LENGTHS);
-                               sPhsRule->u8RefCnt = 0;
-                               sPhsRule->bUnclassifiedPHSRule = false;
-                               sPhsRule->PHSModifiedBytes = 0;
-                               sPhsRule->PHSModifiedNumPackets = 0;
-                               sPhsRule->PHSErrorNumPackets = 0;
-
-                               /* bPHSRuleAssociated = TRUE; */
-                               /* Store The PHS Rule for this classifier */
-
-                               PhsUpdateClassifierRule(
-                                       &Adapter->stBCMPhsContext,
-                                       uVCID,
-                                       curr_classifier->uiClassifierRuleIndex,
-                                       sPhsRule,
-                                       curr_classifier->u8AssociatedPHSI);
-
-                               /* Update PHS Rule For the Classifier */
-                               if (sPhsRule->u8PHSI) {
-                                       curr_classifier->u32PHSRuleID = sPhsRule->u8PHSI;
-                                       memcpy(&curr_classifier->sPhsRule, sPhsRule, sizeof(struct bcm_phs_rule));
-                               }
-                       }
-               }
-       } else {
-               /* Error PHS Rule specified in signaling could not be applied to any classifier */
-
-               /* Copy the PHS Rule */
-               sPhsRule->u8PHSI = cPhsRule->u8PHSI;
-               sPhsRule->u8PHSFLength = cPhsRule->u8PHSFLength;
-               sPhsRule->u8PHSMLength = cPhsRule->u8PHSMLength;
-               sPhsRule->u8PHSS = cPhsRule->u8PHSS;
-               sPhsRule->u8PHSV = cPhsRule->u8PHSV;
-               memcpy(sPhsRule->u8PHSF, cPhsRule->u8PHSF, MAX_PHS_LENGTHS);
-               memcpy(sPhsRule->u8PHSM, cPhsRule->u8PHSM, MAX_PHS_LENGTHS);
-               sPhsRule->u8RefCnt = 0;
-               sPhsRule->bUnclassifiedPHSRule = TRUE;
-               sPhsRule->PHSModifiedBytes = 0;
-               sPhsRule->PHSModifiedNumPackets = 0;
-               sPhsRule->PHSErrorNumPackets = 0;
-               /* Store The PHS Rule for this classifier */
-
-               /*
-                * Passing the argument u8PHSI instead of clsid. Because for DL with no classifier rule,
-                * clsid will be zero hence we can't have multiple PHS rules for the same SF.
-                * To support multiple PHS rule, passing u8PHSI.
-                */
-               PhsUpdateClassifierRule(
-                       &Adapter->stBCMPhsContext,
-                       uVCID,
-                       sPhsRule->u8PHSI,
-                       sPhsRule,
-                       sPhsRule->u8PHSI);
-       }
-}
diff --git a/drivers/staging/bcm/CmHost.h b/drivers/staging/bcm/CmHost.h
deleted file mode 100644 (file)
index 0887d3f..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/***************************************************************************
- * (c) Beceem Communications Inc.
- * All Rights Reserved
- *
- * file  : CmHost.h
- * author: Rajeev Tirumala
- * date  : September 8 , 2006
- * brief : Definitions for Connection Management Requests structure
- *          which we will use to setup our connection structures.Its high
- *          time we had a header file for CmHost.cpp to isolate the way
- *          f/w sends DSx messages and the way we interpret them in code.
- *          Revision History
- *
- *   Date       Author   Version   Description
- *   08-Sep-06    Rajeev       0.1      Created
- ***************************************************************************/
-#ifndef _CM_HOST_H
-#define _CM_HOST_H
-
-#pragma once
-#pragma pack(push, 4)
-
-#define DSX_MESSAGE_EXCHANGE_BUFFER        0xBF60AC84 /* This contains the pointer */
-#define DSX_MESSAGE_EXCHANGE_BUFFER_SIZE   72000      /* 24 K Bytes */
-
-struct bcm_add_indication_alt {
-       u8      u8Type;
-       u8      u8Direction;
-       u16     u16TID;
-       u16     u16CID;
-       u16     u16VCID;
-       struct bcm_connect_mgr_params sfAuthorizedSet;
-       struct bcm_connect_mgr_params sfAdmittedSet;
-       struct bcm_connect_mgr_params sfActiveSet;
-       u8      u8CC;    /* < Confirmation Code */
-       u8      u8Padd;
-       u16     u16Padd;
-};
-
-struct bcm_change_indication {
-       u8      u8Type;
-       u8      u8Direction;
-       u16     u16TID;
-       u16     u16CID;
-       u16     u16VCID;
-       struct bcm_connect_mgr_params sfAuthorizedSet;
-       struct bcm_connect_mgr_params sfAdmittedSet;
-       struct bcm_connect_mgr_params sfActiveSet;
-       u8      u8CC;    /* < Confirmation Code */
-       u8      u8Padd;
-       u16     u16Padd;
-};
-
-unsigned long StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, void *pvBuffer, unsigned int *puBufferLength);
-int AllocAdapterDsxBuffer(struct bcm_mini_adapter *Adapter);
-int FreeAdapterDsxBuffer(struct bcm_mini_adapter *Adapter);
-unsigned long SetUpTargetDsxBuffers(struct bcm_mini_adapter *Adapter);
-bool CmControlResponseMessage(struct bcm_mini_adapter *Adapter, void *pvBuffer);
-
-#pragma pack(pop)
-
-#endif
diff --git a/drivers/staging/bcm/DDRInit.c b/drivers/staging/bcm/DDRInit.c
deleted file mode 100644 (file)
index 4226c93..0000000
+++ /dev/null
@@ -1,1355 +0,0 @@
-#include "headers.h"
-
-
-
-#define DDR_DUMP_INTERNAL_DEVICE_MEMORY 0xBFC02B00
-#define MIPS_CLOCK_REG 0x0f000820
-
-/* DDR INIT-133Mhz */
-#define T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 12  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3_DDRSetting133MHz[] = {
-       /* DPLL Clock Setting */
-       {0x0F000800, 0x00007212},
-       {0x0f000820, 0x07F13FFF},
-       {0x0f000810, 0x00000F95},
-       {0x0f000860, 0x00000000},
-       {0x0f000880, 0x000003DD},
-       /* Changed source for X-bar and MIPS clock to APLL */
-       {0x0f000840, 0x0FFF1B00},
-       {0x0f000870, 0x00000002},
-       {0x0F00a044, 0x1fffffff},
-       {0x0F00a040, 0x1f000000},
-       {0x0F00a084, 0x1Cffffff},
-       {0x0F00a080, 0x1C000000},
-       {0x0F00a04C, 0x0000000C},
-       /* Memcontroller Default values */
-       {0x0F007000, 0x00010001},
-       {0x0F007004, 0x01010100},
-       {0x0F007008, 0x01000001},
-       {0x0F00700c, 0x00000000},
-       {0x0F007010, 0x01000000},
-       {0x0F007014, 0x01000100},
-       {0x0F007018, 0x01000000},
-       {0x0F00701c, 0x01020001},
-       {0x0F007020, 0x04030107},
-       {0x0F007024, 0x02000007},
-       {0x0F007028, 0x02020202},
-       {0x0F00702c, 0x0206060a},
-       {0x0F007030, 0x05000000},
-       {0x0F007034, 0x00000003},
-       {0x0F007038, 0x110a0200},
-       {0x0F00703C, 0x02101010},
-       {0x0F007040, 0x45751200},
-       {0x0F007044, 0x110a0d00},
-       {0x0F007048, 0x081b0306},
-       {0x0F00704c, 0x00000000},
-       {0x0F007050, 0x0000001c},
-       {0x0F007054, 0x00000000},
-       {0x0F007058, 0x00000000},
-       {0x0F00705c, 0x00000000},
-       {0x0F007060, 0x0010246c},
-       {0x0F007064, 0x00000010},
-       {0x0F007068, 0x00000000},
-       {0x0F00706c, 0x00000001},
-       {0x0F007070, 0x00007000},
-       {0x0F007074, 0x00000000},
-       {0x0F007078, 0x00000000},
-       {0x0F00707C, 0x00000000},
-       {0x0F007080, 0x00000000},
-       {0x0F007084, 0x00000000},
-       /* Enable BW improvement within memory controller */
-       {0x0F007094, 0x00000104},
-       /* Enable 2 ports within X-bar */
-       {0x0F00A000, 0x00000016},
-       /* Enable start bit within memory controller */
-       {0x0F007018, 0x01010000}
-};
-/* 80Mhz */
-#define T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 10  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3_DDRSetting80MHz[] = {
-      /* DPLL Clock Setting */
-       {0x0f000810, 0x00000F95},
-       {0x0f000820, 0x07f1ffff},
-       {0x0f000860, 0x00000000},
-       {0x0f000880, 0x000003DD},
-       {0x0F00a044, 0x1fffffff},
-       {0x0F00a040, 0x1f000000},
-       {0x0F00a084, 0x1Cffffff},
-       {0x0F00a080, 0x1C000000},
-       {0x0F00a000, 0x00000016},
-       {0x0F00a04C, 0x0000000C},
-       /* Memcontroller Default values */
-       {0x0F007000, 0x00010001},
-       {0x0F007004, 0x01000000},
-       {0x0F007008, 0x01000001},
-       {0x0F00700c, 0x00000000},
-       {0x0F007010, 0x01000000},
-       {0x0F007014, 0x01000100},
-       {0x0F007018, 0x01000000},
-       {0x0F00701c, 0x01020000},
-       {0x0F007020, 0x04020107},
-       {0x0F007024, 0x00000007},
-       {0x0F007028, 0x02020201},
-       {0x0F00702c, 0x0204040a},
-       {0x0F007030, 0x04000000},
-       {0x0F007034, 0x00000002},
-       {0x0F007038, 0x1F060200},
-       {0x0F00703C, 0x1C22221F},
-       {0x0F007040, 0x8A006600},
-       {0x0F007044, 0x221a0800},
-       {0x0F007048, 0x02690204},
-       {0x0F00704c, 0x00000000},
-       {0x0F007050, 0x0000001c},
-       {0x0F007054, 0x00000000},
-       {0x0F007058, 0x00000000},
-       {0x0F00705c, 0x00000000},
-       {0x0F007060, 0x000A15D6},
-       {0x0F007064, 0x0000000A},
-       {0x0F007068, 0x00000000},
-       {0x0F00706c, 0x00000001},
-       {0x0F007070, 0x00004000},
-       {0x0F007074, 0x00000000},
-       {0x0F007078, 0x00000000},
-       {0x0F00707C, 0x00000000},
-       {0x0F007080, 0x00000000},
-       {0x0F007084, 0x00000000},
-       {0x0F007094, 0x00000104},
-       /* Enable start bit within memory controller */
-       {0x0F007018, 0x01010000}
-};
-/* 100Mhz */
-#define T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 13  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3_DDRSetting100MHz[] = {
-      /* DPLL Clock Setting */
-       {0x0F000800, 0x00007008},
-       {0x0f000810, 0x00000F95},
-       {0x0f000820, 0x07F13E3F},
-       {0x0f000860, 0x00000000},
-       {0x0f000880, 0x000003DD},
-       /* Changed source for X-bar and MIPS clock to APLL */
-       {0x0f000840, 0x0FFF1B00},
-       {0x0f000870, 0x00000002},
-       {0x0F00a044, 0x1fffffff},
-       {0x0F00a040, 0x1f000000},
-       {0x0F00a084, 0x1Cffffff},
-       {0x0F00a080, 0x1C000000},
-       {0x0F00a04C, 0x0000000C},
-       /* Enable 2 ports within X-bar */
-       {0x0F00A000, 0x00000016},
-       /* Memcontroller Default values */
-       {0x0F007000, 0x00010001},
-       {0x0F007004, 0x01010100},
-       {0x0F007008, 0x01000001},
-       {0x0F00700c, 0x00000000},
-       {0x0F007010, 0x01000000},
-       {0x0F007014, 0x01000100},
-       {0x0F007018, 0x01000000},
-       {0x0F00701c, 0x01020001},
-       {0x0F007020, 0x04020107},
-       {0x0F007024, 0x00000007},
-       {0x0F007028, 0x01020201},
-       {0x0F00702c, 0x0204040A},
-       {0x0F007030, 0x06000000},
-       {0x0F007034, 0x00000004},
-       {0x0F007038, 0x20080200},
-       {0x0F00703C, 0x02030320},
-       {0x0F007040, 0x6E7F1200},
-       {0x0F007044, 0x01190A00},
-       {0x0F007048, 0x06120305},
-       {0x0F00704c, 0x00000000},
-       {0x0F007050, 0x0000001C},
-       {0x0F007054, 0x00000000},
-       {0x0F007058, 0x00000000},
-       {0x0F00705c, 0x00000000},
-       {0x0F007060, 0x00082ED6},
-       {0x0F007064, 0x0000000A},
-       {0x0F007068, 0x00000000},
-       {0x0F00706c, 0x00000001},
-       {0x0F007070, 0x00005000},
-       {0x0F007074, 0x00000000},
-       {0x0F007078, 0x00000000},
-       {0x0F00707C, 0x00000000},
-       {0x0F007080, 0x00000000},
-       {0x0F007084, 0x00000000},
-       /* Enable BW improvement within memory controller */
-       {0x0F007094, 0x00000104},
-       /* Enable start bit within memory controller */
-       {0x0F007018, 0x01010000}
-};
-
-/* Net T3B DDR Settings
- * DDR INIT-133Mhz
- */
-static struct bcm_ddr_setting asDPLL_266MHZ[] = {
-       {0x0F000800, 0x00007212},
-       {0x0f000820, 0x07F13FFF},
-       {0x0f000810, 0x00000F95},
-       {0x0f000860, 0x00000000},
-       {0x0f000880, 0x000003DD},
-       /* Changed source for X-bar and MIPS clock to APLL */
-       {0x0f000840, 0x0FFF1B00},
-       {0x0f000870, 0x00000002}
-};
-
-#define T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 11  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3B_DDRSetting133MHz[] = {
-      /* DPLL Clock Setting */
-       {0x0f000810, 0x00000F95},
-       {0x0f000810, 0x00000F95},
-       {0x0f000810, 0x00000F95},
-       {0x0f000820, 0x07F13652},
-       {0x0f000840, 0x0FFF0800},
-       /* Changed source for X-bar and MIPS clock to APLL */
-       {0x0f000880, 0x000003DD},
-       {0x0f000860, 0x00000000},
-       /* Changed source for X-bar and MIPS clock to APLL */
-       {0x0F00a044, 0x1fffffff},
-       {0x0F00a040, 0x1f000000},
-       {0x0F00a084, 0x1Cffffff},
-       {0x0F00a080, 0x1C000000},
-       /* Enable 2 ports within X-bar */
-       {0x0F00A000, 0x00000016},
-       /* Memcontroller Default values */
-       {0x0F007000, 0x00010001},
-       {0x0F007004, 0x01010100},
-       {0x0F007008, 0x01000001},
-       {0x0F00700c, 0x00000000},
-       {0x0F007010, 0x01000000},
-       {0x0F007014, 0x01000100},
-       {0x0F007018, 0x01000000},
-       {0x0F00701c, 0x01020001},
-       {0x0F007020, 0x04030107},
-       {0x0F007024, 0x02000007},
-       {0x0F007028, 0x02020202},
-       {0x0F00702c, 0x0206060a},
-       {0x0F007030, 0x05000000},
-       {0x0F007034, 0x00000003},
-       {0x0F007038, 0x130a0200},
-       {0x0F00703C, 0x02101012},
-       {0x0F007040, 0x457D1200},
-       {0x0F007044, 0x11130d00},
-       {0x0F007048, 0x040D0306},
-       {0x0F00704c, 0x00000000},
-       {0x0F007050, 0x0000001c},
-       {0x0F007054, 0x00000000},
-       {0x0F007058, 0x00000000},
-       {0x0F00705c, 0x00000000},
-       {0x0F007060, 0x0010246c},
-       {0x0F007064, 0x00000012},
-       {0x0F007068, 0x00000000},
-       {0x0F00706c, 0x00000001},
-       {0x0F007070, 0x00007000},
-       {0x0F007074, 0x00000000},
-       {0x0F007078, 0x00000000},
-       {0x0F00707C, 0x00000000},
-       {0x0F007080, 0x00000000},
-       {0x0F007084, 0x00000000},
-       /* Enable BW improvement within memory controller */
-       {0x0F007094, 0x00000104},
-       /* Enable start bit within memory controller */
-       {0x0F007018, 0x01010000},
-       };
-
-#define T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 9  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3B_DDRSetting80MHz[] = {
-      /* DPLL Clock Setting */
-       {0x0f000810, 0x00000F95},
-       {0x0f000820, 0x07F13FFF},
-       {0x0f000840, 0x0FFF1F00},
-       {0x0f000880, 0x000003DD},
-       {0x0f000860, 0x00000000},
-
-       {0x0F00a044, 0x1fffffff},
-       {0x0F00a040, 0x1f000000},
-       {0x0F00a084, 0x1Cffffff},
-       {0x0F00a080, 0x1C000000},
-       {0x0F00a000, 0x00000016},
-       /* Memcontroller Default values */
-       {0x0F007000, 0x00010001},
-       {0x0F007004, 0x01000000},
-       {0x0F007008, 0x01000001},
-       {0x0F00700c, 0x00000000},
-       {0x0F007010, 0x01000000},
-       {0x0F007014, 0x01000100},
-       {0x0F007018, 0x01000000},
-       {0x0F00701c, 0x01020000},
-       {0x0F007020, 0x04020107},
-       {0x0F007024, 0x00000007},
-       {0x0F007028, 0x02020201},
-       {0x0F00702c, 0x0204040a},
-       {0x0F007030, 0x04000000},
-       {0x0F007034, 0x02000002},
-       {0x0F007038, 0x1F060202},
-       {0x0F00703C, 0x1C22221F},
-       {0x0F007040, 0x8A006600},
-       {0x0F007044, 0x221a0800},
-       {0x0F007048, 0x02690204},
-       {0x0F00704c, 0x00000000},
-       {0x0F007050, 0x0100001c},
-       {0x0F007054, 0x00000000},
-       {0x0F007058, 0x00000000},
-       {0x0F00705c, 0x00000000},
-       {0x0F007060, 0x000A15D6},
-       {0x0F007064, 0x0000000A},
-       {0x0F007068, 0x00000000},
-       {0x0F00706c, 0x00000001},
-       {0x0F007070, 0x00004000},
-       {0x0F007074, 0x00000000},
-       {0x0F007078, 0x00000000},
-       {0x0F00707C, 0x00000000},
-       {0x0F007080, 0x00000000},
-       {0x0F007084, 0x00000000},
-       {0x0F007094, 0x00000104},
-       /* Enable start bit within memory controller */
-       {0x0F007018, 0x01010000}
-};
-
-/* 100Mhz */
-#define T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 9  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3B_DDRSetting100MHz[] = {
-      /* DPLL Clock Setting */
-       {0x0f000810, 0x00000F95},
-       {0x0f000820, 0x07F1369B},
-       {0x0f000840, 0x0FFF0800},
-       {0x0f000880, 0x000003DD},
-       {0x0f000860, 0x00000000},
-       {0x0F00a044, 0x1fffffff},
-       {0x0F00a040, 0x1f000000},
-       {0x0F00a084, 0x1Cffffff},
-       {0x0F00a080, 0x1C000000},
-       /* Enable 2 ports within X-bar */
-       {0x0F00A000, 0x00000016},
-       /* Memcontroller Default values */
-       {0x0F007000, 0x00010001},
-       {0x0F007004, 0x01010100},
-       {0x0F007008, 0x01000001},
-       {0x0F00700c, 0x00000000},
-       {0x0F007010, 0x01000000},
-       {0x0F007014, 0x01000100},
-       {0x0F007018, 0x01000000},
-       {0x0F00701c, 0x01020000},
-       {0x0F007020, 0x04020107},
-       {0x0F007024, 0x00000007},
-       {0x0F007028, 0x01020201},
-       {0x0F00702c, 0x0204040A},
-       {0x0F007030, 0x06000000},
-       {0x0F007034, 0x02000004},
-       {0x0F007038, 0x20080200},
-       {0x0F00703C, 0x02030320},
-       {0x0F007040, 0x6E7F1200},
-       {0x0F007044, 0x01190A00},
-       {0x0F007048, 0x06120305},
-       {0x0F00704c, 0x00000000},
-       {0x0F007050, 0x0100001C},
-       {0x0F007054, 0x00000000},
-       {0x0F007058, 0x00000000},
-       {0x0F00705c, 0x00000000},
-       {0x0F007060, 0x00082ED6},
-       {0x0F007064, 0x0000000A},
-       {0x0F007068, 0x00000000},
-       {0x0F00706c, 0x00000001},
-       {0x0F007070, 0x00005000},
-       {0x0F007074, 0x00000000},
-       {0x0F007078, 0x00000000},
-       {0x0F00707C, 0x00000000},
-       {0x0F007080, 0x00000000},
-       {0x0F007084, 0x00000000},
-       /* Enable BW improvement within memory controller */
-       {0x0F007094, 0x00000104},
-       /* Enable start bit within memory controller */
-       {0x0F007018, 0x01010000}
-};
-
-
-#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 9  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3LP_DDRSetting133MHz[] = {
-      /* DPLL Clock Setting */
-       {0x0f000820, 0x03F1365B},
-       {0x0f000810, 0x00002F95},
-       {0x0f000880, 0x000003DD},
-       /* Changed source for X-bar and MIPS clock to APLL */
-       {0x0f000840, 0x0FFF0000},
-       {0x0f000860, 0x00000000},
-       {0x0F00a044, 0x1fffffff},
-       {0x0F00a040, 0x1f000000},
-       {0x0F00a084, 0x1Cffffff},
-       {0x0F00a080, 0x1C000000},
-       {0x0F00A000, 0x00000016},
-       /* Memcontroller Default values */
-       {0x0F007000, 0x00010001},
-       {0x0F007004, 0x01010100},
-       {0x0F007008, 0x01000001},
-       {0x0F00700c, 0x00000000},
-       {0x0F007010, 0x01000000},
-       {0x0F007014, 0x01000100},
-       {0x0F007018, 0x01000000},
-       {0x0F00701c, 0x01020001},
-       {0x0F007020, 0x04030107},
-       {0x0F007024, 0x02000007},
-       {0x0F007028, 0x02020200},
-       {0x0F00702c, 0x0206060a},
-       {0x0F007030, 0x05000000},
-       {0x0F007034, 0x00000003},
-       {0x0F007038, 0x200a0200},
-       {0x0F00703C, 0x02101020},
-       {0x0F007040, 0x45711200},
-       {0x0F007044, 0x110D0D00},
-       {0x0F007048, 0x04080306},
-       {0x0F00704c, 0x00000000},
-       {0x0F007050, 0x0100001c},
-       {0x0F007054, 0x00000000},
-       {0x0F007058, 0x00000000},
-       {0x0F00705c, 0x00000000},
-       {0x0F007060, 0x0010245F},
-       {0x0F007064, 0x00000010},
-       {0x0F007068, 0x00000000},
-       {0x0F00706c, 0x00000001},
-       {0x0F007070, 0x00007000},
-       {0x0F007074, 0x00000000},
-       {0x0F007078, 0x00000000},
-       {0x0F00707C, 0x00000000},
-       {0x0F007080, 0x00000000},
-       {0x0F007084, 0x00000000},
-       {0x0F007088, 0x01000001},
-       {0x0F00708c, 0x00000101},
-       {0x0F007090, 0x00000000},
-       /* Enable BW improvement within memory controller */
-       {0x0F007094, 0x00040000},
-       {0x0F007098, 0x00000000},
-       {0x0F0070c8, 0x00000104},
-       /* Enable 2 ports within X-bar */
-       /* Enable start bit within memory controller */
-       {0x0F007018, 0x01010000}
-};
-
-#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 11  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3LP_DDRSetting100MHz[] = {
-      /* DPLL Clock Setting */
-       {0x0f000810, 0x00002F95},
-       {0x0f000820, 0x03F1369B},
-       {0x0f000840, 0x0fff0000},
-       {0x0f000860, 0x00000000},
-       {0x0f000880, 0x000003DD},
-       /* Changed source for X-bar and MIPS clock to APLL */
-       {0x0f000840, 0x0FFF0000},
-       {0x0F00a044, 0x1fffffff},
-       {0x0F00a040, 0x1f000000},
-       {0x0F00a084, 0x1Cffffff},
-       {0x0F00a080, 0x1C000000},
-       /* Memcontroller Default values */
-       {0x0F007000, 0x00010001},
-       {0x0F007004, 0x01010100},
-       {0x0F007008, 0x01000001},
-       {0x0F00700c, 0x00000000},
-       {0x0F007010, 0x01000000},
-       {0x0F007014, 0x01000100},
-       {0x0F007018, 0x01000000},
-       {0x0F00701c, 0x01020000},
-       {0x0F007020, 0x04020107},
-       {0x0F007024, 0x00000007},
-       {0x0F007028, 0x01020200},
-       {0x0F00702c, 0x0204040a},
-       {0x0F007030, 0x06000000},
-       {0x0F007034, 0x00000004},
-       {0x0F007038, 0x1F080200},
-       {0x0F00703C, 0x0203031F},
-       {0x0F007040, 0x6e001200},
-       {0x0F007044, 0x011a0a00},
-       {0x0F007048, 0x03000305},
-       {0x0F00704c, 0x00000000},
-       {0x0F007050, 0x0100001c},
-       {0x0F007054, 0x00000000},
-       {0x0F007058, 0x00000000},
-       {0x0F00705c, 0x00000000},
-       {0x0F007060, 0x00082ED6},
-       {0x0F007064, 0x0000000A},
-       {0x0F007068, 0x00000000},
-       {0x0F00706c, 0x00000001},
-       {0x0F007070, 0x00005000},
-       {0x0F007074, 0x00000000},
-       {0x0F007078, 0x00000000},
-       {0x0F00707C, 0x00000000},
-       {0x0F007080, 0x00000000},
-       {0x0F007084, 0x00000000},
-       {0x0F007088, 0x01000001},
-       {0x0F00708c, 0x00000101},
-       {0x0F007090, 0x00000000},
-       {0x0F007094, 0x00010000},
-       {0x0F007098, 0x00000000},
-       {0x0F0070C8, 0x00000104},
-       /* Enable 2 ports within X-bar */
-       {0x0F00A000, 0x00000016},
-       /* Enable start bit within memory controller */
-       {0x0F007018, 0x01010000}
-};
-
-#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 9  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3LP_DDRSetting80MHz[] = {
-      /* DPLL Clock Setting */
-       {0x0f000820, 0x07F13FFF},
-       {0x0f000810, 0x00002F95},
-       {0x0f000860, 0x00000000},
-       {0x0f000880, 0x000003DD},
-       {0x0f000840, 0x0FFF1F00},
-       {0x0F00a044, 0x1fffffff},
-       {0x0F00a040, 0x1f000000},
-       {0x0F00a084, 0x1Cffffff},
-       {0x0F00a080, 0x1C000000},
-       {0x0F00A000, 0x00000016},
-       {0x0f007000, 0x00010001},
-       {0x0f007004, 0x01000000},
-       {0x0f007008, 0x01000001},
-       {0x0f00700c, 0x00000000},
-       {0x0f007010, 0x01000000},
-       {0x0f007014, 0x01000100},
-       {0x0f007018, 0x01000000},
-       {0x0f00701c, 0x01020000},
-       {0x0f007020, 0x04020107},
-       {0x0f007024, 0x00000007},
-       {0x0f007028, 0x02020200},
-       {0x0f00702c, 0x0204040a},
-       {0x0f007030, 0x04000000},
-       {0x0f007034, 0x00000002},
-       {0x0f007038, 0x1d060200},
-       {0x0f00703c, 0x1c22221d},
-       {0x0f007040, 0x8A116600},
-       {0x0f007044, 0x222d0800},
-       {0x0f007048, 0x02690204},
-       {0x0f00704c, 0x00000000},
-       {0x0f007050, 0x0100001c},
-       {0x0f007054, 0x00000000},
-       {0x0f007058, 0x00000000},
-       {0x0f00705c, 0x00000000},
-       {0x0f007060, 0x000A15D6},
-       {0x0f007064, 0x0000000A},
-       {0x0f007068, 0x00000000},
-       {0x0f00706c, 0x00000001},
-       {0x0f007070, 0x00004000},
-       {0x0f007074, 0x00000000},
-       {0x0f007078, 0x00000000},
-       {0x0f00707c, 0x00000000},
-       {0x0f007080, 0x00000000},
-       {0x0f007084, 0x00000000},
-       {0x0f007088, 0x01000001},
-       {0x0f00708c, 0x00000101},
-       {0x0f007090, 0x00000000},
-       {0x0f007094, 0x00010000},
-       {0x0f007098, 0x00000000},
-       {0x0F0070C8, 0x00000104},
-       {0x0F007018, 0x01010000}
-};
-
-
-
-
-/* T3 LP-B (UMA-B) */
-
-#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ 7  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3LPB_DDRSetting160MHz[] = {
-      /* DPLL Clock Setting */
-       {0x0f000820, 0x03F137DB},
-       {0x0f000810, 0x01842795},
-       {0x0f000860, 0x00000000},
-       {0x0f000880, 0x000003DD},
-       {0x0f000840, 0x0FFF0400},
-       {0x0F00a044, 0x1fffffff},
-       {0x0F00a040, 0x1f000000},
-       {0x0f003050, 0x00000021},  /* this is flash/eeprom clock divisor which
-                                   * set the flash clock to 20 MHz */
-       {0x0F00a084, 0x1Cffffff},  /* Now dump from her in internal memory */
-       {0x0F00a080, 0x1C000000},
-       {0x0F00A000, 0x00000016},
-       {0x0f007000, 0x00010001},
-       {0x0f007004, 0x01000001},
-       {0x0f007008, 0x01000101},
-       {0x0f00700c, 0x00000000},
-       {0x0f007010, 0x01000100},
-       {0x0f007014, 0x01000100},
-       {0x0f007018, 0x01000000},
-       {0x0f00701c, 0x01020000},
-       {0x0f007020, 0x04030107},
-       {0x0f007024, 0x02000007},
-       {0x0f007028, 0x02020200},
-       {0x0f00702c, 0x0206060a},
-       {0x0f007030, 0x050d0d00},
-       {0x0f007034, 0x00000003},
-       {0x0f007038, 0x170a0200},
-       {0x0f00703c, 0x02101012},
-       {0x0f007040, 0x45161200},
-       {0x0f007044, 0x11250c00},
-       {0x0f007048, 0x04da0307},
-       {0x0f00704c, 0x00000000},
-       {0x0f007050, 0x0000001c},
-       {0x0f007054, 0x00000000},
-       {0x0f007058, 0x00000000},
-       {0x0f00705c, 0x00000000},
-       {0x0f007060, 0x00142bb6},
-       {0x0f007064, 0x20430014},
-       {0x0f007068, 0x00000000},
-       {0x0f00706c, 0x00000001},
-       {0x0f007070, 0x00009000},
-       {0x0f007074, 0x00000000},
-       {0x0f007078, 0x00000000},
-       {0x0f00707c, 0x00000000},
-       {0x0f007080, 0x00000000},
-       {0x0f007084, 0x00000000},
-       {0x0f007088, 0x01000001},
-       {0x0f00708c, 0x00000101},
-       {0x0f007090, 0x00000000},
-       {0x0f007094, 0x00040000},
-       {0x0f007098, 0x00000000},
-       {0x0F0070C8, 0x00000104},
-       {0x0F007018, 0x01010000}
-};
-
-
-#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 7  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3LPB_DDRSetting133MHz[] = {
-      /* DPLL Clock Setting */
-       {0x0f000820, 0x03F1365B},
-       {0x0f000810, 0x00002F95},
-       {0x0f000880, 0x000003DD},
-       /* Changed source for X-bar and MIPS clock to APLL */
-       {0x0f000840, 0x0FFF0000},
-       {0x0f000860, 0x00000000},
-       {0x0F00a044, 0x1fffffff},
-       {0x0F00a040, 0x1f000000},
-       {0x0f003050, 0x00000021},  /* flash/eeprom clock divisor which
-                                   * set the flash clock to 20 MHz */
-       {0x0F00a084, 0x1Cffffff},  /* dump from here in internal memory */
-       {0x0F00a080, 0x1C000000},
-       {0x0F00A000, 0x00000016},
-       /* Memcontroller Default values */
-       {0x0F007000, 0x00010001},
-       {0x0F007004, 0x01010100},
-       {0x0F007008, 0x01000001},
-       {0x0F00700c, 0x00000000},
-       {0x0F007010, 0x01000000},
-       {0x0F007014, 0x01000100},
-       {0x0F007018, 0x01000000},
-       {0x0F00701c, 0x01020001},
-       {0x0F007020, 0x04030107},
-       {0x0F007024, 0x02000007},
-       {0x0F007028, 0x02020200},
-       {0x0F00702c, 0x0206060a},
-       {0x0F007030, 0x05000000},
-       {0x0F007034, 0x00000003},
-       {0x0F007038, 0x190a0200},
-       {0x0F00703C, 0x02101017},
-       {0x0F007040, 0x45171200},
-       {0x0F007044, 0x11290D00},
-       {0x0F007048, 0x04080306},
-       {0x0F00704c, 0x00000000},
-       {0x0F007050, 0x0100001c},
-       {0x0F007054, 0x00000000},
-       {0x0F007058, 0x00000000},
-       {0x0F00705c, 0x00000000},
-       {0x0F007060, 0x0010245F},
-       {0x0F007064, 0x00000010},
-       {0x0F007068, 0x00000000},
-       {0x0F00706c, 0x00000001},
-       {0x0F007070, 0x00007000},
-       {0x0F007074, 0x00000000},
-       {0x0F007078, 0x00000000},
-       {0x0F00707C, 0x00000000},
-       {0x0F007080, 0x00000000},
-       {0x0F007084, 0x00000000},
-       {0x0F007088, 0x01000001},
-       {0x0F00708c, 0x00000101},
-       {0x0F007090, 0x00000000},
-       /* Enable BW improvement within memory controller */
-       {0x0F007094, 0x00040000},
-       {0x0F007098, 0x00000000},
-       {0x0F0070c8, 0x00000104},
-       /* Enable 2 ports within X-bar */
-       /* Enable start bit within memory controller */
-       {0x0F007018, 0x01010000}
-};
-
-#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 8  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3LPB_DDRSetting100MHz[] = {
-      /* DPLL Clock Setting */
-       {0x0f000810, 0x00002F95},
-       {0x0f000820, 0x03F1369B},
-       {0x0f000840, 0x0fff0000},
-       {0x0f000860, 0x00000000},
-       {0x0f000880, 0x000003DD},
-       /* Changed source for X-bar and MIPS clock to APLL */
-       {0x0f000840, 0x0FFF0000},
-       {0x0F00a044, 0x1fffffff},
-       {0x0F00a040, 0x1f000000},
-       {0x0f003050, 0x00000021},  /* flash/eeprom clock divisor which
-                                   * set the flash clock to 20 MHz */
-       {0x0F00a084, 0x1Cffffff},  /* dump from here in internal memory */
-       {0x0F00a080, 0x1C000000},
-       /* Memcontroller Default values */
-       {0x0F007000, 0x00010001},
-       {0x0F007004, 0x01010100},
-       {0x0F007008, 0x01000001},
-       {0x0F00700c, 0x00000000},
-       {0x0F007010, 0x01000000},
-       {0x0F007014, 0x01000100},
-       {0x0F007018, 0x01000000},
-       {0x0F00701c, 0x01020000},
-       {0x0F007020, 0x04020107},
-       {0x0F007024, 0x00000007},
-       {0x0F007028, 0x01020200},
-       {0x0F00702c, 0x0204040a},
-       {0x0F007030, 0x06000000},
-       {0x0F007034, 0x00000004},
-       {0x0F007038, 0x1F080200},
-       {0x0F00703C, 0x0203031F},
-       {0x0F007040, 0x6e001200},
-       {0x0F007044, 0x011a0a00},
-       {0x0F007048, 0x03000305},
-       {0x0F00704c, 0x00000000},
-       {0x0F007050, 0x0100001c},
-       {0x0F007054, 0x00000000},
-       {0x0F007058, 0x00000000},
-       {0x0F00705c, 0x00000000},
-       {0x0F007060, 0x00082ED6},
-       {0x0F007064, 0x0000000A},
-       {0x0F007068, 0x00000000},
-       {0x0F00706c, 0x00000001},
-       {0x0F007070, 0x00005000},
-       {0x0F007074, 0x00000000},
-       {0x0F007078, 0x00000000},
-       {0x0F00707C, 0x00000000},
-       {0x0F007080, 0x00000000},
-       {0x0F007084, 0x00000000},
-       {0x0F007088, 0x01000001},
-       {0x0F00708c, 0x00000101},
-       {0x0F007090, 0x00000000},
-       {0x0F007094, 0x00010000},
-       {0x0F007098, 0x00000000},
-       {0x0F0070C8, 0x00000104},
-       /* Enable 2 ports within X-bar */
-       {0x0F00A000, 0x00000016},
-       /* Enable start bit within memory controller */
-       {0x0F007018, 0x01010000}
-};
-
-#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 7  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3LPB_DDRSetting80MHz[] = {
-      /* DPLL Clock Setting */
-       {0x0f000820, 0x07F13FFF},
-       {0x0f000810, 0x00002F95},
-       {0x0f000860, 0x00000000},
-       {0x0f000880, 0x000003DD},
-       {0x0f000840, 0x0FFF1F00},
-       {0x0F00a044, 0x1fffffff},
-       {0x0F00a040, 0x1f000000},
-       {0x0f003050, 0x00000021},  /* flash/eeprom clock divisor
-                                   * which set the flash clock to 20 MHz */
-       {0x0F00a084, 0x1Cffffff},  /* dump from here in internal memory */
-       {0x0F00a080, 0x1C000000},
-       {0x0F00A000, 0x00000016},
-       {0x0f007000, 0x00010001},
-       {0x0f007004, 0x01000000},
-       {0x0f007008, 0x01000001},
-       {0x0f00700c, 0x00000000},
-       {0x0f007010, 0x01000000},
-       {0x0f007014, 0x01000100},
-       {0x0f007018, 0x01000000},
-       {0x0f00701c, 0x01020000},
-       {0x0f007020, 0x04020107},
-       {0x0f007024, 0x00000007},
-       {0x0f007028, 0x02020200},
-       {0x0f00702c, 0x0204040a},
-       {0x0f007030, 0x04000000},
-       {0x0f007034, 0x00000002},
-       {0x0f007038, 0x1d060200},
-       {0x0f00703c, 0x1c22221d},
-       {0x0f007040, 0x8A116600},
-       {0x0f007044, 0x222d0800},
-       {0x0f007048, 0x02690204},
-       {0x0f00704c, 0x00000000},
-       {0x0f007050, 0x0100001c},
-       {0x0f007054, 0x00000000},
-       {0x0f007058, 0x00000000},
-       {0x0f00705c, 0x00000000},
-       {0x0f007060, 0x000A15D6},
-       {0x0f007064, 0x0000000A},
-       {0x0f007068, 0x00000000},
-       {0x0f00706c, 0x00000001},
-       {0x0f007070, 0x00004000},
-       {0x0f007074, 0x00000000},
-       {0x0f007078, 0x00000000},
-       {0x0f00707c, 0x00000000},
-       {0x0f007080, 0x00000000},
-       {0x0f007084, 0x00000000},
-       {0x0f007088, 0x01000001},
-       {0x0f00708c, 0x00000101},
-       {0x0f007090, 0x00000000},
-       {0x0f007094, 0x00010000},
-       {0x0f007098, 0x00000000},
-       {0x0F0070C8, 0x00000104},
-       {0x0F007018, 0x01010000}
-};
-
-
-int ddr_init(struct bcm_mini_adapter *Adapter)
-{
-       struct bcm_ddr_setting *psDDRSetting = NULL;
-       ULONG RegCount = 0;
-       UINT value = 0;
-       UINT uiResetValue = 0;
-       UINT uiClockSetting = 0;
-       int retval = STATUS_SUCCESS;
-
-       switch (Adapter->chip_id) {
-       case 0xbece3200:
-               switch (Adapter->DDRSetting) {
-               case DDR_80_MHZ:
-                       psDDRSetting = asT3LP_DDRSetting80MHz;
-                       RegCount = (sizeof(asT3LP_DDRSetting80MHz) /
-                                   sizeof(struct bcm_ddr_setting));
-                       break;
-               case DDR_100_MHZ:
-                       psDDRSetting = asT3LP_DDRSetting100MHz;
-                       RegCount = (sizeof(asT3LP_DDRSetting100MHz) /
-                                   sizeof(struct bcm_ddr_setting));
-                       break;
-               case DDR_133_MHZ:
-                       psDDRSetting = asT3LP_DDRSetting133MHz;
-                       RegCount = (sizeof(asT3LP_DDRSetting133MHz) /
-                                   sizeof(struct bcm_ddr_setting));
-                       if (Adapter->bMipsConfig == MIPS_200_MHZ)
-                               uiClockSetting = 0x03F13652;
-                       else
-                               uiClockSetting = 0x03F1365B;
-                       break;
-               default:
-                       return -EINVAL;
-               }
-
-               break;
-       case T3LPB:
-       case BCS220_2:
-       case BCS220_2BC:
-       case BCS250_BC:
-       case BCS220_3:
-               /* Set bit 2 and bit 6 to 1 for BBIC 2mA drive
-                * (please check current value and additionally set these bits)
-                */
-       if ((Adapter->chip_id !=  BCS220_2) &&
-               (Adapter->chip_id !=  BCS220_2BC) &&
-               (Adapter->chip_id != BCS220_3)) {
-               retval = rdmalt(Adapter, (UINT)0x0f000830, &uiResetValue,
-                               sizeof(uiResetValue));
-               if (retval < 0) {
-                       BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL,
-                                       "%s:%d RDM failed\n",
-                                       __func__, __LINE__);
-                       return retval;
-               }
-               uiResetValue |= 0x44;
-               retval = wrmalt(Adapter, (UINT)0x0f000830, &uiResetValue,
-                               sizeof(uiResetValue));
-               if (retval < 0) {
-                       BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL,
-                                       "%s:%d RDM failed\n",
-                                       __func__, __LINE__);
-                       return retval;
-               }
-       }
-               switch (Adapter->DDRSetting) {
-
-
-
-               case DDR_80_MHZ:
-                       psDDRSetting = asT3LPB_DDRSetting80MHz;
-                       RegCount = (sizeof(asT3B_DDRSetting80MHz) /
-                                   sizeof(struct bcm_ddr_setting));
-                       break;
-               case DDR_100_MHZ:
-                       psDDRSetting = asT3LPB_DDRSetting100MHz;
-                       RegCount = (sizeof(asT3B_DDRSetting100MHz) /
-                                   sizeof(struct bcm_ddr_setting));
-                       break;
-               case DDR_133_MHZ:
-                       psDDRSetting = asT3LPB_DDRSetting133MHz;
-                       RegCount = (sizeof(asT3B_DDRSetting133MHz) /
-                                   sizeof(struct bcm_ddr_setting));
-
-                       if (Adapter->bMipsConfig == MIPS_200_MHZ)
-                               uiClockSetting = 0x03F13652;
-                       else
-                               uiClockSetting = 0x03F1365B;
-                       break;
-
-               case DDR_160_MHZ:
-                       psDDRSetting = asT3LPB_DDRSetting160MHz;
-                       RegCount = sizeof(asT3LPB_DDRSetting160MHz) /
-                                  sizeof(struct bcm_ddr_setting);
-
-                       if (Adapter->bMipsConfig == MIPS_200_MHZ)
-                               uiClockSetting = 0x03F137D2;
-                       else
-                               uiClockSetting = 0x03F137DB;
-               }
-                       break;
-
-       case 0xbece0110:
-       case 0xbece0120:
-       case 0xbece0121:
-       case 0xbece0130:
-       case 0xbece0300:
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
-                       "DDR Setting: %x\n", Adapter->DDRSetting);
-               switch (Adapter->DDRSetting) {
-               case DDR_80_MHZ:
-                       psDDRSetting = asT3_DDRSetting80MHz;
-                       RegCount = (sizeof(asT3_DDRSetting80MHz) /
-                                   sizeof(struct bcm_ddr_setting));
-                       break;
-               case DDR_100_MHZ:
-                       psDDRSetting = asT3_DDRSetting100MHz;
-                       RegCount = (sizeof(asT3_DDRSetting100MHz) /
-                                   sizeof(struct bcm_ddr_setting));
-                       break;
-               case DDR_133_MHZ:
-                       psDDRSetting = asT3_DDRSetting133MHz;
-                       RegCount = (sizeof(asT3_DDRSetting133MHz) /
-                                   sizeof(struct bcm_ddr_setting));
-                       break;
-               default:
-                       return -EINVAL;
-               }
-       case 0xbece0310:
-       {
-               switch (Adapter->DDRSetting) {
-               case DDR_80_MHZ:
-                       psDDRSetting = asT3B_DDRSetting80MHz;
-                       RegCount = (sizeof(asT3B_DDRSetting80MHz) /
-                                   sizeof(struct bcm_ddr_setting));
-                       break;
-               case DDR_100_MHZ:
-                       psDDRSetting = asT3B_DDRSetting100MHz;
-                       RegCount = (sizeof(asT3B_DDRSetting100MHz) /
-                                   sizeof(struct bcm_ddr_setting));
-                       break;
-               case DDR_133_MHZ:
-
-                       /* 266Mhz PLL selected. */
-                       if (Adapter->bDPLLConfig == PLL_266_MHZ) {
-                               memcpy(asT3B_DDRSetting133MHz, asDPLL_266MHZ,
-                                      sizeof(asDPLL_266MHZ));
-                               psDDRSetting = asT3B_DDRSetting133MHz;
-                               RegCount = (sizeof(asT3B_DDRSetting133MHz) /
-                                           sizeof(struct bcm_ddr_setting));
-                       } else {
-                               psDDRSetting = asT3B_DDRSetting133MHz;
-                               RegCount = (sizeof(asT3B_DDRSetting133MHz) /
-                                           sizeof(struct bcm_ddr_setting));
-                               if (Adapter->bMipsConfig == MIPS_200_MHZ)
-                                       uiClockSetting = 0x07F13652;
-                               else
-                                       uiClockSetting = 0x07F1365B;
-                       }
-                       break;
-               default:
-                       return -EINVAL;
-               }
-               break;
-
-       }
-       default:
-               return -EINVAL;
-       }
-
-       value = 0;
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
-                       "Register Count is =%lu\n", RegCount);
-       while (RegCount && !retval) {
-               if (uiClockSetting
-                               && psDDRSetting->ulRegAddress == MIPS_CLOCK_REG)
-                       value = uiClockSetting;
-               else
-                       value = psDDRSetting->ulRegValue;
-               retval = wrmalt(Adapter, psDDRSetting->ulRegAddress, &value,
-                               sizeof(value));
-               if (STATUS_SUCCESS != retval) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,
-                                       "%s:%d\n", __func__, __LINE__);
-                       break;
-               }
-
-               RegCount--;
-               psDDRSetting++;
-       }
-
-       if (Adapter->chip_id >= 0xbece3300) {
-
-               mdelay(3);
-               if ((Adapter->chip_id != BCS220_2) &&
-                       (Adapter->chip_id != BCS220_2BC) &&
-                       (Adapter->chip_id != BCS220_3)) {
-                       /* drive MDDR to half in case of UMA-B: */
-                       uiResetValue = 0x01010001;
-                       retval = wrmalt(Adapter, (UINT)0x0F007018,
-                                       &uiResetValue, sizeof(uiResetValue));
-                       if (retval < 0) {
-                               BCM_DEBUG_PRINT(Adapter, CMHOST, RDM,
-                                               DBG_LVL_ALL,
-                                               "%s:%d RDM failed\n",
-                                               __func__,
-                                               __LINE__);
-                               return retval;
-                       }
-                       uiResetValue = 0x00040020;
-                       retval = wrmalt(Adapter, (UINT)0x0F007094,
-                                       &uiResetValue, sizeof(uiResetValue));
-                       if (retval < 0) {
-                               BCM_DEBUG_PRINT(Adapter, CMHOST, RDM,
-                                               DBG_LVL_ALL,
-                                               "%s:%d RDM failed\n",
-                                               __func__,
-                                               __LINE__);
-                               return retval;
-                       }
-                       uiResetValue = 0x01020101;
-                       retval = wrmalt(Adapter, (UINT)0x0F00701c,
-                                       &uiResetValue, sizeof(uiResetValue));
-                       if (retval < 0) {
-                               BCM_DEBUG_PRINT(Adapter, CMHOST, RDM,
-                                               DBG_LVL_ALL,
-                                               "%s:%d RDM failed\n",
-                                               __func__,
-                                               __LINE__);
-                               return retval;
-                       }
-                       uiResetValue = 0x01010000;
-                       retval = wrmalt(Adapter, (UINT)0x0F007018,
-                                       &uiResetValue, sizeof(uiResetValue));
-                       if (retval < 0) {
-                               BCM_DEBUG_PRINT(Adapter, CMHOST, RDM,
-                                               DBG_LVL_ALL,
-                                               "%s:%d RDM failed\n",
-                                               __func__,
-                                               __LINE__);
-                               return retval;
-                       }
-               }
-               mdelay(3);
-
-               /* DC/DC standby change...
-                * This is to be done only for Hybrid PMU mode.
-                * with the current h/w there is no way to detect this.
-                * and since we dont have internal PMU lets do it under
-                * UMA-B chip id. we will change this when we will have
-                * internal PMU.
-                */
-               if (Adapter->PmuMode == HYBRID_MODE_7C) {
-                       retval = rdmalt(Adapter, (UINT)0x0f000c00,
-                                       &uiResetValue, sizeof(uiResetValue));
-                       if (retval < 0) {
-                               BCM_DEBUG_PRINT(Adapter, CMHOST, RDM,
-                                               DBG_LVL_ALL,
-                                               "%s:%d RDM failed\n",
-                                               __func__,
-                                               __LINE__);
-                               return retval;
-                       }
-                       retval = rdmalt(Adapter, (UINT)0x0f000c00,
-                                       &uiResetValue, sizeof(uiResetValue));
-                       if (retval < 0) {
-                               BCM_DEBUG_PRINT(Adapter, CMHOST, RDM,
-                                               DBG_LVL_ALL,
-                                               "%s:%d RDM failed\n",
-                                               __func__,
-                                               __LINE__);
-                               return retval;
-                       }
-                       uiResetValue = 0x1322a8;
-                       retval = wrmalt(Adapter, (UINT)0x0f000d1c,
-                                       &uiResetValue, sizeof(uiResetValue));
-                       if (retval < 0) {
-                               BCM_DEBUG_PRINT(Adapter, CMHOST, RDM,
-                                               DBG_LVL_ALL,
-                                               "%s:%d RDM failed\n",
-                                               __func__,
-                                               __LINE__);
-                               return retval;
-                       }
-                       retval = rdmalt(Adapter, (UINT)0x0f000c00,
-                                       &uiResetValue, sizeof(uiResetValue));
-                       if (retval < 0) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, RDM,
-                                               DBG_LVL_ALL,
-                                               "%s:%d RDM failed\n",
-                                               __func__,
-                                               __LINE__);
-                               return retval;
-                       }
-                       retval = rdmalt(Adapter, (UINT)0x0f000c00,
-                                       &uiResetValue, sizeof(uiResetValue));
-                       if (retval < 0) {
-                               BCM_DEBUG_PRINT(Adapter, CMHOST, RDM,
-                                               DBG_LVL_ALL,
-                                               "%s:%d RDM failed\n",
-                                               __func__,
-                                               __LINE__);
-                               return retval;
-                       }
-                       uiResetValue = 0x132296;
-                       retval = wrmalt(Adapter, (UINT)0x0f000d14,
-                                       &uiResetValue, sizeof(uiResetValue));
-                       if (retval < 0) {
-                               BCM_DEBUG_PRINT(Adapter, CMHOST, RDM,
-                                               DBG_LVL_ALL,
-                                               "%s:%d RDM failed\n",
-                                               __func__,
-                                               __LINE__);
-                               return retval;
-                       }
-               } else if (Adapter->PmuMode == HYBRID_MODE_6) {
-
-                       retval = rdmalt(Adapter, (UINT)0x0f000c00,
-                                       &uiResetValue, sizeof(uiResetValue));
-                       if (retval < 0) {
-                               BCM_DEBUG_PRINT(Adapter, CMHOST, RDM,
-                                               DBG_LVL_ALL,
-                                               "%s:%d RDM failed\n",
-                                               __func__,
-                                               __LINE__);
-                               return retval;
-                       }
-                       retval = rdmalt(Adapter, (UINT)0x0f000c00,
-                                       &uiResetValue, sizeof(uiResetValue));
-                       if (retval < 0) {
-                               BCM_DEBUG_PRINT(Adapter, CMHOST, RDM,
-                                               DBG_LVL_ALL,
-                                               "%s:%d RDM failed\n",
-                                               __func__,
-                                               __LINE__);
-                               return retval;
-                       }
-                       uiResetValue = 0x6003229a;
-                       retval = wrmalt(Adapter, (UINT)0x0f000d14,
-                                       &uiResetValue, sizeof(uiResetValue));
-                       if (retval < 0) {
-                               BCM_DEBUG_PRINT(Adapter, CMHOST, RDM,
-                                               DBG_LVL_ALL,
-                                               "%s:%d RDM failed\n",
-                                               __func__,
-                                               __LINE__);
-                               return retval;
-                       }
-                       retval = rdmalt(Adapter, (UINT)0x0f000c00,
-                                       &uiResetValue, sizeof(uiResetValue));
-                       if (retval < 0) {
-                               BCM_DEBUG_PRINT(Adapter, CMHOST, RDM,
-                                               DBG_LVL_ALL,
-                                               "%s:%d RDM failed\n",
-                                               __func__,
-                                               __LINE__);
-                               return retval;
-                       }
-                       retval = rdmalt(Adapter, (UINT)0x0f000c00,
-                                       &uiResetValue, sizeof(uiResetValue));
-                       if (retval < 0) {
-                               BCM_DEBUG_PRINT(Adapter, CMHOST, RDM,
-                                               DBG_LVL_ALL,
-                                               "%s:%d RDM failed\n",
-                                               __func__,
-                                               __LINE__);
-                               return retval;
-                       }
-                       uiResetValue = 0x1322a8;
-                       retval = wrmalt(Adapter, (UINT)0x0f000d1c,
-                                       &uiResetValue, sizeof(uiResetValue));
-                       if (retval < 0) {
-                               BCM_DEBUG_PRINT(Adapter, CMHOST, RDM,
-                                               DBG_LVL_ALL,
-                                               "%s:%d RDM failed\n",
-                                               __func__,
-                                               __LINE__);
-                               return retval;
-                       }
-               }
-
-       }
-       Adapter->bDDRInitDone = TRUE;
-       return retval;
-}
-
-int download_ddr_settings(struct bcm_mini_adapter *Adapter)
-{
-       struct bcm_ddr_setting *psDDRSetting = NULL;
-       ULONG RegCount = 0;
-       unsigned long ul_ddr_setting_load_addr =
-               DDR_DUMP_INTERNAL_DEVICE_MEMORY;
-       UINT value = 0;
-       int retval = STATUS_SUCCESS;
-       bool bOverrideSelfRefresh = false;
-
-       switch (Adapter->chip_id) {
-       case 0xbece3200:
-               switch (Adapter->DDRSetting) {
-               case DDR_80_MHZ:
-                       psDDRSetting = asT3LP_DDRSetting80MHz;
-                       RegCount = ARRAY_SIZE(asT3LP_DDRSetting80MHz);
-                       RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
-                       psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
-                       break;
-               case DDR_100_MHZ:
-                       psDDRSetting = asT3LP_DDRSetting100MHz;
-                       RegCount = ARRAY_SIZE(asT3LP_DDRSetting100MHz);
-                       RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
-                       psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
-                       break;
-               case DDR_133_MHZ:
-                       bOverrideSelfRefresh = TRUE;
-                       psDDRSetting = asT3LP_DDRSetting133MHz;
-                       RegCount = ARRAY_SIZE(asT3LP_DDRSetting133MHz);
-                       RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
-                       psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
-                       break;
-               default:
-                       return -EINVAL;
-               }
-               break;
-
-       case T3LPB:
-       case BCS220_2:
-       case BCS220_2BC:
-       case BCS250_BC:
-       case BCS220_3:
-               switch (Adapter->DDRSetting) {
-               case DDR_80_MHZ:
-                       psDDRSetting = asT3LPB_DDRSetting80MHz;
-                       RegCount = ARRAY_SIZE(asT3LPB_DDRSetting80MHz);
-                       RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
-                       psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
-                       break;
-               case DDR_100_MHZ:
-                       psDDRSetting = asT3LPB_DDRSetting100MHz;
-                       RegCount = ARRAY_SIZE(asT3LPB_DDRSetting100MHz);
-                       RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
-                       psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
-                       break;
-               case DDR_133_MHZ:
-                       bOverrideSelfRefresh = TRUE;
-                       psDDRSetting = asT3LPB_DDRSetting133MHz;
-                       RegCount = ARRAY_SIZE(asT3LPB_DDRSetting133MHz);
-                       RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
-                       psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
-                       break;
-
-               case DDR_160_MHZ:
-                       bOverrideSelfRefresh = TRUE;
-                       psDDRSetting = asT3LPB_DDRSetting160MHz;
-                       RegCount = ARRAY_SIZE(asT3LPB_DDRSetting160MHz);
-                       RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ;
-                       psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ;
-
-                       break;
-               default:
-                       return -EINVAL;
-               }
-               break;
-       case 0xbece0300:
-               switch (Adapter->DDRSetting) {
-               case DDR_80_MHZ:
-                       psDDRSetting = asT3_DDRSetting80MHz;
-                       RegCount = ARRAY_SIZE(asT3_DDRSetting80MHz);
-                       RegCount -= T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
-                       psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
-                       break;
-               case DDR_100_MHZ:
-                       psDDRSetting = asT3_DDRSetting100MHz;
-                       RegCount = ARRAY_SIZE(asT3_DDRSetting100MHz);
-                       RegCount -= T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
-                       psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
-                       break;
-               case DDR_133_MHZ:
-                       psDDRSetting = asT3_DDRSetting133MHz;
-                       RegCount = ARRAY_SIZE(asT3_DDRSetting133MHz);
-                       RegCount -= T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
-                       psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
-                       break;
-               default:
-                       return -EINVAL;
-               }
-       break;
-       case 0xbece0310:
-           {
-               switch (Adapter->DDRSetting) {
-               case DDR_80_MHZ:
-                       psDDRSetting = asT3B_DDRSetting80MHz;
-                       RegCount = ARRAY_SIZE(asT3B_DDRSetting80MHz);
-                       RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
-                       psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
-                       break;
-               case DDR_100_MHZ:
-                       psDDRSetting = asT3B_DDRSetting100MHz;
-                       RegCount = ARRAY_SIZE(asT3B_DDRSetting100MHz);
-                       RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
-                       psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
-                       break;
-               case DDR_133_MHZ:
-                       bOverrideSelfRefresh = TRUE;
-                       psDDRSetting = asT3B_DDRSetting133MHz;
-                       RegCount = ARRAY_SIZE(asT3B_DDRSetting133MHz);
-                       RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
-                       psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
-               break;
-               }
-               break;
-            }
-       default:
-               return -EINVAL;
-       }
-       /* total number of Register that has to be dumped */
-       value = RegCount;
-       retval = wrmalt(Adapter, ul_ddr_setting_load_addr, &value,
-                       sizeof(value));
-       if (retval) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,
-                               "%s:%d\n", __func__, __LINE__);
-
-               return retval;
-       }
-       ul_ddr_setting_load_addr += sizeof(ULONG);
-       /* signature */
-       value = (0x1d1e0dd0);
-       retval = wrmalt(Adapter, ul_ddr_setting_load_addr, &value,
-                       sizeof(value));
-       if (retval) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,
-                               "%s:%d\n", __func__, __LINE__);
-               return retval;
-       }
-
-       ul_ddr_setting_load_addr += sizeof(ULONG);
-       RegCount *= (sizeof(struct bcm_ddr_setting)/sizeof(ULONG));
-
-       while (RegCount && !retval) {
-               value = psDDRSetting->ulRegAddress;
-               retval = wrmalt(Adapter, ul_ddr_setting_load_addr, &value,
-                               sizeof(value));
-               ul_ddr_setting_load_addr += sizeof(ULONG);
-               if (!retval) {
-                       if (bOverrideSelfRefresh
-                                       && (psDDRSetting->ulRegAddress
-                                               == 0x0F007018))
-                               value = (psDDRSetting->ulRegValue | (1<<8));
-                       else
-                               value = psDDRSetting->ulRegValue;
-
-                       if (STATUS_SUCCESS != wrmalt(Adapter,
-                                                    ul_ddr_setting_load_addr,
-                                                    &value,
-                                                    sizeof(value))) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,
-                                               "%s:%d\n", __func__, __LINE__);
-                               break;
-                       }
-               }
-               ul_ddr_setting_load_addr += sizeof(ULONG);
-               RegCount--;
-               psDDRSetting++;
-       }
-       return retval;
-}
diff --git a/drivers/staging/bcm/DDRInit.h b/drivers/staging/bcm/DDRInit.h
deleted file mode 100644 (file)
index b0196fc..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef _DDR_INIT_H_
-#define _DDR_INIT_H_
-
-
-
-int ddr_init(struct bcm_mini_adapter *psAdapter);
-int download_ddr_settings(struct bcm_mini_adapter *psAdapter);
-
-#endif
diff --git a/drivers/staging/bcm/Debug.h b/drivers/staging/bcm/Debug.h
deleted file mode 100644 (file)
index 7b33121..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Debug.h
- *
- * Dynamic (runtime) debug framework implementation.
- * -kaiwan.
- */
-#ifndef _DEBUG_H
-#define _DEBUG_H
-#include <linux/string.h>
-#define NONE 0xFFFF
-
-/* TYPE and SUBTYPE
- * Define valid TYPE (or category or code-path, however you like to think of it)
- * and SUBTYPE s.
- * Type and SubType are treated as bitmasks.
- */
-#define DBG_TYPE_INITEXIT      (1 << 0)        /* 1 */
-#define DBG_TYPE_TX            (1 << 1)        /* 2 */
-#define DBG_TYPE_RX            (1 << 2)        /* 4 */
-#define DBG_TYPE_OTHERS                (1 << 3)        /* 8 */
-#define NUMTYPES               4
-
-/* -SUBTYPEs for TX :  TYPE is DBG_TYPE_TX -----//
- * Transmit.c ,Arp.c, LeakyBucket.c, And Qos.c
- * total 17 macros
- */
-/* Transmit.c */
-#define TX             1
-#define MP_SEND                (TX << 0)
-#define NEXT_SEND      (TX << 1)
-#define TX_FIFO                (TX << 2)
-#define TX_CONTROL     (TX << 3)
-
-/* Arp.c */
-#define IP_ADDR                (TX << 4)
-#define ARP_REQ                (TX << 5)
-#define ARP_RESP       (TX << 6)
-
-/* Leakybucket.c */
-#define TOKEN_COUNTS   (TX << 8)
-#define CHECK_TOKENS   (TX << 9)
-#define TX_PACKETS     (TX << 10)
-#define TIMER          (TX << 11)
-
-/* Qos.c */
-#define QOS            TX
-#define QUEUE_INDEX    (QOS << 12)
-#define IPV4_DBG       (QOS << 13)
-#define IPV6_DBG       (QOS << 14)
-#define PRUNE_QUEUE    (QOS << 15)
-#define SEND_QUEUE     (QOS << 16)
-
-/* TX_Misc */
-#define TX_OSAL_DBG    (TX << 17)
-
-/* --SUBTYPEs for ------INIT & EXIT---------------------
- * ------------ TYPE is DBG_TYPE_INITEXIT -----//
- * DriverEntry.c, bcmfwup.c, ChipDetectTask.c, HaltnReset.c, InterfaceDDR.c
- */
-#define MP             1
-#define DRV_ENTRY      (MP << 0)
-#define MP_INIT                (MP << 1)
-#define READ_REG       (MP << 3)
-#define DISPATCH       (MP << 2)
-#define CLAIM_ADAP     (MP << 4)
-#define REG_IO_PORT    (MP << 5)
-#define INIT_DISP      (MP << 6)
-#define RX_INIT                (MP << 7)
-
-/* -SUBTYPEs for --RX----------------------------------
- * ------------RX  :  TYPE is DBG_TYPE_RX -----//
- * Receive.c
- */
-#define RX             1
-#define RX_DPC         (RX << 0)
-#define RX_CTRL                (RX << 3)
-#define RX_DATA                (RX << 4)
-#define MP_RETURN      (RX << 1)
-#define LINK_MSG       (RX << 2)
-
-/* -SUBTYPEs for ----OTHER ROUTINES------------------
- * ------------OTHERS  :  TYPE is DBG_TYPE_OTHER -----//
- * HaltnReset,CheckForHang,PnP,Misc,CmHost
- * total 12 macros
- */
-#define OTHERS         1
-#define ISR            OTHERS
-#define MP_DPC         (ISR << 0)
-
-/* HaltnReset.c */
-#define HALT           OTHERS
-#define MP_HALT                (HALT << 1)
-#define CHECK_HANG     (HALT << 2)
-#define MP_RESET       (HALT << 3)
-#define MP_SHUTDOWN    (HALT << 4)
-
-/* pnp.c */
-#define PNP            OTHERS
-#define MP_PNP         (PNP << 5)
-
-/* Misc.c */
-#define MISC           OTHERS
-#define DUMP_INFO      (MISC << 6)
-#define CLASSIFY       (MISC << 7)
-#define LINK_UP_MSG    (MISC << 8)
-#define CP_CTRL_PKT    (MISC << 9)
-#define DUMP_CONTROL   (MISC << 10)
-#define LED_DUMP_INFO  (MISC << 11)
-
-/* CmHost.c */
-#define CMHOST         OTHERS
-#define SERIAL         (OTHERS << 12)
-#define IDLE_MODE      (OTHERS << 13)
-#define WRM            (OTHERS << 14)
-#define RDM            (OTHERS << 15)
-
-/* TODO - put PHS_SEND in Tx PHS_RECEIVE in Rx path ? */
-#define PHS_SEND       (OTHERS << 16)
-#define PHS_RECEIVE    (OTHERS << 17)
-#define PHS_MODULE     (OTHERS << 18)
-
-#define INTF_INIT      (OTHERS << 19)
-#define INTF_ERR       (OTHERS << 20)
-#define INTF_WARN      (OTHERS << 21)
-#define INTF_NORM      (OTHERS << 22)
-
-#define IRP_COMPLETION         (OTHERS << 23)
-#define SF_DESCRIPTOR_CNTS     (OTHERS << 24)
-#define PHS_DISPATCH           (OTHERS << 25)
-#define OSAL_DBG               (OTHERS << 26)
-#define NVM_RW                 (OTHERS << 27)
-
-#define HOST_MIBS      (OTHERS << 28)
-#define CONN_MSG       (CMHOST << 29)
-
-/* Debug level
- * We have 8 debug levels, in (numerical) increasing order of verbosity.
- * IMP: Currently implementing ONLY DBG_LVL_ALL , i.e. , all debug prints will
- * appear (of course, iff global debug flag is ON and we match the Type and SubType).
- * Finer granularity debug levels are currently not in use, although the feature exists.
- *
- * Another way to say this:
- * All the debug prints currently have 'debug_level' set to DBG_LVL_ALL .
- * You can compile-time change that to any of the below, if you wish to. However, as of now, there's
- * no dynamic facility to have the userspace 'TestApp' set debug_level. Slated for future expansion.
- */
-#define BCM_ALL                7
-#define        BCM_LOW         6
-#define        BCM_PRINT       5
-#define        BCM_NORMAL      4
-#define        BCM_MEDIUM      3
-#define        BCM_SCREAM      2
-#define        BCM_ERR         1
-/* Not meant for developer in debug prints.
- * To be used to disable all prints by setting the DBG_LVL_CURR to this value
- */
-#define        BCM_NONE        0
-
-/* The current driver logging level.
- * Everything at this level and (numerically) lower (meaning higher prio)
- * is logged.
- * Replace 'BCM_ALL' in the DBG_LVL_CURR macro with the logging level desired.
- * For eg. to set the logging level to 'errors only' use:
- *      #define DBG_LVL_CURR   (BCM_ERR)
- */
-
-#define DBG_LVL_CURR   (BCM_ALL)
-#define DBG_LVL_ALL    BCM_ALL
-
-/* ---Userspace mapping of Debug State.
- * Delibrately matches that of the Windows driver..
- * The TestApp's ioctl passes this struct to us.
- */
-struct bcm_user_debug_state {
-       unsigned int Subtype, Type;
-       unsigned int OnOff;
-/*     unsigned int debug_level; future expansion */
-} __packed;
-
-/* ---Kernel-space mapping of Debug State */
-struct bcm_debug_state {
-       unsigned int type;
-       /* A bitmap of 32 bits for Subtype per Type.
-        * Valid indexes in 'subtype' array are *only* 1,2,4 and 8,
-        * corresponding to valid Type values. Hence we use the 'Type' field
-        * as the index value, ignoring the array entries 0,3,5,6,7 !
-        */
-       unsigned int subtype[(NUMTYPES*2)+1];
-       unsigned int debug_level;
-};
-/* Instantiated in the Adapter structure
- * We'll reuse the debug level parameter to include a bit (the MSB) to indicate whether or not
- * we want the function's name printed.
- */
-#define DBG_NO_FUNC_PRINT      (1 << 31)
-#define DBG_LVL_BITMASK                0xFF
-
-/* --- Only for direct printk's; "hidden" to API. */
-#define DBG_TYPE_PRINTK                3
-
-#define BCM_DEBUG_PRINT(Adapter, Type, SubType, dbg_level, string, args...) \
-       do {                                                            \
-               if (DBG_TYPE_PRINTK == Type)                            \
-                       pr_info("%s:" string, __func__, ##args);        \
-               else if (Adapter &&                                     \
-                       (dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level && \
-                       (Type & Adapter->stDebugState.type) &&          \
-                       (SubType & Adapter->stDebugState.subtype[Type])) { \
-                       if (dbg_level & DBG_NO_FUNC_PRINT)              \
-                               pr_debug("%s:\n", string);      \
-                       else                                            \
-                               pr_debug("%s:\n" string, __func__, ##args); \
-               }                                                       \
-       } while (0)
-
-#define BCM_DEBUG_PRINT_BUFFER(Adapter, Type, SubType, dbg_level,  buffer, bufferlen) \
-       do {                                                            \
-               if (DBG_TYPE_PRINTK == Type ||                          \
-                       (Adapter &&                                     \
-                               (dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level  && \
-                               (Type & Adapter->stDebugState.type) &&  \
-                               (SubType & Adapter->stDebugState.subtype[Type]))) { \
-                       pr_debug("%s:\n", __func__);                    \
-                       print_hex_dump(KERN_DEBUG, " ", DUMP_PREFIX_OFFSET, \
-                               16, 1, buffer, bufferlen, false);       \
-               }                                                       \
-       } while (0)
-
-#define BCM_SHOW_DEBUG_BITMAP(Adapter) do {                    \
-       int i;                                                  \
-       for (i = 0; i < (NUMTYPES * 2) + 1; i++) {              \
-               if ((i == 1) || (i == 2) || (i == 4) || (i == 8)) {             \
-                       /* CAUTION! Forcefully turn on ALL debug paths and subpaths! \
-                        * Adapter->stDebugState.subtype[i] = 0xffffffff; \
-                        */ \
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "subtype[%d] = 0x%08x\n",       \
-                                       i, Adapter->stDebugState.subtype[i]); \
-               }       \
-       }               \
-} while (0)
-
-#endif
diff --git a/drivers/staging/bcm/HandleControlPacket.c b/drivers/staging/bcm/HandleControlPacket.c
deleted file mode 100644 (file)
index dd5d138..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-/**
- * @file HandleControlPacket.c
- * This file contains the routines to deal with
- * sending and receiving of control packets.
- */
-#include "headers.h"
-
-/**
- * When a control packet is received, analyze the
- * "status" and call appropriate response function.
- * Enqueue the control packet for Application.
- * @return None
- */
-static VOID handle_rx_control_packet(struct bcm_mini_adapter *Adapter,
-                                    struct sk_buff *skb)
-{
-       struct bcm_tarang_data *pTarang = NULL;
-       bool HighPriorityMessage = false;
-       struct sk_buff *newPacket = NULL;
-       CHAR cntrl_msg_mask_bit = 0;
-       bool drop_pkt_flag = TRUE;
-       USHORT usStatus = *(PUSHORT)(skb->data);
-
-       if (netif_msg_pktdata(Adapter))
-               print_hex_dump(KERN_DEBUG, PFX "rx control: ", DUMP_PREFIX_NONE,
-                              16, 1, skb->data, skb->len, 0);
-
-       switch (usStatus) {
-       case CM_RESPONSES:               /* 0xA0 */
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT,
-                       DBG_LVL_ALL,
-                       "MAC Version Seems to be Non Multi-Classifier, rejected by Driver");
-               HighPriorityMessage = TRUE;
-               break;
-       case CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP:
-               HighPriorityMessage = TRUE;
-               if (Adapter->LinkStatus == LINKUP_DONE)
-                       CmControlResponseMessage(Adapter,
-                               (skb->data + sizeof(USHORT)));
-               break;
-       case LINK_CONTROL_RESP:          /* 0xA2 */
-       case STATUS_RSP:                 /* 0xA1 */
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT,
-                       DBG_LVL_ALL, "LINK_CONTROL_RESP");
-               HighPriorityMessage = TRUE;
-               LinkControlResponseMessage(Adapter,
-                       (skb->data + sizeof(USHORT)));
-               break;
-       case STATS_POINTER_RESP:         /* 0xA6 */
-               HighPriorityMessage = TRUE;
-               StatisticsResponse(Adapter, (skb->data + sizeof(USHORT)));
-               break;
-       case IDLE_MODE_STATUS:           /* 0xA3 */
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT,
-                       DBG_LVL_ALL,
-                       "IDLE_MODE_STATUS Type Message Got from F/W");
-               InterfaceIdleModeRespond(Adapter, (PUINT)(skb->data +
-                                       sizeof(USHORT)));
-               HighPriorityMessage = TRUE;
-               break;
-
-       case AUTH_SS_HOST_MSG:
-               HighPriorityMessage = TRUE;
-               break;
-
-       default:
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT,
-                       DBG_LVL_ALL, "Got Default Response");
-               /* Let the Application Deal with This Packet */
-               break;
-       }
-
-       /* Queue The Control Packet to The Application Queues */
-       down(&Adapter->RxAppControlQueuelock);
-
-       for (pTarang = Adapter->pTarangs; pTarang; pTarang = pTarang->next) {
-               if (Adapter->device_removed)
-                       break;
-
-               drop_pkt_flag = TRUE;
-               /*
-                * There are cntrl msg from A0 to AC. It has been mapped to 0 to
-                * C bit in the cntrl mask.
-                * Also, by default AD to BF has been masked to the rest of the
-                * bits... which wil be ON by default.
-                * if mask bit is enable to particular pkt status, send it out
-                * to app else stop it.
-                */
-               cntrl_msg_mask_bit = (usStatus & 0x1F);
-               /*
-                * printk("\ninew  msg  mask bit which is disable in mask:%X",
-                *      cntrl_msg_mask_bit);
-                */
-               if (pTarang->RxCntrlMsgBitMask & (1 << cntrl_msg_mask_bit))
-                       drop_pkt_flag = false;
-
-               if ((drop_pkt_flag == TRUE) ||
-                               (pTarang->AppCtrlQueueLen > MAX_APP_QUEUE_LEN)
-                               || ((pTarang->AppCtrlQueueLen >
-                                       MAX_APP_QUEUE_LEN / 2) &&
-                                   (HighPriorityMessage == false))) {
-                       /*
-                        * Assumption:-
-                        * 1. every tarang manages it own dropped pkt
-                        *    statitistics
-                        * 2. Total packet dropped per tarang will be equal to
-                        *    the sum of all types of dropped pkt by that
-                        *    tarang only.
-                        */
-                       struct bcm_mibs_dropped_cntrl_msg *msg =
-                               &pTarang->stDroppedAppCntrlMsgs;
-                       switch (*(PUSHORT)skb->data) {
-                       case CM_RESPONSES:
-                               msg->cm_responses++;
-                               break;
-                       case CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP:
-                               msg->cm_control_newdsx_multiclassifier_resp++;
-                               break;
-                       case LINK_CONTROL_RESP:
-                               msg->link_control_resp++;
-                               break;
-                       case STATUS_RSP:
-                               msg->status_rsp++;
-                               break;
-                       case STATS_POINTER_RESP:
-                               msg->stats_pointer_resp++;
-                               break;
-                       case IDLE_MODE_STATUS:
-                               msg->idle_mode_status++;
-                               break;
-                       case AUTH_SS_HOST_MSG:
-                               msg->auth_ss_host_msg++;
-                               break;
-                       default:
-                               msg->low_priority_message++;
-                               break;
-                       }
-
-                       continue;
-               }
-
-               newPacket = skb_clone(skb, GFP_KERNEL);
-               if (!newPacket)
-                       break;
-               ENQUEUEPACKET(pTarang->RxAppControlHead,
-                               pTarang->RxAppControlTail, newPacket);
-               pTarang->AppCtrlQueueLen++;
-       }
-       up(&Adapter->RxAppControlQueuelock);
-       wake_up(&Adapter->process_read_wait_queue);
-       dev_kfree_skb(skb);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL,
-                       "After wake_up_interruptible");
-}
-
-/**
- * @ingroup ctrl_pkt_functions
- * Thread to handle control pkt reception
- */
-
-/* pointer to adapter object*/
-int control_packet_handler(struct bcm_mini_adapter *Adapter)
-{
-       struct sk_buff *ctrl_packet = NULL;
-       unsigned long flags = 0;
-       /* struct timeval tv; */
-       /* int *puiBuffer = NULL; */
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL,
-               "Entering to make thread wait on control packet event!");
-       while (1) {
-               wait_event_interruptible(Adapter->process_rx_cntrlpkt,
-                       atomic_read(&Adapter->cntrlpktCnt) ||
-                       Adapter->bWakeUpDevice ||
-                       kthread_should_stop());
-
-
-               if (kthread_should_stop()) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT,
-                               DBG_LVL_ALL, "Exiting\n");
-                       return 0;
-               }
-               if (TRUE == Adapter->bWakeUpDevice) {
-                       Adapter->bWakeUpDevice = false;
-                       if ((false == Adapter->bTriedToWakeUpFromlowPowerMode)
-                                       && ((TRUE == Adapter->IdleMode) ||
-                                           (TRUE == Adapter->bShutStatus))) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
-                                       CP_CTRL_PKT, DBG_LVL_ALL,
-                                       "Calling InterfaceAbortIdlemode\n");
-                               /*
-                                * Adapter->bTriedToWakeUpFromlowPowerMode
-                                *                                      = TRUE;
-                                */
-                               InterfaceIdleModeWakeup(Adapter);
-                       }
-                       continue;
-               }
-
-               while (atomic_read(&Adapter->cntrlpktCnt)) {
-                       spin_lock_irqsave(&Adapter->control_queue_lock, flags);
-                       ctrl_packet = Adapter->RxControlHead;
-                       if (ctrl_packet) {
-                               DEQUEUEPACKET(Adapter->RxControlHead,
-                                       Adapter->RxControlTail);
-                               /* Adapter->RxControlHead=ctrl_packet->next; */
-                       }
-
-                       spin_unlock_irqrestore(&Adapter->control_queue_lock,
-                                               flags);
-                       handle_rx_control_packet(Adapter, ctrl_packet);
-                       atomic_dec(&Adapter->cntrlpktCnt);
-               }
-
-               SetUpTargetDsxBuffers(Adapter);
-       }
-       return STATUS_SUCCESS;
-}
-
-INT flushAllAppQ(void)
-{
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-       struct bcm_tarang_data *pTarang = NULL;
-       struct sk_buff *PacketToDrop = NULL;
-
-       for (pTarang = Adapter->pTarangs; pTarang; pTarang = pTarang->next) {
-               while (pTarang->RxAppControlHead != NULL) {
-                       PacketToDrop = pTarang->RxAppControlHead;
-                       DEQUEUEPACKET(pTarang->RxAppControlHead,
-                                       pTarang->RxAppControlTail);
-                       dev_kfree_skb(PacketToDrop);
-               }
-               pTarang->AppCtrlQueueLen = 0;
-               /* dropped contrl packet statistics also should be reset. */
-               memset((PVOID)&pTarang->stDroppedAppCntrlMsgs, 0,
-                       sizeof(struct bcm_mibs_dropped_cntrl_msg));
-
-       }
-       return STATUS_SUCCESS;
-}
-
-
diff --git a/drivers/staging/bcm/HostMIBSInterface.h b/drivers/staging/bcm/HostMIBSInterface.h
deleted file mode 100644 (file)
index f922ac4..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-#ifndef _HOST_MIBSINTERFACE_H
-#define _HOST_MIBSINTERFACE_H
-
-/*
- * Copyright (c) 2007 Beceem Communications Pvt. Ltd
- * File Name: HostMIBSInterface.h
- * Abstract: This file contains DS used by the Host to update the Host
- * statistics used for the MIBS.
- */
-
-#define MIBS_MAX_CLASSIFIERS           100
-#define MIBS_MAX_PHSRULES              100
-#define MIBS_MAX_SERVICEFLOWS          17
-#define MIBS_MAX_IP_RANGE_LENGTH       4
-#define MIBS_MAX_PORT_RANGE            4
-#define MIBS_MAX_PROTOCOL_LENGTH       32
-#define MIBS_MAX_PHS_LENGTHS           255
-#define MIBS_IPV6_ADDRESS_SIZEINBYTES  0x10
-#define MIBS_IP_LENGTH_OF_ADDRESS      4
-#define MIBS_MAX_HIST_ENTRIES          12
-#define MIBS_PKTSIZEHIST_RANGE         128
-
-union bcm_mibs_ip_addr {
-       struct {
-               /* Source Ip Address Range */
-               unsigned long ulIpv4Addr[MIBS_MAX_IP_RANGE_LENGTH];
-               /* Source Ip Mask Address Range */
-               unsigned long ulIpv4Mask[MIBS_MAX_IP_RANGE_LENGTH];
-       };
-       struct {
-               /* Source Ip Address Range */
-               unsigned long ulIpv6Addr[MIBS_MAX_IP_RANGE_LENGTH * 4];
-               /* Source Ip Mask Address Range */
-               unsigned long ulIpv6Mask[MIBS_MAX_IP_RANGE_LENGTH * 4];
-       };
-       struct {
-               unsigned char ucIpv4Address[MIBS_MAX_IP_RANGE_LENGTH * MIBS_IP_LENGTH_OF_ADDRESS];
-               unsigned char ucIpv4Mask[MIBS_MAX_IP_RANGE_LENGTH * MIBS_IP_LENGTH_OF_ADDRESS];
-       };
-       struct {
-               unsigned char ucIpv6Address[MIBS_MAX_IP_RANGE_LENGTH * MIBS_IPV6_ADDRESS_SIZEINBYTES];
-               unsigned char ucIpv6Mask[MIBS_MAX_IP_RANGE_LENGTH * MIBS_IPV6_ADDRESS_SIZEINBYTES];
-       };
-};
-
-struct bcm_mibs_host_info {
-       u64     GoodTransmits;
-       u64     GoodReceives;
-       /* this to keep track of the Tx and Rx MailBox Registers. */
-       unsigned long   NumDesUsed;
-       unsigned long   CurrNumFreeDesc;
-       unsigned long   PrevNumFreeDesc;
-       /* to keep track the no of byte received */
-       unsigned long   PrevNumRcevBytes;
-       unsigned long   CurrNumRcevBytes;
-       /* QOS Related */
-       unsigned long   BEBucketSize;
-       unsigned long   rtPSBucketSize;
-       unsigned long   LastTxQueueIndex;
-       bool    TxOutofDescriptors;
-       bool    TimerActive;
-       u32     u32TotalDSD;
-       u32     aTxPktSizeHist[MIBS_MAX_HIST_ENTRIES];
-       u32     aRxPktSizeHist[MIBS_MAX_HIST_ENTRIES];
-};
-
-struct bcm_mibs_classifier_rule {
-       unsigned long   ulSFID;
-       unsigned char   ucReserved[2];
-       u16     uiClassifierRuleIndex;
-       bool    bUsed;
-       unsigned short  usVCID_Value;
-       u8      u8ClassifierRulePriority;
-       union bcm_mibs_ip_addr stSrcIpAddress;
-       /* IP Source Address Length */
-       unsigned char   ucIPSourceAddressLength;
-       union bcm_mibs_ip_addr stDestIpAddress;
-       /* IP Destination Address Length */
-       unsigned char   ucIPDestinationAddressLength;
-       unsigned char   ucIPTypeOfServiceLength;
-       unsigned char   ucTosLow;
-       unsigned char   ucTosHigh;
-       unsigned char   ucTosMask;
-       unsigned char   ucProtocolLength;
-       unsigned char   ucProtocol[MIBS_MAX_PROTOCOL_LENGTH];
-       unsigned short  usSrcPortRangeLo[MIBS_MAX_PORT_RANGE];
-       unsigned short  usSrcPortRangeHi[MIBS_MAX_PORT_RANGE];
-       unsigned char   ucSrcPortRangeLength;
-       unsigned short  usDestPortRangeLo[MIBS_MAX_PORT_RANGE];
-       unsigned short  usDestPortRangeHi[MIBS_MAX_PORT_RANGE];
-       unsigned char   ucDestPortRangeLength;
-       bool    bProtocolValid;
-       bool    bTOSValid;
-       bool    bDestIpValid;
-       bool    bSrcIpValid;
-       unsigned char   ucDirection;
-       bool    bIpv6Protocol;
-       u32     u32PHSRuleID;
-};
-
-struct bcm_mibs_phs_rule {
-       unsigned long   ulSFID;
-       u8      u8PHSI;
-       u8      u8PHSFLength;
-       u8      u8PHSF[MIBS_MAX_PHS_LENGTHS];
-       u8      u8PHSMLength;
-       u8      u8PHSM[MIBS_MAX_PHS_LENGTHS];
-       u8      u8PHSS;
-       u8      u8PHSV;
-       u8      reserved[5];
-       long    PHSModifiedBytes;
-       unsigned long   PHSModifiedNumPackets;
-       unsigned long   PHSErrorNumPackets;
-};
-
-struct bcm_mibs_parameters {
-       u32 wmanIfSfid;
-       u32 wmanIfCmnCpsSfState;
-       u32 wmanIfCmnCpsMaxSustainedRate;
-       u32 wmanIfCmnCpsMaxTrafficBurst;
-       u32 wmanIfCmnCpsMinReservedRate;
-       u32 wmanIfCmnCpsToleratedJitter;
-       u32 wmanIfCmnCpsMaxLatency;
-       u32 wmanIfCmnCpsFixedVsVariableSduInd;
-       u32 wmanIfCmnCpsSduSize;
-       u32 wmanIfCmnCpsSfSchedulingType;
-       u32 wmanIfCmnCpsArqEnable;
-       u32 wmanIfCmnCpsArqWindowSize;
-       u32 wmanIfCmnCpsArqBlockLifetime;
-       u32 wmanIfCmnCpsArqSyncLossTimeout;
-       u32 wmanIfCmnCpsArqDeliverInOrder;
-       u32 wmanIfCmnCpsArqRxPurgeTimeout;
-       u32 wmanIfCmnCpsArqBlockSize;
-       u32 wmanIfCmnCpsMinRsvdTolerableRate;
-       u32 wmanIfCmnCpsReqTxPolicy;
-       u32 wmanIfCmnSfCsSpecification;
-       u32 wmanIfCmnCpsTargetSaid;
-};
-
-struct bcm_mibs_table {
-       unsigned long   ulSFID;
-       unsigned short  usVCID_Value;
-       unsigned int    uiThreshold;
-       u8      u8TrafficPriority;
-       bool    bValid;
-       bool    bActive;
-       bool    bActivateRequestSent;
-       u8      u8QueueType;
-       unsigned int    uiMaxBucketSize;
-       unsigned int    uiCurrentQueueDepthOnTarget;
-       unsigned int    uiCurrentBytesOnHost;
-       unsigned int    uiCurrentPacketsOnHost;
-       unsigned int    uiDroppedCountBytes;
-       unsigned int    uiDroppedCountPackets;
-       unsigned int    uiSentBytes;
-       unsigned int    uiSentPackets;
-       unsigned int    uiCurrentDrainRate;
-       unsigned int    uiThisPeriodSentBytes;
-       u64     liDrainCalculated;
-       unsigned int    uiCurrentTokenCount;
-       u64     liLastUpdateTokenAt;
-       unsigned int    uiMaxAllowedRate;
-       unsigned int    NumOfPacketsSent;
-       unsigned char ucDirection;
-       unsigned short  usCID;
-       struct bcm_mibs_parameters stMibsExtServiceFlowTable;
-       unsigned int    uiCurrentRxRate;
-       unsigned int    uiThisPeriodRxBytes;
-       unsigned int    uiTotalRxBytes;
-       unsigned int    uiTotalTxBytes;
-};
-
-struct bcm_mibs_dropped_cntrl_msg {
-       unsigned long cm_responses;
-       unsigned long cm_control_newdsx_multiclassifier_resp;
-       unsigned long link_control_resp;
-       unsigned long status_rsp;
-       unsigned long stats_pointer_resp;
-       unsigned long idle_mode_status;
-       unsigned long auth_ss_host_msg;
-       unsigned long low_priority_message;
-};
-
-struct bcm_host_stats_mibs {
-       struct bcm_mibs_host_info stHostInfo;
-       struct bcm_mibs_classifier_rule astClassifierTable[MIBS_MAX_CLASSIFIERS];
-       struct bcm_mibs_table   astSFtable[MIBS_MAX_SERVICEFLOWS];
-       struct bcm_mibs_phs_rule astPhsRulesTable[MIBS_MAX_PHSRULES];
-       struct bcm_mibs_dropped_cntrl_msg stDroppedAppCntrlMsgs;
-};
-
-#endif
diff --git a/drivers/staging/bcm/IPv6Protocol.c b/drivers/staging/bcm/IPv6Protocol.c
deleted file mode 100644 (file)
index 27f3f41..0000000
+++ /dev/null
@@ -1,476 +0,0 @@
-#include "headers.h"
-
-static bool MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
-       struct bcm_ipv6_hdr *pstIpv6Header);
-static bool MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
-       struct bcm_ipv6_hdr *pstIpv6Header);
-static VOID DumpIpv6Header(struct bcm_ipv6_hdr *pstIpv6Header);
-
-static UCHAR *GetNextIPV6ChainedHeader(UCHAR **ppucPayload,
-       UCHAR *pucNextHeader, bool *bParseDone, USHORT *pusPayloadLength)
-{
-       UCHAR *pucRetHeaderPtr = NULL;
-       UCHAR *pucPayloadPtr = NULL;
-       USHORT  usNextHeaderOffset = 0;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       if ((ppucPayload == NULL) || (*pusPayloadLength == 0) ||
-               (*bParseDone)) {
-               *bParseDone = TRUE;
-               return NULL;
-       }
-
-       pucRetHeaderPtr = *ppucPayload;
-       pucPayloadPtr = *ppucPayload;
-
-       if (!pucRetHeaderPtr || !pucPayloadPtr) {
-               *bParseDone = TRUE;
-               return NULL;
-       }
-
-       /* Get the Nextt Header Type */
-       *bParseDone = false;
-
-
-       switch (*pucNextHeader) {
-       case IPV6HDR_TYPE_HOPBYHOP:
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
-                               DBG_LVL_ALL, "\nIPv6 HopByHop Header");
-               usNextHeaderOffset += sizeof(struct bcm_ipv6_options_hdr);
-               break;
-
-       case IPV6HDR_TYPE_ROUTING:
-               {
-                       struct bcm_ipv6_routing_hdr *pstIpv6RoutingHeader;
-
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
-                                       DBG_LVL_ALL, "\nIPv6 Routing Header");
-                       pstIpv6RoutingHeader =
-                               (struct bcm_ipv6_routing_hdr *)pucPayloadPtr;
-                       usNextHeaderOffset += sizeof(struct bcm_ipv6_routing_hdr);
-                       usNextHeaderOffset += pstIpv6RoutingHeader->ucNumAddresses *
-                                             IPV6_ADDRESS_SIZEINBYTES;
-               }
-               break;
-
-       case IPV6HDR_TYPE_FRAGMENTATION:
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
-                               DBG_LVL_ALL,
-                               "\nIPv6 Fragmentation Header");
-               usNextHeaderOffset += sizeof(struct bcm_ipv6_fragment_hdr);
-               break;
-
-       case IPV6HDR_TYPE_DESTOPTS:
-               {
-                       struct bcm_ipv6_dest_options_hdr *pstIpv6DestOptsHdr =
-                               (struct bcm_ipv6_dest_options_hdr *)pucPayloadPtr;
-                       int nTotalOptions = pstIpv6DestOptsHdr->ucHdrExtLen;
-
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
-                                       DBG_LVL_ALL,
-                                       "\nIPv6 DestOpts Header Header");
-                       usNextHeaderOffset += sizeof(struct bcm_ipv6_dest_options_hdr);
-                       usNextHeaderOffset += nTotalOptions *
-                                             IPV6_DESTOPTS_HDR_OPTIONSIZE;
-               }
-               break;
-
-
-       case IPV6HDR_TYPE_AUTHENTICATION:
-               {
-                       struct bcm_ipv6_authentication_hdr *pstIpv6AuthHdr =
-                               (struct bcm_ipv6_authentication_hdr *)pucPayloadPtr;
-                       int nHdrLen = pstIpv6AuthHdr->ucLength;
-
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
-                                       DBG_LVL_ALL,
-                                       "\nIPv6 Authentication Header");
-                       usNextHeaderOffset += nHdrLen * 4;
-               }
-               break;
-
-       case IPV6HDR_TYPE_ENCRYPTEDSECURITYPAYLOAD:
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
-                               DBG_LVL_ALL,
-                               "\nIPv6 Encrypted Security Payload Header");
-               *bParseDone = TRUE;
-               break;
-
-       case IPV6_ICMP_HDR_TYPE:
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
-                               DBG_LVL_ALL, "\nICMP Header");
-               *bParseDone = TRUE;
-               break;
-
-       case TCP_HEADER_TYPE:
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
-                               DBG_LVL_ALL, "\nTCP Header");
-               *bParseDone = TRUE;
-               break;
-
-       case UDP_HEADER_TYPE:
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
-                               DBG_LVL_ALL, "\nUDP Header");
-               *bParseDone = TRUE;
-               break;
-
-       default:
-               *bParseDone = TRUE;
-               break;
-       }
-
-       if (*bParseDone == false) {
-               if (*pusPayloadLength <= usNextHeaderOffset) {
-                       *bParseDone = TRUE;
-               } else {
-                       *pucNextHeader = *pucPayloadPtr;
-                       pucPayloadPtr += usNextHeaderOffset;
-                       (*pusPayloadLength) -= usNextHeaderOffset;
-               }
-
-       }
-
-       *ppucPayload = pucPayloadPtr;
-       return pucRetHeaderPtr;
-}
-
-
-static UCHAR GetIpv6ProtocolPorts(UCHAR *pucPayload, USHORT *pusSrcPort,
-       USHORT *pusDestPort, USHORT usPayloadLength, UCHAR ucNextHeader)
-{
-       UCHAR *pIpv6HdrScanContext = pucPayload;
-       bool bDone = false;
-       UCHAR ucHeaderType = 0;
-       UCHAR *pucNextHeader = NULL;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       if (!pucPayload || (usPayloadLength == 0))
-               return 0;
-
-       *pusSrcPort = *pusDestPort = 0;
-       ucHeaderType = ucNextHeader;
-       while (!bDone) {
-               pucNextHeader = GetNextIPV6ChainedHeader(&pIpv6HdrScanContext,
-                                                        &ucHeaderType,
-                                                        &bDone,
-                                                        &usPayloadLength);
-               if (bDone) {
-                       if ((ucHeaderType == TCP_HEADER_TYPE) ||
-                               (ucHeaderType == UDP_HEADER_TYPE)) {
-                               *pusSrcPort = *((PUSHORT)(pucNextHeader));
-                               *pusDestPort = *((PUSHORT)(pucNextHeader+2));
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
-                                               DBG_LVL_ALL,
-                                               "\nProtocol Ports - Src Port :0x%x Dest Port : 0x%x",
-                                               ntohs(*pusSrcPort),
-                                               ntohs(*pusDestPort));
-                       }
-                       break;
-
-               }
-       }
-       return ucHeaderType;
-}
-
-
-/*
- * Arg 1 struct bcm_mini_adapter *Adapter is a pointer ot the driver control
- * structure
- * Arg 2 PVOID pcIpHeader is a pointer to the IP header of the packet
- */
-USHORT IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader,
-                  struct bcm_classifier_rule *pstClassifierRule)
-{
-       USHORT  ushDestPort = 0;
-       USHORT  ushSrcPort = 0;
-       UCHAR   ucNextProtocolAboveIP = 0;
-       struct bcm_ipv6_hdr *pstIpv6Header = NULL;
-       bool bClassificationSucceed = false;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
-                       DBG_LVL_ALL, "IpVersion6 ==========>\n");
-
-       pstIpv6Header = pcIpHeader;
-
-       DumpIpv6Header(pstIpv6Header);
-
-       /*
-        * Try to get the next higher layer protocol
-        * and the Ports Nos if TCP or UDP
-        */
-       ucNextProtocolAboveIP = GetIpv6ProtocolPorts((UCHAR *)(pcIpHeader +
-                                                    sizeof(struct bcm_ipv6_hdr)),
-                                                    &ushSrcPort,
-                                                    &ushDestPort,
-                                                    pstIpv6Header->usPayloadLength,
-                                                    pstIpv6Header->ucNextHeader);
-
-       do {
-               if (pstClassifierRule->ucDirection == 0) {
-                       /*
-                        * cannot be processed for classification.
-                        * it is a down link connection
-                        */
-                       break;
-               }
-
-               if (!pstClassifierRule->bIpv6Protocol) {
-                       /*
-                        * We are looking for Ipv6 Classifiers
-                        * Lets ignore this classifier and try the next one
-                        */
-                       break;
-               }
-
-               bClassificationSucceed = MatchSrcIpv6Address(pstClassifierRule,
-                                                            pstIpv6Header);
-               if (!bClassificationSucceed)
-                       break;
-
-               bClassificationSucceed = MatchDestIpv6Address(pstClassifierRule,
-                                                             pstIpv6Header);
-               if (!bClassificationSucceed)
-                       break;
-
-               /*
-                * Match the protocol type.
-                * For IPv6 the next protocol at end of
-                * Chain of IPv6 prot headers
-                */
-               bClassificationSucceed = MatchProtocol(pstClassifierRule,
-                                                      ucNextProtocolAboveIP);
-               if (!bClassificationSucceed)
-                       break;
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
-                               DBG_LVL_ALL, "\nIPv6 Protocol Matched");
-
-               if ((ucNextProtocolAboveIP == TCP_HEADER_TYPE) ||
-                       (ucNextProtocolAboveIP == UDP_HEADER_TYPE)) {
-                       /* Match Src Port */
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
-                                       DBG_LVL_ALL, "\nIPv6 Source Port:%x\n",
-                                       ntohs(ushSrcPort));
-                       bClassificationSucceed = MatchSrcPort(pstClassifierRule,
-                                                             ntohs(ushSrcPort));
-                       if (!bClassificationSucceed)
-                               break;
-
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
-                                       DBG_LVL_ALL, "\nIPv6 Src Port Matched");
-
-                       /* Match Dest Port */
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
-                                       DBG_LVL_ALL,
-                                       "\nIPv6 Destination Port:%x\n",
-                                       ntohs(ushDestPort));
-                       bClassificationSucceed = MatchDestPort(pstClassifierRule,
-                                                              ntohs(ushDestPort));
-                       if (!bClassificationSucceed)
-                               break;
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
-                                       DBG_LVL_ALL,
-                                       "\nIPv6 Dest Port Matched");
-               }
-       } while (0);
-
-       if (bClassificationSucceed == TRUE) {
-               INT iMatchedSFQueueIndex = 0;
-
-               iMatchedSFQueueIndex = SearchSfid(Adapter,
-                                                 pstClassifierRule->ulSFID);
-               if ((iMatchedSFQueueIndex >= NO_OF_QUEUES) ||
-                   (Adapter->PackInfo[iMatchedSFQueueIndex].bActive == false))
-                       bClassificationSucceed = false;
-       }
-
-       return bClassificationSucceed;
-}
-
-
-static bool MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
-                               struct bcm_ipv6_hdr *pstIpv6Header)
-{
-       UINT uiLoopIndex = 0;
-       UINT uiIpv6AddIndex = 0;
-       UINT uiIpv6AddrNoLongWords = 4;
-       ULONG aulSrcIP[4];
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-       union u_ip_address *src_addr = &pstClassifierRule->stSrcIpAddress;
-
-       /*
-        * This is the no. of Src Addresses ie Range of IP Addresses contained
-        * in the classifier rule for which we need to match
-        */
-       UINT  uiCountIPSrcAddresses =
-               (UINT)pstClassifierRule->ucIPSourceAddressLength;
-
-
-       if (uiCountIPSrcAddresses == 0)
-               return TRUE;
-
-
-       /* First Convert the Ip Address in the packet to Host Endian order */
-       for (uiIpv6AddIndex = 0;
-            uiIpv6AddIndex < uiIpv6AddrNoLongWords;
-            uiIpv6AddIndex++)
-               aulSrcIP[uiIpv6AddIndex] =
-                       ntohl(pstIpv6Header->ulSrcIpAddress[uiIpv6AddIndex]);
-
-       for (uiLoopIndex = 0;
-            uiLoopIndex < uiCountIPSrcAddresses;
-            uiLoopIndex += uiIpv6AddrNoLongWords) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
-                               "\n Src Ipv6 Address In Received Packet :\n ");
-               DumpIpv6Address(aulSrcIP);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
-                               "\n Src Ipv6 Mask In Classifier Rule:\n");
-               DumpIpv6Address(&src_addr->ulIpv6Mask[uiLoopIndex]);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
-                               "\n Src Ipv6 Address In Classifier Rule :\n");
-               DumpIpv6Address(&src_addr->ulIpv6Addr[uiLoopIndex]);
-
-               for (uiIpv6AddIndex = 0;
-                    uiIpv6AddIndex < uiIpv6AddrNoLongWords;
-                    uiIpv6AddIndex++) {
-                       if ((src_addr->ulIpv6Mask[uiLoopIndex+uiIpv6AddIndex] &
-                               aulSrcIP[uiIpv6AddIndex]) !=
-                           src_addr->ulIpv6Addr[uiLoopIndex+uiIpv6AddIndex]) {
-                               /*
-                                * Match failed for current Ipv6 Address
-                                * Try next Ipv6 Address
-                                */
-                               break;
-                       }
-
-                       if (uiIpv6AddIndex ==  uiIpv6AddrNoLongWords-1) {
-                               /* Match Found */
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
-                                               DBG_LVL_ALL,
-                                               "Ipv6 Src Ip Address Matched\n");
-                               return TRUE;
-                       }
-               }
-       }
-       return false;
-}
-
-static bool MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
-                                struct bcm_ipv6_hdr *pstIpv6Header)
-{
-       UINT uiLoopIndex = 0;
-       UINT uiIpv6AddIndex = 0;
-       UINT uiIpv6AddrNoLongWords = 4;
-       ULONG aulDestIP[4];
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-       union u_ip_address *dest_addr = &pstClassifierRule->stDestIpAddress;
-
-       /*
-        * This is the no. of Destination Addresses
-        * ie Range of IP Addresses contained in the classifier rule
-        * for which we need to match
-        */
-       UINT uiCountIPDestinationAddresses =
-               (UINT)pstClassifierRule->ucIPDestinationAddressLength;
-
-       if (uiCountIPDestinationAddresses == 0)
-               return TRUE;
-
-
-       /* First Convert the Ip Address in the packet to Host Endian order */
-       for (uiIpv6AddIndex = 0;
-            uiIpv6AddIndex < uiIpv6AddrNoLongWords;
-            uiIpv6AddIndex++)
-               aulDestIP[uiIpv6AddIndex] =
-                       ntohl(pstIpv6Header->ulDestIpAddress[uiIpv6AddIndex]);
-
-       for (uiLoopIndex = 0;
-            uiLoopIndex < uiCountIPDestinationAddresses;
-            uiLoopIndex += uiIpv6AddrNoLongWords) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
-                               "\n Destination Ipv6 Address In Received Packet :\n ");
-               DumpIpv6Address(aulDestIP);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
-                               "\n Destination Ipv6 Mask In Classifier Rule :\n");
-               DumpIpv6Address(&dest_addr->ulIpv6Mask[uiLoopIndex]);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
-                               "\n Destination Ipv6 Address In Classifier Rule :\n");
-               DumpIpv6Address(&dest_addr->ulIpv6Addr[uiLoopIndex]);
-
-               for (uiIpv6AddIndex = 0;
-                    uiIpv6AddIndex < uiIpv6AddrNoLongWords;
-                    uiIpv6AddIndex++) {
-                       if ((dest_addr->ulIpv6Mask[uiLoopIndex+uiIpv6AddIndex] &
-                               aulDestIP[uiIpv6AddIndex]) !=
-                           dest_addr->ulIpv6Addr[uiLoopIndex+uiIpv6AddIndex]) {
-                               /*
-                                * Match failed for current Ipv6 Address.
-                                * Try next Ipv6 Address
-                                */
-                               break;
-                       }
-
-                       if (uiIpv6AddIndex ==  uiIpv6AddrNoLongWords-1) {
-                               /* Match Found */
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
-                                               DBG_LVL_ALL,
-                                               "Ipv6 Destination Ip Address Matched\n");
-                               return TRUE;
-                       }
-               }
-       }
-       return false;
-
-}
-
-VOID DumpIpv6Address(ULONG *puIpv6Address)
-{
-       UINT uiIpv6AddrNoLongWords = 4;
-       UINT uiIpv6AddIndex = 0;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       for (uiIpv6AddIndex = 0;
-            uiIpv6AddIndex < uiIpv6AddrNoLongWords;
-            uiIpv6AddIndex++) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
-                               ":%lx", puIpv6Address[uiIpv6AddIndex]);
-       }
-
-}
-
-static VOID DumpIpv6Header(struct bcm_ipv6_hdr *pstIpv6Header)
-{
-       UCHAR ucVersion;
-       UCHAR ucPrio;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
-                       "----Ipv6 Header---");
-       ucVersion = pstIpv6Header->ucVersionPrio & 0xf0;
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
-                       "Version : %x\n", ucVersion);
-       ucPrio = pstIpv6Header->ucVersionPrio & 0x0f;
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
-                       "Priority : %x\n", ucPrio);
-       /*
-        * BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
-        * "Flow Label : %x\n",(pstIpv6Header->ucVersionPrio &0xf0);
-        */
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
-                       "Payload Length : %x\n",
-                       ntohs(pstIpv6Header->usPayloadLength));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
-                       "Next Header : %x\n", pstIpv6Header->ucNextHeader);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
-                       "Hop Limit : %x\n", pstIpv6Header->ucHopLimit);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
-                       "Src Address :\n");
-       DumpIpv6Address(pstIpv6Header->ulSrcIpAddress);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
-                       "Dest Address :\n");
-       DumpIpv6Address(pstIpv6Header->ulDestIpAddress);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
-                       "----Ipv6 Header End---");
-
-
-}
diff --git a/drivers/staging/bcm/IPv6ProtocolHdr.h b/drivers/staging/bcm/IPv6ProtocolHdr.h
deleted file mode 100644 (file)
index 96b36a5..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#ifndef _IPV6_PROTOCOL_DEFINES_
-#define _IPV6_PROTOCOL_DEFINES_
-
-#define IPV6HDR_TYPE_HOPBYHOP 0x0
-#define IPV6HDR_TYPE_ROUTING 0x2B
-#define IPV6HDR_TYPE_FRAGMENTATION 0x2C
-#define IPV6HDR_TYPE_DESTOPTS 0x3c
-#define IPV6HDR_TYPE_AUTHENTICATION 0x33
-#define IPV6HDR_TYPE_ENCRYPTEDSECURITYPAYLOAD 0x34
-#define MASK_IPV6_CS_SPEC 0x2
-
-#define TCP_HEADER_TYPE        0x6
-#define UDP_HEADER_TYPE        0x11
-#define IPV6_ICMP_HDR_TYPE 0x2
-#define IPV6_FLOWLABEL_BITOFFSET 9
-
-#define IPV6_MAX_CHAINEDHDR_BUFFBYTES 0x64
-/*
- * Size of Dest Options field of Destinations Options Header
- * in bytes.
- */
-#define IPV6_DESTOPTS_HDR_OPTIONSIZE 0x8
-
-struct bcm_ipv6_hdr {
-       unsigned char  ucVersionPrio;
-       unsigned char  aucFlowLabel[3];
-       unsigned short usPayloadLength;
-       unsigned char  ucNextHeader;
-       unsigned char  ucHopLimit;
-       unsigned long  ulSrcIpAddress[4];
-       unsigned long  ulDestIpAddress[4];
-};
-
-struct bcm_ipv6_routing_hdr {
-       unsigned char ucNextHeader;
-       unsigned char ucRoutingType;
-       unsigned char ucNumAddresses;
-       unsigned char ucNextAddress;
-       unsigned long ulReserved;
-};
-
-struct bcm_ipv6_fragment_hdr {
-       unsigned char  ucNextHeader;
-       unsigned char  ucReserved;
-       unsigned short usFragmentOffset;
-       unsigned long  ulIdentification;
-};
-
-struct bcm_ipv6_dest_options_hdr {
-       unsigned char ucNextHeader;
-       unsigned char ucHdrExtLen;
-       unsigned char ucDestOptions[6];
-};
-
-struct bcm_ipv6_options_hdr {
-       unsigned char ucNextHeader;
-       unsigned char ucMisc[3];
-       unsigned long ulJumboPayloadLen;
-};
-
-struct bcm_ipv6_authentication_hdr {
-       unsigned char  ucNextHeader;
-       unsigned char  ucLength;
-       unsigned short usReserved;
-       unsigned long  ulSecurityParametersIndex;
-};
-
-enum bcm_ipaddr_context {
-       eSrcIpAddress,
-       eDestIpAddress
-};
-
-/* Function Prototypes */
-
-unsigned short IpVersion6(struct bcm_mini_adapter *Adapter, /* < Pointer to the driver control structure */
-                                       void *pcIpHeader, /* <Pointer to the IP Hdr of the packet */
-                                       struct bcm_classifier_rule *pstClassifierRule);
-
-void DumpIpv6Address(unsigned long *puIpv6Address);
-
-extern bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule, unsigned short ushSrcPort);
-extern bool MatchDestPort(struct bcm_classifier_rule *pstClassifierRule, unsigned short ushSrcPort);
-extern bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule, unsigned char ucProtocol);
-
-#endif
diff --git a/drivers/staging/bcm/InterfaceAdapter.h b/drivers/staging/bcm/InterfaceAdapter.h
deleted file mode 100644 (file)
index 06a6b18..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-#ifndef _INTERFACE_ADAPTER_H
-#define _INTERFACE_ADAPTER_H
-
-struct bcm_bulk_endpoint_in {
-       char    *bulk_in_buffer;
-       size_t  bulk_in_size;
-       unsigned char   bulk_in_endpointAddr;
-       unsigned int    bulk_in_pipe;
-};
-
-struct bcm_bulk_endpoint_out {
-       unsigned char   bulk_out_buffer;
-       size_t  bulk_out_size;
-       unsigned char   bulk_out_endpointAddr;
-       unsigned int    bulk_out_pipe;
-       /* this is used when int out endpoint is used as bulk out end point */
-       unsigned char   int_out_interval;
-};
-
-struct bcm_intr_endpoint_in {
-       char    *int_in_buffer;
-       size_t  int_in_size;
-       unsigned char   int_in_endpointAddr;
-       unsigned char   int_in_interval;
-       unsigned int    int_in_pipe;
-};
-
-struct bcm_intr_endpoint_out {
-       char    *int_out_buffer;
-       size_t  int_out_size;
-       unsigned char   int_out_endpointAddr;
-       unsigned char   int_out_interval;
-       unsigned int    int_out_pipe;
-};
-
-struct bcm_usb_tcb {
-       struct urb *urb;
-       void *psIntfAdapter;
-       bool bUsed;
-};
-
-struct bcm_usb_rcb {
-       struct urb *urb;
-       void *psIntfAdapter;
-       bool bUsed;
-};
-
-/*
- * This is the interface specific Sub-Adapter
- * Structure.
- */
-struct bcm_interface_adapter {
-       struct usb_device *udev;
-       struct usb_interface *interface;
-       /* Bulk endpoint in info */
-       struct bcm_bulk_endpoint_in     sBulkIn;
-       /* Bulk endpoint out info */
-       struct bcm_bulk_endpoint_out    sBulkOut;
-       /* Interrupt endpoint in info */
-       struct bcm_intr_endpoint_in     sIntrIn;
-       /* Interrupt endpoint out info */
-       struct bcm_intr_endpoint_out    sIntrOut;
-       unsigned long           ulInterruptData[2];
-       struct urb *psInterruptUrb;
-       struct bcm_usb_tcb      asUsbTcb[MAXIMUM_USB_TCB];
-       struct bcm_usb_rcb      asUsbRcb[MAXIMUM_USB_RCB];
-       atomic_t        uNumTcbUsed;
-       atomic_t        uCurrTcb;
-       atomic_t        uNumRcbUsed;
-       atomic_t        uCurrRcb;
-       struct bcm_mini_adapter *psAdapter;
-       bool            bFlashBoot;
-       bool            bHighSpeedDevice;
-       bool            bSuspended;
-       bool            bPreparingForBusSuspend;
-       struct work_struct usbSuspendWork;
-};
-
-#endif
diff --git a/drivers/staging/bcm/InterfaceDld.c b/drivers/staging/bcm/InterfaceDld.c
deleted file mode 100644 (file)
index abc7a7a..0000000
+++ /dev/null
@@ -1,317 +0,0 @@
-#include "headers.h"
-
-int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc)
-{
-       /* unsigned int reg = 0; */
-       mm_segment_t oldfs = {0};
-       int errno = 0, len = 0; /* ,is_config_file = 0 */
-       loff_t pos = 0;
-       struct bcm_interface_adapter *psIntfAdapter = arg;
-       /* struct bcm_mini_adapter *Adapter = psIntfAdapter->psAdapter; */
-       char *buff = kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL);
-
-       if (!buff)
-               return -ENOMEM;
-
-       while (1) {
-               oldfs = get_fs();
-               set_fs(get_ds());
-               len = vfs_read(flp, (void __force __user *)buff,
-                       MAX_TRANSFER_CTRL_BYTE_USB, &pos);
-               set_fs(oldfs);
-               if (len <= 0) {
-                       if (len < 0)
-                               errno = len;
-                       else
-                               errno = 0;
-                       break;
-               }
-               /* BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_INITEXIT, MP_INIT,
-                *                        DBG_LVL_ALL, buff,
-                *                        MAX_TRANSFER_CTRL_BYTE_USB);
-                */
-               errno = InterfaceWRM(psIntfAdapter, on_chip_loc, buff, len);
-               if (errno)
-                       break;
-               on_chip_loc += MAX_TRANSFER_CTRL_BYTE_USB;
-       }
-
-       kfree(buff);
-       return errno;
-}
-
-int InterfaceFileReadbackFromChip(PVOID arg, struct file *flp,
-                               unsigned int on_chip_loc)
-{
-       char *buff, *buff_readback;
-       unsigned int reg = 0;
-       mm_segment_t oldfs = {0};
-       int errno = 0, len = 0, is_config_file = 0;
-       loff_t pos = 0;
-       static int fw_down;
-       INT Status = STATUS_SUCCESS;
-       struct bcm_interface_adapter *psIntfAdapter = arg;
-       int bytes;
-
-       buff = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_DMA);
-       buff_readback = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB , GFP_DMA);
-       if (!buff || !buff_readback) {
-               kfree(buff);
-               kfree(buff_readback);
-
-               return -ENOMEM;
-       }
-
-       is_config_file = (on_chip_loc == CONFIG_BEGIN_ADDR) ? 1 : 0;
-
-       while (1) {
-               oldfs = get_fs();
-               set_fs(get_ds());
-               len = vfs_read(flp, (void __force __user *)buff,
-                               MAX_TRANSFER_CTRL_BYTE_USB, &pos);
-               set_fs(oldfs);
-               fw_down++;
-
-               if (len <= 0) {
-                       if (len < 0)
-                               errno = len;
-                       else
-                               errno = 0;
-                       break;
-               }
-
-               bytes = InterfaceRDM(psIntfAdapter, on_chip_loc,
-                                       buff_readback, len);
-               if (bytes < 0) {
-                       Status = bytes;
-                       goto exit;
-               }
-               reg++;
-               if ((len-sizeof(unsigned int)) < 4) {
-                       if (memcmp(buff_readback, buff, len)) {
-                               Status = -EIO;
-                               goto exit;
-                       }
-               } else {
-                       len -= 4;
-
-                       while (len) {
-                               if (*(unsigned int *)&buff_readback[len] !=
-                                                *(unsigned int *)&buff[len]) {
-                                       Status = -EIO;
-                                       goto exit;
-                               }
-                               len -= 4;
-                       }
-               }
-               on_chip_loc += MAX_TRANSFER_CTRL_BYTE_USB;
-       } /* End of while(1) */
-
-exit:
-       kfree(buff);
-       kfree(buff_readback);
-       return Status;
-}
-
-static int bcm_download_config_file(struct bcm_mini_adapter *Adapter,
-                               struct bcm_firmware_info *psFwInfo)
-{
-       int retval = STATUS_SUCCESS;
-       B_UINT32 value = 0;
-
-       if (Adapter->pstargetparams == NULL) {
-               Adapter->pstargetparams =
-                       kmalloc(sizeof(struct bcm_target_params), GFP_KERNEL);
-               if (Adapter->pstargetparams == NULL)
-                       return -ENOMEM;
-       }
-
-       if (psFwInfo->u32FirmwareLength != sizeof(struct bcm_target_params))
-               return -EIO;
-
-       retval = copy_from_user(Adapter->pstargetparams,
-                       psFwInfo->pvMappedFirmwareAddress,
-                       psFwInfo->u32FirmwareLength);
-       if (retval) {
-               kfree(Adapter->pstargetparams);
-               Adapter->pstargetparams = NULL;
-               return -EFAULT;
-       }
-
-       /* Parse the structure and then Download the Firmware */
-       beceem_parse_target_struct(Adapter);
-
-       /* Initializing the NVM. */
-       BcmInitNVM(Adapter);
-       retval = InitLedSettings(Adapter);
-
-       if (retval)
-               return retval;
-
-       if (Adapter->LEDInfo.led_thread_running &
-                       BCM_LED_THREAD_RUNNING_ACTIVELY) {
-               Adapter->LEDInfo.bLedInitDone = false;
-               Adapter->DriverState = DRIVER_INIT;
-               wake_up(&Adapter->LEDInfo.notify_led_event);
-       }
-
-       if (Adapter->LEDInfo.led_thread_running &
-                       BCM_LED_THREAD_RUNNING_ACTIVELY) {
-               Adapter->DriverState = FW_DOWNLOAD;
-               wake_up(&Adapter->LEDInfo.notify_led_event);
-       }
-
-       /* Initialize the DDR Controller */
-       retval = ddr_init(Adapter);
-       if (retval)
-               return retval;
-
-       value = 0;
-       wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4,
-                               &value, sizeof(value));
-       wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8,
-                               &value, sizeof(value));
-
-       if (Adapter->eNVMType == NVM_FLASH) {
-               retval = PropagateCalParamsFromFlashToMemory(Adapter);
-               if (retval)
-                       return retval;
-       }
-
-       retval = buffDnldVerify(Adapter, (PUCHAR)Adapter->pstargetparams,
-                       sizeof(struct bcm_target_params), CONFIG_BEGIN_ADDR);
-
-       if (retval)
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT,
-                               MP_INIT, DBG_LVL_ALL,
-                               "configuration file not downloaded properly");
-       else
-               Adapter->bCfgDownloaded = TRUE;
-
-       return retval;
-}
-
-int bcm_ioctl_fw_download(struct bcm_mini_adapter *Adapter,
-                       struct bcm_firmware_info *psFwInfo)
-{
-       int retval = STATUS_SUCCESS;
-       PUCHAR buff = NULL;
-
-       /* Config File is needed for the Driver to download the Config file and
-        * Firmware. Check for the Config file to be first to be sent from the
-        * Application
-        */
-       atomic_set(&Adapter->uiMBupdate, false);
-       if (!Adapter->bCfgDownloaded &&
-               psFwInfo->u32StartingAddress != CONFIG_BEGIN_ADDR) {
-               /* Can't Download Firmware. */
-               return -EINVAL;
-       }
-
-       /* If Config File, Finish the DDR Settings and then Download CFG File */
-       if (psFwInfo->u32StartingAddress == CONFIG_BEGIN_ADDR) {
-               retval = bcm_download_config_file(Adapter, psFwInfo);
-       } else {
-               buff = kzalloc(psFwInfo->u32FirmwareLength, GFP_KERNEL);
-               if (buff == NULL)
-                       return -ENOMEM;
-
-               retval = copy_from_user(buff,
-                       psFwInfo->pvMappedFirmwareAddress,
-                       psFwInfo->u32FirmwareLength);
-               if (retval != STATUS_SUCCESS) {
-                       retval = -EFAULT;
-                       goto error;
-               }
-
-               retval = buffDnldVerify(Adapter,
-                                       buff,
-                                       psFwInfo->u32FirmwareLength,
-                                       psFwInfo->u32StartingAddress);
-
-               if (retval != STATUS_SUCCESS)
-                       goto error;
-       }
-
-error:
-       kfree(buff);
-       return retval;
-}
-
-static INT buffDnld(struct bcm_mini_adapter *Adapter,
-                       PUCHAR mappedbuffer, UINT u32FirmwareLength,
-                       ULONG u32StartingAddress)
-{
-       unsigned int len = 0;
-       int retval = STATUS_SUCCESS;
-
-       len = u32FirmwareLength;
-
-       while (u32FirmwareLength) {
-               len = MIN_VAL(u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB);
-               retval = wrm(Adapter, u32StartingAddress, mappedbuffer, len);
-
-               if (retval)
-                       break;
-               u32StartingAddress += len;
-               u32FirmwareLength -= len;
-               mappedbuffer += len;
-       }
-       return retval;
-}
-
-static INT buffRdbkVerify(struct bcm_mini_adapter *Adapter,
-                       PUCHAR mappedbuffer, UINT u32FirmwareLength,
-                       ULONG u32StartingAddress)
-{
-       UINT len = u32FirmwareLength;
-       INT retval = STATUS_SUCCESS;
-       PUCHAR readbackbuff = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL);
-       int bytes;
-
-       if (NULL == readbackbuff)
-               return -ENOMEM;
-
-       while (u32FirmwareLength && !retval) {
-               len = MIN_VAL(u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB);
-               bytes = rdm(Adapter, u32StartingAddress, readbackbuff, len);
-
-               if (bytes < 0) {
-                       retval = bytes;
-                       break;
-               }
-
-               if (memcmp(readbackbuff, mappedbuffer, len) != 0) {
-                       pr_err("%s() failed.  The firmware doesn't match what was written",
-                              __func__);
-                       retval = -EIO;
-               }
-
-               u32StartingAddress += len;
-               u32FirmwareLength -= len;
-               mappedbuffer += len;
-
-       } /* end of while (u32FirmwareLength && !retval) */
-       kfree(readbackbuff);
-       return retval;
-}
-
-INT buffDnldVerify(struct bcm_mini_adapter *Adapter,
-                       unsigned char *mappedbuffer,
-                       unsigned int u32FirmwareLength,
-                       unsigned long u32StartingAddress)
-{
-       INT status = STATUS_SUCCESS;
-
-       status = buffDnld(Adapter, mappedbuffer,
-                       u32FirmwareLength, u32StartingAddress);
-       if (status != STATUS_SUCCESS)
-               goto error;
-
-       status = buffRdbkVerify(Adapter, mappedbuffer,
-                       u32FirmwareLength, u32StartingAddress);
-       if (status != STATUS_SUCCESS)
-               goto error;
-error:
-       return status;
-}
diff --git a/drivers/staging/bcm/InterfaceIdleMode.c b/drivers/staging/bcm/InterfaceIdleMode.c
deleted file mode 100644 (file)
index 612c89f..0000000
+++ /dev/null
@@ -1,274 +0,0 @@
-#include "headers.h"
-
-/*
-Function:      InterfaceIdleModeWakeup
-
-Description:   This is the hardware specific Function for
-               waking up HW device from Idle mode.
-               A software abort pattern is written to the
-               device to wake it and necessary power state
-               transitions from host are performed here.
-
-Input parameters: IN struct bcm_mini_adapter *Adapter
-                 - Miniport Adapter Context
-
-Return:                BCM_STATUS_SUCCESS - If Wakeup of the HW Interface
-                                    was successful.
-               Other              - If an error occurred.
-*/
-
-/*
-Function:      InterfaceIdleModeRespond
-
-Description:   This is the hardware specific Function for
-               responding to Idle mode request from target.
-               Necessary power state transitions from host for
-               idle mode or other device specific initializations
-               are performed here.
-
-Input parameters: IN struct bcm_mini_adapter * Adapter
-                 - Miniport Adapter Context
-
-Return:                BCM_STATUS_SUCCESS - If Idle mode response related
-                                    HW configuration was successful.
-               Other              - If an error occurred.
-*/
-
-/*
-"dmem bfc02f00  100" tells how many time device went in Idle mode.
-this value will be at address bfc02fa4.just before value d0ea1dle.
-
-Set time value by writing at bfc02f98 7d0
-
-checking the Ack timer expire on kannon by running command
-d qcslog .. if it shows e means host has not send response
-to f/w with in 200 ms. Response should be
-send to f/w with in 200 ms after the Idle/Shutdown req issued
-
-*/
-
-
-int InterfaceIdleModeRespond(struct bcm_mini_adapter *Adapter,
-                       unsigned int *puiBuffer)
-{
-       int     status = STATUS_SUCCESS;
-       unsigned int    uiRegRead = 0;
-       int bytes;
-
-       if (ntohl(*puiBuffer) == GO_TO_IDLE_MODE_PAYLOAD) {
-               if (ntohl(*(puiBuffer+1)) == 0) {
-
-                       status = wrmalt(Adapter, SW_ABORT_IDLEMODE_LOC,
-                                       &uiRegRead, sizeof(uiRegRead));
-                       if (status)
-                               return status;
-
-                       if (Adapter->ulPowerSaveMode ==
-                               DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) {
-                               uiRegRead = 0x00000000;
-                               status = wrmalt(Adapter,
-                                       DEBUG_INTERRUPT_GENERATOR_REGISTOR,
-                                       &uiRegRead, sizeof(uiRegRead));
-                               if (status)
-                                       return status;
-                       }
-                       /* Below Register should not br read in case of
-                        * Manual and Protocol Idle mode */
-                       else if (Adapter->ulPowerSaveMode !=
-                               DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) {
-                               /* clear on read Register */
-                               bytes = rdmalt(Adapter, DEVICE_INT_OUT_EP_REG0,
-                                       &uiRegRead, sizeof(uiRegRead));
-                               if (bytes < 0) {
-                                       status = bytes;
-                                       return status;
-                               }
-                               /* clear on read Register */
-                               bytes = rdmalt(Adapter, DEVICE_INT_OUT_EP_REG1,
-                                       &uiRegRead, sizeof(uiRegRead));
-                               if (bytes < 0) {
-                                       status = bytes;
-                                       return status;
-                               }
-                       }
-
-                       /* Set Idle Mode Flag to False and
-                        * Clear IdleMode reg. */
-                       Adapter->IdleMode = false;
-                       Adapter->bTriedToWakeUpFromlowPowerMode = false;
-
-                       wake_up(&Adapter->lowpower_mode_wait_queue);
-
-               } else {
-                       if (TRUE == Adapter->IdleMode)
-                               return status;
-
-                       uiRegRead = 0;
-
-                       if (Adapter->chip_id == BCS220_2 ||
-                               Adapter->chip_id == BCS220_2BC ||
-                                       Adapter->chip_id == BCS250_BC ||
-                                       Adapter->chip_id == BCS220_3) {
-
-                               bytes = rdmalt(Adapter, HPM_CONFIG_MSW,
-                                       &uiRegRead, sizeof(uiRegRead));
-                               if (bytes < 0) {
-                                       status = bytes;
-                                       return status;
-                               }
-
-
-                               uiRegRead |= (1<<17);
-
-                               status = wrmalt(Adapter, HPM_CONFIG_MSW,
-                                       &uiRegRead, sizeof(uiRegRead));
-                               if (status)
-                                       return status;
-                       }
-                       SendIdleModeResponse(Adapter);
-               }
-       } else if (ntohl(*puiBuffer) == IDLE_MODE_SF_UPDATE_MSG) {
-               OverrideServiceFlowParams(Adapter, puiBuffer);
-       }
-       return status;
-}
-
-static int InterfaceAbortIdlemode(struct bcm_mini_adapter *Adapter,
-                               unsigned int Pattern)
-{
-       int status = STATUS_SUCCESS;
-       unsigned int value;
-       unsigned int chip_id;
-       unsigned long timeout = 0, itr = 0;
-
-       int lenwritten = 0;
-       unsigned char aucAbortPattern[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-                                               0xFF, 0xFF, 0xFF};
-       struct bcm_interface_adapter *psInterfaceAdapter =
-                               Adapter->pvInterfaceAdapter;
-
-       /* Abort Bus suspend if its already suspended */
-       if ((TRUE == psInterfaceAdapter->bSuspended) &&
-                       (TRUE == Adapter->bDoSuspend))
-               status = usb_autopm_get_interface(
-                               psInterfaceAdapter->interface);
-
-       if ((Adapter->ulPowerSaveMode ==
-                       DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) ||
-          (Adapter->ulPowerSaveMode ==
-                       DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)) {
-               /* write the SW abort pattern. */
-               status = wrmalt(Adapter, SW_ABORT_IDLEMODE_LOC,
-                               &Pattern, sizeof(Pattern));
-               if (status)
-                       return status;
-       }
-
-       if (Adapter->ulPowerSaveMode ==
-               DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) {
-               value = 0x80000000;
-               status = wrmalt(Adapter,
-                               DEBUG_INTERRUPT_GENERATOR_REGISTOR,
-                               &value, sizeof(value));
-               if (status)
-                       return status;
-       } else if (Adapter->ulPowerSaveMode !=
-                       DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) {
-               /*
-                * Get a Interrupt Out URB and send 8 Bytes Down
-                * To be Done in Thread Context.
-                * Not using Asynchronous Mechanism.
-                */
-               status = usb_interrupt_msg(psInterfaceAdapter->udev,
-                       usb_sndintpipe(psInterfaceAdapter->udev,
-                       psInterfaceAdapter->sIntrOut.int_out_endpointAddr),
-                       aucAbortPattern,
-                       8,
-                       &lenwritten,
-                       5000);
-               if (status)
-                       return status;
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
-                               IDLE_MODE, DBG_LVL_ALL,
-                               "NOB Sent down :%d", lenwritten);
-
-               /* mdelay(25); */
-
-               timeout = jiffies +  msecs_to_jiffies(50);
-               while (time_after(timeout, jiffies)) {
-                       itr++;
-                       rdmalt(Adapter, CHIP_ID_REG, &chip_id, sizeof(UINT));
-                       if (0xbece3200 == (chip_id&~(0xF0)))
-                               chip_id = chip_id&~(0xF0);
-                       if (chip_id == Adapter->chip_id)
-                               break;
-               }
-               if (time_before(timeout, jiffies))
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
-                               IDLE_MODE, DBG_LVL_ALL,
-                               "Not able to read chip-id even after 25 msec");
-               else
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
-                               IDLE_MODE, DBG_LVL_ALL,
-                               "Number of completed iteration to read chip-id :%lu", itr);
-
-               status = wrmalt(Adapter, SW_ABORT_IDLEMODE_LOC,
-                               &Pattern, sizeof(status));
-               if (status)
-                       return status;
-       }
-       return status;
-}
-int InterfaceIdleModeWakeup(struct bcm_mini_adapter *Adapter)
-{
-       if (Adapter->bTriedToWakeUpFromlowPowerMode) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
-               IDLE_MODE, DBG_LVL_ALL,
-               "Wake up already attempted.. ignoring\n");
-       } else {
-               Adapter->bTriedToWakeUpFromlowPowerMode = TRUE;
-               InterfaceAbortIdlemode(Adapter, Adapter->usIdleModePattern);
-
-       }
-       return 0;
-}
-
-void InterfaceHandleShutdownModeWakeup(struct bcm_mini_adapter *Adapter)
-{
-       unsigned int uiRegVal = 0;
-       INT Status = 0;
-       int bytes;
-
-       if (Adapter->ulPowerSaveMode ==
-               DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) {
-               /* clear idlemode interrupt. */
-               uiRegVal = 0;
-               Status = wrmalt(Adapter,
-                       DEBUG_INTERRUPT_GENERATOR_REGISTOR,
-                       &uiRegVal, sizeof(uiRegVal));
-               if (Status)
-                       return;
-       }
-
-       else {
-
-/* clear Interrupt EP registers. */
-               bytes = rdmalt(Adapter,
-                       DEVICE_INT_OUT_EP_REG0,
-                       &uiRegVal, sizeof(uiRegVal));
-               if (bytes < 0) {
-                       Status = bytes;
-                       return;
-               }
-
-               bytes = rdmalt(Adapter,
-                       DEVICE_INT_OUT_EP_REG1,
-                       &uiRegVal, sizeof(uiRegVal));
-               if (bytes < 0) {
-                       Status = bytes;
-                       return;
-               }
-       }
-}
-
diff --git a/drivers/staging/bcm/InterfaceIdleMode.h b/drivers/staging/bcm/InterfaceIdleMode.h
deleted file mode 100644 (file)
index 2ef6400..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef _INTERFACE_IDLEMODE_H
-#define _INTERFACE_IDLEMODE_H
-
-INT InterfaceIdleModeWakeup(struct bcm_mini_adapter *Adapter);
-
-INT InterfaceIdleModeRespond(struct bcm_mini_adapter *Adapter,
-                               unsigned int *puiBuffer);
-
-VOID InterfaceWriteIdleModeWakePattern(struct bcm_mini_adapter *Adapter);
-
-INT InterfaceWakeUp(struct bcm_mini_adapter *Adapter);
-
-VOID InterfaceHandleShutdownModeWakeup(struct bcm_mini_adapter *Adapter);
-#endif
-
diff --git a/drivers/staging/bcm/InterfaceInit.c b/drivers/staging/bcm/InterfaceInit.c
deleted file mode 100644 (file)
index bb61d34..0000000
+++ /dev/null
@@ -1,729 +0,0 @@
-#include "headers.h"
-#include <linux/usb/ch9.h>
-static struct usb_device_id InterfaceUsbtable[] = {
-       { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3) },
-       { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3B) },
-       { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3L) },
-       { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_SYM) },
-       { USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_226) },
-       { USB_DEVICE(BCM_USB_VENDOR_ID_FOXCONN, BCM_USB_PRODUCT_ID_1901) },
-       { USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_ZTE_TU25) },
-       { USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_ZTE_226) },
-       { USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_ZTE_326) },
-       { }
-};
-MODULE_DEVICE_TABLE(usb, InterfaceUsbtable);
-
-static int debug = -1;
-module_param(debug, uint, 0600);
-MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
-
-static const u32 default_msg =
-       NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK
-       | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR
-       | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN;
-
-static int InterfaceAdapterInit(struct bcm_interface_adapter *Adapter);
-
-static void InterfaceAdapterFree(struct bcm_interface_adapter *psIntfAdapter)
-{
-       int i = 0;
-       struct bcm_mini_adapter *ps_ad = psIntfAdapter->psAdapter;
-
-       /* Wake up the wait_queue... */
-       if (ps_ad->LEDInfo.led_thread_running &
-                       BCM_LED_THREAD_RUNNING_ACTIVELY) {
-               ps_ad->DriverState = DRIVER_HALT;
-               wake_up(&ps_ad->LEDInfo.notify_led_event);
-       }
-       reset_card_proc(ps_ad);
-
-       /*
-        * worst case time taken by the RDM/WRM will be 5 sec. will check after
-        * every 100 ms to accertain the device is not being accessed. After
-        * this No RDM/WRM should be made.
-        */
-       while (ps_ad->DeviceAccess) {
-               BCM_DEBUG_PRINT(ps_ad, DBG_TYPE_INITEXIT, DRV_ENTRY,
-                               DBG_LVL_ALL, "Device is being accessed.\n");
-               msleep(100);
-       }
-       /* Free interrupt URB */
-       /* ps_ad->device_removed = TRUE; */
-       usb_free_urb(psIntfAdapter->psInterruptUrb);
-
-       /* Free transmit URBs */
-       for (i = 0; i < MAXIMUM_USB_TCB; i++) {
-               if (psIntfAdapter->asUsbTcb[i].urb  != NULL) {
-                       usb_free_urb(psIntfAdapter->asUsbTcb[i].urb);
-                       psIntfAdapter->asUsbTcb[i].urb = NULL;
-               }
-       }
-       /* Free receive URB and buffers */
-       for (i = 0; i < MAXIMUM_USB_RCB; i++) {
-               if (psIntfAdapter->asUsbRcb[i].urb != NULL) {
-                       kfree(psIntfAdapter->asUsbRcb[i].urb->transfer_buffer);
-                       usb_free_urb(psIntfAdapter->asUsbRcb[i].urb);
-                       psIntfAdapter->asUsbRcb[i].urb = NULL;
-               }
-       }
-       AdapterFree(ps_ad);
-}
-
-static void ConfigureEndPointTypesThroughEEPROM(
-               struct bcm_mini_adapter *Adapter)
-{
-       u32 ulReg;
-       int bytes;
-       struct bcm_interface_adapter *interfaceAdapter;
-
-       /* Program EP2 MAX_PKT_SIZE */
-       ulReg = ntohl(EP2_MPS_REG);
-       BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x128, 4, TRUE);
-       ulReg = ntohl(EP2_MPS);
-       BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x12C, 4, TRUE);
-
-       ulReg = ntohl(EP2_CFG_REG);
-       BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x132, 4, TRUE);
-       interfaceAdapter =
-               (struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter);
-       if (interfaceAdapter->bHighSpeedDevice) {
-               ulReg = ntohl(EP2_CFG_INT);
-               BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x136, 4, TRUE);
-       } else {
-               /* USE BULK EP as TX in FS mode. */
-               ulReg = ntohl(EP2_CFG_BULK);
-               BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x136, 4, TRUE);
-       }
-
-       /* Program EP4 MAX_PKT_SIZE. */
-       ulReg = ntohl(EP4_MPS_REG);
-       BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x13C, 4, TRUE);
-       ulReg = ntohl(EP4_MPS);
-       BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x140, 4, TRUE);
-
-       /* Program TX EP as interrupt(Alternate Setting) */
-       bytes = rdmalt(Adapter, 0x0F0110F8, &ulReg, sizeof(u32));
-       if (bytes < 0) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, DRV_ENTRY,
-                               DBG_LVL_ALL, "reading of Tx EP failed\n");
-               return;
-       }
-       ulReg |= 0x6;
-
-       ulReg = ntohl(ulReg);
-       BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1CC, 4, TRUE);
-
-       ulReg = ntohl(EP4_CFG_REG);
-       BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1C8, 4, TRUE);
-       /* Program ISOCHRONOUS EP size to zero. */
-       ulReg = ntohl(ISO_MPS_REG);
-       BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1D2, 4, TRUE);
-       ulReg = ntohl(ISO_MPS);
-       BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1D6, 4, TRUE);
-
-       /*
-        * Update EEPROM Version.
-        * Read 4 bytes from 508 and modify 511 and 510.
-        */
-       ReadBeceemEEPROM(Adapter, 0x1FC, &ulReg);
-       ulReg &= 0x0101FFFF;
-       BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1FC, 4, TRUE);
-
-       /*
-        * Update length field if required.
-        * Also make the string NULL terminated.
-        */
-
-       ReadBeceemEEPROM(Adapter, 0xA8, &ulReg);
-       if ((ulReg&0x00FF0000)>>16 > 0x30) {
-               ulReg = (ulReg&0xFF00FFFF)|(0x30<<16);
-               BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0xA8, 4, TRUE);
-       }
-       ReadBeceemEEPROM(Adapter, 0x148, &ulReg);
-       if ((ulReg&0x00FF0000)>>16 > 0x30) {
-               ulReg = (ulReg&0xFF00FFFF)|(0x30<<16);
-               BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x148, 4, TRUE);
-       }
-       ulReg = 0;
-       BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x122, 4, TRUE);
-       ulReg = 0;
-       BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1C2, 4, TRUE);
-}
-
-static int usbbcm_device_probe(struct usb_interface *intf,
-                              const struct usb_device_id *id)
-{
-       struct usb_device *udev = interface_to_usbdev(intf);
-       int retval;
-       struct bcm_mini_adapter *psAdapter;
-       struct bcm_interface_adapter *psIntfAdapter;
-       struct net_device *ndev;
-
-       /* Reserve one extra queue for the bit-bucket */
-       ndev = alloc_etherdev_mq(sizeof(struct bcm_mini_adapter),
-                       NO_OF_QUEUES + 1);
-       if (ndev == NULL) {
-               dev_err(&udev->dev, DRV_NAME ": no memory for device\n");
-               return -ENOMEM;
-       }
-
-       SET_NETDEV_DEV(ndev, &intf->dev);
-
-       psAdapter = netdev_priv(ndev);
-       psAdapter->dev = ndev;
-       psAdapter->msg_enable = netif_msg_init(debug, default_msg);
-
-       /* Init default driver debug state */
-
-       psAdapter->stDebugState.debug_level = DBG_LVL_CURR;
-       psAdapter->stDebugState.type = DBG_TYPE_INITEXIT;
-
-       /*
-        * Technically, one can start using BCM_DEBUG_PRINT after this point.
-        * However, realize that by default the Type/Subtype bitmaps are all
-        * zero now; so no prints will actually appear until the TestApp turns
-        * on debug paths via the ioctl(); so practically speaking, in early
-        * init, no logging happens.
-        *
-        * A solution (used below): we explicitly set the bitmaps to 1 for
-        * Type=DBG_TYPE_INITEXIT and ALL subtype's of the same. Now all bcm
-        * debug statements get logged, enabling debug during early init.
-        * Further, we turn this OFF once init_module() completes.
-        */
-
-       psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0xff;
-       BCM_SHOW_DEBUG_BITMAP(psAdapter);
-
-       retval = InitAdapter(psAdapter);
-       if (retval) {
-               dev_err(&udev->dev, DRV_NAME ": InitAdapter Failed\n");
-               AdapterFree(psAdapter);
-               return retval;
-       }
-
-       /* Allocate interface adapter structure */
-       psIntfAdapter = kzalloc(sizeof(struct bcm_interface_adapter),
-                       GFP_KERNEL);
-       if (psIntfAdapter == NULL) {
-               AdapterFree(psAdapter);
-               return -ENOMEM;
-       }
-
-       psAdapter->pvInterfaceAdapter = psIntfAdapter;
-       psIntfAdapter->psAdapter = psAdapter;
-
-       /* Store usb interface in Interface Adapter */
-       psIntfAdapter->interface = intf;
-       usb_set_intfdata(intf, psIntfAdapter);
-
-       BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
-                       "psIntfAdapter 0x%p\n", psIntfAdapter);
-       retval = InterfaceAdapterInit(psIntfAdapter);
-       if (retval) {
-               /* If the Firmware/Cfg File is not present
-                * then return success, let the application
-                * download the files.
-                */
-               if (-ENOENT == retval) {
-                       BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY,
-                                       DBG_LVL_ALL,
-                                       "File Not Found.  Use app to download.\n");
-                       return STATUS_SUCCESS;
-               }
-               BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY,
-                               DBG_LVL_ALL, "InterfaceAdapterInit failed.\n");
-               usb_set_intfdata(intf, NULL);
-               udev = interface_to_usbdev(intf);
-               usb_put_dev(udev);
-               InterfaceAdapterFree(psIntfAdapter);
-               return retval;
-       }
-       if (psAdapter->chip_id > T3) {
-               uint32_t uiNackZeroLengthInt = 4;
-
-               retval =
-                       wrmalt(psAdapter, DISABLE_USB_ZERO_LEN_INT,
-                                       &uiNackZeroLengthInt,
-                                       sizeof(uiNackZeroLengthInt));
-               if (retval)
-                       return retval;
-       }
-
-       /* Check whether the USB-Device Supports remote Wake-Up */
-       if (USB_CONFIG_ATT_WAKEUP & udev->actconfig->desc.bmAttributes) {
-               /* If Suspend then only support dynamic suspend */
-               if (psAdapter->bDoSuspend) {
-#ifdef CONFIG_PM
-                       pm_runtime_set_autosuspend_delay(&udev->dev, 0);
-                       intf->needs_remote_wakeup = 1;
-                       usb_enable_autosuspend(udev);
-                       device_init_wakeup(&intf->dev, 1);
-                       INIT_WORK(&psIntfAdapter->usbSuspendWork,
-                                       putUsbSuspend);
-                       BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY,
-                                       DBG_LVL_ALL,
-                                       "Enabling USB Auto-Suspend\n");
-#endif
-               } else {
-                       intf->needs_remote_wakeup = 0;
-                       usb_disable_autosuspend(udev);
-               }
-       }
-
-       psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0x0;
-       return retval;
-}
-
-static void usbbcm_disconnect(struct usb_interface *intf)
-{
-       struct bcm_interface_adapter *psIntfAdapter = usb_get_intfdata(intf);
-       struct bcm_mini_adapter *psAdapter;
-       struct usb_device  *udev = interface_to_usbdev(intf);
-
-       if (psIntfAdapter == NULL)
-               return;
-
-       psAdapter = psIntfAdapter->psAdapter;
-       netif_device_detach(psAdapter->dev);
-
-       if (psAdapter->bDoSuspend)
-               intf->needs_remote_wakeup = 0;
-
-       psAdapter->device_removed = TRUE;
-       usb_set_intfdata(intf, NULL);
-       InterfaceAdapterFree(psIntfAdapter);
-       usb_put_dev(udev);
-}
-
-static int AllocUsbCb(struct bcm_interface_adapter *psIntfAdapter)
-{
-       int i = 0;
-
-       for (i = 0; i < MAXIMUM_USB_TCB; i++) {
-               psIntfAdapter->asUsbTcb[i].urb = usb_alloc_urb(0, GFP_KERNEL);
-
-               if (psIntfAdapter->asUsbTcb[i].urb == NULL) {
-                       BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,
-                                       DBG_TYPE_PRINTK, 0, 0,
-                                       "Can't allocate Tx urb for index %d\n",
-                                       i);
-                       return -ENOMEM;
-               }
-       }
-
-       for (i = 0; i < MAXIMUM_USB_RCB; i++) {
-               psIntfAdapter->asUsbRcb[i].urb = usb_alloc_urb(0, GFP_KERNEL);
-
-               if (psIntfAdapter->asUsbRcb[i].urb == NULL) {
-                       BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,
-                                       DBG_TYPE_PRINTK, 0, 0,
-                                       "Can't allocate Rx urb for index %d\n",
-                                       i);
-                       return -ENOMEM;
-               }
-
-               psIntfAdapter->asUsbRcb[i].urb->transfer_buffer =
-                       kmalloc(MAX_DATA_BUFFER_SIZE, GFP_KERNEL);
-
-               if (psIntfAdapter->asUsbRcb[i].urb->transfer_buffer == NULL) {
-                       BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,
-                                       DBG_TYPE_PRINTK, 0, 0,
-                                       "Can't allocate Rx buffer for index %d\n",
-                                       i);
-                       return -ENOMEM;
-               }
-               psIntfAdapter->asUsbRcb[i].urb->transfer_buffer_length =
-                       MAX_DATA_BUFFER_SIZE;
-       }
-       return 0;
-}
-
-static int device_run(struct bcm_interface_adapter *psIntfAdapter)
-{
-       int value = 0;
-       UINT status = STATUS_SUCCESS;
-       struct bcm_mini_adapter *psAd = psIntfAdapter->psAdapter;
-
-       status = InitCardAndDownloadFirmware(psAd);
-       if (status != STATUS_SUCCESS) {
-               pr_err(DRV_NAME "InitCardAndDownloadFirmware failed.\n");
-               return status;
-       }
-       if (psAd->fw_download_done) {
-               if (StartInterruptUrb(psIntfAdapter)) {
-                       BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT, DRV_ENTRY,
-                                       DBG_LVL_ALL,
-                                       "Cannot send interrupt in URB\n");
-               }
-
-               /*
-                * now register the cntrl interface.  after downloading the f/w
-                * waiting for 5 sec to get the mailbox interrupt.
-                */
-               psAd->waiting_to_fw_download_done = false;
-               value = wait_event_timeout(psAd->ioctl_fw_dnld_wait_queue,
-                                          psAd->waiting_to_fw_download_done,
-                                          5 * HZ);
-
-               if (value == 0)
-                       pr_err(DRV_NAME ": Timeout waiting for mailbox interrupt.\n");
-
-               if (register_control_device_interface(psAd) < 0) {
-                       pr_err(DRV_NAME ": Register Control Device failed.\n");
-                       return -EIO;
-               }
-       }
-       return 0;
-}
-
-static int select_alternate_setting_for_highspeed_modem(
-               struct bcm_interface_adapter *psIntfAdapter,
-               struct usb_endpoint_descriptor **endpoint,
-               const struct usb_host_interface *iface_desc,
-               int *usedIntOutForBulkTransfer)
-{
-       int retval = 0;
-       struct bcm_mini_adapter *psAd = psIntfAdapter->psAdapter;
-
-       /* selecting alternate setting one as a default setting
-        * for High Speed  modem. */
-       if (psIntfAdapter->bHighSpeedDevice)
-               retval = usb_set_interface(psIntfAdapter->udev,
-                                          DEFAULT_SETTING_0,
-                                          ALTERNATE_SETTING_1);
-       BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
-                       "BCM16 is applicable on this dongle\n");
-       if (retval || !psIntfAdapter->bHighSpeedDevice) {
-               *usedIntOutForBulkTransfer = EP2;
-               *endpoint = &iface_desc->endpoint[EP2].desc;
-               BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
-                               "Interface altsetting failed or modem is configured to Full Speed, hence will work on default setting 0\n");
-               /*
-                * If Modem is high speed device EP2 should be
-                * INT OUT End point
-                *
-                * If Mode is FS then EP2 should be bulk end
-                * point
-                */
-               if ((psIntfAdapter->bHighSpeedDevice &&
-                                       !usb_endpoint_is_int_out(*endpoint)) ||
-                               (!psIntfAdapter->bHighSpeedDevice &&
-                                !usb_endpoint_is_bulk_out(*endpoint))) {
-                       BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT, DRV_ENTRY,
-                                       DBG_LVL_ALL,
-                                       "Configuring the EEPROM\n");
-                       /* change the EP2, EP4 to INT OUT end point */
-                       ConfigureEndPointTypesThroughEEPROM(
-                                       psAd);
-
-                       /*
-                        * It resets the device and if any thing
-                        * gets changed in USB descriptor it
-                        * will show fail and re-enumerate the
-                        * device
-                        */
-                       retval = usb_reset_device(psIntfAdapter->udev);
-                       if (retval) {
-                               BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT,
-                                               DRV_ENTRY, DBG_LVL_ALL,
-                                               "reset failed.  Re-enumerating the device.\n");
-                               return retval;
-                       }
-
-               }
-               if (!psIntfAdapter->bHighSpeedDevice &&
-                   usb_endpoint_is_bulk_out(*endpoint)) {
-                       /*
-                        * Once BULK is selected in FS mode.
-                        * Revert it back to INT.
-                        * Else USB_IF will fail.
-                        */
-                       UINT _uiData = ntohl(EP2_CFG_INT);
-
-                       BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT, DRV_ENTRY,
-                                       DBG_LVL_ALL,
-                                       "Reverting Bulk to INT as it is in Full Speed mode.\n");
-                       BeceemEEPROMBulkWrite(psAd, (PUCHAR) & _uiData, 0x136,
-                                             4, TRUE);
-               }
-       } else {
-               *usedIntOutForBulkTransfer = EP4;
-               *endpoint = &iface_desc->endpoint[EP4].desc;
-               BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
-                               "Choosing AltSetting as a default setting.\n");
-               if (!usb_endpoint_is_int_out(*endpoint)) {
-                       BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT, DRV_ENTRY,
-                                       DBG_LVL_ALL,
-                                       "Dongle does not have BCM16 Fix.\n");
-                       /*
-                        * change the EP2, EP4 to INT OUT end point and use EP4
-                        * in altsetting
-                        */
-                       ConfigureEndPointTypesThroughEEPROM(psAd);
-
-                       /*
-                        * It resets the device and if any thing
-                        * gets changed in USB descriptor it
-                        * will show fail and re-enumerate the
-                        * device
-                        */
-                       retval = usb_reset_device(psIntfAdapter->udev);
-                       if (retval) {
-                               BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT,
-                                               DRV_ENTRY, DBG_LVL_ALL,
-                                               "reset failed.  Re-enumerating the device.\n");
-                               return retval;
-                       }
-               }
-       }
-
-       return 0;
-}
-
-static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter)
-{
-       struct usb_host_interface *iface_desc;
-       struct usb_endpoint_descriptor *endpoint;
-       size_t buffer_size;
-       unsigned long value;
-       int retval = 0;
-       int usedIntOutForBulkTransfer = 0;
-       bool bBcm16 = false;
-       UINT uiData = 0;
-       int bytes;
-       struct bcm_mini_adapter *psAd = psIntfAdapter->psAdapter;
-
-       /* Store the usb dev into interface adapter */
-       psIntfAdapter->udev =
-               usb_get_dev(interface_to_usbdev(psIntfAdapter->interface));
-
-       psIntfAdapter->bHighSpeedDevice =
-               (psIntfAdapter->udev->speed == USB_SPEED_HIGH);
-       psAd->interface_rdm = BcmRDM;
-       psAd->interface_wrm = BcmWRM;
-
-       bytes = rdmalt(psAd, CHIP_ID_REG, (u32 *) &(psAd->chip_id),
-                      sizeof(u32));
-       if (bytes < 0) {
-               retval = bytes;
-               BCM_DEBUG_PRINT(psAd, DBG_TYPE_PRINTK, 0, 0,
-                               "CHIP ID Read Failed\n");
-               return retval;
-       }
-
-       if (0xbece3200 == (psAd->chip_id & ~(0xF0)))
-               psAd->chip_id &= ~0xF0;
-
-       dev_info(&psIntfAdapter->udev->dev, "RDM Chip ID 0x%lx\n",
-                psAd->chip_id);
-
-       iface_desc = psIntfAdapter->interface->cur_altsetting;
-
-       if (psAd->chip_id == T3B) {
-               /* T3B device will have EEPROM, check if EEPROM is proper and
-                * BCM16 can be done or not. */
-               BeceemEEPROMBulkRead(psAd, &uiData, 0x0, 4);
-               if (uiData == BECM)
-                       bBcm16 = TRUE;
-
-               dev_info(&psIntfAdapter->udev->dev,
-                        "number of alternate setting %d\n",
-                        psIntfAdapter->interface->num_altsetting);
-
-               if (bBcm16 == TRUE) {
-                       retval = select_alternate_setting_for_highspeed_modem(
-                                       psIntfAdapter, &endpoint, iface_desc,
-                                       &usedIntOutForBulkTransfer);
-                       if (retval)
-                               return retval;
-               }
-       }
-
-       iface_desc = psIntfAdapter->interface->cur_altsetting;
-
-       for (value = 0; value < iface_desc->desc.bNumEndpoints; ++value) {
-               endpoint = &iface_desc->endpoint[value].desc;
-
-               if (!psIntfAdapter->sBulkIn.bulk_in_endpointAddr &&
-                               usb_endpoint_is_bulk_in(endpoint)) {
-                       buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
-                       psIntfAdapter->sBulkIn.bulk_in_size = buffer_size;
-                       psIntfAdapter->sBulkIn.bulk_in_endpointAddr =
-                               endpoint->bEndpointAddress;
-                       psIntfAdapter->sBulkIn.bulk_in_pipe = usb_rcvbulkpipe(
-                                       psIntfAdapter->udev,
-                                       psIntfAdapter->sBulkIn.bulk_in_endpointAddr);
-               }
-
-               if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr &&
-                               usb_endpoint_is_bulk_out(endpoint)) {
-                       psIntfAdapter->sBulkOut.bulk_out_endpointAddr =
-                               endpoint->bEndpointAddress;
-                       psIntfAdapter->sBulkOut.bulk_out_pipe = usb_sndbulkpipe(
-                                       psIntfAdapter->udev,
-                                       psIntfAdapter->sBulkOut.bulk_out_endpointAddr);
-               }
-
-               if (!psIntfAdapter->sIntrIn.int_in_endpointAddr &&
-                               usb_endpoint_is_int_in(endpoint)) {
-                       buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
-                       psIntfAdapter->sIntrIn.int_in_size = buffer_size;
-                       psIntfAdapter->sIntrIn.int_in_endpointAddr =
-                               endpoint->bEndpointAddress;
-                       psIntfAdapter->sIntrIn.int_in_interval =
-                               endpoint->bInterval;
-                       psIntfAdapter->sIntrIn.int_in_buffer =
-                               kmalloc(buffer_size, GFP_KERNEL);
-                       if (!psIntfAdapter->sIntrIn.int_in_buffer)
-                               return -EINVAL;
-               }
-
-               if (!psIntfAdapter->sIntrOut.int_out_endpointAddr &&
-                               usb_endpoint_is_int_out(endpoint)) {
-                       if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr &&
-                                       (psAd->chip_id == T3B) &&
-                                       (value == usedIntOutForBulkTransfer)) {
-                               /*
-                                * use first intout end point as a bulk out end
-                                * point
-                                */
-                               buffer_size =
-                                       le16_to_cpu(endpoint->wMaxPacketSize);
-                               psIntfAdapter->sBulkOut.bulk_out_size =
-                                       buffer_size;
-                               psIntfAdapter->sBulkOut.bulk_out_endpointAddr =
-                                       endpoint->bEndpointAddress;
-                               psIntfAdapter->sBulkOut.bulk_out_pipe =
-                                       usb_sndintpipe(psIntfAdapter->udev,
-                                                       psIntfAdapter->sBulkOut
-                                                       .bulk_out_endpointAddr);
-                               psIntfAdapter->sBulkOut.int_out_interval =
-                                       endpoint->bInterval;
-                       } else if (value == EP6) {
-                               buffer_size =
-                                       le16_to_cpu(endpoint->wMaxPacketSize);
-                               psIntfAdapter->sIntrOut.int_out_size =
-                                       buffer_size;
-                               psIntfAdapter->sIntrOut.int_out_endpointAddr =
-                                       endpoint->bEndpointAddress;
-                               psIntfAdapter->sIntrOut.int_out_interval =
-                                       endpoint->bInterval;
-                               psIntfAdapter->sIntrOut.int_out_buffer =
-                                       kmalloc(buffer_size, GFP_KERNEL);
-                               if (!psIntfAdapter->sIntrOut.int_out_buffer)
-                                       return -EINVAL;
-                       }
-               }
-       }
-
-       usb_set_intfdata(psIntfAdapter->interface, psIntfAdapter);
-
-       psAd->bcm_file_download = InterfaceFileDownload;
-       psAd->bcm_file_readback_from_chip = InterfaceFileReadbackFromChip;
-       psAd->interface_transmit = InterfaceTransmitPacket;
-
-       retval = CreateInterruptUrb(psIntfAdapter);
-
-       if (retval) {
-               BCM_DEBUG_PRINT(psAd, DBG_TYPE_PRINTK, 0, 0,
-                               "Cannot create interrupt urb\n");
-               return retval;
-       }
-
-       retval = AllocUsbCb(psIntfAdapter);
-       if (retval)
-               return retval;
-
-       return device_run(psIntfAdapter);
-}
-
-static int InterfaceSuspend(struct usb_interface *intf, pm_message_t message)
-{
-       struct bcm_interface_adapter *psIntfAdapter = usb_get_intfdata(intf);
-
-       psIntfAdapter->bSuspended = TRUE;
-
-       if (psIntfAdapter->bPreparingForBusSuspend) {
-               psIntfAdapter->bPreparingForBusSuspend = false;
-
-               if (psIntfAdapter->psAdapter->LinkStatus == LINKUP_DONE) {
-                       psIntfAdapter->psAdapter->IdleMode = TRUE;
-                       BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,
-                                       DBG_TYPE_INITEXIT, DRV_ENTRY,
-                                       DBG_LVL_ALL,
-                                       "Host Entered in PMU Idle Mode.\n");
-               } else {
-                       psIntfAdapter->psAdapter->bShutStatus = TRUE;
-                       BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,
-                                       DBG_TYPE_INITEXIT, DRV_ENTRY,
-                                       DBG_LVL_ALL,
-                                       "Host Entered in PMU Shutdown Mode.\n");
-               }
-       }
-       psIntfAdapter->psAdapter->bPreparingForLowPowerMode = false;
-
-       /* Signaling the control pkt path */
-       wake_up(&psIntfAdapter->psAdapter->lowpower_mode_wait_queue);
-
-       return 0;
-}
-
-static int InterfaceResume(struct usb_interface *intf)
-{
-       struct bcm_interface_adapter *psIntfAdapter = usb_get_intfdata(intf);
-
-       mdelay(100);
-       psIntfAdapter->bSuspended = false;
-
-       StartInterruptUrb(psIntfAdapter);
-       InterfaceRx(psIntfAdapter);
-       return 0;
-}
-
-static struct usb_driver usbbcm_driver = {
-       .name = "usbbcm",
-       .probe = usbbcm_device_probe,
-       .disconnect = usbbcm_disconnect,
-       .suspend = InterfaceSuspend,
-       .resume = InterfaceResume,
-       .id_table = InterfaceUsbtable,
-       .supports_autosuspend = 1,
-};
-
-struct class *bcm_class;
-
-static __init int bcm_init(void)
-{
-       int retval;
-
-       pr_info("%s: %s, %s\n", DRV_NAME, DRV_DESCRIPTION, DRV_VERSION);
-       pr_info("%s\n", DRV_COPYRIGHT);
-
-       bcm_class = class_create(THIS_MODULE, DRV_NAME);
-       if (IS_ERR(bcm_class)) {
-               pr_err(DRV_NAME ": could not create class\n");
-               return PTR_ERR(bcm_class);
-       }
-
-       retval = usb_register(&usbbcm_driver);
-       if (retval < 0) {
-               pr_err(DRV_NAME ": could not register usb driver\n");
-               class_destroy(bcm_class);
-               return retval;
-       }
-       return 0;
-}
-
-static __exit void bcm_exit(void)
-{
-       usb_deregister(&usbbcm_driver);
-       class_destroy(bcm_class);
-}
-
-module_init(bcm_init);
-module_exit(bcm_exit);
-
-MODULE_DESCRIPTION(DRV_DESCRIPTION);
-MODULE_VERSION(DRV_VERSION);
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/bcm/InterfaceInit.h b/drivers/staging/bcm/InterfaceInit.h
deleted file mode 100644 (file)
index ffa6e96..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef _INTERFACE_INIT_H
-#define _INTERFACE_INIT_H
-
-#define BCM_USB_VENDOR_ID_T3   0x198f
-#define BCM_USB_VENDOR_ID_FOXCONN      0x0489
-#define BCM_USB_VENDOR_ID_ZTE  0x19d2
-
-#define BCM_USB_PRODUCT_ID_T3  0x0300
-#define BCM_USB_PRODUCT_ID_T3B 0x0210
-#define BCM_USB_PRODUCT_ID_T3L 0x0220
-#define BCM_USB_PRODUCT_ID_SYM 0x15E
-#define BCM_USB_PRODUCT_ID_1901        0xe017
-#define BCM_USB_PRODUCT_ID_226 0x0132 /* not sure if this is valid */
-#define BCM_USB_PRODUCT_ID_ZTE_226 0x172
-#define BCM_USB_PRODUCT_ID_ZTE_326 0x173 /* ZTE AX326 */
-#define BCM_USB_PRODUCT_ID_ZTE_TU25    0x0007
-
-#define BCM_USB_MINOR_BASE     192
-
-int InterfaceInitialize(void);
-
-int InterfaceExit(void);
-
-int usbbcm_worker_thread(struct bcm_interface_adapter *psIntfAdapter);
-
-#endif
diff --git a/drivers/staging/bcm/InterfaceIsr.c b/drivers/staging/bcm/InterfaceIsr.c
deleted file mode 100644 (file)
index b9f8a7a..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-#include "headers.h"
-
-
-static void read_int_callback(struct urb *urb/*, struct pt_regs *regs*/)
-{
-       int             status = urb->status;
-       struct bcm_interface_adapter *psIntfAdapter =
-               (struct bcm_interface_adapter *)urb->context;
-       struct bcm_mini_adapter *Adapter = psIntfAdapter->psAdapter;
-
-       if (netif_msg_intr(Adapter))
-               pr_info(PFX "%s: interrupt status %d\n",
-                               Adapter->dev->name, status);
-
-       if (Adapter->device_removed) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT,
-                               DBG_LVL_ALL, "Device has Got Removed.");
-               return;
-       }
-
-       if ((Adapter->bPreparingForLowPowerMode && Adapter->bDoSuspend) ||
-                       psIntfAdapter->bSuspended ||
-                       psIntfAdapter->bPreparingForBusSuspend) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT,
-                               DBG_LVL_ALL,
-                               "Interrupt call back is called while suspending the device");
-               return;
-       }
-
-       switch (status) {
-       /* success */
-       case STATUS_SUCCESS:
-               if (urb->actual_length) {
-
-                       if (psIntfAdapter->ulInterruptData[1] & 0xFF) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
-                                               INTF_INIT, DBG_LVL_ALL,
-                                               "Got USIM interrupt");
-                       }
-
-                       if (psIntfAdapter->ulInterruptData[1] & 0xFF00) {
-                               atomic_set(&Adapter->CurrNumFreeTxDesc,
-                                       (psIntfAdapter->ulInterruptData[1] &
-                                        0xFF00) >> 8);
-                               atomic_set(&Adapter->uiMBupdate, TRUE);
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
-                                       INTF_INIT, DBG_LVL_ALL,
-                                       "TX mailbox contains %d",
-                                       atomic_read(&Adapter->CurrNumFreeTxDesc));
-                       }
-                       if (psIntfAdapter->ulInterruptData[1] >> 16) {
-                               Adapter->CurrNumRecvDescs =
-                                       (psIntfAdapter->ulInterruptData[1]  >> 16);
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
-                                               INTF_INIT, DBG_LVL_ALL,
-                                               "RX mailbox contains %d",
-                                               Adapter->CurrNumRecvDescs);
-                               InterfaceRx(psIntfAdapter);
-                       }
-                       if (Adapter->fw_download_done &&
-                               !Adapter->downloadDDR &&
-                               atomic_read(&Adapter->CurrNumFreeTxDesc)) {
-
-                               psIntfAdapter->psAdapter->downloadDDR += 1;
-                               wake_up(&Adapter->tx_packet_wait_queue);
-                       }
-                       if (!Adapter->waiting_to_fw_download_done) {
-                               Adapter->waiting_to_fw_download_done = TRUE;
-                               wake_up(&Adapter->ioctl_fw_dnld_wait_queue);
-                       }
-                       if (!atomic_read(&Adapter->TxPktAvail)) {
-                               atomic_set(&Adapter->TxPktAvail, 1);
-                               wake_up(&Adapter->tx_packet_wait_queue);
-                       }
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT,
-                                       DBG_LVL_ALL, "Firing interrupt in URB");
-               }
-               break;
-       case -ENOENT:
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT,
-                               DBG_LVL_ALL, "URB has got disconnected....");
-               return;
-       case -EINPROGRESS:
-               /*
-                * This situation may happened when URBunlink is used.  for
-                * detail check usb_unlink_urb documentation.
-                */
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT,
-                               DBG_LVL_ALL,
-                               "Impossibe condition has occurred... something very bad is going on");
-               break;
-               /* return; */
-       case -EPIPE:
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT,
-                               DBG_LVL_ALL,
-                               "Interrupt IN endPoint has got halted/stalled...need to clear this");
-               Adapter->bEndPointHalted = TRUE;
-               wake_up(&Adapter->tx_packet_wait_queue);
-               urb->status = STATUS_SUCCESS;
-               return;
-       /* software-driven interface shutdown */
-       case -ECONNRESET:       /* URB got unlinked */
-       case -ESHUTDOWN:        /* hardware gone. this is the serious problem */
-               /*
-                * Occurs only when something happens with the
-                * host controller device
-                */
-       case -ENODEV: /* Device got removed */
-       case -EINVAL:
-               /*
-                * Some thing very bad happened with the URB. No
-                * description is available.
-                */
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT,
-                               DBG_LVL_ALL, "interrupt urb error %d", status);
-               urb->status = STATUS_SUCCESS;
-               break;
-               /* return; */
-       default:
-               /*
-                * This is required to check what is the defaults conditions
-                * when it occurs..
-                */
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,
-                               "GOT DEFAULT INTERRUPT URB STATUS :%d..Please Analyze it...",
-                               status);
-               break;
-       }
-
-       StartInterruptUrb(psIntfAdapter);
-
-
-}
-
-int CreateInterruptUrb(struct bcm_interface_adapter *psIntfAdapter)
-{
-       psIntfAdapter->psInterruptUrb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!psIntfAdapter->psInterruptUrb) {
-               BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS,
-                               INTF_INIT, DBG_LVL_ALL,
-                               "Cannot allocate interrupt urb");
-               return -ENOMEM;
-       }
-       psIntfAdapter->psInterruptUrb->transfer_buffer =
-               psIntfAdapter->ulInterruptData;
-       psIntfAdapter->psInterruptUrb->transfer_buffer_length =
-               sizeof(psIntfAdapter->ulInterruptData);
-
-       psIntfAdapter->sIntrIn.int_in_pipe = usb_rcvintpipe(psIntfAdapter->udev,
-                       psIntfAdapter->sIntrIn.int_in_endpointAddr);
-
-       usb_fill_int_urb(psIntfAdapter->psInterruptUrb, psIntfAdapter->udev,
-                       psIntfAdapter->sIntrIn.int_in_pipe,
-                       psIntfAdapter->psInterruptUrb->transfer_buffer,
-                       psIntfAdapter->psInterruptUrb->transfer_buffer_length,
-                       read_int_callback, psIntfAdapter,
-                       psIntfAdapter->sIntrIn.int_in_interval);
-
-       BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, INTF_INIT,
-                       DBG_LVL_ALL, "Interrupt Interval: %d\n",
-                       psIntfAdapter->sIntrIn.int_in_interval);
-       return 0;
-}
-
-
-INT StartInterruptUrb(struct bcm_interface_adapter *psIntfAdapter)
-{
-       INT status = 0;
-
-       if (!(psIntfAdapter->psAdapter->device_removed ||
-                               psIntfAdapter->psAdapter->bEndPointHalted ||
-                               psIntfAdapter->bSuspended ||
-                               psIntfAdapter->bPreparingForBusSuspend ||
-                               psIntfAdapter->psAdapter->StopAllXaction)) {
-               status =
-                       usb_submit_urb(psIntfAdapter->psInterruptUrb, GFP_ATOMIC);
-               if (status) {
-                       BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,
-                                       DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,
-                                       "Cannot send inturb %d\n", status);
-                       if (status == -EPIPE) {
-                               psIntfAdapter->psAdapter->bEndPointHalted =
-                                       TRUE;
-                               wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue);
-                       }
-               }
-       }
-       return status;
-}
-
diff --git a/drivers/staging/bcm/InterfaceIsr.h b/drivers/staging/bcm/InterfaceIsr.h
deleted file mode 100644 (file)
index 3073bd7..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef _INTERFACE_ISR_H
-#define _INTERFACE_ISR_H
-
-int CreateInterruptUrb(struct bcm_interface_adapter *psIntfAdapter);
-
-
-INT StartInterruptUrb(struct bcm_interface_adapter *psIntfAdapter);
-
-
-VOID InterfaceEnableInterrupt(struct bcm_mini_adapter *Adapter);
-
-VOID InterfaceDisableInterrupt(struct bcm_mini_adapter *Adapter);
-
-#endif
-
diff --git a/drivers/staging/bcm/InterfaceMacros.h b/drivers/staging/bcm/InterfaceMacros.h
deleted file mode 100644 (file)
index fedb794..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef _INTERFACE_MACROS_H
-#define _INTERFACE_MACROS_H
-
-#define BCM_USB_MAX_READ_LENGTH 2048
-
-#define MAXIMUM_USB_TCB      128
-#define MAXIMUM_USB_RCB         128
-
-#define MAX_BUFFERS_PER_QUEUE   256
-
-#define MAX_DATA_BUFFER_SIZE    2048
-
-/* Num of Asynchronous reads pending */
-#define NUM_RX_DESC 64
-
-#define SYS_CFG 0x0F000C00
-
-#endif
diff --git a/drivers/staging/bcm/InterfaceMisc.c b/drivers/staging/bcm/InterfaceMisc.c
deleted file mode 100644 (file)
index e5bcfec..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-#include "headers.h"
-
-static int adapter_err_occurred(const struct bcm_interface_adapter *ad)
-{
-       if (ad->psAdapter->device_removed == TRUE) {
-               BCM_DEBUG_PRINT(ad->psAdapter, DBG_TYPE_PRINTK, 0, 0,
-                               "Device got removed");
-               return -ENODEV;
-       }
-
-       if ((ad->psAdapter->StopAllXaction == TRUE) &&
-           (ad->psAdapter->chip_id >= T3LPB)) {
-               BCM_DEBUG_PRINT(ad->psAdapter, DBG_TYPE_OTHERS, RDM,
-                               DBG_LVL_ALL,
-                               "Currently Xaction is not allowed on the bus");
-               return -EACCES;
-       }
-
-       if (ad->bSuspended == TRUE || ad->bPreparingForBusSuspend == TRUE) {
-               BCM_DEBUG_PRINT(ad->psAdapter, DBG_TYPE_OTHERS, RDM,
-                               DBG_LVL_ALL,
-                               "Bus is in suspended states hence RDM not allowed..");
-               return -EACCES;
-       }
-
-       return 0;
-}
-
-int InterfaceRDM(struct bcm_interface_adapter *psIntfAdapter,
-               unsigned int addr,
-               void *buff,
-               int len)
-{
-       int bytes;
-       int err = 0;
-
-       if (!psIntfAdapter)
-               return -EINVAL;
-
-       err = adapter_err_occurred(psIntfAdapter);
-       if (err)
-               return err;
-
-       psIntfAdapter->psAdapter->DeviceAccess = TRUE;
-
-       bytes = usb_control_msg(psIntfAdapter->udev,
-                               usb_rcvctrlpipe(psIntfAdapter->udev, 0),
-                               0x02,
-                               0xC2,
-                               (addr & 0xFFFF),
-                               ((addr >> 16) & 0xFFFF),
-                               buff,
-                               len,
-                               5000);
-
-       if (-ENODEV == bytes)
-               psIntfAdapter->psAdapter->device_removed = TRUE;
-
-       if (bytes < 0)
-               BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, RDM,
-                               DBG_LVL_ALL, "RDM failed status :%d", bytes);
-       else
-               BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, RDM,
-                               DBG_LVL_ALL, "RDM sent %d", bytes);
-
-       psIntfAdapter->psAdapter->DeviceAccess = false;
-       return bytes;
-}
-
-int InterfaceWRM(struct bcm_interface_adapter *psIntfAdapter,
-               unsigned int addr,
-               void *buff,
-               int len)
-{
-       int retval = 0;
-       int err = 0;
-
-       if (!psIntfAdapter)
-               return -EINVAL;
-
-       err = adapter_err_occurred(psIntfAdapter);
-       if (err)
-               return err;
-
-       psIntfAdapter->psAdapter->DeviceAccess = TRUE;
-
-       retval = usb_control_msg(psIntfAdapter->udev,
-                               usb_sndctrlpipe(psIntfAdapter->udev, 0),
-                               0x01,
-                               0x42,
-                               (addr & 0xFFFF),
-                               ((addr >> 16) & 0xFFFF),
-                               buff,
-                               len,
-                               5000);
-
-       if (-ENODEV == retval)
-               psIntfAdapter->psAdapter->device_removed = TRUE;
-
-       if (retval < 0) {
-               BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, WRM,
-                               DBG_LVL_ALL, "WRM failed status :%d", retval);
-               psIntfAdapter->psAdapter->DeviceAccess = false;
-               return retval;
-       } else {
-               psIntfAdapter->psAdapter->DeviceAccess = false;
-               BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, WRM,
-                               DBG_LVL_ALL, "WRM sent %d", retval);
-               return STATUS_SUCCESS;
-       }
-}
-
-int BcmRDM(void *arg,
-       unsigned int addr,
-       void *buff,
-       int len)
-{
-       return InterfaceRDM((struct bcm_interface_adapter *)arg, addr, buff,
-                           len);
-}
-
-int BcmWRM(void *arg,
-       unsigned int addr,
-       void *buff,
-       int len)
-{
-       return InterfaceWRM((struct bcm_interface_adapter *)arg, addr, buff,
-                           len);
-}
-
-int Bcm_clear_halt_of_endpoints(struct bcm_mini_adapter *Adapter)
-{
-       struct bcm_interface_adapter *psIntfAdapter =
-               (struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter);
-       int status = STATUS_SUCCESS;
-
-       /*
-        * usb_clear_halt - tells device to clear endpoint halt/stall condition
-        * @dev: device whose endpoint is halted
-        * @pipe: endpoint "pipe" being cleared
-        * @ Context: !in_interrupt ()
-        *
-        * usb_clear_halt is the synchrnous call and returns 0 on success else
-        * returns with error code.
-        * This is used to clear halt conditions for bulk and interrupt
-        * endpoints only.
-        * Control and isochronous endpoints never halts.
-        *
-        * Any URBs  queued for such an endpoint should normally be unlinked by
-        * the driver before clearing the halt condition.
-        *
-        */
-
-       /* Killing all the submitted urbs to different end points. */
-       Bcm_kill_all_URBs(psIntfAdapter);
-
-       /* clear the halted/stalled state for every end point */
-       status = usb_clear_halt(psIntfAdapter->udev,
-                               psIntfAdapter->sIntrIn.int_in_pipe);
-       if (status != STATUS_SUCCESS)
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT,
-                               DBG_LVL_ALL,
-                               "Unable to Clear Halt of Interrupt IN end point. :%d ",
-                               status);
-
-       status = usb_clear_halt(psIntfAdapter->udev,
-                               psIntfAdapter->sBulkIn.bulk_in_pipe);
-       if (status != STATUS_SUCCESS)
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT,
-                               DBG_LVL_ALL,
-                               "Unable to Clear Halt of Bulk IN end point. :%d ",
-                               status);
-
-       status = usb_clear_halt(psIntfAdapter->udev,
-                               psIntfAdapter->sBulkOut.bulk_out_pipe);
-       if (status != STATUS_SUCCESS)
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT,
-                               DBG_LVL_ALL,
-                               "Unable to Clear Halt of Bulk OUT end point. :%d ",
-                               status);
-
-       return status;
-}
-
-void Bcm_kill_all_URBs(struct bcm_interface_adapter *psIntfAdapter)
-{
-       struct urb *tempUrb = NULL;
-       unsigned int i;
-
-       /*
-        * usb_kill_urb - cancel a transfer request and wait for it to finish
-        * @urb: pointer to URB describing a previously submitted request,
-        * returns nothing as it is void returned API.
-        *
-        * This routine cancels an in-progress request. It is guaranteed that
-        * upon return all completion handlers will have finished and the URB
-        * will be totally idle and available for reuse
-        *
-        * This routine may not be used in an interrupt context (such as a
-        * bottom half or a completion handler), or when holding a spinlock, or
-        * in other situations where the caller can't schedule().
-        *
-        */
-
-       /* Cancel submitted Interrupt-URB's */
-       if (psIntfAdapter->psInterruptUrb) {
-               if (psIntfAdapter->psInterruptUrb->status == -EINPROGRESS)
-                       usb_kill_urb(psIntfAdapter->psInterruptUrb);
-       }
-
-       /* Cancel All submitted TX URB's */
-       for (i = 0; i < MAXIMUM_USB_TCB; i++) {
-               tempUrb = psIntfAdapter->asUsbTcb[i].urb;
-               if (tempUrb) {
-                       if (tempUrb->status == -EINPROGRESS)
-                               usb_kill_urb(tempUrb);
-               }
-       }
-
-       for (i = 0; i < MAXIMUM_USB_RCB; i++) {
-               tempUrb = psIntfAdapter->asUsbRcb[i].urb;
-               if (tempUrb) {
-                       if (tempUrb->status == -EINPROGRESS)
-                               usb_kill_urb(tempUrb);
-               }
-       }
-
-       atomic_set(&psIntfAdapter->uNumTcbUsed, 0);
-       atomic_set(&psIntfAdapter->uCurrTcb, 0);
-
-       atomic_set(&psIntfAdapter->uNumRcbUsed, 0);
-       atomic_set(&psIntfAdapter->uCurrRcb, 0);
-}
-
-void putUsbSuspend(struct work_struct *work)
-{
-       struct bcm_interface_adapter *psIntfAdapter = NULL;
-       struct usb_interface *intf = NULL;
-
-       psIntfAdapter = container_of(work, struct bcm_interface_adapter,
-                                    usbSuspendWork);
-       intf = psIntfAdapter->interface;
-
-       if (psIntfAdapter->bSuspended == false)
-               usb_autopm_put_interface(intf);
-}
-
diff --git a/drivers/staging/bcm/InterfaceMisc.h b/drivers/staging/bcm/InterfaceMisc.h
deleted file mode 100644 (file)
index 0e5e38b..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef __INTERFACE_MISC_H
-#define __INTERFACE_MISC_H
-
-INT
-InterfaceRDM(struct bcm_interface_adapter *psIntfAdapter,
-                       UINT addr,
-                       PVOID buff,
-                       INT len);
-
-INT
-InterfaceWRM(struct bcm_interface_adapter *psIntfAdapter,
-                       UINT addr,
-                       PVOID buff,
-                       INT len);
-
-
-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 BcmRDM(PVOID arg,
-                       UINT addr,
-                       PVOID buff,
-                       INT len);
-
-int BcmWRM(PVOID arg,
-                       UINT addr,
-                       PVOID buff,
-                       INT len);
-
-INT Bcm_clear_halt_of_endpoints(struct bcm_mini_adapter *Adapter);
-
-VOID Bcm_kill_all_URBs(struct bcm_interface_adapter *psIntfAdapter);
-
-#define DISABLE_USB_ZERO_LEN_INT 0x0F011878
-
-#endif /* __INTERFACE_MISC_H */
diff --git a/drivers/staging/bcm/InterfaceRx.c b/drivers/staging/bcm/InterfaceRx.c
deleted file mode 100644 (file)
index 0f179b9..0000000
+++ /dev/null
@@ -1,289 +0,0 @@
-#include "headers.h"
-
-static void handle_control_packet(struct bcm_interface_adapter *interface,
-                                 struct bcm_mini_adapter *ad,
-                                 struct bcm_leader *leader,
-                                 struct sk_buff *skb,
-                                 struct urb *urb)
-{
-       BCM_DEBUG_PRINT(interface->psAdapter, DBG_TYPE_RX, RX_CTRL, DBG_LVL_ALL,
-                       "Received control pkt...");
-       *(PUSHORT)skb->data = leader->Status;
-       memcpy(skb->data+sizeof(USHORT), urb->transfer_buffer +
-              (sizeof(struct bcm_leader)), leader->PLength);
-       skb->len = leader->PLength + sizeof(USHORT);
-
-       spin_lock(&ad->control_queue_lock);
-       ENQUEUEPACKET(ad->RxControlHead, ad->RxControlTail, skb);
-       spin_unlock(&ad->control_queue_lock);
-
-       atomic_inc(&ad->cntrlpktCnt);
-       wake_up(&ad->process_rx_cntrlpkt);
-}
-
-static void format_eth_hdr_to_stack(struct bcm_interface_adapter *interface,
-                                   struct bcm_mini_adapter *ad,
-                                   struct bcm_leader *p_leader,
-                                   struct sk_buff *skb,
-                                   struct urb *urb,
-                                   UINT ui_index,
-                                   int queue_index,
-                                   bool b_header_supression_endabled)
-{
-       /*
-        * Data Packet, Format a proper Ethernet Header
-        * and give it to the stack
-        */
-       BCM_DEBUG_PRINT(interface->psAdapter, DBG_TYPE_RX, RX_DATA,
-                       DBG_LVL_ALL, "Received Data pkt...");
-       skb_reserve(skb, 2 + SKB_RESERVE_PHS_BYTES);
-       memcpy(skb->data+ETH_HLEN, (PUCHAR)urb->transfer_buffer +
-              sizeof(struct bcm_leader), p_leader->PLength);
-       skb->dev = ad->dev;
-
-       /* currently skb->len has extra ETH_HLEN bytes in the beginning */
-       skb_put(skb, p_leader->PLength + ETH_HLEN);
-       ad->PackInfo[queue_index].uiTotalRxBytes += p_leader->PLength;
-       ad->PackInfo[queue_index].uiThisPeriodRxBytes += p_leader->PLength;
-       BCM_DEBUG_PRINT(interface->psAdapter, DBG_TYPE_RX, RX_DATA,
-                       DBG_LVL_ALL, "Received Data pkt of len :0x%X",
-                       p_leader->PLength);
-
-       if (netif_running(ad->dev)) {
-               /* Moving ahead by ETH_HLEN to the data ptr as received from FW */
-               skb_pull(skb, ETH_HLEN);
-               PHSReceive(ad, p_leader->Vcid, skb, &skb->len,
-                          NULL, b_header_supression_endabled);
-
-               if (!ad->PackInfo[queue_index].bEthCSSupport) {
-                       skb_push(skb, ETH_HLEN);
-
-                       memcpy(skb->data, skb->dev->dev_addr, 6);
-                       memcpy(skb->data+6, skb->dev->dev_addr, 6);
-                       (*(skb->data+11))++;
-                       *(skb->data+12) = 0x08;
-                       *(skb->data+13) = 0x00;
-                       p_leader->PLength += ETH_HLEN;
-               }
-
-               skb->protocol = eth_type_trans(skb, ad->dev);
-               netif_rx(skb);
-       } else {
-               BCM_DEBUG_PRINT(interface->psAdapter, DBG_TYPE_RX,
-                               RX_DATA, DBG_LVL_ALL,
-                               "i/f not up hance freeing SKB...");
-               dev_kfree_skb(skb);
-       }
-
-       ++ad->dev->stats.rx_packets;
-       ad->dev->stats.rx_bytes += p_leader->PLength;
-
-       for (ui_index = 0; ui_index < MIBS_MAX_HIST_ENTRIES; ui_index++) {
-               if ((p_leader->PLength <=
-                   MIBS_PKTSIZEHIST_RANGE*(ui_index+1)) &&
-                       (p_leader->PLength > MIBS_PKTSIZEHIST_RANGE*(ui_index)))
-
-                       ad->aRxPktSizeHist[ui_index]++;
-       }
-}
-
-static int SearchVcid(struct bcm_mini_adapter *Adapter, unsigned short usVcid)
-{
-       int iIndex = 0;
-
-       for (iIndex = (NO_OF_QUEUES-1); iIndex >= 0; iIndex--)
-               if (Adapter->PackInfo[iIndex].usVCID_Value == usVcid)
-                       return iIndex;
-       return NO_OF_QUEUES+1;
-
-}
-
-
-static struct bcm_usb_rcb *
-GetBulkInRcb(struct bcm_interface_adapter *psIntfAdapter)
-{
-       struct bcm_usb_rcb *pRcb = NULL;
-       UINT index = 0;
-
-       if ((atomic_read(&psIntfAdapter->uNumRcbUsed) < MAXIMUM_USB_RCB) &&
-           (psIntfAdapter->psAdapter->StopAllXaction == false)) {
-               index = atomic_read(&psIntfAdapter->uCurrRcb);
-               pRcb = &psIntfAdapter->asUsbRcb[index];
-               pRcb->bUsed = TRUE;
-               pRcb->psIntfAdapter = psIntfAdapter;
-               BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_DPC,
-                               DBG_LVL_ALL, "Got Rx desc %d used %d", index,
-                               atomic_read(&psIntfAdapter->uNumRcbUsed));
-               index = (index + 1) % MAXIMUM_USB_RCB;
-               atomic_set(&psIntfAdapter->uCurrRcb, index);
-               atomic_inc(&psIntfAdapter->uNumRcbUsed);
-       }
-       return pRcb;
-}
-
-/*this is receive call back - when pkt available for receive (BULK IN- end point)*/
-static void read_bulk_callback(struct urb *urb)
-{
-       struct sk_buff *skb = NULL;
-       bool bHeaderSupressionEnabled = false;
-       int QueueIndex = NO_OF_QUEUES + 1;
-       UINT uiIndex = 0;
-       struct bcm_usb_rcb *pRcb = (struct bcm_usb_rcb *)urb->context;
-       struct bcm_interface_adapter *psIntfAdapter = pRcb->psIntfAdapter;
-       struct bcm_mini_adapter *Adapter = psIntfAdapter->psAdapter;
-       struct bcm_leader *pLeader = urb->transfer_buffer;
-
-       if (unlikely(netif_msg_rx_status(Adapter)))
-               pr_info(PFX "%s: rx urb status %d length %d\n",
-                       Adapter->dev->name, urb->status, urb->actual_length);
-
-       if ((Adapter->device_removed == TRUE) ||
-           (TRUE == Adapter->bEndPointHalted) ||
-           (0 == urb->actual_length)) {
-               pRcb->bUsed = false;
-               atomic_dec(&psIntfAdapter->uNumRcbUsed);
-               return;
-       }
-
-       if (urb->status != STATUS_SUCCESS) {
-               if (urb->status == -EPIPE) {
-                       Adapter->bEndPointHalted = TRUE;
-                       wake_up(&Adapter->tx_packet_wait_queue);
-               } else {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC,
-                                       DBG_LVL_ALL,
-                                       "Rx URB has got cancelled. status :%d",
-                                       urb->status);
-               }
-               pRcb->bUsed = false;
-               atomic_dec(&psIntfAdapter->uNumRcbUsed);
-               urb->status = STATUS_SUCCESS;
-               return;
-       }
-
-       if (Adapter->bDoSuspend && (Adapter->bPreparingForLowPowerMode)) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,
-                               "device is going in low power mode while PMU option selected..hence rx packet should not be process");
-               return;
-       }
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,
-                       "Read back done len %d\n", pLeader->PLength);
-       if (!pLeader->PLength) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,
-                               "Leader Length 0");
-               atomic_dec(&psIntfAdapter->uNumRcbUsed);
-               return;
-       }
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,
-                       "Leader Status:0x%hX, Length:0x%hX, VCID:0x%hX",
-                       pLeader->Status, pLeader->PLength, pLeader->Vcid);
-       if (MAX_CNTL_PKT_SIZE < pLeader->PLength) {
-               if (netif_msg_rx_err(Adapter))
-                       pr_info(PFX "%s: corrupted leader length...%d\n",
-                               Adapter->dev->name, pLeader->PLength);
-               ++Adapter->dev->stats.rx_dropped;
-               atomic_dec(&psIntfAdapter->uNumRcbUsed);
-               return;
-       }
-
-       QueueIndex = SearchVcid(Adapter, pLeader->Vcid);
-       if (QueueIndex < NO_OF_QUEUES) {
-               bHeaderSupressionEnabled =
-                       Adapter->PackInfo[QueueIndex].bHeaderSuppressionEnabled;
-               bHeaderSupressionEnabled =
-                       bHeaderSupressionEnabled & Adapter->bPHSEnabled;
-       }
-
-       skb = dev_alloc_skb(pLeader->PLength + SKB_RESERVE_PHS_BYTES +
-                           SKB_RESERVE_ETHERNET_HEADER);
-       if (!skb) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,
-                               "NO SKBUFF!!! Dropping the Packet");
-               atomic_dec(&psIntfAdapter->uNumRcbUsed);
-               return;
-       }
-       /* If it is a control Packet, then call handle_bcm_packet ()*/
-       if ((ntohs(pLeader->Vcid) == VCID_CONTROL_PACKET) ||
-           (!(pLeader->Status >= 0x20  &&  pLeader->Status <= 0x3F))) {
-               handle_control_packet(psIntfAdapter, Adapter, pLeader, skb,
-                                     urb);
-       } else {
-               format_eth_hdr_to_stack(psIntfAdapter, Adapter, pLeader, skb,
-                                       urb, uiIndex, QueueIndex,
-                                       bHeaderSupressionEnabled);
-       }
-       Adapter->PrevNumRecvDescs++;
-       pRcb->bUsed = false;
-       atomic_dec(&psIntfAdapter->uNumRcbUsed);
-}
-
-static int ReceiveRcb(struct bcm_interface_adapter *psIntfAdapter,
-                     struct bcm_usb_rcb *pRcb)
-{
-       struct urb *urb = pRcb->urb;
-       int retval = 0;
-
-       usb_fill_bulk_urb(urb, psIntfAdapter->udev,
-                         usb_rcvbulkpipe(psIntfAdapter->udev,
-                                         psIntfAdapter->sBulkIn.bulk_in_endpointAddr),
-                         urb->transfer_buffer,
-                         BCM_USB_MAX_READ_LENGTH,
-                         read_bulk_callback, pRcb);
-
-       if (false == psIntfAdapter->psAdapter->device_removed &&
-           false == psIntfAdapter->psAdapter->bEndPointHalted &&
-           false == psIntfAdapter->bSuspended &&
-           false == psIntfAdapter->bPreparingForBusSuspend) {
-               retval = usb_submit_urb(urb, GFP_ATOMIC);
-               if (retval) {
-                       BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX,
-                                       RX_DPC, DBG_LVL_ALL,
-                                       "failed submitting read urb, error %d",
-                                       retval);
-                       /* if this return value is because of pipe halt. need to clear this. */
-                       if (retval == -EPIPE) {
-                               psIntfAdapter->psAdapter->bEndPointHalted = TRUE;
-                               wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue);
-                       }
-
-               }
-       }
-       return retval;
-}
-
-/*
-Function:                              InterfaceRx
-
-Description:                   This is the hardware specific Function for Receiving
-                                               data packet/control packets from the device.
-
-Input parameters:              IN struct bcm_mini_adapter *Adapter   - Miniport Adapter Context
-
-
-
-Return:                                TRUE  - If Rx was successful.
-                                       Other - If an error occurred.
-*/
-
-bool InterfaceRx(struct bcm_interface_adapter *psIntfAdapter)
-{
-       USHORT RxDescCount = NUM_RX_DESC -
-               atomic_read(&psIntfAdapter->uNumRcbUsed);
-
-       struct bcm_usb_rcb *pRcb = NULL;
-
-       while (RxDescCount) {
-               pRcb = GetBulkInRcb(psIntfAdapter);
-               if (pRcb == NULL) {
-                       BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,
-                                       DBG_TYPE_PRINTK, 0, 0,
-                                       "Unable to get Rcb pointer");
-                       return false;
-               }
-               ReceiveRcb(psIntfAdapter, pRcb);
-               RxDescCount--;
-       }
-       return TRUE;
-}
-
diff --git a/drivers/staging/bcm/InterfaceRx.h b/drivers/staging/bcm/InterfaceRx.h
deleted file mode 100644 (file)
index b4e858b..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _INTERFACE_RX_H
-#define _INTERFACE_RX_H
-
-bool InterfaceRx(struct bcm_interface_adapter *Adapter);
-
-#endif
-
diff --git a/drivers/staging/bcm/InterfaceTx.c b/drivers/staging/bcm/InterfaceTx.c
deleted file mode 100644 (file)
index 9b3f64b..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-#include "headers.h"
-
-static void prepare_low_power_mode(struct urb *urb,
-                                  struct bcm_interface_adapter *interface,
-                                  struct bcm_mini_adapter *ps_adapter,
-                                  struct bcm_mini_adapter *ad,
-                                  struct bcm_link_request *p_control_msg,
-                                  bool *b_power_down_msg)
-{
-       if (((p_control_msg->szData[0] == GO_TO_IDLE_MODE_PAYLOAD) &&
-               (p_control_msg->szData[1] == TARGET_CAN_GO_TO_IDLE_MODE))) {
-
-               *b_power_down_msg = TRUE;
-               /*
-                * This covers the bus err while Idle Request msg
-                * sent down.
-                */
-               if (urb->status != STATUS_SUCCESS) {
-                       ps_adapter->bPreparingForLowPowerMode = false;
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, NEXT_SEND,
-                                       DBG_LVL_ALL,
-                                       "Idle Mode Request msg failed to reach to Modem");
-                       /* Signalling the cntrl pkt path in Ioctl */
-                       wake_up(&ps_adapter->lowpower_mode_wait_queue);
-                       StartInterruptUrb(interface);
-                       return;
-               }
-
-               if (ps_adapter->bDoSuspend == false) {
-                       ps_adapter->IdleMode = TRUE;
-                       /* since going in Idle mode completed hence making this var false */
-                       ps_adapter->bPreparingForLowPowerMode = false;
-
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, NEXT_SEND,
-                                       DBG_LVL_ALL,
-                                       "Host Entered in Idle Mode State...");
-                       /* Signalling the cntrl pkt path in Ioctl*/
-                       wake_up(&ps_adapter->lowpower_mode_wait_queue);
-               }
-
-       } else if ((p_control_msg->Leader.Status == LINK_UP_CONTROL_REQ) &&
-               (p_control_msg->szData[0] == LINK_UP_ACK) &&
-               (p_control_msg->szData[1] == LINK_SHUTDOWN_REQ_FROM_FIRMWARE)  &&
-               (p_control_msg->szData[2] == SHUTDOWN_ACK_FROM_DRIVER)) {
-               /*
-                * This covers the bus err while shutdown Request
-                * msg sent down.
-                */
-               if (urb->status != STATUS_SUCCESS) {
-                       ps_adapter->bPreparingForLowPowerMode = false;
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, NEXT_SEND,
-                                       DBG_LVL_ALL,
-                                       "Shutdown Request Msg failed to reach to Modem");
-                       /* Signalling the cntrl pkt path in Ioctl */
-                       wake_up(&ps_adapter->lowpower_mode_wait_queue);
-                       StartInterruptUrb(interface);
-                       return;
-               }
-
-               *b_power_down_msg = TRUE;
-               if (ps_adapter->bDoSuspend == false) {
-                       ps_adapter->bShutStatus = TRUE;
-                       /*
-                        * since going in shutdown mode completed hence
-                        * making this var false
-                        */
-                       ps_adapter->bPreparingForLowPowerMode = false;
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, NEXT_SEND,
-                                       DBG_LVL_ALL,
-                                       "Host Entered in shutdown Mode State...");
-                       /* Signalling the cntrl pkt path in Ioctl */
-                       wake_up(&ps_adapter->lowpower_mode_wait_queue);
-               }
-       }
-
-       if (ps_adapter->bDoSuspend && *b_power_down_msg) {
-               /* issuing bus suspend request */
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,
-                               "Issuing the Bus suspend request to USB stack");
-               interface->bPreparingForBusSuspend = TRUE;
-               schedule_work(&interface->usbSuspendWork);
-       }
-}
-
-/*this is transmit call-back(BULK OUT)*/
-static void write_bulk_callback(struct urb *urb/*, struct pt_regs *regs*/)
-{
-       struct bcm_usb_tcb *pTcb = (struct bcm_usb_tcb *)urb->context;
-       struct bcm_interface_adapter *psIntfAdapter = pTcb->psIntfAdapter;
-       struct bcm_link_request *pControlMsg =
-               (struct bcm_link_request *)urb->transfer_buffer;
-       struct bcm_mini_adapter *psAdapter = psIntfAdapter->psAdapter;
-       bool bpowerDownMsg = false;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       if (unlikely(netif_msg_tx_done(Adapter)))
-               pr_info(PFX "%s: transmit status %d\n", Adapter->dev->name,
-                       urb->status);
-
-       if (urb->status != STATUS_SUCCESS) {
-               if (urb->status == -EPIPE) {
-                       psIntfAdapter->psAdapter->bEndPointHalted = TRUE;
-                       wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue);
-               } else {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND,
-                                       DBG_LVL_ALL,
-                                       "Tx URB has got cancelled. status :%d",
-                                       urb->status);
-               }
-       }
-
-       pTcb->bUsed = false;
-       atomic_dec(&psIntfAdapter->uNumTcbUsed);
-
-       if (TRUE == psAdapter->bPreparingForLowPowerMode) {
-               prepare_low_power_mode(urb, psIntfAdapter, psAdapter, Adapter,
-                                      pControlMsg, &bpowerDownMsg);
-       }
-
-       usb_free_coherent(urb->dev, urb->transfer_buffer_length,
-                       urb->transfer_buffer, urb->transfer_dma);
-}
-
-
-static struct bcm_usb_tcb *GetBulkOutTcb(struct bcm_interface_adapter *psIntfAdapter)
-{
-       struct bcm_usb_tcb *pTcb = NULL;
-       UINT index = 0;
-
-       if ((atomic_read(&psIntfAdapter->uNumTcbUsed) < MAXIMUM_USB_TCB) &&
-               (psIntfAdapter->psAdapter->StopAllXaction == false)) {
-               index = atomic_read(&psIntfAdapter->uCurrTcb);
-               pTcb = &psIntfAdapter->asUsbTcb[index];
-               pTcb->bUsed = TRUE;
-               pTcb->psIntfAdapter = psIntfAdapter;
-               BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_TX,
-                               NEXT_SEND, DBG_LVL_ALL,
-                               "Got Tx desc %d used %d",
-                               index,
-                               atomic_read(&psIntfAdapter->uNumTcbUsed));
-               index = (index + 1) % MAXIMUM_USB_TCB;
-               atomic_set(&psIntfAdapter->uCurrTcb, index);
-               atomic_inc(&psIntfAdapter->uNumTcbUsed);
-       }
-       return pTcb;
-}
-
-static int TransmitTcb(struct bcm_interface_adapter *psIntfAdapter,
-                      struct bcm_usb_tcb *pTcb, PVOID data, int len)
-{
-
-       struct urb *urb = pTcb->urb;
-       int retval = 0;
-
-       urb->transfer_buffer = usb_alloc_coherent(psIntfAdapter->udev, len,
-                                               GFP_ATOMIC, &urb->transfer_dma);
-       if (!urb->transfer_buffer) {
-               BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0,
-                               "Error allocating memory\n");
-               return  -ENOMEM;
-       }
-       memcpy(urb->transfer_buffer, data, len);
-       urb->transfer_buffer_length = len;
-
-       BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_TX, NEXT_SEND,
-                       DBG_LVL_ALL, "Sending Bulk out packet\n");
-       /* For T3B,INT OUT end point will be used as bulk out end point */
-       if ((psIntfAdapter->psAdapter->chip_id == T3B) &&
-                       (psIntfAdapter->bHighSpeedDevice == TRUE)) {
-               usb_fill_int_urb(urb, psIntfAdapter->udev,
-                       psIntfAdapter->sBulkOut.bulk_out_pipe,
-                       urb->transfer_buffer, len, write_bulk_callback, pTcb,
-                       psIntfAdapter->sBulkOut.int_out_interval);
-       } else {
-       usb_fill_bulk_urb(urb, psIntfAdapter->udev,
-                 psIntfAdapter->sBulkOut.bulk_out_pipe,
-                 urb->transfer_buffer, len, write_bulk_callback, pTcb);
-       }
-       urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; /* For DMA transfer */
-
-       if (false == psIntfAdapter->psAdapter->device_removed &&
-          false == psIntfAdapter->psAdapter->bEndPointHalted &&
-          false == psIntfAdapter->bSuspended &&
-          false == psIntfAdapter->bPreparingForBusSuspend) {
-               retval = usb_submit_urb(urb, GFP_ATOMIC);
-               if (retval) {
-                       BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_TX,
-                                       NEXT_SEND, DBG_LVL_ALL,
-                                       "failed submitting write urb, error %d",
-                                       retval);
-                       if (retval == -EPIPE) {
-                               psIntfAdapter->psAdapter->bEndPointHalted = TRUE;
-                               wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue);
-                       }
-               }
-       }
-       return retval;
-}
-
-int InterfaceTransmitPacket(PVOID arg, PVOID data, UINT len)
-{
-       struct bcm_usb_tcb *pTcb = NULL;
-       struct bcm_interface_adapter *psIntfAdapter = arg;
-
-       pTcb = GetBulkOutTcb(psIntfAdapter);
-       if (pTcb == NULL) {
-               BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0,
-                               "No URB to transmit packet, dropping packet");
-               return -EFAULT;
-       }
-       return TransmitTcb(psIntfAdapter, pTcb, data, len);
-}
-
diff --git a/drivers/staging/bcm/InterfaceTx.h b/drivers/staging/bcm/InterfaceTx.h
deleted file mode 100644 (file)
index 2731475..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _INTERFACE_TX_H
-#define _INTERFACE_TX_H
-
-INT InterfaceTransmitPacket(PVOID arg, PVOID data, UINT len);
-
-#endif
-
diff --git a/drivers/staging/bcm/Ioctl.h b/drivers/staging/bcm/Ioctl.h
deleted file mode 100644 (file)
index fa5f867..0000000
+++ /dev/null
@@ -1,226 +0,0 @@
-#ifndef _IOCTL_H_
-#define _IOCTL_H_
-
-struct bcm_rdm_buffer {
-       unsigned long Register;
-       unsigned long Length;
-} __packed;
-
-struct bcm_wrm_buffer {
-       unsigned long Register;
-       unsigned long Length;
-       unsigned char Data[4];
-} __packed;
-
-struct bcm_ioctl_buffer {
-       void __user *InputBuffer;
-       unsigned long InputLength;
-       void __user *OutputBuffer;
-       unsigned long OutputLength;
-} __packed;
-
-struct bcm_gpio_info {
-       unsigned int uiGpioNumber; /* valid numbers 0-15 */
-       unsigned int uiGpioValue; /* 1 set ; 0 not  set */
-} __packed;
-
-struct bcm_user_thread_req {
-       /* 0->Inactivate LED thread. */
-       /* 1->Activate the LED thread */
-       unsigned int ThreadState;
-} __packed;
-
-#define LED_THREAD_ACTIVATION_REQ  1
-#define BCM_IOCTL                              'k'
-#define IOCTL_SEND_CONTROL_MESSAGE             _IOW(BCM_IOCTL, 0x801, int)
-#define IOCTL_BCM_REGISTER_WRITE               _IOW(BCM_IOCTL, 0x802, int)
-#define IOCTL_BCM_REGISTER_READ                        _IOR(BCM_IOCTL, 0x803, int)
-#define IOCTL_BCM_COMMON_MEMORY_WRITE          _IOW(BCM_IOCTL, 0x804, int)
-#define IOCTL_BCM_COMMON_MEMORY_READ           _IOR(BCM_IOCTL, 0x805, int)
-#define IOCTL_GET_CONTROL_MESSAGE              _IOR(BCM_IOCTL, 0x806, int)
-#define IOCTL_BCM_FIRMWARE_DOWNLOAD            _IOW(BCM_IOCTL, 0x807, int)
-#define IOCTL_BCM_SET_SEND_VCID                        _IOW(BCM_IOCTL, 0x808, int)
-#define IOCTL_BCM_SWITCH_TRANSFER_MODE         _IOW(BCM_IOCTL, 0x809, int)
-#define IOCTL_LINK_REQ                         _IOW(BCM_IOCTL, 0x80A, int)
-#define IOCTL_RSSI_LEVEL_REQ                   _IOW(BCM_IOCTL, 0x80B, int)
-#define IOCTL_IDLE_REQ                         _IOW(BCM_IOCTL, 0x80C, int)
-#define IOCTL_SS_INFO_REQ                      _IOW(BCM_IOCTL, 0x80D, int)
-#define IOCTL_GET_STATISTICS_POINTER           _IOW(BCM_IOCTL, 0x80E, int)
-#define IOCTL_CM_REQUEST                       _IOW(BCM_IOCTL, 0x80F, int)
-#define IOCTL_INIT_PARAM_REQ                   _IOW(BCM_IOCTL, 0x810, int)
-#define IOCTL_MAC_ADDR_REQ                     _IOW(BCM_IOCTL, 0x811, int)
-#define IOCTL_MAC_ADDR_RESP                    _IOWR(BCM_IOCTL, 0x812, int)
-#define IOCTL_CLASSIFICATION_RULE              _IOW(BCM_IOCTL, 0x813, char)
-#define IOCTL_CLOSE_NOTIFICATION               _IO(BCM_IOCTL, 0x814)
-#define IOCTL_LINK_UP                          _IO(BCM_IOCTL, 0x815)
-#define IOCTL_LINK_DOWN                                _IO(BCM_IOCTL, 0x816, struct bcm_ioctl_buffer)
-#define IOCTL_CHIP_RESET                       _IO(BCM_IOCTL, 0x816)
-#define IOCTL_CINR_LEVEL_REQ                   _IOW(BCM_IOCTL, 0x817, char)
-#define IOCTL_WTM_CONTROL_REQ                  _IOW(BCM_IOCTL, 0x817, char)
-#define IOCTL_BE_BUCKET_SIZE                   _IOW(BCM_IOCTL, 0x818, unsigned long)
-#define IOCTL_RTPS_BUCKET_SIZE                 _IOW(BCM_IOCTL, 0x819, unsigned long)
-#define IOCTL_QOS_THRESHOLD                    _IOW(BCM_IOCTL, 0x820, unsigned long)
-#define IOCTL_DUMP_PACKET_INFO                 _IO(BCM_IOCTL, 0x821)
-#define IOCTL_GET_PACK_INFO                    _IOR(BCM_IOCTL, 0x823, int)
-#define IOCTL_BCM_GET_DRIVER_VERSION           _IOR(BCM_IOCTL, 0x829, int)
-#define IOCTL_BCM_GET_CURRENT_STATUS           _IOW(BCM_IOCTL, 0x828, int)
-#define IOCTL_BCM_GPIO_SET_REQUEST             _IOW(BCM_IOCTL, 0x82A, int)
-#define IOCTL_BCM_GPIO_STATUS_REQUEST          _IOW(BCM_IOCTL, 0x82b, int)
-#define IOCTL_BCM_GET_DSX_INDICATION           _IOR(BCM_IOCTL, 0x854, int)
-#define IOCTL_BCM_BUFFER_DOWNLOAD_START                _IOW(BCM_IOCTL, 0x855, int)
-#define IOCTL_BCM_BUFFER_DOWNLOAD              _IOW(BCM_IOCTL, 0x856, int)
-#define IOCTL_BCM_BUFFER_DOWNLOAD_STOP         _IOW(BCM_IOCTL, 0x857, int)
-#define IOCTL_BCM_REGISTER_WRITE_PRIVATE       _IOW(BCM_IOCTL, 0x826, char)
-#define IOCTL_BCM_REGISTER_READ_PRIVATE                _IOW(BCM_IOCTL, 0x827, char)
-#define IOCTL_BCM_SET_DEBUG                    _IOW(BCM_IOCTL, 0x824, struct bcm_ioctl_buffer)
-#define IOCTL_BCM_EEPROM_REGISTER_WRITE                _IOW(BCM_IOCTL, 0x858, int)
-#define IOCTL_BCM_EEPROM_REGISTER_READ         _IOR(BCM_IOCTL, 0x859, int)
-#define IOCTL_BCM_WAKE_UP_DEVICE_FROM_IDLE     _IOR(BCM_IOCTL, 0x860, int)
-#define IOCTL_BCM_SET_MAC_TRACING              _IOW(BCM_IOCTL, 0x82c, int)
-#define IOCTL_BCM_GET_HOST_MIBS                        _IOW(BCM_IOCTL, 0x853, int)
-#define IOCTL_BCM_NVM_READ                     _IOR(BCM_IOCTL, 0x861, int)
-#define IOCTL_BCM_NVM_WRITE                    _IOW(BCM_IOCTL, 0x862, int)
-#define IOCTL_BCM_GET_NVM_SIZE                 _IOR(BCM_IOCTL, 0x863, int)
-#define IOCTL_BCM_CAL_INIT                     _IOR(BCM_IOCTL, 0x864, int)
-#define IOCTL_BCM_BULK_WRM                     _IOW(BCM_IOCTL, 0x90B, int)
-#define IOCTL_BCM_FLASH2X_SECTION_READ         _IOR(BCM_IOCTL, 0x865, int)
-#define IOCTL_BCM_FLASH2X_SECTION_WRITE                _IOW(BCM_IOCTL, 0x866, int)
-#define IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP   _IOR(BCM_IOCTL, 0x867, int)
-#define IOCTL_BCM_SET_ACTIVE_SECTION           _IOW(BCM_IOCTL, 0x868, int)
-#define IOCTL_BCM_IDENTIFY_ACTIVE_SECTION      _IO(BCM_IOCTL, 0x869)
-#define IOCTL_BCM_COPY_SECTION                 _IOW(BCM_IOCTL, 0x870, int)
-#define IOCTL_BCM_GET_FLASH_CS_INFO            _IOR(BCM_IOCTL, 0x871, int)
-#define IOCTL_BCM_SELECT_DSD                   _IOW(BCM_IOCTL, 0x872, int)
-#define IOCTL_BCM_NVM_RAW_READ                 _IOR(BCM_IOCTL, 0x875, int)
-#define IOCTL_BCM_CNTRLMSG_MASK                        _IOW(BCM_IOCTL, 0x874, int)
-#define IOCTL_BCM_GET_DEVICE_DRIVER_INFO       _IOR(BCM_IOCTL, 0x877, int)
-#define IOCTL_BCM_TIME_SINCE_NET_ENTRY         _IOR(BCM_IOCTL, 0x876, int)
-#define BCM_LED_THREAD_STATE_CHANGE_REQ                _IOW(BCM_IOCTL, 0x878, int)
-#define IOCTL_BCM_GPIO_MULTI_REQUEST           _IOW(BCM_IOCTL, 0x82D, struct bcm_ioctl_buffer)
-#define IOCTL_BCM_GPIO_MODE_REQUEST            _IOW(BCM_IOCTL, 0x82E, struct bcm_ioctl_buffer)
-
-enum bcm_interface_type {
-       BCM_MII,
-       BCM_CARDBUS,
-       BCM_USB,
-       BCM_SDIO,
-       BCM_PCMCIA
-};
-
-struct bcm_driver_info {
-       enum bcm_nvm_type       u32NVMType;
-       unsigned int            MaxRDMBufferSize;
-       enum bcm_interface_type u32InterfaceType;
-       unsigned int            u32DSDStartOffset;
-       unsigned int            u32RxAlignmentCorrection;
-       unsigned int            u32Reserved[10];
-};
-
-struct bcm_nvm_readwrite {
-       void __user *pBuffer;
-       uint32_t  uiOffset;
-       uint32_t uiNumBytes;
-       bool bVerify;
-};
-
-struct bcm_bulk_wrm_buffer {
-       unsigned long Register;
-       unsigned long SwapEndian;
-       unsigned long Values[1];
-};
-
-enum bcm_flash2x_section_val {
-       NO_SECTION_VAL = 0, /* no section chosen when absolute offset is given for RD/WR */
-       ISO_IMAGE1,
-       ISO_IMAGE2,
-       DSD0,
-       DSD1,
-       DSD2,
-       VSA0,
-       VSA1,
-       VSA2,
-       SCSI,
-       CONTROL_SECTION,
-       ISO_IMAGE1_PART2,
-       ISO_IMAGE1_PART3,
-       ISO_IMAGE2_PART2,
-       ISO_IMAGE2_PART3,
-       TOTAL_SECTIONS
-};
-
-/*
- * Structure used for READ/WRITE Flash Map2.x
- */
-struct bcm_flash2x_readwrite {
-       enum bcm_flash2x_section_val Section; /* section to be read/written */
-       u32 offset; /* offset within section. */
-       u32 numOfBytes; /* number of bytes from the offset */
-       u32 bVerify;
-       void __user *pDataBuff; /* buffer for reading/writing */
-};
-
-/*
- * This structure is used for coping one section to other.
- * there are two ways to copy one section to other.
- * it NOB =0, complete section will be copied on to other.
- * if NOB !=0, only NOB will be copied from the given offset.
- */
-
-struct bcm_flash2x_copy_section {
-       enum bcm_flash2x_section_val SrcSection;
-       enum bcm_flash2x_section_val DstSection;
-       u32 offset;
-       u32 numOfBytes;
-};
-
-/*
- * This section provide the complete bitmap of the Flash.
- * using this map lib/APP will issue read/write command.
- * Fields are defined as :
- * Bit [0] = section is present  //1:present, 0: Not present
- * Bit [1] = section is valid  //1: valid, 0: not valid
- * Bit [2] = Section is R/W  //0: RW, 1: RO
- * Bit [3] = Section is Active or not 1 means Active, 0->inactive
- * Bit [7...3] = Reserved
- */
-
-struct bcm_flash2x_bitmap {
-       unsigned char ISO_IMAGE1;
-       unsigned char ISO_IMAGE2;
-       unsigned char DSD0;
-       unsigned char DSD1;
-       unsigned char DSD2;
-       unsigned char VSA0;
-       unsigned char VSA1;
-       unsigned char VSA2;
-       unsigned char SCSI;
-       unsigned char CONTROL_SECTION;
-       /* Reserved for future use */
-       unsigned char Reserved0;
-       unsigned char Reserved1;
-       unsigned char Reserved2;
-};
-
-struct bcm_time_elapsed {
-       u64 ul64TimeElapsedSinceNetEntry;
-       u32 uiReserved[4];
-};
-
-enum {
-       WIMAX_IDX = 0, /* To access WiMAX chip GPIO's for GPIO_MULTI_INFO or GPIO_MULTI_MODE */
-       HOST_IDX, /* To access Host chip GPIO's for GPIO_MULTI_INFO or GPIO_MULTI_MODE */
-       MAX_IDX
-};
-
-struct bcm_gpio_multi_info {
-       unsigned int uiGPIOCommand; /* 1 for set and 0 for get */
-       unsigned int uiGPIOMask; /* set the corresponding bit to 1 to access GPIO */
-       unsigned int uiGPIOValue; /* 0 or 1; value to be set when command is 1. */
-} __packed;
-
-struct bcm_gpio_multi_mode {
-       unsigned int uiGPIOMode; /* 1 for OUT mode, 0 for IN mode */
-       unsigned int uiGPIOMask; /* GPIO mask to set mode */
-} __packed;
-
-#endif
diff --git a/drivers/staging/bcm/Kconfig b/drivers/staging/bcm/Kconfig
deleted file mode 100644 (file)
index 8acf4b2..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-config BCM_WIMAX
-       tristate "Beceem BCS200/BCS220-3 and BCSM250 wimax support"
-       depends on USB && NET
-       help
-         This is an experimental driver for the Beceem WIMAX chipset used
-        by Sprint 4G.
diff --git a/drivers/staging/bcm/LeakyBucket.c b/drivers/staging/bcm/LeakyBucket.c
deleted file mode 100644 (file)
index d6b55f9..0000000
+++ /dev/null
@@ -1,364 +0,0 @@
-/**********************************************************************
-*                      LEAKYBUCKET.C
-*      This file contains the routines related to Leaky Bucket Algorithm.
-***********************************************************************/
-#include "headers.h"
-
-/**
- * UpdateTokenCount() - Calculates the token count for each channel
- * and updates the same in Adapter structure
- * @Adapter:   Pointer to the Adapter structure.
- *
- * Return: None
- */
-static VOID UpdateTokenCount(register struct bcm_mini_adapter *Adapter)
-{
-       ULONG liCurrentTime;
-       INT i = 0;
-       struct timeval tv;
-       struct bcm_packet_info *curr_pi;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL,
-                       "=====>\n");
-       if (NULL == Adapter) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS,
-                               DBG_LVL_ALL, "Adapter found NULL!\n");
-               return;
-       }
-
-       do_gettimeofday(&tv);
-       for (i = 0; i < NO_OF_QUEUES; i++) {
-               curr_pi = &Adapter->PackInfo[i];
-
-               if (TRUE == curr_pi->bValid && (1 == curr_pi->ucDirection)) {
-                       liCurrentTime = ((tv.tv_sec -
-                               curr_pi->stLastUpdateTokenAt.tv_sec)*1000 +
-                               (tv.tv_usec - curr_pi->stLastUpdateTokenAt.tv_usec) /
-                               1000);
-                       if (0 != liCurrentTime) {
-                               curr_pi->uiCurrentTokenCount += (ULONG)
-                                       ((curr_pi->uiMaxAllowedRate) *
-                                       ((ULONG)((liCurrentTime)))/1000);
-                               memcpy(&curr_pi->stLastUpdateTokenAt, &tv,
-                                      sizeof(struct timeval));
-                               curr_pi->liLastUpdateTokenAt = liCurrentTime;
-                               if (curr_pi->uiCurrentTokenCount >=
-                                   curr_pi->uiMaxBucketSize) {
-                                       curr_pi->uiCurrentTokenCount =
-                                               curr_pi->uiMaxBucketSize;
-                               }
-                       }
-               }
-       }
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL,
-                       "<=====\n");
-}
-
-
-/**
- * IsPacketAllowedForFlow() - This function checks whether the given
- * packet from the specified queue can be allowed for transmission by
- * checking the token count.
- * @Adapter:           Pointer to the Adpater structure.
- * @iQIndex:           The queue Identifier.
- * @ulPacketLength:    Number of bytes to be transmitted.
- *
- * Returns: The number of bytes allowed for transmission.
- */
-static ULONG GetSFTokenCount(struct bcm_mini_adapter *Adapter, struct bcm_packet_info *psSF)
-{
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL,
-                       "IsPacketAllowedForFlow ===>");
-
-       /* Validate the parameters */
-       if (NULL == Adapter || (psSF < Adapter->PackInfo &&
-           (uintptr_t)psSF > (uintptr_t) &Adapter->PackInfo[HiPriority])) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL,
-                               "IPAFF: Got wrong Parameters:Adapter: %p, QIndex: %zd\n",
-                               Adapter, (psSF-Adapter->PackInfo));
-               return 0;
-       }
-
-       if (false != psSF->bValid && psSF->ucDirection) {
-               if (0 != psSF->uiCurrentTokenCount) {
-                       return psSF->uiCurrentTokenCount;
-               } else {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS,
-                                       DBG_LVL_ALL,
-                                       "Not enough tokens in queue %zd Available %u\n",
-                                       psSF-Adapter->PackInfo, psSF->uiCurrentTokenCount);
-                       psSF->uiPendedLast = 1;
-               }
-       } else {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL,
-                               "IPAFF: Queue %zd not valid\n",
-                               psSF-Adapter->PackInfo);
-       }
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL,
-                       "IsPacketAllowedForFlow <===");
-       return 0;
-}
-
-/**
-@ingroup tx_functions
-This function despatches packet from the specified queue.
-@return Zero(success) or Negative value(failure)
-*/
-static INT SendPacketFromQueue(struct bcm_mini_adapter *Adapter,/**<Logical Adapter*/
-                              struct bcm_packet_info *psSF, /**<Queue identifier*/
-                              struct sk_buff *Packet)  /**<Pointer to the packet to be sent*/
-{
-       INT Status = STATUS_FAILURE;
-       UINT uiIndex = 0, PktLen = 0;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL,
-                       "=====>");
-       if (!Adapter || !Packet || !psSF) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL,
-                               "Got NULL Adapter or Packet");
-               return -EINVAL;
-       }
-
-       if (psSF->liDrainCalculated == 0)
-               psSF->liDrainCalculated = jiffies;
-       /* send the packet to the fifo.. */
-       PktLen = Packet->len;
-       Status = SetupNextSend(Adapter, Packet, psSF->usVCID_Value);
-       if (Status == 0) {
-               for (uiIndex = 0; uiIndex < MIBS_MAX_HIST_ENTRIES; uiIndex++) {
-                       if ((PktLen <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1)) &&
-                           (PktLen > MIBS_PKTSIZEHIST_RANGE*(uiIndex)))
-                               Adapter->aTxPktSizeHist[uiIndex]++;
-               }
-       }
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL,
-                       "<=====");
-       return Status;
-}
-
-static void get_data_packet(struct bcm_mini_adapter *ad,
-                           struct bcm_packet_info *ps_sf)
-{
-       int packet_len;
-       struct sk_buff *qpacket;
-
-       if (!ps_sf->ucDirection)
-               return;
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL,
-                       "UpdateTokenCount ");
-       if (ad->IdleMode || ad->bPreparingForLowPowerMode)
-               return; /* in idle mode */
-
-       /* Check for Free Descriptors */
-       if (atomic_read(&ad->CurrNumFreeTxDesc) <=
-           MINIMUM_PENDING_DESCRIPTORS) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL,
-                               " No Free Tx Descriptor(%d) is available for Data pkt..",
-                               atomic_read(&ad->CurrNumFreeTxDesc));
-               return;
-       }
-
-       spin_lock_bh(&ps_sf->SFQueueLock);
-       qpacket = ps_sf->FirstTxQueue;
-
-       if (qpacket) {
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL,
-                               "Dequeuing Data Packet");
-
-               if (ps_sf->bEthCSSupport)
-                       packet_len = qpacket->len;
-               else
-                       packet_len = qpacket->len - ETH_HLEN;
-
-               packet_len <<= 3;
-               if (packet_len <= GetSFTokenCount(ad, ps_sf)) {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS,
-                                       DBG_LVL_ALL, "Allowed bytes %d",
-                                       (packet_len >> 3));
-
-                       DEQUEUEPACKET(ps_sf->FirstTxQueue, ps_sf->LastTxQueue);
-                       ps_sf->uiCurrentBytesOnHost -= (qpacket->len);
-                       ps_sf->uiCurrentPacketsOnHost--;
-                               atomic_dec(&ad->TotalPacketCount);
-                       spin_unlock_bh(&ps_sf->SFQueueLock);
-
-                       SendPacketFromQueue(ad, ps_sf, qpacket);
-                       ps_sf->uiPendedLast = false;
-               } else {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS,
-                                       DBG_LVL_ALL, "For Queue: %zd\n",
-                                       ps_sf - ad->PackInfo);
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS,
-                                       DBG_LVL_ALL,
-                                       "\nAvailable Tokens = %d required = %d\n",
-                                       ps_sf->uiCurrentTokenCount,
-                                       packet_len);
-                       /*
-                       this part indicates that because of
-                       non-availability of the tokens
-                       pkt has not been send out hence setting the
-                       pending flag indicating the host to send it out
-                       first next iteration.
-                       */
-                       ps_sf->uiPendedLast = TRUE;
-                       spin_unlock_bh(&ps_sf->SFQueueLock);
-               }
-       } else {
-               spin_unlock_bh(&ps_sf->SFQueueLock);
-       }
-}
-
-static void send_control_packet(struct bcm_mini_adapter *ad,
-                               struct bcm_packet_info *ps_sf)
-{
-       char *ctrl_packet = NULL;
-       INT status = 0;
-
-       if ((atomic_read(&ad->CurrNumFreeTxDesc) > 0) &&
-           (atomic_read(&ad->index_rd_txcntrlpkt) !=
-            atomic_read(&ad->index_wr_txcntrlpkt))) {
-               ctrl_packet = ad->txctlpacket
-               [(atomic_read(&ad->index_rd_txcntrlpkt)%MAX_CNTRL_PKTS)];
-               if (ctrl_packet) {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS,
-                                       DBG_LVL_ALL,
-                                       "Sending Control packet");
-                       status = SendControlPacket(ad, ctrl_packet);
-                       if (STATUS_SUCCESS == status) {
-                               spin_lock_bh(&ps_sf->SFQueueLock);
-                               ps_sf->NumOfPacketsSent++;
-                               ps_sf->uiSentBytes += ((struct bcm_leader *)ctrl_packet)->PLength;
-                               ps_sf->uiSentPackets++;
-                               atomic_dec(&ad->TotalPacketCount);
-                               ps_sf->uiCurrentBytesOnHost -= ((struct bcm_leader *)ctrl_packet)->PLength;
-                               ps_sf->uiCurrentPacketsOnHost--;
-                               atomic_inc(&ad->index_rd_txcntrlpkt);
-                               spin_unlock_bh(&ps_sf->SFQueueLock);
-                       } else {
-                               BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS,
-                                               DBG_LVL_ALL,
-                                               "SendControlPacket Failed\n");
-                       }
-               } else {
-                       BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS,
-                                       DBG_LVL_ALL,
-                                       " Control Pkt is not available, Indexing is wrong....");
-               }
-       }
-}
-
-/**
- * CheckAndSendPacketFromIndex() - This function dequeues the
- * data/control packet from the specified queue for transmission.
- * @Adapter:   Pointer to the driver control structure.
- * @iQIndex:   The queue Identifier.
- *
- * Returns: None.
- */
-static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter,
-                                       struct bcm_packet_info *psSF)
-{
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL,
-                       "%zd ====>", (psSF-Adapter->PackInfo));
-       if ((psSF != &Adapter->PackInfo[HiPriority]) &&
-           Adapter->LinkUpStatus &&
-           atomic_read(&psSF->uiPerSFTxResourceCount)) { /* Get data packet */
-
-               get_data_packet(Adapter, psSF);
-       } else {
-               send_control_packet(Adapter, psSF);
-       }
-}
-
-
-/**
- * transmit_packets() - This function transmits the packets from
- * different queues, if free descriptors are available on target.
- * @Adapter:   Pointer to the Adapter structure.
- *
- * Returns: None.
- */
-VOID transmit_packets(struct bcm_mini_adapter *Adapter)
-{
-       UINT uiPrevTotalCount = 0;
-       int iIndex = 0;
-
-       bool exit_flag = TRUE;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL,
-                       "=====>");
-
-       if (NULL == Adapter) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL,
-                               "Got NULL Adapter");
-               return;
-       }
-       if (Adapter->device_removed == TRUE) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL,
-                               "Device removed");
-               return;
-       }
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL,
-                       "\nUpdateTokenCount ====>\n");
-
-       UpdateTokenCount(Adapter);
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL,
-                       "\nPruneQueueAllSF ====>\n");
-
-       PruneQueueAllSF(Adapter);
-
-       uiPrevTotalCount = atomic_read(&Adapter->TotalPacketCount);
-
-       for (iIndex = HiPriority; iIndex >= 0; iIndex--) {
-               if (!uiPrevTotalCount || (TRUE == Adapter->device_removed))
-                               break;
-
-               if (Adapter->PackInfo[iIndex].bValid &&
-                   Adapter->PackInfo[iIndex].uiPendedLast &&
-                   Adapter->PackInfo[iIndex].uiCurrentBytesOnHost) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS,
-                                       DBG_LVL_ALL,
-                                       "Calling CheckAndSendPacketFromIndex..");
-                       CheckAndSendPacketFromIndex(Adapter,
-                                                   &Adapter->PackInfo[iIndex]);
-                       uiPrevTotalCount--;
-               }
-       }
-
-       while (uiPrevTotalCount > 0 && !Adapter->device_removed) {
-               exit_flag = TRUE;
-               /* second iteration to parse non-pending queues */
-               for (iIndex = HiPriority; iIndex >= 0; iIndex--) {
-                       if (!uiPrevTotalCount ||
-                           (TRUE == Adapter->device_removed))
-                               break;
-
-                       if (Adapter->PackInfo[iIndex].bValid &&
-                           Adapter->PackInfo[iIndex].uiCurrentBytesOnHost &&
-                           !Adapter->PackInfo[iIndex].uiPendedLast) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX,
-                                               TX_PACKETS, DBG_LVL_ALL,
-                                               "Calling CheckAndSendPacketFromIndex..");
-                               CheckAndSendPacketFromIndex(Adapter, &Adapter->PackInfo[iIndex]);
-                               uiPrevTotalCount--;
-                               exit_flag = false;
-                       }
-               }
-
-               if (Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS,
-                                       DBG_LVL_ALL, "In Idle Mode\n");
-                       break;
-               }
-               if (exit_flag == TRUE)
-                       break;
-       } /* end of inner while loop */
-
-       update_per_cid_rx(Adapter);
-       Adapter->txtransmit_running = 0;
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL,
-                       "<======");
-}
diff --git a/drivers/staging/bcm/Macros.h b/drivers/staging/bcm/Macros.h
deleted file mode 100644 (file)
index dc01e30..0000000
+++ /dev/null
@@ -1,352 +0,0 @@
-/*************************************
-* Macros.h
-**************************************/
-#ifndef __MACROS_H__
-#define __MACROS_H__
-
-#define TX_TIMER_PERIOD 10 /*10 msec*/
-#define MAX_CLASSIFIERS 100
-#define MAX_TARGET_DSX_BUFFERS 24
-
-#define MAX_CNTRL_PKTS    100
-#define MAX_DATA_PKTS     200
-#define MAX_ETH_SIZE      1536
-#define MAX_CNTL_PKT_SIZE 2048
-
-#define MTU_SIZE 1400
-#define TX_QLEN  5
-
-#define MAC_ADDR_REGISTER 0xbf60d000
-
-
-/* Quality of Service */
-#define NO_OF_QUEUES 17
-#define HiPriority (NO_OF_QUEUES-1)
-#define LowPriority 0
-#define BE          2
-#define rtPS        4
-#define ERTPS       5
-#define UGS         6
-
-#define BE_BUCKET_SIZE       (1024*1024*100)  /* 32kb */
-#define rtPS_BUCKET_SIZE     (1024*1024*100) /*  8kb */
-#define MAX_ALLOWED_RATE     (1024*1024*100)
-#define TX_PACKET_THRESHOLD  10
-#define XSECONDS             (1*HZ)
-#define DSC_ACTIVATE_REQUEST 248
-#define QUEUE_DEPTH_OFFSET   0x1fc01000
-#define MAX_DEVICE_DESC_SIZE 2040
-#define MAX_CTRL_QUEUE_LEN   100
-#define MAX_APP_QUEUE_LEN    200
-#define MAX_LATENCY_ALLOWED  0xFFFFFFFF
-#define DEFAULT_UG_INTERVAL  250
-#define DEFAULT_UGI_FACTOR   4
-
-#define DEFAULT_PERSFCOUNT    60
-#define MAX_CONNECTIONS       10
-#define MAX_CLASS_NAME_LENGTH 32
-
-#define ETH_LENGTH_OF_ADDRESS   6
-#define MAX_MULTICAST_ADDRESSES 32
-#define IP_LENGTH_OF_ADDRESS    4
-
-#define IP_PACKET_ONLY_MODE       0
-#define ETH_PACKET_TUNNELING_MODE 1
-
-/* Link Request */
-#define SET_MAC_ADDRESS_REQUEST 0
-#define SYNC_UP_REQUEST         1
-#define SYNCED_UP               2
-#define LINK_UP_REQUEST         3
-#define LINK_CONNECTED          4
-#define SYNC_UP_NOTIFICATION    2
-#define LINK_UP_NOTIFICATION    4
-
-
-#define LINK_NET_ENTRY              0x0002
-#define HMC_STATUS                  0x0004
-#define LINK_UP_CONTROL_REQ         0x83
-
-#define STATS_POINTER_REQ_STATUS    0x86
-#define NETWORK_ENTRY_REQ_PAYLOAD   198
-#define LINK_DOWN_REQ_PAYLOAD       226
-#define SYNC_UP_REQ_PAYLOAD         228
-#define STATISTICS_POINTER_REQ      237
-#define LINK_UP_REQ_PAYLOAD         245
-#define LINK_UP_ACK                 246
-
-#define STATS_MSG_SIZE              4
-#define INDEX_TO_DATA               4
-
-#define GO_TO_IDLE_MODE_PAYLOAD         210
-#define COME_UP_FROM_IDLE_MODE_PAYLOAD  211
-#define IDLE_MODE_SF_UPDATE_MSG         187
-
-#define SKB_RESERVE_ETHERNET_HEADER 16
-#define SKB_RESERVE_PHS_BYTES       32
-
-#define IP_PACKET_ONLY_MODE       0
-#define ETH_PACKET_TUNNELING_MODE 1
-
-#define ETH_CS_802_3       1
-#define ETH_CS_802_1Q_VLAN 3
-#define IPV4_CS            1
-#define IPV6_CS            2
-#define ETH_CS_MASK        0x3f
-
-/** \brief Validity bit maps for TLVs in packet classification rule */
-
-#define PKT_CLASSIFICATION_USER_PRIORITY_VALID 0
-#define PKT_CLASSIFICATION_VLANID_VALID        1
-
-#ifndef MIN
-#define MIN(_a, _b) ((_a) < (_b) ? (_a) : (_b))
-#endif
-
-
-/*Leader related terms */
-#define LEADER_STATUS         0x00
-#define LEADER_STATUS_TCP_ACK 0x1
-#define LEADER_SIZE           sizeof(struct bcm_leader)
-#define MAC_ADDR_REQ_SIZE     sizeof(struct bcm_packettosend)
-#define SS_INFO_REQ_SIZE      sizeof(struct bcm_packettosend)
-#define CM_REQUEST_SIZE       (LEADER_SIZE + sizeof(stLocalSFChangeRequest))
-#define IDLE_REQ_SIZE         sizeof(struct bcm_packettosend)
-
-
-#define MAX_TRANSFER_CTRL_BYTE_USB (2*1024)
-
-#define GET_MAILBOX1_REG_REQUEST        0x87
-#define GET_MAILBOX1_REG_RESPONSE       0x67
-#define VCID_CONTROL_PACKET             0x00
-
-#define TRANSMIT_NETWORK_DATA           0x00
-#define RECEIVED_NETWORK_DATA           0x20
-
-#define CM_RESPONSES            0xA0
-#define STATUS_RSP              0xA1
-#define LINK_CONTROL_RESP       0xA2
-#define IDLE_MODE_STATUS        0xA3
-#define STATS_POINTER_RESP      0xA6
-#define MGMT_MSG_INFO_SW_STATUS 0xA7
-#define AUTH_SS_HOST_MSG        0xA8
-
-#define CM_DSA_ACK_PAYLOAD            247
-#define CM_DSC_ACK_PAYLOAD            248
-#define CM_DSD_ACK_PAYLOAD            249
-#define CM_DSDEACTVATE                250
-#define TOTAL_MASKED_ADDRESS_IN_BYTES 32
-
-#define MAC_REQ         0
-#define LINK_RESP       1
-#define RSSI_INDICATION 2
-
-#define SS_INFO         4
-#define STATISTICS_INFO 5
-#define CM_INDICATION   6
-#define PARAM_RESP      7
-#define BUFFER_1K       1024
-#define BUFFER_2K       (BUFFER_1K*2)
-#define BUFFER_4K       (BUFFER_2K*2)
-#define BUFFER_8K       (BUFFER_4K*2)
-#define BUFFER_16K      (BUFFER_8K*2)
-#define DOWNLINK_DIR    0
-#define UPLINK_DIR      1
-
-#define BCM_SIGNATURE   "BECEEM"
-
-
-#define GPIO_OUTPUT_REGISTER     0x0F00003C
-#define BCM_GPIO_OUTPUT_SET_REG  0x0F000040
-#define BCM_GPIO_OUTPUT_CLR_REG  0x0F000044
-#define GPIO_MODE_REGISTER       0x0F000034
-#define GPIO_PIN_STATE_REGISTER  0x0F000038
-
-struct bcm_link_state {
-       unsigned char ucLinkStatus;
-       unsigned char bIdleMode;
-       unsigned char bShutdownMode;
-};
-
-enum enLinkStatus {
-       WAIT_FOR_SYNC = 1,
-       PHY_SYNC_ACHIVED = 2,
-       LINKUP_IN_PROGRESS = 3,
-       LINKUP_DONE = 4,
-       DREG_RECEIVED = 5,
-       LINK_STATUS_RESET_RECEIVED = 6,
-       PERIODIC_WAKE_UP_NOTIFICATION_FRM_FW  = 7,
-       LINK_SHUTDOWN_REQ_FROM_FIRMWARE = 8,
-       COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW = 9
-};
-
-enum bcm_phs_dsc_action {
-       eAddPHSRule = 0,
-       eSetPHSRule,
-       eDeletePHSRule,
-       eDeleteAllPHSRules
-};
-
-#define CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ  0x89 /* Host to Mac */
-#define CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP 0xA9 /* Mac to Host */
-#define MASK_DISABLE_HEADER_SUPPRESSION        0x10 /* 0b000010000 */
-#define MINIMUM_PENDING_DESCRIPTORS            5
-
-#define SHUTDOWN_HOSTINITIATED_REQUESTPAYLOAD 0xCC
-#define SHUTDOWN_ACK_FROM_DRIVER 0x1
-#define SHUTDOWN_NACK_FROM_DRIVER 0x2
-
-#define LINK_SYNC_UP_SUBTYPE   0x0001
-#define LINK_SYNC_DOWN_SUBTYPE 0x0001
-
-
-
-#define CONT_MODE 1
-#define SINGLE_DESCRIPTOR 1
-
-
-#define DESCRIPTOR_LENGTH 0x30
-#define FIRMWARE_DESCS_ADDRESS 0x1F100000
-
-
-#define CLOCK_RESET_CNTRL_REG_1 0x0F00000C
-#define CLOCK_RESET_CNTRL_REG_2 0x0F000840
-
-
-
-#define TX_DESCRIPTOR_HEAD_REGISTER 0x0F010034
-#define RX_DESCRIPTOR_HEAD_REGISTER 0x0F010094
-
-#define STATISTICS_BEGIN_ADDR        0xbf60f02c
-
-#define MAX_PENDING_CTRL_PACKET (MAX_CTRL_QUEUE_LEN-10)
-
-#define WIMAX_MAX_MTU                   (MTU_SIZE + ETH_HLEN)
-#define AUTO_LINKUP_ENABLE              0x2
-#define AUTO_SYNC_DISABLE               0x1
-#define AUTO_FIRM_DOWNLOAD              0x1
-#define SETTLE_DOWN_TIME                50
-
-#define HOST_BUS_SUSPEND_BIT            16
-
-#define IDLE_MESSAGE 0x81
-
-#define MIPS_CLOCK_133MHz 1
-
-#define TARGET_CAN_GO_TO_IDLE_MODE 2
-#define TARGET_CAN_NOT_GO_TO_IDLE_MODE 3
-#define IDLE_MODE_PAYLOAD_LENGTH 8
-
-#define IP_HEADER(Buffer) ((IPHeaderFormat *)(Buffer))
-#define IPV4 4
-#define IP_VERSION(byte) (((byte&0xF0)>>4))
-
-#define SET_MAC_ADDRESS  193
-#define SET_MAC_ADDRESS_RESPONSE 236
-
-#define IDLE_MODE_WAKEUP_PATTERN 0xd0ea1d1e
-#define IDLE_MODE_WAKEUP_NOTIFIER_ADDRESS 0x1FC02FA8
-#define IDLE_MODE_MAX_RETRY_COUNT 1000
-
-#define CONFIG_BEGIN_ADDR 0xBF60B000
-
-#define FIRMWARE_BEGIN_ADDR 0xBFC00000
-
-#define INVALID_QUEUE_INDEX NO_OF_QUEUES
-
-#define INVALID_PID ((pid_t)-1)
-#define DDR_80_MHZ  0
-#define DDR_100_MHZ 1
-#define DDR_120_MHZ 2 /* Additional Frequency for T3LP */
-#define DDR_133_MHZ 3
-#define DDR_140_MHZ 4 /* Not Used (Reserved for future) */
-#define DDR_160_MHZ 5 /* Additional Frequency for T3LP  */
-#define DDR_180_MHZ 6 /* Not Used (Reserved for future) */
-#define DDR_200_MHZ 7 /* Not Used (Reserved for future) */
-
-#define MIPS_200_MHZ   0
-#define MIPS_160_MHZ   1
-
-#define PLL_800_MHZ    0
-#define PLL_266_MHZ    1
-
-#define DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING        0
-#define DEVICE_POWERSAVE_MODE_AS_PMU_CLOCK_GATING           1
-#define DEVICE_POWERSAVE_MODE_AS_PMU_SHUTDOWN               2
-#define DEVICE_POWERSAVE_MODE_AS_RESERVED                   3
-#define DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE         4
-
-
-#define EEPROM_REJECT_REG_1 0x0f003018
-#define EEPROM_REJECT_REG_2 0x0f00301c
-#define EEPROM_REJECT_REG_3 0x0f003008
-#define EEPROM_REJECT_REG_4 0x0f003020
-#define EEPROM_REJECT_MASK  0x0fffffff
-#define VSG_MODE            0x3
-
-/* Idle Mode Related Registers */
-#define DEBUG_INTERRUPT_GENERATOR_REGISTOR 0x0F00007C
-#define SW_ABORT_IDLEMODE_LOC 0x0FF01FFC
-
-#define SW_ABORT_IDLEMODE_PATTERN 0xd0ea1d1e
-#define DEVICE_INT_OUT_EP_REG0    0x0F011870
-#define DEVICE_INT_OUT_EP_REG1    0x0F011874
-
-#define BIN_FILE "/lib/firmware/macxvi200.bin"
-#define CFG_FILE "/lib/firmware/macxvi.cfg"
-#define SF_MAX_ALLOWED_PACKETS_TO_BACKUP 128
-#define MIN_VAL(x, y) ((x) < (y) ? (x) : (y))
-#define MAC_ADDRESS_SIZE 6
-#define EEPROM_COMMAND_Q_REG    0x0F003018
-#define EEPROM_READ_DATA_Q_REG  0x0F003020
-#define CHIP_ID_REG             0x0F000000
-#define GPIO_MODE_REG           0x0F000034
-#define GPIO_OUTPUT_REG         0x0F00003C
-#define WIMAX_MAX_ALLOWED_RATE  (1024*1024*50)
-
-#define T3 0xbece0300
-#define TARGET_SFID_TXDESC_MAP_LOC 0xBFFFF400
-
-#define RWM_READ 0
-#define RWM_WRITE 1
-
-#define T3LPB      0xbece3300
-#define BCS220_2   0xbece3311
-#define BCS220_2BC 0xBECE3310
-#define BCS250_BC  0xbece3301
-#define BCS220_3   0xbece3321
-
-
-#define HPM_CONFIG_LDO145 0x0F000D54
-#define HPM_CONFIG_MSW    0x0F000D58
-
-#define T3B 0xbece0310
-enum bcm_nvm_type {
-       NVM_AUTODETECT = 0,
-       NVM_EEPROM,
-       NVM_FLASH,
-       NVM_UNKNOWN
-};
-
-enum bcm_pmu_modes {
-       HYBRID_MODE_7C  = 0,
-       INTERNAL_MODE_6 = 1,
-       HYBRID_MODE_6   = 2
-};
-
-#define MAX_RDM_WRM_RETIRES 1
-
-enum eAbortPattern {
-       ABORT_SHUTDOWN_MODE = 1,
-       ABORT_IDLE_REG = 1,
-       ABORT_IDLE_MODE = 2,
-       ABORT_IDLE_SYNCDOWN = 3
-};
-
-
-/* Offsets used by driver in skb cb variable */
-#define SKB_CB_CLASSIFICATION_OFFSET    0
-#define SKB_CB_LATENCY_OFFSET           1
-#define SKB_CB_TCPACK_OFFSET            2
-
-#endif /* __MACROS_H__ */
diff --git a/drivers/staging/bcm/Makefile b/drivers/staging/bcm/Makefile
deleted file mode 100644 (file)
index 652b7f8..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-# Makefile for Beceem USB Wimax card
-#
-
-obj-$(CONFIG_BCM_WIMAX) +=     bcm_wimax.o
-
-bcm_wimax-y :=  InterfaceDld.o InterfaceIdleMode.o InterfaceInit.o InterfaceRx.o \
-               InterfaceIsr.o InterfaceMisc.o InterfaceTx.o \
-               CmHost.o IPv6Protocol.o Qos.o Transmit.o\
-               Bcmnet.o DDRInit.o HandleControlPacket.o\
-               LeakyBucket.o Misc.o sort.o Bcmchar.o hostmibs.o PHSModule.o\
-               led_control.o nvm.o vendorspecificextn.o
diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c
deleted file mode 100644 (file)
index 883f739..0000000
+++ /dev/null
@@ -1,1587 +0,0 @@
-#include "headers.h"
-
-static int BcmFileDownload(struct bcm_mini_adapter *Adapter, const char *path, unsigned int loc);
-static void doPowerAutoCorrection(struct bcm_mini_adapter *psAdapter);
-static void HandleShutDownModeRequest(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer);
-static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter);
-static void beceem_protocol_reset(struct bcm_mini_adapter *Adapter);
-
-static void default_wimax_protocol_initialize(struct bcm_mini_adapter *Adapter)
-{
-       unsigned int uiLoopIndex;
-
-       for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES-1; uiLoopIndex++) {
-               Adapter->PackInfo[uiLoopIndex].uiThreshold = TX_PACKET_THRESHOLD;
-               Adapter->PackInfo[uiLoopIndex].uiMaxAllowedRate = MAX_ALLOWED_RATE;
-               Adapter->PackInfo[uiLoopIndex].uiMaxBucketSize = 20*1024*1024;
-       }
-
-       Adapter->BEBucketSize = BE_BUCKET_SIZE;
-       Adapter->rtPSBucketSize = rtPS_BUCKET_SIZE;
-       Adapter->LinkStatus = SYNC_UP_REQUEST;
-       Adapter->TransferMode = IP_PACKET_ONLY_MODE;
-       Adapter->usBestEffortQueueIndex = -1;
-}
-
-int InitAdapter(struct bcm_mini_adapter *psAdapter)
-{
-       int i = 0;
-       int Status = STATUS_SUCCESS;
-
-       BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Initialising Adapter = %p", psAdapter);
-
-       if (psAdapter == NULL) {
-               BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Adapter is NULL");
-               return -EINVAL;
-       }
-
-       sema_init(&psAdapter->NVMRdmWrmLock, 1);
-       sema_init(&psAdapter->rdmwrmsync, 1);
-       spin_lock_init(&psAdapter->control_queue_lock);
-       spin_lock_init(&psAdapter->txtransmitlock);
-       sema_init(&psAdapter->RxAppControlQueuelock, 1);
-       sema_init(&psAdapter->fw_download_sema, 1);
-       sema_init(&psAdapter->LowPowerModeSync, 1);
-
-       for (i = 0; i < NO_OF_QUEUES; i++)
-               spin_lock_init(&psAdapter->PackInfo[i].SFQueueLock);
-       i = 0;
-
-       init_waitqueue_head(&psAdapter->process_rx_cntrlpkt);
-       init_waitqueue_head(&psAdapter->tx_packet_wait_queue);
-       init_waitqueue_head(&psAdapter->process_read_wait_queue);
-       init_waitqueue_head(&psAdapter->ioctl_fw_dnld_wait_queue);
-       init_waitqueue_head(&psAdapter->lowpower_mode_wait_queue);
-       psAdapter->waiting_to_fw_download_done = TRUE;
-       psAdapter->fw_download_done = false;
-
-       default_wimax_protocol_initialize(psAdapter);
-       for (i = 0; i < MAX_CNTRL_PKTS; i++) {
-               psAdapter->txctlpacket[i] = kmalloc(MAX_CNTL_PKT_SIZE, GFP_KERNEL);
-               if (!psAdapter->txctlpacket[i]) {
-                       BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No More Cntl pkts got, max got is %d", i);
-                       return -ENOMEM;
-               }
-       }
-
-       if (AllocAdapterDsxBuffer(psAdapter)) {
-               BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to allocate DSX buffers");
-               return -EINVAL;
-       }
-
-       /* Initialize PHS interface */
-       if (phs_init(&psAdapter->stBCMPhsContext, psAdapter) != 0) {
-               BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "%s:%s:%d:Error PHS Init Failed=====>\n", __FILE__, __func__, __LINE__);
-               return -ENOMEM;
-       }
-
-       Status = BcmAllocFlashCSStructure(psAdapter);
-       if (Status) {
-               BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Memory Allocation for Flash structure failed");
-               return Status;
-       }
-
-       Status = vendorextnInit(psAdapter);
-
-       if (STATUS_SUCCESS != Status) {
-               BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Vendor Init Failed");
-               return Status;
-       }
-
-       BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Adapter initialised");
-
-       return STATUS_SUCCESS;
-}
-
-void AdapterFree(struct bcm_mini_adapter *Adapter)
-{
-       int count;
-
-       beceem_protocol_reset(Adapter);
-       vendorextnExit(Adapter);
-
-       if (Adapter->control_packet_handler && !IS_ERR(Adapter->control_packet_handler))
-               kthread_stop(Adapter->control_packet_handler);
-
-       if (Adapter->transmit_packet_thread && !IS_ERR(Adapter->transmit_packet_thread))
-               kthread_stop(Adapter->transmit_packet_thread);
-
-       wake_up(&Adapter->process_read_wait_queue);
-
-       if (Adapter->LEDInfo.led_thread_running & (BCM_LED_THREAD_RUNNING_ACTIVELY | BCM_LED_THREAD_RUNNING_INACTIVELY))
-               kthread_stop(Adapter->LEDInfo.led_cntrl_threadid);
-
-       unregister_networkdev(Adapter);
-
-       /* FIXME: use proper wait_event and refcounting */
-       while (atomic_read(&Adapter->ApplicationRunning)) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Waiting for Application to close.. %d\n", atomic_read(&Adapter->ApplicationRunning));
-               msleep(100);
-       }
-       unregister_control_device_interface(Adapter);
-       kfree(Adapter->pstargetparams);
-
-       for (count = 0; count < MAX_CNTRL_PKTS; count++)
-               kfree(Adapter->txctlpacket[count]);
-
-       FreeAdapterDsxBuffer(Adapter);
-       kfree(Adapter->pvInterfaceAdapter);
-
-       /* Free the PHS Interface */
-       PhsCleanup(&Adapter->stBCMPhsContext);
-
-       BcmDeAllocFlashCSStructure(Adapter);
-
-       free_netdev(Adapter->dev);
-}
-
-static int create_worker_threads(struct bcm_mini_adapter *psAdapter)
-{
-       /* Rx Control Packets Processing */
-       psAdapter->control_packet_handler = kthread_run((int (*)(void *))
-                                                       control_packet_handler, psAdapter, "%s-rx", DRV_NAME);
-       if (IS_ERR(psAdapter->control_packet_handler)) {
-               pr_notice(DRV_NAME ": could not create control thread\n");
-               return PTR_ERR(psAdapter->control_packet_handler);
-       }
-
-       /* Tx Thread */
-       psAdapter->transmit_packet_thread = kthread_run((int (*)(void *))
-                                                       tx_pkt_handler, psAdapter, "%s-tx", DRV_NAME);
-       if (IS_ERR(psAdapter->transmit_packet_thread)) {
-               pr_notice(DRV_NAME ": could not creat transmit thread\n");
-               kthread_stop(psAdapter->control_packet_handler);
-               return PTR_ERR(psAdapter->transmit_packet_thread);
-       }
-       return 0;
-}
-
-static struct file *open_firmware_file(struct bcm_mini_adapter *Adapter, const char *path)
-{
-       struct file *flp = filp_open(path, O_RDONLY, S_IRWXU);
-
-       if (IS_ERR(flp)) {
-               pr_err(DRV_NAME "Unable To Open File %s, err %ld", path, PTR_ERR(flp));
-               flp = NULL;
-       }
-
-       if (Adapter->device_removed)
-               flp = NULL;
-
-       return flp;
-}
-
-/* Arguments:
- * Logical Adapter
- * Path to image file
- * Download Address on the chip
- */
-static int BcmFileDownload(struct bcm_mini_adapter *Adapter, const char *path, unsigned int loc)
-{
-       int errorno = 0;
-       struct file *flp = NULL;
-       struct timeval tv = {0};
-
-       flp = open_firmware_file(Adapter, path);
-       if (!flp) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Unable to Open %s\n", path);
-               return -ENOENT;
-       }
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Opened file is = %s and length =0x%lx to be downloaded at =0x%x", path, (unsigned long)file_inode(flp)->i_size, loc);
-       do_gettimeofday(&tv);
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "download start %lx", ((tv.tv_sec * 1000) + (tv.tv_usec / 1000)));
-       if (Adapter->bcm_file_download(Adapter->pvInterfaceAdapter, flp, loc)) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to download the firmware with error %x!!!", -EIO);
-               errorno = -EIO;
-               goto exit_download;
-       }
-       vfs_llseek(flp, 0, 0);
-       if (Adapter->bcm_file_readback_from_chip(Adapter->pvInterfaceAdapter, flp, loc)) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to read back firmware!");
-               errorno = -EIO;
-               goto exit_download;
-       }
-
-exit_download:
-       filp_close(flp, NULL);
-       return errorno;
-}
-
-/**
- * @ingroup ctrl_pkt_functions
- * This function copies the contents of given buffer
- * to the control packet and queues it for transmission.
- * @note Do not acquire the spinlock, as it it already acquired.
- * @return  SUCCESS/FAILURE.
- * Arguments:
- * Logical Adapter
- * Control Packet Buffer
- */
-int CopyBufferToControlPacket(struct bcm_mini_adapter *Adapter, void *ioBuffer)
-{
-       struct bcm_leader *pLeader = NULL;
-       int Status = 0;
-       unsigned char *ctrl_buff;
-       unsigned int pktlen = 0;
-       struct bcm_link_request *pLinkReq = NULL;
-       PUCHAR pucAddIndication = NULL;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "======>");
-       if (!ioBuffer) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Got Null Buffer\n");
-               return -EINVAL;
-       }
-
-       pLinkReq = (struct bcm_link_request *)ioBuffer;
-       pLeader = (struct bcm_leader *)ioBuffer; /* ioBuffer Contains sw_Status and Payload */
-
-       if (Adapter->bShutStatus == TRUE &&
-               pLinkReq->szData[0] == LINK_DOWN_REQ_PAYLOAD &&
-               pLinkReq->szData[1] == LINK_SYNC_UP_SUBTYPE) {
-
-               /* Got sync down in SHUTDOWN..we could not process this. */
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "SYNC DOWN Request in Shut Down Mode..\n");
-               return STATUS_FAILURE;
-       }
-
-       if ((pLeader->Status == LINK_UP_CONTROL_REQ) &&
-               ((pLinkReq->szData[0] == LINK_UP_REQ_PAYLOAD &&
-                       (pLinkReq->szData[1] == LINK_SYNC_UP_SUBTYPE)) || /* Sync Up Command */
-                       pLinkReq->szData[0] == NETWORK_ENTRY_REQ_PAYLOAD)) /* Net Entry Command */ {
-
-               if (Adapter->LinkStatus > PHY_SYNC_ACHIVED) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "LinkStatus is Greater than PHY_SYN_ACHIEVED");
-                       return STATUS_FAILURE;
-               }
-
-               if (Adapter->bShutStatus == TRUE) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "SYNC UP IN SHUTDOWN..Device WakeUp\n");
-                       if (Adapter->bTriedToWakeUpFromlowPowerMode == false) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Waking up for the First Time..\n");
-                               Adapter->usIdleModePattern = ABORT_SHUTDOWN_MODE; /* change it to 1 for current support. */
-                               Adapter->bWakeUpDevice = TRUE;
-                               wake_up(&Adapter->process_rx_cntrlpkt);
-                               Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, !Adapter->bShutStatus, (5 * HZ));
-
-                               if (Status == -ERESTARTSYS)
-                                       return Status;
-
-                               if (Adapter->bShutStatus) {
-                                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Shutdown Mode Wake up Failed - No Wake Up Received\n");
-                                       return STATUS_FAILURE;
-                               }
-                       } else {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Wakeup has been tried already...\n");
-                       }
-               }
-       }
-
-       if (Adapter->IdleMode == TRUE) {
-               /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle mode ... hence\n"); */
-               if (pLeader->Status == LINK_UP_CONTROL_REQ || pLeader->Status == 0x80 ||
-                       pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ) {
-
-                       if ((pLeader->Status == LINK_UP_CONTROL_REQ) && (pLinkReq->szData[0] == LINK_DOWN_REQ_PAYLOAD)) {
-                               if (pLinkReq->szData[1] == LINK_SYNC_DOWN_SUBTYPE) {
-                                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Link Down Sent in Idle Mode\n");
-                                       Adapter->usIdleModePattern = ABORT_IDLE_SYNCDOWN; /* LINK DOWN sent in Idle Mode */
-                               } else {
-                                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "ABORT_IDLE_MODE pattern is being written\n");
-                                       Adapter->usIdleModePattern = ABORT_IDLE_REG;
-                               }
-                       } else {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "ABORT_IDLE_MODE pattern is being written\n");
-                               Adapter->usIdleModePattern = ABORT_IDLE_MODE;
-                       }
-
-                       /*Setting bIdleMode_tx_from_host to TRUE to indicate LED control thread to represent
-                        *  the wake up from idlemode is from host
-                        */
-                       /* Adapter->LEDInfo.bIdleMode_tx_from_host = TRUE; */
-                       Adapter->bWakeUpDevice = TRUE;
-                       wake_up(&Adapter->process_rx_cntrlpkt);
-
-                       /* We should not send DREG message down while in idlemode. */
-                       if (LINK_DOWN_REQ_PAYLOAD == pLinkReq->szData[0])
-                               return STATUS_SUCCESS;
-
-                       Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, !Adapter->IdleMode, (5 * HZ));
-
-                       if (Status == -ERESTARTSYS)
-                               return Status;
-
-                       if (Adapter->IdleMode) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Idle Mode Wake up Failed - No Wake Up Received\n");
-                               return STATUS_FAILURE;
-                       }
-               } else {
-                       return STATUS_SUCCESS;
-               }
-       }
-
-       /* The Driver has to send control messages with a particular VCID */
-       pLeader->Vcid = VCID_CONTROL_PACKET; /* VCID for control packet. */
-
-       /* Allocate skb for Control Packet */
-       pktlen = pLeader->PLength;
-       ctrl_buff = (char *)Adapter->txctlpacket[atomic_read(&Adapter->index_wr_txcntrlpkt)%MAX_CNTRL_PKTS];
-
-       if (!ctrl_buff) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "mem allocation Failed");
-               return -ENOMEM;
-       }
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Control packet to be taken =%d and address is =%pincoming address is =%p and packet len=%x",
-                       atomic_read(&Adapter->index_wr_txcntrlpkt), ctrl_buff, ioBuffer, pktlen);
-
-       if (pLeader) {
-               if ((pLeader->Status == 0x80) ||
-                       (pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ)) {
-                       /*
-                        * Restructure the DSX message to handle Multiple classifier Support
-                        * Write the Service Flow param Structures directly to the target
-                        * and embed the pointers in the DSX messages sent to target.
-                        */
-                       /* Lets store the current length of the control packet we are transmitting */
-                       pucAddIndication = (PUCHAR)ioBuffer + LEADER_SIZE;
-                       pktlen = pLeader->PLength;
-                       Status = StoreCmControlResponseMessage(Adapter, pucAddIndication, &pktlen);
-                       if (Status != 1) {
-                               ClearTargetDSXBuffer(Adapter, ((struct bcm_add_indication_alt *)pucAddIndication)->u16TID, false);
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, " Error Restoring The DSX Control Packet. Dsx Buffers on Target may not be Setup Properly ");
-                               return STATUS_FAILURE;
-                       }
-                       /*
-                        * update the leader to use the new length
-                        * The length of the control packet is length of message being sent + Leader length
-                        */
-                       pLeader->PLength = pktlen;
-               }
-       }
-
-       if (pktlen + LEADER_SIZE > MAX_CNTL_PKT_SIZE)
-               return -EINVAL;
-
-       memset(ctrl_buff, 0, pktlen+LEADER_SIZE);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Copying the Control Packet Buffer with length=%d\n", pLeader->PLength);
-       *(struct bcm_leader *)ctrl_buff = *pLeader;
-       memcpy(ctrl_buff + LEADER_SIZE, ((PUCHAR)ioBuffer + LEADER_SIZE), pLeader->PLength);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Enqueuing the Control Packet");
-
-       /* Update the statistics counters */
-       spin_lock_bh(&Adapter->PackInfo[HiPriority].SFQueueLock);
-       Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost += pLeader->PLength;
-       Adapter->PackInfo[HiPriority].uiCurrentPacketsOnHost++;
-       atomic_inc(&Adapter->TotalPacketCount);
-       spin_unlock_bh(&Adapter->PackInfo[HiPriority].SFQueueLock);
-       Adapter->PackInfo[HiPriority].bValid = TRUE;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "CurrBytesOnHost: %x bValid: %x",
-                       Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost,
-                       Adapter->PackInfo[HiPriority].bValid);
-       Status = STATUS_SUCCESS;
-       /*Queue the packet for transmission */
-       atomic_inc(&Adapter->index_wr_txcntrlpkt);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Calling transmit_packets");
-       atomic_set(&Adapter->TxPktAvail, 1);
-       wake_up(&Adapter->tx_packet_wait_queue);
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "<====");
-       return Status;
-}
-
-/******************************************************************
-* Function    - LinkMessage()
-*
-* Description - This function builds the Sync-up and Link-up request
-* packet messages depending on the device Link status.
-*
-* Parameters  - Adapter:       Pointer to the Adapter structure.
-*
-* Returns     - None.
-*******************************************************************/
-void LinkMessage(struct bcm_mini_adapter *Adapter)
-{
-       struct bcm_link_request *pstLinkRequest = NULL;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "=====>");
-       if (Adapter->LinkStatus == SYNC_UP_REQUEST && Adapter->AutoSyncup) {
-               pstLinkRequest = kzalloc(sizeof(struct bcm_link_request), GFP_ATOMIC);
-               if (!pstLinkRequest) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!");
-                       return;
-               }
-               /* sync up request... */
-               Adapter->LinkStatus = WAIT_FOR_SYNC; /* current link status */
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Requesting For SyncUp...");
-               pstLinkRequest->szData[0] = LINK_UP_REQ_PAYLOAD;
-               pstLinkRequest->szData[1] = LINK_SYNC_UP_SUBTYPE;
-               pstLinkRequest->Leader.Status = LINK_UP_CONTROL_REQ;
-               pstLinkRequest->Leader.PLength = sizeof(ULONG);
-               Adapter->bSyncUpRequestSent = TRUE;
-
-       } else if (Adapter->LinkStatus == PHY_SYNC_ACHIVED && Adapter->AutoLinkUp) {
-               pstLinkRequest = kzalloc(sizeof(struct bcm_link_request), GFP_ATOMIC);
-               if (!pstLinkRequest) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!");
-                       return;
-               }
-               /* LINK_UP_REQUEST */
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Requesting For LinkUp...");
-               pstLinkRequest->szData[0] = LINK_UP_REQ_PAYLOAD;
-               pstLinkRequest->szData[1] = LINK_NET_ENTRY;
-               pstLinkRequest->Leader.Status = LINK_UP_CONTROL_REQ;
-               pstLinkRequest->Leader.PLength = sizeof(ULONG);
-       }
-       if (pstLinkRequest) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Calling CopyBufferToControlPacket");
-               CopyBufferToControlPacket(Adapter, pstLinkRequest);
-               kfree(pstLinkRequest);
-       }
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "LinkMessage <=====");
-       return;
-}
-
-/**********************************************************************
-* Function    - StatisticsResponse()
-*
-* Description - This function handles the Statistics response packet.
-*
-* Parameters  - Adapter        : Pointer to the Adapter structure.
-* - pvBuffer: Starting address of Statistic response data.
-*
-* Returns     - None.
-************************************************************************/
-void StatisticsResponse(struct bcm_mini_adapter *Adapter, void *pvBuffer)
-{
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s====>", __func__);
-       Adapter->StatisticsPointer = ntohl(*(__be32 *)pvBuffer);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Stats at %x", (unsigned int)Adapter->StatisticsPointer);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s <====", __func__);
-}
-
-/**********************************************************************
-* Function    - LinkControlResponseMessage()
-*
-* Description - This function handles the Link response packets.
-*
-* Parameters  - Adapter         : Pointer to the Adapter structure.
-* - pucBuffer: Starting address of Link response data.
-*
-* Returns     - None.
-***********************************************************************/
-void LinkControlResponseMessage(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer)
-{
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "=====>");
-
-       if (*pucBuffer == LINK_UP_ACK) {
-               switch (*(pucBuffer+1)) {
-               case PHY_SYNC_ACHIVED: /* SYNCed UP */
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "PHY_SYNC_ACHIVED");
-
-                               if (Adapter->LinkStatus == LINKUP_DONE)
-                                       beceem_protocol_reset(Adapter);
-
-                               Adapter->usBestEffortQueueIndex = INVALID_QUEUE_INDEX;
-                               Adapter->LinkStatus = PHY_SYNC_ACHIVED;
-
-                               if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) {
-                                       Adapter->DriverState = NO_NETWORK_ENTRY;
-                                       wake_up(&Adapter->LEDInfo.notify_led_event);
-                               }
-
-                               LinkMessage(Adapter);
-                               break;
-
-               case LINKUP_DONE:
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "LINKUP_DONE");
-                       Adapter->LinkStatus = LINKUP_DONE;
-                       Adapter->bPHSEnabled = *(pucBuffer+3);
-                       Adapter->bETHCSEnabled = *(pucBuffer+4) & ETH_CS_MASK;
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "PHS Support Status Received In LinkUp Ack : %x\n", Adapter->bPHSEnabled);
-
-                       if ((false == Adapter->bShutStatus) && (false == Adapter->IdleMode)) {
-                               if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) {
-                                       Adapter->DriverState = NORMAL_OPERATION;
-                                       wake_up(&Adapter->LEDInfo.notify_led_event);
-                               }
-                       }
-                       LinkMessage(Adapter);
-                       break;
-
-               case WAIT_FOR_SYNC:
-                       /*
-                        * Driver to ignore the DREG_RECEIVED
-                        * WiMAX Application should handle this Message
-                        */
-                       /* Adapter->liTimeSinceLastNetEntry = 0; */
-                       Adapter->LinkUpStatus = 0;
-                       Adapter->LinkStatus = 0;
-                       Adapter->usBestEffortQueueIndex = INVALID_QUEUE_INDEX;
-                       Adapter->bTriedToWakeUpFromlowPowerMode = false;
-                       Adapter->IdleMode = false;
-                       beceem_protocol_reset(Adapter);
-
-                       break;
-               case LINK_SHUTDOWN_REQ_FROM_FIRMWARE:
-               case COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW:
-               {
-                       HandleShutDownModeRequest(Adapter, pucBuffer);
-               }
-               break;
-               default:
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "default case:LinkResponse %x", *(pucBuffer + 1));
-                       break;
-               }
-       } else if (SET_MAC_ADDRESS_RESPONSE == *pucBuffer) {
-               PUCHAR puMacAddr = (pucBuffer + 1);
-
-               Adapter->LinkStatus = SYNC_UP_REQUEST;
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "MAC address response, sending SYNC_UP");
-               LinkMessage(Adapter);
-               memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE);
-       }
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "%s <=====", __func__);
-}
-
-void SendIdleModeResponse(struct bcm_mini_adapter *Adapter)
-{
-       int status = 0, NVMAccess = 0, lowPwrAbortMsg = 0;
-       struct timeval tv;
-       struct bcm_link_request stIdleResponse = {{0} };
-
-       memset(&tv, 0, sizeof(tv));
-       stIdleResponse.Leader.Status = IDLE_MESSAGE;
-       stIdleResponse.Leader.PLength = IDLE_MODE_PAYLOAD_LENGTH;
-       stIdleResponse.szData[0] = GO_TO_IDLE_MODE_PAYLOAD;
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, " ============>");
-
-       /*********************************
-        *down_trylock -
-        * if [ semaphore is available ]
-        *               acquire semaphone and return value 0 ;
-        *   else
-        *               return non-zero value ;
-        *
-        ***********************************/
-
-       NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock);
-       lowPwrAbortMsg = down_trylock(&Adapter->LowPowerModeSync);
-
-
-       if ((NVMAccess || lowPwrAbortMsg || atomic_read(&Adapter->TotalPacketCount)) &&
-               (Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)) {
-
-               if (!NVMAccess)
-                       up(&Adapter->NVMRdmWrmLock);
-
-               if (!lowPwrAbortMsg)
-                       up(&Adapter->LowPowerModeSync);
-
-               stIdleResponse.szData[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE; /* NACK- device access is going on. */
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "HOST IS NACKING Idle mode To F/W!!!!!!!!");
-               Adapter->bPreparingForLowPowerMode = false;
-       } else {
-               stIdleResponse.szData[1] = TARGET_CAN_GO_TO_IDLE_MODE; /* 2; Idle ACK */
-               Adapter->StatisticsPointer = 0;
-
-               /* Wait for the LED to TURN OFF before sending ACK response */
-               if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) {
-                       int iRetVal = 0;
-
-                       /* Wake the LED Thread with IDLEMODE_ENTER State */
-                       Adapter->DriverState = LOWPOWER_MODE_ENTER;
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "LED Thread is Running..Hence Setting LED Event as IDLEMODE_ENTER jiffies:%ld", jiffies);
-                       wake_up(&Adapter->LEDInfo.notify_led_event);
-
-                       /* Wait for 1 SEC for LED to OFF */
-                       iRetVal = wait_event_timeout(Adapter->LEDInfo.idleModeSyncEvent, Adapter->LEDInfo.bIdle_led_off, msecs_to_jiffies(1000));
-
-                       /* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */
-                       if (iRetVal <= 0) {
-                               stIdleResponse.szData[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE; /* NACK- device access is going on. */
-                               Adapter->DriverState = NORMAL_OPERATION;
-                               wake_up(&Adapter->LEDInfo.notify_led_event);
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "NACKING Idle mode as time out happen from LED side!!!!!!!!");
-                       }
-               }
-
-               if (stIdleResponse.szData[1] == TARGET_CAN_GO_TO_IDLE_MODE) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "ACKING IDLE MODE !!!!!!!!!");
-                       down(&Adapter->rdmwrmsync);
-                       Adapter->bPreparingForLowPowerMode = TRUE;
-                       up(&Adapter->rdmwrmsync);
-                       /* Killing all URBS. */
-                       if (Adapter->bDoSuspend == TRUE)
-                               Bcm_kill_all_URBs((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter));
-               } else {
-                       Adapter->bPreparingForLowPowerMode = false;
-               }
-
-               if (!NVMAccess)
-                       up(&Adapter->NVMRdmWrmLock);
-
-               if (!lowPwrAbortMsg)
-                       up(&Adapter->LowPowerModeSync);
-       }
-
-       status = CopyBufferToControlPacket(Adapter, &stIdleResponse);
-       if (status != STATUS_SUCCESS) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "fail to send the Idle mode Request\n");
-               Adapter->bPreparingForLowPowerMode = false;
-               StartInterruptUrb((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter));
-       }
-       do_gettimeofday(&tv);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "IdleMode Msg submitter to Q :%ld ms", tv.tv_sec * 1000 + tv.tv_usec / 1000);
-}
-
-/******************************************************************
-* Function    - DumpPackInfo()
-*
-* Description - This function dumps the all Queue(PackInfo[]) details.
-*
-* Parameters  - Adapter: Pointer to the Adapter structure.
-*
-* Returns     - None.
-*******************************************************************/
-void DumpPackInfo(struct bcm_mini_adapter *Adapter)
-{
-       unsigned int uiLoopIndex = 0;
-       unsigned int uiIndex = 0;
-       unsigned int uiClsfrIndex = 0;
-       struct bcm_classifier_rule *pstClassifierEntry = NULL;
-
-       for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES; uiLoopIndex++) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "*********** Showing Details Of Queue %d***** ******", uiLoopIndex);
-               if (false == Adapter->PackInfo[uiLoopIndex].bValid) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bValid is false for %X index\n", uiLoopIndex);
-                       continue;
-               }
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, " Dumping     SF Rule Entry For SFID %lX\n", Adapter->PackInfo[uiLoopIndex].ulSFID);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, " ucDirection %X\n", Adapter->PackInfo[uiLoopIndex].ucDirection);
-
-               if (Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6)
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Ipv6 Service Flow\n");
-               else
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Ipv4 Service Flow\n");
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "SF Traffic Priority %X\n", Adapter->PackInfo[uiLoopIndex].u8TrafficPriority);
-
-               for (uiClsfrIndex = 0; uiClsfrIndex < MAX_CLASSIFIERS; uiClsfrIndex++) {
-                       pstClassifierEntry = &Adapter->astClassifierTable[uiClsfrIndex];
-                       if (!pstClassifierEntry->bUsed)
-                               continue;
-
-                       if (pstClassifierEntry->ulSFID != Adapter->PackInfo[uiLoopIndex].ulSFID)
-                               continue;
-
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X Classifier Rule ID : %X\n", uiClsfrIndex, pstClassifierEntry->uiClassifierRuleIndex);
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X usVCID_Value : %X\n", uiClsfrIndex, pstClassifierEntry->usVCID_Value);
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X bProtocolValid : %X\n", uiClsfrIndex, pstClassifierEntry->bProtocolValid);
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X bTOSValid : %X\n", uiClsfrIndex, pstClassifierEntry->bTOSValid);
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X bDestIpValid : %X\n", uiClsfrIndex, pstClassifierEntry->bDestIpValid);
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X bSrcIpValid : %X\n", uiClsfrIndex, pstClassifierEntry->bSrcIpValid);
-
-                       for (uiIndex = 0; uiIndex < MAX_PORT_RANGE; uiIndex++) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tusSrcPortRangeLo:%X\n", pstClassifierEntry->usSrcPortRangeLo[uiIndex]);
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tusSrcPortRangeHi:%X\n", pstClassifierEntry->usSrcPortRangeHi[uiIndex]);
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tusDestPortRangeLo:%X\n", pstClassifierEntry->usDestPortRangeLo[uiIndex]);
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tusDestPortRangeHi:%X\n", pstClassifierEntry->usDestPortRangeHi[uiIndex]);
-                       }
-
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tucIPSourceAddressLength : 0x%x\n", pstClassifierEntry->ucIPSourceAddressLength);
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tucIPDestinationAddressLength : 0x%x\n", pstClassifierEntry->ucIPDestinationAddressLength);
-                       for (uiIndex = 0; uiIndex < pstClassifierEntry->ucIPSourceAddressLength; uiIndex++) {
-                               if (Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6) {
-                                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tIpv6 ulSrcIpAddr :\n");
-                                       DumpIpv6Address(pstClassifierEntry->stSrcIpAddress.ulIpv6Addr);
-                                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tIpv6 ulSrcIpMask :\n");
-                                       DumpIpv6Address(pstClassifierEntry->stSrcIpAddress.ulIpv6Mask);
-                               } else {
-                                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tulSrcIpAddr:%lX\n", pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[uiIndex]);
-                                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tulSrcIpMask:%lX\n", pstClassifierEntry->stSrcIpAddress.ulIpv4Mask[uiIndex]);
-                               }
-                       }
-
-                       for (uiIndex = 0; uiIndex < pstClassifierEntry->ucIPDestinationAddressLength; uiIndex++) {
-                               if (Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6) {
-                                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tIpv6 ulDestIpAddr :\n");
-                                       DumpIpv6Address(pstClassifierEntry->stDestIpAddress.ulIpv6Addr);
-                                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tIpv6 ulDestIpMask :\n");
-                                       DumpIpv6Address(pstClassifierEntry->stDestIpAddress.ulIpv6Mask);
-                               } else {
-                                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tulDestIpAddr:%lX\n", pstClassifierEntry->stDestIpAddress.ulIpv4Addr[uiIndex]);
-                                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tulDestIpMask:%lX\n", pstClassifierEntry->stDestIpAddress.ulIpv4Mask[uiIndex]);
-                               }
-                       }
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tucProtocol:0x%X\n", pstClassifierEntry->ucProtocol[0]);
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tu8ClassifierRulePriority:%X\n", pstClassifierEntry->u8ClassifierRulePriority);
-               }
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ulSFID:%lX\n", Adapter->PackInfo[uiLoopIndex].ulSFID);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "usVCID_Value:%X\n", Adapter->PackInfo[uiLoopIndex].usVCID_Value);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "PhsEnabled: 0x%X\n", Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiThreshold:%X\n", Adapter->PackInfo[uiLoopIndex].uiThreshold);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bValid:%X\n", Adapter->PackInfo[uiLoopIndex].bValid);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bActive:%X\n", Adapter->PackInfo[uiLoopIndex].bActive);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ActivateReqSent: %x", Adapter->PackInfo[uiLoopIndex].bActivateRequestSent);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "u8QueueType:%X\n", Adapter->PackInfo[uiLoopIndex].u8QueueType);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiMaxBucketSize:%X\n", Adapter->PackInfo[uiLoopIndex].uiMaxBucketSize);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiPerSFTxResourceCount:%X\n", atomic_read(&Adapter->PackInfo[uiLoopIndex].uiPerSFTxResourceCount));
-               /* DumpDebug(DUMP_INFO,("bCSSupport:%X\n",Adapter->PackInfo[uiLoopIndex].bCSSupport)); */
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "CurrQueueDepthOnTarget: %x\n", Adapter->PackInfo[uiLoopIndex].uiCurrentQueueDepthOnTarget);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiCurrentBytesOnHost:%X\n", Adapter->PackInfo[uiLoopIndex].uiCurrentBytesOnHost);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiCurrentPacketsOnHost:%X\n", Adapter->PackInfo[uiLoopIndex].uiCurrentPacketsOnHost);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiDroppedCountBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiDroppedCountBytes);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiDroppedCountPackets:%X\n", Adapter->PackInfo[uiLoopIndex].uiDroppedCountPackets);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiSentBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiSentBytes);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiSentPackets:%X\n", Adapter->PackInfo[uiLoopIndex].uiSentPackets);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiCurrentDrainRate:%X\n", Adapter->PackInfo[uiLoopIndex].uiCurrentDrainRate);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiThisPeriodSentBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiThisPeriodSentBytes);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "liDrainCalculated:%llX\n", Adapter->PackInfo[uiLoopIndex].liDrainCalculated);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiCurrentTokenCount:%X\n", Adapter->PackInfo[uiLoopIndex].uiCurrentTokenCount);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "liLastUpdateTokenAt:%llX\n", Adapter->PackInfo[uiLoopIndex].liLastUpdateTokenAt);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiMaxAllowedRate:%X\n", Adapter->PackInfo[uiLoopIndex].uiMaxAllowedRate);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiPendedLast:%X\n", Adapter->PackInfo[uiLoopIndex].uiPendedLast);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "NumOfPacketsSent:%X\n", Adapter->PackInfo[uiLoopIndex].NumOfPacketsSent);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Direction: %x\n", Adapter->PackInfo[uiLoopIndex].ucDirection);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "CID: %x\n", Adapter->PackInfo[uiLoopIndex].usCID);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ProtocolValid: %x\n", Adapter->PackInfo[uiLoopIndex].bProtocolValid);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "TOSValid: %x\n", Adapter->PackInfo[uiLoopIndex].bTOSValid);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "DestIpValid: %x\n", Adapter->PackInfo[uiLoopIndex].bDestIpValid);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "SrcIpValid: %x\n", Adapter->PackInfo[uiLoopIndex].bSrcIpValid);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ActiveSet: %x\n", Adapter->PackInfo[uiLoopIndex].bActiveSet);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "AdmittedSet: %x\n", Adapter->PackInfo[uiLoopIndex].bAdmittedSet);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "AuthzSet: %x\n", Adapter->PackInfo[uiLoopIndex].bAuthorizedSet);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ClassifyPrority: %x\n", Adapter->PackInfo[uiLoopIndex].bClassifierPriority);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiMaxLatency: %x\n", Adapter->PackInfo[uiLoopIndex].uiMaxLatency);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO,
-                               DBG_LVL_ALL, "ServiceClassName: %*ph\n",
-                               4, Adapter->PackInfo[uiLoopIndex].
-                                           ucServiceClassName);
-/* BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bHeaderSuppressionEnabled :%X\n", Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled);
- * BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalTxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalTxBytes);
- * BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalRxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalRxBytes);
- *             DumpDebug(DUMP_INFO,("                          uiRanOutOfResCount:%X\n",Adapter->PackInfo[uiLoopIndex].uiRanOutOfResCount));
- */
-       }
-
-       for (uiLoopIndex = 0; uiLoopIndex < MIBS_MAX_HIST_ENTRIES; uiLoopIndex++)
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Adapter->aRxPktSizeHist[%x] = %x\n", uiLoopIndex, Adapter->aRxPktSizeHist[uiLoopIndex]);
-
-       for (uiLoopIndex = 0; uiLoopIndex < MIBS_MAX_HIST_ENTRIES; uiLoopIndex++)
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Adapter->aTxPktSizeHist[%x] = %x\n", uiLoopIndex, Adapter->aTxPktSizeHist[uiLoopIndex]);
-}
-
-int reset_card_proc(struct bcm_mini_adapter *ps_adapter)
-{
-       int retval = STATUS_SUCCESS;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-       struct bcm_interface_adapter *psIntfAdapter = NULL;
-       unsigned int value = 0, uiResetValue = 0;
-       int bytes;
-
-       psIntfAdapter = ((struct bcm_interface_adapter *)(ps_adapter->pvInterfaceAdapter));
-       ps_adapter->bDDRInitDone = false;
-
-       if (ps_adapter->chip_id >= T3LPB) {
-               /* SYS_CFG register is write protected hence for modifying this reg value, it should be read twice before */
-               rdmalt(ps_adapter, SYS_CFG, &value, sizeof(value));
-               rdmalt(ps_adapter, SYS_CFG, &value, sizeof(value));
-
-               /* making bit[6...5] same as was before f/w download. this setting force the h/w to */
-               /* re-populated the SP RAM area with the string descriptor. */
-               value = value | (ps_adapter->syscfgBefFwDld & 0x00000060);
-               wrmalt(ps_adapter, SYS_CFG, &value, sizeof(value));
-       }
-
-       /* killing all submitted URBs. */
-       psIntfAdapter->psAdapter->StopAllXaction = TRUE;
-       Bcm_kill_all_URBs(psIntfAdapter);
-       /* Reset the UMA-B Device */
-       if (ps_adapter->chip_id >= T3LPB) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Resetting UMA-B\n");
-               retval = usb_reset_device(psIntfAdapter->udev);
-               psIntfAdapter->psAdapter->StopAllXaction = false;
-
-               if (retval != STATUS_SUCCESS) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reset failed with ret value :%d", retval);
-                       goto err_exit;
-               }
-
-               if (ps_adapter->chip_id == BCS220_2 ||
-                       ps_adapter->chip_id == BCS220_2BC ||
-                       ps_adapter->chip_id == BCS250_BC ||
-                       ps_adapter->chip_id == BCS220_3) {
-
-                       bytes = rdmalt(ps_adapter, HPM_CONFIG_LDO145, &value, sizeof(value));
-                       if (bytes < 0) {
-                               retval = bytes;
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "read failed with status :%d", retval);
-                               goto err_exit;
-                       }
-                       /* setting 0th bit */
-                       value |= (1<<0);
-                       retval = wrmalt(ps_adapter, HPM_CONFIG_LDO145, &value, sizeof(value));
-                       if (retval < 0) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "write failed with status :%d", retval);
-                               goto err_exit;
-                       }
-               }
-       } else {
-               bytes = rdmalt(ps_adapter, 0x0f007018, &value, sizeof(value));
-               if (bytes < 0) {
-                       retval = bytes;
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "read failed with status :%d", retval);
-                       goto err_exit;
-               }
-               value &= (~(1<<16));
-               retval = wrmalt(ps_adapter, 0x0f007018, &value, sizeof(value));
-               if (retval < 0) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "write failed with status :%d", retval);
-                       goto err_exit;
-               }
-
-               /* Toggling the GPIO 8, 9 */
-               value = 0;
-               retval = wrmalt(ps_adapter, GPIO_OUTPUT_REGISTER, &value, sizeof(value));
-               if (retval < 0) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "write failed with status :%d", retval);
-                       goto err_exit;
-               }
-               value = 0x300;
-               retval = wrmalt(ps_adapter, GPIO_MODE_REGISTER, &value, sizeof(value));
-               if (retval < 0) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "write failed with status :%d", retval);
-                       goto err_exit;
-               }
-               mdelay(50);
-       }
-
-       /* ps_adapter->downloadDDR = false; */
-       if (ps_adapter->bFlashBoot) {
-               /* In flash boot mode MIPS state register has reverse polarity.
-                * So just or with setting bit 30.
-                * Make the MIPS in Reset state.
-                */
-               rdmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &uiResetValue, sizeof(uiResetValue));
-               uiResetValue |= (1<<30);
-               wrmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &uiResetValue, sizeof(uiResetValue));
-       }
-
-       if (ps_adapter->chip_id >= T3LPB) {
-               uiResetValue = 0;
-               /*
-                * WA for SYSConfig Issue.
-                * Read SYSCFG Twice to make it writable.
-                */
-               rdmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue));
-               if (uiResetValue & (1<<4)) {
-                       uiResetValue = 0;
-                       rdmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue)); /* 2nd read to make it writable. */
-                       uiResetValue &= (~(1<<4));
-                       wrmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue));
-               }
-       }
-       uiResetValue = 0;
-       wrmalt(ps_adapter, 0x0f01186c, &uiResetValue, sizeof(uiResetValue));
-
-err_exit:
-       psIntfAdapter->psAdapter->StopAllXaction = false;
-       return retval;
-}
-
-int run_card_proc(struct bcm_mini_adapter *ps_adapter)
-{
-       int status = STATUS_SUCCESS;
-       int bytes;
-
-       unsigned int value = 0;
-       {
-               bytes = rdmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &value, sizeof(value));
-               if (bytes < 0) {
-                       status = bytes;
-                       BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "%s:%d\n", __func__, __LINE__);
-                       return status;
-               }
-
-               if (ps_adapter->bFlashBoot)
-                       value &= (~(1<<30));
-               else
-                       value |= (1<<30);
-
-               if (wrmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &value, sizeof(value)) < 0) {
-                       BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "%s:%d\n", __func__, __LINE__);
-                       return STATUS_FAILURE;
-               }
-       }
-       return status;
-}
-
-int InitCardAndDownloadFirmware(struct bcm_mini_adapter *ps_adapter)
-{
-       int status;
-       unsigned int value = 0;
-       /*
-        * Create the threads first and then download the
-        * Firm/DDR Settings..
-        */
-       status = create_worker_threads(ps_adapter);
-       if (status < 0)
-               return status;
-
-       status = bcm_parse_target_params(ps_adapter);
-       if (status)
-               return status;
-
-       if (ps_adapter->chip_id >= T3LPB) {
-               rdmalt(ps_adapter, SYS_CFG, &value, sizeof(value));
-               ps_adapter->syscfgBefFwDld = value;
-
-               if ((value & 0x60) == 0)
-                       ps_adapter->bFlashBoot = TRUE;
-       }
-
-       reset_card_proc(ps_adapter);
-
-       /* Initializing the NVM. */
-       BcmInitNVM(ps_adapter);
-       status = ddr_init(ps_adapter);
-       if (status) {
-               pr_err(DRV_NAME "ddr_init Failed\n");
-               return status;
-       }
-
-       /* Download cfg file */
-       status = buffDnldVerify(ps_adapter,
-                               (PUCHAR)ps_adapter->pstargetparams,
-                               sizeof(struct bcm_target_params),
-                               CONFIG_BEGIN_ADDR);
-       if (status) {
-               BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Error downloading CFG file");
-               goto OUT;
-       }
-
-       if (register_networkdev(ps_adapter)) {
-               BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Netdevice failed. Cleanup needs to be performed.");
-               return -EIO;
-       }
-
-       if (false == ps_adapter->AutoFirmDld) {
-               BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "AutoFirmDld Disabled in CFG File..\n");
-               /* If Auto f/w download is disable, register the control interface, */
-               /* register the control interface after the mailbox. */
-               if (register_control_device_interface(ps_adapter) < 0) {
-                       BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Control Device failed. Cleanup needs to be performed.");
-                       return -EIO;
-               }
-               return STATUS_SUCCESS;
-       }
-
-       /*
-        * Do the LED Settings here. It will be used by the Firmware Download
-        * Thread.
-        */
-
-       /*
-        * 1. If the LED Settings fails, do not stop and do the Firmware download.
-        * 2. This init would happened only if the cfg file is present, else
-        *    call from the ioctl context.
-        */
-
-       status = InitLedSettings(ps_adapter);
-       if (status) {
-               BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_PRINTK, 0, 0, "INIT LED FAILED\n");
-               return status;
-       }
-
-       if (ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) {
-               ps_adapter->DriverState = DRIVER_INIT;
-               wake_up(&ps_adapter->LEDInfo.notify_led_event);
-       }
-
-       if (ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) {
-               ps_adapter->DriverState = FW_DOWNLOAD;
-               wake_up(&ps_adapter->LEDInfo.notify_led_event);
-       }
-
-       value = 0;
-       wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value));
-       wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value));
-
-       if (ps_adapter->eNVMType == NVM_FLASH) {
-               status = PropagateCalParamsFromFlashToMemory(ps_adapter);
-               if (status) {
-                       BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Propagation of Cal param failed ..");
-                       goto OUT;
-               }
-       }
-
-       /* Download Firmare */
-       status = BcmFileDownload(ps_adapter, BIN_FILE, FIRMWARE_BEGIN_ADDR);
-       if (status != 0) {
-               BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No Firmware File is present...\n");
-               goto OUT;
-       }
-
-       status = run_card_proc(ps_adapter);
-       if (status) {
-               BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "run_card_proc Failed\n");
-               goto OUT;
-       }
-
-       ps_adapter->fw_download_done = TRUE;
-       mdelay(10);
-
-OUT:
-       if (ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) {
-               ps_adapter->DriverState = FW_DOWNLOAD_DONE;
-               wake_up(&ps_adapter->LEDInfo.notify_led_event);
-       }
-
-       return status;
-}
-
-static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter)
-{
-       struct file *flp = NULL;
-       char *buff;
-       int len = 0;
-
-       buff = kmalloc(BUFFER_1K, GFP_KERNEL);
-       if (!buff)
-               return -ENOMEM;
-
-       Adapter->pstargetparams = kmalloc(sizeof(struct bcm_target_params), GFP_KERNEL);
-       if (Adapter->pstargetparams == NULL) {
-               kfree(buff);
-               return -ENOMEM;
-       }
-
-       flp = open_firmware_file(Adapter, CFG_FILE);
-       if (!flp) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "NOT ABLE TO OPEN THE %s FILE\n", CFG_FILE);
-               kfree(buff);
-               kfree(Adapter->pstargetparams);
-               Adapter->pstargetparams = NULL;
-               return -ENOENT;
-       }
-       len = kernel_read(flp, 0, buff, BUFFER_1K);
-       filp_close(flp, NULL);
-
-       if (len != sizeof(struct bcm_target_params)) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Mismatch in Target Param Structure!\n");
-               kfree(buff);
-               kfree(Adapter->pstargetparams);
-               Adapter->pstargetparams = NULL;
-               return -ENOENT;
-       }
-
-       /* Check for autolink in config params */
-       /*
-        * Values in Adapter->pstargetparams are in network byte order
-        */
-       memcpy(Adapter->pstargetparams, buff, sizeof(struct bcm_target_params));
-       kfree(buff);
-       beceem_parse_target_struct(Adapter);
-       return STATUS_SUCCESS;
-}
-
-void beceem_parse_target_struct(struct bcm_mini_adapter *Adapter)
-{
-       unsigned int uiHostDrvrCfg6 = 0, uiEEPROMFlag = 0;
-
-       if (ntohl(Adapter->pstargetparams->m_u32PhyParameter2) & AUTO_SYNC_DISABLE) {
-               pr_info(DRV_NAME ": AutoSyncup is Disabled\n");
-               Adapter->AutoSyncup = false;
-       } else {
-               pr_info(DRV_NAME ": AutoSyncup is Enabled\n");
-               Adapter->AutoSyncup = TRUE;
-       }
-
-       if (ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_LINKUP_ENABLE) {
-               pr_info(DRV_NAME ": Enabling autolink up");
-               Adapter->AutoLinkUp = TRUE;
-       } else {
-               pr_info(DRV_NAME ": Disabling autolink up");
-               Adapter->AutoLinkUp = false;
-       }
-       /* Setting the DDR Setting.. */
-       Adapter->DDRSetting = (ntohl(Adapter->pstargetparams->HostDrvrConfig6) >> 8)&0x0F;
-       Adapter->ulPowerSaveMode = (ntohl(Adapter->pstargetparams->HostDrvrConfig6)>>12)&0x0F;
-       pr_info(DRV_NAME ": DDR Setting: %x\n", Adapter->DDRSetting);
-       pr_info(DRV_NAME ": Power Save Mode: %lx\n", Adapter->ulPowerSaveMode);
-       if (ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_FIRM_DOWNLOAD) {
-               pr_info(DRV_NAME ": Enabling Auto Firmware Download\n");
-               Adapter->AutoFirmDld = TRUE;
-       } else {
-               pr_info(DRV_NAME ": Disabling Auto Firmware Download\n");
-               Adapter->AutoFirmDld = false;
-       }
-       uiHostDrvrCfg6 = ntohl(Adapter->pstargetparams->HostDrvrConfig6);
-       Adapter->bMipsConfig = (uiHostDrvrCfg6>>20)&0x01;
-       pr_info(DRV_NAME ": MIPSConfig   : 0x%X\n", Adapter->bMipsConfig);
-       /* used for backward compatibility. */
-       Adapter->bDPLLConfig = (uiHostDrvrCfg6>>19)&0x01;
-       Adapter->PmuMode = (uiHostDrvrCfg6 >> 24) & 0x03;
-       pr_info(DRV_NAME ": PMU MODE: %x", Adapter->PmuMode);
-
-       if ((uiHostDrvrCfg6 >> HOST_BUS_SUSPEND_BIT) & (0x01)) {
-               Adapter->bDoSuspend = TRUE;
-               pr_info(DRV_NAME ": Making DoSuspend TRUE as per configFile");
-       }
-
-       uiEEPROMFlag = ntohl(Adapter->pstargetparams->m_u32EEPROMFlag);
-       pr_info(DRV_NAME ": uiEEPROMFlag  : 0x%X\n", uiEEPROMFlag);
-       Adapter->eNVMType = (enum bcm_nvm_type)((uiEEPROMFlag>>4)&0x3);
-       Adapter->bStatusWrite = (uiEEPROMFlag>>6)&0x1;
-       Adapter->uiSectorSizeInCFG = 1024*(0xFFFF & ntohl(Adapter->pstargetparams->HostDrvrConfig4));
-       Adapter->bSectorSizeOverride = (bool) ((ntohl(Adapter->pstargetparams->HostDrvrConfig4))>>16)&0x1;
-
-       if (ntohl(Adapter->pstargetparams->m_u32PowerSavingModeOptions) & 0x01)
-               Adapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE;
-
-       if (Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)
-               doPowerAutoCorrection(Adapter);
-}
-
-static void doPowerAutoCorrection(struct bcm_mini_adapter *psAdapter)
-{
-       unsigned int reporting_mode;
-
-       reporting_mode = ntohl(psAdapter->pstargetparams->m_u32PowerSavingModeOptions) & 0x02;
-       psAdapter->bIsAutoCorrectEnabled = !((char)(psAdapter->ulPowerSaveMode >> 3) & 0x1);
-
-       if (reporting_mode) {
-               BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "can't do suspen/resume as reporting mode is enable");
-               psAdapter->bDoSuspend = false;
-       }
-
-       if (psAdapter->bIsAutoCorrectEnabled && (psAdapter->chip_id >= T3LPB)) {
-               /* If reporting mode is enable, switch PMU to PMC */
-               {
-                       psAdapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PMU_CLOCK_GATING;
-                       psAdapter->bDoSuspend = false;
-               }
-
-               /* clearing space bit[15..12] */
-               psAdapter->pstargetparams->HostDrvrConfig6 &= ~(htonl((0xF << 12)));
-               /* placing the power save mode option */
-               psAdapter->pstargetparams->HostDrvrConfig6 |= htonl((psAdapter->ulPowerSaveMode << 12));
-       } else if (psAdapter->bIsAutoCorrectEnabled == false) {
-               /* remove the autocorrect disable bit set before dumping. */
-               psAdapter->ulPowerSaveMode &= ~(1 << 3);
-               psAdapter->pstargetparams->HostDrvrConfig6 &= ~(htonl(1 << 15));
-               BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Using Forced User Choice: %lx\n", psAdapter->ulPowerSaveMode);
-       }
-}
-
-static void convertEndian(unsigned char rwFlag, unsigned int *puiBuffer, unsigned int uiByteCount)
-{
-       unsigned int uiIndex = 0;
-
-       if (RWM_WRITE == rwFlag) {
-               for (uiIndex = 0; uiIndex < (uiByteCount/sizeof(unsigned int)); uiIndex++)
-                       puiBuffer[uiIndex] = htonl(puiBuffer[uiIndex]);
-       } else {
-               for (uiIndex = 0; uiIndex < (uiByteCount/sizeof(unsigned int)); uiIndex++)
-                       puiBuffer[uiIndex] = ntohl(puiBuffer[uiIndex]);
-       }
-}
-
-int rdm(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, PCHAR pucBuff, size_t sSize)
-{
-       return Adapter->interface_rdm(Adapter->pvInterfaceAdapter,
-                               uiAddress, pucBuff, sSize);
-}
-
-int wrm(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, PCHAR pucBuff, size_t sSize)
-{
-       int iRetVal;
-
-       iRetVal = Adapter->interface_wrm(Adapter->pvInterfaceAdapter,
-                                       uiAddress, pucBuff, sSize);
-       return iRetVal;
-}
-
-int wrmalt(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, unsigned int *pucBuff, size_t size)
-{
-       convertEndian(RWM_WRITE, pucBuff, size);
-       return wrm(Adapter, uiAddress, (PUCHAR)pucBuff, size);
-}
-
-int rdmalt(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, unsigned int *pucBuff, size_t size)
-{
-       int uiRetVal = 0;
-
-       uiRetVal = rdm(Adapter, uiAddress, (PUCHAR)pucBuff, size);
-       convertEndian(RWM_READ, (unsigned int *)pucBuff, size);
-
-       return uiRetVal;
-}
-
-int wrmWithLock(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, PCHAR pucBuff, size_t sSize)
-{
-       int status = STATUS_SUCCESS;
-
-       down(&Adapter->rdmwrmsync);
-
-       if ((Adapter->IdleMode == TRUE) ||
-               (Adapter->bShutStatus == TRUE) ||
-               (Adapter->bPreparingForLowPowerMode == TRUE)) {
-
-               status = -EACCES;
-               goto exit;
-       }
-
-       status = wrm(Adapter, uiAddress, pucBuff, sSize);
-exit:
-       up(&Adapter->rdmwrmsync);
-       return status;
-}
-
-int wrmaltWithLock(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, unsigned int *pucBuff, size_t size)
-{
-       int iRetVal = STATUS_SUCCESS;
-
-       down(&Adapter->rdmwrmsync);
-
-       if ((Adapter->IdleMode == TRUE) ||
-               (Adapter->bShutStatus == TRUE) ||
-               (Adapter->bPreparingForLowPowerMode == TRUE)) {
-
-               iRetVal = -EACCES;
-               goto exit;
-       }
-
-       iRetVal = wrmalt(Adapter, uiAddress, pucBuff, size);
-exit:
-       up(&Adapter->rdmwrmsync);
-       return iRetVal;
-}
-
-int rdmaltWithLock(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, unsigned int *pucBuff, size_t size)
-{
-       int uiRetVal = STATUS_SUCCESS;
-
-       down(&Adapter->rdmwrmsync);
-       if ((Adapter->IdleMode == TRUE) ||
-               (Adapter->bShutStatus == TRUE) ||
-               (Adapter->bPreparingForLowPowerMode == TRUE)) {
-
-               uiRetVal = -EACCES;
-               goto exit;
-       }
-
-       uiRetVal = rdmalt(Adapter, uiAddress, pucBuff, size);
-exit:
-       up(&Adapter->rdmwrmsync);
-       return uiRetVal;
-}
-
-static void HandleShutDownModeWakeup(struct bcm_mini_adapter *Adapter)
-{
-       int clear_abort_pattern = 0, Status = 0;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n");
-       /* target has woken up From Shut Down */
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Clearing Shut Down Software abort pattern\n");
-       Status = wrmalt(Adapter, SW_ABORT_IDLEMODE_LOC, (unsigned int *)&clear_abort_pattern, sizeof(clear_abort_pattern));
-       if (Status) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "WRM to SW_ABORT_IDLEMODE_LOC failed with err:%d", Status);
-               return;
-       }
-
-       if (Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) {
-               msleep(100);
-               InterfaceHandleShutdownModeWakeup(Adapter);
-               msleep(100);
-       }
-
-       if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) {
-               Adapter->DriverState = NO_NETWORK_ENTRY;
-               wake_up(&Adapter->LEDInfo.notify_led_event);
-       }
-
-       Adapter->bTriedToWakeUpFromlowPowerMode = false;
-       Adapter->bShutStatus = false;
-       wake_up(&Adapter->lowpower_mode_wait_queue);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n");
-}
-
-static void SendShutModeResponse(struct bcm_mini_adapter *Adapter)
-{
-       struct bcm_link_request stShutdownResponse;
-       unsigned int NVMAccess = 0, lowPwrAbortMsg = 0;
-       unsigned int Status = 0;
-
-       memset(&stShutdownResponse, 0, sizeof(struct bcm_link_request));
-       stShutdownResponse.Leader.Status  = LINK_UP_CONTROL_REQ;
-       stShutdownResponse.Leader.PLength = 8; /* 8 bytes; */
-       stShutdownResponse.szData[0] = LINK_UP_ACK;
-       stShutdownResponse.szData[1] = LINK_SHUTDOWN_REQ_FROM_FIRMWARE;
-
-       /*********************************
-        * down_trylock -
-        * if [ semaphore is available ]
-        *               acquire semaphone and return value 0 ;
-        *   else
-        *               return non-zero value ;
-        *
-        ***********************************/
-
-       NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock);
-       lowPwrAbortMsg = down_trylock(&Adapter->LowPowerModeSync);
-
-       if (NVMAccess || lowPwrAbortMsg || atomic_read(&Adapter->TotalPacketCount)) {
-               if (!NVMAccess)
-                       up(&Adapter->NVMRdmWrmLock);
-
-               if (!lowPwrAbortMsg)
-                       up(&Adapter->LowPowerModeSync);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Device Access is going on NACK the Shut Down MODE\n");
-               stShutdownResponse.szData[2] = SHUTDOWN_NACK_FROM_DRIVER; /* NACK- device access is going on. */
-               Adapter->bPreparingForLowPowerMode = false;
-       } else {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Sending SHUTDOWN MODE ACK\n");
-               stShutdownResponse.szData[2] = SHUTDOWN_ACK_FROM_DRIVER; /* ShutDown ACK */
-
-               /* Wait for the LED to TURN OFF before sending ACK response */
-               if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) {
-                       int iRetVal = 0;
-
-                       /* Wake the LED Thread with LOWPOWER_MODE_ENTER State */
-                       Adapter->DriverState = LOWPOWER_MODE_ENTER;
-                       wake_up(&Adapter->LEDInfo.notify_led_event);
-
-                       /* Wait for 1 SEC for LED to OFF */
-                       iRetVal = wait_event_timeout(Adapter->LEDInfo.idleModeSyncEvent, Adapter->LEDInfo.bIdle_led_off, msecs_to_jiffies(1000));
-
-                       /* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */
-                       if (iRetVal <= 0) {
-                               stShutdownResponse.szData[1] = SHUTDOWN_NACK_FROM_DRIVER; /* NACK- device access is going on. */
-                               Adapter->DriverState = NO_NETWORK_ENTRY;
-                               wake_up(&Adapter->LEDInfo.notify_led_event);
-                       }
-               }
-
-               if (stShutdownResponse.szData[2] == SHUTDOWN_ACK_FROM_DRIVER) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "ACKING SHUTDOWN MODE !!!!!!!!!");
-                       down(&Adapter->rdmwrmsync);
-                       Adapter->bPreparingForLowPowerMode = TRUE;
-                       up(&Adapter->rdmwrmsync);
-                       /* Killing all URBS. */
-                       if (Adapter->bDoSuspend == TRUE)
-                               Bcm_kill_all_URBs((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter));
-               } else {
-                       Adapter->bPreparingForLowPowerMode = false;
-               }
-
-               if (!NVMAccess)
-                       up(&Adapter->NVMRdmWrmLock);
-
-               if (!lowPwrAbortMsg)
-                       up(&Adapter->LowPowerModeSync);
-       }
-
-       Status = CopyBufferToControlPacket(Adapter, &stShutdownResponse);
-       if (Status != STATUS_SUCCESS) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "fail to send the Idle mode Request\n");
-               Adapter->bPreparingForLowPowerMode = false;
-               StartInterruptUrb((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter));
-       }
-}
-
-static void HandleShutDownModeRequest(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer)
-{
-       unsigned int uiResetValue = 0;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n");
-
-       if (*(pucBuffer+1) ==  COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW) {
-               HandleShutDownModeWakeup(Adapter);
-       } else if (*(pucBuffer+1) ==  LINK_SHUTDOWN_REQ_FROM_FIRMWARE) {
-               /* Target wants to go to Shut Down Mode */
-               /* InterfacePrepareForShutdown(Adapter); */
-               if (Adapter->chip_id == BCS220_2 ||
-                       Adapter->chip_id == BCS220_2BC ||
-                       Adapter->chip_id == BCS250_BC ||
-                       Adapter->chip_id == BCS220_3) {
-
-                       rdmalt(Adapter, HPM_CONFIG_MSW, &uiResetValue, 4);
-                       uiResetValue |= (1<<17);
-                       wrmalt(Adapter, HPM_CONFIG_MSW, &uiResetValue, 4);
-               }
-
-               SendShutModeResponse(Adapter);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "ShutDownModeResponse:Notification received: Sending the response(Ack/Nack)\n");
-       }
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n");
-}
-
-void ResetCounters(struct bcm_mini_adapter *Adapter)
-{
-       beceem_protocol_reset(Adapter);
-       Adapter->CurrNumRecvDescs = 0;
-       Adapter->PrevNumRecvDescs = 0;
-       Adapter->LinkUpStatus = 0;
-       Adapter->LinkStatus = 0;
-       atomic_set(&Adapter->cntrlpktCnt, 0);
-       atomic_set(&Adapter->TotalPacketCount, 0);
-       Adapter->fw_download_done = false;
-       Adapter->LinkStatus = 0;
-       Adapter->AutoLinkUp = false;
-       Adapter->IdleMode = false;
-       Adapter->bShutStatus = false;
-}
-
-struct bcm_classifier_rule *GetFragIPClsEntry(struct bcm_mini_adapter *Adapter, USHORT usIpIdentification, ULONG SrcIP)
-{
-       unsigned int uiIndex = 0;
-
-       for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) {
-               if ((Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed) &&
-                       (Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification) &&
-                       (Adapter->astFragmentedPktClassifierTable[uiIndex].ulSrcIpAddress == SrcIP) &&
-                       !Adapter->astFragmentedPktClassifierTable[uiIndex].bOutOfOrderFragment)
-
-                       return Adapter->astFragmentedPktClassifierTable[uiIndex].pstMatchedClassifierEntry;
-       }
-       return NULL;
-}
-
-void AddFragIPClsEntry(struct bcm_mini_adapter *Adapter, struct bcm_fragmented_packet_info *psFragPktInfo)
-{
-       unsigned int uiIndex = 0;
-
-       for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) {
-               if (!Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed) {
-                       memcpy(&Adapter->astFragmentedPktClassifierTable[uiIndex], psFragPktInfo, sizeof(struct bcm_fragmented_packet_info));
-                       break;
-               }
-       }
-}
-
-void DelFragIPClsEntry(struct bcm_mini_adapter *Adapter, USHORT usIpIdentification, ULONG SrcIp)
-{
-       unsigned int uiIndex = 0;
-
-       for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) {
-               if ((Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed) &&
-                       (Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification) &&
-                       (Adapter->astFragmentedPktClassifierTable[uiIndex].ulSrcIpAddress == SrcIp))
-
-                       memset(&Adapter->astFragmentedPktClassifierTable[uiIndex], 0, sizeof(struct bcm_fragmented_packet_info));
-       }
-}
-
-void update_per_cid_rx(struct bcm_mini_adapter *Adapter)
-{
-       unsigned int qindex = 0;
-
-       if ((jiffies - Adapter->liDrainCalculated) < XSECONDS)
-               return;
-
-       for (qindex = 0; qindex < HiPriority; qindex++) {
-               if (Adapter->PackInfo[qindex].ucDirection == 0) {
-                       Adapter->PackInfo[qindex].uiCurrentRxRate =
-                               (Adapter->PackInfo[qindex].uiCurrentRxRate +
-                                       Adapter->PackInfo[qindex].uiThisPeriodRxBytes) / 2;
-
-                       Adapter->PackInfo[qindex].uiThisPeriodRxBytes = 0;
-               } else {
-                       Adapter->PackInfo[qindex].uiCurrentDrainRate =
-                               (Adapter->PackInfo[qindex].uiCurrentDrainRate +
-                                       Adapter->PackInfo[qindex].uiThisPeriodSentBytes) / 2;
-                       Adapter->PackInfo[qindex].uiThisPeriodSentBytes = 0;
-               }
-       }
-       Adapter->liDrainCalculated = jiffies;
-}
-
-void update_per_sf_desc_cnts(struct bcm_mini_adapter *Adapter)
-{
-       int iIndex = 0;
-       u32 uibuff[MAX_TARGET_DSX_BUFFERS];
-       int bytes;
-
-       if (!atomic_read(&Adapter->uiMBupdate))
-               return;
-
-       bytes = rdmaltWithLock(Adapter, TARGET_SFID_TXDESC_MAP_LOC, (unsigned int *)uibuff, sizeof(unsigned int) * MAX_TARGET_DSX_BUFFERS);
-       if (bytes < 0) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "rdm failed\n");
-               return;
-       }
-
-       for (iIndex = 0; iIndex < HiPriority; iIndex++) {
-               if (Adapter->PackInfo[iIndex].bValid && Adapter->PackInfo[iIndex].ucDirection) {
-                       if (Adapter->PackInfo[iIndex].usVCID_Value < MAX_TARGET_DSX_BUFFERS)
-                               atomic_set(&Adapter->PackInfo[iIndex].uiPerSFTxResourceCount, uibuff[Adapter->PackInfo[iIndex].usVCID_Value]);
-                       else
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Invalid VCID : %x\n", Adapter->PackInfo[iIndex].usVCID_Value);
-               }
-       }
-       atomic_set(&Adapter->uiMBupdate, false);
-}
-
-void flush_queue(struct bcm_mini_adapter *Adapter, unsigned int iQIndex)
-{
-       struct sk_buff *PacketToDrop = NULL;
-       struct net_device_stats *netstats = &Adapter->dev->stats;
-
-       spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock);
-
-       while (Adapter->PackInfo[iQIndex].FirstTxQueue && atomic_read(&Adapter->TotalPacketCount)) {
-               PacketToDrop = Adapter->PackInfo[iQIndex].FirstTxQueue;
-               if (PacketToDrop && PacketToDrop->len) {
-                       netstats->tx_dropped++;
-                       DEQUEUEPACKET(Adapter->PackInfo[iQIndex].FirstTxQueue, Adapter->PackInfo[iQIndex].LastTxQueue);
-                       Adapter->PackInfo[iQIndex].uiCurrentPacketsOnHost--;
-                       Adapter->PackInfo[iQIndex].uiCurrentBytesOnHost -= PacketToDrop->len;
-
-                       /* Adding dropped statistics */
-                       Adapter->PackInfo[iQIndex].uiDroppedCountBytes += PacketToDrop->len;
-                       Adapter->PackInfo[iQIndex].uiDroppedCountPackets++;
-                       dev_kfree_skb(PacketToDrop);
-                       atomic_dec(&Adapter->TotalPacketCount);
-               }
-       }
-       spin_unlock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock);
-}
-
-static void beceem_protocol_reset(struct bcm_mini_adapter *Adapter)
-{
-       int i;
-
-       if (netif_msg_link(Adapter))
-               pr_notice(PFX "%s: protocol reset\n", Adapter->dev->name);
-
-       netif_carrier_off(Adapter->dev);
-       netif_stop_queue(Adapter->dev);
-
-       Adapter->IdleMode = false;
-       Adapter->LinkUpStatus = false;
-       ClearTargetDSXBuffer(Adapter, 0, TRUE);
-       /* Delete All Classifier Rules */
-
-       for (i = 0; i < HiPriority; i++)
-               DeleteAllClassifiersForSF(Adapter, i);
-
-       flush_all_queues(Adapter);
-
-       if (Adapter->TimerActive == TRUE)
-               Adapter->TimerActive = false;
-
-       memset(Adapter->astFragmentedPktClassifierTable, 0, sizeof(struct bcm_fragmented_packet_info) * MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES);
-
-       for (i = 0; i < HiPriority; i++) {
-               /* resetting only the first size (S_MIBS_SERVICEFLOW_TABLE) for the SF. */
-               /* It is same between MIBs and SF. */
-               memset(&Adapter->PackInfo[i].stMibsExtServiceFlowTable, 0, sizeof(struct bcm_mibs_parameters));
-       }
-}
diff --git a/drivers/staging/bcm/PHSDefines.h b/drivers/staging/bcm/PHSDefines.h
deleted file mode 100644 (file)
index cd78ee4..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-#ifndef BCM_PHS_DEFINES_H
-#define BCM_PHS_DEFINES_H
-
-#define PHS_INVALID_TABLE_INDEX        0xffffffff
-#define PHS_MEM_TAG "_SHP"
-
-/* PHS Defines */
-#define STATUS_PHS_COMPRESSED          0xa1
-#define STATUS_PHS_NOCOMPRESSION       0xa2
-#define APPLY_PHS                      1
-#define MAX_NO_BIT                     7
-#define ZERO_PHSI                      0
-#define VERIFY                         0
-#define SIZE_MULTIPLE_32               4
-#define UNCOMPRESSED_PACKET            0
-#define DYNAMIC                                0
-#define SUPPRESS                       0x80
-#define NO_CLASSIFIER_MATCH            0
-#define SEND_PACKET_UNCOMPRESSED       0
-#define PHSI_IS_ZERO                   0
-#define PHSI_LEN                       1
-#define ERROR_LEN                      0
-#define PHS_BUFFER_SIZE                        1532
-#define MAX_PHSRULE_PER_SF             20
-#define MAX_SERVICEFLOWS               17
-
-/* PHS Error Defines */
-#define PHS_SUCCESS                            0
-#define ERR_PHS_INVALID_DEVICE_EXETENSION      0x800
-#define ERR_PHS_INVALID_PHS_RULE               0x801
-#define ERR_PHS_RULE_ALREADY_EXISTS            0x802
-#define ERR_SF_MATCH_FAIL                      0x803
-#define ERR_INVALID_CLASSIFIERTABLE_FOR_SF     0x804
-#define ERR_SFTABLE_FULL                       0x805
-#define ERR_CLSASSIFIER_TABLE_FULL             0x806
-#define ERR_PHSRULE_MEMALLOC_FAIL              0x807
-#define ERR_CLSID_MATCH_FAIL                   0x808
-#define ERR_PHSRULE_MATCH_FAIL                 0x809
-
-struct bcm_phs_rule {
-       u8 u8PHSI;
-       u8 u8PHSFLength;
-       u8 u8PHSF[MAX_PHS_LENGTHS];
-       u8 u8PHSMLength;
-       u8 u8PHSM[MAX_PHS_LENGTHS];
-       u8 u8PHSS;
-       u8 u8PHSV;
-       u8 u8RefCnt;
-       u8 bUnclassifiedPHSRule;
-       u8 u8Reserved[3];
-       long PHSModifiedBytes;
-       unsigned long PHSModifiedNumPackets;
-       unsigned long PHSErrorNumPackets;
-};
-
-enum bcm_phs_classifier_context {
-       eActiveClassifierRuleContext,
-       eOldClassifierRuleContext
-};
-
-struct bcm_phs_classifier_entry {
-       u8  bUsed;
-       u16 uiClassifierRuleId;
-       u8  u8PHSI;
-       struct bcm_phs_rule *pstPhsRule;
-       u8  bUnclassifiedPHSRule;
-};
-
-struct bcm_phs_classifier_table {
-       u16 uiTotalClassifiers;
-       struct bcm_phs_classifier_entry stActivePhsRulesList[MAX_PHSRULE_PER_SF];
-       struct bcm_phs_classifier_entry stOldPhsRulesList[MAX_PHSRULE_PER_SF];
-       u16 uiOldestPhsRuleIndex;
-};
-
-struct bcm_phs_entry {
-       u8  bUsed;
-       u16 uiVcid;
-       struct bcm_phs_classifier_table *pstClassifierTable;
-};
-
-struct bcm_phs_table {
-       u16 uiTotalServiceFlows;
-       struct bcm_phs_entry stSFList[MAX_SERVICEFLOWS];
-};
-
-struct bcm_phs_extension {
-       /* PHS Specific data */
-       struct bcm_phs_table *pstServiceFlowPhsRulesTable;
-       void *CompressedTxBuffer;
-       void *UnCompressedRxBuffer;
-};
-
-#endif
diff --git a/drivers/staging/bcm/PHSModule.c b/drivers/staging/bcm/PHSModule.c
deleted file mode 100644 (file)
index 5f4e503..0000000
+++ /dev/null
@@ -1,1703 +0,0 @@
-#include "headers.h"
-
-static UINT CreateSFToClassifierRuleMapping(B_UINT16 uiVcid,
-                                           B_UINT16 uiClsId,
-                                           struct bcm_phs_table *psServiceFlowTable,
-                                           struct bcm_phs_rule *psPhsRule,
-                                           B_UINT8 u8AssociatedPHSI);
-
-static UINT CreateClassiferToPHSRuleMapping(B_UINT16 uiVcid,
-                                           B_UINT16  uiClsId,
-                                           struct bcm_phs_entry *pstServiceFlowEntry,
-                                           struct bcm_phs_rule *psPhsRule,
-                                           B_UINT8 u8AssociatedPHSI);
-
-static UINT CreateClassifierPHSRule(B_UINT16  uiClsId,
-                                   struct bcm_phs_classifier_table *psaClassifiertable,
-                                   struct bcm_phs_rule *psPhsRule,
-                                   enum bcm_phs_classifier_context eClsContext,
-                                   B_UINT8 u8AssociatedPHSI);
-
-static UINT UpdateClassifierPHSRule(B_UINT16 uiClsId,
-                                   struct bcm_phs_classifier_entry *pstClassifierEntry,
-                                   struct bcm_phs_classifier_table *psaClassifiertable,
-                                   struct bcm_phs_rule *psPhsRule,
-                                   B_UINT8 u8AssociatedPHSI);
-
-static bool ValidatePHSRuleComplete(const struct bcm_phs_rule *psPhsRule);
-
-static bool DerefPhsRule(B_UINT16 uiClsId,
-                        struct bcm_phs_classifier_table *psaClassifiertable,
-                        struct bcm_phs_rule *pstPhsRule);
-
-static UINT GetClassifierEntry(struct bcm_phs_classifier_table *pstClassifierTable,
-                              B_UINT32 uiClsid,
-                              enum bcm_phs_classifier_context eClsContext,
-                              struct bcm_phs_classifier_entry **ppstClassifierEntry);
-
-static UINT GetPhsRuleEntry(struct bcm_phs_classifier_table *pstClassifierTable,
-                           B_UINT32 uiPHSI,
-                           enum bcm_phs_classifier_context eClsContext,
-                           struct bcm_phs_rule **ppstPhsRule);
-
-static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesTable);
-
-static int phs_compress(struct bcm_phs_rule *phs_members,
-                       unsigned char *in_buf,
-                       unsigned char *out_buf,
-                       unsigned int *header_size,
-                       UINT *new_header_size);
-
-static int verify_suppress_phsf(unsigned char *in_buffer,
-                               unsigned char *out_buffer,
-                               unsigned char *phsf,
-                               unsigned char *phsm,
-                               unsigned int phss,
-                               unsigned int phsv,
-                               UINT *new_header_size);
-
-static int phs_decompress(unsigned char *in_buf,
-                         unsigned char *out_buf,
-                         struct bcm_phs_rule *phs_rules,
-                         UINT *header_size);
-
-static ULONG PhsCompress(void *pvContext,
-                        B_UINT16 uiVcid,
-                        B_UINT16 uiClsId,
-                        void *pvInputBuffer,
-                        void *pvOutputBuffer,
-                        UINT *pOldHeaderSize,
-                        UINT *pNewHeaderSize);
-
-static ULONG PhsDeCompress(void *pvContext,
-                          B_UINT16 uiVcid,
-                          void *pvInputBuffer,
-                          void *pvOutputBuffer,
-                          UINT *pInHeaderSize,
-                          UINT *pOutHeaderSize);
-
-#define IN
-#define OUT
-
-/*
- * Function: PHSTransmit
- * Description:        This routine handle PHS(Payload Header Suppression for Tx path.
- *     It extracts a fragment of the NDIS_PACKET containing the header
- *     to be suppressed. It then suppresses the header by invoking PHS exported compress routine.
- *     The header data after suppression is copied back to the NDIS_PACKET.
- *
- * Input parameters: IN struct bcm_mini_adapter *Adapter         - Miniport Adapter Context
- *     IN Packet - NDIS packet containing data to be transmitted
- *     IN USHORT Vcid - vcid pertaining to connection on which the packet is being sent.Used to
- *             identify PHS rule to be applied.
- *     B_UINT16 uiClassifierRuleID - Classifier Rule ID
- *     BOOLEAN bHeaderSuppressionEnabled - indicates if header suprression is enabled for SF.
- *
- * Return:     STATUS_SUCCESS - If the send was successful.
- *     Other  - If an error occurred.
- */
-
-int PHSTransmit(struct bcm_mini_adapter *Adapter,
-               struct sk_buff **pPacket,
-               USHORT Vcid,
-               B_UINT16 uiClassifierRuleID,
-               bool bHeaderSuppressionEnabled,
-               UINT *PacketLen,
-               UCHAR bEthCSSupport)
-{
-       /* PHS Sepcific */
-       UINT unPHSPktHdrBytesCopied = 0;
-       UINT unPhsOldHdrSize = 0;
-       UINT unPHSNewPktHeaderLen = 0;
-       /* Pointer to PHS IN Hdr Buffer */
-       PUCHAR pucPHSPktHdrInBuf =
-               Adapter->stPhsTxContextInfo.ucaHdrSuppressionInBuf;
-       /* Pointer to PHS OUT Hdr Buffer */
-       PUCHAR pucPHSPktHdrOutBuf =
-               Adapter->stPhsTxContextInfo.ucaHdrSuppressionOutBuf;
-       UINT usPacketType;
-       UINT BytesToRemove = 0;
-       bool bPHSI = 0;
-       LONG ulPhsStatus = 0;
-       UINT numBytesCompressed = 0;
-       struct sk_buff *newPacket = NULL;
-       struct sk_buff *Packet = *pPacket;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
-                       "In PHSTransmit");
-
-       if (!bEthCSSupport)
-               BytesToRemove = ETH_HLEN;
-       /*
-        * Accumulate the header upto the size we support suppression
-        * from NDIS packet
-        */
-
-       usPacketType = ((struct ethhdr *)(Packet->data))->h_proto;
-
-       pucPHSPktHdrInBuf = Packet->data + BytesToRemove;
-       /* considering data after ethernet header */
-       if ((*PacketLen - BytesToRemove) < MAX_PHS_LENGTHS)
-               unPHSPktHdrBytesCopied = (*PacketLen - BytesToRemove);
-       else
-               unPHSPktHdrBytesCopied = MAX_PHS_LENGTHS;
-
-       if ((unPHSPktHdrBytesCopied > 0) &&
-               (unPHSPktHdrBytesCopied <= MAX_PHS_LENGTHS)) {
-
-               /*
-                * Step 2 Suppress Header using PHS and fill into intermediate
-                * ucaPHSPktHdrOutBuf.
-                * Suppress only if IP Header and PHS Enabled For the
-                * Service Flow
-                */
-               if (((usPacketType == ETHERNET_FRAMETYPE_IPV4) ||
-                               (usPacketType == ETHERNET_FRAMETYPE_IPV6)) &&
-                       (bHeaderSuppressionEnabled)) {
-
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND,
-                                       DBG_LVL_ALL,
-                                       "\nTrying to PHS Compress Using Classifier rule 0x%X",
-                                       uiClassifierRuleID);
-                       unPHSNewPktHeaderLen = unPHSPktHdrBytesCopied;
-                       ulPhsStatus = PhsCompress(&Adapter->stBCMPhsContext,
-                                                 Vcid,
-                                                 uiClassifierRuleID,
-                                                 pucPHSPktHdrInBuf,
-                                                 pucPHSPktHdrOutBuf,
-                                                 &unPhsOldHdrSize,
-                                                 &unPHSNewPktHeaderLen);
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND,
-                                       DBG_LVL_ALL,
-                                       "\nPHS Old header Size : %d New Header Size  %d\n",
-                                       unPhsOldHdrSize, unPHSNewPktHeaderLen);
-
-                       if (unPHSNewPktHeaderLen == unPhsOldHdrSize) {
-
-                               if (ulPhsStatus == STATUS_PHS_COMPRESSED)
-                                       bPHSI = *pucPHSPktHdrOutBuf;
-
-                               ulPhsStatus = STATUS_PHS_NOCOMPRESSION;
-                       }
-
-                       if (ulPhsStatus == STATUS_PHS_COMPRESSED) {
-
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
-                                               PHS_SEND, DBG_LVL_ALL,
-                                               "PHS Sending packet Compressed");
-
-                               if (skb_cloned(Packet)) {
-                                       newPacket =
-                                               skb_copy(Packet, GFP_ATOMIC);
-
-                                       if (newPacket == NULL)
-                                               return STATUS_FAILURE;
-
-                                       dev_kfree_skb(Packet);
-                                       *pPacket = Packet = newPacket;
-                                       pucPHSPktHdrInBuf =
-                                               Packet->data + BytesToRemove;
-                               }
-
-                               numBytesCompressed = unPhsOldHdrSize -
-                                       (unPHSNewPktHeaderLen + PHSI_LEN);
-
-                               memcpy(pucPHSPktHdrInBuf + numBytesCompressed,
-                                      pucPHSPktHdrOutBuf,
-                                      unPHSNewPktHeaderLen + PHSI_LEN);
-                               memcpy(Packet->data + numBytesCompressed,
-                                      Packet->data, BytesToRemove);
-                               skb_pull(Packet, numBytesCompressed);
-
-                               return STATUS_SUCCESS;
-                       } else {
-                               /* if one byte headroom is not available,
-                                * increase it through skb_cow
-                                */
-                               if (!(skb_headroom(Packet) > 0)) {
-
-                                       if (skb_cow(Packet, 1)) {
-                                               BCM_DEBUG_PRINT(Adapter,
-                                                               DBG_TYPE_PRINTK,
-                                                               0, 0,
-                                                               "SKB Cow Failed\n");
-                                               return STATUS_FAILURE;
-                                       }
-                               }
-                               skb_push(Packet, 1);
-
-                               /*
-                                * CAUTION: The MAC Header is getting corrupted
-                                * here for IP CS - can be saved by copying 14
-                                * Bytes.  not needed .... hence corrupting it.
-                                */
-                               *(Packet->data + BytesToRemove) = bPHSI;
-                               return STATUS_SUCCESS;
-                       }
-               } else {
-
-                       if (!bHeaderSuppressionEnabled)
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
-                                               PHS_SEND, DBG_LVL_ALL,
-                                               "\nHeader Suppression Disabled For SF: No PHS\n");
-
-                       return STATUS_SUCCESS;
-               }
-       }
-
-       /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
-        * "PHSTransmit : Dumping data packet After PHS"); */
-       return STATUS_SUCCESS;
-}
-
-int PHSReceive(struct bcm_mini_adapter *Adapter,
-              USHORT usVcid,
-              struct sk_buff *packet,
-              UINT *punPacketLen,
-              UCHAR *pucEthernetHdr,
-              UINT bHeaderSuppressionEnabled)
-{
-       u32 nStandardPktHdrLen = 0;
-       u32 nTotalsuppressedPktHdrBytes = 0;
-       int ulPhsStatus = 0;
-       PUCHAR pucInBuff = NULL;
-       UINT TotalBytesAdded = 0;
-
-       if (!bHeaderSuppressionEnabled) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE,
-                               DBG_LVL_ALL,
-                               "\nPhs Disabled for incoming packet");
-               return ulPhsStatus;
-       }
-
-       pucInBuff = packet->data;
-
-       /* Restore PHS suppressed header */
-       nStandardPktHdrLen = packet->len;
-       ulPhsStatus = PhsDeCompress(&Adapter->stBCMPhsContext,
-                                   usVcid,
-                                   pucInBuff,
-                                   Adapter->ucaPHSPktRestoreBuf,
-                                   &nTotalsuppressedPktHdrBytes,
-                                   &nStandardPktHdrLen);
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL,
-                       "\nSuppressed PktHdrLen : 0x%x Restored PktHdrLen : 0x%x",
-                       nTotalsuppressedPktHdrBytes, nStandardPktHdrLen);
-
-       if (ulPhsStatus != STATUS_PHS_COMPRESSED) {
-               skb_pull(packet, 1);
-               return STATUS_SUCCESS;
-       } else {
-               TotalBytesAdded = nStandardPktHdrLen -
-                       nTotalsuppressedPktHdrBytes - PHSI_LEN;
-
-               if (TotalBytesAdded) {
-                       if (skb_headroom(packet) >= (SKB_RESERVE_ETHERNET_HEADER + TotalBytesAdded))
-                               skb_push(packet, TotalBytesAdded);
-                       else {
-                               if (skb_cow(packet, skb_headroom(packet) + TotalBytesAdded)) {
-                                       BCM_DEBUG_PRINT(Adapter,
-                                                       DBG_TYPE_PRINTK, 0, 0,
-                                                       "cow failed in receive\n");
-                                       return STATUS_FAILURE;
-                               }
-
-                               skb_push(packet, TotalBytesAdded);
-                       }
-               }
-
-               memcpy(packet->data, Adapter->ucaPHSPktRestoreBuf,
-                      nStandardPktHdrLen);
-       }
-
-       return STATUS_SUCCESS;
-}
-
-void DumpFullPacket(UCHAR *pBuf, UINT nPktLen)
-{
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,
-                       "Dumping Data Packet");
-       BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,
-                              pBuf, nPktLen);
-}
-
-/*
- * Procedure:   phs_init
- *
- * Description: This routine is responsible for allocating memory for classifier
- * and PHS rules.
- *
- * Arguments:
- * pPhsdeviceExtension - ptr to Device extension containing PHS Classifier rules
- * and PHS Rules , RX, TX buffer etc
- *
- * Returns:
- * TRUE(1)     -If allocation of memory was successful.
- * FALSE       -If allocation of memory fails.
- */
-int phs_init(struct bcm_phs_extension *pPhsdeviceExtension,
-            struct bcm_mini_adapter *Adapter)
-{
-       int i;
-       struct bcm_phs_table *pstServiceFlowTable;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
-                       "\nPHS:phs_init function");
-
-       if (pPhsdeviceExtension->pstServiceFlowPhsRulesTable)
-               return -EINVAL;
-
-       pPhsdeviceExtension->pstServiceFlowPhsRulesTable =
-               kzalloc(sizeof(struct bcm_phs_table), GFP_KERNEL);
-
-       if (!pPhsdeviceExtension->pstServiceFlowPhsRulesTable) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
-                               DBG_LVL_ALL,
-                               "\nAllocation ServiceFlowPhsRulesTable failed");
-               return -ENOMEM;
-       }
-
-       pstServiceFlowTable = pPhsdeviceExtension->pstServiceFlowPhsRulesTable;
-       for (i = 0; i < MAX_SERVICEFLOWS; i++) {
-               struct bcm_phs_entry sServiceFlow =
-                       pstServiceFlowTable->stSFList[i];
-               sServiceFlow.pstClassifierTable =
-                       kzalloc(sizeof(struct bcm_phs_classifier_table),
-                               GFP_KERNEL);
-               if (!sServiceFlow.pstClassifierTable) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
-                                       DBG_LVL_ALL, "\nAllocation failed");
-                       free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable);
-                       pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL;
-                       return -ENOMEM;
-               }
-       }
-
-       pPhsdeviceExtension->CompressedTxBuffer = kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL);
-       if (pPhsdeviceExtension->CompressedTxBuffer == NULL) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
-                               DBG_LVL_ALL, "\nAllocation failed");
-               free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable);
-               pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL;
-               return -ENOMEM;
-       }
-
-       pPhsdeviceExtension->UnCompressedRxBuffer =
-               kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL);
-       if (pPhsdeviceExtension->UnCompressedRxBuffer == NULL) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
-                               DBG_LVL_ALL, "\nAllocation failed");
-               kfree(pPhsdeviceExtension->CompressedTxBuffer);
-               free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable);
-               pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL;
-               return -ENOMEM;
-       }
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
-                       "\n phs_init Successful");
-       return STATUS_SUCCESS;
-}
-
-int PhsCleanup(IN struct bcm_phs_extension *pPHSDeviceExt)
-{
-       if (pPHSDeviceExt->pstServiceFlowPhsRulesTable) {
-               free_phs_serviceflow_rules(pPHSDeviceExt->pstServiceFlowPhsRulesTable);
-               pPHSDeviceExt->pstServiceFlowPhsRulesTable = NULL;
-       }
-
-       kfree(pPHSDeviceExt->CompressedTxBuffer);
-       pPHSDeviceExt->CompressedTxBuffer = NULL;
-
-       kfree(pPHSDeviceExt->UnCompressedRxBuffer);
-       pPHSDeviceExt->UnCompressedRxBuffer = NULL;
-
-       return 0;
-}
-
-/*
- * PHS functions
- * PhsUpdateClassifierRule
- *
- * Routine Description:
- *   Exported function to add or modify a PHS Rule.
- *
- * Arguments:
- *     IN void* pvContext - PHS Driver Specific Context
- *     IN B_UINT16 uiVcid    - The Service Flow ID for which the PHS rule applies
- *     IN B_UINT16  uiClsId   - The Classifier ID within the Service Flow for which the PHS rule applies.
- *     IN struct bcm_phs_rule *psPhsRule - The PHS Rule strcuture to be added to the PHS Rule table.
- *
- * Return Value:
- *
- * 0 if successful,
- * >0 Error.
- */
-ULONG PhsUpdateClassifierRule(IN void *pvContext,
-                             IN B_UINT16 uiVcid ,
-                             IN B_UINT16 uiClsId   ,
-                             IN struct bcm_phs_rule *psPhsRule,
-                             IN B_UINT8 u8AssociatedPHSI)
-{
-       ULONG lStatus = 0;
-       UINT nSFIndex = 0;
-       struct bcm_phs_entry *pstServiceFlowEntry = NULL;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-       struct bcm_phs_extension *pDeviceExtension =
-               (struct bcm_phs_extension *)pvContext;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
-                       "PHS With Corr2 Changes\n");
-
-       if (pDeviceExtension == NULL) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
-                               DBG_LVL_ALL, "Invalid Device Extension\n");
-               return ERR_PHS_INVALID_DEVICE_EXETENSION;
-       }
-
-       if (u8AssociatedPHSI == 0)
-               return ERR_PHS_INVALID_PHS_RULE;
-
-       /* Retrieve the SFID Entry Index for requested Service Flow */
-       nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
-                                      uiVcid, &pstServiceFlowEntry);
-
-       if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
-               /* This is a new SF. Create a mapping entry for this */
-               lStatus = CreateSFToClassifierRuleMapping(uiVcid, uiClsId,
-                                                         pDeviceExtension->pstServiceFlowPhsRulesTable,
-                                                         psPhsRule,
-                                                         u8AssociatedPHSI);
-               return lStatus;
-       }
-
-       /* SF already Exists Add PHS Rule to existing SF */
-       lStatus = CreateClassiferToPHSRuleMapping(uiVcid, uiClsId,
-                                                 pstServiceFlowEntry,
-                                                 psPhsRule,
-                                                 u8AssociatedPHSI);
-
-       return lStatus;
-}
-
-/*
- * PhsDeletePHSRule
- *
- * Routine Description:
- *   Deletes the specified phs Rule within Vcid
- *
- * Arguments:
- *     IN void* pvContext - PHS Driver Specific Context
- *     IN B_UINT16  uiVcid    - The Service Flow ID for which the PHS rule applies
- *     IN B_UINT8  u8PHSI   - the PHS Index identifying PHS rule to be deleted.
- *
- * Return Value:
- *
- * 0 if successful,
- * >0 Error.
- */
-ULONG PhsDeletePHSRule(IN void *pvContext,
-                      IN B_UINT16 uiVcid,
-                      IN B_UINT8 u8PHSI)
-{
-       UINT nSFIndex = 0, nClsidIndex = 0;
-       struct bcm_phs_entry *pstServiceFlowEntry = NULL;
-       struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-       struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext;
-       struct bcm_phs_classifier_entry *curr_entry;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
-                       "======>\n");
-
-       if (pDeviceExtension) {
-               /* Retrieve the SFID Entry Index for requested Service Flow */
-               nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
-                                              uiVcid, &pstServiceFlowEntry);
-
-               if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
-                                       DBG_LVL_ALL, "SFID Match Failed\n");
-                       return ERR_SF_MATCH_FAIL;
-               }
-
-               pstClassifierRulesTable = pstServiceFlowEntry->pstClassifierTable;
-               if (pstClassifierRulesTable) {
-                       for (nClsidIndex = 0; nClsidIndex < MAX_PHSRULE_PER_SF; nClsidIndex++) {
-                               curr_entry = &pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex];
-                               if (curr_entry->bUsed &&
-                                   curr_entry->pstPhsRule &&
-                                   (curr_entry->pstPhsRule->u8PHSI == u8PHSI)) {
-
-                                       if (curr_entry->pstPhsRule->u8RefCnt)
-                                               curr_entry->pstPhsRule->u8RefCnt--;
-
-                                       if (0 == curr_entry->pstPhsRule->u8RefCnt)
-                                               kfree(curr_entry->pstPhsRule);
-
-                                       memset(curr_entry,
-                                              0,
-                                              sizeof(struct bcm_phs_classifier_entry));
-                               }
-                       }
-               }
-       }
-       return 0;
-}
-
-/*
- * PhsDeleteClassifierRule
- *
- * Routine Description:
- *    Exported function to Delete a PHS Rule for the SFID,CLSID Pair.
- *
- * Arguments:
- *     IN void* pvContext - PHS Driver Specific Context
- *     IN B_UINT16  uiVcid    - The Service Flow ID for which the PHS rule applies
- *     IN B_UINT16  uiClsId   - The Classifier ID within the Service Flow for which the PHS rule applies.
- *
- * Return Value:
- *
- * 0 if successful,
- * >0 Error.
- */
-ULONG PhsDeleteClassifierRule(IN void *pvContext,
-                             IN B_UINT16 uiVcid,
-                             IN B_UINT16 uiClsId)
-{
-       UINT nSFIndex = 0, nClsidIndex = 0;
-       struct bcm_phs_entry *pstServiceFlowEntry = NULL;
-       struct bcm_phs_classifier_entry *pstClassifierEntry = NULL;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-       struct bcm_phs_extension *pDeviceExtension =
-               (struct bcm_phs_extension *)pvContext;
-
-       if (!pDeviceExtension)
-               goto out;
-
-       /* Retrieve the SFID Entry Index for requested Service Flow */
-       nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
-                                      uiVcid, &pstServiceFlowEntry);
-       if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
-                               DBG_LVL_ALL, "SFID Match Failed\n");
-               return ERR_SF_MATCH_FAIL;
-       }
-
-       nClsidIndex =
-               GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
-                                  uiClsId,
-                                  eActiveClassifierRuleContext,
-                                  &pstClassifierEntry);
-
-       if ((nClsidIndex != PHS_INVALID_TABLE_INDEX) &&
-                       (!pstClassifierEntry->bUnclassifiedPHSRule)) {
-               if (pstClassifierEntry->pstPhsRule) {
-                       if (pstClassifierEntry->pstPhsRule->u8RefCnt)
-                               pstClassifierEntry->pstPhsRule->u8RefCnt--;
-
-                       if (0 == pstClassifierEntry->pstPhsRule->u8RefCnt)
-                               kfree(pstClassifierEntry->pstPhsRule);
-               }
-               memset(pstClassifierEntry, 0,
-                      sizeof(struct bcm_phs_classifier_entry));
-       }
-
-       nClsidIndex =
-               GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
-                                  uiClsId,
-                                  eOldClassifierRuleContext,
-                                  &pstClassifierEntry);
-
-       if ((nClsidIndex != PHS_INVALID_TABLE_INDEX) &&
-                       (!pstClassifierEntry->bUnclassifiedPHSRule)) {
-               kfree(pstClassifierEntry->pstPhsRule);
-               memset(pstClassifierEntry, 0,
-                      sizeof(struct bcm_phs_classifier_entry));
-       }
-
-out:
-       return 0;
-}
-
-/*
- * PhsDeleteSFRules
- *
- * Routine Description:
- *    Exported function to Delete a all PHS Rules for the SFID.
- *
- * Arguments:
- *     IN void* pvContext - PHS Driver Specific Context
- *     IN B_UINT16 uiVcid   - The Service Flow ID for which the PHS rules need to be deleted
- *
- * Return Value:
- *
- * 0 if successful,
- * >0 Error.
- */
-ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid)
-{
-       UINT nSFIndex = 0, nClsidIndex = 0;
-       struct bcm_phs_entry *pstServiceFlowEntry = NULL;
-       struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-       struct bcm_phs_extension *pDeviceExtension =
-               (struct bcm_phs_extension *)pvContext;
-       struct bcm_phs_classifier_entry *curr_clsf_entry;
-       struct bcm_phs_classifier_entry *curr_rules_list;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
-                       "====>\n");
-
-       if (!pDeviceExtension)
-               goto out;
-
-       /* Retrieve the SFID Entry Index for requested Service Flow */
-       nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
-                                      uiVcid, &pstServiceFlowEntry);
-       if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
-                               DBG_LVL_ALL, "SFID Match Failed\n");
-               return ERR_SF_MATCH_FAIL;
-       }
-
-       pstClassifierRulesTable = pstServiceFlowEntry->pstClassifierTable;
-       if (pstClassifierRulesTable) {
-               for (nClsidIndex = 0; nClsidIndex < MAX_PHSRULE_PER_SF; nClsidIndex++) {
-                       curr_clsf_entry =
-                               &pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex];
-
-                       curr_rules_list =
-                               &pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex];
-
-                       if (curr_clsf_entry->pstPhsRule) {
-
-                               if (curr_clsf_entry->pstPhsRule->u8RefCnt)
-                                       curr_clsf_entry->pstPhsRule->u8RefCnt--;
-
-                               if (0 == curr_clsf_entry->pstPhsRule->u8RefCnt)
-                                       kfree(curr_clsf_entry->pstPhsRule);
-
-                               curr_clsf_entry->pstPhsRule = NULL;
-                       }
-                       memset(curr_clsf_entry, 0,
-                              sizeof(struct bcm_phs_classifier_entry));
-                       if (curr_rules_list->pstPhsRule) {
-
-                               if (curr_rules_list->pstPhsRule->u8RefCnt)
-                                       curr_rules_list->pstPhsRule->u8RefCnt--;
-
-                               if (0 == curr_rules_list->pstPhsRule->u8RefCnt)
-                                       kfree(curr_rules_list->pstPhsRule);
-
-                               curr_rules_list->pstPhsRule = NULL;
-                       }
-                       memset(curr_rules_list, 0,
-                              sizeof(struct bcm_phs_classifier_entry));
-               }
-       }
-       pstServiceFlowEntry->bUsed = false;
-       pstServiceFlowEntry->uiVcid = 0;
-
-out:
-       return 0;
-}
-
-/*
- * PhsCompress
- *
- * Routine Description:
- *    Exported function to compress the data using PHS.
- *
- * Arguments:
- *     IN void* pvContext          - PHS Driver Specific Context.
- *     IN B_UINT16 uiVcid          - The Service Flow ID to which current
- *                                   packet header compression applies.
- *     IN UINT  uiClsId            - The Classifier ID to which current packet
- *                                   header compression applies.
- *     IN void *pvInputBuffer      - The Input buffer containg packet header
- *                                   data
- *     IN void *pvOutputBuffer     - The output buffer returned by this
- *                                   function after PHS
- *     IN UINT *pOldHeaderSize     - The actual size of the header before PHS
- *     IN UINT *pNewHeaderSize     - The new size of the header after applying
- *                                   PHS
- *
- * Return Value:
- *
- * 0 if successful,
- * >0 Error.
- */
-static ULONG PhsCompress(IN void *pvContext,
-                        IN B_UINT16 uiVcid,
-                        IN B_UINT16 uiClsId,
-                        IN void *pvInputBuffer,
-                        OUT void *pvOutputBuffer,
-                        OUT UINT *pOldHeaderSize,
-                        OUT UINT *pNewHeaderSize)
-{
-       UINT nSFIndex = 0, nClsidIndex = 0;
-       struct bcm_phs_entry *pstServiceFlowEntry = NULL;
-       struct bcm_phs_classifier_entry *pstClassifierEntry = NULL;
-       struct bcm_phs_rule *pstPhsRule = NULL;
-       ULONG lStatus = 0;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-       struct bcm_phs_extension *pDeviceExtension =
-               (struct bcm_phs_extension *)pvContext;
-
-       if (pDeviceExtension == NULL) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
-                               "Invalid Device Extension\n");
-               lStatus = STATUS_PHS_NOCOMPRESSION;
-               return lStatus;
-       }
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
-                       "Suppressing header\n");
-
-       /* Retrieve the SFID Entry Index for requested Service Flow */
-       nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
-                                      uiVcid, &pstServiceFlowEntry);
-       if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
-                               "SFID Match Failed\n");
-               lStatus = STATUS_PHS_NOCOMPRESSION;
-               return lStatus;
-       }
-
-       nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
-                                        uiClsId, eActiveClassifierRuleContext,
-                                        &pstClassifierEntry);
-
-       if (nClsidIndex == PHS_INVALID_TABLE_INDEX) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
-                               "No PHS Rule Defined For Classifier\n");
-               lStatus =  STATUS_PHS_NOCOMPRESSION;
-               return lStatus;
-       }
-
-       /* get rule from SF id,Cls ID pair and proceed */
-       pstPhsRule = pstClassifierEntry->pstPhsRule;
-       if (!ValidatePHSRuleComplete(pstPhsRule)) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
-                               "PHS Rule Defined For Classifier But Not Complete\n");
-               lStatus = STATUS_PHS_NOCOMPRESSION;
-               return lStatus;
-       }
-
-       /* Compress Packet */
-       lStatus = phs_compress(pstPhsRule,
-                              (PUCHAR)pvInputBuffer,
-                              (PUCHAR)pvOutputBuffer,
-                              pOldHeaderSize,
-                              pNewHeaderSize);
-
-       if (lStatus == STATUS_PHS_COMPRESSED) {
-               pstPhsRule->PHSModifiedBytes +=
-                       *pOldHeaderSize - *pNewHeaderSize - 1;
-               pstPhsRule->PHSModifiedNumPackets++;
-       } else {
-               pstPhsRule->PHSErrorNumPackets++;
-       }
-
-       return lStatus;
-}
-
-/*
- * PhsDeCompress
- *
- * Routine Description:
- *    Exported function to restore the packet header in Rx path.
- *
- * Arguments:
- *     IN void* pvContext          - PHS Driver Specific Context.
- *     IN B_UINT16 uiVcid          - The Service Flow ID to which current
- *                                   packet header restoration applies.
- *     IN  void *pvInputBuffer     - The Input buffer containg suppressed
- *                                   packet header data
- *     OUT void *pvOutputBuffer    - The output buffer returned by this
- *                                   function after restoration
- *     OUT UINT *pHeaderSize       - The packet header size after restoration
- *                                   is returned in this parameter.
- *
- * Return Value:
- *
- * 0 if successful,
- * >0 Error.
- */
-static ULONG PhsDeCompress(IN void *pvContext,
-                          IN B_UINT16 uiVcid,
-                          IN void *pvInputBuffer,
-                          OUT void *pvOutputBuffer,
-                          OUT UINT *pInHeaderSize,
-                          OUT UINT *pOutHeaderSize)
-{
-       UINT nSFIndex = 0, nPhsRuleIndex = 0;
-       struct bcm_phs_entry *pstServiceFlowEntry = NULL;
-       struct bcm_phs_rule *pstPhsRule = NULL;
-       UINT phsi;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-       struct bcm_phs_extension *pDeviceExtension =
-               (struct bcm_phs_extension *)pvContext;
-
-       *pInHeaderSize = 0;
-       if (pDeviceExtension == NULL) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE,
-                               DBG_LVL_ALL, "Invalid Device Extension\n");
-               return ERR_PHS_INVALID_DEVICE_EXETENSION;
-       }
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL,
-                       "Restoring header\n");
-
-       phsi = *((unsigned char *)(pvInputBuffer));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL,
-                       "PHSI To Be Used For restore : %x\n", phsi);
-       if (phsi == UNCOMPRESSED_PACKET)
-               return STATUS_PHS_NOCOMPRESSION;
-
-       /* Retrieve the SFID Entry Index for requested Service Flow */
-       nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
-                                      uiVcid, &pstServiceFlowEntry);
-       if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE,
-                               DBG_LVL_ALL,
-                               "SFID Match Failed During Lookup\n");
-               return ERR_SF_MATCH_FAIL;
-       }
-
-       nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable,
-                                       phsi,
-                                       eActiveClassifierRuleContext,
-                                       &pstPhsRule);
-       if (nPhsRuleIndex == PHS_INVALID_TABLE_INDEX) {
-               /* Phs Rule does not exist in  active rules table. Lets try
-                * in the old rules table. */
-               nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable,
-                                               phsi,
-                                               eOldClassifierRuleContext,
-                                               &pstPhsRule);
-               if (nPhsRuleIndex == PHS_INVALID_TABLE_INDEX)
-                       return ERR_PHSRULE_MATCH_FAIL;
-       }
-
-       *pInHeaderSize = phs_decompress((PUCHAR)pvInputBuffer,
-                                       (PUCHAR)pvOutputBuffer,
-                                       pstPhsRule,
-                                       pOutHeaderSize);
-
-       pstPhsRule->PHSModifiedBytes += *pOutHeaderSize - *pInHeaderSize - 1;
-
-       pstPhsRule->PHSModifiedNumPackets++;
-       return STATUS_PHS_COMPRESSED;
-}
-
-/*
- * Procedure:   free_phs_serviceflow_rules
- *
- * Description: This routine is responsible for freeing memory allocated for
- * PHS rules.
- *
- * Arguments:
- * rules       - ptr to S_SERVICEFLOW_TABLE structure.
- *
- * Returns:
- * Does not return any value.
- */
-static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesTable)
-{
-       int i, j;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-       struct bcm_phs_classifier_entry *curr_act_rules_list;
-       struct bcm_phs_classifier_entry *curr_old_rules_list;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
-                       "=======>\n");
-
-       if (!psServiceFlowRulesTable)
-               goto out;
-
-       for (i = 0; i < MAX_SERVICEFLOWS; i++) {
-               struct bcm_phs_entry stServiceFlowEntry =
-                       psServiceFlowRulesTable->stSFList[i];
-               struct bcm_phs_classifier_table *pstClassifierRulesTable =
-                       stServiceFlowEntry.pstClassifierTable;
-
-               if (pstClassifierRulesTable) {
-                       for (j = 0; j < MAX_PHSRULE_PER_SF; j++) {
-                               curr_act_rules_list =
-                                       &pstClassifierRulesTable->stActivePhsRulesList[j];
-
-                               curr_old_rules_list =
-                                       &pstClassifierRulesTable->stOldPhsRulesList[j];
-
-                               if (curr_act_rules_list->pstPhsRule) {
-
-                                       if (curr_act_rules_list->pstPhsRule->u8RefCnt)
-                                               curr_act_rules_list->pstPhsRule->u8RefCnt--;
-
-                                       if (0 == curr_act_rules_list->pstPhsRule->u8RefCnt)
-                                               kfree(curr_act_rules_list->pstPhsRule);
-
-                                       curr_act_rules_list->pstPhsRule = NULL;
-                               }
-
-                               if (curr_old_rules_list->pstPhsRule) {
-
-                                       if (curr_old_rules_list->pstPhsRule->u8RefCnt)
-                                               curr_old_rules_list->pstPhsRule->u8RefCnt--;
-
-                                       if (0 == curr_old_rules_list->pstPhsRule->u8RefCnt)
-                                               kfree(curr_old_rules_list->pstPhsRule);
-
-                                       curr_old_rules_list->pstPhsRule = NULL;
-                               }
-                       }
-                       kfree(pstClassifierRulesTable);
-                       stServiceFlowEntry.pstClassifierTable =
-                               pstClassifierRulesTable = NULL;
-               }
-       }
-
-out:
-
-       kfree(psServiceFlowRulesTable);
-       psServiceFlowRulesTable = NULL;
-}
-
-static bool ValidatePHSRuleComplete(IN const struct bcm_phs_rule *psPhsRule)
-{
-       return (psPhsRule &&
-               psPhsRule->u8PHSI &&
-               psPhsRule->u8PHSS &&
-               psPhsRule->u8PHSFLength);
-}
-
-UINT GetServiceFlowEntry(IN struct bcm_phs_table *psServiceFlowTable,
-                        IN B_UINT16 uiVcid,
-                        struct bcm_phs_entry **ppstServiceFlowEntry)
-{
-       int i;
-       struct bcm_phs_entry *curr_sf_list;
-
-       for (i = 0; i < MAX_SERVICEFLOWS; i++) {
-               curr_sf_list = &psServiceFlowTable->stSFList[i];
-               if (curr_sf_list->bUsed && (curr_sf_list->uiVcid == uiVcid)) {
-                       *ppstServiceFlowEntry = curr_sf_list;
-                       return i;
-               }
-       }
-
-       *ppstServiceFlowEntry = NULL;
-       return PHS_INVALID_TABLE_INDEX;
-}
-
-static UINT GetClassifierEntry(IN struct bcm_phs_classifier_table *pstClassifierTable,
-                              IN B_UINT32 uiClsid,
-                              enum bcm_phs_classifier_context eClsContext,
-                              OUT struct bcm_phs_classifier_entry **ppstClassifierEntry)
-{
-       int  i;
-       struct bcm_phs_classifier_entry *psClassifierRules = NULL;
-
-       for (i = 0; i < MAX_PHSRULE_PER_SF; i++) {
-
-               if (eClsContext == eActiveClassifierRuleContext)
-                       psClassifierRules =
-                               &pstClassifierTable->stActivePhsRulesList[i];
-               else
-                       psClassifierRules =
-                               &pstClassifierTable->stOldPhsRulesList[i];
-
-               if (psClassifierRules->bUsed &&
-                  (psClassifierRules->uiClassifierRuleId == uiClsid)) {
-                       *ppstClassifierEntry = psClassifierRules;
-                       return i;
-               }
-       }
-
-       *ppstClassifierEntry = NULL;
-       return PHS_INVALID_TABLE_INDEX;
-}
-
-static UINT GetPhsRuleEntry(IN struct bcm_phs_classifier_table *pstClassifierTable,
-                           IN B_UINT32 uiPHSI,
-                           enum bcm_phs_classifier_context eClsContext,
-                           OUT struct bcm_phs_rule **ppstPhsRule)
-{
-       int  i;
-       struct bcm_phs_classifier_entry *pstClassifierRule = NULL;
-
-       for (i = 0; i < MAX_PHSRULE_PER_SF; i++) {
-               if (eClsContext == eActiveClassifierRuleContext)
-                       pstClassifierRule =
-                               &pstClassifierTable->stActivePhsRulesList[i];
-               else
-                       pstClassifierRule =
-                               &pstClassifierTable->stOldPhsRulesList[i];
-
-               if (pstClassifierRule->bUsed &&
-                  (pstClassifierRule->u8PHSI == uiPHSI)) {
-                       *ppstPhsRule = pstClassifierRule->pstPhsRule;
-                       return i;
-               }
-       }
-
-       *ppstPhsRule = NULL;
-       return PHS_INVALID_TABLE_INDEX;
-}
-
-static UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid,
-                                           IN B_UINT16  uiClsId,
-                                           IN struct bcm_phs_table *psServiceFlowTable,
-                                           struct bcm_phs_rule *psPhsRule,
-                                           B_UINT8 u8AssociatedPHSI)
-{
-       struct bcm_phs_classifier_table *psaClassifiertable = NULL;
-       UINT uiStatus = 0;
-       int iSfIndex;
-       bool bFreeEntryFound = false;
-       struct bcm_phs_entry *curr_list;
-
-       /* Check for a free entry in SFID table */
-       for (iSfIndex = 0; iSfIndex < MAX_SERVICEFLOWS; iSfIndex++) {
-               curr_list = &psServiceFlowTable->stSFList[iSfIndex];
-               if (!curr_list->bUsed) {
-                       bFreeEntryFound = TRUE;
-                       break;
-               }
-       }
-
-       if (!bFreeEntryFound)
-               return ERR_SFTABLE_FULL;
-
-       psaClassifiertable = curr_list->pstClassifierTable;
-       uiStatus = CreateClassifierPHSRule(uiClsId,
-                                          psaClassifiertable,
-                                          psPhsRule,
-                                          eActiveClassifierRuleContext,
-                                          u8AssociatedPHSI);
-       if (uiStatus == PHS_SUCCESS) {
-               /* Add entry at free index to the SF */
-               curr_list->bUsed = TRUE;
-               curr_list->uiVcid = uiVcid;
-       }
-
-       return uiStatus;
-}
-
-static UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid,
-                                           IN B_UINT16 uiClsId,
-                                           IN struct bcm_phs_entry *pstServiceFlowEntry,
-                                           struct bcm_phs_rule *psPhsRule,
-                                           B_UINT8 u8AssociatedPHSI)
-{
-       struct bcm_phs_classifier_entry *pstClassifierEntry = NULL;
-       UINT uiStatus = PHS_SUCCESS;
-       UINT nClassifierIndex = 0;
-       struct bcm_phs_classifier_table *psaClassifiertable = NULL;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       psaClassifiertable = pstServiceFlowEntry->pstClassifierTable;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
-                       "==>");
-
-       /* Check if the supplied Classifier already exists */
-       nClassifierIndex = GetClassifierEntry(
-               pstServiceFlowEntry->pstClassifierTable,
-               uiClsId,
-               eActiveClassifierRuleContext,
-               &pstClassifierEntry);
-
-       if (nClassifierIndex == PHS_INVALID_TABLE_INDEX) {
-               /*
-                * The Classifier doesn't exist. So its a new classifier being
-                * added.
-                * Add new entry to associate PHS Rule to the Classifier
-                */
-
-               uiStatus = CreateClassifierPHSRule(uiClsId, psaClassifiertable,
-                                                  psPhsRule,
-                                                  eActiveClassifierRuleContext,
-                                                  u8AssociatedPHSI);
-               return uiStatus;
-       }
-
-       /*
-        * The Classifier exists.The PHS Rule for this classifier
-        * is being modified
-        */
-
-       if (pstClassifierEntry->u8PHSI == psPhsRule->u8PHSI) {
-               if (pstClassifierEntry->pstPhsRule == NULL)
-                       return ERR_PHS_INVALID_PHS_RULE;
-
-               /*
-                * This rule already exists if any fields are changed for this
-                * PHS rule update them.
-                */
-               /* If any part of PHSF is valid then we update PHSF */
-               if (psPhsRule->u8PHSFLength) {
-                       /* update PHSF */
-                       memcpy(pstClassifierEntry->pstPhsRule->u8PHSF,
-                              psPhsRule->u8PHSF,
-                              MAX_PHS_LENGTHS);
-               }
-
-               if (psPhsRule->u8PHSFLength) {
-                       /* update PHSFLen */
-                       pstClassifierEntry->pstPhsRule->u8PHSFLength =
-                               psPhsRule->u8PHSFLength;
-               }
-
-               if (psPhsRule->u8PHSMLength) {
-                       /* update PHSM */
-                       memcpy(pstClassifierEntry->pstPhsRule->u8PHSM,
-                              psPhsRule->u8PHSM,
-                              MAX_PHS_LENGTHS);
-               }
-
-               if (psPhsRule->u8PHSMLength) {
-                       /* update PHSM Len */
-                       pstClassifierEntry->pstPhsRule->u8PHSMLength =
-                               psPhsRule->u8PHSMLength;
-               }
-
-               if (psPhsRule->u8PHSS) {
-                       /* update PHSS */
-                       pstClassifierEntry->pstPhsRule->u8PHSS =
-                               psPhsRule->u8PHSS;
-               }
-
-               /* update PHSV */
-               pstClassifierEntry->pstPhsRule->u8PHSV = psPhsRule->u8PHSV;
-       } else {
-               /* A new rule is being set for this classifier. */
-               uiStatus = UpdateClassifierPHSRule(uiClsId,
-                                                  pstClassifierEntry,
-                                                  psaClassifiertable,
-                                                  psPhsRule,
-                                                  u8AssociatedPHSI);
-       }
-
-       return uiStatus;
-}
-
-static UINT CreateClassifierPHSRule(IN B_UINT16  uiClsId,
-                                   struct bcm_phs_classifier_table *psaClassifiertable,
-                                   struct bcm_phs_rule *psPhsRule,
-                                   enum bcm_phs_classifier_context eClsContext,
-                                   B_UINT8 u8AssociatedPHSI)
-{
-       UINT iClassifierIndex = 0;
-       bool bFreeEntryFound = false;
-       struct bcm_phs_classifier_entry *psClassifierRules = NULL;
-       UINT nStatus = PHS_SUCCESS;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
-                       "Inside CreateClassifierPHSRule");
-
-       if (psaClassifiertable == NULL)
-               return ERR_INVALID_CLASSIFIERTABLE_FOR_SF;
-
-       if (eClsContext == eOldClassifierRuleContext) {
-               /*
-                * If An Old Entry for this classifier ID already exists in the
-                * old rules table replace it.
-                */
-
-               iClassifierIndex = GetClassifierEntry(psaClassifiertable,
-                                                     uiClsId,
-                                                     eClsContext,
-                                                     &psClassifierRules);
-
-               if (iClassifierIndex != PHS_INVALID_TABLE_INDEX) {
-                       /*
-                        * The Classifier already exists in the old rules table
-                        * Lets replace the old classifier with the new one.
-                        */
-                       bFreeEntryFound = TRUE;
-               }
-       }
-
-       if (!bFreeEntryFound) {
-               /* Continue to search for a free location to add the rule */
-               for (iClassifierIndex = 0; iClassifierIndex <
-                            MAX_PHSRULE_PER_SF; iClassifierIndex++) {
-                       if (eClsContext == eActiveClassifierRuleContext)
-                               psClassifierRules = &psaClassifiertable->stActivePhsRulesList[iClassifierIndex];
-                       else
-                               psClassifierRules = &psaClassifiertable->stOldPhsRulesList[iClassifierIndex];
-
-                       if (!psClassifierRules->bUsed) {
-                               bFreeEntryFound = TRUE;
-                               break;
-                       }
-               }
-       }
-
-       if (!bFreeEntryFound) {
-
-               if (eClsContext == eActiveClassifierRuleContext)
-                       return ERR_CLSASSIFIER_TABLE_FULL;
-               else {
-                       /* Lets replace the oldest rule if we are looking in
-                        * old Rule table */
-                       if (psaClassifiertable->uiOldestPhsRuleIndex >= MAX_PHSRULE_PER_SF)
-                               psaClassifiertable->uiOldestPhsRuleIndex = 0;
-
-                       iClassifierIndex =
-                               psaClassifiertable->uiOldestPhsRuleIndex;
-                       psClassifierRules =
-                               &psaClassifiertable->stOldPhsRulesList[iClassifierIndex];
-
-                       (psaClassifiertable->uiOldestPhsRuleIndex)++;
-               }
-       }
-
-       if (eClsContext == eOldClassifierRuleContext) {
-
-               if (psClassifierRules->pstPhsRule == NULL) {
-
-                       psClassifierRules->pstPhsRule =
-                               kmalloc(sizeof(struct bcm_phs_rule),
-                                       GFP_KERNEL);
-
-                       if (NULL == psClassifierRules->pstPhsRule)
-                               return ERR_PHSRULE_MEMALLOC_FAIL;
-               }
-
-               psClassifierRules->bUsed = TRUE;
-               psClassifierRules->uiClassifierRuleId = uiClsId;
-               psClassifierRules->u8PHSI = psPhsRule->u8PHSI;
-               psClassifierRules->bUnclassifiedPHSRule =
-                       psPhsRule->bUnclassifiedPHSRule;
-
-               /* Update The PHS rule */
-               memcpy(psClassifierRules->pstPhsRule, psPhsRule,
-                      sizeof(struct bcm_phs_rule));
-       } else
-               nStatus = UpdateClassifierPHSRule(uiClsId,
-                                                 psClassifierRules,
-                                                 psaClassifiertable,
-                                                 psPhsRule,
-                                                 u8AssociatedPHSI);
-
-       return nStatus;
-}
-
-static UINT UpdateClassifierPHSRule(IN B_UINT16  uiClsId,
-                                   IN struct bcm_phs_classifier_entry *pstClassifierEntry,
-                                   struct bcm_phs_classifier_table *psaClassifiertable,
-                                   struct bcm_phs_rule *psPhsRule,
-                                   B_UINT8 u8AssociatedPHSI)
-{
-       struct bcm_phs_rule *pstAddPhsRule = NULL;
-       UINT nPhsRuleIndex = 0;
-       bool bPHSRuleOrphaned = false;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       psPhsRule->u8RefCnt = 0;
-
-       /* Step 1 Deref Any Exisiting PHS Rule in this classifier Entry */
-       bPHSRuleOrphaned = DerefPhsRule(uiClsId, psaClassifiertable,
-                                       pstClassifierEntry->pstPhsRule);
-
-       /* Step 2 Search if there is a PHS Rule with u8AssociatedPHSI in
-        * Classifier table for this SF */
-       nPhsRuleIndex = GetPhsRuleEntry(psaClassifiertable, u8AssociatedPHSI,
-                                       eActiveClassifierRuleContext,
-                                       &pstAddPhsRule);
-       if (PHS_INVALID_TABLE_INDEX == nPhsRuleIndex) {
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
-                               DBG_LVL_ALL,
-                               "\nAdding New PHSRuleEntry For Classifier");
-
-               if (psPhsRule->u8PHSI == 0) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
-                                       DBG_LVL_ALL, "\nError PHSI is Zero\n");
-                       return ERR_PHS_INVALID_PHS_RULE;
-               }
-
-               /* Step 2.a PHS Rule Does Not Exist .Create New PHS Rule for
-                * uiClsId */
-               if (false == bPHSRuleOrphaned) {
-
-                       pstClassifierEntry->pstPhsRule =
-                               kmalloc(sizeof(struct bcm_phs_rule),
-                                       GFP_KERNEL);
-                       if (NULL == pstClassifierEntry->pstPhsRule)
-                               return ERR_PHSRULE_MEMALLOC_FAIL;
-               }
-               memcpy(pstClassifierEntry->pstPhsRule, psPhsRule,
-                      sizeof(struct bcm_phs_rule));
-       } else {
-               /* Step 2.b PHS Rule  Exists Tie uiClsId with the existing
-                * PHS Rule */
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
-                               DBG_LVL_ALL,
-                               "\nTying Classifier to Existing PHS Rule");
-               if (bPHSRuleOrphaned) {
-                       kfree(pstClassifierEntry->pstPhsRule);
-                       pstClassifierEntry->pstPhsRule = NULL;
-               }
-               pstClassifierEntry->pstPhsRule = pstAddPhsRule;
-       }
-
-       pstClassifierEntry->bUsed = TRUE;
-       pstClassifierEntry->u8PHSI = pstClassifierEntry->pstPhsRule->u8PHSI;
-       pstClassifierEntry->uiClassifierRuleId = uiClsId;
-       pstClassifierEntry->pstPhsRule->u8RefCnt++;
-       pstClassifierEntry->bUnclassifiedPHSRule =
-               pstClassifierEntry->pstPhsRule->bUnclassifiedPHSRule;
-
-       return PHS_SUCCESS;
-}
-
-static bool DerefPhsRule(IN B_UINT16  uiClsId,
-                        struct bcm_phs_classifier_table *psaClassifiertable,
-                        struct bcm_phs_rule *pstPhsRule)
-{
-       if (pstPhsRule == NULL)
-               return false;
-
-       if (pstPhsRule->u8RefCnt)
-               pstPhsRule->u8RefCnt--;
-
-       return (0 == pstPhsRule->u8RefCnt);
-}
-
-static void dbg_print_st_cls_entry(struct bcm_mini_adapter *ad,
-                                  struct bcm_phs_entry *st_serv_flow_entry,
-                                  struct bcm_phs_classifier_entry *st_cls_entry)
-{
-       int k;
-
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n VCID  : %#X", st_serv_flow_entry->uiVcid);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n ClassifierID  : %#X", st_cls_entry->uiClassifierRuleId);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSRuleID  : %#X", st_cls_entry->u8PHSI);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n****************PHS Rule********************\n");
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSI  : %#X", st_cls_entry->pstPhsRule->u8PHSI);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSFLength : %#X ", st_cls_entry->pstPhsRule->u8PHSFLength);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSF : ");
-
-       for (k = 0 ; k < st_cls_entry->pstPhsRule->u8PHSFLength; k++)
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X  ", st_cls_entry->pstPhsRule->u8PHSF[k]);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSMLength  : %#X", st_cls_entry->pstPhsRule->u8PHSMLength);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSM :");
-
-       for (k = 0; k < st_cls_entry->pstPhsRule->u8PHSMLength; k++)
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X  ", st_cls_entry->pstPhsRule->u8PHSM[k]);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSS : %#X ", st_cls_entry->pstPhsRule->u8PHSS);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSV  : %#X", st_cls_entry->pstPhsRule->u8PHSV);
-       BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n********************************************\n");
-}
-
-static void phsrules_per_sf_dbg_print(struct bcm_mini_adapter *ad,
-                                     struct bcm_phs_entry *st_serv_flow_entry)
-{
-       int j, l;
-       struct bcm_phs_classifier_entry st_cls_entry;
-
-       for (j = 0; j < MAX_PHSRULE_PER_SF; j++) {
-
-               for (l = 0; l < 2; l++) {
-
-                       if (l == 0) {
-                               st_cls_entry = st_serv_flow_entry->pstClassifierTable->stActivePhsRulesList[j];
-                               if (st_cls_entry.bUsed)
-                                       BCM_DEBUG_PRINT(ad,
-                                                       DBG_TYPE_OTHERS,
-                                                       DUMP_INFO,
-                                                       (DBG_LVL_ALL | DBG_NO_FUNC_PRINT),
-                                                       "\n Active PHS Rule :\n");
-                       } else {
-                               st_cls_entry = st_serv_flow_entry->pstClassifierTable->stOldPhsRulesList[j];
-                               if (st_cls_entry.bUsed)
-                                       BCM_DEBUG_PRINT(ad,
-                                                       DBG_TYPE_OTHERS,
-                                                       DUMP_INFO,
-                                                       (DBG_LVL_ALL | DBG_NO_FUNC_PRINT),
-                                                       "\n Old PHS Rule :\n");
-                       }
-
-                       if (st_cls_entry.bUsed) {
-                               dbg_print_st_cls_entry(ad,
-                                                      st_serv_flow_entry,
-                                                      &st_cls_entry);
-                       }
-               }
-       }
-}
-
-void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension)
-{
-       int i;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,
-                       "\n Dumping PHS Rules :\n");
-
-       for (i = 0; i < MAX_SERVICEFLOWS; i++) {
-
-               struct bcm_phs_entry stServFlowEntry =
-                       pDeviceExtension->pstServiceFlowPhsRulesTable->stSFList[i];
-
-               if (!stServFlowEntry.bUsed)
-                       continue;
-
-               phsrules_per_sf_dbg_print(Adapter, &stServFlowEntry);
-       }
-}
-
-/*
- * Procedure:   phs_decompress
- *
- * Description: This routine restores the static fields within the packet.
- *
- * Arguments:
- *     in_buf                  - ptr to incoming packet buffer.
- *     out_buf                 - ptr to output buffer where the suppressed
- *                               header is copied.
- *     decomp_phs_rules        - ptr to PHS rule.
- *     header_size             - ptr to field which holds the phss or
- *                               phsf_length.
- *
- * Returns:
- *     size    - The number of bytes of dynamic fields present with in the
- *               incoming packet header.
- *     0       - If PHS rule is NULL.If PHSI is 0 indicateing packet as
- *               uncompressed.
- */
-static int phs_decompress(unsigned char *in_buf,
-                         unsigned char *out_buf,
-                         struct bcm_phs_rule *decomp_phs_rules,
-                         UINT *header_size)
-{
-       int phss, size = 0;
-       struct bcm_phs_rule *tmp_memb;
-       int bit, i = 0;
-       unsigned char *phsf, *phsm;
-       int in_buf_len = *header_size - 1;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       in_buf++;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL,
-                       "====>\n");
-       *header_size = 0;
-
-       if (decomp_phs_rules == NULL)
-               return 0;
-
-       tmp_memb = decomp_phs_rules;
-       /*
-        * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,
-        * "\nDECOMP:In phs_decompress PHSI 1  %d",phsi));
-        * header_size = tmp_memb->u8PHSFLength;
-        */
-       phss = tmp_memb->u8PHSS;
-       phsf = tmp_memb->u8PHSF;
-       phsm = tmp_memb->u8PHSM;
-
-       if (phss > MAX_PHS_LENGTHS)
-               phss = MAX_PHS_LENGTHS;
-
-       /*
-        * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,
-        * "\nDECOMP:
-        * In phs_decompress PHSI  %d phss %d index %d",phsi,phss,index));
-        */
-       while ((phss > 0) && (size < in_buf_len)) {
-               bit = ((*phsm << i) & SUPPRESS);
-
-               if (bit == SUPPRESS) {
-                       *out_buf = *phsf;
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE,
-                                       DBG_LVL_ALL,
-                                       "\nDECOMP:In phss  %d phsf %d output %d",
-                                       phss, *phsf, *out_buf);
-               } else {
-                       *out_buf = *in_buf;
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE,
-                                       DBG_LVL_ALL,
-                                       "\nDECOMP:In phss  %d input %d output %d",
-                                       phss, *in_buf, *out_buf);
-                       in_buf++;
-                       size++;
-               }
-               out_buf++;
-               phsf++;
-               phss--;
-               i++;
-               *header_size = *header_size + 1;
-
-               if (i > MAX_NO_BIT) {
-                       i = 0;
-                       phsm++;
-               }
-       }
-
-       return size;
-}
-
-/*
- * Procedure:   phs_compress
- *
- * Description: This routine suppresses the static fields within the packet.
- * Before that it will verify the fields to be suppressed with the corresponding
- * fields in the phsf. For verification it checks the phsv field of PHS rule.
- * If set and verification succeeds it suppresses the field.If any one static
- * field is found different none of the static fields are suppressed then the
- * packet is sent as uncompressed packet with phsi=0.
- *
- * Arguments:
- *     phs_rule - ptr to PHS rule.
- *     in_buf          - ptr to incoming packet buffer.
- *     out_buf         - ptr to output buffer where the suppressed header is
- *                       copied.
- *     header_size     - ptr to field which holds the phss.
- *
- * Returns:
- *     size    - The number of bytes copied into the output buffer i.e
- *               dynamic fields
- *     0       - If PHS rule is NULL.If PHSV field is not set. If the
- *               verification fails.
- */
-static int phs_compress(struct bcm_phs_rule *phs_rule,
-                       unsigned char *in_buf,
-                       unsigned char *out_buf,
-                       UINT *header_size,
-                       UINT *new_header_size)
-{
-       unsigned char *old_addr = out_buf;
-       int suppress = 0;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       if (phs_rule == NULL) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
-                               "\nphs_compress(): phs_rule null!");
-               *out_buf = ZERO_PHSI;
-               return STATUS_PHS_NOCOMPRESSION;
-       }
-
-       if (phs_rule->u8PHSS <= *new_header_size)
-               *header_size = phs_rule->u8PHSS;
-       else
-               *header_size = *new_header_size;
-
-       /* To copy PHSI */
-       out_buf++;
-       suppress = verify_suppress_phsf(in_buf, out_buf, phs_rule->u8PHSF,
-                                       phs_rule->u8PHSM, phs_rule->u8PHSS,
-                                       phs_rule->u8PHSV, new_header_size);
-
-       if (suppress == STATUS_PHS_COMPRESSED) {
-               *old_addr = (unsigned char)phs_rule->u8PHSI;
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
-                               "\nCOMP:In phs_compress phsi %d",
-                               phs_rule->u8PHSI);
-       } else {
-               *old_addr = ZERO_PHSI;
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
-                               "\nCOMP:In phs_compress PHSV Verification failed");
-       }
-
-       return suppress;
-}
-
-/*
- * Procedure:  verify_suppress_phsf
- *
- * Description: This routine verifies the fields of the packet and if all the
- * static fields are equal it adds the phsi of that PHS rule.If any static
- * field differs it woun't suppress any field.
- *
- * Arguments:
- * rules_set   - ptr to classifier_rules.
- * in_buffer   - ptr to incoming packet buffer.
- * out_buffer  - ptr to output buffer where the suppressed header is copied.
- * phsf                - ptr to phsf.
- * phsm                - ptr to phsm.
- * phss                - variable holding phss.
- *
- * Returns:
- *     size    - The number of bytes copied into the output buffer i.e dynamic
- *               fields.
- *     0       - Packet has failed the verification.
- */
-static int verify_suppress_phsf(unsigned char *in_buffer,
-                               unsigned char *out_buffer,
-                               unsigned char *phsf,
-                               unsigned char *phsm,
-                               unsigned int phss,
-                               unsigned int phsv,
-                               UINT *new_header_size)
-{
-       unsigned int size = 0;
-       int bit, i = 0;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
-                       "\nCOMP:In verify_phsf PHSM - 0x%X", *phsm);
-
-       if (phss > (*new_header_size))
-               phss = *new_header_size;
-
-       while (phss > 0) {
-               bit = ((*phsm << i) & SUPPRESS);
-               if (bit == SUPPRESS) {
-                       if (*in_buffer != *phsf) {
-                               if (phsv == VERIFY) {
-                                       BCM_DEBUG_PRINT(Adapter,
-                                                       DBG_TYPE_OTHERS,
-                                                       PHS_SEND,
-                                                       DBG_LVL_ALL,
-                                                       "\nCOMP:In verify_phsf failed for field  %d buf  %d phsf %d",
-                                                       phss,
-                                                       *in_buffer,
-                                                       *phsf);
-                                       return STATUS_PHS_NOCOMPRESSION;
-                               }
-                       } else
-                               BCM_DEBUG_PRINT(Adapter,
-                                               DBG_TYPE_OTHERS,
-                                               PHS_SEND,
-                                               DBG_LVL_ALL,
-                                               "\nCOMP:In verify_phsf success for field  %d buf  %d phsf %d",
-                                               phss,
-                                               *in_buffer,
-                                               *phsf);
-               } else {
-                       *out_buffer = *in_buffer;
-                       BCM_DEBUG_PRINT(Adapter,
-                                       DBG_TYPE_OTHERS,
-                                       PHS_SEND,
-                                       DBG_LVL_ALL,
-                                       "\nCOMP:In copying_header input %d  out %d",
-                                       *in_buffer,
-                                       *out_buffer);
-                       out_buffer++;
-                       size++;
-               }
-
-               in_buffer++;
-               phsf++;
-               phss--;
-               i++;
-
-               if (i > MAX_NO_BIT) {
-                       i = 0;
-                       phsm++;
-               }
-       }
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
-                       "\nCOMP:In verify_phsf success");
-       *new_header_size = size;
-       return STATUS_PHS_COMPRESSED;
-}
diff --git a/drivers/staging/bcm/PHSModule.h b/drivers/staging/bcm/PHSModule.h
deleted file mode 100644 (file)
index d84d60b..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef BCM_MINIPORT_PHSMODULE_H
-#define BCM_MINIPORT_PHSMODULE_H
-
-int PHSTransmit(struct bcm_mini_adapter *Adapter,
-                                       struct sk_buff **pPacket,
-                                        USHORT Vcid,
-                                        B_UINT16 uiClassifierRuleID,
-                                        bool bHeaderSuppressionEnabled,
-                                        PUINT PacketLen,
-                                        UCHAR bEthCSSupport);
-
-int PHSReceive(struct bcm_mini_adapter *Adapter,
-                                       USHORT usVcid,
-                                       struct sk_buff *packet,
-                                       UINT *punPacketLen,
-                                       UCHAR *pucEthernetHdr,
-                                       UINT
-                                       );
-
-
-void DumpDataPacketHeader(PUCHAR pPkt);
-
-void DumpFullPacket(UCHAR *pBuf, UINT nPktLen);
-
-void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension);
-
-
-int phs_init(struct bcm_phs_extension *pPhsdeviceExtension,
-            struct bcm_mini_adapter *Adapter);
-
-int PhsCleanup(struct bcm_phs_extension *pPHSDeviceExt);
-
-/* Utility Functions */
-ULONG PhsUpdateClassifierRule(void *pvContext,
-                             B_UINT16 uiVcid,
-                             B_UINT16 uiClsId,
-                             struct bcm_phs_rule *psPhsRule,
-                             B_UINT8  u8AssociatedPHSI);
-
-ULONG PhsDeletePHSRule(void *pvContext, B_UINT16 uiVcid, B_UINT8 u8PHSI);
-
-ULONG PhsDeleteClassifierRule(void *pvContext,
-                             B_UINT16 uiVcid,
-                             B_UINT16  uiClsId);
-
-ULONG PhsDeleteSFRules(void *pvContext, B_UINT16 uiVcid);
-
-
-bool ValidatePHSRule(struct bcm_phs_rule *psPhsRule);
-
-UINT GetServiceFlowEntry(struct bcm_phs_table *psServiceFlowTable,
-                        B_UINT16 uiVcid,
-                        struct bcm_phs_entry **ppstServiceFlowEntry);
-
-
-void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension);
-
-
-#endif
diff --git a/drivers/staging/bcm/Protocol.h b/drivers/staging/bcm/Protocol.h
deleted file mode 100644 (file)
index 9818128..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/************************************
-*      Protocol.h
-*************************************/
-#ifndef        __PROTOCOL_H__
-#define        __PROTOCOL_H__
-
-#define IPV4 4
-#define IPV6 6
-
-struct ArpHeader {
-       struct arphdr arp;
-       unsigned char ar_sha[ETH_ALEN]; /* sender hardware address  */
-       unsigned char ar_sip[4];        /* sender IP address        */
-       unsigned char ar_tha[ETH_ALEN]; /* target hardware address  */
-       unsigned char ar_tip[4];        /* target IP address        */
-};
-
-struct bcm_transport_header {
-       union {
-               struct udphdr uhdr;
-               struct tcphdr thdr;
-       };
-} __packed;
-
-enum bcm_ip_frame_type {
-       eNonIPPacket,
-       eIPv4Packet,
-       eIPv6Packet
-};
-
-enum bcm_eth_frame_type {
-       eEthUnsupportedFrame,
-       eEth802LLCFrame,
-       eEth802LLCSNAPFrame,
-       eEth802QVLANFrame,
-       eEthOtherFrame
-};
-
-struct bcm_eth_packet_info {
-       enum bcm_ip_frame_type  eNwpktIPFrameType;
-       enum bcm_eth_frame_type eNwpktEthFrameType;
-       unsigned short  usEtherType;
-       unsigned char   ucDSAP;
-};
-
-struct bcm_eth_q_frame {
-       struct bcm_eth_header EThHdr;
-       unsigned short UserPriority:3;
-       unsigned short CFI:1;
-       unsigned short VLANID:12;
-       unsigned short EthType;
-} __packed;
-
-struct bcm_eth_llc_frame {
-       struct bcm_eth_header EThHdr;
-       unsigned char DSAP;
-       unsigned char SSAP;
-       unsigned char Control;
-} __packed;
-
-struct bcm_eth_llc_snap_frame {
-       struct bcm_eth_header EThHdr;
-       unsigned char DSAP;
-       unsigned char SSAP;
-       unsigned char Control;
-       unsigned char OUI[3];
-       unsigned short usEtherType;
-} __packed;
-
-struct bcm_ethernet2_frame {
-       struct bcm_eth_header EThHdr;
-} __packed;
-
-#define ETHERNET_FRAMETYPE_IPV4                ntohs(0x0800)
-#define ETHERNET_FRAMETYPE_IPV6                ntohs(0x86dd)
-#define ETHERNET_FRAMETYPE_802QVLAN    ntohs(0x8100)
-
-/* Per SF CS Specification Encodings */
-enum bcm_spec_encoding {
-       eCSSpecUnspecified = 0,
-       eCSPacketIPV4,
-       eCSPacketIPV6,
-       eCS802_3PacketEthernet,
-       eCS802_1QPacketVLAN,
-       eCSPacketIPV4Over802_3Ethernet,
-       eCSPacketIPV6Over802_3Ethernet,
-       eCSPacketIPV4Over802_1QVLAN,
-       eCSPacketIPV6Over802_1QVLAN,
-       eCSPacketUnsupported
-};
-
-#define        IP6_HEADER_LEN          40
-#define IP_VERSION(byte)       (((byte&0xF0)>>4))
-
-#define MAC_ADDRESS_SIZE       6
-#define        ETH_AND_IP_HEADER_LEN   (14 + 20)
-#define L4_SRC_PORT_LEN                2
-#define L4_DEST_PORT_LEN       2
-#define        CTRL_PKT_LEN            (8 + ETH_AND_IP_HEADER_LEN)
-
-#define        ETH_ARP_FRAME           0x806
-#define        ETH_IPV4_FRAME          0x800
-#define        ETH_IPV6_FRAME          0x86DD
-#define UDP                    0x11
-#define TCP                    0x06
-
-#define        ARP_OP_REQUEST          0x01
-#define        ARP_OP_REPLY            0x02
-#define        ARP_PKT_SIZE            60
-
-/* This is the format for the TCP packet header */
-struct bcm_tcp_header {
-       unsigned short usSrcPort;
-       unsigned short usDestPort;
-       unsigned long  ulSeqNumber;
-       unsigned long  ulAckNumber;
-       unsigned char  HeaderLength;
-       unsigned char  ucFlags;
-       unsigned short usWindowsSize;
-       unsigned short usChkSum;
-       unsigned short usUrgetPtr;
-};
-
-#define TCP_HEADER_LEN         sizeof(struct bcm_tcp_header)
-#define TCP_ACK                        0x10  /* Bit 4 in tcpflags field. */
-#define GET_TCP_HEADER_LEN(byte) ((byte&0xF0)>>4)
-
-#endif /* __PROTOCOL_H__ */
diff --git a/drivers/staging/bcm/Prototypes.h b/drivers/staging/bcm/Prototypes.h
deleted file mode 100644 (file)
index 1ddc8b2..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-#ifndef _PROTOTYPES_H_
-#define _PROTOTYPES_H_
-
-VOID LinkControlResponseMessage(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer);
-
-VOID StatisticsResponse(struct bcm_mini_adapter *Adapter, PVOID pvBuffer);
-
-VOID IdleModeResponse(struct bcm_mini_adapter *Adapter, PUINT puiBuffer);
-
-int control_packet_handler(struct bcm_mini_adapter *Adapter);
-
-VOID DeleteAllClassifiersForSF(struct bcm_mini_adapter *Adapter, UINT uiSearchRuleIndex);
-
-VOID flush_all_queues(struct bcm_mini_adapter *Adapter);
-
-int register_control_device_interface(struct bcm_mini_adapter *ps_adapter);
-
-void unregister_control_device_interface(struct bcm_mini_adapter *Adapter);
-
-INT CopyBufferToControlPacket(struct bcm_mini_adapter *Adapter,/**<Logical Adapter*/
-                                                                         PVOID ioBuffer/**<Control Packet Buffer*/
-                                                                         );
-
-VOID SortPackInfo(struct bcm_mini_adapter *Adapter);
-
-VOID SortClassifiers(struct bcm_mini_adapter *Adapter);
-
-VOID flush_all_queues(struct bcm_mini_adapter *Adapter);
-
-VOID PruneQueueAllSF(struct bcm_mini_adapter *Adapter);
-
-INT SearchSfid(struct bcm_mini_adapter *Adapter, UINT uiSfid);
-
-USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff *skb);
-
-bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule, USHORT ushSrcPort);
-
-bool MatchDestPort(struct bcm_classifier_rule *pstClassifierRule, USHORT ushSrcPort);
-
-bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule, UCHAR ucProtocol);
-
-INT SetupNextSend(struct bcm_mini_adapter *Adapter, /**<Logical Adapter*/
-                                       struct sk_buff *Packet, /**<data buffer*/
-                                       USHORT Vcid);
-
-VOID LinkMessage(struct bcm_mini_adapter *Adapter);
-
-VOID transmit_packets(struct bcm_mini_adapter *Adapter);
-
-INT SendControlPacket(struct bcm_mini_adapter *Adapter, /**<Logical Adapter*/
-                                                       char *pControlPacket/**<Control Packet*/
-                                                       );
-
-int register_networkdev(struct bcm_mini_adapter *Adapter);
-
-void unregister_networkdev(struct bcm_mini_adapter *Adapter);
-
-INT AllocAdapterDsxBuffer(struct bcm_mini_adapter *Adapter);
-
-VOID AdapterFree(struct bcm_mini_adapter *Adapter);
-
-INT FreeAdapterDsxBuffer(struct bcm_mini_adapter *Adapter);
-
-int tx_pkt_handler(struct bcm_mini_adapter *Adapter);
-
-int reset_card_proc(struct bcm_mini_adapter *Adapter);
-
-int run_card_proc(struct bcm_mini_adapter *Adapter);
-
-int InitCardAndDownloadFirmware(struct bcm_mini_adapter *ps_adapter);
-
-INT ReadMacAddressFromNVM(struct bcm_mini_adapter *Adapter);
-
-int register_control_device_interface(struct bcm_mini_adapter *ps_adapter);
-
-void DumpPackInfo(struct bcm_mini_adapter *Adapter);
-
-int rdm(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t size);
-
-int wrm(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t size);
-
-int wrmalt(struct bcm_mini_adapter *Adapter, UINT uiAddress, unsigned int *pucBuff, size_t sSize);
-
-int rdmalt(struct bcm_mini_adapter *Adapter, UINT uiAddress, unsigned int *pucBuff, size_t sSize);
-
-int get_dsx_sf_data_to_application(struct bcm_mini_adapter *Adapter, UINT uiSFId, void __user *user_buffer);
-
-void SendIdleModeResponse(struct bcm_mini_adapter *Adapter);
-
-int ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_mibs *buf);
-
-void GetDroppedAppCntrlPktMibs(struct bcm_host_stats_mibs *ioBuffer, struct bcm_tarang_data *pTarang);
-
-void beceem_parse_target_struct(struct bcm_mini_adapter *Adapter);
-
-int bcm_ioctl_fw_download(struct bcm_mini_adapter *Adapter, struct bcm_firmware_info *psFwInfo);
-
-void CopyMIBSExtendedSFParameters(struct bcm_mini_adapter *Adapter,
-               struct bcm_connect_mgr_params *psfLocalSet, UINT uiSearchRuleIndex);
-
-VOID ResetCounters(struct bcm_mini_adapter *Adapter);
-
-int InitLedSettings(struct bcm_mini_adapter *Adapter);
-
-struct bcm_classifier_rule *GetFragIPClsEntry(struct bcm_mini_adapter *Adapter, USHORT usIpIdentification, ULONG SrcIP);
-
-void AddFragIPClsEntry(struct bcm_mini_adapter *Adapter, struct bcm_fragmented_packet_info *psFragPktInfo);
-
-void DelFragIPClsEntry(struct bcm_mini_adapter *Adapter, USHORT usIpIdentification, ULONG SrcIp);
-
-void update_per_cid_rx(struct bcm_mini_adapter *Adapter);
-
-void update_per_sf_desc_cnts(struct bcm_mini_adapter *Adapter);
-
-void ClearTargetDSXBuffer(struct bcm_mini_adapter *Adapter, B_UINT16 TID, bool bFreeAll);
-
-void flush_queue(struct bcm_mini_adapter *Adapter, UINT iQIndex);
-
-INT flushAllAppQ(VOID);
-
-INT BeceemEEPROMBulkRead(
-       struct bcm_mini_adapter *Adapter,
-       PUINT pBuffer,
-       UINT uiOffset,
-       UINT uiNumBytes);
-
-INT WriteBeceemEEPROM(struct bcm_mini_adapter *Adapter, UINT uiEEPROMOffset, UINT uiData);
-
-INT PropagateCalParamsFromFlashToMemory(struct bcm_mini_adapter *Adapter);
-
-INT BeceemEEPROMBulkWrite(
-       struct bcm_mini_adapter *Adapter,
-       PUCHAR pBuffer,
-       UINT uiOffset,
-       UINT uiNumBytes,
-       bool bVerify);
-
-INT ReadBeceemEEPROM(struct bcm_mini_adapter *Adapter, UINT dwAddress, UINT *pdwData);
-
-INT BeceemNVMRead(
-       struct bcm_mini_adapter *Adapter,
-       PUINT pBuffer,
-       UINT uiOffset,
-       UINT uiNumBytes);
-
-INT BeceemNVMWrite(
-       struct bcm_mini_adapter *Adapter,
-       PUINT pBuffer,
-       UINT uiOffset,
-       UINT uiNumBytes,
-       bool bVerify);
-
-INT BcmInitNVM(struct bcm_mini_adapter *Adapter);
-
-INT BcmUpdateSectorSize(struct bcm_mini_adapter *Adapter, UINT uiSectorSize);
-
-bool IsSectionExistInFlash(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val section);
-
-INT BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_bitmap *psFlash2xBitMap);
-
-INT BcmFlash2xBulkWrite(
-       struct bcm_mini_adapter *Adapter,
-       PUINT pBuffer,
-       enum bcm_flash2x_section_val eFlashSectionVal,
-       UINT uiOffset,
-       UINT uiNumBytes,
-       UINT bVerify);
-
-INT BcmFlash2xBulkRead(
-       struct bcm_mini_adapter *Adapter,
-       PUINT pBuffer,
-       enum bcm_flash2x_section_val eFlashSectionVal,
-       UINT uiOffsetWithinSectionVal,
-       UINT uiNumBytes);
-
-INT BcmGetSectionValStartOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlashSectionVal);
-
-INT BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectVal);
-
-INT BcmAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter);
-
-INT BcmDeAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter);
-
-INT BcmCopyISO(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_copy_section sCopySectStrut);
-
-INT BcmFlash2xCorruptSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal);
-
-INT BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlashSectionVal);
-
-INT validateFlash2xReadWrite(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_readwrite *psFlash2xReadWrite);
-
-INT IsFlash2x(struct bcm_mini_adapter *Adapter);
-
-INT BcmCopySection(struct bcm_mini_adapter *Adapter,
-                                               enum bcm_flash2x_section_val SrcSection,
-                                               enum bcm_flash2x_section_val DstSection,
-                                               UINT offset,
-                                               UINT numOfBytes);
-
-bool IsNonCDLessDevice(struct bcm_mini_adapter *Adapter);
-
-VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, PUINT puiBuffer);
-
-int wrmaltWithLock(struct bcm_mini_adapter *Adapter, UINT uiAddress, unsigned int *pucBuff, size_t sSize);
-
-int rdmaltWithLock(struct bcm_mini_adapter *Adapter, UINT uiAddress, unsigned int *pucBuff, size_t sSize);
-
-int wrmWithLock(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t size);
-
-INT buffDnldVerify(struct bcm_mini_adapter *Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength,
-               unsigned long u32StartingAddress);
-
-VOID putUsbSuspend(struct work_struct *work);
-
-bool IsReqGpioIsLedInNVM(struct bcm_mini_adapter *Adapter, UINT gpios);
-
-#endif
diff --git a/drivers/staging/bcm/Qos.c b/drivers/staging/bcm/Qos.c
deleted file mode 100644 (file)
index b3ac614..0000000
+++ /dev/null
@@ -1,1200 +0,0 @@
-/**
- * @file Qos.C
- * 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 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);
-
-
-/*******************************************************************
-* Function    - MatchSrcIpAddress()
-*
-* Description - Checks whether the Source IP address from the packet
-*                              matches with that of Queue.
-*
-* Parameters  - pstClassifierRule: Pointer to the packet info structure.
-*              - ulSrcIP           : Source IP address from the packet.
-*
-* Returns     - TRUE(If address matches) else FAIL .
-*********************************************************************/
-static bool MatchSrcIpAddress(struct bcm_classifier_rule *pstClassifierRule,
-                             ULONG ulSrcIP)
-{
-       UCHAR ucLoopIndex = 0;
-
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-       union u_ip_address      *src_addr;
-
-       ulSrcIP = ntohl(ulSrcIP);
-       if (0 == pstClassifierRule->ucIPSourceAddressLength)
-               return TRUE;
-       for (ucLoopIndex = 0;
-            ucLoopIndex < (pstClassifierRule->ucIPSourceAddressLength);
-            ucLoopIndex++) {
-               src_addr = &pstClassifierRule->stSrcIpAddress;
-               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)src_addr->ulIpv4Mask[ucLoopIndex],
-                               (UINT)ulSrcIP,
-                               (UINT)src_addr->ulIpv6Addr[ucLoopIndex]);
-
-               if ((src_addr->ulIpv4Mask[ucLoopIndex] & ulSrcIP) ==
-                               (src_addr->ulIpv4Addr[ucLoopIndex] &
-                                src_addr->ulIpv4Mask[ucLoopIndex]))
-                       return TRUE;
-       }
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "Src Ip Address Not Matched");
-       return false;
-}
-
-
-/*******************************************************************
-* Function    - MatchDestIpAddress()
-*
-* Description - Checks whether the Destination IP address from the packet
-*                              matches with that of Queue.
-*
-* Parameters  - pstClassifierRule: Pointer to the packet info structure.
-*              - ulDestIP    : Destination IP address from the packet.
-*
-* Returns     - TRUE(If address matches) else FAIL .
-*********************************************************************/
-static bool MatchDestIpAddress(struct bcm_classifier_rule *pstClassifierRule, ULONG ulDestIP)
-{
-       UCHAR ucLoopIndex = 0;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-       union u_ip_address      *dest_addr = &pstClassifierRule->stDestIpAddress;
-
-       ulDestIP = ntohl(ulDestIP);
-       if (0 == pstClassifierRule->ucIPDestinationAddressLength)
-               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)dest_addr->ulIpv4Mask[ucLoopIndex],
-                       (UINT)dest_addr->ulIpv4Addr[ucLoopIndex]);
-
-       for (ucLoopIndex = 0;
-            ucLoopIndex < (pstClassifierRule->ucIPDestinationAddressLength);
-            ucLoopIndex++) {
-               if ((dest_addr->ulIpv4Mask[ucLoopIndex] & ulDestIP) ==
-                               (dest_addr->ulIpv4Addr[ucLoopIndex] &
-                                dest_addr->ulIpv4Mask[ucLoopIndex]))
-                       return TRUE;
-       }
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "Destination Ip Address Not Matched");
-       return false;
-}
-
-
-/************************************************************************
-* Function    - MatchTos()
-*
-* Description - Checks the TOS from the packet matches with that of queue.
-*
-* Parameters  - pstClassifierRule   : Pointer to the packet info structure.
-*              - ucTypeOfService: TOS from the packet.
-*
-* Returns     - TRUE(If address matches) else FAIL.
-**************************************************************************/
-static bool MatchTos(struct bcm_classifier_rule *pstClassifierRule,
-                    UCHAR ucTypeOfService)
-{
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       if (3 != pstClassifierRule->ucIPTypeOfServiceLength)
-               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;
-}
-
-
-/***************************************************************************
-* Function    - MatchProtocol()
-*
-* Description - Checks the protocol from the packet matches with that of queue.
-*
-* Parameters  - pstClassifierRule: Pointer to the packet info structure.
-*              - ucProtocol    : Protocol from the packet.
-*
-* Returns     - TRUE(If address matches) else FAIL.
-****************************************************************************/
-bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,
-                  UCHAR ucProtocol)
-{
-       UCHAR ucLoopIndex = 0;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       if (0 == pstClassifierRule->ucProtocolLength)
-               return TRUE;
-       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;
-}
-
-
-/***********************************************************************
-* Function    - MatchSrcPort()
-*
-* Description - Checks, Source port from the packet matches with that of queue.
-*
-* Parameters  - pstClassifierRule: Pointer to the packet info structure.
-*              - ushSrcPort    : Source port from the packet.
-*
-* Returns     - TRUE(If address matches) else FAIL.
-***************************************************************************/
-bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,
-                 USHORT ushSrcPort)
-{
-       UCHAR ucLoopIndex = 0;
-
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-
-       if (0 == pstClassifierRule->ucSrcPortRangeLength)
-               return TRUE;
-       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;
-}
-
-
-/***********************************************************************
-* Function    - MatchDestPort()
-*
-* Description - Checks, Destination port from packet matches with that of queue.
-*
-* Parameters  - pstClassifierRule: Pointer to the packet info structure.
-*              - ushDestPort   : Destination port from the packet.
-*
-* Returns     - TRUE(If address matches) else FAIL.
-***************************************************************************/
-bool MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,
-                  USHORT ushDestPort)
-{
-       UCHAR ucLoopIndex = 0;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       if (0 == pstClassifierRule->ucDestPortRangeLength)
-               return TRUE;
-
-       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;
-}
-/**
- * @ingroup tx_functions
- * Compares IPV4 Ip address and port number
- * @return Queue Index.
-*/
-static USHORT  IpVersion4(struct bcm_mini_adapter *Adapter,
-                          struct iphdr *iphd,
-                          struct bcm_classifier_rule *pstClassifierRule)
-{
-       struct bcm_transport_header *xprt_hdr = NULL;
-       bool    bClassificationSucceed = false;
-
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "========>");
-
-       xprt_hdr = (struct bcm_transport_header *)((PUCHAR)iphd + sizeof(struct iphdr));
-
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "Trying to see Direction = %d %d",
-                       pstClassifierRule->ucDirection,
-                       pstClassifierRule->usVCID_Value);
-
-       /* Checking classifier validity */
-       if (!pstClassifierRule->bUsed ||
-                       pstClassifierRule->ucDirection == DOWNLINK_DIR)
-               goto out;
-
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "is IPv6 check!");
-       if (pstClassifierRule->bIpv6Protocol)
-               goto out;
-
-       /* Checking IP header parameter */
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "Trying to match Source IP Address");
-       if (!MatchSrcIpAddress(pstClassifierRule, iphd->saddr))
-               goto out;
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "Source IP Address Matched");
-
-       if (!MatchDestIpAddress(pstClassifierRule, iphd->daddr))
-               goto out;
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "Destination IP Address Matched");
-
-       if (!MatchTos(pstClassifierRule, iphd->tos)) {
-               BCM_DEBUG_PRINT(Adapter,
-                               DBG_TYPE_TX,
-                               IPV4_DBG,
-                               DBG_LVL_ALL,
-                               "TOS Match failed\n");
-               goto out;
-       }
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "TOS Matched");
-
-       if (!MatchProtocol(pstClassifierRule, iphd->protocol))
-               goto out;
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "Protocol Matched");
-
-       /*
-        * if protocol is not TCP or UDP then no
-        * need of comparing source port and destination port
-        */
-       if (iphd->protocol != TCP && iphd->protocol != UDP) {
-               bClassificationSucceed = TRUE;
-               goto out;
-       }
-       /* Checking Transport Layer Header field if present */
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "Source Port %04x",
-                       (iphd->protocol == UDP) ? xprt_hdr->uhdr.source : xprt_hdr->thdr.source);
-
-       if (!MatchSrcPort(pstClassifierRule,
-                         ntohs((iphd->protocol == UDP) ?
-                         xprt_hdr->uhdr.source : xprt_hdr->thdr.source)))
-               goto out;
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "Src Port Matched");
-
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "Destination Port %04x",
-                       (iphd->protocol == UDP) ? xprt_hdr->uhdr.dest :
-                               xprt_hdr->thdr.dest);
-
-       if (!MatchDestPort(pstClassifierRule,
-                          ntohs((iphd->protocol == UDP) ?
-                          xprt_hdr->uhdr.dest : xprt_hdr->thdr.dest)))
-               goto out;
-       bClassificationSucceed = TRUE;
-
-out:
-       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;
-       }
-
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "IpVersion4 <==========");
-
-       return bClassificationSucceed;
-}
-
-VOID PruneQueueAllSF(struct bcm_mini_adapter *Adapter)
-{
-       UINT iIndex = 0;
-
-       for (iIndex = 0; iIndex < HiPriority; iIndex++) {
-               if (!Adapter->PackInfo[iIndex].bValid)
-                       continue;
-
-               PruneQueue(Adapter, iIndex);
-       }
-}
-
-
-/**
- * @ingroup tx_functions
- * This function checks if the max queue size for a queue
- * is less than number of bytes in the queue. If so -
- * drops packets from the Head till the number of bytes is
- * less than or equal to max queue size for the queue.
- */
-static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex)
-{
-       struct sk_buff *PacketToDrop = NULL;
-       struct net_device_stats *netstats;
-       struct bcm_packet_info  *curr_pack_info = &Adapter->PackInfo[iIndex];
-
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       PRUNE_QUEUE,
-                       DBG_LVL_ALL,
-                       "=====> Index %d",
-                       iIndex);
-
-       if (iIndex == HiPriority)
-               return;
-
-       if (!Adapter || (iIndex < 0) || (iIndex > HiPriority))
-               return;
-
-       /* To Store the netdevice statistic */
-       netstats = &Adapter->dev->stats;
-
-       spin_lock_bh(&curr_pack_info->SFQueueLock);
-
-       while (1) {
-/*     while((UINT)curr_pack_info->uiCurrentPacketsOnHost >
-               SF_MAX_ALLOWED_PACKETS_TO_BACKUP) { */
-
-               BCM_DEBUG_PRINT(Adapter,
-                               DBG_TYPE_TX,
-                               PRUNE_QUEUE,
-                               DBG_LVL_ALL,
-                               "uiCurrentBytesOnHost:%x uiMaxBucketSize :%x",
-                               curr_pack_info->uiCurrentBytesOnHost,
-                               curr_pack_info->uiMaxBucketSize);
-
-               PacketToDrop = curr_pack_info->FirstTxQueue;
-
-               if (PacketToDrop == NULL)
-                       break;
-               if ((curr_pack_info->uiCurrentPacketsOnHost <
-                                       SF_MAX_ALLOWED_PACKETS_TO_BACKUP) &&
-                       ((1000*(jiffies - *((B_UINT32 *)(PacketToDrop->cb) +
-                                           SKB_CB_LATENCY_OFFSET))/HZ) <=
-                               curr_pack_info->uiMaxLatency))
-                       break;
-
-               if (PacketToDrop) {
-                       if (netif_msg_tx_err(Adapter))
-                               pr_info(PFX "%s: tx queue %d overlimit\n",
-                                       Adapter->dev->name, iIndex);
-
-                       netstats->tx_dropped++;
-
-                       DEQUEUEPACKET(curr_pack_info->FirstTxQueue,
-                                     curr_pack_info->LastTxQueue);
-                       /* update current bytes and packets count */
-                       curr_pack_info->uiCurrentBytesOnHost -=
-                               PacketToDrop->len;
-                       curr_pack_info->uiCurrentPacketsOnHost--;
-                       /* update dropped bytes and packets counts */
-                       curr_pack_info->uiDroppedCountBytes += PacketToDrop->len;
-                       curr_pack_info->uiDroppedCountPackets++;
-                       dev_kfree_skb(PacketToDrop);
-
-               }
-
-               BCM_DEBUG_PRINT(Adapter,
-                               DBG_TYPE_TX,
-                               PRUNE_QUEUE,
-                               DBG_LVL_ALL,
-                               "Dropped Bytes:%x Dropped Packets:%x",
-                               curr_pack_info->uiDroppedCountBytes,
-                               curr_pack_info->uiDroppedCountPackets);
-
-               atomic_dec(&Adapter->TotalPacketCount);
-       }
-
-       spin_unlock_bh(&curr_pack_info->SFQueueLock);
-
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       PRUNE_QUEUE,
-                       DBG_LVL_ALL,
-                       "TotalPacketCount:%x",
-                       atomic_read(&Adapter->TotalPacketCount));
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       PRUNE_QUEUE,
-                       DBG_LVL_ALL,
-                       "<=====");
-}
-
-VOID flush_all_queues(struct bcm_mini_adapter *Adapter)
-{
-       INT     iQIndex;
-       UINT uiTotalPacketLength;
-       struct sk_buff *PacketToDrop = NULL;
-       struct bcm_packet_info *curr_packet_info;
-
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_OTHERS,
-                       DUMP_INFO,
-                       DBG_LVL_ALL,
-                       "=====>");
-
-       /* down(&Adapter->data_packet_queue_lock); */
-       for (iQIndex = LowPriority; iQIndex < HiPriority; iQIndex++) {
-               struct net_device_stats *netstats = &Adapter->dev->stats;
-
-               curr_packet_info = &Adapter->PackInfo[iQIndex];
-
-               spin_lock_bh(&curr_packet_info->SFQueueLock);
-               while (curr_packet_info->FirstTxQueue) {
-                       PacketToDrop = curr_packet_info->FirstTxQueue;
-                       if (PacketToDrop) {
-                               uiTotalPacketLength = PacketToDrop->len;
-                               netstats->tx_dropped++;
-                       } else
-                               uiTotalPacketLength = 0;
-
-                       DEQUEUEPACKET(curr_packet_info->FirstTxQueue,
-                                     curr_packet_info->LastTxQueue);
-
-                       /* Free the skb */
-                       dev_kfree_skb(PacketToDrop);
-
-                       /* update current bytes and packets count */
-                       curr_packet_info->uiCurrentBytesOnHost -= uiTotalPacketLength;
-                       curr_packet_info->uiCurrentPacketsOnHost--;
-
-                       /* update dropped bytes and packets counts */
-                       curr_packet_info->uiDroppedCountBytes += uiTotalPacketLength;
-                       curr_packet_info->uiDroppedCountPackets++;
-
-                       BCM_DEBUG_PRINT(Adapter,
-                                       DBG_TYPE_OTHERS,
-                                       DUMP_INFO,
-                                       DBG_LVL_ALL,
-                                       "Dropped Bytes:%x Dropped Packets:%x",
-                                       curr_packet_info->uiDroppedCountBytes,
-                                       curr_packet_info->uiDroppedCountPackets);
-                       atomic_dec(&Adapter->TotalPacketCount);
-               }
-               spin_unlock_bh(&curr_packet_info->SFQueueLock);
-       }
-       /* up(&Adapter->data_packet_queue_lock); */
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_OTHERS,
-                       DUMP_INFO,
-                       DBG_LVL_ALL,
-                       "<=====");
-}
-
-USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff *skb)
-{
-       INT uiLoopIndex = 0;
-       struct bcm_classifier_rule *pstClassifierRule = NULL;
-       struct bcm_eth_packet_info stEthCsPktInfo;
-       PVOID pvEThPayload = NULL;
-       struct iphdr *pIpHeader = NULL;
-       INT uiSfIndex = 0;
-       USHORT usIndex = Adapter->usBestEffortQueueIndex;
-       bool bFragmentedPkt = false, bClassificationSucceed = false;
-       USHORT usCurrFragment = 0;
-
-       struct bcm_tcp_header *pTcpHeader;
-       UCHAR IpHeaderLength;
-       UCHAR TcpHeaderLength;
-
-       pvEThPayload = skb->data;
-       *((UINT32 *) (skb->cb) + SKB_CB_TCPACK_OFFSET) = 0;
-       EThCSGetPktInfo(Adapter, pvEThPayload, &stEthCsPktInfo);
-
-       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) {
-               usCurrFragment = (ntohs(pIpHeader->frag_off) & IP_OFFSET);
-               if ((ntohs(pIpHeader->frag_off) & IP_MF) || usCurrFragment)
-                       bFragmentedPkt = TRUE;
-
-               if (bFragmentedPkt) {
-                       /* Fragmented  Packet. Get Frag Classifier Entry. */
-                       pstClassifierRule = GetFragIPClsEntry(Adapter,
-                                                             pIpHeader->id,
-                                                             pIpHeader->saddr);
-                       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)) {
-                               /* 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);
-                       }
-               }
-       }
-
-       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
-                */
-               if (false == Adapter->astClassifierTable[uiLoopIndex].bUsed) {
-                       bClassificationSucceed = false;
-                       continue;
-               }
-               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) {
-                       bClassificationSucceed = false; /* cannot be processed for classification. */
-                       continue;       /* it is a down link connection */
-               }
-
-               pstClassifierRule = &Adapter->astClassifierTable[uiLoopIndex];
-
-               uiSfIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID);
-               if (uiSfIndex >= NO_OF_QUEUES) {
-                       BCM_DEBUG_PRINT(Adapter,
-                                       DBG_TYPE_TX,
-                                       IPV4_DBG,
-                                       DBG_LVL_ALL,
-                                       "Queue Not Valid. SearchSfid for this classifier Failed\n");
-                       continue;
-               }
-
-               if (Adapter->PackInfo[uiSfIndex].bEthCSSupport) {
-
-                       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;
-                               continue;
-                       }
-
-
-
-                       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) {
-                               BCM_DEBUG_PRINT(Adapter,
-                                               DBG_TYPE_TX,
-                                               IPV4_DBG,
-                                               DBG_LVL_ALL,
-                                               "ClassifyPacket : Ethernet CS Classification Failed\n");
-                               continue;
-                       }
-               } 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;
-                               continue;
-                       }
-               }
-
-               BCM_DEBUG_PRINT(Adapter,
-                               DBG_TYPE_TX,
-                               IPV4_DBG,
-                               DBG_LVL_ALL,
-                               "Proceeding to IP CS Clasification");
-
-               if (Adapter->PackInfo[uiSfIndex].bIPCSSupport) {
-
-                       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;
-                               continue;
-                       }
-                       BCM_DEBUG_PRINT(Adapter,
-                                       DBG_TYPE_TX,
-                                       IPV4_DBG,
-                                       DBG_LVL_ALL,
-                                       "Dump IP Header :\n");
-                       DumpFullPacket((PUCHAR)pIpHeader, 20);
-
-                       if (stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet)
-                               bClassificationSucceed = IpVersion4(Adapter,
-                                                                   pIpHeader,
-                                                                   pstClassifierRule);
-                       else if (stEthCsPktInfo.eNwpktIPFrameType == eIPv6Packet)
-                               bClassificationSucceed = IpVersion6(Adapter,
-                                                                   pIpHeader,
-                                                                   pstClassifierRule);
-               }
-       }
-
-       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)) {
-                       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)) {
-                       /*
-                        * First Fragment of Fragmented Packet.
-                        * Create Frag CLS Entry
-                        */
-                       struct bcm_fragmented_packet_info stFragPktInfo;
-
-                       stFragPktInfo.bUsed = TRUE;
-                       stFragPktInfo.ulSrcIpAddress = pIpHeader->saddr;
-                       stFragPktInfo.usIpIdentification = pIpHeader->id;
-                       stFragPktInfo.pstMatchedClassifierEntry =
-                               pstClassifierRule;
-                       stFragPktInfo.bOutOfOrderFragment = false;
-                       AddFragIPClsEntry(Adapter, &stFragPktInfo);
-               }
-
-
-       }
-
-       return bClassificationSucceed ? usIndex : INVALID_QUEUE_INDEX;
-}
-
-static bool EthCSMatchSrcMACAddress(struct bcm_classifier_rule *pstClassifierRule,
-                                   PUCHAR Mac)
-{
-       UINT i = 0;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       if (pstClassifierRule->ucEthCSSrcMACLen == 0)
-               return TRUE;
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "%s\n", __func__);
-       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]))
-                       return false;
-       }
-       return TRUE;
-}
-
-static bool EthCSMatchDestMACAddress(struct bcm_classifier_rule *pstClassifierRule,
-                                    PUCHAR Mac)
-{
-       UINT i = 0;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       if (pstClassifierRule->ucEthCSDestMACLen == 0)
-               return TRUE;
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "%s\n",
-                       __func__);
-       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]))
-                       return false;
-       }
-       return TRUE;
-}
-
-static bool EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule,
-                                struct sk_buff *skb,
-                                struct bcm_eth_packet_info *pstEthCsPktInfo)
-{
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       if ((pstClassifierRule->ucEtherTypeLen == 0) ||
-               (pstClassifierRule->au8EthCSEtherType[0] == 0))
-               return TRUE;
-
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "%s SrcEtherType:%x CLS EtherType[0]:%x\n",
-                       __func__,
-                       pstEthCsPktInfo->usEtherType,
-                       pstClassifierRule->au8EthCSEtherType[0]);
-       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",
-                               __func__,
-                               pstClassifierRule->au8EthCSEtherType[1],
-                               pstClassifierRule->au8EthCSEtherType[2]);
-
-               if (memcmp(&pstEthCsPktInfo->usEtherType,
-                          &pstClassifierRule->au8EthCSEtherType[1],
-                          2) == 0)
-                       return TRUE;
-               else
-                       return false;
-       }
-
-       if (pstClassifierRule->au8EthCSEtherType[0] == 2) {
-               if (eEth802LLCFrame != pstEthCsPktInfo->eNwpktEthFrameType)
-                       return false;
-
-               BCM_DEBUG_PRINT(Adapter,
-                               DBG_TYPE_TX,
-                               IPV4_DBG,
-                               DBG_LVL_ALL,
-                               "%s  EthCS DSAP:%x EtherType[2]:%x\n",
-                               __func__,
-                               pstEthCsPktInfo->ucDSAP,
-                               pstClassifierRule->au8EthCSEtherType[2]);
-               if (pstEthCsPktInfo->ucDSAP ==
-                               pstClassifierRule->au8EthCSEtherType[2])
-                       return TRUE;
-               else
-                       return false;
-
-       }
-
-       return false;
-
-}
-
-static bool EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule,
-                               struct sk_buff *skb,
-                               struct bcm_eth_packet_info *pstEthCsPktInfo)
-{
-       bool bClassificationSucceed = false;
-       USHORT usVLANID;
-       B_UINT8 uPriority = 0;
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "%s  CLS UserPrio:%x CLS VLANID:%x\n",
-                       __func__,
-                       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 (pstEthCsPktInfo->eNwpktEthFrameType != eEth802QVLANFrame)
-                               return false;
-
-               uPriority = (ntohs(*(USHORT *)(skb->data +
-                                  sizeof(struct bcm_eth_header))) &
-                                  0xF000) >> 13;
-
-               if ((uPriority >= pstClassifierRule->usUserPriority[0]) &&
-                               (uPriority <=
-                                pstClassifierRule->usUserPriority[1]))
-                       bClassificationSucceed = TRUE;
-
-               if (!bClassificationSucceed)
-                       return false;
-       }
-
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "ETH CS 802.1 D  User Priority Rule Matched\n");
-
-       bClassificationSucceed = false;
-
-       if (pstClassifierRule->usValidityBitMap &
-                       (1<<PKT_CLASSIFICATION_VLANID_VALID)) {
-               if (pstEthCsPktInfo->eNwpktEthFrameType != eEth802QVLANFrame)
-                               return false;
-
-               usVLANID = ntohs(*(USHORT *)(skb->data +
-                                       sizeof(struct bcm_eth_header))) & 0xFFF;
-
-               BCM_DEBUG_PRINT(Adapter,
-                               DBG_TYPE_TX,
-                               IPV4_DBG,
-                               DBG_LVL_ALL,
-                               "%s  Pkt VLANID %x Priority: %d\n",
-                               __func__,
-                               usVLANID,
-                               uPriority);
-
-               if (usVLANID == ((pstClassifierRule->usVLANID & 0xFFF0) >> 4))
-                       bClassificationSucceed = TRUE;
-
-               if (!bClassificationSucceed)
-                       return false;
-       }
-
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "ETH CS 802.1 Q VLAN ID Rule Matched\n");
-
-       return TRUE;
-}
-
-
-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)
-{
-       bool bClassificationSucceed = false;
-
-       bClassificationSucceed = EthCSMatchSrcMACAddress(pstClassifierRule,
-                       ((struct bcm_eth_header *)(skb->data))->au8SourceAddress);
-       if (!bClassificationSucceed)
-               return false;
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "ETH CS SrcMAC Matched\n");
-
-       bClassificationSucceed = EthCSMatchDestMACAddress(pstClassifierRule,
-                       ((struct bcm_eth_header *)(skb->data))->au8DestinationAddress);
-       if (!bClassificationSucceed)
-               return false;
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "ETH CS DestMAC Matched\n");
-
-       /* classify on ETHType/802.2SAP TLV */
-       bClassificationSucceed = EthCSMatchEThTypeSAP(pstClassifierRule,
-                                                     skb,
-                                                     pstEthCsPktInfo);
-       if (!bClassificationSucceed)
-               return false;
-
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "ETH CS EthType/802.2SAP Matched\n");
-
-       /* classify on 802.1VLAN Header Parameters */
-       bClassificationSucceed = EthCSMatchVLANRules(pstClassifierRule,
-                                                    skb,
-                                                    pstEthCsPktInfo);
-       if (!bClassificationSucceed)
-               return false;
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "ETH CS 802.1 VLAN Rules Matched\n");
-
-       return bClassificationSucceed;
-}
-
-static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,
-                           PVOID pvEthPayload,
-                           struct bcm_eth_packet_info *pstEthCsPktInfo)
-{
-       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) {
-               BCM_DEBUG_PRINT(Adapter,
-                               DBG_TYPE_TX,
-                               IPV4_DBG,
-                               DBG_LVL_ALL,
-                               "EthCSGetPktInfo : ETH2 Frame\n");
-               /* ETH2 Frame */
-               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 {
-                       pstEthCsPktInfo->eNwpktEthFrameType = eEthOtherFrame;
-                       u16Etype = ntohs(u16Etype);
-               }
-       } 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) {
-                       /* SNAP Frame */
-                       pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCSNAPFrame;
-                       u16Etype = ((struct bcm_eth_llc_snap_frame *)pvEthPayload)->usEtherType;
-               }
-       }
-       if (u16Etype == ETHERNET_FRAMETYPE_IPV4)
-               pstEthCsPktInfo->eNwpktIPFrameType = eIPv4Packet;
-       else if (u16Etype == ETHERNET_FRAMETYPE_IPV6)
-               pstEthCsPktInfo->eNwpktIPFrameType = eIPv6Packet;
-       else
-               pstEthCsPktInfo->eNwpktIPFrameType = eNonIPPacket;
-
-       pstEthCsPktInfo->usEtherType = ((struct bcm_eth_header *)pvEthPayload)->u16Etype;
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "EthCsPktInfo->eNwpktIPFrameType : %x\n",
-                       pstEthCsPktInfo->eNwpktIPFrameType);
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "EthCsPktInfo->eNwpktEthFrameType : %x\n",
-                       pstEthCsPktInfo->eNwpktEthFrameType);
-       BCM_DEBUG_PRINT(Adapter,
-                       DBG_TYPE_TX,
-                       IPV4_DBG,
-                       DBG_LVL_ALL,
-                       "EthCsPktInfo->usEtherType : %x\n",
-                       pstEthCsPktInfo->usEtherType);
-}
-
diff --git a/drivers/staging/bcm/Queue.h b/drivers/staging/bcm/Queue.h
deleted file mode 100644 (file)
index 460c0ae..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*************************************
-* Queue.h
-**************************************/
-#ifndef        __QUEUE_H__
-#define        __QUEUE_H__
-
-
-
-#define ENQUEUEPACKET(_Head, _Tail, _Packet)   \
-do {                                           \
-       if (!_Head) {                           \
-               _Head = _Packet;                \
-       }                                       \
-       else {                                  \
-               (_Tail)->next = _Packet;        \
-       }                                       \
-       (_Packet)->next = NULL;                 \
-       _Tail = _Packet;                        \
-} while (0)
-#define DEQUEUEPACKET(Head, Tail)              \
-do {                                           \
-       if (Head) {                             \
-               if (!Head->next) {              \
-                       Tail = NULL;            \
-               }                               \
-               Head = Head->next;              \
-       }                                       \
-} while (0)
-#endif /* __QUEUE_H__ */
diff --git a/drivers/staging/bcm/TODO b/drivers/staging/bcm/TODO
deleted file mode 100644 (file)
index 8467f45..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-This driver is barely functional in its current state.
-
-Kevin McKinney(klmckinney1@gmail.com) and Matthias Beyer(mail@beyermatthias.de)
-are currently maintaining/cleaning up this driver.  Please copy us on all
-patches.  More maintainers are aways welcomed.
-
-BIG:
-       - existing API is (/dev/tarang) should be replaced
-         Is it possible to use same API as Intel Wimax stack and
-         have same user level components.
-       - Qos and queue model is non-standard and inflexible.
-         Use existing TC Qos?
-
-TODO:
-       - support more than one board - eliminate global variables
-       - remove developer debug BCM_DEBUG() macros
-         add a limited number of messages through netif_msg()
-       - fix non-standard kernel style
-       - checkpatch warnings
-       - use request firmware
-       - fix use of file I/O to load config with better API
-       - merge some files together?
-       - cleanup/eliminate debug messages
-
-
-
diff --git a/drivers/staging/bcm/Transmit.c b/drivers/staging/bcm/Transmit.c
deleted file mode 100644 (file)
index 622a482..0000000
+++ /dev/null
@@ -1,271 +0,0 @@
-/**
- * @file Transmit.c
- * @defgroup tx_functions Transmission
- * @section Queueing
- * @dot
- * digraph transmit1 {
- * node[shape=box]
- * edge[weight=5;color=red]
- *
- * bcm_transmit->GetPacketQueueIndex[label="IP Packet"]
- * GetPacketQueueIndex->IpVersion4[label="IPV4"]
- * GetPacketQueueIndex->IpVersion6[label="IPV6"]
- * }
- *
- * @enddot
- *
- * @section De-Queueing
- * @dot
- * digraph transmit2 {
- * node[shape=box]
- * edge[weight=5;color=red]
- * interrupt_service_thread->transmit_packets
- * tx_pkt_hdler->transmit_packets
- * transmit_packets->CheckAndSendPacketFromIndex
- * transmit_packets->UpdateTokenCount
- * CheckAndSendPacketFromIndex->PruneQueue
- * CheckAndSendPacketFromIndex->IsPacketAllowedForFlow
- * CheckAndSendPacketFromIndex->SendControlPacket[label="control pkt"]
- * SendControlPacket->bcm_cmd53
- * CheckAndSendPacketFromIndex->SendPacketFromQueue[label="data pkt"]
- * SendPacketFromQueue->SetupNextSend->bcm_cmd53
- * }
- * @enddot
- */
-
-#include "headers.h"
-
-/**
- * @ingroup ctrl_pkt_functions
- * This function dispatches control packet to the h/w interface
- * @return zero(success) or -ve value(failure)
- */
-int SendControlPacket(struct bcm_mini_adapter *Adapter, char *pControlPacket)
-{
-       struct bcm_leader *PLeader = (struct bcm_leader *)pControlPacket;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Tx");
-       if (!pControlPacket || !Adapter) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL,
-                               "Got NULL Control Packet or Adapter");
-               return STATUS_FAILURE;
-       }
-       if ((atomic_read(&Adapter->CurrNumFreeTxDesc) <
-                       ((PLeader->PLength-1)/MAX_DEVICE_DESC_SIZE)+1)) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL,
-                               "NO FREE DESCRIPTORS TO SEND CONTROL PACKET");
-               return STATUS_FAILURE;
-       }
-
-       /* Update the netdevice statistics */
-       /* Dump Packet  */
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL,
-                       "Leader Status: %x", PLeader->Status);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL,
-                       "Leader VCID: %x", PLeader->Vcid);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL,
-                       "Leader Length: %x", PLeader->PLength);
-       if (Adapter->device_removed)
-               return 0;
-
-       if (netif_msg_pktdata(Adapter))
-               print_hex_dump(KERN_DEBUG, PFX "tx control: ", DUMP_PREFIX_NONE,
-                              16, 1, pControlPacket,
-                              PLeader->PLength + LEADER_SIZE, 0);
-
-       Adapter->interface_transmit(Adapter->pvInterfaceAdapter,
-                                   pControlPacket,
-                                   (PLeader->PLength + LEADER_SIZE));
-
-       atomic_dec(&Adapter->CurrNumFreeTxDesc);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL,
-                       "<=========");
-       return STATUS_SUCCESS;
-}
-
-/**
- * @ingroup tx_functions
- * This function despatches the IP packets with the given vcid
- * to the target via the host h/w interface.
- * @return  zero(success) or -ve value(failure)
- */
-int SetupNextSend(struct bcm_mini_adapter *Adapter,
-               struct sk_buff *Packet, USHORT Vcid)
-{
-       int     status = 0;
-       bool    bHeaderSupressionEnabled = false;
-       B_UINT16 uiClassifierRuleID;
-       u16     QueueIndex = skb_get_queue_mapping(Packet);
-       struct bcm_packet_info *curr_packet_info =
-               &Adapter->PackInfo[QueueIndex];
-       struct bcm_leader Leader = {0};
-
-       if (Packet->len > MAX_DEVICE_DESC_SIZE) {
-               status = STATUS_FAILURE;
-               goto errExit;
-       }
-
-       /* Get the Classifier Rule ID */
-       uiClassifierRuleID = *((UINT32 *) (Packet->cb) +
-                              SKB_CB_CLASSIFICATION_OFFSET);
-
-       bHeaderSupressionEnabled = curr_packet_info->bHeaderSuppressionEnabled &
-               Adapter->bPHSEnabled;
-
-       if (Adapter->device_removed) {
-               status = STATUS_FAILURE;
-               goto errExit;
-       }
-
-       status = PHSTransmit(Adapter, &Packet, Vcid, uiClassifierRuleID,
-                            bHeaderSupressionEnabled,
-                            (UINT *)&Packet->len,
-                            curr_packet_info->bEthCSSupport);
-
-       if (status != STATUS_SUCCESS) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,
-                               "PHS Transmit failed..\n");
-               goto errExit;
-       }
-
-       Leader.Vcid = Vcid;
-
-       if (TCP_ACK == *((UINT32 *) (Packet->cb) + SKB_CB_TCPACK_OFFSET))
-               Leader.Status = LEADER_STATUS_TCP_ACK;
-       else
-               Leader.Status = LEADER_STATUS;
-
-       if (curr_packet_info->bEthCSSupport) {
-               Leader.PLength = Packet->len;
-               if (skb_headroom(Packet) < LEADER_SIZE) {
-                       status = skb_cow(Packet, LEADER_SIZE);
-                       if (status) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND,
-                                               DBG_LVL_ALL,
-                                               "bcm_transmit : Failed To Increase headRoom\n");
-                               goto errExit;
-                       }
-               }
-               skb_push(Packet, LEADER_SIZE);
-               memcpy(Packet->data, &Leader, LEADER_SIZE);
-       } else {
-               Leader.PLength = Packet->len - ETH_HLEN;
-               memcpy((struct bcm_leader *)skb_pull(Packet,
-                                                    (ETH_HLEN - LEADER_SIZE)),
-                       &Leader,
-                       LEADER_SIZE);
-       }
-
-       status = Adapter->interface_transmit(Adapter->pvInterfaceAdapter,
-                                            Packet->data,
-                                            (Leader.PLength + LEADER_SIZE));
-       if (status) {
-               ++Adapter->dev->stats.tx_errors;
-               if (netif_msg_tx_err(Adapter))
-                       pr_info(PFX "%s: transmit error %d\n",
-                               Adapter->dev->name,
-                               status);
-       } else {
-               struct net_device_stats *netstats = &Adapter->dev->stats;
-
-               curr_packet_info->uiTotalTxBytes += Leader.PLength;
-
-               netstats->tx_bytes += Leader.PLength;
-               ++netstats->tx_packets;
-
-               curr_packet_info->uiCurrentTokenCount -= Leader.PLength << 3;
-               curr_packet_info->uiSentBytes += (Packet->len);
-               curr_packet_info->uiSentPackets++;
-               curr_packet_info->NumOfPacketsSent++;
-
-               atomic_dec(&curr_packet_info->uiPerSFTxResourceCount);
-               curr_packet_info->uiThisPeriodSentBytes += Leader.PLength;
-       }
-
-       atomic_dec(&Adapter->CurrNumFreeTxDesc);
-
-errExit:
-       dev_kfree_skb(Packet);
-       return status;
-}
-
-static int tx_pending(struct bcm_mini_adapter *Adapter)
-{
-       return (atomic_read(&Adapter->TxPktAvail)
-               && MINIMUM_PENDING_DESCRIPTORS <
-                       atomic_read(&Adapter->CurrNumFreeTxDesc))
-               || Adapter->device_removed || (1 == Adapter->downloadDDR);
-}
-
-/**
- * @ingroup tx_functions
- * Transmit thread
- */
-int tx_pkt_handler(struct bcm_mini_adapter *Adapter)
-{
-       int status = 0;
-
-       while (!kthread_should_stop()) {
-               /* FIXME - the timeout looks like workaround
-                *  for racey usage of TxPktAvail
-               */
-               if (Adapter->LinkUpStatus)
-                       wait_event_timeout(Adapter->tx_packet_wait_queue,
-                                          tx_pending(Adapter),
-                                          msecs_to_jiffies(10));
-               else
-                       wait_event_interruptible(Adapter->tx_packet_wait_queue,
-                                                tx_pending(Adapter));
-
-               if (Adapter->device_removed)
-                       break;
-
-               if (Adapter->downloadDDR == 1) {
-                       Adapter->downloadDDR += 1;
-                       status = download_ddr_settings(Adapter);
-                       if (status)
-                               pr_err(PFX "DDR DOWNLOAD FAILED! %d\n", status);
-                       continue;
-               }
-
-               /* Check end point for halt/stall. */
-               if (Adapter->bEndPointHalted == TRUE) {
-                       Bcm_clear_halt_of_endpoints(Adapter);
-                       Adapter->bEndPointHalted = false;
-                       StartInterruptUrb((struct bcm_interface_adapter *)
-                                       (Adapter->pvInterfaceAdapter));
-               }
-
-               if (Adapter->LinkUpStatus && !Adapter->IdleMode) {
-                       if (atomic_read(&Adapter->TotalPacketCount))
-                               update_per_sf_desc_cnts(Adapter);
-               }
-
-               if (atomic_read(&Adapter->CurrNumFreeTxDesc) &&
-                       Adapter->LinkStatus == SYNC_UP_REQUEST &&
-                       !Adapter->bSyncUpRequestSent) {
-
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS,
-                                       DBG_LVL_ALL, "Calling LinkMessage");
-                       LinkMessage(Adapter);
-               }
-
-               if ((Adapter->IdleMode || Adapter->bShutStatus) &&
-                               atomic_read(&Adapter->TotalPacketCount)) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX,
-                                       TX_PACKETS, DBG_LVL_ALL,
-                                       "Device in Low Power mode...waking up");
-                       Adapter->usIdleModePattern = ABORT_IDLE_MODE;
-                       Adapter->bWakeUpDevice = TRUE;
-                       wake_up(&Adapter->process_rx_cntrlpkt);
-               }
-
-               transmit_packets(Adapter);
-               atomic_set(&Adapter->TxPktAvail, 0);
-       }
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL,
-                       "Exiting the tx thread..\n");
-       Adapter->transmit_packet_thread = NULL;
-       return 0;
-}
diff --git a/drivers/staging/bcm/Typedefs.h b/drivers/staging/bcm/Typedefs.h
deleted file mode 100644 (file)
index 90b3b25..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/****************************
-*      Typedefs.h
-****************************/
-#ifndef        __TYPEDEFS_H__
-#define        __TYPEDEFS_H__
-#define  STATUS_SUCCESS        0
-#define  STATUS_FAILURE -1
-
-
-#define         TRUE           1
-
-
-typedef char CHAR;
-typedef int INT;
-typedef short SHORT;
-typedef long LONG;
-typedef void VOID;
-
-typedef unsigned char UCHAR;
-typedef unsigned char B_UINT8;
-typedef unsigned short USHORT;
-typedef unsigned short B_UINT16;
-typedef unsigned int UINT;
-typedef unsigned int B_UINT32;
-typedef unsigned long ULONG;
-typedef unsigned long DWORD;
-
-typedef char *PCHAR;
-typedef short *PSHORT;
-typedef int *PINT;
-typedef long *PLONG;
-typedef void *PVOID;
-
-typedef unsigned char *PUCHAR;
-typedef unsigned short *PUSHORT;
-typedef unsigned int *PUINT;
-typedef unsigned long *PULONG;
-typedef unsigned long long ULONG64;
-typedef unsigned long long LARGE_INTEGER;
-typedef unsigned int UINT32;
-#ifndef NULL
-#define NULL 0
-#endif
-
-
-#endif /* __TYPEDEFS_H__ */
-
diff --git a/drivers/staging/bcm/cntrl_SignalingInterface.h b/drivers/staging/bcm/cntrl_SignalingInterface.h
deleted file mode 100644 (file)
index 8683c2d..0000000
+++ /dev/null
@@ -1,311 +0,0 @@
-#ifndef CNTRL_SIGNALING_INTERFACE_
-#define CNTRL_SIGNALING_INTERFACE_
-
-#define DSA_REQ                        11
-#define DSA_RSP                        12
-#define DSA_ACK                        13
-#define DSC_REQ                        14
-#define DSC_RSP                        15
-#define DSC_ACK                        16
-#define DSD_REQ                        17
-#define DSD_RSP                        18
-#define DSD_ACK                        19
-#define MAX_CLASSIFIERS_IN_SF  4
-
-#define MAX_STRING_LEN                 20
-#define MAX_PHS_LENGTHS                        255
-#define VENDOR_PHS_PARAM_LENGTH                10
-#define MAX_NUM_ACTIVE_BS              10
-#define AUTH_TOKEN_LENGTH              10
-#define NUM_HARQ_CHANNELS              16 /* Changed from 10 to 16 to accommodate all HARQ channels */
-#define VENDOR_CLASSIFIER_PARAM_LENGTH 1  /* Changed the size to 1 byte since we dnt use it */
-#define  VENDOR_SPECIF_QOS_PARAM       1
-#define VENDOR_PHS_PARAM_LENGTH                10
-#define MBS_CONTENTS_ID_LENGTH         10
-#define GLOBAL_SF_CLASSNAME_LENGTH     6
-
-#define TYPE_OF_SERVICE_LENGTH         3
-#define IP_MASKED_SRC_ADDRESS_LENGTH   32
-#define IP_MASKED_DEST_ADDRESS_LENGTH  32
-#define PROTOCOL_SRC_PORT_RANGE_LENGTH 4
-#define PROTOCOL_DEST_PORT_RANGE_LENGTH        4
-#define ETHERNET_DEST_MAC_ADDR_LENGTH  12
-#define ETHERNET_SRC_MAC_ADDR_LENGTH   12
-#define NUM_ETHERTYPE_BYTES            3
-#define NUM_IPV6_FLOWLABLE_BYTES       3
-
-struct bcm_packet_class_rules {
-       /* 16bit UserPriority Of The Service Flow */
-       u16 u16UserPriority;
-       /* 16bit VLANID Of The Service Flow */
-       u16 u16VLANID;
-       /* 16bit Packet Classification RuleIndex Of The Service Flow */
-       u16 u16PacketClassificationRuleIndex;
-       /* 8bit Classifier Rule Priority Of The Service Flow */
-       u8 u8ClassifierRulePriority;
-       /* Length of IP TypeOfService field */
-       u8 u8IPTypeOfServiceLength;
-       /* 3bytes IP TypeOfService */
-       u8 u8IPTypeOfService[TYPE_OF_SERVICE_LENGTH];
-       /* Protocol used in classification of Service Flow */
-       u8 u8Protocol;
-       /* Length of IP Masked Source Address */
-       u8 u8IPMaskedSourceAddressLength;
-       /* IP Masked Source Address used in classification for the Service Flow */
-       u8 u8IPMaskedSourceAddress[IP_MASKED_SRC_ADDRESS_LENGTH];
-       /* Length of IP Destination Address */
-       u8 u8IPDestinationAddressLength;
-       /* IP Destination Address used in classification for the Service Flow */
-       u8 u8IPDestinationAddress[IP_MASKED_DEST_ADDRESS_LENGTH];
-       /* Length of Protocol Source Port Range */
-       u8 u8ProtocolSourcePortRangeLength;
-       /* Protocol Source Port Range used in the Service Flow */
-       u8 u8ProtocolSourcePortRange[PROTOCOL_SRC_PORT_RANGE_LENGTH];
-       /* Length of Protocol Dest Port Range */
-       u8 u8ProtocolDestPortRangeLength;
-       /* Protocol Dest Port Range used in the Service Flow */
-       u8 u8ProtocolDestPortRange[PROTOCOL_DEST_PORT_RANGE_LENGTH];
-       /* Length of Ethernet Destination MAC Address */
-       u8 u8EthernetDestMacAddressLength;
-       /* Ethernet Destination MAC Address  used in classification of the Service Flow */
-       u8 u8EthernetDestMacAddress[ETHERNET_DEST_MAC_ADDR_LENGTH];
-       /* Length of Ethernet Source MAC Address */
-       u8 u8EthernetSourceMACAddressLength;
-       /* Ethernet Source MAC Address  used in classification of the Service Flow */
-       u8 u8EthernetSourceMACAddress[ETHERNET_SRC_MAC_ADDR_LENGTH];
-       /* Length of Ethertype */
-       u8 u8EthertypeLength;
-       /* 3bytes Ethertype Of The Service Flow */
-       u8 u8Ethertype[NUM_ETHERTYPE_BYTES];
-       /* 8bit Associated PHSI Of The Service Flow */
-       u8 u8AssociatedPHSI;
-       /* Length of Vendor Specific Classifier Param length Of The Service Flow */
-       u8 u8VendorSpecificClassifierParamLength;
-       /* Vendor Specific Classifier Param Of The Service Flow */
-       u8 u8VendorSpecificClassifierParam[VENDOR_CLASSIFIER_PARAM_LENGTH];
-       /* Length Of IPv6 Flow Lable of the Service Flow */
-       u8 u8IPv6FlowLableLength;
-       /* IPv6 Flow Lable Of The Service Flow */
-       u8 u8IPv6FlowLable[NUM_IPV6_FLOWLABLE_BYTES];
-       /* Action associated with the classifier rule */
-       u8 u8ClassifierActionRule;
-       u16 u16ValidityBitMap;
-};
-
-struct bcm_phs_rules {
-       /* 8bit PHS Index Of The Service Flow */
-       u8 u8PHSI;
-       /* PHSF Length Of The Service Flow */
-       u8 u8PHSFLength;
-       /* String of bytes containing header information to be suppressed by the sending CS and reconstructed by the receiving CS */
-       u8 u8PHSF[MAX_PHS_LENGTHS];
-       /* PHSM Length Of The Service Flow */
-       u8 u8PHSMLength;
-       /* PHS Mask for the SF */
-       u8 u8PHSM[MAX_PHS_LENGTHS];
-       /* 8bit Total number of bytes to be suppressed for the Service Flow */
-       u8 u8PHSS;
-       /* 8bit Indicates whether or not Packet Header contents need to be verified prior to suppression */
-       u8 u8PHSV;
-       /* Vendor Specific PHS param Length Of The Service Flow */
-       u8 u8VendorSpecificPHSParamsLength;
-       /* Vendor Specific PHS param Of The Service Flow */
-       u8 u8VendorSpecificPHSParams[VENDOR_PHS_PARAM_LENGTH];
-       u8 u8Padding[2];
-};
-
-struct bcm_convergence_types {
-       /* 8bit Phs Classfier Action Of The Service Flow */
-       u8 u8ClassfierDSCAction;
-       /* 8bit Phs DSC Action Of The Service Flow */
-       u8 u8PhsDSCAction;
-       /* 16bit Padding */
-       u8 u8Padding[2];
-       /* Packet classification rules structure */
-       struct bcm_packet_class_rules cCPacketClassificationRule;
-       /* Payload header suppression rules structure */
-       struct bcm_phs_rules cPhsRule;
-};
-
-struct bcm_connect_mgr_params {
-       /* 32bitSFID Of The Service Flow */
-       u32 u32SFID;
-       /* 32bit Maximum Sustained Traffic Rate of the Service Flow */
-       u32 u32MaxSustainedTrafficRate;
-       /* 32bit Maximum Traffic Burst allowed for the Service Flow */
-       u32 u32MaxTrafficBurst;
-       /* 32bit Minimum Reserved Traffic Rate of the Service Flow */
-       u32 u32MinReservedTrafficRate;
-       /* 32bit Tolerated Jitter of the Service Flow */
-       u32 u32ToleratedJitter;
-       /* 32bit Maximum Latency of the Service Flow */
-       u32 u32MaximumLatency;
-       /* 16bitCID Of The Service Flow */
-       u16 u16CID;
-       /* 16bit SAID on which the service flow being set up shall be mapped */
-       u16 u16TargetSAID;
-       /* 16bit  ARQ window size negotiated */
-       u16 u16ARQWindowSize;
-       /* 16bit Total Tx delay incl sending, receiving & processing delays */
-       u16 u16ARQRetryTxTimeOut;
-       /* 16bit Total Rx delay incl sending, receiving & processing delays */
-       u16 u16ARQRetryRxTimeOut;
-       /* 16bit ARQ block lifetime */
-       u16 u16ARQBlockLifeTime;
-       /* 16bit ARQ Sync loss timeout */
-       u16 u16ARQSyncLossTimeOut;
-       /* 16bit ARQ Purge timeout */
-       u16 u16ARQRxPurgeTimeOut;
-       /* TODO::Remove this once we move to a new CORR2 driver
-        * brief Size of an ARQ block
-        */
-       u16 u16ARQBlockSize;
-       /* #endif */
-       /* 16bit Nominal interval b/w consecutive SDU arrivals at MAC SAP */
-       u16 u16SDUInterArrivalTime;
-       /* 16bit Specifies the time base for rate measurement */
-       u16 u16TimeBase;
-       /* 16bit Interval b/w Successive Grant oppurtunities */
-       u16 u16UnsolicitedGrantInterval;
-       /* 16bit Interval b/w Successive Polling grant oppurtunities */
-       u16 u16UnsolicitedPollingInterval;
-       /* internal var to get the overhead */
-       u16 u16MacOverhead;
-       /* MBS contents Identifier */
-       u16 u16MBSContentsID[MBS_CONTENTS_ID_LENGTH];
-       /* MBS contents Identifier length */
-       u8 u8MBSContentsIDLength;
-       /* ServiceClassName Length Of The Service Flow */
-       u8 u8ServiceClassNameLength;
-       /* 32bytes ServiceClassName Of The Service Flow */
-       u8 u8ServiceClassName[32];
-       /* 8bit Indicates whether or not MBS service is requested for this Serivce Flow */
-       u8 u8MBSService;
-       /* 8bit QOS Parameter Set specifies proper application of QoS parameters to Provisioned, Admitted and Active sets */
-       u8 u8QosParamSet;
-       /* 8bit Traffic Priority Of the Service Flow */
-       u8 u8TrafficPriority;
-       /* 8bit Uplink Grant Scheduling Type of The Service Flow */
-       u8 u8ServiceFlowSchedulingType;
-       /* 8bit Request transmission Policy of the Service Flow */
-       u8 u8RequesttransmissionPolicy;
-       /* 8bit Specifies whether SDUs for this Service flow are of FixedLength or Variable length */
-       u8 u8FixedLengthVSVariableLengthSDUIndicator;
-       /* 8bit Length of the SDU for a fixed length SDU service flow */
-       u8 u8SDUSize;
-       /* 8bit Indicates whether or not ARQ is requested for this connection */
-       u8 u8ARQEnable;
-       /* < 8bit Indicates whether or not data has tobe delivered in order to higher layer */
-       u8 u8ARQDeliverInOrder;
-       /* 8bit Receiver ARQ ACK processing time */
-       u8 u8RxARQAckProcessingTime;
-       /* 8bit Convergence Sublayer Specification Of The Service Flow */
-       u8 u8CSSpecification;
-       /* 8 bit Type of data delivery service */
-       u8 u8TypeOfDataDeliveryService;
-       /* 8bit Specifies whether a service flow may generate Paging */
-       u8 u8PagingPreference;
-       /* 8bit Indicates the MBS Zone through which the connection or virtual connection is valid */
-       u8 u8MBSZoneIdentifierassignment;
-       /* 8bit Specifies whether traffic on SF should generate MOB_TRF_IND to MS in sleep mode */
-       u8 u8TrafficIndicationPreference;
-       /* 8bit Speciifes the length of predefined Global QoS parameter set encoding for this SF */
-       u8 u8GlobalServicesClassNameLength;
-       /* 6 byte Speciifes the predefined Global QoS parameter set encoding for this SF */
-       u8 u8GlobalServicesClassName[GLOBAL_SF_CLASSNAME_LENGTH];
-       /* 8bit Indicates whether or not SN feedback is enabled for the conn */
-       u8 u8SNFeedbackEnabled;
-       /* Indicates the size of the Fragment Sequence Number for the connection */
-       u8 u8FSNSize;
-       /* 8bit Number of CIDs in active BS list */
-       u8 u8CIDAllocation4activeBSsLength;
-       /* CIDs of BS in the active list */
-       u8 u8CIDAllocation4activeBSs[MAX_NUM_ACTIVE_BS];
-       /* Specifies if PDU extended subheader should be applied on every PDU on this conn */
-       u8 u8PDUSNExtendedSubheader4HarqReordering;
-       /* 8bit Specifies whether the connection uses HARQ or not */
-       u8 u8HARQServiceFlows;
-       /* Specifies the length of Authorization token */
-       u8 u8AuthTokenLength;
-       /* Specifies the Authorization token */
-       u8 u8AuthToken[AUTH_TOKEN_LENGTH];
-       /* specifes Number of HARQ channels used to carry data length */
-       u8 u8HarqChannelMappingLength;
-       /* specifes HARQ channels used to carry data */
-       u8 u8HARQChannelMapping[NUM_HARQ_CHANNELS];
-       /* 8bit Length of Vendor Specific QoS Params */
-       u8 u8VendorSpecificQoSParamLength;
-       /* 1byte  Vendor Specific QoS Param Of The Service Flow */
-       u8 u8VendorSpecificQoSParam[VENDOR_SPECIF_QOS_PARAM];
-       /* indicates total classifiers in the SF */
-       u8 u8TotalClassifiers;  /* < Total number of valid classifiers */
-       u8 bValid;      /* < Validity flag */
-       u8 u8Padding;    /* < Padding byte */
-       /*
-        * Structure for Convergence SubLayer Types with a maximum of 4 classifiers
-        */
-       struct bcm_convergence_types cConvergenceSLTypes[MAX_CLASSIFIERS_IN_SF];
-};
-
-struct bcm_add_request {
-       u8 u8Type;      /* < Type */
-       u8 eConnectionDir; /* < Connection direction */
-       /* brief 16 bit TID */
-       u16 u16TID; /* < 16bit TID */
-       /* brief 16bitCID */
-       u16 u16CID; /* < 16bit CID */
-       /* brief 16bitVCID */
-       u16 u16VCID; /* < 16bit VCID */
-       struct bcm_connect_mgr_params *psfParameterSet; /* < connection manager parameters */
-};
-
-struct bcm_add_indication {
-       u8 u8Type;      /* < Type */
-       u8 eConnectionDir;      /* < Connection Direction */
-       /* brief 16 bit TID */
-       u16 u16TID; /* < TID */
-       /* brief 16bitCID */
-       u16 u16CID; /* < 16bitCID */
-       /* brief 16bitVCID */
-       u16 u16VCID; /* < 16bitVCID */
-       struct bcm_connect_mgr_params *psfAuthorizedSet; /* Authorized set of connection manager parameters */
-       struct bcm_connect_mgr_params *psfAdmittedSet; /* Admitted set of connection manager parameters */
-       struct bcm_connect_mgr_params *psfActiveSet; /* Activeset of connection manager parameters */
-       u8 u8CC; /* <Confirmation Code */
-       u8 u8Padd; /* < 8-bit Padding */
-       u16 u16Padd; /* < 16 bit Padding */
-};
-
-struct bcm_del_request {
-       u8 u8Type; /* < Type */
-       u8 u8Padding; /* < Padding byte */
-       u16 u16TID; /* < TID */
-       /* brief 32bitSFID */
-       u32 u32SFID; /* < SFID */
-};
-
-struct bcm_del_indication {
-       u8 u8Type;      /* < Type */
-       u8 u8Padding; /* < Padding */
-       u16 u16TID; /* < TID */
-       /* brief 16bitCID */
-       u16 u16CID; /* < CID */
-       /* brief 16bitVCID */
-       u16 u16VCID; /* < VCID */
-       /* brief 32bitSFID */
-       u32 u32SFID; /* < SFID */
-       /* brief 8bit Confirmation code */
-       u8 u8ConfirmationCode; /* < Confirmation code */
-       u8 u8Padding1[3]; /* < 3 byte Padding */
-};
-
-struct bcm_stim_sfhostnotify {
-       u32 SFID; /* SFID of the service flow */
-       u16 newCID; /* the new/changed CID */
-       u16 VCID; /* Get new Vcid if the flow has been made active in CID update TLV, but was inactive earlier or the orig vcid */
-       u8 RetainSF; /* Indication to Host if the SF is to be retained or deleted; if TRUE-retain else delete */
-       u8 QoSParamSet; /* QoS paramset of the retained SF */
-       u16 u16reserved; /* For byte alignment */
-};
-
-#endif
diff --git a/drivers/staging/bcm/headers.h b/drivers/staging/bcm/headers.h
deleted file mode 100644 (file)
index a7d4af5..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-
-/*******************************************************************
-*              Headers.h
-*******************************************************************/
-#ifndef __HEADERS_H__
-#define __HEADERS_H__
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/netdevice.h>
-#include <linux/skbuff.h>
-#include <linux/socket.h>
-#include <linux/netfilter.h>
-#include <linux/netfilter_ipv4.h>
-#include <linux/if_arp.h>
-#include <linux/delay.h>
-#include <linux/spinlock.h>
-#include <linux/fs.h>
-#include <linux/file.h>
-#include <linux/string.h>
-#include <linux/etherdevice.h>
-#include <linux/wait.h>
-#include <linux/proc_fs.h>
-#include <linux/interrupt.h>
-#include <linux/stddef.h>
-#include <linux/stat.h>
-#include <linux/fcntl.h>
-#include <linux/unistd.h>
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/pagemap.h>
-#include <linux/kthread.h>
-#include <linux/tcp.h>
-#include <linux/udp.h>
-#include <linux/usb.h>
-#include <linux/uaccess.h>
-#include <net/ip.h>
-
-#include "Typedefs.h"
-#include "Macros.h"
-#include "HostMIBSInterface.h"
-#include "cntrl_SignalingInterface.h"
-#include "PHSDefines.h"
-#include "led_control.h"
-#include "Ioctl.h"
-#include "nvm.h"
-#include "target_params.h"
-#include "Adapter.h"
-#include "CmHost.h"
-#include "DDRInit.h"
-#include "Debug.h"
-#include "IPv6ProtocolHdr.h"
-#include "PHSModule.h"
-#include "Protocol.h"
-#include "Prototypes.h"
-#include "Queue.h"
-#include "vendorspecificextn.h"
-
-#include "InterfaceMacros.h"
-#include "InterfaceAdapter.h"
-#include "InterfaceIsr.h"
-#include "InterfaceMisc.h"
-#include "InterfaceRx.h"
-#include "InterfaceTx.h"
-#include "InterfaceIdleMode.h"
-#include "InterfaceInit.h"
-
-#define DRV_NAME       "beceem"
-#define DEV_NAME       "tarang"
-#define DRV_DESCRIPTION "Beceem Communications Inc. WiMAX driver"
-#define DRV_COPYRIGHT  "Copyright 2010. Beceem Communications Inc"
-#define DRV_VERSION    "5.2.45"
-#define PFX            DRV_NAME " "
-
-extern struct class *bcm_class;
-
-#endif
diff --git a/drivers/staging/bcm/hostmibs.c b/drivers/staging/bcm/hostmibs.c
deleted file mode 100644 (file)
index f9b08a5..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * File Name: hostmibs.c
- *
- * Author: Beceem Communications Pvt. Ltd
- *
- * Abstract: This file contains the routines to copy the statistics used by
- * the driver to the Host MIBS structure and giving the same to Application.
- */
-
-#include "headers.h"
-
-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 = &Adapter->stBCMPhsContext;
-       struct bcm_mibs_host_info *host_info;
-       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");
-               return STATUS_FAILURE;
-       }
-
-       /* Copy the classifier Table */
-       for (nClassifierIndex = 0; nClassifierIndex < MAX_CLASSIFIERS;
-                                                       nClassifierIndex++) {
-               if (Adapter->astClassifierTable[nClassifierIndex].bUsed == TRUE)
-                       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(&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.
-                        * Go For the next entry.
-                        */
-                       continue;
-               }
-
-               /* Retrieve the SFID Entry Index for requested Service Flow */
-               if (PHS_INVALID_TABLE_INDEX ==
-                   GetServiceFlowEntry(pDeviceExtension->
-                                       pstServiceFlowPhsRulesTable,
-                                       Adapter->PackInfo[nSfIndex].
-                                       usVCID_Value, &pstServiceFlowEntry))
-
-                       continue;
-
-               pstClassifierTable = pstServiceFlowEntry->pstClassifierTable;
-
-               for (uiIndex = 0; uiIndex < MAX_PHSRULE_PER_SF; uiIndex++) {
-                       pstClassifierRule = &pstClassifierTable->stActivePhsRulesList[uiIndex];
-
-                       if (pstClassifierRule->bUsed) {
-                               pstPhsRule = pstClassifierRule->pstPhsRule;
-
-                               pstHostMibs->astPhsRulesTable[nPhsTableIndex].
-                                   ulSFID = Adapter->PackInfo[nSfIndex].ulSFID;
-
-                               memcpy(&pstHostMibs->astPhsRulesTable[nPhsTableIndex].u8PHSI,
-                                      &pstPhsRule->u8PHSI,
-                                      sizeof(struct bcm_phs_rule));
-                               nPhsTableIndex++;
-
-                       }
-
-               }
-
-       }
-
-       /* Copy other Host Statistics parameters */
-       host_info = &pstHostMibs->stHostInfo;
-       host_info->GoodTransmits    = Adapter->dev->stats.tx_packets;
-       host_info->GoodReceives     = Adapter->dev->stats.rx_packets;
-       host_info->CurrNumFreeDesc  = atomic_read(&Adapter->CurrNumFreeTxDesc);
-       host_info->BEBucketSize     = Adapter->BEBucketSize;
-       host_info->rtPSBucketSize   = Adapter->rtPSBucketSize;
-       host_info->TimerActive      = Adapter->TimerActive;
-       host_info->u32TotalDSD      = Adapter->u32TotalDSD;
-
-       memcpy(host_info->aTxPktSizeHist, Adapter->aTxPktSizeHist,
-              sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES);
-       memcpy(host_info->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)
-{
-       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)
-{
-       struct bcm_mibs_parameters *t =
-               &Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable;
-
-       t->wmanIfSfid = psfLocalSet->u32SFID;
-       t->wmanIfCmnCpsMaxSustainedRate =
-               psfLocalSet->u32MaxSustainedTrafficRate;
-       t->wmanIfCmnCpsMaxTrafficBurst = psfLocalSet->u32MaxTrafficBurst;
-       t->wmanIfCmnCpsMinReservedRate = psfLocalSet->u32MinReservedTrafficRate;
-       t->wmanIfCmnCpsToleratedJitter = psfLocalSet->u32ToleratedJitter;
-       t->wmanIfCmnCpsMaxLatency = psfLocalSet->u32MaximumLatency;
-       t->wmanIfCmnCpsFixedVsVariableSduInd =
-               psfLocalSet->u8FixedLengthVSVariableLengthSDUIndicator;
-       t->wmanIfCmnCpsFixedVsVariableSduInd =
-               ntohl(t->wmanIfCmnCpsFixedVsVariableSduInd);
-       t->wmanIfCmnCpsSduSize = psfLocalSet->u8SDUSize;
-       t->wmanIfCmnCpsSduSize = ntohl(t->wmanIfCmnCpsSduSize);
-       t->wmanIfCmnCpsSfSchedulingType =
-               psfLocalSet->u8ServiceFlowSchedulingType;
-       t->wmanIfCmnCpsSfSchedulingType =
-               ntohl(t->wmanIfCmnCpsSfSchedulingType);
-       t->wmanIfCmnCpsArqEnable = psfLocalSet->u8ARQEnable;
-       t->wmanIfCmnCpsArqEnable = ntohl(t->wmanIfCmnCpsArqEnable);
-       t->wmanIfCmnCpsArqWindowSize = ntohs(psfLocalSet->u16ARQWindowSize);
-       t->wmanIfCmnCpsArqWindowSize = ntohl(t->wmanIfCmnCpsArqWindowSize);
-       t->wmanIfCmnCpsArqBlockLifetime =
-               ntohs(psfLocalSet->u16ARQBlockLifeTime);
-       t->wmanIfCmnCpsArqBlockLifetime =
-               ntohl(t->wmanIfCmnCpsArqBlockLifetime);
-       t->wmanIfCmnCpsArqSyncLossTimeout =
-               ntohs(psfLocalSet->u16ARQSyncLossTimeOut);
-       t->wmanIfCmnCpsArqSyncLossTimeout =
-               ntohl(t->wmanIfCmnCpsArqSyncLossTimeout);
-       t->wmanIfCmnCpsArqDeliverInOrder = psfLocalSet->u8ARQDeliverInOrder;
-       t->wmanIfCmnCpsArqDeliverInOrder =
-               ntohl(t->wmanIfCmnCpsArqDeliverInOrder);
-       t->wmanIfCmnCpsArqRxPurgeTimeout =
-               ntohs(psfLocalSet->u16ARQRxPurgeTimeOut);
-       t->wmanIfCmnCpsArqRxPurgeTimeout =
-               ntohl(t->wmanIfCmnCpsArqRxPurgeTimeout);
-       t->wmanIfCmnCpsArqBlockSize = ntohs(psfLocalSet->u16ARQBlockSize);
-       t->wmanIfCmnCpsArqBlockSize = ntohl(t->wmanIfCmnCpsArqBlockSize);
-       t->wmanIfCmnCpsReqTxPolicy = psfLocalSet->u8RequesttransmissionPolicy;
-       t->wmanIfCmnCpsReqTxPolicy = ntohl(t->wmanIfCmnCpsReqTxPolicy);
-       t->wmanIfCmnSfCsSpecification = psfLocalSet->u8CSSpecification;
-       t->wmanIfCmnSfCsSpecification = ntohl(t->wmanIfCmnSfCsSpecification);
-       t->wmanIfCmnCpsTargetSaid = ntohs(psfLocalSet->u16TargetSAID);
-       t->wmanIfCmnCpsTargetSaid = ntohl(t->wmanIfCmnCpsTargetSaid);
-
-}
diff --git a/drivers/staging/bcm/led_control.c b/drivers/staging/bcm/led_control.c
deleted file mode 100644 (file)
index 074fc39..0000000
+++ /dev/null
@@ -1,952 +0,0 @@
-#include "headers.h"
-
-#define STATUS_IMAGE_CHECKSUM_MISMATCH -199
-#define EVENT_SIGNALED 1
-
-static B_UINT16 CFG_CalculateChecksum(B_UINT8 *pu8Buffer, B_UINT32 u32Size)
-{
-       B_UINT16 u16CheckSum = 0;
-
-       while (u32Size--) {
-               u16CheckSum += (B_UINT8)~(*pu8Buffer);
-               pu8Buffer++;
-       }
-       return u16CheckSum;
-}
-
-bool IsReqGpioIsLedInNVM(struct bcm_mini_adapter *Adapter, UINT gpios)
-{
-       INT Status;
-
-       Status = (Adapter->gpioBitMap & gpios) ^ gpios;
-       if (Status)
-               return false;
-       else
-               return TRUE;
-}
-
-static INT LED_Blink(struct bcm_mini_adapter *Adapter,
-                    UINT GPIO_Num,
-                    UCHAR uiLedIndex,
-                    ULONG timeout,
-                    INT num_of_time,
-                    enum bcm_led_events currdriverstate)
-{
-       int Status = STATUS_SUCCESS;
-       bool bInfinite = false;
-
-       /* Check if num_of_time is -ve. If yes, blink led in infinite loop */
-       if (num_of_time < 0) {
-               bInfinite = TRUE;
-               num_of_time = 1;
-       }
-       while (num_of_time) {
-               if (currdriverstate == Adapter->DriverState)
-                       TURN_ON_LED(Adapter, GPIO_Num, uiLedIndex);
-
-               /* Wait for timeout after setting on the LED */
-               Status = wait_event_interruptible_timeout(
-                               Adapter->LEDInfo.notify_led_event,
-                               currdriverstate != Adapter->DriverState ||
-                                       kthread_should_stop(),
-                               msecs_to_jiffies(timeout));
-
-               if (kthread_should_stop()) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
-                               DBG_LVL_ALL,
-                               "Led thread got signal to exit..hence exiting");
-                       Adapter->LEDInfo.led_thread_running =
-                                       BCM_LED_THREAD_DISABLED;
-                       TURN_OFF_LED(Adapter, GPIO_Num, uiLedIndex);
-                       Status = EVENT_SIGNALED;
-                       break;
-               }
-               if (Status) {
-                       TURN_OFF_LED(Adapter, GPIO_Num, uiLedIndex);
-                       Status = EVENT_SIGNALED;
-                       break;
-               }
-
-               TURN_OFF_LED(Adapter, GPIO_Num, uiLedIndex);
-               Status = wait_event_interruptible_timeout(
-                               Adapter->LEDInfo.notify_led_event,
-                               currdriverstate != Adapter->DriverState ||
-                                       kthread_should_stop(),
-                               msecs_to_jiffies(timeout));
-               if (bInfinite == false)
-                       num_of_time--;
-       }
-       return Status;
-}
-
-static INT ScaleRateofTransfer(ULONG rate)
-{
-       if (rate <= 3)
-               return rate;
-       else if ((rate > 3) && (rate <= 100))
-               return 5;
-       else if ((rate > 100) && (rate <= 200))
-               return 6;
-       else if ((rate > 200) && (rate <= 300))
-               return 7;
-       else if ((rate > 300) && (rate <= 400))
-               return 8;
-       else if ((rate > 400) && (rate <= 500))
-               return 9;
-       else if ((rate > 500) && (rate <= 600))
-               return 10;
-       else
-               return MAX_NUM_OF_BLINKS;
-}
-
-static INT blink_in_normal_bandwidth(struct bcm_mini_adapter *ad,
-                                    INT *time,
-                                    INT *time_tx,
-                                    INT *time_rx,
-                                    UCHAR GPIO_Num_tx,
-                                    UCHAR uiTxLedIndex,
-                                    UCHAR GPIO_Num_rx,
-                                    UCHAR uiRxLedIndex,
-                                    enum bcm_led_events currdriverstate,
-                                    ulong *timeout)
-{
-       /*
-        * Assign minimum number of blinks of
-        * either Tx or Rx.
-        */
-       *time = (*time_tx > *time_rx ? *time_rx : *time_tx);
-
-       if (*time > 0) {
-               /* Blink both Tx and Rx LEDs */
-               if ((LED_Blink(ad, 1 << GPIO_Num_tx, uiTxLedIndex, *timeout,
-                             *time, currdriverstate) == EVENT_SIGNALED) ||
-                   (LED_Blink(ad, 1 << GPIO_Num_rx, uiRxLedIndex, *timeout,
-                             *time, currdriverstate) == EVENT_SIGNALED))
-                       return EVENT_SIGNALED;
-       }
-
-       if (*time == *time_tx) {
-               /* Blink pending rate of Rx */
-               if (LED_Blink(ad, (1 << GPIO_Num_rx), uiRxLedIndex, *timeout,
-                             *time_rx - *time,
-                             currdriverstate) == EVENT_SIGNALED)
-                       return EVENT_SIGNALED;
-
-               *time = *time_rx;
-       } else {
-               /* Blink pending rate of Tx */
-               if (LED_Blink(ad, 1 << GPIO_Num_tx, uiTxLedIndex, *timeout,
-                             *time_tx - *time,
-                             currdriverstate) == EVENT_SIGNALED)
-                       return EVENT_SIGNALED;
-
-               *time = *time_tx;
-       }
-
-       return 0;
-}
-
-static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter,
-                                 UCHAR GPIO_Num_tx,
-                                 UCHAR uiTxLedIndex,
-                                 UCHAR GPIO_Num_rx,
-                                 UCHAR uiRxLedIndex,
-                                 enum bcm_led_events currdriverstate)
-{
-       /* Initial values of TX and RX packets */
-       ULONG64 Initial_num_of_packts_tx = 0, Initial_num_of_packts_rx = 0;
-       /* values of TX and RX packets after 1 sec */
-       ULONG64 Final_num_of_packts_tx = 0, Final_num_of_packts_rx = 0;
-       /* Rate of transfer of Tx and Rx in 1 sec */
-       ULONG64 rate_of_transfer_tx = 0, rate_of_transfer_rx = 0;
-       int Status = STATUS_SUCCESS;
-       INT num_of_time = 0, num_of_time_tx = 0, num_of_time_rx = 0;
-       UINT remDelay = 0;
-       /* UINT GPIO_num = DISABLE_GPIO_NUM; */
-       ulong timeout = 0;
-
-       /* Read initial value of packets sent/received */
-       Initial_num_of_packts_tx = Adapter->dev->stats.tx_packets;
-       Initial_num_of_packts_rx = Adapter->dev->stats.rx_packets;
-
-       /* Scale the rate of transfer to no of blinks. */
-       num_of_time_tx = ScaleRateofTransfer((ULONG)rate_of_transfer_tx);
-       num_of_time_rx = ScaleRateofTransfer((ULONG)rate_of_transfer_rx);
-
-       while ((Adapter->device_removed == false)) {
-               timeout = 50;
-
-               if (EVENT_SIGNALED == blink_in_normal_bandwidth(Adapter,
-                                                               &num_of_time,
-                                                               &num_of_time_tx,
-                                                               &num_of_time_rx,
-                                                               GPIO_Num_tx,
-                                                               uiTxLedIndex,
-                                                               GPIO_Num_rx,
-                                                               uiRxLedIndex,
-                                                               currdriverstate,
-                                                               &timeout))
-                       return EVENT_SIGNALED;
-
-
-               /*
-                * If Tx/Rx rate is less than maximum blinks per second,
-                * wait till delay completes to 1 second
-                */
-               remDelay = MAX_NUM_OF_BLINKS - num_of_time;
-               if (remDelay > 0) {
-                       timeout = 100 * remDelay;
-                       Status = wait_event_interruptible_timeout(
-                                       Adapter->LEDInfo.notify_led_event,
-                                       currdriverstate != Adapter->DriverState
-                                               || kthread_should_stop(),
-                                       msecs_to_jiffies(timeout));
-
-                       if (kthread_should_stop()) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
-                                       LED_DUMP_INFO, DBG_LVL_ALL,
-                                       "Led thread got signal to exit..hence exiting");
-                               Adapter->LEDInfo.led_thread_running =
-                                               BCM_LED_THREAD_DISABLED;
-                               return EVENT_SIGNALED;
-                       }
-                       if (Status)
-                               return EVENT_SIGNALED;
-               }
-
-               /* Turn off both Tx and Rx LEDs before next second */
-               TURN_OFF_LED(Adapter, 1 << GPIO_Num_tx, uiTxLedIndex);
-               TURN_OFF_LED(Adapter, 1 << GPIO_Num_rx, uiTxLedIndex);
-
-               /*
-                * Read the Tx & Rx packets transmission after 1 second and
-                * calculate rate of transfer
-                */
-               Final_num_of_packts_tx = Adapter->dev->stats.tx_packets;
-               Final_num_of_packts_rx = Adapter->dev->stats.rx_packets;
-
-               rate_of_transfer_tx = Final_num_of_packts_tx -
-                                               Initial_num_of_packts_tx;
-               rate_of_transfer_rx = Final_num_of_packts_rx -
-                                               Initial_num_of_packts_rx;
-
-               /* Read initial value of packets sent/received */
-               Initial_num_of_packts_tx = Final_num_of_packts_tx;
-               Initial_num_of_packts_rx = Final_num_of_packts_rx;
-
-               /* Scale the rate of transfer to no of blinks. */
-               num_of_time_tx =
-                       ScaleRateofTransfer((ULONG)rate_of_transfer_tx);
-               num_of_time_rx =
-                       ScaleRateofTransfer((ULONG)rate_of_transfer_rx);
-
-       }
-       return Status;
-}
-
-/*
- * -----------------------------------------------------------------------------
- * Procedure:   ValidateDSDParamsChecksum
- *
- * Description: Reads DSD Params and validates checkusm.
- *
- * Arguments:
- *      Adapter - Pointer to Adapter structure.
- *      ulParamOffset - Start offset of the DSD parameter to be read and
- *                     validated.
- *      usParamLen - Length of the DSD Parameter.
- *
- * Returns:
- *  <OSAL_STATUS_CODE>
- * -----------------------------------------------------------------------------
- */
-static INT ValidateDSDParamsChecksum(struct bcm_mini_adapter *Adapter,
-                                    ULONG ulParamOffset,
-                                    USHORT usParamLen)
-{
-       INT Status = STATUS_SUCCESS;
-       PUCHAR puBuffer = NULL;
-       USHORT usChksmOrg = 0;
-       USHORT usChecksumCalculated = 0;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
-                       "LED Thread:ValidateDSDParamsChecksum: 0x%lx 0x%X",
-                       ulParamOffset, usParamLen);
-
-       puBuffer = kmalloc(usParamLen, GFP_KERNEL);
-       if (!puBuffer) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
-                               DBG_LVL_ALL,
-                               "LED Thread: ValidateDSDParamsChecksum Allocation failed");
-               return -ENOMEM;
-
-       }
-
-       /* Read the DSD data from the parameter offset. */
-       if (STATUS_SUCCESS != BeceemNVMRead(Adapter, (PUINT)puBuffer,
-                                           ulParamOffset, usParamLen)) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
-                               DBG_LVL_ALL,
-                               "LED Thread: ValidateDSDParamsChecksum BeceemNVMRead failed");
-               Status = STATUS_IMAGE_CHECKSUM_MISMATCH;
-               goto exit;
-       }
-
-       /* Calculate the checksum of the data read from the DSD parameter. */
-       usChecksumCalculated = CFG_CalculateChecksum(puBuffer, usParamLen);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
-                       "LED Thread: usCheckSumCalculated = 0x%x\n",
-                       usChecksumCalculated);
-
-       /*
-        * End of the DSD parameter will have a TWO bytes checksum stored in it.
-        * Read it and compare with the calculated Checksum.
-        */
-       if (STATUS_SUCCESS != BeceemNVMRead(Adapter, (PUINT)&usChksmOrg,
-                                           ulParamOffset+usParamLen, 2)) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
-                               DBG_LVL_ALL,
-                               "LED Thread: ValidateDSDParamsChecksum BeceemNVMRead failed");
-               Status = STATUS_IMAGE_CHECKSUM_MISMATCH;
-               goto exit;
-       }
-       usChksmOrg = ntohs(usChksmOrg);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
-                       "LED Thread: usChksmOrg = 0x%x", usChksmOrg);
-
-       /*
-        * Compare the checksum calculated with the checksum read
-        * from DSD section
-        */
-       if (usChecksumCalculated ^ usChksmOrg) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
-                               DBG_LVL_ALL,
-                               "LED Thread: ValidateDSDParamsChecksum: Checksums don't match");
-               Status = STATUS_IMAGE_CHECKSUM_MISMATCH;
-               goto exit;
-       }
-
-exit:
-       kfree(puBuffer);
-       return Status;
-}
-
-
-/*
- * -----------------------------------------------------------------------------
- * Procedure:   ValidateHWParmStructure
- *
- * Description: Validates HW Parameters.
- *
- * Arguments:
- *      Adapter - Pointer to Adapter structure.
- *      ulHwParamOffset - Start offset of the HW parameter Section to be read
- *                             and validated.
- *
- * Returns:
- *  <OSAL_STATUS_CODE>
- * -----------------------------------------------------------------------------
- */
-static INT ValidateHWParmStructure(struct bcm_mini_adapter *Adapter,
-                                  ULONG ulHwParamOffset)
-{
-
-       INT Status = STATUS_SUCCESS;
-       USHORT HwParamLen = 0;
-       /*
-        * Add DSD start offset to the hwParamOffset to get
-        * the actual address.
-        */
-       ulHwParamOffset += DSD_START_OFFSET;
-
-       /* Read the Length of HW_PARAM structure */
-       BeceemNVMRead(Adapter, (PUINT)&HwParamLen, ulHwParamOffset, 2);
-       HwParamLen = ntohs(HwParamLen);
-       if (0 == HwParamLen || HwParamLen > Adapter->uiNVMDSDSize)
-               return STATUS_IMAGE_CHECKSUM_MISMATCH;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
-                       "LED Thread:HwParamLen = 0x%x", HwParamLen);
-       Status = ValidateDSDParamsChecksum(Adapter, ulHwParamOffset,
-                                          HwParamLen);
-       return Status;
-} /* ValidateHWParmStructure() */
-
-static int ReadLEDInformationFromEEPROM(struct bcm_mini_adapter *Adapter,
-                                       UCHAR GPIO_Array[])
-{
-       int Status = STATUS_SUCCESS;
-
-       ULONG  dwReadValue      = 0;
-       USHORT usHwParamData    = 0;
-       USHORT usEEPROMVersion  = 0;
-       UCHAR  ucIndex          = 0;
-       UCHAR  ucGPIOInfo[32]   = {0};
-
-       BeceemNVMRead(Adapter, (PUINT)&usEEPROMVersion,
-                     EEPROM_VERSION_OFFSET, 2);
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
-                       "usEEPROMVersion: Minor:0x%X Major:0x%x",
-                       usEEPROMVersion & 0xFF,
-                       ((usEEPROMVersion >> 8) & 0xFF));
-
-
-       if (((usEEPROMVersion>>8)&0xFF) < EEPROM_MAP5_MAJORVERSION) {
-               BeceemNVMRead(Adapter, (PUINT)&usHwParamData,
-                             EEPROM_HW_PARAM_POINTER_ADDRESS, 2);
-               usHwParamData = ntohs(usHwParamData);
-               dwReadValue   = usHwParamData;
-       } else {
-               /*
-                * Validate Compatibility section and then read HW param
-                * if compatibility section is valid.
-                */
-               Status = ValidateDSDParamsChecksum(Adapter,
-                                                  DSD_START_OFFSET,
-                                                  COMPATIBILITY_SECTION_LENGTH_MAP5);
-
-               if (Status != STATUS_SUCCESS)
-                       return Status;
-
-               BeceemNVMRead(Adapter, (PUINT)&dwReadValue,
-                             EEPROM_HW_PARAM_POINTER_ADDRRES_MAP5, 4);
-               dwReadValue = ntohl(dwReadValue);
-       }
-
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
-                       "LED Thread: Start address of HW_PARAM structure = 0x%lx",
-                       dwReadValue);
-
-       /*
-        * Validate if the address read out is within the DSD.
-        * Adapter->uiNVMDSDSize gives whole DSD size inclusive of Autoinit.
-        * lower limit should be above DSD_START_OFFSET and
-        * upper limit should be below (Adapter->uiNVMDSDSize-DSD_START_OFFSET)
-        */
-       if (dwReadValue < DSD_START_OFFSET ||
-                       dwReadValue > (Adapter->uiNVMDSDSize-DSD_START_OFFSET))
-               return STATUS_IMAGE_CHECKSUM_MISMATCH;
-
-       Status = ValidateHWParmStructure(Adapter, dwReadValue);
-       if (Status)
-               return Status;
-
-       /*
-        * Add DSD_START_OFFSET to the offset read from the EEPROM.
-        * This will give the actual start HW Parameters start address.
-        * To read GPIO section, add GPIO offset further.
-        */
-
-       dwReadValue += DSD_START_OFFSET;
-                       /* = start address of hw param section. */
-       dwReadValue += GPIO_SECTION_START_OFFSET;
-                       /* = GPIO start offset within HW Param section. */
-
-       /*
-        * Read the GPIO values for 32 GPIOs from EEPROM and map the function
-        * number to GPIO pin number to GPIO_Array
-        */
-       BeceemNVMRead(Adapter, (UINT *)ucGPIOInfo, dwReadValue, 32);
-       for (ucIndex = 0; ucIndex < 32; ucIndex++) {
-
-               switch (ucGPIOInfo[ucIndex]) {
-               case RED_LED:
-                       GPIO_Array[RED_LED] = ucIndex;
-                       Adapter->gpioBitMap |= (1 << ucIndex);
-                       break;
-               case BLUE_LED:
-                       GPIO_Array[BLUE_LED] = ucIndex;
-                       Adapter->gpioBitMap |= (1 << ucIndex);
-                       break;
-               case YELLOW_LED:
-                       GPIO_Array[YELLOW_LED] = ucIndex;
-                       Adapter->gpioBitMap |= (1 << ucIndex);
-                       break;
-               case GREEN_LED:
-                       GPIO_Array[GREEN_LED] = ucIndex;
-                       Adapter->gpioBitMap |= (1 << ucIndex);
-                       break;
-               default:
-                       break;
-               }
-
-       }
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
-                       "GPIO's bit map correspond to LED :0x%X",
-                       Adapter->gpioBitMap);
-       return Status;
-}
-
-
-static int ReadConfigFileStructure(struct bcm_mini_adapter *Adapter,
-                                  bool *bEnableThread)
-{
-       int Status = STATUS_SUCCESS;
-       /* Array to store GPIO numbers from EEPROM */
-       UCHAR GPIO_Array[NUM_OF_LEDS+1];
-       UINT uiIndex = 0;
-       UINT uiNum_of_LED_Type = 0;
-       PUCHAR puCFGData        = NULL;
-       UCHAR bData = 0;
-       struct bcm_led_state_info *curr_led_state;
-
-       memset(GPIO_Array, DISABLE_GPIO_NUM, NUM_OF_LEDS+1);
-
-       if (!Adapter->pstargetparams || IS_ERR(Adapter->pstargetparams)) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
-                               DBG_LVL_ALL, "Target Params not Avail.\n");
-               return -ENOENT;
-       }
-
-       /* Populate GPIO_Array with GPIO numbers for LED functions */
-       /* Read the GPIO numbers from EEPROM */
-       Status = ReadLEDInformationFromEEPROM(Adapter, GPIO_Array);
-       if (Status == STATUS_IMAGE_CHECKSUM_MISMATCH) {
-               *bEnableThread = false;
-               return STATUS_SUCCESS;
-       } else if (Status) {
-               *bEnableThread = false;
-               return Status;
-       }
-
-       /*
-        * CONFIG file read successfully. Deallocate the memory of
-        * uiFileNameBufferSize
-        */
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,
-                       "LED Thread: Config file read successfully\n");
-       puCFGData = (PUCHAR) &Adapter->pstargetparams->HostDrvrConfig1;
-
-       /*
-        * Offset for HostDrvConfig1, HostDrvConfig2, HostDrvConfig3 which
-        * will have the information of LED type, LED on state for different
-        * driver state and LED blink state.
-        */
-
-       for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
-               bData = *puCFGData;
-               curr_led_state = &Adapter->LEDInfo.LEDState[uiIndex];
-
-               /*
-                * Check Bit 8 for polarity. If it is set,
-                * polarity is reverse polarity
-                */
-               if (bData & 0x80) {
-                       curr_led_state->BitPolarity = 0;
-                       /* unset the bit 8 */
-                       bData = bData & 0x7f;
-               }
-
-               curr_led_state->LED_Type = bData;
-               if (bData <= NUM_OF_LEDS)
-                       curr_led_state->GPIO_Num = GPIO_Array[bData];
-               else
-                       curr_led_state->GPIO_Num = DISABLE_GPIO_NUM;
-
-               puCFGData++;
-               bData = *puCFGData;
-               curr_led_state->LED_On_State = bData;
-               puCFGData++;
-               bData = *puCFGData;
-               curr_led_state->LED_Blink_State = bData;
-               puCFGData++;
-       }
-
-       /*
-        * Check if all the LED settings are disabled. If it is disabled,
-        * dont launch the LED control thread.
-        */
-       for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
-               curr_led_state = &Adapter->LEDInfo.LEDState[uiIndex];
-
-               if ((curr_led_state->LED_Type == DISABLE_GPIO_NUM) ||
-                       (curr_led_state->LED_Type == 0x7f) ||
-                       (curr_led_state->LED_Type == 0))
-                       uiNum_of_LED_Type++;
-       }
-       if (uiNum_of_LED_Type >= NUM_OF_LEDS)
-               *bEnableThread = false;
-
-       return Status;
-}
-
-/*
- * -----------------------------------------------------------------------------
- * Procedure:   LedGpioInit
- *
- * Description: Initializes LED GPIOs. Makes the LED GPIOs to OUTPUT mode
- *                       and make the initial state to be OFF.
- *
- * Arguments:
- *      Adapter - Pointer to MINI_ADAPTER structure.
- *
- * Returns: VOID
- *
- * -----------------------------------------------------------------------------
- */
-static VOID LedGpioInit(struct bcm_mini_adapter *Adapter)
-{
-       UINT uiResetValue = 0;
-       UINT uiIndex      = 0;
-       struct bcm_led_state_info *curr_led_state;
-
-       /* Set all LED GPIO Mode to output mode */
-       if (rdmalt(Adapter, GPIO_MODE_REGISTER, &uiResetValue,
-                  sizeof(uiResetValue)) < 0)
-               BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
-                       DBG_LVL_ALL, "LED Thread: RDM Failed\n");
-       for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
-               curr_led_state = &Adapter->LEDInfo.LEDState[uiIndex];
-
-               if (curr_led_state->GPIO_Num != DISABLE_GPIO_NUM)
-                       uiResetValue |= (1 << curr_led_state->GPIO_Num);
-
-               TURN_OFF_LED(Adapter, 1 << curr_led_state->GPIO_Num, uiIndex);
-
-       }
-       if (wrmalt(Adapter, GPIO_MODE_REGISTER, &uiResetValue,
-                  sizeof(uiResetValue)) < 0)
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
-                               DBG_LVL_ALL, "LED Thread: WRM Failed\n");
-
-       Adapter->LEDInfo.bIdle_led_off = false;
-}
-
-static INT BcmGetGPIOPinInfo(struct bcm_mini_adapter *Adapter,
-                            UCHAR *GPIO_num_tx,
-                            UCHAR *GPIO_num_rx,
-                            UCHAR *uiLedTxIndex,
-                            UCHAR *uiLedRxIndex,
-                            enum bcm_led_events currdriverstate)
-{
-       UINT uiIndex = 0;
-       struct bcm_led_state_info *led_state_info;
-
-       *GPIO_num_tx = DISABLE_GPIO_NUM;
-       *GPIO_num_rx = DISABLE_GPIO_NUM;
-
-       for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
-               led_state_info = &Adapter->LEDInfo.LEDState[uiIndex];
-
-               if (((currdriverstate == NORMAL_OPERATION) ||
-                       (currdriverstate == IDLEMODE_EXIT) ||
-                       (currdriverstate == FW_DOWNLOAD)) &&
-                   (led_state_info->LED_Blink_State & currdriverstate) &&
-                   (led_state_info->GPIO_Num != DISABLE_GPIO_NUM)) {
-                       if (*GPIO_num_tx == DISABLE_GPIO_NUM) {
-                               *GPIO_num_tx = led_state_info->GPIO_Num;
-                               *uiLedTxIndex = uiIndex;
-                       } else {
-                               *GPIO_num_rx = led_state_info->GPIO_Num;
-                               *uiLedRxIndex = uiIndex;
-                       }
-               } else {
-                       if ((led_state_info->LED_On_State & currdriverstate) &&
-                           (led_state_info->GPIO_Num != DISABLE_GPIO_NUM)) {
-                               *GPIO_num_tx = led_state_info->GPIO_Num;
-                               *uiLedTxIndex = uiIndex;
-                       }
-               }
-       }
-       return STATUS_SUCCESS;
-}
-
-static void handle_adapter_driver_state(struct bcm_mini_adapter *ad,
-                                       enum bcm_led_events currdriverstate,
-                                       UCHAR GPIO_num,
-                                       UCHAR dummyGPIONum,
-                                       UCHAR uiLedIndex,
-                                       UCHAR dummyIndex,
-                                       ulong timeout,
-                                       UINT uiResetValue,
-                                       UINT uiIndex)
-{
-       switch (ad->DriverState) {
-       case DRIVER_INIT:
-               currdriverstate = DRIVER_INIT;
-                               /* ad->DriverState; */
-               BcmGetGPIOPinInfo(ad, &GPIO_num, &dummyGPIONum,
-                                 &uiLedIndex, &dummyIndex,
-                                 currdriverstate);
-
-               if (GPIO_num != DISABLE_GPIO_NUM)
-                       TURN_ON_LED(ad, 1 << GPIO_num, uiLedIndex);
-
-               break;
-       case FW_DOWNLOAD:
-               /*
-                * BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS,
-                *      LED_DUMP_INFO, DBG_LVL_ALL,
-                *      "LED Thread: FW_DN_DONE called\n");
-                */
-               currdriverstate = FW_DOWNLOAD;
-               BcmGetGPIOPinInfo(ad, &GPIO_num, &dummyGPIONum,
-                                 &uiLedIndex, &dummyIndex,
-                                 currdriverstate);
-
-               if (GPIO_num != DISABLE_GPIO_NUM) {
-                       timeout = 50;
-                       LED_Blink(ad, 1 << GPIO_num, uiLedIndex, timeout,
-                                 -1, currdriverstate);
-               }
-               break;
-       case FW_DOWNLOAD_DONE:
-               currdriverstate = FW_DOWNLOAD_DONE;
-               BcmGetGPIOPinInfo(ad, &GPIO_num, &dummyGPIONum,
-                                 &uiLedIndex, &dummyIndex, currdriverstate);
-               if (GPIO_num != DISABLE_GPIO_NUM)
-                       TURN_ON_LED(ad, 1 << GPIO_num, uiLedIndex);
-               break;
-
-       case SHUTDOWN_EXIT:
-               /*
-                * no break, continue to NO_NETWORK_ENTRY
-                * state as well.
-                */
-       case NO_NETWORK_ENTRY:
-               currdriverstate = NO_NETWORK_ENTRY;
-               BcmGetGPIOPinInfo(ad, &GPIO_num, &dummyGPIONum,
-                                 &uiLedIndex, &dummyGPIONum, currdriverstate);
-               if (GPIO_num != DISABLE_GPIO_NUM)
-                       TURN_ON_LED(ad, 1 << GPIO_num, uiLedIndex);
-               break;
-       case NORMAL_OPERATION:
-               {
-                       UCHAR GPIO_num_tx = DISABLE_GPIO_NUM;
-                       UCHAR GPIO_num_rx = DISABLE_GPIO_NUM;
-                       UCHAR uiLEDTx = 0;
-                       UCHAR uiLEDRx = 0;
-
-                       currdriverstate = NORMAL_OPERATION;
-                       ad->LEDInfo.bIdle_led_off = false;
-
-                       BcmGetGPIOPinInfo(ad, &GPIO_num_tx, &GPIO_num_rx,
-                                         &uiLEDTx, &uiLEDRx, currdriverstate);
-                       if ((GPIO_num_tx == DISABLE_GPIO_NUM) &&
-                                       (GPIO_num_rx == DISABLE_GPIO_NUM)) {
-                               GPIO_num = DISABLE_GPIO_NUM;
-                       } else {
-                               /*
-                                * If single LED is selected, use same
-                                * for both Tx and Rx
-                                */
-                               if (GPIO_num_tx == DISABLE_GPIO_NUM) {
-                                       GPIO_num_tx = GPIO_num_rx;
-                                       uiLEDTx = uiLEDRx;
-                               } else if (GPIO_num_rx == DISABLE_GPIO_NUM) {
-                                       GPIO_num_rx = GPIO_num_tx;
-                                       uiLEDRx = uiLEDTx;
-                               }
-                               /*
-                                * Blink the LED in proportionate
-                                * to Tx and Rx transmissions.
-                                */
-                               LED_Proportional_Blink(ad,
-                                                      GPIO_num_tx, uiLEDTx,
-                                                      GPIO_num_rx, uiLEDRx,
-                                                      currdriverstate);
-                       }
-               }
-               break;
-       case LOWPOWER_MODE_ENTER:
-               currdriverstate = LOWPOWER_MODE_ENTER;
-               if (DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING ==
-                               ad->ulPowerSaveMode) {
-                       /* Turn OFF all the LED */
-                       uiResetValue = 0;
-                       for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
-                               if (ad->LEDInfo.LEDState[uiIndex].GPIO_Num != DISABLE_GPIO_NUM)
-                                       TURN_OFF_LED(ad,
-                                                    (1 << ad->LEDInfo.LEDState[uiIndex].GPIO_Num),
-                                                    uiIndex);
-                       }
-
-               }
-               /* Turn off LED And WAKE-UP for Sendinf IDLE mode ACK */
-               ad->LEDInfo.bLedInitDone = false;
-               ad->LEDInfo.bIdle_led_off = TRUE;
-               wake_up(&ad->LEDInfo.idleModeSyncEvent);
-               GPIO_num = DISABLE_GPIO_NUM;
-               break;
-       case IDLEMODE_CONTINUE:
-               currdriverstate = IDLEMODE_CONTINUE;
-               GPIO_num = DISABLE_GPIO_NUM;
-               break;
-       case IDLEMODE_EXIT:
-               break;
-       case DRIVER_HALT:
-               currdriverstate = DRIVER_HALT;
-               GPIO_num = DISABLE_GPIO_NUM;
-               for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
-                       if (ad->LEDInfo.LEDState[uiIndex].GPIO_Num !=
-                                       DISABLE_GPIO_NUM)
-                               TURN_OFF_LED(ad,
-                                            (1 << ad->LEDInfo.LEDState[uiIndex].GPIO_Num),
-                                            uiIndex);
-               }
-               /* ad->DriverState = DRIVER_INIT; */
-               break;
-       case LED_THREAD_INACTIVE:
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, LED_DUMP_INFO,
-                               DBG_LVL_ALL, "InActivating LED thread...");
-               currdriverstate = LED_THREAD_INACTIVE;
-               ad->LEDInfo.led_thread_running =
-                               BCM_LED_THREAD_RUNNING_INACTIVELY;
-               ad->LEDInfo.bLedInitDone = false;
-               /* disable ALL LED */
-               for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
-                       if (ad->LEDInfo.LEDState[uiIndex].GPIO_Num !=
-                                       DISABLE_GPIO_NUM)
-                               TURN_OFF_LED(ad,
-                                            (1 << ad->LEDInfo.LEDState[uiIndex].GPIO_Num),
-                                            uiIndex);
-               }
-               break;
-       case LED_THREAD_ACTIVE:
-               BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, LED_DUMP_INFO,
-                               DBG_LVL_ALL, "Activating LED thread again...");
-               if (ad->LinkUpStatus == false)
-                       ad->DriverState = NO_NETWORK_ENTRY;
-               else
-                       ad->DriverState = NORMAL_OPERATION;
-
-               ad->LEDInfo.led_thread_running =
-                               BCM_LED_THREAD_RUNNING_ACTIVELY;
-               break;
-               /* return; */
-       default:
-               break;
-       }
-}
-
-static VOID LEDControlThread(struct bcm_mini_adapter *Adapter)
-{
-       UINT uiIndex = 0;
-       UCHAR GPIO_num = 0;
-       UCHAR uiLedIndex = 0;
-       UINT uiResetValue = 0;
-       enum bcm_led_events currdriverstate = 0;
-       ulong timeout = 0;
-
-       INT Status = 0;
-
-       UCHAR dummyGPIONum = 0;
-       UCHAR dummyIndex = 0;
-
-       /* currdriverstate = Adapter->DriverState; */
-       Adapter->LEDInfo.bIdleMode_tx_from_host = false;
-
-       /*
-        * Wait till event is triggered
-        *
-        * wait_event(Adapter->LEDInfo.notify_led_event,
-        *      currdriverstate!= Adapter->DriverState);
-        */
-
-       GPIO_num = DISABLE_GPIO_NUM;
-
-       while (TRUE) {
-               /* Wait till event is triggered */
-               if ((GPIO_num == DISABLE_GPIO_NUM)
-                                               ||
-                               ((currdriverstate != FW_DOWNLOAD) &&
-                                (currdriverstate != NORMAL_OPERATION) &&
-                                (currdriverstate != LOWPOWER_MODE_ENTER))
-                                               ||
-                               (currdriverstate == LED_THREAD_INACTIVE))
-                       Status = wait_event_interruptible(
-                                       Adapter->LEDInfo.notify_led_event,
-                                       currdriverstate != Adapter->DriverState
-                                               || kthread_should_stop());
-
-               if (kthread_should_stop() || Adapter->device_removed) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
-                               DBG_LVL_ALL,
-                               "Led thread got signal to exit..hence exiting");
-                       Adapter->LEDInfo.led_thread_running =
-                                               BCM_LED_THREAD_DISABLED;
-                       TURN_OFF_LED(Adapter, 1 << GPIO_num, uiLedIndex);
-                       return; /* STATUS_FAILURE; */
-               }
-
-               if (GPIO_num != DISABLE_GPIO_NUM)
-                       TURN_OFF_LED(Adapter, 1 << GPIO_num, uiLedIndex);
-
-               if (Adapter->LEDInfo.bLedInitDone == false) {
-                       LedGpioInit(Adapter);
-                       Adapter->LEDInfo.bLedInitDone = TRUE;
-               }
-
-               handle_adapter_driver_state(Adapter,
-                                           currdriverstate,
-                                           GPIO_num,
-                                           dummyGPIONum,
-                                           uiLedIndex,
-                                           dummyIndex,
-                                           timeout,
-                                           uiResetValue,
-                                           uiIndex
-                                           );
-       }
-       Adapter->LEDInfo.led_thread_running = BCM_LED_THREAD_DISABLED;
-}
-
-int InitLedSettings(struct bcm_mini_adapter *Adapter)
-{
-       int Status = STATUS_SUCCESS;
-       bool bEnableThread = TRUE;
-       UCHAR uiIndex = 0;
-
-       /*
-        * Initially set BitPolarity to normal polarity. The bit 8 of LED type
-        * is used to change the polarity of the LED.
-        */
-
-       for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++)
-               Adapter->LEDInfo.LEDState[uiIndex].BitPolarity = 1;
-
-       /*
-        * Read the LED settings of CONFIG file and map it
-        * to GPIO numbers in EEPROM
-        */
-       Status = ReadConfigFileStructure(Adapter, &bEnableThread);
-       if (STATUS_SUCCESS != Status) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
-                               DBG_LVL_ALL,
-                               "LED Thread: FAILED in ReadConfigFileStructure\n");
-               return Status;
-       }
-
-       if (Adapter->LEDInfo.led_thread_running) {
-               if (bEnableThread) {
-                       ;
-               } else {
-                       Adapter->DriverState = DRIVER_HALT;
-                       wake_up(&Adapter->LEDInfo.notify_led_event);
-                       Adapter->LEDInfo.led_thread_running =
-                                               BCM_LED_THREAD_DISABLED;
-               }
-
-       } else if (bEnableThread) {
-               /* Create secondary thread to handle the LEDs */
-               init_waitqueue_head(&Adapter->LEDInfo.notify_led_event);
-               init_waitqueue_head(&Adapter->LEDInfo.idleModeSyncEvent);
-               Adapter->LEDInfo.led_thread_running =
-                                       BCM_LED_THREAD_RUNNING_ACTIVELY;
-               Adapter->LEDInfo.bIdle_led_off = false;
-               Adapter->LEDInfo.led_cntrl_threadid =
-                       kthread_run((int (*)(void *)) LEDControlThread,
-                                   Adapter, "led_control_thread");
-               if (IS_ERR(Adapter->LEDInfo.led_cntrl_threadid)) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
-                                       DBG_LVL_ALL,
-                                       "Not able to spawn Kernel Thread\n");
-                       Adapter->LEDInfo.led_thread_running =
-                               BCM_LED_THREAD_DISABLED;
-                       return PTR_ERR(Adapter->LEDInfo.led_cntrl_threadid);
-               }
-       }
-       return Status;
-}
diff --git a/drivers/staging/bcm/led_control.h b/drivers/staging/bcm/led_control.h
deleted file mode 100644 (file)
index 1b24bf4..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-#ifndef _LED_CONTROL_H
-#define _LED_CONTROL_H
-
-#define NUM_OF_LEDS                            4
-#define DSD_START_OFFSET                       0x0200
-#define EEPROM_VERSION_OFFSET                  0x020E
-#define EEPROM_HW_PARAM_POINTER_ADDRESS                0x0218
-#define EEPROM_HW_PARAM_POINTER_ADDRRES_MAP5   0x0220
-#define GPIO_SECTION_START_OFFSET              0x03
-#define COMPATIBILITY_SECTION_LENGTH           42
-#define COMPATIBILITY_SECTION_LENGTH_MAP5      84
-#define EEPROM_MAP5_MAJORVERSION               5
-#define EEPROM_MAP5_MINORVERSION               0
-#define MAX_NUM_OF_BLINKS                      10
-#define NUM_OF_GPIO_PINS                       16
-#define DISABLE_GPIO_NUM                       0xFF
-#define EVENT_SIGNALED                         1
-#define MAX_FILE_NAME_BUFFER_SIZE              100
-
-#define TURN_ON_LED(ad, GPIO, index) do {                                      \
-               unsigned int gpio_val = GPIO;                                   \
-               (ad->LEDInfo.LEDState[index].BitPolarity == 1) ?        \
-                       wrmaltWithLock(ad, BCM_GPIO_OUTPUT_SET_REG, &gpio_val, sizeof(gpio_val)) : \
-                       wrmaltWithLock(ad, BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)); \
-       } while (0)
-
-#define TURN_OFF_LED(ad, GPIO, index)  do {                                    \
-               unsigned int gpio_val = GPIO;                                   \
-               (ad->LEDInfo.LEDState[index].BitPolarity == 1) ?        \
-                       wrmaltWithLock(ad, BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)) : \
-                       wrmaltWithLock(ad, BCM_GPIO_OUTPUT_SET_REG, &gpio_val, sizeof(gpio_val)); \
-       } while (0)
-
-enum bcm_led_colors {
-       RED_LED         = 1,
-       BLUE_LED        = 2,
-       YELLOW_LED      = 3,
-       GREEN_LED       = 4
-};
-
-enum bcm_led_events {
-       SHUTDOWN_EXIT           = 0x00,
-       DRIVER_INIT             = 0x1,
-       FW_DOWNLOAD             = 0x2,
-       FW_DOWNLOAD_DONE        = 0x4,
-       NO_NETWORK_ENTRY        = 0x8,
-       NORMAL_OPERATION        = 0x10,
-       LOWPOWER_MODE_ENTER     = 0x20,
-       IDLEMODE_CONTINUE       = 0x40,
-       IDLEMODE_EXIT           = 0x80,
-       LED_THREAD_INACTIVE     = 0x100,  /* Makes the LED thread Inactivce. It wil be equivallent to putting the thread on hold. */
-       LED_THREAD_ACTIVE       = 0x200,  /* Makes the LED Thread Active back. */
-       DRIVER_HALT             = 0xff
-}; /* Enumerated values of different driver states */
-
-/*
- * Structure which stores the information of different LED types
- * and corresponding LED state information of driver states
- */
-struct bcm_led_state_info {
-       unsigned char LED_Type; /* specify GPIO number - use 0xFF if not used */
-       unsigned char LED_On_State; /* Bits set or reset for different states */
-       unsigned char LED_Blink_State; /* Bits set or reset for blinking LEDs for different states */
-       unsigned char GPIO_Num;
-       unsigned char BitPolarity; /* To represent whether H/W is normal polarity or reverse polarity */
-};
-
-struct bcm_led_info {
-       struct bcm_led_state_info LEDState[NUM_OF_LEDS];
-       bool            bIdleMode_tx_from_host; /* Variable to notify whether driver came out from idlemode due to Host or target */
-       bool            bIdle_led_off;
-       wait_queue_head_t       notify_led_event;
-       wait_queue_head_t       idleModeSyncEvent;
-       struct task_struct      *led_cntrl_threadid;
-       int             led_thread_running;
-       bool            bLedInitDone;
-};
-
-/* LED Thread state. */
-#define BCM_LED_THREAD_DISABLED                0   /* LED Thread is not running. */
-#define BCM_LED_THREAD_RUNNING_ACTIVELY        1   /* LED thread is running. */
-#define BCM_LED_THREAD_RUNNING_INACTIVELY 2 /* LED thread has been put on hold */
-
-#endif
diff --git a/drivers/staging/bcm/nvm.c b/drivers/staging/bcm/nvm.c
deleted file mode 100644 (file)
index ce09473..0000000
+++ /dev/null
@@ -1,4661 +0,0 @@
-#include "headers.h"
-
-#define DWORD unsigned int
-
-static int BcmDoChipSelect(struct bcm_mini_adapter *Adapter,
-                          unsigned int offset);
-static int BcmGetActiveDSD(struct bcm_mini_adapter *Adapter);
-static int BcmGetActiveISO(struct bcm_mini_adapter *Adapter);
-static unsigned int BcmGetEEPROMSize(struct bcm_mini_adapter *Adapter);
-static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter);
-static unsigned int BcmGetFlashSectorSize(struct bcm_mini_adapter *Adapter,
-                                         unsigned int FlashSectorSizeSig,
-                                         unsigned int FlashSectorSize);
-
-static VOID BcmValidateNvmType(struct bcm_mini_adapter *Adapter);
-static int BcmGetNvmSize(struct bcm_mini_adapter *Adapter);
-static unsigned int BcmGetFlashSize(struct bcm_mini_adapter *Adapter);
-static enum bcm_nvm_type BcmGetNvmType(struct bcm_mini_adapter *Adapter);
-
-static int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter,
-                                    enum bcm_flash2x_section_val eFlash2xSectionVal);
-
-static B_UINT8 IsOffsetWritable(struct bcm_mini_adapter *Adapter,
-                               unsigned int uiOffset);
-static int IsSectionWritable(struct bcm_mini_adapter *Adapter,
-                            enum bcm_flash2x_section_val Section);
-static int IsSectionExistInVendorInfo(struct bcm_mini_adapter *Adapter,
-                                     enum bcm_flash2x_section_val section);
-
-static int ReadDSDPriority(struct bcm_mini_adapter *Adapter,
-                          enum bcm_flash2x_section_val dsd);
-static int ReadDSDSignature(struct bcm_mini_adapter *Adapter,
-                           enum bcm_flash2x_section_val dsd);
-static int ReadISOPriority(struct bcm_mini_adapter *Adapter,
-                          enum bcm_flash2x_section_val iso);
-static int ReadISOSignature(struct bcm_mini_adapter *Adapter,
-                           enum bcm_flash2x_section_val iso);
-
-static int CorruptDSDSig(struct bcm_mini_adapter *Adapter,
-                        enum bcm_flash2x_section_val eFlash2xSectionVal);
-static int CorruptISOSig(struct bcm_mini_adapter *Adapter,
-                        enum bcm_flash2x_section_val eFlash2xSectionVal);
-static int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter,
-                              PUCHAR pBuff,
-                              unsigned int uiSectAlignAddr);
-static int WriteToFlashWithoutSectorErase(struct bcm_mini_adapter *Adapter,
-                                         PUINT pBuff,
-                                         enum bcm_flash2x_section_val eFlash2xSectionVal,
-                                         unsigned int uiOffset,
-                                         unsigned int uiNumBytes);
-static enum bcm_flash2x_section_val getHighestPriDSD(struct bcm_mini_adapter *Adapter);
-static enum bcm_flash2x_section_val getHighestPriISO(struct bcm_mini_adapter *Adapter);
-
-static int BeceemFlashBulkRead(
-       struct bcm_mini_adapter *Adapter,
-       PUINT pBuffer,
-       unsigned int uiOffset,
-       unsigned int uiNumBytes);
-
-static int BeceemFlashBulkWrite(
-       struct bcm_mini_adapter *Adapter,
-       PUINT pBuffer,
-       unsigned int uiOffset,
-       unsigned int uiNumBytes,
-       bool bVerify);
-
-static int GetFlashBaseAddr(struct bcm_mini_adapter *Adapter);
-
-static int ReadBeceemEEPROMBulk(struct bcm_mini_adapter *Adapter, unsigned int dwAddress, unsigned int *pdwData, unsigned int dwNumData);
-
-/* Procedure:  ReadEEPROMStatusRegister
- *
- * Description: Reads the standard EEPROM Status Register.
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- * Returns:
- *             OSAL_STATUS_CODE
- */
-static UCHAR ReadEEPROMStatusRegister(struct bcm_mini_adapter *Adapter)
-{
-       UCHAR uiData = 0;
-       DWORD dwRetries = MAX_EEPROM_RETRIES * RETRIES_PER_DELAY;
-       unsigned int uiStatus = 0;
-       unsigned int value = 0;
-       unsigned int value1 = 0;
-
-       /* Read the EEPROM status register */
-       value = EEPROM_READ_STATUS_REGISTER;
-       wrmalt(Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value));
-
-       while (dwRetries != 0) {
-               value = 0;
-               uiStatus = 0;
-               rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &uiStatus, sizeof(uiStatus));
-               if (Adapter->device_removed == TRUE) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Modem has got removed hence exiting....");
-                       break;
-               }
-
-               /* Wait for Avail bit to be set. */
-               if ((uiStatus & EEPROM_READ_DATA_AVAIL) != 0) {
-                       /* Clear the Avail/Full bits - which ever is set. */
-                       value = uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL);
-                       wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
-
-                       value = 0;
-                       rdmalt(Adapter, EEPROM_READ_DATAQ_REG, &value, sizeof(value));
-                       uiData = (UCHAR)value;
-
-                       break;
-               }
-
-               dwRetries--;
-               if (dwRetries == 0) {
-                       rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
-                       rdmalt(Adapter, EEPROM_SPI_Q_STATUS_REG, &value1, sizeof(value1));
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "0x3004 = %x 0x3008 = %x, retries = %d failed.\n", value, value1, MAX_EEPROM_RETRIES * RETRIES_PER_DELAY);
-                       return uiData;
-               }
-               if (!(dwRetries%RETRIES_PER_DELAY))
-                       udelay(1000);
-               uiStatus = 0;
-       }
-       return uiData;
-} /* ReadEEPROMStatusRegister */
-
-/*
- * Procedure:  ReadBeceemEEPROMBulk
- *
- * Description: This routine reads 16Byte data from EEPROM
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *      dwAddress   - EEPROM Offset to read the data from.
- *      pdwData     - Pointer to double word where data needs to be stored in.  //             dwNumWords  - Number of words.  Valid values are 4 ONLY.
- *
- * Returns:
- *             OSAL_STATUS_CODE:
- */
-
-static int ReadBeceemEEPROMBulk(struct bcm_mini_adapter *Adapter,
-                       DWORD dwAddress,
-                       DWORD *pdwData,
-                       DWORD dwNumWords)
-{
-       DWORD dwIndex = 0;
-       DWORD dwRetries = MAX_EEPROM_RETRIES * RETRIES_PER_DELAY;
-       unsigned int uiStatus  = 0;
-       unsigned int value = 0;
-       unsigned int value1 = 0;
-       UCHAR *pvalue;
-
-       /* Flush the read and cmd queue. */
-       value = (EEPROM_READ_QUEUE_FLUSH | EEPROM_CMD_QUEUE_FLUSH);
-       wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value));
-       value = 0;
-       wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value));
-
-       /* Clear the Avail/Full bits. */
-       value = (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL);
-       wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
-
-       value = dwAddress | ((dwNumWords == 4) ? EEPROM_16_BYTE_PAGE_READ : EEPROM_4_BYTE_PAGE_READ);
-       wrmalt(Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value));
-
-       while (dwRetries != 0) {
-               uiStatus = 0;
-               rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &uiStatus, sizeof(uiStatus));
-               if (Adapter->device_removed == TRUE) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Modem has got Removed.hence exiting from loop...");
-                       return -ENODEV;
-               }
-
-               /* If we are reading 16 bytes we want to be sure that the queue
-                * is full before we read.  In the other cases we are ok if the
-                * queue has data available
-                */
-               if (dwNumWords == 4) {
-                       if ((uiStatus & EEPROM_READ_DATA_FULL) != 0) {
-                               /* Clear the Avail/Full bits - which ever is set. */
-                               value = (uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL));
-                               wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
-                               break;
-                       }
-               } else if (dwNumWords == 1) {
-                       if ((uiStatus & EEPROM_READ_DATA_AVAIL) != 0) {
-                               /* We just got Avail and we have to read 32bits so we
-                                * need this sleep for Cardbus kind of devices.
-                                */
-                               if (Adapter->chip_id == 0xBECE0210)
-                                       udelay(800);
-
-                               /* Clear the Avail/Full bits - which ever is set. */
-                               value = (uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL));
-                               wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
-                               break;
-                       }
-               }
-
-               uiStatus = 0;
-
-               dwRetries--;
-               if (dwRetries == 0) {
-                       value = 0;
-                       value1 = 0;
-                       rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
-                       rdmalt(Adapter, EEPROM_SPI_Q_STATUS_REG, &value1, sizeof(value1));
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "dwNumWords %d 0x3004 = %x 0x3008 = %x  retries = %d failed.\n",
-                                       dwNumWords, value,  value1,  MAX_EEPROM_RETRIES * RETRIES_PER_DELAY);
-                       return STATUS_FAILURE;
-               }
-
-               if (!(dwRetries%RETRIES_PER_DELAY))
-                       udelay(1000);
-       }
-
-       for (dwIndex = 0; dwIndex < dwNumWords; dwIndex++) {
-               /* We get only a byte at a time - from LSB to MSB. We shift it into an integer. */
-               pvalue = (PUCHAR)(pdwData + dwIndex);
-
-               value = 0;
-               rdmalt(Adapter, EEPROM_READ_DATAQ_REG, &value, sizeof(value));
-
-               pvalue[0] = value;
-
-               value = 0;
-               rdmalt(Adapter, EEPROM_READ_DATAQ_REG, &value, sizeof(value));
-
-               pvalue[1] = value;
-
-               value = 0;
-               rdmalt(Adapter, EEPROM_READ_DATAQ_REG, &value, sizeof(value));
-
-               pvalue[2] = value;
-
-               value = 0;
-               rdmalt(Adapter, EEPROM_READ_DATAQ_REG, &value, sizeof(value));
-
-               pvalue[3] = value;
-       }
-
-       return STATUS_SUCCESS;
-} /* ReadBeceemEEPROMBulk() */
-
-/*
- * Procedure:  ReadBeceemEEPROM
- *
- * Description: This routine reads 4 data from EEPROM.  It uses 1 or 2 page
- *                             reads to do this operation.
- *
- * Arguments:
- *             Adapter     - ptr to Adapter object instance
- *      uiOffset       - EEPROM Offset to read the data from.
- *      pBuffer                - Pointer to word where data needs to be stored in.
- *
- * Returns:
- *             OSAL_STATUS_CODE:
- */
-
-int ReadBeceemEEPROM(struct bcm_mini_adapter *Adapter,
-               DWORD uiOffset,
-               DWORD *pBuffer)
-{
-       unsigned int uiData[8]          = {0};
-       unsigned int uiByteOffset       = 0;
-       unsigned int uiTempOffset       = 0;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " ====> ");
-
-       uiTempOffset = uiOffset - (uiOffset % MAX_RW_SIZE);
-       uiByteOffset = uiOffset - uiTempOffset;
-
-       ReadBeceemEEPROMBulk(Adapter, uiTempOffset, (PUINT)&uiData[0], 4);
-
-       /* A word can overlap at most over 2 pages. In that case we read the
-        * next page too.
-        */
-       if (uiByteOffset > 12)
-               ReadBeceemEEPROMBulk(Adapter, uiTempOffset + MAX_RW_SIZE, (PUINT)&uiData[4], 4);
-
-       memcpy((PUCHAR)pBuffer, (((PUCHAR)&uiData[0]) + uiByteOffset), 4);
-
-       return STATUS_SUCCESS;
-} /* ReadBeceemEEPROM() */
-
-int ReadMacAddressFromNVM(struct bcm_mini_adapter *Adapter)
-{
-       int Status;
-       unsigned char puMacAddr[6];
-
-       Status = BeceemNVMRead(Adapter,
-                       (PUINT)&puMacAddr[0],
-                       INIT_PARAMS_1_MACADDRESS_ADDRESS,
-                       MAC_ADDRESS_SIZE);
-
-       if (Status == STATUS_SUCCESS)
-               memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE);
-
-       return Status;
-}
-
-/*
- * Procedure:  BeceemEEPROMBulkRead
- *
- * Description: Reads the EEPROM and returns the Data.
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *             pBuffer    - Buffer to store the data read from EEPROM
- *             uiOffset   - Offset of EEPROM from where data should be read
- *             uiNumBytes - Number of bytes to be read from the EEPROM.
- *
- * Returns:
- *             OSAL_STATUS_SUCCESS - if EEPROM read is successful.
- *             <FAILURE>                       - if failed.
- */
-
-int BeceemEEPROMBulkRead(struct bcm_mini_adapter *Adapter,
-                       PUINT pBuffer,
-                       unsigned int uiOffset,
-                       unsigned int uiNumBytes)
-{
-       unsigned int uiData[4]          = {0};
-       /* unsigned int uiAddress       = 0; */
-       unsigned int uiBytesRemaining   = uiNumBytes;
-       unsigned int uiIndex            = 0;
-       unsigned int uiTempOffset       = 0;
-       unsigned int uiExtraBytes       = 0;
-       unsigned int uiFailureRetries   = 0;
-       PUCHAR pcBuff = (PUCHAR)pBuffer;
-
-       if (uiOffset % MAX_RW_SIZE && uiBytesRemaining) {
-               uiTempOffset = uiOffset - (uiOffset % MAX_RW_SIZE);
-               uiExtraBytes = uiOffset - uiTempOffset;
-               ReadBeceemEEPROMBulk(Adapter, uiTempOffset, (PUINT)&uiData[0], 4);
-               if (uiBytesRemaining >= (MAX_RW_SIZE - uiExtraBytes)) {
-                       memcpy(pBuffer, (((PUCHAR)&uiData[0]) + uiExtraBytes), MAX_RW_SIZE - uiExtraBytes);
-                       uiBytesRemaining -= (MAX_RW_SIZE - uiExtraBytes);
-                       uiIndex += (MAX_RW_SIZE - uiExtraBytes);
-                       uiOffset += (MAX_RW_SIZE - uiExtraBytes);
-               } else {
-                       memcpy(pBuffer, (((PUCHAR)&uiData[0]) + uiExtraBytes), uiBytesRemaining);
-                       uiIndex += uiBytesRemaining;
-                       uiOffset += uiBytesRemaining;
-                       uiBytesRemaining = 0;
-               }
-       }
-
-       while (uiBytesRemaining && uiFailureRetries != 128) {
-               if (Adapter->device_removed)
-                       return -1;
-
-               if (uiBytesRemaining >= MAX_RW_SIZE) {
-                       /* For the requests more than or equal to 16 bytes, use bulk
-                        * read function to make the access faster.
-                        * We read 4 Dwords of data
-                        */
-                       if (ReadBeceemEEPROMBulk(Adapter, uiOffset, &uiData[0], 4) == 0) {
-                               memcpy(pcBuff + uiIndex, &uiData[0], MAX_RW_SIZE);
-                               uiOffset += MAX_RW_SIZE;
-                               uiBytesRemaining -= MAX_RW_SIZE;
-                               uiIndex += MAX_RW_SIZE;
-                       } else {
-                               uiFailureRetries++;
-                               mdelay(3); /* sleep for a while before retry... */
-                       }
-               } else if (uiBytesRemaining >= 4) {
-                       if (ReadBeceemEEPROM(Adapter, uiOffset, &uiData[0]) == 0) {
-                               memcpy(pcBuff + uiIndex, &uiData[0], 4);
-                               uiOffset += 4;
-                               uiBytesRemaining -= 4;
-                               uiIndex += 4;
-                       } else {
-                               uiFailureRetries++;
-                               mdelay(3); /* sleep for a while before retry... */
-                       }
-               } else {
-                       /* Handle the reads less than 4 bytes... */
-                       PUCHAR pCharBuff = (PUCHAR)pBuffer;
-
-                       pCharBuff += uiIndex;
-                       if (ReadBeceemEEPROM(Adapter, uiOffset, &uiData[0]) == 0) {
-                               memcpy(pCharBuff, &uiData[0], uiBytesRemaining); /* copy only bytes requested. */
-                               uiBytesRemaining = 0;
-                       } else {
-                               uiFailureRetries++;
-                               mdelay(3); /* sleep for a while before retry... */
-                       }
-               }
-       }
-
-       return 0;
-}
-
-/*
- * Procedure:  BeceemFlashBulkRead
- *
- * Description: Reads the FLASH and returns the Data.
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *             pBuffer    - Buffer to store the data read from FLASH
- *             uiOffset   - Offset of FLASH from where data should be read
- *             uiNumBytes - Number of bytes to be read from the FLASH.
- *
- * Returns:
- *             OSAL_STATUS_SUCCESS - if FLASH read is successful.
- *             <FAILURE>                       - if failed.
- */
-
-static int BeceemFlashBulkRead(struct bcm_mini_adapter *Adapter,
-                       PUINT pBuffer,
-                       unsigned int uiOffset,
-                       unsigned int uiNumBytes)
-{
-       unsigned int uiIndex = 0;
-       unsigned int uiBytesToRead = uiNumBytes;
-       int Status = 0;
-       unsigned int uiPartOffset = 0;
-       int bytes;
-
-       if (Adapter->device_removed) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device Got Removed");
-               return -ENODEV;
-       }
-
-       /* Adding flash Base address
-        * uiOffset = uiOffset + GetFlashBaseAddr(Adapter);
-        */
-       #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
-               Status = bcmflash_raw_read((uiOffset/FLASH_PART_SIZE), (uiOffset % FLASH_PART_SIZE), (unsigned char *)pBuffer, uiNumBytes);
-               return Status;
-       #endif
-
-       Adapter->SelectedChip = RESET_CHIP_SELECT;
-
-       if (uiOffset % MAX_RW_SIZE) {
-               BcmDoChipSelect(Adapter, uiOffset);
-               uiPartOffset = (uiOffset & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter);
-
-               uiBytesToRead = MAX_RW_SIZE - (uiOffset % MAX_RW_SIZE);
-               uiBytesToRead = MIN(uiNumBytes, uiBytesToRead);
-
-               bytes = rdm(Adapter, uiPartOffset, (PCHAR)pBuffer + uiIndex, uiBytesToRead);
-               if (bytes < 0) {
-                       Status = bytes;
-                       Adapter->SelectedChip = RESET_CHIP_SELECT;
-                       return Status;
-               }
-
-               uiIndex += uiBytesToRead;
-               uiOffset += uiBytesToRead;
-               uiNumBytes -= uiBytesToRead;
-       }
-
-       while (uiNumBytes) {
-               BcmDoChipSelect(Adapter, uiOffset);
-               uiPartOffset = (uiOffset & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter);
-
-               uiBytesToRead = MIN(uiNumBytes, MAX_RW_SIZE);
-
-               bytes = rdm(Adapter, uiPartOffset, (PCHAR)pBuffer + uiIndex, uiBytesToRead);
-               if (bytes < 0) {
-                       Status = bytes;
-                       break;
-               }
-
-               uiIndex += uiBytesToRead;
-               uiOffset += uiBytesToRead;
-               uiNumBytes -= uiBytesToRead;
-       }
-       Adapter->SelectedChip = RESET_CHIP_SELECT;
-       return Status;
-}
-
-/*
- * Procedure:  BcmGetFlashSize
- *
- * Description: Finds the size of FLASH.
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *
- * Returns:
- *             unsigned int - size of the FLASH Storage.
- *
- */
-
-static unsigned int BcmGetFlashSize(struct bcm_mini_adapter *Adapter)
-{
-       if (IsFlash2x(Adapter))
-               return Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header);
-       else
-               return 32 * 1024;
-}
-
-/*
- * Procedure:  BcmGetEEPROMSize
- *
- * Description: Finds the size of EEPROM.
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *
- * Returns:
- *             unsigned int - size of the EEPROM Storage.
- *
- */
-
-static unsigned int BcmGetEEPROMSize(struct bcm_mini_adapter *Adapter)
-{
-       unsigned int uiData = 0;
-       unsigned int uiIndex = 0;
-
-       /*
-        * if EEPROM is present and already Calibrated,it will have
-        * 'BECM' string at 0th offset.
-        * To find the EEPROM size read the possible boundaries of the
-        * EEPROM like 4K,8K etc..accessing the EEPROM beyond its size will
-        * result in wrap around. So when we get the End of the EEPROM we will
-        * get 'BECM' string which is indeed at offset 0.
-        */
-       BeceemEEPROMBulkRead(Adapter, &uiData, 0x0, 4);
-       if (uiData == BECM) {
-               for (uiIndex = 2; uiIndex <= 256; uiIndex *= 2) {
-                       BeceemEEPROMBulkRead(Adapter, &uiData, uiIndex * 1024, 4);
-                       if (uiData == BECM)
-                               return uiIndex * 1024;
-               }
-       } else {
-               /*
-                * EEPROM may not be present or not programmed
-                */
-               uiData = 0xBABEFACE;
-               if (BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&uiData, 0, 4, TRUE) == 0) {
-                       uiData = 0;
-                       for (uiIndex = 2; uiIndex <= 256; uiIndex *= 2) {
-                               BeceemEEPROMBulkRead(Adapter, &uiData, uiIndex * 1024, 4);
-                               if (uiData == 0xBABEFACE)
-                                       return uiIndex * 1024;
-                       }
-               }
-       }
-       return 0;
-}
-
-/*
- * Procedure:  FlashSectorErase
- *
- * Description: Finds the sector size of the FLASH.
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *             addr       - sector start address
- *             numOfSectors - number of sectors to  be erased.
- *
- * Returns:
- *             OSAL_STATUS_CODE
- *
- */
-
-static int FlashSectorErase(struct bcm_mini_adapter *Adapter,
-                       unsigned int addr,
-                       unsigned int numOfSectors)
-{
-       unsigned int iIndex = 0, iRetries = 0;
-       unsigned int uiStatus = 0;
-       unsigned int value;
-       int bytes;
-
-       for (iIndex = 0; iIndex < numOfSectors; iIndex++) {
-               value = 0x06000000;
-               wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value));
-
-               value = (0xd8000000 | (addr & 0xFFFFFF));
-               wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value));
-               iRetries = 0;
-
-               do {
-                       value = (FLASH_CMD_STATUS_REG_READ << 24);
-                       if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails");
-                               return STATUS_FAILURE;
-                       }
-
-                       bytes = rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus));
-                       if (bytes < 0) {
-                               uiStatus = bytes;
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reading status of FLASH_SPI_READQ_REG fails");
-                               return uiStatus;
-                       }
-                       iRetries++;
-                       /* After every try lets make the CPU free for 10 ms. generally time taken by the
-                        * the sector erase cycle is 500 ms to 40000 msec. hence sleeping 10 ms
-                        * won't hamper performance in any case.
-                        */
-                       mdelay(10);
-               } while ((uiStatus & 0x1) && (iRetries < 400));
-
-               if (uiStatus & 0x1) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "iRetries crossing the limit of 80000\n");
-                       return STATUS_FAILURE;
-               }
-
-               addr += Adapter->uiSectorSize;
-       }
-       return 0;
-}
-/*
- * Procedure:  flashByteWrite
- *
- * Description: Performs Byte by Byte write to flash
- *
- * Arguments:
- *             Adapter   - ptr to Adapter object instance
- *             uiOffset   - Offset of the flash where data needs to be written to.
- *             pData   - Address of Data to be written.
- * Returns:
- *             OSAL_STATUS_CODE
- *
- */
-
-static int flashByteWrite(struct bcm_mini_adapter *Adapter,
-                       unsigned int uiOffset,
-                       PVOID pData)
-{
-       unsigned int uiStatus = 0;
-       int  iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; /* 3 */
-       unsigned int value;
-       ULONG ulData = *(PUCHAR)pData;
-       int bytes;
-       /*
-        * need not write 0xFF because write requires an erase and erase will
-        * make whole sector 0xFF.
-        */
-
-       if (0xFF == ulData)
-               return STATUS_SUCCESS;
-
-       /* DumpDebug(NVM_RW,("flashWrite ====>\n")); */
-       value = (FLASH_CMD_WRITE_ENABLE << 24);
-       if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write enable in FLASH_SPI_CMDQ_REG register fails");
-               return STATUS_FAILURE;
-       }
-
-       if (wrm(Adapter, FLASH_SPI_WRITEQ_REG, (PCHAR)&ulData, 4) < 0) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "DATA Write on FLASH_SPI_WRITEQ_REG fails");
-               return STATUS_FAILURE;
-       }
-       value = (0x02000000 | (uiOffset & 0xFFFFFF));
-       if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programming of FLASH_SPI_CMDQ_REG fails");
-               return STATUS_FAILURE;
-       }
-
-       /* __udelay(950); */
-
-       do {
-               value = (FLASH_CMD_STATUS_REG_READ << 24);
-               if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails");
-                       return STATUS_FAILURE;
-               }
-               /* __udelay(1); */
-               bytes = rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus));
-               if (bytes < 0) {
-                       uiStatus = bytes;
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reading status of FLASH_SPI_READQ_REG fails");
-                       return uiStatus;
-               }
-               iRetries--;
-               if (iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0))
-                       udelay(1000);
-
-       } while ((uiStatus & 0x1) && (iRetries  > 0));
-
-       if (uiStatus & 0x1) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Write fails even after checking status for 200 times.");
-               return STATUS_FAILURE;
-       }
-
-       return STATUS_SUCCESS;
-}
-
-/*
- * Procedure:  flashWrite
- *
- * Description: Performs write to flash
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *             uiOffset   - Offset of the flash where data needs to be written to.
- *             pData   - Address of Data to be written.
- * Returns:
- *             OSAL_STATUS_CODE
- *
- */
-
-static int flashWrite(struct bcm_mini_adapter *Adapter,
-               unsigned int uiOffset,
-               PVOID pData)
-{
-       /* unsigned int uiStatus = 0;
-        * int  iRetries = 0;
-        * unsigned int uiReadBack = 0;
-        */
-       unsigned int uiStatus = 0;
-       int  iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; /* 3 */
-       unsigned int value;
-       unsigned int uiErasePattern[4] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF};
-       int bytes;
-       /*
-        * need not write 0xFFFFFFFF because write requires an erase and erase will
-        * make whole sector 0xFFFFFFFF.
-        */
-       if (!memcmp(pData, uiErasePattern, MAX_RW_SIZE))
-               return 0;
-
-       value = (FLASH_CMD_WRITE_ENABLE << 24);
-
-       if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write Enable of FLASH_SPI_CMDQ_REG fails");
-               return STATUS_FAILURE;
-       }
-
-       if (wrm(Adapter, uiOffset, (PCHAR)pData, MAX_RW_SIZE) < 0) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Data write fails...");
-               return STATUS_FAILURE;
-       }
-
-       /* __udelay(950); */
-       do {
-               value = (FLASH_CMD_STATUS_REG_READ << 24);
-               if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails");
-                       return STATUS_FAILURE;
-               }
-               /* __udelay(1); */
-               bytes = rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus));
-               if (bytes < 0) {
-                       uiStatus = bytes;
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reading status of FLASH_SPI_READQ_REG fails");
-                       return uiStatus;
-               }
-
-               iRetries--;
-               /* this will ensure that in there will be no changes in the current path.
-                * currently one rdm/wrm takes 125 us.
-                * Hence  125 *2 * FLASH_PER_RETRIES_DELAY > 3 ms(worst case delay)
-                * Hence current implementation cycle will intoduce no delay in current path
-                */
-               if (iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0))
-                       udelay(1000);
-       } while ((uiStatus & 0x1) && (iRetries > 0));
-
-       if (uiStatus & 0x1) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Write fails even after checking status for 200 times.");
-               return STATUS_FAILURE;
-       }
-
-       return STATUS_SUCCESS;
-}
-
-/*-----------------------------------------------------------------------------
- * Procedure:  flashByteWriteStatus
- *
- * Description: Performs byte by byte write to flash with write done status check
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *             uiOffset    - Offset of the flash where data needs to be written to.
- *             pData    - Address of the Data to be written.
- * Returns:
- *             OSAL_STATUS_CODE
- *
- */
-static int flashByteWriteStatus(struct bcm_mini_adapter *Adapter,
-                               unsigned int uiOffset,
-                               PVOID pData)
-{
-       unsigned int uiStatus = 0;
-       int  iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; /* 3 */
-       ULONG ulData  = *(PUCHAR)pData;
-       unsigned int value;
-       int bytes;
-
-       /*
-        * need not write 0xFFFFFFFF because write requires an erase and erase will
-        * make whole sector 0xFFFFFFFF.
-        */
-
-       if (0xFF == ulData)
-               return STATUS_SUCCESS;
-
-       /* DumpDebug(NVM_RW,("flashWrite ====>\n")); */
-
-       value = (FLASH_CMD_WRITE_ENABLE << 24);
-       if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write enable in FLASH_SPI_CMDQ_REG register fails");
-               return STATUS_SUCCESS;
-       }
-       if (wrm(Adapter, FLASH_SPI_WRITEQ_REG, (PCHAR)&ulData, 4) < 0) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "DATA Write on FLASH_SPI_WRITEQ_REG fails");
-               return STATUS_FAILURE;
-       }
-       value = (0x02000000 | (uiOffset & 0xFFFFFF));
-       if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programming of FLASH_SPI_CMDQ_REG fails");
-               return STATUS_FAILURE;
-       }
-
-       /* msleep(1); */
-
-       do {
-               value = (FLASH_CMD_STATUS_REG_READ << 24);
-               if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails");
-                       return STATUS_FAILURE;
-               }
-               /* __udelay(1); */
-               bytes = rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus));
-               if (bytes < 0) {
-                       uiStatus = bytes;
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reading status of FLASH_SPI_READQ_REG fails");
-                       return uiStatus;
-               }
-
-               iRetries--;
-               if (iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0))
-                       udelay(1000);
-
-       } while ((uiStatus & 0x1) && (iRetries > 0));
-
-       if (uiStatus & 0x1) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Write fails even after checking status for 200 times.");
-               return STATUS_FAILURE;
-       }
-
-       return STATUS_SUCCESS;
-}
-/*
- * Procedure:  flashWriteStatus
- *
- * Description: Performs write to flash with write done status check
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *             uiOffset    - Offset of the flash where data needs to be written to.
- *             pData    - Address of the Data to be written.
- * Returns:
- *             OSAL_STATUS_CODE
- *
- */
-
-static int flashWriteStatus(struct bcm_mini_adapter *Adapter,
-                       unsigned int uiOffset,
-                       PVOID pData)
-{
-       unsigned int uiStatus = 0;
-       int  iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; /* 3 */
-       /* unsigned int uiReadBack = 0; */
-       unsigned int value;
-       unsigned int uiErasePattern[4] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF};
-       int bytes;
-
-       /*
-        * need not write 0xFFFFFFFF because write requires an erase and erase will
-        * make whole sector 0xFFFFFFFF.
-        */
-       if (!memcmp(pData, uiErasePattern, MAX_RW_SIZE))
-               return 0;
-
-       value = (FLASH_CMD_WRITE_ENABLE << 24);
-       if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write Enable of FLASH_SPI_CMDQ_REG fails");
-               return STATUS_FAILURE;
-       }
-
-       if (wrm(Adapter, uiOffset, (PCHAR)pData, MAX_RW_SIZE) < 0) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Data write fails...");
-               return STATUS_FAILURE;
-       }
-       /* __udelay(1); */
-
-       do {
-               value = (FLASH_CMD_STATUS_REG_READ << 24);
-               if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails");
-                       return STATUS_FAILURE;
-               }
-               /* __udelay(1); */
-               bytes = rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus));
-               if (bytes < 0) {
-                       uiStatus = bytes;
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reading status of FLASH_SPI_READQ_REG fails");
-                       return uiStatus;
-               }
-               iRetries--;
-               /* this will ensure that in there will be no changes in the current path.
-                * currently one rdm/wrm takes 125 us.
-                * Hence  125 *2  * FLASH_PER_RETRIES_DELAY  >3 ms(worst case delay)
-                * Hence current implementation cycle will intoduce no delay in current path
-                */
-               if (iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0))
-                       udelay(1000);
-
-       } while ((uiStatus & 0x1) && (iRetries > 0));
-
-       if (uiStatus & 0x1) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Write fails even after checking status for 200 times.");
-               return STATUS_FAILURE;
-       }
-
-       return STATUS_SUCCESS;
-}
-
-/*
- * Procedure:  BcmRestoreBlockProtectStatus
- *
- * Description: Restores the original block protection status.
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *             ulWriteStatus   -Original status
- * Returns:
- *             <VOID>
- *
- */
-
-static VOID BcmRestoreBlockProtectStatus(struct bcm_mini_adapter *Adapter, ULONG ulWriteStatus)
-{
-       unsigned int value;
-
-       value = (FLASH_CMD_WRITE_ENABLE << 24);
-       wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value));
-
-       udelay(20);
-       value = (FLASH_CMD_STATUS_REG_WRITE << 24) | (ulWriteStatus << 16);
-       wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value));
-       udelay(20);
-}
-
-/*
- * Procedure:  BcmFlashUnProtectBlock
- *
- * Description: UnProtects appropriate blocks for writing.
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *             uiOffset   - Offset of the flash where data needs to be written to. This should be Sector aligned.
- * Returns:
- *             ULONG   - Status value before UnProtect.
- *
- */
-
-static ULONG BcmFlashUnProtectBlock(struct bcm_mini_adapter *Adapter, unsigned int uiOffset, unsigned int uiLength)
-{
-       ULONG ulStatus          = 0;
-       ULONG ulWriteStatus     = 0;
-       unsigned int value;
-
-       uiOffset = uiOffset&0x000FFFFF;
-       /*
-        * Implemented only for 1MB Flash parts.
-        */
-       if (FLASH_PART_SST25VF080B == Adapter->ulFlashID) {
-               /*
-                * Get Current BP status.
-                */
-               value = (FLASH_CMD_STATUS_REG_READ << 24);
-               wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value));
-               udelay(10);
-               /*
-                * Read status will be WWXXYYZZ. We have to take only WW.
-                */
-               rdmalt(Adapter, FLASH_SPI_READQ_REG, (PUINT)&ulStatus, sizeof(ulStatus));
-               ulStatus >>= 24;
-               ulWriteStatus = ulStatus;
-               /*
-                * Bits [5-2] give current block level protection status.
-                * Bit5: BP3 - DONT CARE
-                * BP2-BP0: 0 - NO PROTECTION, 1 - UPPER 1/16, 2 - UPPER 1/8, 3 - UPPER 1/4
-                *                4 - UPPER 1/2. 5 to 7 - ALL BLOCKS
-                */
-
-               if (ulStatus) {
-                       if ((uiOffset+uiLength) <= 0x80000) {
-                               /*
-                                * Offset comes in lower half of 1MB. Protect the upper half.
-                                * Clear BP1 and BP0 and set BP2.
-                                */
-                               ulWriteStatus |= (0x4<<2);
-                               ulWriteStatus &= ~(0x3<<2);
-                       } else if ((uiOffset + uiLength) <= 0xC0000) {
-                               /*
-                                * Offset comes below Upper 1/4. Upper 1/4 can be protected.
-                                *  Clear BP2 and set BP1 and BP0.
-                                */
-                               ulWriteStatus |= (0x3<<2);
-                               ulWriteStatus &= ~(0x1<<4);
-                       } else if ((uiOffset + uiLength) <= 0xE0000) {
-                               /*
-                                * Offset comes below Upper 1/8. Upper 1/8 can be protected.
-                                * Clear BP2 and BP0  and set BP1
-                                */
-                               ulWriteStatus |= (0x1<<3);
-                               ulWriteStatus &= ~(0x5<<2);
-                       } else if ((uiOffset + uiLength) <= 0xF0000) {
-                               /*
-                                * Offset comes below Upper 1/16. Only upper 1/16 can be protected.
-                                * Set BP0 and Clear BP2,BP1.
-                                */
-                               ulWriteStatus |= (0x1<<2);
-                               ulWriteStatus &= ~(0x3<<3);
-                       } else {
-                               /*
-                                * Unblock all.
-                                * Clear BP2,BP1 and BP0.
-                                */
-                               ulWriteStatus &= ~(0x7<<2);
-                       }
-
-                       value = (FLASH_CMD_WRITE_ENABLE << 24);
-                       wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value));
-                       udelay(20);
-                       value = (FLASH_CMD_STATUS_REG_WRITE << 24) | (ulWriteStatus << 16);
-                       wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value));
-                       udelay(20);
-               }
-       }
-       return ulStatus;
-}
-
-static int bulk_read_complete_sector(struct bcm_mini_adapter *ad,
-                                    UCHAR read_bk[],
-                                    PCHAR tmpbuff,
-                                    unsigned int offset,
-                                    unsigned int partoff)
-{
-       unsigned int i;
-       int j;
-       int bulk_read_stat;
-       FP_FLASH_WRITE_STATUS writef =
-               ad->fpFlashWriteWithStatusCheck;
-
-       for (i = 0; i < ad->uiSectorSize; i += MAX_RW_SIZE) {
-               bulk_read_stat = BeceemFlashBulkRead(ad,
-                                                    (PUINT)read_bk,
-                                                    offset + i,
-                                                    MAX_RW_SIZE);
-
-               if (bulk_read_stat != STATUS_SUCCESS)
-                       continue;
-
-               if (ad->ulFlashWriteSize == 1) {
-                       for (j = 0; j < 16; j++) {
-                               if ((read_bk[j] != tmpbuff[i + j]) &&
-                                   (STATUS_SUCCESS != (*writef)(ad, partoff + i + j, &tmpbuff[i + j]))) {
-                                       return STATUS_FAILURE;
-                               }
-                       }
-               } else {
-                       if ((memcmp(read_bk, &tmpbuff[i], MAX_RW_SIZE)) &&
-                           (STATUS_SUCCESS != (*writef)(ad, partoff + i, &tmpbuff[i]))) {
-                               return STATUS_FAILURE;
-                       }
-               }
-       }
-
-       return STATUS_SUCCESS;
-}
-
-/*
- * Procedure:  BeceemFlashBulkWrite
- *
- * Description: Performs write to the flash
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- * pBuffer - Data to be written.
- *             uiOffset   - Offset of the flash where data needs to be written to.
- *             uiNumBytes - Number of bytes to be written.
- *             bVerify    - read verify flag.
- * Returns:
- *             OSAL_STATUS_CODE
- *
- */
-
-static int BeceemFlashBulkWrite(struct bcm_mini_adapter *Adapter,
-                               PUINT pBuffer,
-                               unsigned int uiOffset,
-                               unsigned int uiNumBytes,
-                               bool bVerify)
-{
-       PCHAR pTempBuff                 = NULL;
-       PUCHAR pcBuffer                 = (PUCHAR)pBuffer;
-       unsigned int uiIndex                    = 0;
-       unsigned int uiOffsetFromSectStart      = 0;
-       unsigned int uiSectAlignAddr            = 0;
-       unsigned int uiCurrSectOffsetAddr       = 0;
-       unsigned int uiSectBoundary             = 0;
-       unsigned int uiNumSectTobeRead          = 0;
-       UCHAR ucReadBk[16]              = {0};
-       ULONG ulStatus                  = 0;
-       int Status                      = STATUS_SUCCESS;
-       unsigned int uiTemp                     = 0;
-       unsigned int index                      = 0;
-       unsigned int uiPartOffset               = 0;
-
-       #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
-               Status = bcmflash_raw_write((uiOffset / FLASH_PART_SIZE), (uiOffset % FLASH_PART_SIZE), (unsigned char *)pBuffer, uiNumBytes);
-               return Status;
-       #endif
-
-       uiOffsetFromSectStart = uiOffset & ~(Adapter->uiSectorSize - 1);
-
-       /* Adding flash Base address
-        * uiOffset = uiOffset + GetFlashBaseAddr(Adapter);
-        */
-
-       uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1);
-       uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1);
-       uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize;
-
-       pTempBuff = kmalloc(Adapter->uiSectorSize, GFP_KERNEL);
-       if (!pTempBuff)
-               goto BeceemFlashBulkWrite_EXIT;
-       /*
-        * check if the data to be written is overlapped across sectors
-        */
-       if (uiOffset+uiNumBytes < uiSectBoundary) {
-               uiNumSectTobeRead = 1;
-       } else {
-               /* Number of sectors  = Last sector start address/First sector start address */
-               uiNumSectTobeRead =  (uiCurrSectOffsetAddr + uiNumBytes) / Adapter->uiSectorSize;
-               if ((uiCurrSectOffsetAddr + uiNumBytes)%Adapter->uiSectorSize)
-                       uiNumSectTobeRead++;
-       }
-       /* Check whether Requested sector is writable or not in case of flash2x write. But if  write call is
-        * for DSD calibration, allow it without checking of sector permission
-        */
-
-       if (IsFlash2x(Adapter) && (Adapter->bAllDSDWriteAllow == false)) {
-               index = 0;
-               uiTemp = uiNumSectTobeRead;
-               while (uiTemp) {
-                       if (IsOffsetWritable(Adapter, uiOffsetFromSectStart + index * Adapter->uiSectorSize) == false) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Sector Starting at offset <0X%X> is not writable",
-                                               (uiOffsetFromSectStart + index * Adapter->uiSectorSize));
-                               Status = SECTOR_IS_NOT_WRITABLE;
-                               goto BeceemFlashBulkWrite_EXIT;
-                       }
-                       uiTemp = uiTemp - 1;
-                       index = index + 1;
-               }
-       }
-       Adapter->SelectedChip = RESET_CHIP_SELECT;
-       while (uiNumSectTobeRead) {
-               /* do_gettimeofday(&tv1);
-                * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "\nTime In start of write :%ld ms\n",(tv1.tv_sec *1000 + tv1.tv_usec /1000));
-                */
-               uiPartOffset = (uiSectAlignAddr & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter);
-
-               BcmDoChipSelect(Adapter, uiSectAlignAddr);
-
-               if (0 != BeceemFlashBulkRead(Adapter,
-                                               (PUINT)pTempBuff,
-                                               uiOffsetFromSectStart,
-                                               Adapter->uiSectorSize)) {
-                       Status = -1;
-                       goto BeceemFlashBulkWrite_EXIT;
-               }
-
-               /* do_gettimeofday(&tr);
-                * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken by Read :%ld ms\n", (tr.tv_sec *1000 + tr.tv_usec/1000) - (tv1.tv_sec *1000 + tv1.tv_usec/1000));
-                */
-               ulStatus = BcmFlashUnProtectBlock(Adapter, uiSectAlignAddr, Adapter->uiSectorSize);
-
-               if (uiNumSectTobeRead > 1) {
-                       memcpy(&pTempBuff[uiCurrSectOffsetAddr], pcBuffer, uiSectBoundary - (uiSectAlignAddr + uiCurrSectOffsetAddr));
-                       pcBuffer += ((uiSectBoundary - (uiSectAlignAddr + uiCurrSectOffsetAddr)));
-                       uiNumBytes -= (uiSectBoundary - (uiSectAlignAddr + uiCurrSectOffsetAddr));
-               } else {
-                       memcpy(&pTempBuff[uiCurrSectOffsetAddr], pcBuffer, uiNumBytes);
-               }
-
-               if (IsFlash2x(Adapter))
-                       SaveHeaderIfPresent(Adapter, (PUCHAR)pTempBuff, uiOffsetFromSectStart);
-
-               FlashSectorErase(Adapter, uiPartOffset, 1);
-               /* do_gettimeofday(&te);
-                * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken by Erase :%ld ms\n", (te.tv_sec *1000 + te.tv_usec/1000) - (tr.tv_sec *1000 + tr.tv_usec/1000));
-                */
-               for (uiIndex = 0; uiIndex < Adapter->uiSectorSize; uiIndex += Adapter->ulFlashWriteSize) {
-                       if (Adapter->device_removed) {
-                               Status = -1;
-                               goto BeceemFlashBulkWrite_EXIT;
-                       }
-
-                       if (STATUS_SUCCESS != (*Adapter->fpFlashWrite)(Adapter, uiPartOffset + uiIndex, (&pTempBuff[uiIndex]))) {
-                               Status = -1;
-                               goto BeceemFlashBulkWrite_EXIT;
-                       }
-               }
-
-               /* do_gettimeofday(&tw);
-                * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken in Write  to Flash :%ld ms\n", (tw.tv_sec *1000 + tw.tv_usec/1000) - (te.tv_sec *1000 + te.tv_usec/1000));
-                */
-
-               if (STATUS_FAILURE == bulk_read_complete_sector(Adapter,
-                                                               ucReadBk,
-                                                               pTempBuff,
-                                                               uiOffsetFromSectStart,
-                                                               uiPartOffset)) {
-                       Status = STATUS_FAILURE;
-                       goto BeceemFlashBulkWrite_EXIT;
-               }
-
-               /* do_gettimeofday(&twv);
-                * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken in Write  to Flash verification :%ld ms\n", (twv.tv_sec *1000 + twv.tv_usec/1000) - (tw.tv_sec *1000 + tw.tv_usec/1000));
-                */
-               if (ulStatus) {
-                       BcmRestoreBlockProtectStatus(Adapter, ulStatus);
-                       ulStatus = 0;
-               }
-
-               uiCurrSectOffsetAddr = 0;
-               uiSectAlignAddr = uiSectBoundary;
-               uiSectBoundary += Adapter->uiSectorSize;
-               uiOffsetFromSectStart += Adapter->uiSectorSize;
-               uiNumSectTobeRead--;
-       }
-       /* do_gettimeofday(&tv2);
-        * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Time after Write :%ld ms\n",(tv2.tv_sec *1000 + tv2.tv_usec/1000));
-        * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken by in Write is :%ld ms\n", (tv2.tv_sec *1000 + tv2.tv_usec/1000) - (tv1.tv_sec *1000 + tv1.tv_usec/1000));
-        *
-        * Cleanup.
-        */
-BeceemFlashBulkWrite_EXIT:
-       if (ulStatus)
-               BcmRestoreBlockProtectStatus(Adapter, ulStatus);
-
-       kfree(pTempBuff);
-
-       Adapter->SelectedChip = RESET_CHIP_SELECT;
-       return Status;
-}
-
-/*
- * Procedure:  BeceemFlashBulkWriteStatus
- *
- * Description: Writes to Flash. Checks the SPI status after each write.
- *
- * Arguments:
- *             Adapter         - ptr to Adapter object instance
- *             pBuffer         - Data to be written.
- *             uiOffset        - Offset of the flash where data needs to be written to.
- *             uiNumBytes      - Number of bytes to be written.
- *             bVerify         - read verify flag.
- * Returns:
- *             OSAL_STATUS_CODE
- *
- */
-
-static int BeceemFlashBulkWriteStatus(struct bcm_mini_adapter *Adapter,
-                               PUINT pBuffer,
-                               unsigned int uiOffset,
-                               unsigned int uiNumBytes,
-                               bool bVerify)
-{
-       PCHAR pTempBuff                 = NULL;
-       PUCHAR pcBuffer                 = (PUCHAR)pBuffer;
-       unsigned int uiIndex                    = 0;
-       unsigned int uiOffsetFromSectStart      = 0;
-       unsigned int uiSectAlignAddr            = 0;
-       unsigned int uiCurrSectOffsetAddr       = 0;
-       unsigned int uiSectBoundary             = 0;
-       unsigned int uiNumSectTobeRead          = 0;
-       UCHAR ucReadBk[16]              = {0};
-       ULONG ulStatus                  = 0;
-       unsigned int Status                     = STATUS_SUCCESS;
-       unsigned int uiTemp                     = 0;
-       unsigned int index                      = 0;
-       unsigned int uiPartOffset               = 0;
-
-       uiOffsetFromSectStart = uiOffset & ~(Adapter->uiSectorSize - 1);
-
-       /* uiOffset += Adapter->ulFlashCalStart;
-        * Adding flash Base address
-        * uiOffset = uiOffset + GetFlashBaseAddr(Adapter);
-        */
-       uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1);
-       uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1);
-       uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize;
-
-       pTempBuff = kmalloc(Adapter->uiSectorSize, GFP_KERNEL);
-       if (!pTempBuff)
-               goto BeceemFlashBulkWriteStatus_EXIT;
-
-       /*
-        * check if the data to be written is overlapped across sectors
-        */
-       if (uiOffset+uiNumBytes < uiSectBoundary) {
-               uiNumSectTobeRead = 1;
-       } else {
-               /* Number of sectors  = Last sector start address/First sector start address */
-               uiNumSectTobeRead =  (uiCurrSectOffsetAddr + uiNumBytes) / Adapter->uiSectorSize;
-               if ((uiCurrSectOffsetAddr + uiNumBytes)%Adapter->uiSectorSize)
-                       uiNumSectTobeRead++;
-       }
-
-       if (IsFlash2x(Adapter) && (Adapter->bAllDSDWriteAllow == false)) {
-               index = 0;
-               uiTemp = uiNumSectTobeRead;
-               while (uiTemp) {
-                       if (IsOffsetWritable(Adapter, uiOffsetFromSectStart + index * Adapter->uiSectorSize) == false) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Sector Starting at offset <0X%x> is not writable",
-                                               (uiOffsetFromSectStart + index * Adapter->uiSectorSize));
-                               Status = SECTOR_IS_NOT_WRITABLE;
-                               goto BeceemFlashBulkWriteStatus_EXIT;
-                       }
-                       uiTemp = uiTemp - 1;
-                       index = index + 1;
-               }
-       }
-
-       Adapter->SelectedChip = RESET_CHIP_SELECT;
-       while (uiNumSectTobeRead) {
-               uiPartOffset = (uiSectAlignAddr & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter);
-
-               BcmDoChipSelect(Adapter, uiSectAlignAddr);
-               if (0 != BeceemFlashBulkRead(Adapter,
-                                               (PUINT)pTempBuff,
-                                               uiOffsetFromSectStart,
-                                               Adapter->uiSectorSize)) {
-                       Status = -1;
-                       goto BeceemFlashBulkWriteStatus_EXIT;
-               }
-
-               ulStatus = BcmFlashUnProtectBlock(Adapter, uiOffsetFromSectStart, Adapter->uiSectorSize);
-
-               if (uiNumSectTobeRead > 1) {
-                       memcpy(&pTempBuff[uiCurrSectOffsetAddr], pcBuffer, uiSectBoundary - (uiSectAlignAddr + uiCurrSectOffsetAddr));
-                       pcBuffer += ((uiSectBoundary - (uiSectAlignAddr + uiCurrSectOffsetAddr)));
-                       uiNumBytes -= (uiSectBoundary - (uiSectAlignAddr + uiCurrSectOffsetAddr));
-               } else {
-                       memcpy(&pTempBuff[uiCurrSectOffsetAddr], pcBuffer, uiNumBytes);
-               }
-
-               if (IsFlash2x(Adapter))
-                       SaveHeaderIfPresent(Adapter, (PUCHAR)pTempBuff, uiOffsetFromSectStart);
-
-               FlashSectorErase(Adapter, uiPartOffset, 1);
-
-               for (uiIndex = 0; uiIndex < Adapter->uiSectorSize; uiIndex += Adapter->ulFlashWriteSize) {
-                       if (Adapter->device_removed) {
-                               Status = -1;
-                               goto BeceemFlashBulkWriteStatus_EXIT;
-                       }
-
-                       if (STATUS_SUCCESS != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter, uiPartOffset+uiIndex, &pTempBuff[uiIndex])) {
-                               Status = -1;
-                               goto BeceemFlashBulkWriteStatus_EXIT;
-                       }
-               }
-
-               if (bVerify) {
-                       for (uiIndex = 0; uiIndex < Adapter->uiSectorSize; uiIndex += MAX_RW_SIZE) {
-                               if (STATUS_SUCCESS == BeceemFlashBulkRead(Adapter, (PUINT)ucReadBk, uiOffsetFromSectStart + uiIndex, MAX_RW_SIZE)) {
-                                       if (memcmp(ucReadBk, &pTempBuff[uiIndex], MAX_RW_SIZE)) {
-                                               Status = STATUS_FAILURE;
-                                               goto BeceemFlashBulkWriteStatus_EXIT;
-                                       }
-                               }
-                       }
-               }
-
-               if (ulStatus) {
-                       BcmRestoreBlockProtectStatus(Adapter, ulStatus);
-                       ulStatus = 0;
-               }
-
-               uiCurrSectOffsetAddr = 0;
-               uiSectAlignAddr = uiSectBoundary;
-               uiSectBoundary += Adapter->uiSectorSize;
-               uiOffsetFromSectStart += Adapter->uiSectorSize;
-               uiNumSectTobeRead--;
-       }
-/*
- * Cleanup.
- */
-BeceemFlashBulkWriteStatus_EXIT:
-       if (ulStatus)
-               BcmRestoreBlockProtectStatus(Adapter, ulStatus);
-
-       kfree(pTempBuff);
-       Adapter->SelectedChip = RESET_CHIP_SELECT;
-       return Status;
-}
-
-/*
- * Procedure:  PropagateCalParamsFromFlashToMemory
- *
- * Description: Dumps the calibration section of EEPROM to DDR.
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- * Returns:
- *             OSAL_STATUS_CODE
- *
- */
-
-int PropagateCalParamsFromFlashToMemory(struct bcm_mini_adapter *Adapter)
-{
-       PCHAR pBuff, pPtr;
-       unsigned int uiEepromSize = 0;
-       unsigned int uiBytesToCopy = 0;
-       /* unsigned int uiIndex = 0; */
-       unsigned int uiCalStartAddr = EEPROM_CALPARAM_START;
-       unsigned int uiMemoryLoc = EEPROM_CAL_DATA_INTERNAL_LOC;
-       unsigned int value;
-       int Status = 0;
-
-       /*
-        * Write the signature first. This will ensure firmware does not access EEPROM.
-        */
-       value = 0xbeadbead;
-       wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value));
-       value = 0xbeadbead;
-       wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value));
-
-       if (0 != BeceemNVMRead(Adapter, &uiEepromSize, EEPROM_SIZE_OFFSET, 4))
-               return -1;
-
-       uiEepromSize = ntohl(uiEepromSize);
-       uiEepromSize >>= 16;
-
-       /*
-        * subtract the auto init section size
-        */
-       uiEepromSize -= EEPROM_CALPARAM_START;
-
-       if (uiEepromSize > 1024 * 1024)
-               return -1;
-
-       pBuff = kmalloc(uiEepromSize, GFP_KERNEL);
-       if (pBuff == NULL)
-               return -ENOMEM;
-
-       if (0 != BeceemNVMRead(Adapter, (PUINT)pBuff, uiCalStartAddr, uiEepromSize)) {
-               kfree(pBuff);
-               return -1;
-       }
-
-       pPtr = pBuff;
-
-       uiBytesToCopy = MIN(BUFFER_4K, uiEepromSize);
-
-       while (uiBytesToCopy) {
-               Status = wrm(Adapter, uiMemoryLoc, (PCHAR)pPtr, uiBytesToCopy);
-               if (Status) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "wrm failed with status :%d", Status);
-                       break;
-               }
-
-               pPtr += uiBytesToCopy;
-               uiEepromSize -= uiBytesToCopy;
-               uiMemoryLoc += uiBytesToCopy;
-               uiBytesToCopy = MIN(BUFFER_4K, uiEepromSize);
-       }
-
-       kfree(pBuff);
-       return Status;
-}
-
-/*
- * Procedure:  BeceemEEPROMReadBackandVerify
- *
- * Description: Read back the data written and verifies.
- *
- * Arguments:
- *             Adapter         - ptr to Adapter object instance
- *             pBuffer         - Data to be written.
- *             uiOffset        - Offset of the flash where data needs to be written to.
- *             uiNumBytes      - Number of bytes to be written.
- * Returns:
- *             OSAL_STATUS_CODE
- *
- */
-
-static int BeceemEEPROMReadBackandVerify(struct bcm_mini_adapter *Adapter,
-                                       PUINT pBuffer,
-                                       unsigned int uiOffset,
-                                       unsigned int uiNumBytes)
-{
-       unsigned int uiRdbk     = 0;
-       unsigned int uiIndex    = 0;
-       unsigned int uiData     = 0;
-       unsigned int auiData[4] = {0};
-
-       while (uiNumBytes) {
-               if (Adapter->device_removed)
-                       return -1;
-
-               if (uiNumBytes >= MAX_RW_SIZE) {
-                       /* for the requests more than or equal to MAX_RW_SIZE bytes, use bulk read function to make the access faster. */
-                       BeceemEEPROMBulkRead(Adapter, &auiData[0], uiOffset, MAX_RW_SIZE);
-
-                       if (memcmp(&pBuffer[uiIndex], &auiData[0], MAX_RW_SIZE)) {
-                               /* re-write */
-                               BeceemEEPROMBulkWrite(Adapter, (PUCHAR)(pBuffer + uiIndex), uiOffset, MAX_RW_SIZE, false);
-                               mdelay(3);
-                               BeceemEEPROMBulkRead(Adapter, &auiData[0], uiOffset, MAX_RW_SIZE);
-
-                               if (memcmp(&pBuffer[uiIndex], &auiData[0], MAX_RW_SIZE))
-                                       return -1;
-                       }
-                       uiOffset += MAX_RW_SIZE;
-                       uiNumBytes -= MAX_RW_SIZE;
-                       uiIndex += 4;
-               } else if (uiNumBytes >= 4) {
-                       BeceemEEPROMBulkRead(Adapter, &uiData, uiOffset, 4);
-                       if (uiData != pBuffer[uiIndex]) {
-                               /* re-write */
-                               BeceemEEPROMBulkWrite(Adapter, (PUCHAR)(pBuffer + uiIndex), uiOffset, 4, false);
-                               mdelay(3);
-                               BeceemEEPROMBulkRead(Adapter, &uiData, uiOffset, 4);
-                               if (uiData != pBuffer[uiIndex])
-                                       return -1;
-                       }
-                       uiOffset += 4;
-                       uiNumBytes -= 4;
-                       uiIndex++;
-               } else {
-                       /* Handle the reads less than 4 bytes... */
-                       uiData = 0;
-                       memcpy(&uiData, ((PUCHAR)pBuffer) + (uiIndex * sizeof(unsigned int)), uiNumBytes);
-                       BeceemEEPROMBulkRead(Adapter, &uiRdbk, uiOffset, 4);
-
-                       if (memcmp(&uiData, &uiRdbk, uiNumBytes))
-                               return -1;
-
-                       uiNumBytes = 0;
-               }
-       }
-
-       return 0;
-}
-
-static VOID BcmSwapWord(unsigned int *ptr1)
-{
-       unsigned int tempval = (unsigned int)*ptr1;
-       char *ptr2 = (char *)&tempval;
-       char *ptr = (char *)ptr1;
-
-       ptr[0] = ptr2[3];
-       ptr[1] = ptr2[2];
-       ptr[2] = ptr2[1];
-       ptr[3] = ptr2[0];
-}
-
-/*
- * Procedure:  BeceemEEPROMWritePage
- *
- * Description: Performs page write (16bytes) to the EEPROM
- *
- * Arguments:
- *             Adapter         - ptr to Adapter object instance
- *             uiData          - Data to be written.
- *             uiOffset        - Offset of the EEPROM where data needs to be written to.
- * Returns:
- *             OSAL_STATUS_CODE
- *
- */
-
-static int BeceemEEPROMWritePage(struct bcm_mini_adapter *Adapter, unsigned int uiData[], unsigned int uiOffset)
-{
-       unsigned int uiRetries = MAX_EEPROM_RETRIES * RETRIES_PER_DELAY;
-       unsigned int uiStatus = 0;
-       UCHAR uiEpromStatus = 0;
-       unsigned int value = 0;
-
-       /* Flush the Write/Read/Cmd queues. */
-       value = (EEPROM_WRITE_QUEUE_FLUSH | EEPROM_CMD_QUEUE_FLUSH | EEPROM_READ_QUEUE_FLUSH);
-       wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value));
-       value = 0;
-       wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value));
-
-       /* Clear the Empty/Avail/Full bits.  After this it has been confirmed
-        * that the bit was cleared by reading back the register. See NOTE below.
-        * We also clear the Read queues as we do a EEPROM status register read
-        * later.
-        */
-       value = (EEPROM_WRITE_QUEUE_EMPTY | EEPROM_WRITE_QUEUE_AVAIL | EEPROM_WRITE_QUEUE_FULL | EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL);
-       wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
-
-       /* Enable write */
-       value = EEPROM_WRITE_ENABLE;
-       wrmalt(Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value));
-
-       /* We can write back to back 8bits * 16 into the queue and as we have
-        * checked for the queue to be empty we can write in a burst.
-        */
-
-       value = uiData[0];
-       BcmSwapWord(&value);
-       wrm(Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4);
-
-       value = uiData[1];
-       BcmSwapWord(&value);
-       wrm(Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4);
-
-       value = uiData[2];
-       BcmSwapWord(&value);
-       wrm(Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4);
-
-       value = uiData[3];
-       BcmSwapWord(&value);
-       wrm(Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4);
-
-       /* NOTE : After this write, on readback of EEPROM_SPI_Q_STATUS1_REG
-        * shows that we see 7 for the EEPROM data write.  Which means that
-        * queue got full, also space is available as well as the queue is empty.
-        * This may happen in sequence.
-        */
-       value =  EEPROM_16_BYTE_PAGE_WRITE | uiOffset;
-       wrmalt(Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value));
-
-       /* Ideally we should loop here without tries and eventually succeed.
-        * What we are checking if the previous write has completed, and this
-        * may take time. We should wait till the Empty bit is set.
-        */
-       uiStatus = 0;
-       rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &uiStatus, sizeof(uiStatus));
-       while ((uiStatus & EEPROM_WRITE_QUEUE_EMPTY) == 0) {
-               uiRetries--;
-               if (uiRetries == 0) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "0x0f003004 = %x, %d retries failed.\n", uiStatus, MAX_EEPROM_RETRIES * RETRIES_PER_DELAY);
-                       return STATUS_FAILURE;
-               }
-
-               if (!(uiRetries%RETRIES_PER_DELAY))
-                       udelay(1000);
-
-               uiStatus = 0;
-               rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &uiStatus, sizeof(uiStatus));
-               if (Adapter->device_removed == TRUE) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Modem got removed hence exiting from loop....");
-                       return -ENODEV;
-               }
-       }
-
-       if (uiRetries != 0) {
-               /* Clear the ones that are set - either, Empty/Full/Avail bits */
-               value = (uiStatus & (EEPROM_WRITE_QUEUE_EMPTY | EEPROM_WRITE_QUEUE_AVAIL | EEPROM_WRITE_QUEUE_FULL));
-               wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
-       }
-
-       /* Here we should check if the EEPROM status register is correct before
-        * proceeding. Bit 0 in the EEPROM Status register should be 0 before
-        * we proceed further.  A 1 at Bit 0 indicates that the EEPROM is busy
-        * with the previous write. Note also that issuing this read finally
-        * means the previous write to the EEPROM has completed.
-        */
-       uiRetries = MAX_EEPROM_RETRIES * RETRIES_PER_DELAY;
-       uiEpromStatus = 0;
-       while (uiRetries != 0) {
-               uiEpromStatus = ReadEEPROMStatusRegister(Adapter);
-               if (Adapter->device_removed == TRUE) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Modem has got removed hence exiting from loop...");
-                       return -ENODEV;
-               }
-               if ((EEPROM_STATUS_REG_WRITE_BUSY & uiEpromStatus) == 0) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "EEPROM status register = %x tries = %d\n", uiEpromStatus, (MAX_EEPROM_RETRIES * RETRIES_PER_DELAY - uiRetries));
-                       return STATUS_SUCCESS;
-               }
-               uiRetries--;
-               if (uiRetries == 0) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "0x0f003004 = %x, for EEPROM status read %d retries failed.\n", uiEpromStatus, MAX_EEPROM_RETRIES * RETRIES_PER_DELAY);
-                       return STATUS_FAILURE;
-               }
-               uiEpromStatus = 0;
-               if (!(uiRetries%RETRIES_PER_DELAY))
-                       udelay(1000);
-       }
-
-       return STATUS_SUCCESS;
-} /* BeceemEEPROMWritePage */
-
-/*
- * Procedure:  BeceemEEPROMBulkWrite
- *
- * Description: Performs write to the EEPROM
- *
- * Arguments:
- *             Adapter         - ptr to Adapter object instance
- *             pBuffer         - Data to be written.
- *             uiOffset        - Offset of the EEPROM where data needs to be written to.
- *             uiNumBytes      - Number of bytes to be written.
- *             bVerify         - read verify flag.
- * Returns:
- *             OSAL_STATUS_CODE
- *
- */
-
-int BeceemEEPROMBulkWrite(struct bcm_mini_adapter *Adapter,
-                       PUCHAR pBuffer,
-                       unsigned int uiOffset,
-                       unsigned int uiNumBytes,
-                       bool bVerify)
-{
-       unsigned int uiBytesToCopy      = uiNumBytes;
-       /* unsigned int uiRdbk          = 0; */
-       unsigned int uiData[4]          = {0};
-       unsigned int uiIndex            = 0;
-       unsigned int uiTempOffset       = 0;
-       unsigned int uiExtraBytes       = 0;
-       /* PUINT puiBuffer      = (PUINT)pBuffer;
-        * int value;
-        */
-
-       if (uiOffset % MAX_RW_SIZE && uiBytesToCopy) {
-               uiTempOffset = uiOffset - (uiOffset % MAX_RW_SIZE);
-               uiExtraBytes = uiOffset - uiTempOffset;
-
-               BeceemEEPROMBulkRead(Adapter, &uiData[0], uiTempOffset, MAX_RW_SIZE);
-
-               if (uiBytesToCopy >= (16 - uiExtraBytes)) {
-                       memcpy((((PUCHAR)&uiData[0]) + uiExtraBytes), pBuffer, MAX_RW_SIZE - uiExtraBytes);
-
-                       if (STATUS_FAILURE == BeceemEEPROMWritePage(Adapter, uiData, uiTempOffset))
-                               return STATUS_FAILURE;
-
-                       uiBytesToCopy -= (MAX_RW_SIZE - uiExtraBytes);
-                       uiIndex += (MAX_RW_SIZE - uiExtraBytes);
-                       uiOffset += (MAX_RW_SIZE - uiExtraBytes);
-               } else {
-                       memcpy((((PUCHAR)&uiData[0]) + uiExtraBytes), pBuffer, uiBytesToCopy);
-
-                       if (STATUS_FAILURE == BeceemEEPROMWritePage(Adapter, uiData, uiTempOffset))
-                               return STATUS_FAILURE;
-
-                       uiIndex += uiBytesToCopy;
-                       uiOffset += uiBytesToCopy;
-                       uiBytesToCopy = 0;
-               }
-       }
-
-       while (uiBytesToCopy) {
-               if (Adapter->device_removed)
-                       return -1;
-
-               if (uiBytesToCopy >= MAX_RW_SIZE) {
-                       if (STATUS_FAILURE == BeceemEEPROMWritePage(Adapter, (PUINT) &pBuffer[uiIndex], uiOffset))
-                               return STATUS_FAILURE;
-
-                       uiIndex += MAX_RW_SIZE;
-                       uiOffset += MAX_RW_SIZE;
-                       uiBytesToCopy -= MAX_RW_SIZE;
-               } else {
-                       /*
-                        * To program non 16byte aligned data, read 16byte and then update.
-                        */
-                       BeceemEEPROMBulkRead(Adapter, &uiData[0], uiOffset, 16);
-                       memcpy(&uiData[0], pBuffer + uiIndex, uiBytesToCopy);
-
-                       if (STATUS_FAILURE == BeceemEEPROMWritePage(Adapter, uiData, uiOffset))
-                               return STATUS_FAILURE;
-
-                       uiBytesToCopy = 0;
-               }
-       }
-
-       return 0;
-}
-
-/*
- * Procedure:  BeceemNVMRead
- *
- * Description: Reads n number of bytes from NVM.
- *
- * Arguments:
- *             Adapter      - ptr to Adapter object instance
- *             pBuffer       - Buffer to store the data read from NVM
- *             uiOffset       - Offset of NVM from where data should be read
- *             uiNumBytes - Number of bytes to be read from the NVM.
- *
- * Returns:
- *             OSAL_STATUS_SUCCESS - if NVM read is successful.
- *             <FAILURE>                       - if failed.
- */
-
-int BeceemNVMRead(struct bcm_mini_adapter *Adapter,
-               PUINT pBuffer,
-               unsigned int uiOffset,
-               unsigned int uiNumBytes)
-{
-       int Status = 0;
-
-       #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS)
-               unsigned int uiTemp = 0, value;
-       #endif
-
-       if (Adapter->eNVMType == NVM_FLASH) {
-               if (Adapter->bFlashRawRead == false) {
-                       if (IsSectionExistInVendorInfo(Adapter, Adapter->eActiveDSD))
-                               return vendorextnReadSection(Adapter, (PUCHAR)pBuffer, Adapter->eActiveDSD, uiOffset, uiNumBytes);
-
-                       uiOffset = uiOffset + Adapter->ulFlashCalStart;
-               }
-
-               #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
-                       Status = bcmflash_raw_read((uiOffset / FLASH_PART_SIZE), (uiOffset % FLASH_PART_SIZE), (unsigned char *)pBuffer, uiNumBytes);
-               #else
-                       rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
-                       value = 0;
-                       wrmalt(Adapter, 0x0f000C80, &value, sizeof(value));
-                       Status = BeceemFlashBulkRead(Adapter,
-                                               pBuffer,
-                                               uiOffset,
-                                               uiNumBytes);
-                       wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
-               #endif
-       } else if (Adapter->eNVMType == NVM_EEPROM) {
-               Status = BeceemEEPROMBulkRead(Adapter,
-                                       pBuffer,
-                                       uiOffset,
-                                       uiNumBytes);
-       } else {
-               Status = -1;
-       }
-
-       return Status;
-}
-
-/*
- * Procedure:  BeceemNVMWrite
- *
- * Description: Writes n number of bytes to NVM.
- *
- * Arguments:
- *             Adapter      - ptr to Adapter object instance
- *             pBuffer       - Buffer contains the data to be written.
- *             uiOffset       - Offset of NVM where data to be written to.
- *             uiNumBytes - Number of bytes to be written..
- *
- * Returns:
- *             OSAL_STATUS_SUCCESS - if NVM write is successful.
- *             <FAILURE>                       - if failed.
- */
-
-int BeceemNVMWrite(struct bcm_mini_adapter *Adapter,
-               PUINT pBuffer,
-               unsigned int uiOffset,
-               unsigned int uiNumBytes,
-               bool bVerify)
-{
-       int Status = 0;
-       unsigned int uiTemp = 0;
-       unsigned int uiMemoryLoc = EEPROM_CAL_DATA_INTERNAL_LOC;
-       unsigned int uiIndex = 0;
-
-       #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS)
-               unsigned int value;
-       #endif
-
-       unsigned int uiFlashOffset = 0;
-
-       if (Adapter->eNVMType == NVM_FLASH) {
-               if (IsSectionExistInVendorInfo(Adapter, Adapter->eActiveDSD))
-                       Status = vendorextnWriteSection(Adapter, (PUCHAR)pBuffer, Adapter->eActiveDSD, uiOffset, uiNumBytes, bVerify);
-               else {
-                       uiFlashOffset = uiOffset + Adapter->ulFlashCalStart;
-
-                       #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
-                               Status = bcmflash_raw_write((uiFlashOffset / FLASH_PART_SIZE), (uiFlashOffset % FLASH_PART_SIZE), (unsigned char *)pBuffer, uiNumBytes);
-                       #else
-                               rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
-                               value = 0;
-                               wrmalt(Adapter, 0x0f000C80, &value, sizeof(value));
-
-                               if (Adapter->bStatusWrite == TRUE)
-                                       Status = BeceemFlashBulkWriteStatus(Adapter,
-                                                                       pBuffer,
-                                                                       uiFlashOffset,
-                                                                       uiNumBytes ,
-                                                                       bVerify);
-                               else
-
-                                       Status = BeceemFlashBulkWrite(Adapter,
-                                                               pBuffer,
-                                                               uiFlashOffset,
-                                                               uiNumBytes,
-                                                               bVerify);
-                       #endif
-               }
-
-               if (uiOffset >= EEPROM_CALPARAM_START) {
-                       uiMemoryLoc += (uiOffset - EEPROM_CALPARAM_START);
-                       while (uiNumBytes) {
-                               if (uiNumBytes > BUFFER_4K) {
-                                       wrm(Adapter, (uiMemoryLoc+uiIndex), (PCHAR)(pBuffer + (uiIndex / 4)), BUFFER_4K);
-                                       uiNumBytes -= BUFFER_4K;
-                                       uiIndex += BUFFER_4K;
-                               } else {
-                                       wrm(Adapter, uiMemoryLoc+uiIndex, (PCHAR)(pBuffer + (uiIndex / 4)), uiNumBytes);
-                                       uiNumBytes = 0;
-                                       break;
-                               }
-                       }
-               } else {
-                       if ((uiOffset + uiNumBytes) > EEPROM_CALPARAM_START) {
-                               ULONG ulBytesTobeSkipped = 0;
-                               PUCHAR pcBuffer = (PUCHAR)pBuffer; /* char pointer to take care of odd byte cases. */
-
-                               uiNumBytes -= (EEPROM_CALPARAM_START - uiOffset);
-                               ulBytesTobeSkipped += (EEPROM_CALPARAM_START - uiOffset);
-                               uiOffset += (EEPROM_CALPARAM_START - uiOffset);
-                               while (uiNumBytes) {
-                                       if (uiNumBytes > BUFFER_4K) {
-                                               wrm(Adapter, uiMemoryLoc + uiIndex, (PCHAR)&pcBuffer[ulBytesTobeSkipped + uiIndex], BUFFER_4K);
-                                               uiNumBytes -= BUFFER_4K;
-                                               uiIndex += BUFFER_4K;
-                                       } else {
-                                               wrm(Adapter, uiMemoryLoc + uiIndex, (PCHAR)&pcBuffer[ulBytesTobeSkipped + uiIndex], uiNumBytes);
-                                               uiNumBytes = 0;
-                                               break;
-                                       }
-                               }
-                       }
-               }
-               /* restore the values. */
-               wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
-       } else if (Adapter->eNVMType == NVM_EEPROM) {
-               Status = BeceemEEPROMBulkWrite(Adapter,
-                                       (PUCHAR)pBuffer,
-                                       uiOffset,
-                                       uiNumBytes,
-                                       bVerify);
-               if (bVerify)
-                       Status = BeceemEEPROMReadBackandVerify(Adapter, (PUINT)pBuffer, uiOffset, uiNumBytes);
-       } else {
-               Status = -1;
-       }
-       return Status;
-}
-
-/*
- * Procedure:  BcmUpdateSectorSize
- *
- * Description: Updates the sector size to FLASH.
- *
- * Arguments:
- *             Adapter       - ptr to Adapter object instance
- *          uiSectorSize - sector size
- *
- * Returns:
- *             OSAL_STATUS_SUCCESS - if NVM write is successful.
- *             <FAILURE>                       - if failed.
- */
-
-int BcmUpdateSectorSize(struct bcm_mini_adapter *Adapter, unsigned int uiSectorSize)
-{
-       int Status = -1;
-       struct bcm_flash_cs_info sFlashCsInfo = {0};
-       unsigned int uiTemp = 0;
-       unsigned int uiSectorSig = 0;
-       unsigned int uiCurrentSectorSize = 0;
-       unsigned int value;
-
-       rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
-       value = 0;
-       wrmalt(Adapter, 0x0f000C80, &value, sizeof(value));
-
-       /*
-        * Before updating the sector size in the reserved area, check if already present.
-        */
-       BeceemFlashBulkRead(Adapter, (PUINT)&sFlashCsInfo, Adapter->ulFlashControlSectionStart, sizeof(sFlashCsInfo));
-       uiSectorSig = ntohl(sFlashCsInfo.FlashSectorSizeSig);
-       uiCurrentSectorSize = ntohl(sFlashCsInfo.FlashSectorSize);
-
-       if (uiSectorSig == FLASH_SECTOR_SIZE_SIG) {
-               if ((uiCurrentSectorSize <= MAX_SECTOR_SIZE) && (uiCurrentSectorSize >= MIN_SECTOR_SIZE)) {
-                       if (uiSectorSize == uiCurrentSectorSize) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Provided sector size is same as programmed in Flash");
-                               Status = STATUS_SUCCESS;
-                               goto Restore;
-                       }
-               }
-       }
-
-       if ((uiSectorSize <= MAX_SECTOR_SIZE) && (uiSectorSize >= MIN_SECTOR_SIZE)) {
-               sFlashCsInfo.FlashSectorSize = htonl(uiSectorSize);
-               sFlashCsInfo.FlashSectorSizeSig = htonl(FLASH_SECTOR_SIZE_SIG);
-
-               Status = BeceemFlashBulkWrite(Adapter,
-                                       (PUINT)&sFlashCsInfo,
-                                       Adapter->ulFlashControlSectionStart,
-                                       sizeof(sFlashCsInfo),
-                                       TRUE);
-       }
-
-Restore:
-       /* restore the values. */
-       wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
-
-       return Status;
-}
-
-/*
- * Procedure:  BcmGetFlashSectorSize
- *
- * Description: Finds the sector size of the FLASH.
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *
- * Returns:
- *             unsigned int - sector size.
- *
- */
-
-static unsigned int BcmGetFlashSectorSize(struct bcm_mini_adapter *Adapter, unsigned int FlashSectorSizeSig, unsigned int FlashSectorSize)
-{
-       unsigned int uiSectorSize = 0;
-       unsigned int uiSectorSig = 0;
-
-       if (Adapter->bSectorSizeOverride &&
-               (Adapter->uiSectorSizeInCFG <= MAX_SECTOR_SIZE &&
-                       Adapter->uiSectorSizeInCFG >= MIN_SECTOR_SIZE)) {
-               Adapter->uiSectorSize = Adapter->uiSectorSizeInCFG;
-       } else {
-               uiSectorSig = FlashSectorSizeSig;
-
-               if (uiSectorSig == FLASH_SECTOR_SIZE_SIG) {
-                       uiSectorSize = FlashSectorSize;
-                       /*
-                        * If the sector size stored in the FLASH makes sense then use it.
-                        */
-                       if (uiSectorSize <= MAX_SECTOR_SIZE && uiSectorSize >= MIN_SECTOR_SIZE) {
-                               Adapter->uiSectorSize = uiSectorSize;
-                       } else if (Adapter->uiSectorSizeInCFG <= MAX_SECTOR_SIZE &&
-                               Adapter->uiSectorSizeInCFG >= MIN_SECTOR_SIZE) {
-                               /* No valid size in FLASH, check if Config file has it. */
-                               Adapter->uiSectorSize = Adapter->uiSectorSizeInCFG;
-                       } else {
-                               /* Init to Default, if none of the above works. */
-                               Adapter->uiSectorSize = DEFAULT_SECTOR_SIZE;
-                       }
-               } else {
-                       if (Adapter->uiSectorSizeInCFG <= MAX_SECTOR_SIZE &&
-                               Adapter->uiSectorSizeInCFG >= MIN_SECTOR_SIZE)
-                               Adapter->uiSectorSize = Adapter->uiSectorSizeInCFG;
-                       else
-                               Adapter->uiSectorSize = DEFAULT_SECTOR_SIZE;
-               }
-       }
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Sector size  :%x\n", Adapter->uiSectorSize);
-
-       return Adapter->uiSectorSize;
-}
-
-/*
- * Procedure:  BcmInitEEPROMQueues
- *
- * Description: Initialization of EEPROM queues.
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *
- * Returns:
- *             <OSAL_STATUS_CODE>
- */
-
-static int BcmInitEEPROMQueues(struct bcm_mini_adapter *Adapter)
-{
-       unsigned int value = 0;
-       /* CHIP Bug : Clear the Avail bits on the Read queue. The default
-        * value on this register is supposed to be 0x00001102.
-        * But we get 0x00001122.
-        */
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Fixing reset value on 0x0f003004 register\n");
-       value = EEPROM_READ_DATA_AVAIL;
-       wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
-
-       /* Flush the all the EEPROM queues. */
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " Flushing the queues\n");
-       value = EEPROM_ALL_QUEUE_FLUSH;
-       wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value));
-
-       value = 0;
-       wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value));
-
-       /* Read the EEPROM Status Register. Just to see, no real purpose. */
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "EEPROM Status register value = %x\n", ReadEEPROMStatusRegister(Adapter));
-
-       return STATUS_SUCCESS;
-} /* BcmInitEEPROMQueues() */
-
-/*
- * Procedure:  BcmInitNVM
- *
- * Description: Initialization of NVM, EEPROM size,FLASH size, sector size etc.
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *
- * Returns:
- *             <OSAL_STATUS_CODE>
- */
-
-int BcmInitNVM(struct bcm_mini_adapter *ps_adapter)
-{
-       BcmValidateNvmType(ps_adapter);
-       BcmInitEEPROMQueues(ps_adapter);
-
-       if (ps_adapter->eNVMType == NVM_AUTODETECT) {
-               ps_adapter->eNVMType = BcmGetNvmType(ps_adapter);
-               if (ps_adapter->eNVMType == NVM_UNKNOWN)
-                       BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_PRINTK, 0, 0, "NVM Type is unknown!!\n");
-       } else if (ps_adapter->eNVMType == NVM_FLASH) {
-               BcmGetFlashCSInfo(ps_adapter);
-       }
-
-       BcmGetNvmSize(ps_adapter);
-
-       return STATUS_SUCCESS;
-}
-
-/* BcmGetNvmSize : set the EEPROM or flash size in Adapter.
- *
- * Input Parameter:
- *             Adapter data structure
- * Return Value :
- *             0. means success;
- */
-
-static int BcmGetNvmSize(struct bcm_mini_adapter *Adapter)
-{
-       if (Adapter->eNVMType == NVM_EEPROM)
-               Adapter->uiNVMDSDSize = BcmGetEEPROMSize(Adapter);
-       else if (Adapter->eNVMType == NVM_FLASH)
-               Adapter->uiNVMDSDSize = BcmGetFlashSize(Adapter);
-
-       return 0;
-}
-
-/*
- * Procedure:  BcmValidateNvm
- *
- * Description: Validates the NVM Type option selected against the device
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *
- * Returns:
- *             <VOID>
- */
-
-static VOID BcmValidateNvmType(struct bcm_mini_adapter *Adapter)
-{
-       /*
-        * if forcing the FLASH through CFG file, we should ensure device really has a FLASH.
-        * Accessing the FLASH address without the FLASH being present can cause hang/freeze etc.
-        * So if NVM_FLASH is selected for older chipsets, change it to AUTODETECT where EEPROM is 1st choice.
-        */
-
-       if (Adapter->eNVMType == NVM_FLASH &&
-               Adapter->chip_id < 0xBECE3300)
-               Adapter->eNVMType = NVM_AUTODETECT;
-}
-
-/*
- * Procedure:  BcmReadFlashRDID
- *
- * Description: Reads ID from Serial Flash
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *
- * Returns:
- *             Flash ID
- */
-
-static ULONG BcmReadFlashRDID(struct bcm_mini_adapter *Adapter)
-{
-       ULONG ulRDID = 0;
-       unsigned int value;
-
-       /*
-        * Read ID Instruction.
-        */
-       value = (FLASH_CMD_READ_ID << 24);
-       wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value));
-
-       /* Delay */
-       udelay(10);
-
-       /*
-        * Read SPI READQ REG. The output will be WWXXYYZZ.
-        * The ID is 3Bytes long and is WWXXYY. ZZ needs to be Ignored.
-        */
-       rdmalt(Adapter, FLASH_SPI_READQ_REG, (PUINT)&ulRDID, sizeof(ulRDID));
-
-       return ulRDID >> 8;
-}
-
-int BcmAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter)
-{
-       if (!psAdapter) {
-               BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Adapter structure point is NULL");
-               return -EINVAL;
-       }
-       psAdapter->psFlashCSInfo = kzalloc(sizeof(struct bcm_flash_cs_info), GFP_KERNEL);
-       if (psAdapter->psFlashCSInfo == NULL) {
-               BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Can't Allocate memory for Flash 1.x");
-               return -ENOMEM;
-       }
-
-       psAdapter->psFlash2xCSInfo = kzalloc(sizeof(struct bcm_flash2x_cs_info), GFP_KERNEL);
-       if (!psAdapter->psFlash2xCSInfo) {
-               BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Can't Allocate memory for Flash 2.x");
-               kfree(psAdapter->psFlashCSInfo);
-               return -ENOMEM;
-       }
-
-       psAdapter->psFlash2xVendorInfo = kzalloc(sizeof(struct bcm_flash2x_vendor_info), GFP_KERNEL);
-       if (!psAdapter->psFlash2xVendorInfo) {
-               BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Can't Allocate Vendor Info Memory for Flash 2.x");
-               kfree(psAdapter->psFlashCSInfo);
-               kfree(psAdapter->psFlash2xCSInfo);
-               return -ENOMEM;
-       }
-
-       return STATUS_SUCCESS;
-}
-
-int BcmDeAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter)
-{
-       if (!psAdapter) {
-               BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Adapter structure point is NULL");
-               return -EINVAL;
-       }
-       kfree(psAdapter->psFlashCSInfo);
-       kfree(psAdapter->psFlash2xCSInfo);
-       kfree(psAdapter->psFlash2xVendorInfo);
-       return STATUS_SUCCESS;
-}
-
-static int BcmDumpFlash2XCSStructure(struct bcm_flash2x_cs_info *psFlash2xCSInfo, struct bcm_mini_adapter *Adapter)
-{
-       unsigned int Index = 0;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "**********************FLASH2X CS Structure *******************");
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Signature is  :%x", (psFlash2xCSInfo->MagicNumber));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Major Version :%d", MAJOR_VERSION(psFlash2xCSInfo->FlashLayoutVersion));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Minor Version :%d", MINOR_VERSION(psFlash2xCSInfo->FlashLayoutVersion));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " ISOImageMajorVersion:0x%x", (psFlash2xCSInfo->ISOImageVersion));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SCSIFirmwareMajorVersion :0x%x", (psFlash2xCSInfo->SCSIFirmwareVersion));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForPart1ISOImage :0x%x", (psFlash2xCSInfo->OffsetFromZeroForPart1ISOImage));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForScsiFirmware :0x%x", (psFlash2xCSInfo->OffsetFromZeroForScsiFirmware));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SizeOfScsiFirmware  :0x%x", (psFlash2xCSInfo->SizeOfScsiFirmware));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForPart2ISOImage :0x%x", (psFlash2xCSInfo->OffsetFromZeroForPart2ISOImage));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSDStart :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSDStart));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSDEnd :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSDEnd));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSAStart :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSAStart));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSAEnd :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSAEnd));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForControlSectionStart :0x%x", (psFlash2xCSInfo->OffsetFromZeroForControlSectionStart));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForControlSectionData :0x%x", (psFlash2xCSInfo->OffsetFromZeroForControlSectionData));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "CDLessInactivityTimeout :0x%x", (psFlash2xCSInfo->CDLessInactivityTimeout));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "NewImageSignature :0x%x", (psFlash2xCSInfo->NewImageSignature));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashSectorSizeSig :0x%x", (psFlash2xCSInfo->FlashSectorSizeSig));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashSectorSize :0x%x", (psFlash2xCSInfo->FlashSectorSize));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashWriteSupportSize :0x%x", (psFlash2xCSInfo->FlashWriteSupportSize));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "TotalFlashSize :0x%X", (psFlash2xCSInfo->TotalFlashSize));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashBaseAddr :0x%x", (psFlash2xCSInfo->FlashBaseAddr));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashPartMaxSize :0x%x", (psFlash2xCSInfo->FlashPartMaxSize));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "IsCDLessDeviceBootSig :0x%x", (psFlash2xCSInfo->IsCDLessDeviceBootSig));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "MassStorageTimeout :0x%x", (psFlash2xCSInfo->MassStorageTimeout));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part1Start :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part1Start));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part1End :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part1End));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part2Start :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part2Start));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part2End :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part2End));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part3Start :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part3Start));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part3End :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part3End));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part1Start :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part1Start));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part1End :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part1End));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part2Start :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part2Start));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part2End :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part2End));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part3Start :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part3Start));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part3End :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part3End));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromDSDStartForDSDHeader :0x%x", (psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD1Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD1Start));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD1End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD1End));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD2Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD2Start));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD2End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD2End));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA1Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA1Start));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA1End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA1End));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA2Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA2Start));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA2End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA2End));
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Sector Access Bit Map is Defined as :");
-
-       for (Index = 0; Index < (FLASH2X_TOTAL_SIZE / (DEFAULT_SECTOR_SIZE * 16)); Index++)
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SectorAccessBitMap[%d] :0x%x", Index,
-                               (psFlash2xCSInfo->SectorAccessBitMap[Index]));
-
-       return STATUS_SUCCESS;
-}
-
-static int ConvertEndianOf2XCSStructure(struct bcm_flash2x_cs_info *psFlash2xCSInfo)
-{
-       unsigned int Index = 0;
-
-       psFlash2xCSInfo->MagicNumber = ntohl(psFlash2xCSInfo->MagicNumber);
-       psFlash2xCSInfo->FlashLayoutVersion = ntohl(psFlash2xCSInfo->FlashLayoutVersion);
-       /* psFlash2xCSInfo->FlashLayoutMinorVersion = ntohs(psFlash2xCSInfo->FlashLayoutMinorVersion); */
-       psFlash2xCSInfo->ISOImageVersion = ntohl(psFlash2xCSInfo->ISOImageVersion);
-       psFlash2xCSInfo->SCSIFirmwareVersion = ntohl(psFlash2xCSInfo->SCSIFirmwareVersion);
-       psFlash2xCSInfo->OffsetFromZeroForPart1ISOImage = ntohl(psFlash2xCSInfo->OffsetFromZeroForPart1ISOImage);
-       psFlash2xCSInfo->OffsetFromZeroForScsiFirmware = ntohl(psFlash2xCSInfo->OffsetFromZeroForScsiFirmware);
-       psFlash2xCSInfo->SizeOfScsiFirmware = ntohl(psFlash2xCSInfo->SizeOfScsiFirmware);
-       psFlash2xCSInfo->OffsetFromZeroForPart2ISOImage = ntohl(psFlash2xCSInfo->OffsetFromZeroForPart2ISOImage);
-       psFlash2xCSInfo->OffsetFromZeroForDSDStart = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSDStart);
-       psFlash2xCSInfo->OffsetFromZeroForDSDEnd = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSDEnd);
-       psFlash2xCSInfo->OffsetFromZeroForVSAStart = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSAStart);
-       psFlash2xCSInfo->OffsetFromZeroForVSAEnd = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSAEnd);
-       psFlash2xCSInfo->OffsetFromZeroForControlSectionStart = ntohl(psFlash2xCSInfo->OffsetFromZeroForControlSectionStart);
-       psFlash2xCSInfo->OffsetFromZeroForControlSectionData = ntohl(psFlash2xCSInfo->OffsetFromZeroForControlSectionData);
-       psFlash2xCSInfo->CDLessInactivityTimeout = ntohl(psFlash2xCSInfo->CDLessInactivityTimeout);
-       psFlash2xCSInfo->NewImageSignature = ntohl(psFlash2xCSInfo->NewImageSignature);
-       psFlash2xCSInfo->FlashSectorSizeSig = ntohl(psFlash2xCSInfo->FlashSectorSizeSig);
-       psFlash2xCSInfo->FlashSectorSize = ntohl(psFlash2xCSInfo->FlashSectorSize);
-       psFlash2xCSInfo->FlashWriteSupportSize = ntohl(psFlash2xCSInfo->FlashWriteSupportSize);
-       psFlash2xCSInfo->TotalFlashSize = ntohl(psFlash2xCSInfo->TotalFlashSize);
-       psFlash2xCSInfo->FlashBaseAddr = ntohl(psFlash2xCSInfo->FlashBaseAddr);
-       psFlash2xCSInfo->FlashPartMaxSize = ntohl(psFlash2xCSInfo->FlashPartMaxSize);
-       psFlash2xCSInfo->IsCDLessDeviceBootSig = ntohl(psFlash2xCSInfo->IsCDLessDeviceBootSig);
-       psFlash2xCSInfo->MassStorageTimeout = ntohl(psFlash2xCSInfo->MassStorageTimeout);
-       psFlash2xCSInfo->OffsetISOImage1Part1Start = ntohl(psFlash2xCSInfo->OffsetISOImage1Part1Start);
-       psFlash2xCSInfo->OffsetISOImage1Part1End = ntohl(psFlash2xCSInfo->OffsetISOImage1Part1End);
-       psFlash2xCSInfo->OffsetISOImage1Part2Start = ntohl(psFlash2xCSInfo->OffsetISOImage1Part2Start);
-       psFlash2xCSInfo->OffsetISOImage1Part2End = ntohl(psFlash2xCSInfo->OffsetISOImage1Part2End);
-       psFlash2xCSInfo->OffsetISOImage1Part3Start = ntohl(psFlash2xCSInfo->OffsetISOImage1Part3Start);
-       psFlash2xCSInfo->OffsetISOImage1Part3End = ntohl(psFlash2xCSInfo->OffsetISOImage1Part3End);
-       psFlash2xCSInfo->OffsetISOImage2Part1Start = ntohl(psFlash2xCSInfo->OffsetISOImage2Part1Start);
-       psFlash2xCSInfo->OffsetISOImage2Part1End = ntohl(psFlash2xCSInfo->OffsetISOImage2Part1End);
-       psFlash2xCSInfo->OffsetISOImage2Part2Start = ntohl(psFlash2xCSInfo->OffsetISOImage2Part2Start);
-       psFlash2xCSInfo->OffsetISOImage2Part2End = ntohl(psFlash2xCSInfo->OffsetISOImage2Part2End);
-       psFlash2xCSInfo->OffsetISOImage2Part3Start = ntohl(psFlash2xCSInfo->OffsetISOImage2Part3Start);
-       psFlash2xCSInfo->OffsetISOImage2Part3End = ntohl(psFlash2xCSInfo->OffsetISOImage2Part3End);
-       psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader = ntohl(psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader);
-       psFlash2xCSInfo->OffsetFromZeroForDSD1Start = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSD1Start);
-       psFlash2xCSInfo->OffsetFromZeroForDSD1End = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSD1End);
-       psFlash2xCSInfo->OffsetFromZeroForDSD2Start = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSD2Start);
-       psFlash2xCSInfo->OffsetFromZeroForDSD2End = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSD2End);
-       psFlash2xCSInfo->OffsetFromZeroForVSA1Start = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSA1Start);
-       psFlash2xCSInfo->OffsetFromZeroForVSA1End = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSA1End);
-       psFlash2xCSInfo->OffsetFromZeroForVSA2Start = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSA2Start);
-       psFlash2xCSInfo->OffsetFromZeroForVSA2End = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSA2End);
-
-       for (Index = 0; Index < (FLASH2X_TOTAL_SIZE / (DEFAULT_SECTOR_SIZE * 16)); Index++)
-               psFlash2xCSInfo->SectorAccessBitMap[Index] = ntohl(psFlash2xCSInfo->SectorAccessBitMap[Index]);
-
-       return STATUS_SUCCESS;
-}
-
-static int ConvertEndianOfCSStructure(struct bcm_flash_cs_info *psFlashCSInfo)
-{
-       /* unsigned int Index = 0; */
-       psFlashCSInfo->MagicNumber                              = ntohl(psFlashCSInfo->MagicNumber);
-       psFlashCSInfo->FlashLayoutVersion                       = ntohl(psFlashCSInfo->FlashLayoutVersion);
-       psFlashCSInfo->ISOImageVersion                          = ntohl(psFlashCSInfo->ISOImageVersion);
-       /* won't convert according to old assumption */
-       psFlashCSInfo->SCSIFirmwareVersion                      = (psFlashCSInfo->SCSIFirmwareVersion);
-       psFlashCSInfo->OffsetFromZeroForPart1ISOImage           = ntohl(psFlashCSInfo->OffsetFromZeroForPart1ISOImage);
-       psFlashCSInfo->OffsetFromZeroForScsiFirmware            = ntohl(psFlashCSInfo->OffsetFromZeroForScsiFirmware);
-       psFlashCSInfo->SizeOfScsiFirmware                       = ntohl(psFlashCSInfo->SizeOfScsiFirmware);
-       psFlashCSInfo->OffsetFromZeroForPart2ISOImage           = ntohl(psFlashCSInfo->OffsetFromZeroForPart2ISOImage);
-       psFlashCSInfo->OffsetFromZeroForCalibrationStart        = ntohl(psFlashCSInfo->OffsetFromZeroForCalibrationStart);
-       psFlashCSInfo->OffsetFromZeroForCalibrationEnd          = ntohl(psFlashCSInfo->OffsetFromZeroForCalibrationEnd);
-       psFlashCSInfo->OffsetFromZeroForVSAStart                = ntohl(psFlashCSInfo->OffsetFromZeroForVSAStart);
-       psFlashCSInfo->OffsetFromZeroForVSAEnd                  = ntohl(psFlashCSInfo->OffsetFromZeroForVSAEnd);
-       psFlashCSInfo->OffsetFromZeroForControlSectionStart     = ntohl(psFlashCSInfo->OffsetFromZeroForControlSectionStart);
-       psFlashCSInfo->OffsetFromZeroForControlSectionData      = ntohl(psFlashCSInfo->OffsetFromZeroForControlSectionData);
-       psFlashCSInfo->CDLessInactivityTimeout                  = ntohl(psFlashCSInfo->CDLessInactivityTimeout);
-       psFlashCSInfo->NewImageSignature                        = ntohl(psFlashCSInfo->NewImageSignature);
-       psFlashCSInfo->FlashSectorSizeSig                       = ntohl(psFlashCSInfo->FlashSectorSizeSig);
-       psFlashCSInfo->FlashSectorSize                          = ntohl(psFlashCSInfo->FlashSectorSize);
-       psFlashCSInfo->FlashWriteSupportSize                    = ntohl(psFlashCSInfo->FlashWriteSupportSize);
-       psFlashCSInfo->TotalFlashSize                           = ntohl(psFlashCSInfo->TotalFlashSize);
-       psFlashCSInfo->FlashBaseAddr                            = ntohl(psFlashCSInfo->FlashBaseAddr);
-       psFlashCSInfo->FlashPartMaxSize                         = ntohl(psFlashCSInfo->FlashPartMaxSize);
-       psFlashCSInfo->IsCDLessDeviceBootSig                    = ntohl(psFlashCSInfo->IsCDLessDeviceBootSig);
-       psFlashCSInfo->MassStorageTimeout                       = ntohl(psFlashCSInfo->MassStorageTimeout);
-
-       return STATUS_SUCCESS;
-}
-
-static int IsSectionExistInVendorInfo(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val section)
-{
-       return (Adapter->uiVendorExtnFlag &&
-               (Adapter->psFlash2xVendorInfo->VendorSection[section].AccessFlags & FLASH2X_SECTION_PRESENT) &&
-               (Adapter->psFlash2xVendorInfo->VendorSection[section].OffsetFromZeroForSectionStart != UNINIT_PTR_IN_CS));
-}
-
-static VOID UpdateVendorInfo(struct bcm_mini_adapter *Adapter)
-{
-       B_UINT32 i = 0;
-       unsigned int uiSizeSection = 0;
-
-       Adapter->uiVendorExtnFlag = false;
-
-       for (i = 0; i < TOTAL_SECTIONS; i++)
-               Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart = UNINIT_PTR_IN_CS;
-
-       if (STATUS_SUCCESS != vendorextnGetSectionInfo(Adapter, Adapter->psFlash2xVendorInfo))
-               return;
-
-       i = 0;
-       while (i < TOTAL_SECTIONS) {
-               if (!(Adapter->psFlash2xVendorInfo->VendorSection[i].AccessFlags & FLASH2X_SECTION_PRESENT)) {
-                       i++;
-                       continue;
-               }
-
-               Adapter->uiVendorExtnFlag = TRUE;
-               uiSizeSection = (Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionEnd -
-                               Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart);
-
-               switch (i) {
-               case DSD0:
-                       if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header))) &&
-                               (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart))
-                               Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd = VENDOR_PTR_IN_CS;
-                       else
-                               Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd = UNINIT_PTR_IN_CS;
-                       break;
-
-               case DSD1:
-                       if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header))) &&
-                               (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart))
-                               Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End = VENDOR_PTR_IN_CS;
-                       else
-                               Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End = UNINIT_PTR_IN_CS;
-                       break;
-
-               case DSD2:
-                       if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header))) &&
-                               (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart))
-                               Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End = VENDOR_PTR_IN_CS;
-                       else
-                               Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End = UNINIT_PTR_IN_CS;
-                       break;
-               case VSA0:
-                       if (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)
-                               Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAEnd = VENDOR_PTR_IN_CS;
-                       else
-                               Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAEnd = UNINIT_PTR_IN_CS;
-                       break;
-
-               case VSA1:
-                       if (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)
-                               Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1End = VENDOR_PTR_IN_CS;
-                       else
-                               Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1End = UNINIT_PTR_IN_CS;
-                       break;
-               case VSA2:
-                       if (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)
-                               Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2End = VENDOR_PTR_IN_CS;
-                       else
-                               Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2End = UNINIT_PTR_IN_CS;
-                       break;
-
-               default:
-                       break;
-               }
-               i++;
-       }
-}
-
-/*
- * Procedure:  BcmGetFlashCSInfo
- *
- * Description: Reads control structure and gets Cal section addresses.
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *
- * Returns:
- *             <VOID>
- */
-
-static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter)
-{
-       /* struct bcm_flash_cs_info sFlashCsInfo = {0}; */
-
-       #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS)
-               unsigned int value;
-       #endif
-
-       unsigned int uiFlashLayoutMajorVersion;
-
-       Adapter->uiFlashLayoutMinorVersion = 0;
-       Adapter->uiFlashLayoutMajorVersion = 0;
-       Adapter->ulFlashControlSectionStart = FLASH_CS_INFO_START_ADDR;
-
-       Adapter->uiFlashBaseAdd = 0;
-       Adapter->ulFlashCalStart = 0;
-       memset(Adapter->psFlashCSInfo, 0 , sizeof(struct bcm_flash_cs_info));
-       memset(Adapter->psFlash2xCSInfo, 0 , sizeof(struct bcm_flash2x_cs_info));
-
-       if (!Adapter->bDDRInitDone) {
-               value = FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT;
-               wrmalt(Adapter, 0xAF00A080, &value, sizeof(value));
-       }
-
-       /* Reading first 8 Bytes to get the Flash Layout
-        * MagicNumber(4 bytes) +FlashLayoutMinorVersion(2 Bytes) +FlashLayoutMajorVersion(2 Bytes)
-        */
-       BeceemFlashBulkRead(Adapter, (PUINT)Adapter->psFlashCSInfo, Adapter->ulFlashControlSectionStart, 8);
-
-       Adapter->psFlashCSInfo->FlashLayoutVersion =  ntohl(Adapter->psFlashCSInfo->FlashLayoutVersion);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Layout Version :%X", (Adapter->psFlashCSInfo->FlashLayoutVersion));
-       /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Layout Minor Version :%d\n", ntohs(sFlashCsInfo.FlashLayoutMinorVersion)); */
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Signature is  :%x\n", ntohl(Adapter->psFlashCSInfo->MagicNumber));
-
-       if (FLASH_CONTROL_STRUCT_SIGNATURE == ntohl(Adapter->psFlashCSInfo->MagicNumber)) {
-               uiFlashLayoutMajorVersion = MAJOR_VERSION((Adapter->psFlashCSInfo->FlashLayoutVersion));
-               Adapter->uiFlashLayoutMinorVersion = MINOR_VERSION((Adapter->psFlashCSInfo->FlashLayoutVersion));
-       } else {
-               Adapter->uiFlashLayoutMinorVersion = 0;
-               uiFlashLayoutMajorVersion = 0;
-       }
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FLASH LAYOUT MAJOR VERSION :%X", uiFlashLayoutMajorVersion);
-
-       if (uiFlashLayoutMajorVersion < FLASH_2X_MAJOR_NUMBER) {
-               BeceemFlashBulkRead(Adapter, (PUINT)Adapter->psFlashCSInfo, Adapter->ulFlashControlSectionStart, sizeof(struct bcm_flash_cs_info));
-               ConvertEndianOfCSStructure(Adapter->psFlashCSInfo);
-               Adapter->ulFlashCalStart = (Adapter->psFlashCSInfo->OffsetFromZeroForCalibrationStart);
-
-               if (!((Adapter->uiFlashLayoutMajorVersion == 1) && (Adapter->uiFlashLayoutMinorVersion == 1)))
-                       Adapter->ulFlashControlSectionStart = Adapter->psFlashCSInfo->OffsetFromZeroForControlSectionStart;
-
-               if ((FLASH_CONTROL_STRUCT_SIGNATURE == (Adapter->psFlashCSInfo->MagicNumber)) &&
-                       (SCSI_FIRMWARE_MINOR_VERSION <= MINOR_VERSION(Adapter->psFlashCSInfo->SCSIFirmwareVersion)) &&
-                       (FLASH_SECTOR_SIZE_SIG == (Adapter->psFlashCSInfo->FlashSectorSizeSig)) &&
-                       (BYTE_WRITE_SUPPORT == (Adapter->psFlashCSInfo->FlashWriteSupportSize))) {
-                       Adapter->ulFlashWriteSize = (Adapter->psFlashCSInfo->FlashWriteSupportSize);
-                       Adapter->fpFlashWrite = flashByteWrite;
-                       Adapter->fpFlashWriteWithStatusCheck = flashByteWriteStatus;
-               } else {
-                       Adapter->ulFlashWriteSize = MAX_RW_SIZE;
-                       Adapter->fpFlashWrite = flashWrite;
-                       Adapter->fpFlashWriteWithStatusCheck = flashWriteStatus;
-               }
-
-               BcmGetFlashSectorSize(Adapter, (Adapter->psFlashCSInfo->FlashSectorSizeSig),
-                               (Adapter->psFlashCSInfo->FlashSectorSize));
-               Adapter->uiFlashBaseAdd = Adapter->psFlashCSInfo->FlashBaseAddr & 0xFCFFFFFF;
-       } else {
-               if (BcmFlash2xBulkRead(Adapter, (PUINT)Adapter->psFlash2xCSInfo, NO_SECTION_VAL,
-                                       Adapter->ulFlashControlSectionStart, sizeof(struct bcm_flash2x_cs_info))) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Unable to read CS structure\n");
-                       return STATUS_FAILURE;
-               }
-
-               ConvertEndianOf2XCSStructure(Adapter->psFlash2xCSInfo);
-               BcmDumpFlash2XCSStructure(Adapter->psFlash2xCSInfo, Adapter);
-               if ((FLASH_CONTROL_STRUCT_SIGNATURE == Adapter->psFlash2xCSInfo->MagicNumber) &&
-                       (SCSI_FIRMWARE_MINOR_VERSION <= MINOR_VERSION(Adapter->psFlash2xCSInfo->SCSIFirmwareVersion)) &&
-                       (FLASH_SECTOR_SIZE_SIG == Adapter->psFlash2xCSInfo->FlashSectorSizeSig) &&
-                       (BYTE_WRITE_SUPPORT == Adapter->psFlash2xCSInfo->FlashWriteSupportSize)) {
-                       Adapter->ulFlashWriteSize = Adapter->psFlash2xCSInfo->FlashWriteSupportSize;
-                       Adapter->fpFlashWrite = flashByteWrite;
-                       Adapter->fpFlashWriteWithStatusCheck = flashByteWriteStatus;
-               } else {
-                       Adapter->ulFlashWriteSize = MAX_RW_SIZE;
-                       Adapter->fpFlashWrite = flashWrite;
-                       Adapter->fpFlashWriteWithStatusCheck = flashWriteStatus;
-               }
-
-               BcmGetFlashSectorSize(Adapter, Adapter->psFlash2xCSInfo->FlashSectorSizeSig,
-                               Adapter->psFlash2xCSInfo->FlashSectorSize);
-
-               UpdateVendorInfo(Adapter);
-
-               BcmGetActiveDSD(Adapter);
-               BcmGetActiveISO(Adapter);
-               Adapter->uiFlashBaseAdd = Adapter->psFlash2xCSInfo->FlashBaseAddr & 0xFCFFFFFF;
-               Adapter->ulFlashControlSectionStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart;
-       }
-       /*
-        * Concerns: what if CS sector size does not match with this sector size ???
-        * what is the indication of AccessBitMap  in CS in flash 2.x ????
-        */
-       Adapter->ulFlashID = BcmReadFlashRDID(Adapter);
-       Adapter->uiFlashLayoutMajorVersion = uiFlashLayoutMajorVersion;
-
-       return STATUS_SUCCESS;
-}
-
-/*
- * Procedure:  BcmGetNvmType
- *
- * Description: Finds the type of NVM used.
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *
- * Returns:
- *             NVM_TYPE
- *
- */
-
-static enum bcm_nvm_type BcmGetNvmType(struct bcm_mini_adapter *Adapter)
-{
-       unsigned int uiData = 0;
-
-       BeceemEEPROMBulkRead(Adapter, &uiData, 0x0, 4);
-       if (uiData == BECM)
-               return NVM_EEPROM;
-
-       /*
-        * Read control struct and get cal addresses before accessing the flash
-        */
-       BcmGetFlashCSInfo(Adapter);
-
-       BeceemFlashBulkRead(Adapter, &uiData, 0x0 + Adapter->ulFlashCalStart, 4);
-       if (uiData == BECM)
-               return NVM_FLASH;
-
-       /*
-        * even if there is no valid signature on EEPROM/FLASH find out if they really exist.
-        * if exist select it.
-        */
-       if (BcmGetEEPROMSize(Adapter))
-               return NVM_EEPROM;
-
-       /* TBD for Flash. */
-       return NVM_UNKNOWN;
-}
-
-/*
- * BcmGetSectionValStartOffset - this will calculate the section's starting offset if section val is given
- * @Adapter : Drivers Private Data structure
- * @eFlashSectionVal : Flash secion value defined in enum bcm_flash2x_section_val
- *
- * Return value:-
- * On success it return the start offset of the provided section val
- * On Failure -returns STATUS_FAILURE
- */
-
-int BcmGetSectionValStartOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlashSectionVal)
-{
-       /*
-        * Considering all the section for which end offset can be calculated or directly given
-        * in CS Structure. if matching case does not exist, return STATUS_FAILURE indicating section
-        * endoffset can't be calculated or given in CS Structure.
-        */
-
-       int SectStartOffset = 0;
-
-       SectStartOffset = INVALID_OFFSET;
-
-       if (IsSectionExistInVendorInfo(Adapter, eFlashSectionVal))
-               return Adapter->psFlash2xVendorInfo->VendorSection[eFlashSectionVal].OffsetFromZeroForSectionStart;
-
-       switch (eFlashSectionVal) {
-       case ISO_IMAGE1:
-               if ((Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start != UNINIT_PTR_IN_CS) &&
-                       (IsNonCDLessDevice(Adapter) == false))
-                       SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start);
-               break;
-       case ISO_IMAGE2:
-               if ((Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start != UNINIT_PTR_IN_CS) &&
-                       (IsNonCDLessDevice(Adapter) == false))
-                       SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start);
-               break;
-       case DSD0:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart != UNINIT_PTR_IN_CS)
-                       SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart);
-               break;
-       case DSD1:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start != UNINIT_PTR_IN_CS)
-                       SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start);
-               break;
-       case DSD2:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start != UNINIT_PTR_IN_CS)
-                       SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start);
-               break;
-       case VSA0:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart != UNINIT_PTR_IN_CS)
-                       SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart);
-               break;
-       case VSA1:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start != UNINIT_PTR_IN_CS)
-                       SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start);
-               break;
-       case VSA2:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start != UNINIT_PTR_IN_CS)
-                       SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start);
-               break;
-       case SCSI:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware != UNINIT_PTR_IN_CS)
-                       SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware);
-               break;
-       case CONTROL_SECTION:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart != UNINIT_PTR_IN_CS)
-                       SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart);
-               break;
-       case ISO_IMAGE1_PART2:
-               if (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start != UNINIT_PTR_IN_CS)
-                       SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start);
-               break;
-       case ISO_IMAGE1_PART3:
-               if (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start != UNINIT_PTR_IN_CS)
-                       SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start);
-               break;
-       case ISO_IMAGE2_PART2:
-               if (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start != UNINIT_PTR_IN_CS)
-                       SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start);
-               break;
-       case ISO_IMAGE2_PART3:
-               if (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start != UNINIT_PTR_IN_CS)
-                       SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start);
-               break;
-       default:
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section Does not exist in Flash 2.x");
-               SectStartOffset = INVALID_OFFSET;
-       }
-
-       return SectStartOffset;
-}
-
-/*
- * BcmGetSectionValEndOffset - this will calculate the section's Ending offset if section val is given
- * @Adapter : Drivers Private Data structure
- * @eFlashSectionVal : Flash secion value defined in enum bcm_flash2x_section_val
- *
- * Return value:-
- * On success it return the end offset of the provided section val
- * On Failure -returns STATUS_FAILURE
- */
-
-static int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal)
-{
-       int SectEndOffset = 0;
-
-       SectEndOffset = INVALID_OFFSET;
-       if (IsSectionExistInVendorInfo(Adapter, eFlash2xSectionVal))
-               return Adapter->psFlash2xVendorInfo->VendorSection[eFlash2xSectionVal].OffsetFromZeroForSectionEnd;
-
-       switch (eFlash2xSectionVal) {
-       case ISO_IMAGE1:
-               if ((Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End != UNINIT_PTR_IN_CS) &&
-                       (IsNonCDLessDevice(Adapter) == false))
-                       SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End);
-               break;
-       case ISO_IMAGE2:
-               if ((Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End != UNINIT_PTR_IN_CS) &&
-                       (IsNonCDLessDevice(Adapter) == false))
-                       SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End);
-               break;
-       case DSD0:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd != UNINIT_PTR_IN_CS)
-                       SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd);
-               break;
-       case DSD1:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End != UNINIT_PTR_IN_CS)
-                       SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End);
-               break;
-       case DSD2:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End != UNINIT_PTR_IN_CS)
-                       SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End);
-               break;
-       case VSA0:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAEnd != UNINIT_PTR_IN_CS)
-                       SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAEnd);
-               break;
-       case VSA1:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1End != UNINIT_PTR_IN_CS)
-                       SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1End);
-               break;
-       case VSA2:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2End != UNINIT_PTR_IN_CS)
-                       SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2End);
-               break;
-       case SCSI:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware != UNINIT_PTR_IN_CS)
-                       SectEndOffset = ((Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware) +
-                                       (Adapter->psFlash2xCSInfo->SizeOfScsiFirmware));
-               break;
-       case CONTROL_SECTION:
-               /* Not Clear So Putting failure. confirm and fix it. */
-               SectEndOffset = STATUS_FAILURE;
-               break;
-       case ISO_IMAGE1_PART2:
-               if (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End != UNINIT_PTR_IN_CS)
-                       SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End);
-               break;
-       case ISO_IMAGE1_PART3:
-               if (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End != UNINIT_PTR_IN_CS)
-                       SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End);
-               break;
-       case ISO_IMAGE2_PART2:
-               if (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End != UNINIT_PTR_IN_CS)
-                       SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End);
-               break;
-       case ISO_IMAGE2_PART3:
-               if (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End != UNINIT_PTR_IN_CS)
-                       SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End);
-               break;
-       default:
-               SectEndOffset = INVALID_OFFSET;
-       }
-
-       return SectEndOffset;
-}
-
-/*
- * BcmFlash2xBulkRead:- Read API for Flash Map 2.x .
- * @Adapter :Driver Private Data Structure
- * @pBuffer : Buffer where data has to be put after reading
- * @eFlashSectionVal :Flash Section Val defined in enum bcm_flash2x_section_val
- * @uiOffsetWithinSectionVal :- Offset with in provided section
- * @uiNumBytes : Number of Bytes for Read
- *
- * Return value:-
- * return true on success and STATUS_FAILURE on fail.
- */
-
-int BcmFlash2xBulkRead(struct bcm_mini_adapter *Adapter,
-               PUINT pBuffer,
-               enum bcm_flash2x_section_val eFlash2xSectionVal,
-               unsigned int uiOffsetWithinSectionVal,
-               unsigned int uiNumBytes)
-{
-       int Status = STATUS_SUCCESS;
-       int SectionStartOffset = 0;
-       unsigned int uiAbsoluteOffset = 0;
-       unsigned int uiTemp = 0, value = 0;
-
-       if (!Adapter) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Adapter structure is NULL");
-               return -EINVAL;
-       }
-       if (Adapter->device_removed) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device has been removed");
-               return -ENODEV;
-       }
-
-       /* NO_SECTION_VAL means absolute offset is given. */
-       if (eFlash2xSectionVal == NO_SECTION_VAL)
-               SectionStartOffset = 0;
-       else
-               SectionStartOffset = BcmGetSectionValStartOffset(Adapter, eFlash2xSectionVal);
-
-       if (SectionStartOffset == STATUS_FAILURE) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "This Section<%d> does not exist in Flash 2.x Map ", eFlash2xSectionVal);
-               return -EINVAL;
-       }
-
-       if (IsSectionExistInVendorInfo(Adapter, eFlash2xSectionVal))
-               return vendorextnReadSection(Adapter, (PUCHAR)pBuffer, eFlash2xSectionVal, uiOffsetWithinSectionVal, uiNumBytes);
-
-       /* calculating  the absolute offset from FLASH; */
-       uiAbsoluteOffset = uiOffsetWithinSectionVal + SectionStartOffset;
-       rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
-       value = 0;
-       wrmalt(Adapter, 0x0f000C80, &value, sizeof(value));
-       Status = BeceemFlashBulkRead(Adapter, pBuffer, uiAbsoluteOffset, uiNumBytes);
-       wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
-       if (Status) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Read Failed with Status :%d", Status);
-               return Status;
-       }
-
-       return Status;
-}
-
-/*
- * BcmFlash2xBulkWrite :-API for Writing on the Flash Map 2.x.
- * @Adapter :Driver Private Data Structure
- * @pBuffer : Buffer From where data has to taken for writing
- * @eFlashSectionVal :Flash Section Val defined in enum bcm_flash2x_section_val
- * @uiOffsetWithinSectionVal :- Offset with in provided section
- * @uiNumBytes : Number of Bytes for Write
- *
- * Return value:-
- * return true on success and STATUS_FAILURE on fail.
- *
- */
-
-int BcmFlash2xBulkWrite(struct bcm_mini_adapter *Adapter,
-                       PUINT pBuffer,
-                       enum bcm_flash2x_section_val eFlash2xSectVal,
-                       unsigned int uiOffset,
-                       unsigned int uiNumBytes,
-                       unsigned int bVerify)
-{
-       int Status = STATUS_SUCCESS;
-       unsigned int FlashSectValStartOffset = 0;
-       unsigned int uiTemp = 0, value = 0;
-
-       if (!Adapter) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Adapter structure is NULL");
-               return -EINVAL;
-       }
-
-       if (Adapter->device_removed) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device has been removed");
-               return -ENODEV;
-       }
-
-       /* NO_SECTION_VAL means absolute offset is given. */
-       if (eFlash2xSectVal == NO_SECTION_VAL)
-               FlashSectValStartOffset = 0;
-       else
-               FlashSectValStartOffset = BcmGetSectionValStartOffset(Adapter, eFlash2xSectVal);
-
-       if (FlashSectValStartOffset == STATUS_FAILURE) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "This Section<%d> does not exist in Flash Map 2.x", eFlash2xSectVal);
-               return -EINVAL;
-       }
-
-       if (IsSectionExistInVendorInfo(Adapter, eFlash2xSectVal))
-               return vendorextnWriteSection(Adapter, (PUCHAR)pBuffer, eFlash2xSectVal, uiOffset, uiNumBytes, bVerify);
-
-       /* calculating  the absolute offset from FLASH; */
-       uiOffset = uiOffset + FlashSectValStartOffset;
-
-       rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
-       value = 0;
-       wrmalt(Adapter, 0x0f000C80, &value, sizeof(value));
-
-       Status = BeceemFlashBulkWrite(Adapter, pBuffer, uiOffset, uiNumBytes, bVerify);
-
-       wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
-       if (Status) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Write failed with Status :%d", Status);
-               return Status;
-       }
-
-       return Status;
-}
-
-/*
- * BcmGetActiveDSD : Set the Active DSD in Adapter Structure which has to be dumped in DDR
- * @Adapter :-Drivers private Data Structure
- *
- * Return Value:-
- * Return STATUS_SUCESS if get success in setting the right DSD else negative error code
- *
- */
-
-static int BcmGetActiveDSD(struct bcm_mini_adapter *Adapter)
-{
-       enum bcm_flash2x_section_val uiHighestPriDSD = 0;
-
-       uiHighestPriDSD = getHighestPriDSD(Adapter);
-       Adapter->eActiveDSD = uiHighestPriDSD;
-
-       if (DSD0  == uiHighestPriDSD)
-               Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart;
-       if (DSD1 == uiHighestPriDSD)
-               Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start;
-       if (DSD2 == uiHighestPriDSD)
-               Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start;
-       if (Adapter->eActiveDSD)
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Active DSD :%d", Adapter->eActiveDSD);
-       if (Adapter->eActiveDSD == 0) {
-               /* if No DSD gets Active, Make Active the DSD with WR  permission */
-               if (IsSectionWritable(Adapter, DSD2)) {
-                       Adapter->eActiveDSD = DSD2;
-                       Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start;
-               } else if (IsSectionWritable(Adapter, DSD1)) {
-                       Adapter->eActiveDSD = DSD1;
-                       Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start;
-               } else if (IsSectionWritable(Adapter, DSD0)) {
-                       Adapter->eActiveDSD = DSD0;
-                       Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart;
-               }
-       }
-
-       return STATUS_SUCCESS;
-}
-
-/*
- * BcmGetActiveISO :- Set the Active ISO in Adapter Data Structue
- * @Adapter : Driver private Data Structure
- *
- * Return Value:-
- * Sucsess:- STATUS_SUCESS
- * Failure- : negative erro code
- *
- */
-
-static int BcmGetActiveISO(struct bcm_mini_adapter *Adapter)
-{
-       int HighestPriISO = 0;
-
-       HighestPriISO = getHighestPriISO(Adapter);
-
-       Adapter->eActiveISO = HighestPriISO;
-       if (Adapter->eActiveISO == ISO_IMAGE2)
-               Adapter->uiActiveISOOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start);
-       else if (Adapter->eActiveISO == ISO_IMAGE1)
-               Adapter->uiActiveISOOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start);
-
-       if (Adapter->eActiveISO)
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Active ISO :%x", Adapter->eActiveISO);
-
-       return STATUS_SUCCESS;
-}
-
-/*
- * IsOffsetWritable :- it will tell the access permission of the sector having passed offset
- * @Adapter : Drivers Private Data Structure
- * @uiOffset : Offset provided in the Flash
- *
- * Return Value:-
- * Success:-TRUE ,  offset is writable
- * Failure:-false, offset is RO
- *
- */
-
-static B_UINT8 IsOffsetWritable(struct bcm_mini_adapter *Adapter, unsigned int uiOffset)
-{
-       unsigned int uiSectorNum = 0;
-       unsigned int uiWordOfSectorPermission = 0;
-       unsigned int uiBitofSectorePermission = 0;
-       B_UINT32 permissionBits = 0;
-
-       uiSectorNum = uiOffset/Adapter->uiSectorSize;
-
-       /* calculating the word having this Sector Access permission from SectorAccessBitMap Array */
-       uiWordOfSectorPermission = Adapter->psFlash2xCSInfo->SectorAccessBitMap[uiSectorNum / 16];
-
-       /* calculating the bit index inside the word for  this sector */
-       uiBitofSectorePermission = 2 * (15 - uiSectorNum % 16);
-
-       /* Setting Access permission */
-       permissionBits = uiWordOfSectorPermission & (0x3 << uiBitofSectorePermission);
-       permissionBits = (permissionBits >> uiBitofSectorePermission) & 0x3;
-       if (permissionBits == SECTOR_READWRITE_PERMISSION)
-               return TRUE;
-       else
-               return false;
-}
-
-static int BcmDumpFlash2xSectionBitMap(struct bcm_flash2x_bitmap *psFlash2xBitMap)
-{
-       struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "***************Flash 2.x Section Bitmap***************");
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISO_IMAGE1  :0X%x", psFlash2xBitMap->ISO_IMAGE1);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISO_IMAGE2  :0X%x", psFlash2xBitMap->ISO_IMAGE2);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSD0  :0X%x", psFlash2xBitMap->DSD0);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSD1  :0X%x", psFlash2xBitMap->DSD1);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSD2  :0X%x", psFlash2xBitMap->DSD2);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "VSA0  :0X%x", psFlash2xBitMap->VSA0);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "VSA1  :0X%x", psFlash2xBitMap->VSA1);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "VSA2  :0X%x", psFlash2xBitMap->VSA2);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SCSI  :0X%x", psFlash2xBitMap->SCSI);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "CONTROL_SECTION  :0X%x", psFlash2xBitMap->CONTROL_SECTION);
-
-       return STATUS_SUCCESS;
-}
-
-/*
- * BcmGetFlash2xSectionalBitMap :- It will provide the bit map of all the section present in Flash
- * 8bit has been assigned to every section.
- * bit[0] :Section present or not
- * bit[1] :section is valid or not
- * bit[2] : Secton is read only or has write permission too.
- * bit[3] : Active Section -
- * bit[7...4] = Reserved .
- *
- * @Adapter:-Driver private Data Structure
- *
- * Return value:-
- * Success:- STATUS_SUCESS
- * Failure:- negative error code
- */
-
-int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_bitmap *psFlash2xBitMap)
-{
-       struct bcm_flash2x_cs_info *psFlash2xCSInfo = Adapter->psFlash2xCSInfo;
-       enum bcm_flash2x_section_val uiHighestPriDSD = 0;
-       enum bcm_flash2x_section_val uiHighestPriISO = 0;
-       bool SetActiveDSDDone = false;
-       bool SetActiveISODone = false;
-
-       /* For 1.x map all the section except DSD0 will be shown as not present
-        * This part will be used by calibration tool to detect the number of DSD present in Flash.
-        */
-       if (IsFlash2x(Adapter) == false) {
-               psFlash2xBitMap->ISO_IMAGE2 = 0;
-               psFlash2xBitMap->ISO_IMAGE1 = 0;
-               psFlash2xBitMap->DSD0 = FLASH2X_SECTION_VALID | FLASH2X_SECTION_ACT | FLASH2X_SECTION_PRESENT; /* 0xF; 0000(Reseved)1(Active)0(RW)1(valid)1(present) */
-               psFlash2xBitMap->DSD1  = 0;
-               psFlash2xBitMap->DSD2 = 0;
-               psFlash2xBitMap->VSA0 = 0;
-               psFlash2xBitMap->VSA1 = 0;
-               psFlash2xBitMap->VSA2 = 0;
-               psFlash2xBitMap->CONTROL_SECTION = 0;
-               psFlash2xBitMap->SCSI = 0;
-               psFlash2xBitMap->Reserved0 = 0;
-               psFlash2xBitMap->Reserved1 = 0;
-               psFlash2xBitMap->Reserved2 = 0;
-
-               return STATUS_SUCCESS;
-       }
-
-       uiHighestPriDSD = getHighestPriDSD(Adapter);
-       uiHighestPriISO = getHighestPriISO(Adapter);
-
-       /*
-        * IS0 IMAGE 2
-        */
-       if ((psFlash2xCSInfo->OffsetISOImage2Part1Start) != UNINIT_PTR_IN_CS) {
-               /* Setting the 0th Bit representing the Section is present or not. */
-               psFlash2xBitMap->ISO_IMAGE2 = psFlash2xBitMap->ISO_IMAGE2 | FLASH2X_SECTION_PRESENT;
-
-               if (ReadISOSignature(Adapter, ISO_IMAGE2) == ISO_IMAGE_MAGIC_NUMBER)
-                       psFlash2xBitMap->ISO_IMAGE2 |= FLASH2X_SECTION_VALID;
-
-               /* Calculation for extrating the Access permission */
-               if (IsSectionWritable(Adapter, ISO_IMAGE2) == false)
-                       psFlash2xBitMap->ISO_IMAGE2 |= FLASH2X_SECTION_RO;
-
-               if (SetActiveISODone == false && uiHighestPriISO == ISO_IMAGE2) {
-                       psFlash2xBitMap->ISO_IMAGE2 |= FLASH2X_SECTION_ACT;
-                       SetActiveISODone = TRUE;
-               }
-       }
-
-       /*
-        * IS0 IMAGE 1
-        */
-       if ((psFlash2xCSInfo->OffsetISOImage1Part1Start) != UNINIT_PTR_IN_CS) {
-               /* Setting the 0th Bit representing the Section is present or not. */
-               psFlash2xBitMap->ISO_IMAGE1 = psFlash2xBitMap->ISO_IMAGE1 | FLASH2X_SECTION_PRESENT;
-
-               if (ReadISOSignature(Adapter, ISO_IMAGE1) == ISO_IMAGE_MAGIC_NUMBER)
-                       psFlash2xBitMap->ISO_IMAGE1 |= FLASH2X_SECTION_VALID;
-
-               /* Calculation for extrating the Access permission */
-               if (IsSectionWritable(Adapter, ISO_IMAGE1) == false)
-                       psFlash2xBitMap->ISO_IMAGE1 |= FLASH2X_SECTION_RO;
-
-               if (SetActiveISODone == false && uiHighestPriISO == ISO_IMAGE1) {
-                       psFlash2xBitMap->ISO_IMAGE1 |= FLASH2X_SECTION_ACT;
-                       SetActiveISODone = TRUE;
-               }
-       }
-
-       /*
-        * DSD2
-        */
-       if ((psFlash2xCSInfo->OffsetFromZeroForDSD2Start) != UNINIT_PTR_IN_CS) {
-               /* Setting the 0th Bit representing the Section is present or not. */
-               psFlash2xBitMap->DSD2 = psFlash2xBitMap->DSD2 | FLASH2X_SECTION_PRESENT;
-
-               if (ReadDSDSignature(Adapter, DSD2) == DSD_IMAGE_MAGIC_NUMBER)
-                       psFlash2xBitMap->DSD2 |= FLASH2X_SECTION_VALID;
-
-               /* Calculation for extrating the Access permission */
-               if (IsSectionWritable(Adapter, DSD2) == false) {
-                       psFlash2xBitMap->DSD2 |= FLASH2X_SECTION_RO;
-               } else {
-                       /* Means section is writable */
-                       if ((SetActiveDSDDone == false) && (uiHighestPriDSD == DSD2)) {
-                               psFlash2xBitMap->DSD2 |= FLASH2X_SECTION_ACT;
-                               SetActiveDSDDone = TRUE;
-                       }
-               }
-       }
-
-       /*
-        * DSD 1
-        */
-       if ((psFlash2xCSInfo->OffsetFromZeroForDSD1Start) != UNINIT_PTR_IN_CS) {
-               /* Setting the 0th Bit representing the Section is present or not. */
-               psFlash2xBitMap->DSD1 = psFlash2xBitMap->DSD1 | FLASH2X_SECTION_PRESENT;
-
-               if (ReadDSDSignature(Adapter, DSD1) == DSD_IMAGE_MAGIC_NUMBER)
-                       psFlash2xBitMap->DSD1 |= FLASH2X_SECTION_VALID;
-
-               /* Calculation for extrating the Access permission */
-               if (IsSectionWritable(Adapter, DSD1) == false) {
-                       psFlash2xBitMap->DSD1 |= FLASH2X_SECTION_RO;
-               } else {
-                       /* Means section is writable */
-                       if ((SetActiveDSDDone == false) && (uiHighestPriDSD == DSD1)) {
-                               psFlash2xBitMap->DSD1 |= FLASH2X_SECTION_ACT;
-                               SetActiveDSDDone = TRUE;
-                       }
-               }
-       }
-
-       /*
-        * For DSD 0
-        */
-       if ((psFlash2xCSInfo->OffsetFromZeroForDSDStart) != UNINIT_PTR_IN_CS) {
-               /* Setting the 0th Bit representing the Section is present or not. */
-               psFlash2xBitMap->DSD0 = psFlash2xBitMap->DSD0 | FLASH2X_SECTION_PRESENT;
-
-               if (ReadDSDSignature(Adapter, DSD0) == DSD_IMAGE_MAGIC_NUMBER)
-                       psFlash2xBitMap->DSD0 |= FLASH2X_SECTION_VALID;
-
-               /* Setting Access permission */
-               if (IsSectionWritable(Adapter, DSD0) == false) {
-                       psFlash2xBitMap->DSD0 |= FLASH2X_SECTION_RO;
-               } else {
-                       /* Means section is writable */
-                       if ((SetActiveDSDDone == false) && (uiHighestPriDSD == DSD0)) {
-                               psFlash2xBitMap->DSD0 |= FLASH2X_SECTION_ACT;
-                               SetActiveDSDDone = TRUE;
-                       }
-               }
-       }
-
-       /*
-        * VSA 0
-        */
-       if ((psFlash2xCSInfo->OffsetFromZeroForVSAStart) != UNINIT_PTR_IN_CS) {
-               /* Setting the 0th Bit representing the Section is present or not. */
-               psFlash2xBitMap->VSA0 = psFlash2xBitMap->VSA0 | FLASH2X_SECTION_PRESENT;
-
-               /* Setting the Access Bit. Map is not defined hece setting it always valid */
-               psFlash2xBitMap->VSA0 |= FLASH2X_SECTION_VALID;
-
-               /* Calculation for extrating the Access permission */
-               if (IsSectionWritable(Adapter, VSA0) == false)
-                       psFlash2xBitMap->VSA0 |=  FLASH2X_SECTION_RO;
-
-               /* By Default section is Active */
-               psFlash2xBitMap->VSA0 |= FLASH2X_SECTION_ACT;
-       }
-
-       /*
-        * VSA 1
-        */
-       if ((psFlash2xCSInfo->OffsetFromZeroForVSA1Start) != UNINIT_PTR_IN_CS) {
-               /* Setting the 0th Bit representing the Section is present or not. */
-               psFlash2xBitMap->VSA1 = psFlash2xBitMap->VSA1 | FLASH2X_SECTION_PRESENT;
-
-               /* Setting the Access Bit. Map is not defined hece setting it always valid */
-               psFlash2xBitMap->VSA1 |= FLASH2X_SECTION_VALID;
-
-               /* Checking For Access permission */
-               if (IsSectionWritable(Adapter, VSA1) == false)
-                       psFlash2xBitMap->VSA1 |= FLASH2X_SECTION_RO;
-
-               /* By Default section is Active */
-               psFlash2xBitMap->VSA1 |= FLASH2X_SECTION_ACT;
-       }
-
-       /*
-        * VSA 2
-        */
-       if ((psFlash2xCSInfo->OffsetFromZeroForVSA2Start) != UNINIT_PTR_IN_CS) {
-               /* Setting the 0th Bit representing the Section is present or not. */
-               psFlash2xBitMap->VSA2 = psFlash2xBitMap->VSA2 | FLASH2X_SECTION_PRESENT;
-
-               /* Setting the Access Bit. Map is not defined hece setting it always valid */
-               psFlash2xBitMap->VSA2 |= FLASH2X_SECTION_VALID;
-
-               /* Checking For Access permission */
-               if (IsSectionWritable(Adapter, VSA2) == false)
-                       psFlash2xBitMap->VSA2 |= FLASH2X_SECTION_RO;
-
-               /* By Default section is Active */
-               psFlash2xBitMap->VSA2 |= FLASH2X_SECTION_ACT;
-       }
-
-       /*
-        * SCSI Section
-        */
-       if ((psFlash2xCSInfo->OffsetFromZeroForScsiFirmware) != UNINIT_PTR_IN_CS) {
-               /* Setting the 0th Bit representing the Section is present or not. */
-               psFlash2xBitMap->SCSI = psFlash2xBitMap->SCSI | FLASH2X_SECTION_PRESENT;
-
-               /* Setting the Access Bit. Map is not defined hece setting it always valid */
-               psFlash2xBitMap->SCSI |= FLASH2X_SECTION_VALID;
-
-               /* Checking For Access permission */
-               if (IsSectionWritable(Adapter, SCSI) == false)
-                       psFlash2xBitMap->SCSI |= FLASH2X_SECTION_RO;
-
-               /* By Default section is Active */
-               psFlash2xBitMap->SCSI |= FLASH2X_SECTION_ACT;
-       }
-
-       /*
-        * Control Section
-        */
-       if ((psFlash2xCSInfo->OffsetFromZeroForControlSectionStart) != UNINIT_PTR_IN_CS) {
-               /* Setting the 0th Bit representing the Section is present or not. */
-               psFlash2xBitMap->CONTROL_SECTION = psFlash2xBitMap->CONTROL_SECTION | (FLASH2X_SECTION_PRESENT);
-
-               /* Setting the Access Bit. Map is not defined hece setting it always valid */
-               psFlash2xBitMap->CONTROL_SECTION |= FLASH2X_SECTION_VALID;
-
-               /* Checking For Access permission */
-               if (IsSectionWritable(Adapter, CONTROL_SECTION) == false)
-                       psFlash2xBitMap->CONTROL_SECTION |= FLASH2X_SECTION_RO;
-
-               /* By Default section is Active */
-               psFlash2xBitMap->CONTROL_SECTION |= FLASH2X_SECTION_ACT;
-       }
-
-       /*
-        * For Reserved Sections
-        */
-       psFlash2xBitMap->Reserved0 = 0;
-       psFlash2xBitMap->Reserved0 = 0;
-       psFlash2xBitMap->Reserved0 = 0;
-       BcmDumpFlash2xSectionBitMap(psFlash2xBitMap);
-
-       return STATUS_SUCCESS;
-}
-
-/*
- * BcmSetActiveSection :- Set Active section is used to make priority field highest over other
- * section of same type.
- *
- * @Adapater :- Bcm Driver Private Data Structure
- * @eFlash2xSectionVal :- Flash section val whose priority has to be made highest.
- *
- * Return Value:- Make the priorit highest else return erorr code
- *
- */
-
-int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectVal)
-{
-       unsigned int SectImagePriority = 0;
-       int Status = STATUS_SUCCESS;
-
-       /* struct bcm_dsd_header sDSD = {0};
-        * struct bcm_iso_header sISO = {0};
-        */
-       int HighestPriDSD = 0;
-       int HighestPriISO = 0;
-
-       Status = IsSectionWritable(Adapter, eFlash2xSectVal);
-       if (Status != TRUE) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Provided Section <%d> is not writable", eFlash2xSectVal);
-               return STATUS_FAILURE;
-       }
-
-       Adapter->bHeaderChangeAllowed = TRUE;
-       switch (eFlash2xSectVal) {
-       case ISO_IMAGE1:
-       case ISO_IMAGE2:
-               if (ReadISOSignature(Adapter, eFlash2xSectVal) == ISO_IMAGE_MAGIC_NUMBER) {
-                       HighestPriISO = getHighestPriISO(Adapter);
-
-                       if (HighestPriISO == eFlash2xSectVal) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Given ISO<%x> already has highest priority", eFlash2xSectVal);
-                               Status = STATUS_SUCCESS;
-                               break;
-                       }
-
-                       SectImagePriority = ReadISOPriority(Adapter, HighestPriISO) + 1;
-
-                       if ((SectImagePriority == 0) && IsSectionWritable(Adapter, HighestPriISO)) {
-                               /* This is a SPECIAL Case which will only happen if the current highest priority ISO has priority value = 0x7FFFFFFF.
-                                * We will write 1 to the current Highest priority ISO And then shall increase the priority of the requested ISO
-                                * by user
-                                */
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SectImagePriority wraparound happened, eFlash2xSectVal: 0x%x\n", eFlash2xSectVal);
-                               SectImagePriority = htonl(0x1);
-                               Status = BcmFlash2xBulkWrite(Adapter,
-                                                       &SectImagePriority,
-                                                       HighestPriISO,
-                                                       0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImagePriority),
-                                                       SIGNATURE_SIZE,
-                                                       TRUE);
-                               if (Status) {
-                                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly");
-                                       Status = STATUS_FAILURE;
-                                       break;
-                               }
-
-                               HighestPriISO = getHighestPriISO(Adapter);
-
-                               if (HighestPriISO == eFlash2xSectVal) {
-                                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Given ISO<%x> already has highest priority", eFlash2xSectVal);
-                                       Status = STATUS_SUCCESS;
-                                       break;
-                               }
-
-                               SectImagePriority = 2;
-                       }
-
-                       SectImagePriority = htonl(SectImagePriority);
-
-                       Status = BcmFlash2xBulkWrite(Adapter,
-                                               &SectImagePriority,
-                                               eFlash2xSectVal,
-                                               0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImagePriority),
-                                               SIGNATURE_SIZE,
-                                               TRUE);
-                       if (Status) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly");
-                               break;
-                       }
-               } else {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Signature is currupted. Hence can't increase the priority");
-                       Status = STATUS_FAILURE;
-                       break;
-               }
-               break;
-       case DSD0:
-       case DSD1:
-       case DSD2:
-               if (ReadDSDSignature(Adapter, eFlash2xSectVal) == DSD_IMAGE_MAGIC_NUMBER) {
-                       HighestPriDSD = getHighestPriDSD(Adapter);
-                       if (HighestPriDSD == eFlash2xSectVal) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Given DSD<%x> already has highest priority", eFlash2xSectVal);
-                               Status = STATUS_SUCCESS;
-                               break;
-                       }
-
-                       SectImagePriority = ReadDSDPriority(Adapter, HighestPriDSD) + 1;
-                       if (SectImagePriority == 0) {
-                               /* This is a SPECIAL Case which will only happen if the current highest priority DSD has priority value = 0x7FFFFFFF.
-                                * We will write 1 to the current Highest priority DSD And then shall increase the priority of the requested DSD
-                                * by user
-                                */
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, NVM_RW, DBG_LVL_ALL, "SectImagePriority wraparound happened, eFlash2xSectVal: 0x%x\n", eFlash2xSectVal);
-                               SectImagePriority = htonl(0x1);
-
-                               Status = BcmFlash2xBulkWrite(Adapter,
-                                                       &SectImagePriority,
-                                                       HighestPriDSD,
-                                                       Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority),
-                                                       SIGNATURE_SIZE,
-                                                       TRUE);
-                               if (Status) {
-                                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly");
-                                       break;
-                               }
-
-                               HighestPriDSD = getHighestPriDSD(Adapter);
-
-                               if (HighestPriDSD == eFlash2xSectVal) {
-                                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Made the DSD: %x highest by reducing priority of other\n", eFlash2xSectVal);
-                                       Status = STATUS_SUCCESS;
-                                       break;
-                               }
-
-                               SectImagePriority = htonl(0x2);
-                               Status = BcmFlash2xBulkWrite(Adapter,
-                                                       &SectImagePriority,
-                                                       HighestPriDSD,
-                                                       Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority),
-                                                       SIGNATURE_SIZE,
-                                                       TRUE);
-                               if (Status) {
-                                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly");
-                                       break;
-                               }
-
-                               HighestPriDSD = getHighestPriDSD(Adapter);
-                               if (HighestPriDSD == eFlash2xSectVal) {
-                                       Status = STATUS_SUCCESS;
-                                       break;
-                               }
-
-                               SectImagePriority = 3;
-                       }
-                       SectImagePriority = htonl(SectImagePriority);
-                       Status = BcmFlash2xBulkWrite(Adapter,
-                                               &SectImagePriority,
-                                               eFlash2xSectVal,
-                                               Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority),
-                                               SIGNATURE_SIZE,
-                                               TRUE);
-                       if (Status) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly");
-                               Status = STATUS_FAILURE;
-                               break;
-                       }
-               } else {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Signature is currupted. Hence can't increase the priority");
-                       Status = STATUS_FAILURE;
-                       break;
-               }
-               break;
-       case VSA0:
-       case VSA1:
-       case VSA2:
-               /* Has to be decided */
-               break;
-       default:
-               Status = STATUS_FAILURE;
-               break;
-       }
-
-       Adapter->bHeaderChangeAllowed = false;
-       return Status;
-}
-
-/*
- * BcmCopyISO - Used only for copying the ISO section
- * @Adapater :- Bcm Driver Private Data Structure
- * @sCopySectStrut :- Section copy structure
- *
- * Return value:- SUCCESS if copies successfully else negative error code
- *
- */
-
-int BcmCopyISO(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_copy_section sCopySectStrut)
-{
-       PCHAR Buff = NULL;
-       enum bcm_flash2x_section_val eISOReadPart = 0, eISOWritePart = 0;
-       unsigned int uiReadOffsetWithinPart = 0, uiWriteOffsetWithinPart = 0;
-       unsigned int uiTotalDataToCopy = 0;
-       bool IsThisHeaderSector = false;
-       unsigned int sigOffset = 0;
-       unsigned int ISOLength = 0;
-       unsigned int Status = STATUS_SUCCESS;
-       unsigned int SigBuff[MAX_RW_SIZE];
-       unsigned int i = 0;
-
-       if (ReadISOSignature(Adapter, sCopySectStrut.SrcSection) != ISO_IMAGE_MAGIC_NUMBER) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "error as Source ISO Section does not have valid signature");
-               return STATUS_FAILURE;
-       }
-
-       Status = BcmFlash2xBulkRead(Adapter, &ISOLength,
-                                   sCopySectStrut.SrcSection,
-                                   0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageSize),
-                                   4);
-       if (Status) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read failed while copying ISO\n");
-               return Status;
-       }
-
-       ISOLength = htonl(ISOLength);
-       if (ISOLength % Adapter->uiSectorSize)
-               ISOLength = Adapter->uiSectorSize * (1 + ISOLength/Adapter->uiSectorSize);
-
-       sigOffset = FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageMagicNumber);
-
-       Buff = kzalloc(Adapter->uiSectorSize, GFP_KERNEL);
-
-       if (!Buff) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed for section size");
-               return -ENOMEM;
-       }
-
-       if (sCopySectStrut.SrcSection == ISO_IMAGE1 && sCopySectStrut.DstSection == ISO_IMAGE2) {
-               eISOReadPart = ISO_IMAGE1;
-               eISOWritePart = ISO_IMAGE2;
-               uiReadOffsetWithinPart =  0;
-               uiWriteOffsetWithinPart = 0;
-
-               uiTotalDataToCopy = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End) -
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start) +
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End) -
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start) +
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End) -
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start);
-
-               if (uiTotalDataToCopy < ISOLength) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "error as Source ISO Section does not have valid signature");
-                       Status = STATUS_FAILURE;
-                       goto out;
-               }
-
-               uiTotalDataToCopy = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End) -
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start) +
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End) -
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start) +
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End) -
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start);
-
-               if (uiTotalDataToCopy < ISOLength) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "error as Dest ISO Section does not have enough section size");
-                       Status = STATUS_FAILURE;
-                       goto out;
-               }
-
-               uiTotalDataToCopy = ISOLength;
-
-               CorruptISOSig(Adapter, ISO_IMAGE2);
-               while (uiTotalDataToCopy) {
-                       if (uiTotalDataToCopy == Adapter->uiSectorSize) {
-                               /* Setting for write of first sector. First sector is assumed to be written in last */
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Writing the signature sector");
-                               eISOReadPart = ISO_IMAGE1;
-                               uiReadOffsetWithinPart = 0;
-                               eISOWritePart = ISO_IMAGE2;
-                               uiWriteOffsetWithinPart = 0;
-                               IsThisHeaderSector = TRUE;
-                       } else {
-                               uiReadOffsetWithinPart = uiReadOffsetWithinPart + Adapter->uiSectorSize;
-                               uiWriteOffsetWithinPart = uiWriteOffsetWithinPart + Adapter->uiSectorSize;
-
-                               if ((eISOReadPart == ISO_IMAGE1) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start))) {
-                                       eISOReadPart = ISO_IMAGE1_PART2;
-                                       uiReadOffsetWithinPart = 0;
-                               }
-
-                               if ((eISOReadPart == ISO_IMAGE1_PART2) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start))) {
-                                       eISOReadPart = ISO_IMAGE1_PART3;
-                                       uiReadOffsetWithinPart = 0;
-                               }
-
-                               if ((eISOWritePart == ISO_IMAGE2) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start))) {
-                                       eISOWritePart = ISO_IMAGE2_PART2;
-                                       uiWriteOffsetWithinPart = 0;
-                               }
-
-                               if ((eISOWritePart == ISO_IMAGE2_PART2) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start))) {
-                                       eISOWritePart = ISO_IMAGE2_PART3;
-                                       uiWriteOffsetWithinPart = 0;
-                               }
-                       }
-
-                       Status = BcmFlash2xBulkRead(Adapter,
-                                               (PUINT)Buff,
-                                               eISOReadPart,
-                                               uiReadOffsetWithinPart,
-                                               Adapter->uiSectorSize);
-                       if (Status) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOReadPart, uiReadOffsetWithinPart);
-                               break;
-                       }
-
-                       if (IsThisHeaderSector == TRUE) {
-                               /* If this is header sector write 0xFFFFFFFF at the sig time and in last write sig */
-                               memcpy(SigBuff, Buff + sigOffset, sizeof(SigBuff));
-
-                               for (i = 0; i < MAX_RW_SIZE; i++)
-                                       *(Buff + sigOffset + i) = 0xFF;
-                       }
-                       Adapter->bHeaderChangeAllowed = TRUE;
-                       Status = BcmFlash2xBulkWrite(Adapter,
-                                               (PUINT)Buff,
-                                               eISOWritePart,
-                                               uiWriteOffsetWithinPart,
-                                               Adapter->uiSectorSize,
-                                               TRUE);
-                       if (Status) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOWritePart, uiWriteOffsetWithinPart);
-                               break;
-                       }
-
-                       Adapter->bHeaderChangeAllowed = false;
-                       if (IsThisHeaderSector == TRUE) {
-                               WriteToFlashWithoutSectorErase(Adapter,
-                                                       SigBuff,
-                                                       eISOWritePart,
-                                                       sigOffset,
-                                                       MAX_RW_SIZE);
-                               IsThisHeaderSector = false;
-                       }
-                       /* subtracting the written Data */
-                       uiTotalDataToCopy = uiTotalDataToCopy - Adapter->uiSectorSize;
-               }
-       }
-
-       if (sCopySectStrut.SrcSection == ISO_IMAGE2 && sCopySectStrut.DstSection == ISO_IMAGE1) {
-               eISOReadPart = ISO_IMAGE2;
-               eISOWritePart = ISO_IMAGE1;
-               uiReadOffsetWithinPart = 0;
-               uiWriteOffsetWithinPart = 0;
-
-               uiTotalDataToCopy = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End) -
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start) +
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End) -
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start) +
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End) -
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start);
-
-               if (uiTotalDataToCopy < ISOLength) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "error as Source ISO Section does not have valid signature");
-                       Status = STATUS_FAILURE;
-                       goto out;
-               }
-
-               uiTotalDataToCopy = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End) -
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start) +
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End) -
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start) +
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End) -
-                       (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start);
-
-               if (uiTotalDataToCopy < ISOLength) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "error as Dest ISO Section does not have enough section size");
-                       Status = STATUS_FAILURE;
-                       goto out;
-               }
-
-               uiTotalDataToCopy = ISOLength;
-
-               CorruptISOSig(Adapter, ISO_IMAGE1);
-
-               while (uiTotalDataToCopy) {
-                       if (uiTotalDataToCopy == Adapter->uiSectorSize) {
-                               /* Setting for write of first sector. First sector is assumed to be written in last */
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Writing the signature sector");
-                               eISOReadPart = ISO_IMAGE2;
-                               uiReadOffsetWithinPart = 0;
-                               eISOWritePart = ISO_IMAGE1;
-                               uiWriteOffsetWithinPart = 0;
-                               IsThisHeaderSector = TRUE;
-                       } else {
-                               uiReadOffsetWithinPart = uiReadOffsetWithinPart + Adapter->uiSectorSize;
-                               uiWriteOffsetWithinPart = uiWriteOffsetWithinPart + Adapter->uiSectorSize;
-
-                               if ((eISOReadPart == ISO_IMAGE2) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start))) {
-                                       eISOReadPart = ISO_IMAGE2_PART2;
-                                       uiReadOffsetWithinPart = 0;
-                               }
-
-                               if ((eISOReadPart == ISO_IMAGE2_PART2) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start))) {
-                                       eISOReadPart = ISO_IMAGE2_PART3;
-                                       uiReadOffsetWithinPart = 0;
-                               }
-
-                               if ((eISOWritePart == ISO_IMAGE1) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start))) {
-                                       eISOWritePart = ISO_IMAGE1_PART2;
-                                       uiWriteOffsetWithinPart = 0;
-                               }
-
-                               if ((eISOWritePart == ISO_IMAGE1_PART2) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start))) {
-                                       eISOWritePart = ISO_IMAGE1_PART3;
-                                       uiWriteOffsetWithinPart = 0;
-                               }
-                       }
-
-                       Status = BcmFlash2xBulkRead(Adapter,
-                                               (PUINT)Buff,
-                                               eISOReadPart,
-                                               uiReadOffsetWithinPart,
-                                               Adapter->uiSectorSize);
-                       if (Status) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOReadPart, uiReadOffsetWithinPart);
-                               break;
-                       }
-
-                       if (IsThisHeaderSector == TRUE) {
-                               /* If this is header sector write 0xFFFFFFFF at the sig time and in last write sig */
-                               memcpy(SigBuff, Buff + sigOffset, sizeof(SigBuff));
-
-                               for (i = 0; i < MAX_RW_SIZE; i++)
-                                       *(Buff + sigOffset + i) = 0xFF;
-                       }
-                       Adapter->bHeaderChangeAllowed = TRUE;
-                       Status = BcmFlash2xBulkWrite(Adapter,
-                                               (PUINT)Buff,
-                                               eISOWritePart,
-                                               uiWriteOffsetWithinPart,
-                                               Adapter->uiSectorSize,
-                                               TRUE);
-                       if (Status) {
-                               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOWritePart, uiWriteOffsetWithinPart);
-                               break;
-                       }
-
-                       Adapter->bHeaderChangeAllowed = false;
-                       if (IsThisHeaderSector == TRUE) {
-                               WriteToFlashWithoutSectorErase(Adapter,
-                                                       SigBuff,
-                                                       eISOWritePart,
-                                                       sigOffset,
-                                                       MAX_RW_SIZE);
-
-                               IsThisHeaderSector = false;
-                       }
-
-                       /* subtracting the written Data */
-                       uiTotalDataToCopy = uiTotalDataToCopy - Adapter->uiSectorSize;
-               }
-       }
-out:
-       kfree(Buff);
-
-       return Status;
-}
-
-/*
- * BcmFlash2xCorruptSig : this API is used to corrupt the written sig in Bcm Header present in flash section.
- * It will corrupt the sig, if Section is writable, by making first bytes as zero.
- * @Adapater :- Bcm Driver Private Data Structure
- * @eFlash2xSectionVal :- Flash section val which has header
- *
- * Return Value :-
- *     Success :- If Section is present and writable, corrupt the sig and return STATUS_SUCCESS
- *     Failure :-Return negative error code
- */
-
-int BcmFlash2xCorruptSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal)
-{
-       int Status = STATUS_SUCCESS;
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section Value :%x\n", eFlash2xSectionVal);
-
-       if ((eFlash2xSectionVal == DSD0) || (eFlash2xSectionVal == DSD1) || (eFlash2xSectionVal == DSD2)) {
-               Status = CorruptDSDSig(Adapter, eFlash2xSectionVal);
-       } else if (eFlash2xSectionVal == ISO_IMAGE1 || eFlash2xSectionVal == ISO_IMAGE2) {
-               Status = CorruptISOSig(Adapter, eFlash2xSectionVal);
-       } else {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Given Section <%d>does not have Header", eFlash2xSectionVal);
-               return STATUS_SUCCESS;
-       }
-       return Status;
-}
-
-/*
- *BcmFlash2xWriteSig :-this API is used to Write the sig if requested Section has
- *                                       header and  Write Permission.
- * @Adapater :- Bcm Driver Private Data Structure
- * @eFlashSectionVal :- Flash section val which has header
- *
- * Return Value :-
- *     Success :- If Section is present and writable write the sig and return STATUS_SUCCESS
- *     Failure :-Return negative error code
- */
-
-int BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlashSectionVal)
-{
-       unsigned int uiSignature = 0;
-       unsigned int uiOffset = 0;
-
-       /* struct bcm_dsd_header dsdHeader = {0}; */
-       if (Adapter->bSigCorrupted == false) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Signature is not corrupted by driver, hence not restoring\n");
-               return STATUS_SUCCESS;
-       }
-
-       if (Adapter->bAllDSDWriteAllow == false) {
-               if (IsSectionWritable(Adapter, eFlashSectionVal) == false) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section is not Writable...Hence can't Write signature");
-                       return SECTOR_IS_NOT_WRITABLE;
-               }
-       }
-
-       if ((eFlashSectionVal == DSD0) || (eFlashSectionVal == DSD1) || (eFlashSectionVal == DSD2)) {
-               uiSignature = htonl(DSD_IMAGE_MAGIC_NUMBER);
-               uiOffset = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader;
-
-               uiOffset += FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImageMagicNumber);
-
-               if ((ReadDSDSignature(Adapter, eFlashSectionVal) & 0xFF000000) != CORRUPTED_PATTERN) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Corrupted Pattern is not there. Hence won't write sig");
-                       return STATUS_FAILURE;
-               }
-       } else if ((eFlashSectionVal == ISO_IMAGE1) || (eFlashSectionVal == ISO_IMAGE2)) {
-               uiSignature = htonl(ISO_IMAGE_MAGIC_NUMBER);
-               /* uiOffset = 0; */
-               uiOffset = FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageMagicNumber);
-               if ((ReadISOSignature(Adapter, eFlashSectionVal) & 0xFF000000) != CORRUPTED_PATTERN) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Currupted Pattern is not there. Hence won't write sig");
-                       return STATUS_FAILURE;
-               }
-       } else {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "GIVEN SECTION< %d > IS NOT VALID FOR SIG WRITE...", eFlashSectionVal);
-               return STATUS_FAILURE;
-       }
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Restoring the signature");
-
-       Adapter->bHeaderChangeAllowed = TRUE;
-       Adapter->bSigCorrupted = false;
-       BcmFlash2xBulkWrite(Adapter, &uiSignature, eFlashSectionVal, uiOffset, SIGNATURE_SIZE, TRUE);
-       Adapter->bHeaderChangeAllowed = false;
-
-       return STATUS_SUCCESS;
-}
-
-/*
- * validateFlash2xReadWrite :- This API is used to validate the user request for Read/Write.
- *                                                   if requested Bytes goes beyond the Requested section, it reports error.
- * @Adapater :- Bcm Driver Private Data Structure
- * @psFlash2xReadWrite :-Flash2x Read/write structure pointer
- *
- * Return values:-Return TRUE is request is valid else false.
- */
-
-int validateFlash2xReadWrite(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_readwrite *psFlash2xReadWrite)
-{
-       unsigned int uiNumOfBytes = 0;
-       unsigned int uiSectStartOffset = 0;
-       unsigned int uiSectEndOffset = 0;
-
-       uiNumOfBytes = psFlash2xReadWrite->numOfBytes;
-
-       if (IsSectionExistInFlash(Adapter, psFlash2xReadWrite->Section) != TRUE) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section<%x> does not exist in Flash", psFlash2xReadWrite->Section);
-               return false;
-       }
-       uiSectStartOffset = BcmGetSectionValStartOffset(Adapter, psFlash2xReadWrite->Section);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Start offset :%x ,section :%d\n", uiSectStartOffset, psFlash2xReadWrite->Section);
-       if ((psFlash2xReadWrite->Section == ISO_IMAGE1) || (psFlash2xReadWrite->Section == ISO_IMAGE2)) {
-               if (psFlash2xReadWrite->Section == ISO_IMAGE1) {
-                       uiSectEndOffset = BcmGetSectionValEndOffset(Adapter, ISO_IMAGE1) -
-                               BcmGetSectionValStartOffset(Adapter, ISO_IMAGE1) +
-                               BcmGetSectionValEndOffset(Adapter, ISO_IMAGE1_PART2) -
-                               BcmGetSectionValStartOffset(Adapter, ISO_IMAGE1_PART2) +
-                               BcmGetSectionValEndOffset(Adapter, ISO_IMAGE1_PART3) -
-                               BcmGetSectionValStartOffset(Adapter, ISO_IMAGE1_PART3);
-               } else if (psFlash2xReadWrite->Section == ISO_IMAGE2) {
-                       uiSectEndOffset = BcmGetSectionValEndOffset(Adapter, ISO_IMAGE2) -
-                               BcmGetSectionValStartOffset(Adapter, ISO_IMAGE2) +
-                               BcmGetSectionValEndOffset(Adapter, ISO_IMAGE2_PART2) -
-                               BcmGetSectionValStartOffset(Adapter, ISO_IMAGE2_PART2) +
-                               BcmGetSectionValEndOffset(Adapter, ISO_IMAGE2_PART3) -
-                               BcmGetSectionValStartOffset(Adapter, ISO_IMAGE2_PART3);
-               }
-
-               /* since this uiSectEndoffset is the size of iso Image. hence for calculating the virtual endoffset
-                * it should be added in startoffset. so that check done in last of this function can be valued.
-                */
-               uiSectEndOffset = uiSectStartOffset + uiSectEndOffset;
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Total size of the ISO Image :%x", uiSectEndOffset);
-       } else
-               uiSectEndOffset = BcmGetSectionValEndOffset(Adapter, psFlash2xReadWrite->Section);
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "End offset :%x\n", uiSectEndOffset);
-
-       /* psFlash2xReadWrite->offset and uiNumOfBytes are user controlled and can lead to integer overflows */
-       if (psFlash2xReadWrite->offset > uiSectEndOffset) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Invalid Request....");
-               return false;
-       }
-       if (uiNumOfBytes > uiSectEndOffset) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Invalid Request....");
-               return false;
-       }
-       /* Checking the boundary condition */
-       if ((uiSectStartOffset + psFlash2xReadWrite->offset + uiNumOfBytes) <= uiSectEndOffset)
-               return TRUE;
-       else {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Invalid Request....");
-               return false;
-       }
-}
-
-/*
- * IsFlash2x :- check for Flash 2.x
- * Adapater :- Bcm Driver Private Data Structure
- *
- * Return value:-
- *     return TRUE if flah2.x of hgher version else return false.
- */
-
-int IsFlash2x(struct bcm_mini_adapter *Adapter)
-{
-       if (Adapter->uiFlashLayoutMajorVersion >= FLASH_2X_MAJOR_NUMBER)
-               return TRUE;
-       else
-               return false;
-}
-
-/*
- * GetFlashBaseAddr :- Calculate the Flash Base address
- * @Adapater :- Bcm Driver Private Data Structure
- *
- * Return Value:-
- *     Success :- Base Address of the Flash
- */
-
-static int GetFlashBaseAddr(struct bcm_mini_adapter *Adapter)
-{
-       unsigned int uiBaseAddr = 0;
-
-       if (Adapter->bDDRInitDone) {
-               /*
-                * For All Valid Flash Versions... except 1.1, take the value from FlashBaseAddr
-                * In case of Raw Read... use the default value
-                */
-               if (Adapter->uiFlashLayoutMajorVersion && (Adapter->bFlashRawRead == false) &&
-                       !((Adapter->uiFlashLayoutMajorVersion == 1) && (Adapter->uiFlashLayoutMinorVersion == 1)))
-                       uiBaseAddr = Adapter->uiFlashBaseAdd;
-               else
-                       uiBaseAddr = FLASH_CONTIGIOUS_START_ADDR_AFTER_INIT;
-       } else {
-               /*
-                * For All Valid Flash Versions... except 1.1, take the value from FlashBaseAddr
-                * In case of Raw Read... use the default value
-                */
-               if (Adapter->uiFlashLayoutMajorVersion && (Adapter->bFlashRawRead == false) &&
-                       !((Adapter->uiFlashLayoutMajorVersion == 1) && (Adapter->uiFlashLayoutMinorVersion == 1)))
-                       uiBaseAddr = Adapter->uiFlashBaseAdd | FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT;
-               else
-                       uiBaseAddr = FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT;
-       }
-
-       return uiBaseAddr;
-}
-
-/*
- * BcmCopySection :- This API is used to copy the One section in another. Both section should
- *                                 be contiuous and of same size. Hence this Will not be applicabe to copy ISO.
- *
- * @Adapater :- Bcm Driver Private Data Structure
- * @SrcSection :- Source section From where data has to be copied
- * @DstSection :- Destination section to which data has to be copied
- * @offset :- Offset from/to  where data has to be copied from one section to another.
- * @numOfBytes :- number of byes that has to be copyed from one section to another at given offset.
- *                          in case of numofBytes  equal zero complete section will be copied.
- * Return Values-
- *     Success : Return STATUS_SUCCESS
- *     Faillure :- return negative error code
- */
-
-int BcmCopySection(struct bcm_mini_adapter *Adapter,
-               enum bcm_flash2x_section_val SrcSection,
-               enum bcm_flash2x_section_val DstSection,
-               unsigned int offset,
-               unsigned int numOfBytes)
-{
-       unsigned int BuffSize = 0;
-       unsigned int BytesToBeCopied = 0;
-       PUCHAR pBuff = NULL;
-       int Status = STATUS_SUCCESS;
-
-       if (SrcSection == DstSection) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Source and Destination should be different ...try again");
-               return -EINVAL;
-       }
-
-       if ((SrcSection != DSD0) && (SrcSection != DSD1) && (SrcSection != DSD2)) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Source should be DSD subsection");
-               return -EINVAL;
-       }
-
-       if ((DstSection != DSD0) && (DstSection != DSD1) && (DstSection != DSD2)) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Destination should be DSD subsection");
-               return -EINVAL;
-       }
-
-       /* if offset zero means have to copy complete secton */
-       if (numOfBytes == 0) {
-               numOfBytes = BcmGetSectionValEndOffset(Adapter, SrcSection)
-                       - BcmGetSectionValStartOffset(Adapter, SrcSection);
-
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Section Size :0x%x", numOfBytes);
-       }
-
-       if ((offset + numOfBytes) > BcmGetSectionValEndOffset(Adapter, SrcSection)
-               - BcmGetSectionValStartOffset(Adapter, SrcSection)) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, " Input parameters going beyond the section offS: %x numB: %x of Source Section\n",
-                               offset, numOfBytes);
-               return -EINVAL;
-       }
-
-       if ((offset + numOfBytes) > BcmGetSectionValEndOffset(Adapter, DstSection)
-               - BcmGetSectionValStartOffset(Adapter, DstSection)) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Input parameters going beyond the section offS: %x numB: %x of Destination Section\n",
-                               offset, numOfBytes);
-               return -EINVAL;
-       }
-
-       if (numOfBytes > Adapter->uiSectorSize)
-               BuffSize = Adapter->uiSectorSize;
-       else
-               BuffSize = numOfBytes;
-
-       pBuff = kzalloc(BuffSize, GFP_KERNEL);
-       if (!pBuff) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed.. ");
-               return -ENOMEM;
-       }
-
-       BytesToBeCopied = Adapter->uiSectorSize;
-       if (offset % Adapter->uiSectorSize)
-               BytesToBeCopied = Adapter->uiSectorSize - (offset % Adapter->uiSectorSize);
-       if (BytesToBeCopied > numOfBytes)
-               BytesToBeCopied = numOfBytes;
-
-       Adapter->bHeaderChangeAllowed = TRUE;
-
-       do {
-               Status = BcmFlash2xBulkRead(Adapter, (PUINT)pBuff, SrcSection , offset, BytesToBeCopied);
-               if (Status) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read failed at offset :%d for NOB :%d", SrcSection, BytesToBeCopied);
-                       break;
-               }
-               Status = BcmFlash2xBulkWrite(Adapter, (PUINT)pBuff, DstSection, offset, BytesToBeCopied, false);
-               if (Status) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write failed at offset :%d for NOB :%d", DstSection, BytesToBeCopied);
-                       break;
-               }
-               offset = offset + BytesToBeCopied;
-               numOfBytes = numOfBytes - BytesToBeCopied;
-               if (numOfBytes) {
-                       if (numOfBytes > Adapter->uiSectorSize)
-                               BytesToBeCopied = Adapter->uiSectorSize;
-                       else
-                               BytesToBeCopied = numOfBytes;
-               }
-       } while (numOfBytes > 0);
-
-       kfree(pBuff);
-       Adapter->bHeaderChangeAllowed = false;
-
-       return Status;
-}
-
-/*
- * SaveHeaderIfPresent :- This API is use to Protect the Header in case of Header Sector write
- * @Adapater :- Bcm Driver Private Data Structure
- * @pBuff :- Data buffer that has to be written in sector having the header map.
- * @uiOffset :- Flash offset that has to be written.
- *
- * Return value :-
- *     Success :- On success return STATUS_SUCCESS
- *     Faillure :- Return negative error code
- */
-
-static int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, unsigned int uiOffset)
-{
-       unsigned int offsetToProtect = 0, HeaderSizeToProtect = 0;
-       bool bHasHeader = false;
-       PUCHAR pTempBuff = NULL;
-       unsigned int uiSectAlignAddr = 0;
-       unsigned int sig = 0;
-
-       /* making the offset sector aligned */
-       uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1);
-
-       if ((uiSectAlignAddr == BcmGetSectionValEndOffset(Adapter, DSD2) - Adapter->uiSectorSize) ||
-               (uiSectAlignAddr == BcmGetSectionValEndOffset(Adapter, DSD1) - Adapter->uiSectorSize) ||
-               (uiSectAlignAddr == BcmGetSectionValEndOffset(Adapter, DSD0) - Adapter->uiSectorSize)) {
-               /* offset from the sector boundary having the header map */
-               offsetToProtect = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader % Adapter->uiSectorSize;
-               HeaderSizeToProtect = sizeof(struct bcm_dsd_header);
-               bHasHeader = TRUE;
-       }
-
-       if (uiSectAlignAddr == BcmGetSectionValStartOffset(Adapter, ISO_IMAGE1) ||
-               uiSectAlignAddr == BcmGetSectionValStartOffset(Adapter, ISO_IMAGE2)) {
-               offsetToProtect = 0;
-               HeaderSizeToProtect = sizeof(struct bcm_iso_header);
-               bHasHeader = TRUE;
-       }
-       /* If Header is present overwrite passed buffer with this */
-       if (bHasHeader && (Adapter->bHeaderChangeAllowed == false)) {
-               pTempBuff = kzalloc(HeaderSizeToProtect, GFP_KERNEL);
-               if (!pTempBuff) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed");
-                       return -ENOMEM;
-               }
-               /* Read header */
-               BeceemFlashBulkRead(Adapter, (PUINT)pTempBuff, (uiSectAlignAddr + offsetToProtect), HeaderSizeToProtect);
-               BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, pTempBuff, HeaderSizeToProtect);
-               /* Replace Buffer content with Header */
-               memcpy(pBuff + offsetToProtect, pTempBuff, HeaderSizeToProtect);
-
-               kfree(pTempBuff);
-       }
-       if (bHasHeader && Adapter->bSigCorrupted) {
-               sig = *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImageMagicNumber)));
-               sig = ntohl(sig);
-               if ((sig & 0xFF000000) != CORRUPTED_PATTERN) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Desired pattern is not at sig offset. Hence won't restore");
-                       Adapter->bSigCorrupted = false;
-                       return STATUS_SUCCESS;
-               }
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " Corrupted sig is :%X", sig);
-               *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImageMagicNumber))) = htonl(DSD_IMAGE_MAGIC_NUMBER);
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Restoring the signature in Header Write only");
-               Adapter->bSigCorrupted = false;
-       }
-
-       return STATUS_SUCCESS;
-}
-
-/*
- * BcmDoChipSelect : This will selcet the appropriate chip for writing.
- * @Adapater :- Bcm Driver Private Data Structure
- *
- * OutPut:-
- *     Select the Appropriate chip and retrn status Success
- */
-static int BcmDoChipSelect(struct bcm_mini_adapter *Adapter, unsigned int offset)
-{
-       unsigned int FlashConfig = 0;
-       int ChipNum = 0;
-       unsigned int GPIOConfig = 0;
-       unsigned int PartNum = 0;
-
-       ChipNum = offset / FLASH_PART_SIZE;
-
-       /*
-        * Chip Select mapping to enable flash0.
-        * To select flash 0, we have to OR with (0<<12).
-        * ORing 0 will have no impact so not doing that part.
-        * In future if Chip select value changes from 0 to non zero,
-        * That needs be taken care with backward comaptibility. No worries for now.
-        */
-
-       /*
-        * SelectedChip Variable is the selection that the host is 100% Sure the same as what the register will hold. This can be ONLY ensured
-        * if the Chip doesn't goes to low power mode while the flash operation is in progress (NVMRdmWrmLock is taken)
-        * Before every new Flash Write operation, we reset the variable. This is to ensure that after any wake-up from
-        * power down modes (Idle mode/shutdown mode), the values in the register will be different.
-        */
-
-       if (Adapter->SelectedChip == ChipNum)
-               return STATUS_SUCCESS;
-
-       /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Selected Chip :%x", ChipNum); */
-       Adapter->SelectedChip = ChipNum;
-
-       /* bit[13..12]  will select the appropriate chip */
-       rdmalt(Adapter, FLASH_CONFIG_REG, &FlashConfig, 4);
-       rdmalt(Adapter, FLASH_GPIO_CONFIG_REG, &GPIOConfig, 4);
-       {
-               switch (ChipNum) {
-               case 0:
-                       PartNum = 0;
-                       break;
-               case 1:
-                       PartNum = 3;
-                       GPIOConfig |= (0x4 << CHIP_SELECT_BIT12);
-                       break;
-               case 2:
-                       PartNum = 1;
-                       GPIOConfig |= (0x1 << CHIP_SELECT_BIT12);
-                       break;
-               case 3:
-                       PartNum = 2;
-                       GPIOConfig |= (0x2 << CHIP_SELECT_BIT12);
-                       break;
-               }
-       }
-       /* In case the bits already written in the FLASH_CONFIG_REG is same as what the user desired,
-        * nothing to do... can return immediately.
-        * ASSUMPTION: FLASH_GPIO_CONFIG_REG will be in sync with FLASH_CONFIG_REG.
-        * Even if the chip goes to low power mode, it should wake with values in each register in sync with each other.
-        * These values are not written by host other than during CHIP_SELECT.
-        */
-       if (PartNum == ((FlashConfig >> CHIP_SELECT_BIT12) & 0x3))
-               return STATUS_SUCCESS;
-
-       /* clearing the bit[13..12] */
-       FlashConfig &= 0xFFFFCFFF;
-       FlashConfig = (FlashConfig | (PartNum<<CHIP_SELECT_BIT12)); /* 00 */
-
-       wrmalt(Adapter, FLASH_GPIO_CONFIG_REG, &GPIOConfig, 4);
-       udelay(100);
-
-       wrmalt(Adapter, FLASH_CONFIG_REG, &FlashConfig, 4);
-       udelay(100);
-
-       return STATUS_SUCCESS;
-}
-
-static int ReadDSDSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val dsd)
-{
-       unsigned int uiDSDsig = 0;
-       /* unsigned int sigoffsetInMap = 0;
-        * struct bcm_dsd_header dsdHeader = {0};
-        */
-
-       /* sigoffsetInMap =(PUCHAR)&(dsdHeader.DSDImageMagicNumber) -(PUCHAR)&dsdHeader; */
-
-       if (dsd != DSD0 && dsd != DSD1 && dsd != DSD2) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "passed section value is not for DSDs");
-               return STATUS_FAILURE;
-       }
-       BcmFlash2xBulkRead(Adapter,
-                       &uiDSDsig,
-                       dsd,
-                       Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImageMagicNumber),
-                       SIGNATURE_SIZE);
-
-       uiDSDsig = ntohl(uiDSDsig);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSD SIG :%x", uiDSDsig);
-
-       return uiDSDsig;
-}
-
-static int ReadDSDPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val dsd)
-{
-       /* unsigned int priOffsetInMap = 0 ; */
-       unsigned int uiDSDPri = STATUS_FAILURE;
-       /* struct bcm_dsd_header dsdHeader = {0};
-        * priOffsetInMap = (PUCHAR)&(dsdHeader.DSDImagePriority) -(PUCHAR)&dsdHeader;
-        */
-       if (IsSectionWritable(Adapter, dsd)) {
-               if (ReadDSDSignature(Adapter, dsd) == DSD_IMAGE_MAGIC_NUMBER) {
-                       BcmFlash2xBulkRead(Adapter,
-                                       &uiDSDPri,
-                                       dsd,
-                                       Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority),
-                                       4);
-
-                       uiDSDPri = ntohl(uiDSDPri);
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSD<%x> Priority :%x", dsd, uiDSDPri);
-               }
-       }
-
-       return uiDSDPri;
-}
-
-static enum bcm_flash2x_section_val getHighestPriDSD(struct bcm_mini_adapter *Adapter)
-{
-       int DSDHighestPri = STATUS_FAILURE;
-       int DsdPri = 0;
-       enum bcm_flash2x_section_val HighestPriDSD = 0;
-
-       if (IsSectionWritable(Adapter, DSD2)) {
-               DSDHighestPri = ReadDSDPriority(Adapter, DSD2);
-               HighestPriDSD = DSD2;
-       }
-
-       if (IsSectionWritable(Adapter, DSD1)) {
-               DsdPri = ReadDSDPriority(Adapter, DSD1);
-               if (DSDHighestPri  < DsdPri) {
-                       DSDHighestPri = DsdPri;
-                       HighestPriDSD = DSD1;
-               }
-       }
-
-       if (IsSectionWritable(Adapter, DSD0)) {
-               DsdPri = ReadDSDPriority(Adapter, DSD0);
-               if (DSDHighestPri  < DsdPri) {
-                       DSDHighestPri = DsdPri;
-                       HighestPriDSD = DSD0;
-               }
-       }
-       if (HighestPriDSD)
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Highest DSD :%x , and its  Pri :%x", HighestPriDSD, DSDHighestPri);
-
-       return  HighestPriDSD;
-}
-
-static int ReadISOSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val iso)
-{
-       unsigned int uiISOsig = 0;
-       /* unsigned int sigoffsetInMap = 0;
-        * struct bcm_iso_header ISOHeader = {0};
-        * sigoffsetInMap =(PUCHAR)&(ISOHeader.ISOImageMagicNumber) -(PUCHAR)&ISOHeader;
-        */
-       if (iso != ISO_IMAGE1 && iso != ISO_IMAGE2) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "passed section value is not for ISOs");
-               return STATUS_FAILURE;
-       }
-       BcmFlash2xBulkRead(Adapter,
-                       &uiISOsig,
-                       iso,
-                       0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageMagicNumber),
-                       SIGNATURE_SIZE);
-
-       uiISOsig = ntohl(uiISOsig);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISO SIG :%x", uiISOsig);
-
-       return uiISOsig;
-}
-
-static int ReadISOPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val iso)
-{
-       unsigned int ISOPri = STATUS_FAILURE;
-
-       if (IsSectionWritable(Adapter, iso)) {
-               if (ReadISOSignature(Adapter, iso) == ISO_IMAGE_MAGIC_NUMBER) {
-                       BcmFlash2xBulkRead(Adapter,
-                                       &ISOPri,
-                                       iso,
-                                       0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImagePriority),
-                                       4);
-
-                       ISOPri = ntohl(ISOPri);
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISO<%x> Priority :%x", iso, ISOPri);
-               }
-       }
-
-       return ISOPri;
-}
-
-static enum bcm_flash2x_section_val getHighestPriISO(struct bcm_mini_adapter *Adapter)
-{
-       int ISOHighestPri = STATUS_FAILURE;
-       int ISOPri = 0;
-       enum bcm_flash2x_section_val HighestPriISO = NO_SECTION_VAL;
-
-       if (IsSectionWritable(Adapter, ISO_IMAGE2)) {
-               ISOHighestPri = ReadISOPriority(Adapter, ISO_IMAGE2);
-               HighestPriISO = ISO_IMAGE2;
-       }
-
-       if (IsSectionWritable(Adapter, ISO_IMAGE1)) {
-               ISOPri = ReadISOPriority(Adapter, ISO_IMAGE1);
-               if (ISOHighestPri  < ISOPri) {
-                       ISOHighestPri = ISOPri;
-                       HighestPriISO = ISO_IMAGE1;
-               }
-       }
-       if (HighestPriISO)
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Highest ISO :%x and its Pri :%x", HighestPriISO, ISOHighestPri);
-
-       return HighestPriISO;
-}
-
-static int WriteToFlashWithoutSectorErase(struct bcm_mini_adapter *Adapter,
-                               PUINT pBuff,
-                               enum bcm_flash2x_section_val eFlash2xSectionVal,
-                               unsigned int uiOffset,
-                               unsigned int uiNumBytes)
-{
-       #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS)
-               unsigned int uiTemp = 0, value = 0;
-               unsigned int i = 0;
-               unsigned int uiPartOffset = 0;
-       #endif
-       unsigned int uiStartOffset = 0;
-       /* Adding section start address */
-       int Status = STATUS_SUCCESS;
-       PUCHAR pcBuff = (PUCHAR)pBuff;
-
-       if (uiNumBytes % Adapter->ulFlashWriteSize) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Writing without Sector Erase for non-FlashWriteSize number of bytes 0x%x\n", uiNumBytes);
-               return STATUS_FAILURE;
-       }
-
-       uiStartOffset = BcmGetSectionValStartOffset(Adapter, eFlash2xSectionVal);
-
-       if (IsSectionExistInVendorInfo(Adapter, eFlash2xSectionVal))
-               return vendorextnWriteSectionWithoutErase(Adapter, pcBuff, eFlash2xSectionVal, uiOffset, uiNumBytes);
-
-       uiOffset = uiOffset + uiStartOffset;
-
-       #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
-               Status = bcmflash_raw_writenoerase((uiOffset / FLASH_PART_SIZE), (uiOffset % FLASH_PART_SIZE), pcBuff, uiNumBytes);
-       #else
-               rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
-               value = 0;
-               wrmalt(Adapter, 0x0f000C80, &value, sizeof(value));
-
-               Adapter->SelectedChip = RESET_CHIP_SELECT;
-               BcmDoChipSelect(Adapter, uiOffset);
-               uiPartOffset = (uiOffset & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter);
-
-               for (i = 0; i < uiNumBytes; i += Adapter->ulFlashWriteSize) {
-                       if (Adapter->ulFlashWriteSize == BYTE_WRITE_SUPPORT)
-                               Status = flashByteWrite(Adapter, uiPartOffset, pcBuff);
-                       else
-                               Status = flashWrite(Adapter, uiPartOffset, pcBuff);
-
-                       if (Status != STATUS_SUCCESS)
-                               break;
-
-                       pcBuff = pcBuff + Adapter->ulFlashWriteSize;
-                       uiPartOffset = uiPartOffset +  Adapter->ulFlashWriteSize;
-               }
-               wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
-               Adapter->SelectedChip = RESET_CHIP_SELECT;
-       #endif
-
-       return Status;
-}
-
-bool IsSectionExistInFlash(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val section)
-{
-       bool SectionPresent = false;
-
-       switch (section) {
-       case ISO_IMAGE1:
-               if ((Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start != UNINIT_PTR_IN_CS) &&
-                       (IsNonCDLessDevice(Adapter) == false))
-                       SectionPresent = TRUE;
-               break;
-       case ISO_IMAGE2:
-               if ((Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start != UNINIT_PTR_IN_CS) &&
-                       (IsNonCDLessDevice(Adapter) == false))
-                       SectionPresent = TRUE;
-               break;
-       case DSD0:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart != UNINIT_PTR_IN_CS)
-                       SectionPresent = TRUE;
-               break;
-       case DSD1:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start != UNINIT_PTR_IN_CS)
-                       SectionPresent = TRUE;
-               break;
-       case DSD2:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start != UNINIT_PTR_IN_CS)
-                       SectionPresent = TRUE;
-               break;
-       case VSA0:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart != UNINIT_PTR_IN_CS)
-                       SectionPresent = TRUE;
-               break;
-       case VSA1:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start != UNINIT_PTR_IN_CS)
-                       SectionPresent = TRUE;
-               break;
-       case VSA2:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start != UNINIT_PTR_IN_CS)
-                       SectionPresent = TRUE;
-               break;
-       case SCSI:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware != UNINIT_PTR_IN_CS)
-                       SectionPresent = TRUE;
-               break;
-       case CONTROL_SECTION:
-               if (Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart != UNINIT_PTR_IN_CS)
-                       SectionPresent = TRUE;
-               break;
-       default:
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section Does not exist in Flash 2.x");
-               SectionPresent =  false;
-       }
-
-       return SectionPresent;
-}
-
-static int IsSectionWritable(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val Section)
-{
-       int offset = STATUS_FAILURE;
-       int Status = false;
-
-       if (IsSectionExistInFlash(Adapter, Section) == false) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section <%d> does not exist", Section);
-               return false;
-       }
-
-       offset = BcmGetSectionValStartOffset(Adapter, Section);
-       if (offset == INVALID_OFFSET) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section<%d> does not exist", Section);
-               return false;
-       }
-
-       if (IsSectionExistInVendorInfo(Adapter, Section))
-               return !(Adapter->psFlash2xVendorInfo->VendorSection[Section].AccessFlags & FLASH2X_SECTION_RO);
-
-       Status = IsOffsetWritable(Adapter, offset);
-       return Status;
-}
-
-static int CorruptDSDSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal)
-{
-       PUCHAR pBuff = NULL;
-       unsigned int sig = 0;
-       unsigned int uiOffset = 0;
-       unsigned int BlockStatus = 0;
-       unsigned int uiSectAlignAddr = 0;
-
-       Adapter->bSigCorrupted = false;
-       if (Adapter->bAllDSDWriteAllow == false) {
-               if (IsSectionWritable(Adapter, eFlash2xSectionVal) != TRUE) {
-                       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section is not Writable...Hence can't Corrupt signature");
-                       return SECTOR_IS_NOT_WRITABLE;
-               }
-       }
-
-       pBuff = kzalloc(MAX_RW_SIZE, GFP_KERNEL);
-       if (!pBuff) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Can't allocate memorey");
-               return -ENOMEM;
-       }
-
-       uiOffset = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header);
-       uiOffset -= MAX_RW_SIZE;
-
-       BcmFlash2xBulkRead(Adapter, (PUINT)pBuff, eFlash2xSectionVal, uiOffset, MAX_RW_SIZE);
-
-       sig = *((PUINT)(pBuff + 12));
-       sig = ntohl(sig);
-       BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, pBuff, MAX_RW_SIZE);
-       /* Now corrupting the sig by corrupting 4th last Byte. */
-       *(pBuff + 12) = 0;
-
-       if (sig == DSD_IMAGE_MAGIC_NUMBER) {
-               Adapter->bSigCorrupted = TRUE;
-               if (Adapter->ulFlashWriteSize == BYTE_WRITE_SUPPORT) {
-                       uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1);
-                       BlockStatus = BcmFlashUnProtectBlock(Adapter, uiSectAlignAddr, Adapter->uiSectorSize);
-
-                       WriteToFlashWithoutSectorErase(Adapter, (PUINT)(pBuff + 12), eFlash2xSectionVal,
-                                               (uiOffset + 12), BYTE_WRITE_SUPPORT);
-                       if (BlockStatus) {
-                               BcmRestoreBlockProtectStatus(Adapter, BlockStatus);
-                               BlockStatus = 0;
-                       }
-               } else {
-                       WriteToFlashWithoutSectorErase(Adapter, (PUINT)pBuff, eFlash2xSectionVal,
-                                               uiOffset, MAX_RW_SIZE);
-               }
-       } else {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "BCM Signature is not present in header");
-               kfree(pBuff);
-
-               return STATUS_FAILURE;
-       }
-
-       kfree(pBuff);
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Corrupted the signature");
-
-       return STATUS_SUCCESS;
-}
-
-static int CorruptISOSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal)
-{
-       PUCHAR pBuff = NULL;
-       unsigned int sig = 0;
-       unsigned int uiOffset = 0;
-
-       Adapter->bSigCorrupted = false;
-
-       if (IsSectionWritable(Adapter, eFlash2xSectionVal) != TRUE) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section is not Writable...Hence can't Corrupt signature");
-               return SECTOR_IS_NOT_WRITABLE;
-       }
-
-       pBuff = kzalloc(MAX_RW_SIZE, GFP_KERNEL);
-       if (!pBuff) {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Can't allocate memorey");
-               return -ENOMEM;
-       }
-
-       uiOffset = 0;
-
-       BcmFlash2xBulkRead(Adapter, (PUINT)pBuff, eFlash2xSectionVal, uiOffset, MAX_RW_SIZE);
-
-       sig = *((PUINT)pBuff);
-       sig = ntohl(sig);
-
-       /* corrupt signature */
-       *pBuff = 0;
-
-       if (sig == ISO_IMAGE_MAGIC_NUMBER) {
-               Adapter->bSigCorrupted = TRUE;
-               WriteToFlashWithoutSectorErase(Adapter, (PUINT)pBuff, eFlash2xSectionVal,
-                                       uiOffset, Adapter->ulFlashWriteSize);
-       } else {
-               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "BCM Signature is not present in header");
-               kfree(pBuff);
-
-               return STATUS_FAILURE;
-       }
-
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Corrupted the signature");
-       BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, pBuff, MAX_RW_SIZE);
-
-       kfree(pBuff);
-       return STATUS_SUCCESS;
-}
-
-bool IsNonCDLessDevice(struct bcm_mini_adapter *Adapter)
-{
-       if (Adapter->psFlash2xCSInfo->IsCDLessDeviceBootSig == NON_CDLESS_DEVICE_BOOT_SIG)
-               return TRUE;
-       else
-               return false;
-}
diff --git a/drivers/staging/bcm/nvm.h b/drivers/staging/bcm/nvm.h
deleted file mode 100644 (file)
index e765cca..0000000
+++ /dev/null
@@ -1,286 +0,0 @@
-/***************************************************************************************
- *
- * Copyright (c) Beceem Communications Inc.
- *
- * Module Name:
- *     NVM.h
- *
- * Abstract:
- *     This file has the prototypes,preprocessors and definitions various NVM libraries.
- *
- *
- * Revision History:
- *     Who             When            What
- *     --------        --------        ----------------------------------------------
- *     Name            Date            Created/reviewed/modified
- *
- * Notes:
- *
- ****************************************************************************************/
-
-#ifndef _NVM_H_
-#define _NVM_H_
-
-struct bcm_flash_cs_info {
-       u32 MagicNumber;
-       /* let the magic number be 0xBECE-F1A5 - F1A5 for "flas-h" */
-       u32 FlashLayoutVersion;
-       u32 ISOImageVersion;
-       u32 SCSIFirmwareVersion;
-       u32 OffsetFromZeroForPart1ISOImage;
-       u32 OffsetFromZeroForScsiFirmware;
-       u32 SizeOfScsiFirmware;
-       u32 OffsetFromZeroForPart2ISOImage;
-       u32 OffsetFromZeroForCalibrationStart;
-       u32 OffsetFromZeroForCalibrationEnd;
-       u32 OffsetFromZeroForVSAStart;
-       u32 OffsetFromZeroForVSAEnd;
-       u32 OffsetFromZeroForControlSectionStart;
-       u32 OffsetFromZeroForControlSectionData;
-       u32 CDLessInactivityTimeout;
-       u32 NewImageSignature;
-       u32 FlashSectorSizeSig;
-       u32 FlashSectorSize;
-       u32 FlashWriteSupportSize;
-       u32 TotalFlashSize;
-       u32 FlashBaseAddr;
-       u32 FlashPartMaxSize;
-       u32 IsCDLessDeviceBootSig;
-       /* MSC Timeout after reset to switch from MSC to NW Mode */
-       u32 MassStorageTimeout;
-};
-
-#define FLASH2X_TOTAL_SIZE     (64 * 1024 * 1024)
-#define DEFAULT_SECTOR_SIZE    (64 * 1024)
-
-struct bcm_flash2x_cs_info {
-       /* magic number as 0xBECE-F1A5 - F1A5 for "flas-h" */
-       u32 MagicNumber;
-       u32 FlashLayoutVersion;
-       u32 ISOImageVersion;
-       u32 SCSIFirmwareVersion;
-       u32 OffsetFromZeroForPart1ISOImage;
-       u32 OffsetFromZeroForScsiFirmware;
-       u32 SizeOfScsiFirmware;
-       u32 OffsetFromZeroForPart2ISOImage;
-       u32 OffsetFromZeroForDSDStart;
-       u32 OffsetFromZeroForDSDEnd;
-       u32 OffsetFromZeroForVSAStart;
-       u32 OffsetFromZeroForVSAEnd;
-       u32 OffsetFromZeroForControlSectionStart;
-       u32 OffsetFromZeroForControlSectionData;
-       /* NO Data Activity timeout to switch from MSC to NW Mode */
-       u32 CDLessInactivityTimeout;
-       u32 NewImageSignature;
-       u32 FlashSectorSizeSig;
-       u32 FlashSectorSize;
-       u32 FlashWriteSupportSize;
-       u32 TotalFlashSize;
-       u32 FlashBaseAddr;
-       u32 FlashPartMaxSize;
-       u32 IsCDLessDeviceBootSig;
-       /* MSC Timeout after reset to switch from MSC to NW Mode */
-       u32 MassStorageTimeout;
-       /* Flash Map 2.0 Field */
-       u32 OffsetISOImage1Part1Start;
-       u32 OffsetISOImage1Part1End;
-       u32 OffsetISOImage1Part2Start;
-       u32 OffsetISOImage1Part2End;
-       u32 OffsetISOImage1Part3Start;
-       u32 OffsetISOImage1Part3End;
-       u32 OffsetISOImage2Part1Start;
-       u32 OffsetISOImage2Part1End;
-       u32 OffsetISOImage2Part2Start;
-       u32 OffsetISOImage2Part2End;
-       u32 OffsetISOImage2Part3Start;
-       u32 OffsetISOImage2Part3End;
-       /* DSD Header offset from start of DSD */
-       u32 OffsetFromDSDStartForDSDHeader;
-       u32 OffsetFromZeroForDSD1Start;
-       u32 OffsetFromZeroForDSD1End;
-       u32 OffsetFromZeroForDSD2Start;
-       u32 OffsetFromZeroForDSD2End;
-       u32 OffsetFromZeroForVSA1Start;
-       u32 OffsetFromZeroForVSA1End;
-       u32 OffsetFromZeroForVSA2Start;
-       u32 OffsetFromZeroForVSA2End;
-       /*
-        * ACCESS_BITS_PER_SECTOR       2
-        * ACCESS_RW                    0
-        * ACCESS_RO                    1
-        * ACCESS_RESVD                 2
-        * ACCESS_RESVD                 3
-        */
-       u32 SectorAccessBitMap[FLASH2X_TOTAL_SIZE / (DEFAULT_SECTOR_SIZE * 16)];
-       /* All expansions to the control data structure should add here */
-};
-
-struct bcm_vendor_section_info {
-       u32 OffsetFromZeroForSectionStart;
-       u32 OffsetFromZeroForSectionEnd;
-       u32 AccessFlags;
-       u32 Reserved[16];
-};
-
-struct bcm_flash2x_vendor_info {
-       struct bcm_vendor_section_info VendorSection[TOTAL_SECTIONS];
-       u32 Reserved[16];
-};
-
-struct bcm_dsd_header {
-       u32 DSDImageSize;
-       u32 DSDImageCRC;
-       u32 DSDImagePriority;
-       /* We should not consider right now. Reading reserve is worthless. */
-       u32 Reserved[252]; /* Resvd for DSD Header */
-       u32 DSDImageMagicNumber;
-};
-
-struct bcm_iso_header {
-       u32 ISOImageMagicNumber;
-       u32 ISOImageSize;
-       u32 ISOImageCRC;
-       u32 ISOImagePriority;
-       /* We should not consider right now. Reading reserve is worthless. */
-       u32 Reserved[60]; /* Resvd for ISO Header extension */
-};
-
-#define EEPROM_BEGIN_CIS       (0)
-#define EEPROM_BEGIN_NON_CIS   (0x200)
-#define EEPROM_END             (0x2000)
-#define INIT_PARAMS_SIGNATURE  (0x95a7a597)
-#define MAX_INIT_PARAMS_LENGTH (2048)
-#define MAC_ADDRESS_OFFSET     0x200
-
-#define INIT_PARAMS_1_SIGNATURE_ADDRESS                EEPROM_BEGIN_NON_CIS
-#define INIT_PARAMS_1_DATA_ADDRESS             (INIT_PARAMS_1_SIGNATURE_ADDRESS+16)
-#define INIT_PARAMS_1_MACADDRESS_ADDRESS       (MAC_ADDRESS_OFFSET)
-#define INIT_PARAMS_1_LENGTH_ADDRESS           (INIT_PARAMS_1_SIGNATURE_ADDRESS+4)
-
-#define INIT_PARAMS_2_SIGNATURE_ADDRESS                (EEPROM_BEGIN_NON_CIS + 2048 + 16)
-#define INIT_PARAMS_2_DATA_ADDRESS             (INIT_PARAMS_2_SIGNATURE_ADDRESS + 16)
-#define INIT_PARAMS_2_MACADDRESS_ADDRESS       (INIT_PARAMS_2_SIGNATURE_ADDRESS + 8)
-#define INIT_PARAMS_2_LENGTH_ADDRESS           (INIT_PARAMS_2_SIGNATURE_ADDRESS + 4)
-
-#define EEPROM_SPI_DEV_CONFIG_REG              0x0F003000
-#define EEPROM_SPI_Q_STATUS1_REG               0x0F003004
-#define EEPROM_SPI_Q_STATUS1_MASK_REG          0x0F00300C
-
-#define EEPROM_SPI_Q_STATUS_REG                        0x0F003008
-#define EEPROM_CMDQ_SPI_REG                    0x0F003018
-#define EEPROM_WRITE_DATAQ_REG                 0x0F00301C
-#define EEPROM_READ_DATAQ_REG                  0x0F003020
-#define SPI_FLUSH_REG                          0x0F00304C
-
-#define EEPROM_WRITE_ENABLE                    0x06000000
-#define EEPROM_READ_STATUS_REGISTER            0x05000000
-#define EEPROM_16_BYTE_PAGE_WRITE              0xFA000000
-#define EEPROM_WRITE_QUEUE_EMPTY               0x00001000
-#define EEPROM_WRITE_QUEUE_AVAIL               0x00002000
-#define EEPROM_WRITE_QUEUE_FULL                        0x00004000
-#define EEPROM_16_BYTE_PAGE_READ               0xFB000000
-#define EEPROM_4_BYTE_PAGE_READ                        0x3B000000
-
-#define EEPROM_CMD_QUEUE_FLUSH                 0x00000001
-#define EEPROM_WRITE_QUEUE_FLUSH               0x00000002
-#define EEPROM_READ_QUEUE_FLUSH                        0x00000004
-#define EEPROM_ETH_QUEUE_FLUSH                 0x00000008
-#define EEPROM_ALL_QUEUE_FLUSH                 0x0000000f
-#define EEPROM_READ_ENABLE                     0x06000000
-#define EEPROM_16_BYTE_PAGE_WRITE              0xFA000000
-#define EEPROM_READ_DATA_FULL                  0x00000010
-#define EEPROM_READ_DATA_AVAIL                 0x00000020
-#define EEPROM_READ_QUEUE_EMPTY                        0x00000002
-#define EEPROM_CMD_QUEUE_EMPTY                 0x00000100
-#define EEPROM_CMD_QUEUE_AVAIL                 0x00000200
-#define EEPROM_CMD_QUEUE_FULL                  0x00000400
-
-/* Most EEPROM status register bit 0 indicates if the EEPROM is busy
- * with a write if set 1. See the details of the EEPROM Status Register
- * in the EEPROM data sheet.
- */
-#define EEPROM_STATUS_REG_WRITE_BUSY           0x00000001
-
-/* We will have 1 mSec for every RETRIES_PER_DELAY count and have a max attempts of MAX_EEPROM_RETRIES
- * This will give us 80 mSec minimum of delay = 80mSecs
- */
-#define MAX_EEPROM_RETRIES                     80
-#define RETRIES_PER_DELAY                      64
-#define MAX_RW_SIZE                            0x10
-#define MAX_READ_SIZE                          0x10
-#define MAX_SECTOR_SIZE                                (512 * 1024)
-#define MIN_SECTOR_SIZE                                (1024)
-#define FLASH_SECTOR_SIZE_OFFSET               0xEFFFC
-#define FLASH_SECTOR_SIZE_SIG_OFFSET           0xEFFF8
-#define FLASH_SECTOR_SIZE_SIG                  0xCAFEBABE
-#define FLASH_CS_INFO_START_ADDR               0xFF0000
-#define FLASH_CONTROL_STRUCT_SIGNATURE         0xBECEF1A5
-#define SCSI_FIRMWARE_MAJOR_VERSION            0x1
-#define SCSI_FIRMWARE_MINOR_VERSION            0x5
-#define BYTE_WRITE_SUPPORT                     0x1
-#define FLASH_AUTO_INIT_BASE_ADDR              0xF00000
-#define FLASH_CONTIGIOUS_START_ADDR_AFTER_INIT 0x1C000000
-#define FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT        0x1F000000
-#define FLASH_CONTIGIOUS_START_ADDR_BCS350     0x08000000
-#define FLASH_CONTIGIOUS_END_ADDR_BCS350       0x08FFFFFF
-#define FLASH_SIZE_ADDR                                0xFFFFEC
-#define FLASH_SPI_CMDQ_REG                     0xAF003040
-#define FLASH_SPI_WRITEQ_REG                   0xAF003044
-#define FLASH_SPI_READQ_REG                    0xAF003048
-#define FLASH_CONFIG_REG                       0xAF003050
-#define FLASH_GPIO_CONFIG_REG                  0xAF000030
-#define FLASH_CMD_WRITE_ENABLE                 0x06
-#define FLASH_CMD_READ_ENABLE                  0x03
-#define FLASH_CMD_RESET_WRITE_ENABLE           0x04
-#define FLASH_CMD_STATUS_REG_READ              0x05
-#define FLASH_CMD_STATUS_REG_WRITE             0x01
-#define FLASH_CMD_READ_ID                      0x9F
-#define PAD_SELECT_REGISTER                    0xAF000410
-#define FLASH_PART_SST25VF080B                 0xBF258E
-#define EEPROM_CAL_DATA_INTERNAL_LOC           0xbFB00008
-#define EEPROM_CALPARAM_START                  0x200
-#define EEPROM_SIZE_OFFSET                     524
-
-/* As Read/Write time vaires from 1.5 to 3.0 ms.
- * so After Ignoring the rdm/wrm time(that is dependent on many factor like interface etc.),
- * here time calculated meets the worst case delay, 3.0 ms
- */
-#define MAX_FLASH_RETRIES              4
-#define FLASH_PER_RETRIES_DELAY                16
-#define EEPROM_MAX_CAL_AREA_SIZE       0xF0000
-#define BECM                           ntohl(0x4245434d)
-#define FLASH_2X_MAJOR_NUMBER          0x2
-#define DSD_IMAGE_MAGIC_NUMBER         0xBECE0D5D
-#define ISO_IMAGE_MAGIC_NUMBER         0xBECE0150
-#define NON_CDLESS_DEVICE_BOOT_SIG     0xBECEB007
-
-#define MINOR_VERSION(x) ((x >> 16) & 0xFFFF)
-#define MAJOR_VERSION(x) (x & 0xFFFF)
-
-#define CORRUPTED_PATTERN              0x0
-#define UNINIT_PTR_IN_CS               0xBBBBDDDD
-#define VENDOR_PTR_IN_CS               0xAAAACCCC
-#define FLASH2X_SECTION_PRESENT                (1 << 0)
-#define FLASH2X_SECTION_VALID          (1 << 1)
-#define FLASH2X_SECTION_RO             (1 << 2)
-#define FLASH2X_SECTION_ACT            (1 << 3)
-#define SECTOR_IS_NOT_WRITABLE         STATUS_FAILURE
-#define INVALID_OFFSET                 STATUS_FAILURE
-#define INVALID_SECTION                        STATUS_FAILURE
-#define SECTOR_1K                      1024
-#define SECTOR_64K                     (64 * SECTOR_1K)
-#define SECTOR_128K                    (2 * SECTOR_64K)
-#define SECTOR_256k                    (2 * SECTOR_128K)
-#define SECTOR_512K                    (2 * SECTOR_256k)
-#define FLASH_PART_SIZE                        (16 * 1024 * 1024)
-#define RESET_CHIP_SELECT              -1
-#define CHIP_SELECT_BIT12              12
-#define SECTOR_READWRITE_PERMISSION    0
-#define SECTOR_READONLY                        1
-#define SIGNATURE_SIZE                 4
-#define DEFAULT_BUFF_SIZE              0x10000
-
-#define FIELD_OFFSET_IN_HEADER(HeaderPointer, Field) ((u8 *)&((HeaderPointer)(NULL))->Field - (u8 *)(NULL))
-
-#endif
-
diff --git a/drivers/staging/bcm/sort.c b/drivers/staging/bcm/sort.c
deleted file mode 100644 (file)
index ca0b179..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "headers.h"
-#include <linux/sort.h>
-
-/*
- * File Name: sort.c
- *
- * Author: Beceem Communications Pvt. Ltd
- *
- * Abstract: This file contains the routines sorting the classification rules.
- *
- * Copyright (c) 2007 Beceem Communications Pvt. Ltd
- */
-
-static int compare_packet_info(void const *a, void const *b)
-{
-       struct bcm_packet_info const *pa = a;
-       struct bcm_packet_info const *pb = b;
-
-       if (!pa->bValid || !pb->bValid)
-               return 0;
-
-       return pa->u8TrafficPriority - pb->u8TrafficPriority;
-}
-
-VOID SortPackInfo(struct bcm_mini_adapter *Adapter)
-{
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG,
-                       DBG_LVL_ALL, "<=======");
-
-       sort(Adapter->PackInfo, NO_OF_QUEUES, sizeof(struct bcm_packet_info),
-            compare_packet_info, NULL);
-}
-
-static int compare_classifiers(void const *a, void const *b)
-{
-       struct bcm_classifier_rule const *pa = a;
-       struct bcm_classifier_rule const *pb = b;
-
-       if (!pa->bUsed || !pb->bUsed)
-               return 0;
-
-       return pa->u8ClassifierRulePriority - pb->u8ClassifierRulePriority;
-}
-
-VOID SortClassifiers(struct bcm_mini_adapter *Adapter)
-{
-       BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG,
-                       DBG_LVL_ALL, "<=======");
-
-       sort(Adapter->astClassifierTable, MAX_CLASSIFIERS,
-            sizeof(struct bcm_classifier_rule), compare_classifiers, NULL);
-}
diff --git a/drivers/staging/bcm/target_params.h b/drivers/staging/bcm/target_params.h
deleted file mode 100644 (file)
index dc45f9a..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef TARGET_PARAMS_H
-#define TARGET_PARAMS_H
-
-struct bcm_target_params {
-       u32 m_u32CfgVersion;
-       u32 m_u32CenterFrequency;
-       u32 m_u32BandAScan;
-       u32 m_u32BandBScan;
-       u32 m_u32BandCScan;
-       u32 m_u32ErtpsOptions;
-       u32 m_u32PHSEnable;
-       u32 m_u32HoEnable;
-       u32 m_u32HoReserved1;
-       u32 m_u32HoReserved2;
-       u32 m_u32MimoEnable;
-       u32 m_u32SecurityEnable;
-       u32 m_u32PowerSavingModesEnable; /* bit 1: 1 Idlemode enable; bit2: 1 Sleepmode Enable */
-       /* PowerSaving Mode Options:
-        * bit 0 = 1: CPE mode - to keep pcmcia if alive;
-        * bit 1 = 1: CINR reporting in Idlemode Msg
-        * bit 2 = 1: Default PSC Enable in sleepmode
-        */
-       u32 m_u32PowerSavingModeOptions;
-       u32 m_u32ArqEnable;
-       /* From Version #3, the HARQ section renamed as general */
-       u32 m_u32HarqEnable;
-       u32 m_u32EEPROMFlag;
-       /* BINARY TYPE - 4th MSByte: Interface Type -  3rd MSByte: Vendor Type - 2nd MSByte
-        * Unused - LSByte
-        */
-       u32 m_u32Customize;
-       u32 m_u32ConfigBW;  /* In Hz */
-       u32 m_u32ShutDownInitThresholdTimer;
-       u32 m_u32RadioParameter;
-       u32 m_u32PhyParameter1;
-       u32 m_u32PhyParameter2;
-       u32 m_u32PhyParameter3;
-       u32 m_u32TestOptions; /* in eval mode only; lower 16bits = basic cid for testing; then bit 16 is test cqich,bit 17  test init rang; bit 18 test periodic rang and bit 19 is test harq ack/nack */
-       u32 m_u32MaxMACDataperDLFrame;
-       u32 m_u32MaxMACDataperULFrame;
-       u32 m_u32Corr2MacFlags;
-       u32 HostDrvrConfig1;
-       u32 HostDrvrConfig2;
-       u32 HostDrvrConfig3;
-       u32 HostDrvrConfig4;
-       u32 HostDrvrConfig5;
-       u32 HostDrvrConfig6;
-       u32 m_u32SegmentedPUSCenable;
-       /* removed SHUT down related 'unused' params from here to sync 4.x and 5.x CFG files..
-        * BAMC Related Parameters
-        * Bit 0-15 Band AMC signaling configuration: Bit 1 = 1 \96 Enable Band AMC signaling.
-        * bit 16-31 Band AMC Data configuration: Bit 16 = 1 \96 Band AMC 2x3 support.
-        */
-       u32 m_u32BandAMCEnable;
-};
-
-#endif
diff --git a/drivers/staging/bcm/vendorspecificextn.c b/drivers/staging/bcm/vendorspecificextn.c
deleted file mode 100644 (file)
index 1d9bef6..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-#include "headers.h"
-/*
- * Procedure:  vendorextnGetSectionInfo
- *
- * Description: Finds the type of NVM used.
- *
- * Arguments:
- *             Adapter    - ptr to Adapter object instance
- *             pNVMType   - ptr to NVM type.
- * Returns:
- *             STATUS_SUCCESS/STATUS_FAILURE
- *
- */
-INT vendorextnGetSectionInfo(PVOID  pContext,
-                       struct bcm_flash2x_vendor_info *pVendorInfo)
-{
-       return STATUS_FAILURE;
-}
-
-/*
- * Procedure:   vendorextnInit
- *
- * Description: Initializing the vendor extension NVM interface
- *
- * Arguments:
- *              Adapter   - Pointer to MINI Adapter Structure
- * Returns:
- *             STATUS_SUCCESS/STATUS_FAILURE
- *
- *
- */
-INT vendorextnInit(struct bcm_mini_adapter *Adapter)
-{
-       return STATUS_SUCCESS;
-}
-
-/*
- * Procedure:   vendorextnExit
- *
- * Description: Free the resource associated with vendor extension NVM interface
- *
- * Arguments:
- *
- * Returns:
- *              STATUS_SUCCESS/STATUS_FAILURE
- *
- *
- */
-INT vendorextnExit(struct bcm_mini_adapter *Adapter)
-{
-       return STATUS_SUCCESS;
-}
-
-/*
- * Procedure:  vendorextnIoctl
- *
- * Description: execute the vendor extension specific ioctl
- *
- * Arguments:
- *             Adapter -Beceem private Adapter Structure
- *             cmd     -vendor extension specific Ioctl commad
- *             arg     -input parameter sent by vendor
- *
- * Returns:
- *             CONTINUE_COMMON_PATH in case it is not meant to be processed
- *             by vendor ioctls
- *             STATUS_SUCCESS/STATUS_FAILURE as per the IOCTL return value
- */
-
-INT vendorextnIoctl(struct bcm_mini_adapter *Adapter, UINT cmd, ULONG arg)
-{
-       return CONTINUE_COMMON_PATH;
-}
-
-
-
-/*
- * Procedure:  vendorextnReadSection
- *
- * Description: Reads from a section of NVM
- *
- * Arguments:
- *             pContext - ptr to Adapter object instance
- *             pBuffer - Read the data from Vendor Area to this buffer
- *             SectionVal   - Value of type of Section
- *             Offset - Read from the Offset of the Vendor Section.
- *             numOfBytes - Read numOfBytes from the Vendor section to Buffer
- *
- * Returns:
- *             STATUS_SUCCESS/STATUS_FAILURE
- */
-
-INT vendorextnReadSection(PVOID  pContext, PUCHAR pBuffer,
-       enum bcm_flash2x_section_val SectionVal, UINT offset, UINT numOfBytes)
-{
-       return STATUS_FAILURE;
-}
-
-
-
-/*
- * Procedure:  vendorextnWriteSection
- *
- * Description: Write to a Section of NVM
- *
- * Arguments:
- *             pContext - ptr to Adapter object instance
- *             pBuffer - Write the data provided in the buffer
- *             SectionVal   - Value of type of Section
- *             Offset - Writes to the Offset of the Vendor Section.
- *             numOfBytes - Write num Bytes after reading from pBuffer.
- *             bVerify - the Buffer Written should be verified.
- *
- * Returns:
- *             STATUS_SUCCESS/STATUS_FAILURE
- */
-INT vendorextnWriteSection(PVOID  pContext, PUCHAR pBuffer,
-       enum bcm_flash2x_section_val SectionVal, UINT offset,
-       UINT numOfBytes, bool bVerify)
-{
-       return STATUS_FAILURE;
-}
-
-
-
-/*
- * Procedure:  vendorextnWriteSectionWithoutErase
- *
- * Description: Write to a Section of NVM without erasing the sector
- *
- * Arguments:
- *             pContext - ptr to Adapter object instance
- *             pBuffer - Write the data provided in the buffer
- *             SectionVal   - Value of type of Section
- *             Offset - Writes to the Offset of the Vendor Section.
- *             numOfBytes - Write num Bytes after reading from pBuffer.
- *
- * Returns:
- *             STATUS_SUCCESS/STATUS_FAILURE
- */
-INT vendorextnWriteSectionWithoutErase(PVOID  pContext, PUCHAR pBuffer,
-       enum bcm_flash2x_section_val SectionVal, UINT offset, UINT numOfBytes)
-{
-       return STATUS_FAILURE;
-}
diff --git a/drivers/staging/bcm/vendorspecificextn.h b/drivers/staging/bcm/vendorspecificextn.h
deleted file mode 100644 (file)
index ff57f05..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-
-#ifndef __VENDOR_EXTN_NVM_H__
-#define __VENDOR_EXTN_NVM_H__
-
-#define CONTINUE_COMMON_PATH 0xFFFF
-
-INT vendorextnGetSectionInfo(PVOID  pContext, struct bcm_flash2x_vendor_info *pVendorInfo);
-INT vendorextnExit(struct bcm_mini_adapter *Adapter);
-INT vendorextnInit(struct bcm_mini_adapter *Adapter);
-INT vendorextnIoctl(struct bcm_mini_adapter *Adapter, UINT cmd, ULONG arg);
-INT vendorextnReadSection(PVOID  pContext, PUCHAR pBuffer, enum bcm_flash2x_section_val SectionVal,
-                       UINT offset, UINT numOfBytes);
-INT vendorextnWriteSection(PVOID  pContext, PUCHAR pBuffer, enum bcm_flash2x_section_val SectionVal,
-                       UINT offset, UINT numOfBytes, bool bVerify);
-INT vendorextnWriteSectionWithoutErase(PVOID  pContext, PUCHAR pBuffer, enum bcm_flash2x_section_val SectionVal,
-                       UINT offset, UINT numOfBytes);
-
-#endif /*  */
diff --git a/drivers/staging/clocking-wizard/Kconfig b/drivers/staging/clocking-wizard/Kconfig
new file mode 100644 (file)
index 0000000..357af02
--- /dev/null
@@ -0,0 +1,9 @@
+#
+# Xilinx Clocking Wizard Driver
+#
+
+config COMMON_CLK_XLNX_CLKWZRD
+       tristate "Xilinx Clocking Wizard"
+       depends on COMMON_CLK && OF
+       ---help---
+         Support for the Xilinx Clocking Wizard IP core clock generator.
diff --git a/drivers/staging/clocking-wizard/Makefile b/drivers/staging/clocking-wizard/Makefile
new file mode 100644 (file)
index 0000000..5ad352f
--- /dev/null
@@ -0,0 +1 @@
+obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD)  += clk-xlnx-clock-wizard.o
diff --git a/drivers/staging/clocking-wizard/TODO b/drivers/staging/clocking-wizard/TODO
new file mode 100644 (file)
index 0000000..ebe99db
--- /dev/null
@@ -0,0 +1,12 @@
+TODO:
+       - support for fractional multiplier
+       - support for fractional divider (output 0 only)
+       - support for set_rate() operations (may benefit from Stephen Boyd's
+         refactoring of the clk primitives: https://lkml.org/lkml/2014/9/5/766)
+       - review arithmetic
+         - overflow after multiplication?
+         - maximize accuracy before divisions
+
+Patches to:
+       Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+       Sören Brinkmann <soren.brinkmann@xilinx.com>
diff --git a/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c
new file mode 100644 (file)
index 0000000..7202d8e
--- /dev/null
@@ -0,0 +1,335 @@
+/*
+ * Xilinx 'Clocking Wizard' driver
+ *
+ *  Copyright (C) 2013 - 2014 Xilinx
+ *
+ *  Sören Brinkmann <soren.brinkmann@xilinx.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License v2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/clk-provider.h>
+#include <linux/slab.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/module.h>
+#include <linux/err.h>
+
+#define WZRD_NUM_OUTPUTS       7
+#define WZRD_ACLK_MAX_FREQ     250000000UL
+
+#define WZRD_CLK_CFG_REG(n)    (0x200 + 4 * (n))
+
+#define WZRD_CLkOUT0_FRAC_EN   BIT(18)
+#define WZRD_CLkFBOUT_FRAC_EN  BIT(26)
+
+#define WZRD_CLKFBOUT_MULT_SHIFT       8
+#define WZRD_CLKFBOUT_MULT_MASK                (0xff << WZRD_CLKFBOUT_MULT_SHIFT)
+#define WZRD_DIVCLK_DIVIDE_SHIFT       0
+#define WZRD_DIVCLK_DIVIDE_MASK                (0xff << WZRD_DIVCLK_DIVIDE_SHIFT)
+#define WZRD_CLKOUT_DIVIDE_SHIFT       0
+#define WZRD_CLKOUT_DIVIDE_MASK                (0xff << WZRD_DIVCLK_DIVIDE_SHIFT)
+
+enum clk_wzrd_int_clks {
+       wzrd_clk_mul,
+       wzrd_clk_mul_div,
+       wzrd_clk_int_max
+};
+
+/**
+ * struct clk_wzrd:
+ * @clk_data:          Clock data
+ * @nb:                        Notifier block
+ * @base:              Memory base
+ * @clk_in1:           Handle to input clock 'clk_in1'
+ * @axi_clk:           Handle to input clock 's_axi_aclk'
+ * @clks_internal:     Internal clocks
+ * @clkout:            Output clocks
+ * @speed_grade:       Speed grade of the device
+ * @suspended:         Flag indicating power state of the device
+ */
+struct clk_wzrd {
+       struct clk_onecell_data clk_data;
+       struct notifier_block nb;
+       void __iomem *base;
+       struct clk *clk_in1;
+       struct clk *axi_clk;
+       struct clk *clks_internal[wzrd_clk_int_max];
+       struct clk *clkout[WZRD_NUM_OUTPUTS];
+       int speed_grade;
+       bool suspended;
+};
+#define to_clk_wzrd(_nb) container_of(_nb, struct clk_wzrd, nb)
+
+/* maximum frequencies for input/output clocks per speed grade */
+static const unsigned long clk_wzrd_max_freq[] = {
+       800000000UL,
+       933000000UL,
+       1066000000UL
+};
+
+static int clk_wzrd_clk_notifier(struct notifier_block *nb, unsigned long event,
+                                void *data)
+{
+       unsigned long max;
+       struct clk_notifier_data *ndata = data;
+       struct clk_wzrd *clk_wzrd = to_clk_wzrd(nb);
+
+       if (clk_wzrd->suspended)
+               return NOTIFY_OK;
+
+       if (ndata->clk == clk_wzrd->clk_in1)
+               max = clk_wzrd_max_freq[clk_wzrd->speed_grade - 1];
+       if (ndata->clk == clk_wzrd->axi_clk)
+               max = WZRD_ACLK_MAX_FREQ;
+
+       switch (event) {
+       case PRE_RATE_CHANGE:
+               if (ndata->new_rate > max)
+                       return NOTIFY_BAD;
+               return NOTIFY_OK;
+       case POST_RATE_CHANGE:
+       case ABORT_RATE_CHANGE:
+       default:
+               return NOTIFY_DONE;
+       }
+}
+
+static int __maybe_unused clk_wzrd_suspend(struct device *dev)
+{
+       struct clk_wzrd *clk_wzrd = dev_get_drvdata(dev);
+
+       clk_disable_unprepare(clk_wzrd->axi_clk);
+       clk_wzrd->suspended = true;
+
+       return 0;
+}
+
+static int __maybe_unused clk_wzrd_resume(struct device *dev)
+{
+       int ret;
+       struct clk_wzrd *clk_wzrd = dev_get_drvdata(dev);
+
+       ret = clk_prepare_enable(clk_wzrd->axi_clk);
+       if (ret) {
+               dev_err(dev, "unable to enable s_axi_aclk\n");
+               return ret;
+       }
+
+       clk_wzrd->suspended = false;
+
+       return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(clk_wzrd_dev_pm_ops, clk_wzrd_suspend,
+                        clk_wzrd_resume);
+
+static int clk_wzrd_probe(struct platform_device *pdev)
+{
+       int i, ret;
+       u32 reg;
+       unsigned long rate;
+       const char *clk_name;
+       struct clk_wzrd *clk_wzrd;
+       struct resource *mem;
+       struct device_node *np = pdev->dev.of_node;
+
+       clk_wzrd = devm_kzalloc(&pdev->dev, sizeof(*clk_wzrd), GFP_KERNEL);
+       if (!clk_wzrd)
+               return -ENOMEM;
+       platform_set_drvdata(pdev, clk_wzrd);
+
+       mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       clk_wzrd->base = devm_ioremap_resource(&pdev->dev, mem);
+       if (IS_ERR(clk_wzrd->base))
+               return PTR_ERR(clk_wzrd->base);
+
+       ret = of_property_read_u32(np, "speed-grade", &clk_wzrd->speed_grade);
+       if (!ret) {
+               if (clk_wzrd->speed_grade < 1 || clk_wzrd->speed_grade > 3) {
+                       dev_warn(&pdev->dev, "invalid speed grade '%d'\n",
+                                clk_wzrd->speed_grade);
+                       clk_wzrd->speed_grade = 0;
+               }
+       }
+
+       clk_wzrd->clk_in1 = devm_clk_get(&pdev->dev, "clk_in1");
+       if (IS_ERR(clk_wzrd->clk_in1)) {
+               if (clk_wzrd->clk_in1 != ERR_PTR(-EPROBE_DEFER))
+                       dev_err(&pdev->dev, "clk_in1 not found\n");
+               return PTR_ERR(clk_wzrd->clk_in1);
+       }
+
+       clk_wzrd->axi_clk = devm_clk_get(&pdev->dev, "s_axi_aclk");
+       if (IS_ERR(clk_wzrd->axi_clk)) {
+               if (clk_wzrd->axi_clk != ERR_PTR(-EPROBE_DEFER))
+                       dev_err(&pdev->dev, "s_axi_aclk not found\n");
+               return PTR_ERR(clk_wzrd->axi_clk);
+       }
+       ret = clk_prepare_enable(clk_wzrd->axi_clk);
+       if (ret) {
+               dev_err(&pdev->dev, "enabling s_axi_aclk failed\n");
+               return ret;
+       }
+       rate = clk_get_rate(clk_wzrd->axi_clk);
+       if (rate > WZRD_ACLK_MAX_FREQ) {
+               dev_err(&pdev->dev, "s_axi_aclk frequency (%lu) too high\n",
+                       rate);
+               ret = -EINVAL;
+               goto err_disable_clk;
+       }
+
+       /* we don't support fractional div/mul yet */
+       reg = readl(clk_wzrd->base + WZRD_CLK_CFG_REG(0)) &
+                   WZRD_CLkFBOUT_FRAC_EN;
+       reg |= readl(clk_wzrd->base + WZRD_CLK_CFG_REG(2)) &
+                    WZRD_CLkOUT0_FRAC_EN;
+       if (reg)
+               dev_warn(&pdev->dev, "fractional div/mul not supported\n");
+
+       /* register multiplier */
+       reg = (readl(clk_wzrd->base + WZRD_CLK_CFG_REG(0)) &
+                    WZRD_CLKFBOUT_MULT_MASK) >> WZRD_CLKFBOUT_MULT_SHIFT;
+       clk_name = kasprintf(GFP_KERNEL, "%s_mul", dev_name(&pdev->dev));
+       if (!clk_name) {
+               ret = -ENOMEM;
+               goto err_disable_clk;
+       }
+       clk_wzrd->clks_internal[wzrd_clk_mul] = clk_register_fixed_factor(
+                       &pdev->dev, clk_name,
+                       __clk_get_name(clk_wzrd->clk_in1),
+                       0, reg, 1);
+       kfree(clk_name);
+       if (IS_ERR(clk_wzrd->clks_internal[wzrd_clk_mul])) {
+               dev_err(&pdev->dev, "unable to register fixed-factor clock\n");
+               ret = PTR_ERR(clk_wzrd->clks_internal[wzrd_clk_mul]);
+               goto err_disable_clk;
+       }
+
+       /* register div */
+       reg = (readl(clk_wzrd->base + WZRD_CLK_CFG_REG(0)) &
+                       WZRD_DIVCLK_DIVIDE_MASK) >> WZRD_DIVCLK_DIVIDE_SHIFT;
+       clk_name = kasprintf(GFP_KERNEL, "%s_mul_div", dev_name(&pdev->dev));
+       clk_wzrd->clks_internal[wzrd_clk_mul_div] = clk_register_fixed_factor(
+                       &pdev->dev, clk_name,
+                       __clk_get_name(clk_wzrd->clks_internal[wzrd_clk_mul]),
+                       0, 1, reg);
+       if (IS_ERR(clk_wzrd->clks_internal[wzrd_clk_mul_div])) {
+               dev_err(&pdev->dev, "unable to register divider clock\n");
+               ret = PTR_ERR(clk_wzrd->clks_internal[wzrd_clk_mul_div]);
+               goto err_rm_int_clk;
+       }
+
+       /* register div per output */
+       for (i = WZRD_NUM_OUTPUTS - 1; i >= 0 ; i--) {
+               const char *clkout_name;
+               if (of_property_read_string_index(np, "clock-output-names", i,
+                                                 &clkout_name)) {
+                       dev_err(&pdev->dev,
+                               "clock output name not specified\n");
+                       ret = -EINVAL;
+                       goto err_rm_int_clks;
+               }
+               reg = readl(clk_wzrd->base + WZRD_CLK_CFG_REG(2) + i * 12);
+               reg &= WZRD_CLKOUT_DIVIDE_MASK;
+               reg >>= WZRD_CLKOUT_DIVIDE_SHIFT;
+               clk_wzrd->clkout[i] = clk_register_fixed_factor(&pdev->dev,
+                               clkout_name, clk_name, 0, 1, reg);
+               if (IS_ERR(clk_wzrd->clkout[i])) {
+                       int j;
+                       for (j = i + 1; j < WZRD_NUM_OUTPUTS; j++)
+                               clk_unregister(clk_wzrd->clkout[j]);
+                       dev_err(&pdev->dev,
+                               "unable to register divider clock\n");
+                       ret = PTR_ERR(clk_wzrd->clkout[i]);
+                       goto err_rm_int_clks;
+               }
+       }
+
+       kfree(clk_name);
+
+       clk_wzrd->clk_data.clks = clk_wzrd->clkout;
+       clk_wzrd->clk_data.clk_num = ARRAY_SIZE(clk_wzrd->clkout);
+       of_clk_add_provider(np, of_clk_src_onecell_get, &clk_wzrd->clk_data);
+
+       if (clk_wzrd->speed_grade) {
+               clk_wzrd->nb.notifier_call = clk_wzrd_clk_notifier;
+
+               ret = clk_notifier_register(clk_wzrd->clk_in1,
+                                           &clk_wzrd->nb);
+               if (ret)
+                       dev_warn(&pdev->dev,
+                                "unable to register clock notifier\n");
+
+               ret = clk_notifier_register(clk_wzrd->axi_clk, &clk_wzrd->nb);
+               if (ret)
+                       dev_warn(&pdev->dev,
+                                "unable to register clock notifier\n");
+       }
+
+       return 0;
+
+err_rm_int_clks:
+       clk_unregister(clk_wzrd->clks_internal[1]);
+err_rm_int_clk:
+       kfree(clk_name);
+       clk_unregister(clk_wzrd->clks_internal[0]);
+err_disable_clk:
+       clk_disable_unprepare(clk_wzrd->axi_clk);
+
+       return ret;
+}
+
+static int clk_wzrd_remove(struct platform_device *pdev)
+{
+       int i;
+       struct clk_wzrd *clk_wzrd = platform_get_drvdata(pdev);
+
+       of_clk_del_provider(pdev->dev.of_node);
+
+       for (i = 0; i < WZRD_NUM_OUTPUTS; i++)
+               clk_unregister(clk_wzrd->clkout[i]);
+       for (i = 0; i < wzrd_clk_int_max; i++)
+               clk_unregister(clk_wzrd->clks_internal[i]);
+
+       if (clk_wzrd->speed_grade) {
+               clk_notifier_unregister(clk_wzrd->axi_clk, &clk_wzrd->nb);
+               clk_notifier_unregister(clk_wzrd->clk_in1, &clk_wzrd->nb);
+       }
+
+       clk_disable_unprepare(clk_wzrd->axi_clk);
+
+       return 0;
+}
+
+static const struct of_device_id clk_wzrd_ids[] = {
+       { .compatible = "xlnx,clocking-wizard" },
+       { },
+};
+MODULE_DEVICE_TABLE(of, clk_wzrd_ids);
+
+static struct platform_driver clk_wzrd_driver = {
+       .driver = {
+               .name = "clk-wizard",
+               .of_match_table = clk_wzrd_ids,
+               .pm = &clk_wzrd_dev_pm_ops,
+       },
+       .probe = clk_wzrd_probe,
+       .remove = clk_wzrd_remove,
+};
+module_platform_driver(clk_wzrd_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Soeren Brinkmann <soren.brinkmann@xilinx.com");
+MODULE_DESCRIPTION("Driver for the Xilinx Clocking Wizard IP core");
diff --git a/drivers/staging/clocking-wizard/dt-binding.txt b/drivers/staging/clocking-wizard/dt-binding.txt
new file mode 100644 (file)
index 0000000..723271e
--- /dev/null
@@ -0,0 +1,30 @@
+Binding for Xilinx Clocking Wizard IP Core
+
+This binding uses the common clock binding[1]. Details about the devices can be
+found in the product guide[2].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+[2] Clocking Wizard Product Guide
+http://www.xilinx.com/support/documentation/ip_documentation/clk_wiz/v5_1/pg065-clk-wiz.pdf
+
+Required properties:
+ - compatible: Must be 'xlnx,clocking-wizard'
+ - reg: Base and size of the cores register space
+ - clocks: Handle to input clock
+ - clock-names: Tuple containing 'clk_in1' and 's_axi_aclk'
+ - clock-output-names: Names for the output clocks
+
+Optional properties:
+ - speed-grade: Speed grade of the device (valid values are 1..3)
+
+Example:
+       clock-generator@40040000 {
+               reg = <0x40040000 0x1000>;
+               compatible = "xlnx,clocking-wizard";
+               speed-grade = <1>;
+               clock-names = "clk_in1", "s_axi_aclk";
+               clocks = <&clkc 15>, <&clkc 15>;
+               clock-output-names = "clk_out0", "clk_out1", "clk_out2",
+                                    "clk_out3", "clk_out4", "clk_out5",
+                                    "clk_out6", "clk_out7";
+       };
index 152f4c1..b2d68ec 100644 (file)
@@ -595,14 +595,6 @@ config COMEDI_ADDI_WATCHDOG
          boards. This module will be automatically selected when needed. The
          module will be called addi_watchdog.
 
-config COMEDI_ADDI_APCI_035
-       tristate "ADDI-DATA APCI_035 support"
-       ---help---
-         Enable support for ADDI-DATA APCI_035 cards
-
-         To compile this driver as a module, choose M here: the module will be
-         called addi_apci_035.
-
 config COMEDI_ADDI_APCI_1032
        tristate "ADDI-DATA APCI_1032 support"
        ---help---
@@ -939,11 +931,11 @@ config COMEDI_CB_PCIDDA
          called cb_pcidda.
 
 config COMEDI_CB_PCIMDAS
-       tristate "MeasurementComputing PCIM-DAS1602/16 support"
+       tristate "MeasurementComputing PCIM-DAS1602/16, PCIe-DAS1602/16 support"
        select COMEDI_8255
        ---help---
          Enable support for ComputerBoards/MeasurementComputing PCI Migration
-         series PCIM-DAS1602/16
+         series PCIM-DAS1602/16 and PCIe-DAS1602/16.
 
          To compile this driver as a module, choose M here: the module will be
          called cb_pcimdas.
index c8c99e6..f302ce6 100644 (file)
@@ -514,17 +514,6 @@ struct comedi_bufinfo {
 
 #define COMEDI_MIN_SPEED       ((unsigned int)0xffffffff)
 
-/* callback stuff */
-/* only relevant to kernel modules. */
-
-#define COMEDI_CB_EOS          1       /* end of scan */
-#define COMEDI_CB_EOA          2       /* end of acquisition/output */
-#define COMEDI_CB_BLOCK                4       /* data has arrived:
-                                        * wakes up read() / write() */
-#define COMEDI_CB_EOBUF                8       /* DEPRECATED: end of buffer */
-#define COMEDI_CB_ERROR                16      /* card error during acquisition */
-#define COMEDI_CB_OVERFLOW     32      /* buffer overflow/underflow */
-
 /**********************************************************/
 /* everything after this line is ALPHA */
 /**********************************************************/
index c60a45a..6dd87cb 100644 (file)
@@ -252,15 +252,15 @@ static unsigned int comedi_buf_write_n_available(struct comedi_subdevice *s)
        return free_end - async->buf_write_alloc_count;
 }
 
-static unsigned int __comedi_buf_write_alloc(struct comedi_subdevice *s,
-                                            unsigned int nbytes,
-                                            int strict)
+/* allocates chunk for the writer from free buffer space */
+unsigned int comedi_buf_write_alloc(struct comedi_subdevice *s,
+                                   unsigned int nbytes)
 {
        struct comedi_async *async = s->async;
        unsigned int available = comedi_buf_write_n_available(s);
 
        if (nbytes > available)
-               nbytes = strict ? 0 : available;
+               nbytes = available;
 
        async->buf_write_alloc_count += nbytes;
 
@@ -272,13 +272,6 @@ static unsigned int __comedi_buf_write_alloc(struct comedi_subdevice *s,
 
        return nbytes;
 }
-
-/* allocates chunk for the writer from free buffer space */
-unsigned int comedi_buf_write_alloc(struct comedi_subdevice *s,
-                                   unsigned int nbytes)
-{
-       return __comedi_buf_write_alloc(s, nbytes, 0);
-}
 EXPORT_SYMBOL_GPL(comedi_buf_write_alloc);
 
 /*
@@ -427,43 +420,11 @@ unsigned int comedi_buf_read_free(struct comedi_subdevice *s,
 }
 EXPORT_SYMBOL_GPL(comedi_buf_read_free);
 
-int comedi_buf_put(struct comedi_subdevice *s, unsigned short x)
-{
-       struct comedi_async *async = s->async;
-       unsigned int n = __comedi_buf_write_alloc(s, sizeof(short), 1);
-
-       if (n < sizeof(short)) {
-               async->events |= COMEDI_CB_ERROR;
-               return 0;
-       }
-       *(unsigned short *)(async->prealloc_buf + async->buf_write_ptr) = x;
-       comedi_buf_write_free(s, sizeof(short));
-       return 1;
-}
-EXPORT_SYMBOL_GPL(comedi_buf_put);
-
-int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x)
-{
-       struct comedi_async *async = s->async;
-       unsigned int n = comedi_buf_read_n_available(s);
-
-       if (n < sizeof(short))
-               return 0;
-       comedi_buf_read_alloc(s, sizeof(short));
-       *x = *(unsigned short *)(async->prealloc_buf + async->buf_read_ptr);
-       comedi_buf_read_free(s, sizeof(short));
-       return 1;
-}
-EXPORT_SYMBOL_GPL(comedi_buf_get);
-
-void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset,
-                         const void *data, unsigned int num_bytes)
+static void comedi_buf_memcpy_to(struct comedi_subdevice *s,
+                                const void *data, unsigned int num_bytes)
 {
        struct comedi_async *async = s->async;
-       unsigned int write_ptr = async->buf_write_ptr + offset;
-
-       if (write_ptr >= async->prealloc_bufsz)
-               write_ptr %= async->prealloc_bufsz;
+       unsigned int write_ptr = async->buf_write_ptr;
 
        while (num_bytes) {
                unsigned int block_size;
@@ -481,17 +442,13 @@ void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset,
                write_ptr = 0;
        }
 }
-EXPORT_SYMBOL_GPL(comedi_buf_memcpy_to);
 
-void comedi_buf_memcpy_from(struct comedi_subdevice *s, unsigned int offset,
-                           void *dest, unsigned int nbytes)
+static void comedi_buf_memcpy_from(struct comedi_subdevice *s,
+                                  void *dest, unsigned int nbytes)
 {
        void *src;
        struct comedi_async *async = s->async;
-       unsigned int read_ptr = async->buf_read_ptr + offset;
-
-       if (read_ptr >= async->prealloc_bufsz)
-               read_ptr %= async->prealloc_bufsz;
+       unsigned int read_ptr = async->buf_read_ptr;
 
        while (nbytes) {
                unsigned int block_size;
@@ -509,69 +466,76 @@ void comedi_buf_memcpy_from(struct comedi_subdevice *s, unsigned int offset,
                read_ptr = 0;
        }
 }
-EXPORT_SYMBOL_GPL(comedi_buf_memcpy_from);
 
 /**
- * comedi_write_array_to_buffer - write data to comedi buffer
+ * comedi_buf_write_samples - write sample data to comedi buffer
  * @s: comedi_subdevice struct
- * @data: destination
- * @num_bytes: number of bytes to write
+ * @data: samples
+ * @nsamples: number of samples
  *
- * Writes up to num_bytes bytes of data to the comedi buffer associated with
- * the subdevice, marks it as written and updates the acquisition scan
- * progress.
+ * Writes nsamples to the comedi buffer associated with the subdevice, marks
+ * it as written and updates the acquisition scan progress.
  *
  * Returns the amount of data written in bytes.
  */
-unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s,
-                                         const void *data,
-                                         unsigned int num_bytes)
+unsigned int comedi_buf_write_samples(struct comedi_subdevice *s,
+                                     const void *data, unsigned int nsamples)
 {
-       struct comedi_async *async = s->async;
-       unsigned int retval;
-
-       if (num_bytes == 0)
-               return 0;
+       unsigned int max_samples;
+       unsigned int nbytes;
 
-       retval = comedi_buf_write_alloc(s, num_bytes);
-       if (retval != num_bytes) {
+       /* make sure there is enought room in the buffer for all the samples */
+       max_samples = comedi_buf_write_n_available(s) / bytes_per_sample(s);
+       if (nsamples > max_samples) {
                dev_warn(s->device->class_dev, "buffer overrun\n");
-               async->events |= COMEDI_CB_OVERFLOW;
+               s->async->events |= COMEDI_CB_OVERFLOW;
                return 0;
        }
 
-       comedi_buf_memcpy_to(s, 0, data, num_bytes);
-       comedi_buf_write_free(s, num_bytes);
-       comedi_inc_scan_progress(s, num_bytes);
-       async->events |= COMEDI_CB_BLOCK;
+       if (nsamples == 0)
+               return 0;
 
-       return num_bytes;
+       nbytes = comedi_buf_write_alloc(s, nsamples * bytes_per_sample(s));
+       comedi_buf_memcpy_to(s, data, nbytes);
+       comedi_buf_write_free(s, nbytes);
+       comedi_inc_scan_progress(s, nbytes);
+       s->async->events |= COMEDI_CB_BLOCK;
+
+       return nbytes;
 }
-EXPORT_SYMBOL_GPL(comedi_write_array_to_buffer);
+EXPORT_SYMBOL_GPL(comedi_buf_write_samples);
 
 /**
- * comedi_read_array_from_buffer - read data from comedi buffer
+ * comedi_buf_read_samples - read sample data from comedi buffer
  * @s: comedi_subdevice struct
  * @data: destination
- * @num_bytes: number of bytes to read
+ * @nsamples: maximum number of samples to read
  *
- * Reads up to num_bytes bytes of data from the comedi buffer associated with
- * the subdevice, marks it as read and updates the acquisition scan progress.
+ * Reads up to nsamples from the comedi buffer associated with the subdevice,
+ * marks it as read and updates the acquisition scan progress.
  *
  * Returns the amount of data read in bytes.
  */
-unsigned int comedi_read_array_from_buffer(struct comedi_subdevice *s,
-                                          void *data, unsigned int num_bytes)
+unsigned int comedi_buf_read_samples(struct comedi_subdevice *s,
+                                    void *data, unsigned int nsamples)
 {
-       if (num_bytes == 0)
+       unsigned int max_samples;
+       unsigned int nbytes;
+
+       /* clamp nsamples to the number of full samples available */
+       max_samples = comedi_buf_read_n_available(s) / bytes_per_sample(s);
+       if (nsamples > max_samples)
+               nsamples = max_samples;
+
+       if (nsamples == 0)
                return 0;
 
-       num_bytes = comedi_buf_read_alloc(s, num_bytes);
-       comedi_buf_memcpy_from(s, 0, data, num_bytes);
-       comedi_buf_read_free(s, num_bytes);
-       comedi_inc_scan_progress(s, num_bytes);
+       nbytes = comedi_buf_read_alloc(s, nsamples * bytes_per_sample(s));
+       comedi_buf_memcpy_from(s, data, nbytes);
+       comedi_buf_read_free(s, nbytes);
+       comedi_inc_scan_progress(s, nbytes);
        s->async->events |= COMEDI_CB_BLOCK;
 
-       return num_bytes;
+       return nbytes;
 }
-EXPORT_SYMBOL_GPL(comedi_read_array_from_buffer);
+EXPORT_SYMBOL_GPL(comedi_buf_read_samples);
index 9c32f02..c1fe9e0 100644 (file)
@@ -1552,9 +1552,7 @@ static int do_cmd_ioctl(struct comedi_device *dev,
 
        comedi_buf_reset(s);
 
-       async->cb_mask =
-           COMEDI_CB_EOA | COMEDI_CB_BLOCK | COMEDI_CB_ERROR |
-           COMEDI_CB_OVERFLOW;
+       async->cb_mask = COMEDI_CB_BLOCK | COMEDI_CB_CANCEL_MASK;
        if (async->cmd.flags & CMDF_WAKE_EOS)
                async->cb_mask |= COMEDI_CB_EOS;
 
@@ -1720,7 +1718,6 @@ static int do_cancel_ioctl(struct comedi_device *dev, unsigned long arg,
                           void *file)
 {
        struct comedi_subdevice *s;
-       int ret;
 
        if (arg >= dev->n_subdevices)
                return -EINVAL;
@@ -1734,9 +1731,7 @@ static int do_cancel_ioctl(struct comedi_device *dev, unsigned long arg,
        if (s->busy != file)
                return -EBUSY;
 
-       ret = do_cancel(dev, s);
-
-       return ret;
+       return do_cancel(dev, s);
 }
 
 /*
@@ -2395,14 +2390,14 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
        if (!comedi_is_subdevice_running(s))
                return;
 
-       if (s->
-           async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR |
-                            COMEDI_CB_OVERFLOW)) {
+       if (s->async->events & COMEDI_CB_CANCEL_MASK)
                runflags_mask |= SRF_RUNNING;
-       }
-       /* remember if an error event has occurred, so an error
-        * can be returned the next time the user does a read() */
-       if (s->async->events & (COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW)) {
+
+       /*
+        * Remember if an error event has occurred, so an error
+        * can be returned the next time the user does a read().
+        */
+       if (s->async->events & COMEDI_CB_ERROR_MASK) {
                runflags_mask |= SRF_ERROR;
                runflags |= SRF_ERROR;
        }
index 1b2bbd5..d18f702 100644 (file)
@@ -213,6 +213,28 @@ struct comedi_async {
                       unsigned int x);
 };
 
+/**
+ * comedi_async callback "events"
+ * @COMEDI_CB_EOS:             end-of-scan
+ * @COMEDI_CB_EOA:             end-of-acquisition/output
+ * @COMEDI_CB_BLOCK:           data has arrived, wakes up read() / write()
+ * @COMEDI_CB_EOBUF:           DEPRECATED: end of buffer
+ * @COMEDI_CB_ERROR:           card error during acquisition
+ * @COMEDI_CB_OVERFLOW:                buffer overflow/underflow
+ *
+ * @COMEDI_CB_ERROR_MASK:      events that indicate an error has occurred
+ * @COMEDI_CB_CANCEL_MASK:     events that will cancel an async command
+ */
+#define COMEDI_CB_EOS          (1 << 0)
+#define COMEDI_CB_EOA          (1 << 1)
+#define COMEDI_CB_BLOCK                (1 << 2)
+#define COMEDI_CB_EOBUF                (1 << 3)
+#define COMEDI_CB_ERROR                (1 << 4)
+#define COMEDI_CB_OVERFLOW     (1 << 5)
+
+#define COMEDI_CB_ERROR_MASK   (COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW)
+#define COMEDI_CB_CANCEL_MASK  (COMEDI_CB_EOA | COMEDI_CB_ERROR_MASK)
+
 struct comedi_driver {
        struct comedi_driver *next;
 
@@ -391,12 +413,67 @@ static inline unsigned int comedi_offset_munge(struct comedi_subdevice *s,
        return val ^ s->maxdata ^ (s->maxdata >> 1);
 }
 
-static inline unsigned int bytes_per_sample(const struct comedi_subdevice *subd)
+/**
+ * comedi_bytes_per_sample - determine subdevice sample size
+ * @s:         comedi_subdevice struct
+ *
+ * The sample size will be 4 (sizeof int) or 2 (sizeof short) depending on
+ * whether the SDF_LSAMPL subdevice flag is set or not.
+ *
+ * Returns the subdevice sample size.
+ */
+static inline unsigned int comedi_bytes_per_sample(struct comedi_subdevice *s)
+{
+       return s->subdev_flags & SDF_LSAMPL ? sizeof(int) : sizeof(short);
+}
+
+/* to be removed */
+static inline unsigned int bytes_per_sample(struct comedi_subdevice *s)
+{
+       return comedi_bytes_per_sample(s);
+}
+
+/**
+ * comedi_sample_shift - determine log2 of subdevice sample size
+ * @s:         comedi_subdevice struct
+ *
+ * The sample size will be 4 (sizeof int) or 2 (sizeof short) depending on
+ * whether the SDF_LSAMPL subdevice flag is set or not.  The log2 of the
+ * sample size will be 2 or 1 and can be used as the right operand of a
+ * bit-shift operator to multiply or divide something by the sample size.
+ *
+ * Returns log2 of the subdevice sample size.
+ */
+static inline unsigned int comedi_sample_shift(struct comedi_subdevice *s)
 {
-       if (subd->subdev_flags & SDF_LSAMPL)
-               return sizeof(unsigned int);
+       return s->subdev_flags & SDF_LSAMPL ? 2 : 1;
+}
 
-       return sizeof(short);
+/**
+ * comedi_bytes_to_samples - converts a number of bytes to a number of samples
+ * @s:         comedi_subdevice struct
+ * @nbytes:    number of bytes
+ *
+ * Returns the number of bytes divided by the subdevice sample size.
+ */
+static inline unsigned int comedi_bytes_to_samples(struct comedi_subdevice *s,
+                                                  unsigned int nbytes)
+{
+       return nbytes >> comedi_sample_shift(s);
+}
+
+/**
+ * comedi_samples_to_bytes - converts a number of samples to a number of bytes
+ * @s:         comedi_subdevice struct
+ * @nsamples:  number of samples
+ *
+ * Returns the number of samples multiplied by the subdevice sample size.
+ * Does not check for arithmetic overflow.
+ */
+static inline unsigned int comedi_samples_to_bytes(struct comedi_subdevice *s,
+                                                  unsigned int nsamples)
+{
+       return nsamples << comedi_sample_shift(s);
 }
 
 /*
@@ -419,18 +496,10 @@ unsigned int comedi_buf_read_n_available(struct comedi_subdevice *s);
 unsigned int comedi_buf_read_alloc(struct comedi_subdevice *s, unsigned int n);
 unsigned int comedi_buf_read_free(struct comedi_subdevice *s, unsigned int n);
 
-int comedi_buf_put(struct comedi_subdevice *s, unsigned short x);
-int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x);
-
-void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset,
-                         const void *source, unsigned int num_bytes);
-void comedi_buf_memcpy_from(struct comedi_subdevice *s, unsigned int offset,
-                           void *destination, unsigned int num_bytes);
-unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s,
-                                         const void *data,
-                                         unsigned int num_bytes);
-unsigned int comedi_read_array_from_buffer(struct comedi_subdevice *s,
-                                          void *data, unsigned int num_bytes);
+unsigned int comedi_buf_write_samples(struct comedi_subdevice *s,
+                                     const void *data, unsigned int nsamples);
+unsigned int comedi_buf_read_samples(struct comedi_subdevice *s,
+                                    void *data, unsigned int nsamples);
 
 /* drivers.c - general comedi driver functions */
 
index 3e5bccb..ff2df85 100644 (file)
@@ -317,8 +317,7 @@ unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s)
        case COMEDI_SUBD_DO:
        case COMEDI_SUBD_DIO:
                bits_per_sample = 8 * bytes_per_sample(s);
-               num_samples = (cmd->chanlist_len + bits_per_sample - 1) /
-                               bits_per_sample;
+               num_samples = DIV_ROUND_UP(cmd->chanlist_len, bits_per_sample);
                break;
        default:
                num_samples = cmd->chanlist_len;
@@ -376,7 +375,7 @@ unsigned int comedi_handle_events(struct comedi_device *dev,
        if (events == 0)
                return events;
 
-       if (events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW))
+       if (events & COMEDI_CB_CANCEL_MASK)
                s->cancel(dev, s);
 
        comedi_event(dev, s);
index 6bc9ef3..84fdf20 100644 (file)
@@ -60,7 +60,6 @@ obj-$(CONFIG_COMEDI_S526)             += s526.o
 # Comedi PCI drivers
 obj-$(CONFIG_COMEDI_8255_PCI)          += 8255_pci.o
 obj-$(CONFIG_COMEDI_ADDI_WATCHDOG)     += addi_watchdog.o
-obj-$(CONFIG_COMEDI_ADDI_APCI_035)     += addi_apci_035.o
 obj-$(CONFIG_COMEDI_ADDI_APCI_1032)    += addi_apci_1032.o
 obj-$(CONFIG_COMEDI_ADDI_APCI_1500)    += addi_apci_1500.o
 obj-$(CONFIG_COMEDI_ADDI_APCI_1516)    += addi_apci_1516.o
diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.c b/drivers/staging/comedi/drivers/addi-data/addi_common.c
deleted file mode 100644 (file)
index 2e7fb21..0000000
+++ /dev/null
@@ -1,274 +0,0 @@
-/**
-@verbatim
-
-Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
-
-       ADDI-DATA GmbH
-       Dieselstrasse 3
-       D-77833 Ottersweier
-       Tel: +19(0)7223/9493-0
-       Fax: +49(0)7223/9493-92
-       http://www.addi-data.com
-       info@addi-data.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.
-
-@endverbatim
-*/
-/*
-
-  +-----------------------------------------------------------------------+
-  | (C) ADDI-DATA GmbH          Dieselstrasse 3      D-77833 Ottersweier  |
-  +-----------------------------------------------------------------------+
-  | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |
-  | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |
-  +-----------------------------------------------------------------------+
-  | Project   : ADDI DATA         | Compiler : GCC                        |
-  | Modulname : addi_common.c     | Version  : 2.96                       |
-  +-------------------------------+---------------------------------------+
-  | Author    :           | Date     :                                    |
-  +-----------------------------------------------------------------------+
-  | Description : ADDI COMMON Main Module                                 |
-  +-----------------------------------------------------------------------+
-*/
-
-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 = dev->board_ptr;
-       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 = dev->board_ptr;
-
-       this_board->interrupt(irq, d);
-       return IRQ_RETVAL(1);
-}
-
-static int i_ADDI_Reset(struct comedi_device *dev)
-{
-       const struct addi_board *this_board = dev->board_ptr;
-
-       this_board->reset(dev);
-       return 0;
-}
-
-static int addi_auto_attach(struct comedi_device *dev,
-                                     unsigned long context_unused)
-{
-       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
-       const struct addi_board *this_board = dev->board_ptr;
-       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];
-       if ((devpriv->s_EeParameters.i_NbrAiChannel)
-               || (this_board->i_NbrAiChannelDiff)) {
-               dev->read_subdev = s;
-               s->type = COMEDI_SUBD_AI;
-               s->subdev_flags =
-                       SDF_READABLE | SDF_COMMON | SDF_GROUND
-                       | SDF_DIFF;
-               if (devpriv->s_EeParameters.i_NbrAiChannel)
-                       s->n_chan = devpriv->s_EeParameters.i_NbrAiChannel;
-               else
-                       s->n_chan = this_board->i_NbrAiChannelDiff;
-               s->maxdata = devpriv->s_EeParameters.i_AiMaxdata;
-               s->len_chanlist = this_board->i_AiChannelList;
-               s->range_table = this_board->pr_AiRangelist;
-
-               s->insn_config = this_board->ai_config;
-               s->insn_read = this_board->ai_read;
-               s->insn_write = this_board->ai_write;
-               s->insn_bits = this_board->ai_bits;
-               s->do_cmdtest = this_board->ai_cmdtest;
-               s->do_cmd = this_board->ai_cmd;
-               s->cancel = this_board->ai_cancel;
-
-       } else {
-               s->type = COMEDI_SUBD_UNUSED;
-       }
-
-       /*  Allocate and Initialise AO Subdevice Structures */
-       s = &dev->subdevices[1];
-       if (devpriv->s_EeParameters.i_NbrAoChannel) {
-               s->type = COMEDI_SUBD_AO;
-               s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
-               s->n_chan = devpriv->s_EeParameters.i_NbrAoChannel;
-               s->maxdata = devpriv->s_EeParameters.i_AoMaxdata;
-               s->len_chanlist =
-                       devpriv->s_EeParameters.i_NbrAoChannel;
-               s->insn_write = this_board->ao_write;
-       } else {
-               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 i_ADDI_Detach(struct comedi_device *dev)
-{
-       if (dev->iobase)
-               i_ADDI_Reset(dev);
-       comedi_pci_detach(dev);
-}
diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h
deleted file mode 100644 (file)
index e2a3ffe..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- *  Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.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.
- */
-
-#include <linux/sched.h>
-#include <linux/interrupt.h>
-
-struct addi_board {
-       const char *pc_DriverName;      /*  driver name */
-       int i_IorangeBase1;
-       int i_PCIEeprom;        /*  eeprom present or not */
-       char *pc_EepromChip;    /*  type of chip */
-       int i_NbrAiChannel;     /*  num of A/D chans */
-       int i_NbrAiChannelDiff; /*  num of A/D chans in diff mode */
-       int i_AiChannelList;    /*  len of chanlist */
-       int i_NbrAoChannel;     /*  num of D/A chans */
-       int i_AiMaxdata;        /*  resolution of A/D */
-       int i_AoMaxdata;        /*  resolution of D/A */
-       const struct comedi_lrange *pr_AiRangelist;     /* rangelist for A/D */
-
-       int i_NbrDiChannel;     /*  Number of DI channels */
-       int i_NbrDoChannel;     /*  Number of DO channels */
-       int i_DoMaxdata;        /*  data to set all channels high */
-
-       int i_Timer;            /*    timer subdevice present or not */
-       unsigned int ui_MinAcquisitiontimeNs;   /*  Minimum Acquisition in Nano secs */
-       unsigned int ui_MinDelaytimeNs; /*  Minimum Delay in Nano secs */
-
-       /* interrupt and reset */
-       void (*interrupt)(int irq, void *d);
-       int (*reset)(struct comedi_device *);
-
-       /* Subdevice functions */
-
-       /* ANALOG INPUT */
-       int (*ai_config)(struct comedi_device *, struct comedi_subdevice *,
-                        struct comedi_insn *, unsigned int *);
-       int (*ai_read)(struct comedi_device *, struct comedi_subdevice *,
-                      struct comedi_insn *, unsigned int *);
-       int (*ai_write)(struct comedi_device *, struct comedi_subdevice *,
-                       struct comedi_insn *, unsigned int *);
-       int (*ai_bits)(struct comedi_device *, struct comedi_subdevice *,
-                      struct comedi_insn *, unsigned int *);
-       int (*ai_cmdtest)(struct comedi_device *, struct comedi_subdevice *,
-                         struct comedi_cmd *);
-       int (*ai_cmd)(struct comedi_device *, struct comedi_subdevice *);
-       int (*ai_cancel)(struct comedi_device *, struct comedi_subdevice *);
-
-       /* Analog Output */
-       int (*ao_write)(struct comedi_device *, struct comedi_subdevice *,
-                       struct comedi_insn *, unsigned int *);
-
-       /* Digital Input */
-       int (*di_config)(struct comedi_device *, struct comedi_subdevice *,
-                        struct comedi_insn *, unsigned int *);
-       int (*di_read)(struct comedi_device *, struct comedi_subdevice *,
-                      struct comedi_insn *, unsigned int *);
-       int (*di_write)(struct comedi_device *, struct comedi_subdevice *,
-                       struct comedi_insn *, unsigned int *);
-       int (*di_bits)(struct comedi_device *, struct comedi_subdevice *,
-                      struct comedi_insn *, unsigned int *);
-
-       /* Digital Output */
-       int (*do_config)(struct comedi_device *, struct comedi_subdevice *,
-                        struct comedi_insn *, unsigned int *);
-       int (*do_write)(struct comedi_device *, struct comedi_subdevice *,
-                       struct comedi_insn *, unsigned int *);
-       int (*do_bits)(struct comedi_device *, struct comedi_subdevice *,
-                      struct comedi_insn *, unsigned int *);
-       int (*do_read)(struct comedi_device *, struct comedi_subdevice *,
-                      struct comedi_insn *, unsigned int *);
-
-       /* TIMER */
-       int (*timer_config)(struct comedi_device *, struct comedi_subdevice *,
-                           struct comedi_insn *, unsigned int *);
-       int (*timer_write)(struct comedi_device *, struct comedi_subdevice *,
-                          struct comedi_insn *, unsigned int *);
-       int (*timer_read)(struct comedi_device *, struct comedi_subdevice *,
-                         struct comedi_insn *, unsigned int *);
-       int (*timer_bits)(struct comedi_device *, struct comedi_subdevice *,
-                         struct comedi_insn *, unsigned int *);
-};
-
-struct addi_private {
-       int iobase;
-       int i_IobaseAmcc;       /*  base+size for AMCC chip */
-       int i_IobaseAddon;      /* addon base address */
-       int i_IobaseReserved;
-       unsigned int ui_AiActualScan;   /* how many scans we finished */
-       unsigned int ui_AiNbrofChannels;        /*  how many channels is measured */
-       unsigned int ui_AiChannelList[32];      /*  actual chanlist */
-       unsigned int ui_AiReadData[32];
-       unsigned short us_UseDma;       /*  To use Dma or not */
-       unsigned char b_DmaDoubleBuffer;        /*  we can use double buffering */
-       unsigned int ui_DmaActualBuffer;        /*  which buffer is used now */
-       unsigned short *ul_DmaBufferVirtual[2]; /*  pointers to DMA buffer */
-       dma_addr_t ul_DmaBufferHw[2];           /*  hw address of DMA buff */
-       unsigned int ui_DmaBufferSize[2];       /*  size of dma buffer in bytes */
-       unsigned int ui_DmaBufferUsesize[2];    /*  which size we may now used for transfer */
-       unsigned char b_DigitalOutputRegister;  /*  Digital Output Register */
-       unsigned char b_OutputMemoryStatus;
-       unsigned char b_TimerSelectMode;        /*  Contain data written at iobase + 0C */
-       unsigned char b_ModeSelectRegister;     /*  Contain data written at iobase + 0E */
-       unsigned short us_OutputRegister;       /*  Contain data written at iobase + 0 */
-       unsigned char b_Timer2Mode;     /*  Specify the timer 2 mode */
-       unsigned char b_Timer2Interrupt;        /* Timer2  interrupt enable or disable */
-       unsigned int ai_running:1;
-       unsigned char b_InterruptMode;  /*  eoc eos or dma */
-       unsigned char b_EocEosInterrupt;        /*  Enable disable eoc eos interrupt */
-       unsigned int ui_EocEosConversionTime;
-       unsigned char b_ExttrigEnable;  /* To enable or disable external trigger */
-
-       /* Pointer to the current process */
-       struct task_struct *tsk_Current;
-
-       /* Parameters read from EEPROM overriding static board info */
-       struct {
-               int i_NbrAiChannel;     /*  num of A/D chans */
-               int i_NbrAoChannel;     /*  num of D/A chans */
-               int i_AiMaxdata;        /*  resolution of A/D */
-               int i_AoMaxdata;        /*  resolution of D/A */
-               int i_NbrDiChannel;     /*  Number of DI channels */
-               int i_NbrDoChannel;     /*  Number of DO channels */
-               int i_DoMaxdata;        /*  data to set all channels high */
-               int i_Timer;            /*  timer subdevice present or not */
-               unsigned int ui_MinAcquisitiontimeNs;
-                                       /*  Minimum Acquisition in Nano secs */
-               unsigned int ui_MinDelaytimeNs;
-                                       /*  Minimum Delay in Nano secs */
-       } s_EeParameters;
-};
diff --git a/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c b/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c
deleted file mode 100644 (file)
index b731856..0000000
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- * addi_eeprom.c - ADDI EEPROM Module
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- * Project manager: Eric Stolz
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.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/delay.h>
-
-#define NVRAM_USER_DATA_START  0x100
-
-#define NVCMD_BEGIN_READ       (0x7 << 5)      /* nvRam begin read command */
-#define NVCMD_LOAD_LOW         (0x4 << 5)      /* nvRam load low command */
-#define NVCMD_LOAD_HIGH                (0x5 << 5)      /* nvRam load high command */
-
-#define EE93C76_CLK_BIT                (1 << 0)
-#define EE93C76_CS_BIT         (1 << 1)
-#define EE93C76_DOUT_BIT       (1 << 2)
-#define EE93C76_DIN_BIT                (1 << 3)
-#define EE93C76_READ_CMD       (0x0180 << 4)
-#define EE93C76_CMD_LEN                13
-
-#define EEPROM_DIGITALINPUT            0
-#define EEPROM_DIGITALOUTPUT           1
-#define EEPROM_ANALOGINPUT             2
-#define EEPROM_ANALOGOUTPUT            3
-#define EEPROM_TIMER                   4
-#define EEPROM_WATCHDOG                        5
-#define EEPROM_TIMER_WATCHDOG_COUNTER  10
-
-static void addi_eeprom_clk_93c76(unsigned long iobase, unsigned int val)
-{
-       outl(val & ~EE93C76_CLK_BIT, iobase);
-       udelay(100);
-
-       outl(val | EE93C76_CLK_BIT, iobase);
-       udelay(100);
-}
-
-static unsigned int addi_eeprom_cmd_93c76(unsigned long iobase,
-                                         unsigned int cmd,
-                                         unsigned char len)
-{
-       unsigned int val = EE93C76_CS_BIT;
-       int i;
-
-       /* Toggle EEPROM's Chip select to get it out of Shift Register Mode */
-       outl(val, iobase);
-       udelay(100);
-
-       /* Send EEPROM command - one bit at a time */
-       for (i = (len - 1); i >= 0; i--) {
-               if (cmd & (1 << i))
-                       val |= EE93C76_DOUT_BIT;
-               else
-                       val &= ~EE93C76_DOUT_BIT;
-
-               /* Write the command */
-               outl(val, iobase);
-               udelay(100);
-
-               addi_eeprom_clk_93c76(iobase, val);
-       }
-       return val;
-}
-
-static unsigned short addi_eeprom_readw_93c76(unsigned long iobase,
-                                             unsigned short addr)
-{
-       unsigned short val = 0;
-       unsigned int cmd;
-       unsigned int tmp;
-       int i;
-
-       /* Send EEPROM read command and offset to EEPROM */
-       cmd = EE93C76_READ_CMD | (addr / 2);
-       cmd = addi_eeprom_cmd_93c76(iobase, cmd, EE93C76_CMD_LEN);
-
-       /* Get the 16-bit value */
-       for (i = 0; i < 16; i++) {
-               addi_eeprom_clk_93c76(iobase, cmd);
-
-               tmp = inl(iobase);
-               udelay(100);
-
-               val <<= 1;
-               if (tmp & EE93C76_DIN_BIT)
-                       val |= 0x1;
-       }
-
-       /* Toggle EEPROM's Chip select to get it out of Shift Register Mode */
-       outl(0, iobase);
-       udelay(100);
-
-       return val;
-}
-
-static void addi_eeprom_nvram_wait(unsigned long iobase)
-{
-       unsigned char val;
-
-       do {
-               val = inb(iobase + AMCC_OP_REG_MCSR_NVCMD);
-       } while (val & 0x80);
-}
-
-static unsigned short addi_eeprom_readw_nvram(unsigned long iobase,
-                                             unsigned short addr)
-{
-       unsigned short val = 0;
-       unsigned char tmp;
-       unsigned char i;
-
-       for (i = 0; i < 2; i++) {
-               /* Load the low 8 bit address */
-               outb(NVCMD_LOAD_LOW, iobase + AMCC_OP_REG_MCSR_NVCMD);
-               addi_eeprom_nvram_wait(iobase);
-               outb((addr + i) & 0xff, iobase + AMCC_OP_REG_MCSR_NVDATA);
-               addi_eeprom_nvram_wait(iobase);
-
-               /* Load the high 8 bit address */
-               outb(NVCMD_LOAD_HIGH, iobase + AMCC_OP_REG_MCSR_NVCMD);
-               addi_eeprom_nvram_wait(iobase);
-               outb(((addr + i) >> 8) & 0xff,
-                       iobase + AMCC_OP_REG_MCSR_NVDATA);
-               addi_eeprom_nvram_wait(iobase);
-
-               /* Read the eeprom data byte */
-               outb(NVCMD_BEGIN_READ, iobase + AMCC_OP_REG_MCSR_NVCMD);
-               addi_eeprom_nvram_wait(iobase);
-               tmp = inb(iobase + AMCC_OP_REG_MCSR_NVDATA);
-               addi_eeprom_nvram_wait(iobase);
-
-               if (i == 0)
-                       val |= tmp;
-               else
-                       val |= (tmp << 8);
-       }
-
-       return val;
-}
-
-static unsigned short addi_eeprom_readw(unsigned long iobase,
-                                       char *type,
-                                       unsigned short addr)
-{
-       unsigned short val = 0;
-
-       /* Add the offset to the start of the user data */
-       addr += NVRAM_USER_DATA_START;
-
-       if (!strcmp(type, "S5920") || !strcmp(type, "S5933"))
-               val = addi_eeprom_readw_nvram(iobase, addr);
-
-       if (!strcmp(type, "93C76"))
-               val = addi_eeprom_readw_93c76(iobase, addr);
-
-       return val;
-}
-
-static void addi_eeprom_read_di_info(struct comedi_device *dev,
-                                    unsigned long iobase,
-                                    unsigned short addr)
-{
-       const struct addi_board *this_board = dev->board_ptr;
-       struct addi_private *devpriv = dev->private;
-       char *type = this_board->pc_EepromChip;
-       unsigned short tmp;
-
-       /* Number of channels */
-       tmp = addi_eeprom_readw(iobase, type, addr + 6);
-       devpriv->s_EeParameters.i_NbrDiChannel = tmp;
-
-       /* Interruptible or not */
-       tmp = addi_eeprom_readw(iobase, type, addr + 8);
-       tmp = (tmp >> 7) & 0x01;
-
-       /* How many interruptible logic */
-       tmp = addi_eeprom_readw(iobase, type, addr + 10);
-}
-
-static void addi_eeprom_read_do_info(struct comedi_device *dev,
-                                    unsigned long iobase,
-                                    unsigned short addr)
-{
-       const struct addi_board *this_board = dev->board_ptr;
-       struct addi_private *devpriv = dev->private;
-       char *type = this_board->pc_EepromChip;
-       unsigned short tmp;
-
-       /* Number of channels */
-       tmp = addi_eeprom_readw(iobase, type, addr + 6);
-       devpriv->s_EeParameters.i_NbrDoChannel = tmp;
-
-       devpriv->s_EeParameters.i_DoMaxdata = 0xffffffff >> (32 - tmp);
-}
-
-static void addi_eeprom_read_timer_info(struct comedi_device *dev,
-                                       unsigned long iobase,
-                                       unsigned short addr)
-{
-       struct addi_private *devpriv = dev->private;
-#if 0
-       const struct addi_board *this_board = dev->board_ptr;
-       char *type = this_board->pc_EepromChip;
-       unsigned short offset = 0;
-       unsigned short ntimers;
-       unsigned short tmp;
-       int i;
-
-       /* Number of Timers */
-       ntimers = addi_eeprom_readw(iobase, type, addr + 6);
-
-       /* Read header size */
-       for (i = 0; i < ntimers; i++) {
-               unsigned short size;
-               unsigned short res;
-               unsigned short mode;
-               unsigned short min_timing;
-               unsigned short timebase;
-
-               size = addi_eeprom_readw(iobase, type, addr + 8 + offset + 0);
-
-               /* Resolution / Mode */
-               tmp = addi_eeprom_readw(iobase, type, addr + 8 + offset + 2);
-               res = (tmp >> 10) & 0x3f;
-               mode = (tmp >> 4) & 0x3f;
-
-               /* MinTiming / Timebase */
-               tmp = addi_eeprom_readw(iobase, type, addr + 8 + offset + 4);
-               min_timing = (tmp  >> 6) & 0x3ff;
-               Timebase = tmp & 0x3f;
-
-               offset += size;
-       }
-#endif
-       /* Timer subdevice present */
-       devpriv->s_EeParameters.i_Timer = 1;
-}
-
-static void addi_eeprom_read_ao_info(struct comedi_device *dev,
-                                    unsigned long iobase,
-                                    unsigned short addr)
-{
-       const struct addi_board *this_board = dev->board_ptr;
-       struct addi_private *devpriv = dev->private;
-       char *type = this_board->pc_EepromChip;
-       unsigned short tmp;
-
-       /* No of channels for 1st hard component */
-       tmp = addi_eeprom_readw(iobase, type, addr + 10);
-       devpriv->s_EeParameters.i_NbrAoChannel = (tmp >> 4) & 0x3ff;
-
-       /* Resolution for 1st hard component */
-       tmp = addi_eeprom_readw(iobase, type, addr + 16);
-       tmp = (tmp >> 8) & 0xff;
-       devpriv->s_EeParameters.i_AoMaxdata = 0xfff >> (16 - tmp);
-}
-
-static void addi_eeprom_read_ai_info(struct comedi_device *dev,
-                                    unsigned long iobase,
-                                    unsigned short addr)
-{
-       const struct addi_board *this_board = dev->board_ptr;
-       struct addi_private *devpriv = dev->private;
-       char *type = this_board->pc_EepromChip;
-       unsigned short offset;
-       unsigned short tmp;
-
-       /* No of channels for 1st hard component */
-       tmp = addi_eeprom_readw(iobase, type, addr + 10);
-       devpriv->s_EeParameters.i_NbrAiChannel = (tmp >> 4) & 0x3ff;
-       if (!strcmp(this_board->pc_DriverName, "apci3200"))
-               devpriv->s_EeParameters.i_NbrAiChannel *= 4;
-
-       tmp = addi_eeprom_readw(iobase, type, addr + 16);
-       devpriv->s_EeParameters.ui_MinAcquisitiontimeNs = tmp * 1000;
-
-       tmp = addi_eeprom_readw(iobase, type, addr + 30);
-       devpriv->s_EeParameters.ui_MinDelaytimeNs = tmp * 1000;
-
-       tmp = addi_eeprom_readw(iobase, type, addr + 20);
-       /* dma = (tmp >> 13) & 0x01; */
-
-       tmp = addi_eeprom_readw(iobase, type, addr + 72) & 0xff;
-       if (tmp) {              /* > 0 */
-               /* offset of first analog input single header */
-               offset = 74 + (2 * tmp) + (10 * (1 + (tmp / 16)));
-       } else {                /* = 0 */
-               offset = 74;
-       }
-
-       /* Resolution */
-       tmp = addi_eeprom_readw(iobase, type, addr + offset + 2) & 0x1f;
-       devpriv->s_EeParameters.i_AiMaxdata = 0xffff >> (16 - tmp);
-}
-
-static void addi_eeprom_read_info(struct comedi_device *dev,
-                                 unsigned long iobase)
-{
-       const struct addi_board *this_board = dev->board_ptr;
-       char *type = this_board->pc_EepromChip;
-       unsigned short size;
-       unsigned char nfuncs;
-       int i;
-
-       size = addi_eeprom_readw(iobase, type, 8);
-       nfuncs = addi_eeprom_readw(iobase, type, 10) & 0xff;
-
-       /* Read functionality details */
-       for (i = 0; i < nfuncs; i++) {
-               unsigned short offset = i * 4;
-               unsigned short addr;
-               unsigned char func;
-
-               func = addi_eeprom_readw(iobase, type, 12 + offset) & 0x3f;
-               addr = addi_eeprom_readw(iobase, type, 14 + offset);
-
-               switch (func) {
-               case EEPROM_DIGITALINPUT:
-                       addi_eeprom_read_di_info(dev, iobase, addr);
-                       break;
-
-               case EEPROM_DIGITALOUTPUT:
-                       addi_eeprom_read_do_info(dev, iobase, addr);
-                       break;
-
-               case EEPROM_ANALOGINPUT:
-                       addi_eeprom_read_ai_info(dev, iobase, addr);
-                       break;
-
-               case EEPROM_ANALOGOUTPUT:
-                       addi_eeprom_read_ao_info(dev, iobase, addr);
-                       break;
-
-               case EEPROM_TIMER:
-               case EEPROM_WATCHDOG:
-               case EEPROM_TIMER_WATCHDOG_COUNTER:
-                       addi_eeprom_read_timer_info(dev, iobase, addr);
-                       break;
-               }
-       }
-}
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c
deleted file mode 100644 (file)
index 53bb51b..0000000
+++ /dev/null
@@ -1,480 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.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.
- */
-
-/* Card Specific information */
-#define APCI035_ADDRESS_RANGE          255
-
-/* Timer / Watchdog Related Defines */
-#define APCI035_TCW_SYNC_ENABLEDISABLE 0
-#define APCI035_TCW_RELOAD_VALUE       4
-#define APCI035_TCW_TIMEBASE           8
-#define APCI035_TCW_PROG               12
-#define APCI035_TCW_TRIG_STATUS                16
-#define APCI035_TCW_IRQ                        20
-#define APCI035_TCW_WARN_TIMEVAL       24
-#define APCI035_TCW_WARN_TIMEBASE      28
-
-#define ADDIDATA_TIMER                 0
-/* #define ADDIDATA_WATCHDOG           1 */
-
-#define APCI035_TW1                    0
-#define APCI035_TW2                    32
-#define APCI035_TW3                    64
-#define APCI035_TW4                    96
-
-#define APCI035_AI_OFFSET              0
-#define APCI035_TEMP                   128
-#define APCI035_ALR_SEQ                        4
-#define APCI035_START_STOP_INDEX       8
-#define APCI035_ALR_START_STOP         12
-#define APCI035_ALR_IRQ                        16
-#define APCI035_EOS                    20
-#define APCI035_CHAN_NO                        24
-#define APCI035_CHAN_VAL               28
-#define APCI035_CONV_TIME_TIME_BASE    36
-#define APCI035_RELOAD_CONV_TIME_VAL   32
-#define APCI035_DELAY_TIME_TIME_BASE   44
-#define APCI035_RELOAD_DELAY_TIME_VAL  40
-#define ENABLE_EXT_TRIG                        1
-#define ENABLE_EXT_GATE                        2
-#define ENABLE_EXT_TRIG_GATE           3
-
-#define ANALOG_INPUT                   0
-#define TEMPERATURE                    1
-#define RESISTANCE                     2
-
-#define ADDIDATA_GREATER_THAN_TEST     0
-#define ADDIDATA_LESS_THAN_TEST                1
-
-#define APCI035_MAXVOLT                        2.5
-
-#define ADDIDATA_UNIPOLAR              1
-#define ADDIDATA_BIPOLAR               2
-
-/* ANALOG INPUT RANGE */
-static struct comedi_lrange range_apci035_ai = {
-       8, {
-               BIP_RANGE(10),
-               BIP_RANGE(5),
-               BIP_RANGE(2),
-               BIP_RANGE(1),
-               UNI_RANGE(10),
-               UNI_RANGE(5),
-               UNI_RANGE(2),
-               UNI_RANGE(1)
-       }
-};
-
-static int i_WatchdogNbr;
-static int i_Temp;
-static int i_Flag = 1;
-
-/*
- * Configures The Timer , Counter or Watchdog
- *
- * data[0] 0 = Configure As Timer, 1 = Configure As Watchdog
- * data[1] Watchdog number
- * data[2] Time base Unit
- * data[3] Reload Value
- * data[4] External Trigger, 1 = Enable, 0 = Disable
- * data[5] External Trigger Level
- *     00 = Trigger Disabled
- *     01 = Trigger Enabled (Low level)
- *     10 = Trigger Enabled (High Level)
- *     11 = Trigger Enabled (High/Low level)
- * data[6] External Gate, 1 = Enable, 0 = Disable
- * data[7] External Gate level
- *     00 = Gate Disabled
- *     01 = Gate Enabled (Low level)
- *     10 = Gate Enabled (High Level)
- * data[8] Warning Relay, 1 = Enable, 0 = Disable
- * data[9] Warning Delay available
- * data[10] Warning Relay Time unit
- * data[11] Warning Relay Time Reload value
- * data[12] Reset Relay, 1 = Enable, 0 = Disable
- * data[13] Interrupt, 1 = Enable, 0 = Disable
- */
-static int apci035_timer_config(struct comedi_device *dev,
-                               struct comedi_subdevice *s,
-                               struct comedi_insn *insn,
-                               unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_Status;
-       unsigned int ui_Command;
-       unsigned int ui_Mode;
-
-       i_Temp = 0;
-       devpriv->tsk_Current = current;
-       devpriv->b_TimerSelectMode = data[0];
-       i_WatchdogNbr = data[1];
-       if (data[0] == 0)
-               ui_Mode = 2;
-       else
-               ui_Mode = 0;
-
-       ui_Command = 0;
-       outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
-
-       ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
-
-       /* Set the reload value */
-       outl(data[3], devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 4);
-
-       /* Set the time unit */
-       outl(data[2], devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 8);
-       if (data[0] == ADDIDATA_TIMER) {
-
-               /* Set the mode :             */
-               /* - Disable the hardware     */
-               /* - Disable the counter mode */
-               /* - Disable the warning      */
-               /* - Disable the reset        */
-               /* - Enable the timer mode    */
-               /* - Set the timer mode       */
-
-               ui_Command =
-                       (ui_Command & 0xFFF719E2UL) | ui_Mode << 13UL | 0x10UL;
-
-       } else if (data[0] == ADDIDATA_WATCHDOG) {
-
-               /* Set the mode :             */
-               /* - Disable the hardware     */
-               /* - Disable the counter mode */
-               /* - Disable the warning      */
-               /* - Disable the reset        */
-               /* - Disable the timer mode   */
-
-               ui_Command = ui_Command & 0xFFF819E2UL;
-
-       } else {
-               dev_err(dev->class_dev, "The parameter for Timer/watchdog selection is in error\n");
-               return -EINVAL;
-       }
-
-       outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
-
-       ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
-
-       /* Disable the hardware trigger */
-       ui_Command = ui_Command & 0xFFFFF89FUL;
-       if (data[4] == 1) {
-               /* Set the hardware trigger level */
-               ui_Command = ui_Command | (data[5] << 5);
-       }
-       outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
-
-       ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
-
-       /* Disable the hardware gate */
-       ui_Command = ui_Command & 0xFFFFF87FUL;
-       if (data[6] == 1) {
-               /* Set the hardware gate level */
-               ui_Command = ui_Command | (data[7] << 7);
-       }
-       outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
-
-       ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
-
-       /* Disable the hardware output */
-       ui_Command = ui_Command & 0xFFFFF9FBUL;
-
-       /* Set the hardware output level */
-       ui_Command = ui_Command | (data[8] << 2);
-       outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
-       if (data[9] == 1) {
-               /* Set the reload value */
-               outl(data[11],
-                       devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 24);
-
-               /* Set the time unite */
-               outl(data[10],
-                       devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 28);
-       }
-
-       ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
-
-       /* Disable the hardware output */
-       ui_Command = ui_Command & 0xFFFFF9F7UL;
-
-       /* Set the hardware output level */
-       ui_Command = ui_Command | (data[12] << 3);
-       outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
-
-       /* Enable the watchdog interrupt */
-       ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
-
-       /* Set the interrupt selection */
-       ui_Status = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 16);
-
-       ui_Command = (ui_Command & 0xFFFFF9FDUL) | (data[13] << 1);
-       outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
-
-       return insn->n;
-}
-
-/*
- * Start / Stop The Selected Timer , or Watchdog
- *
- * data[0]
- *     0 - Stop Selected Timer/Watchdog
- *     1 - Start Selected Timer/Watch*dog
- *     2 - Trigger Selected Timer/Watchdog
- *     3 - Stop All Timer/Watchdog
- *     4 - Start All Timer/Watchdog
- *     5 - Trigger All Timer/Watchdog
- */
-static int apci035_timer_write(struct comedi_device *dev,
-                              struct comedi_subdevice *s,
-                              struct comedi_insn *insn,
-                              unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_Command;
-       int i_Count;
-
-       if (data[0] == 1) {
-               ui_Command =
-                       inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
-
-               /* Start the hardware */
-               ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x1UL;
-               outl(ui_Command,
-                       devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
-       }
-       if (data[0] == 2) {
-               ui_Command =
-                       inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
-
-               /* Set the trigger command */
-               ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x200UL;
-               outl(ui_Command,
-                       devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
-       }
-
-       if (data[0] == 0) {
-               /* Stop The Watchdog */
-               ui_Command = 0;
-               /*
-               * ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);
-               * ui_Command = ui_Command & 0xFFFFF9FEUL;
-               */
-               outl(ui_Command,
-                       devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
-       }
-       if (data[0] == 3) {
-               /* stop all Watchdogs */
-               ui_Command = 0;
-               for (i_Count = 1; i_Count <= 4; i_Count++) {
-                       if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG)
-                               ui_Command = 0x2UL;
-                       else
-                               ui_Command = 0x10UL;
-
-                       i_WatchdogNbr = i_Count;
-                       outl(ui_Command,
-                               devpriv->iobase + ((i_WatchdogNbr - 1) * 32) +
-                               0);
-               }
-
-       }
-       if (data[0] == 4) {
-               /* start all Watchdogs */
-               ui_Command = 0;
-               for (i_Count = 1; i_Count <= 4; i_Count++) {
-                       if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG)
-                               ui_Command = 0x1UL;
-                       else
-                               ui_Command = 0x8UL;
-
-                       i_WatchdogNbr = i_Count;
-                       outl(ui_Command,
-                               devpriv->iobase + ((i_WatchdogNbr - 1) * 32) +
-                               0);
-               }
-       }
-       if (data[0] == 5) {
-               /* trigger all Watchdogs */
-               ui_Command = 0;
-               for (i_Count = 1; i_Count <= 4; i_Count++) {
-                       if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG)
-                               ui_Command = 0x4UL;
-                       else
-                               ui_Command = 0x20UL;
-
-                       i_WatchdogNbr = i_Count;
-                       outl(ui_Command,
-                               devpriv->iobase + ((i_WatchdogNbr - 1) * 32) +
-                               0);
-               }
-               i_Temp = 1;
-       }
-       return insn->n;
-}
-
-/*
- * Read The Selected Timer , Counter or Watchdog
- *
- * data[0] software trigger status
- * data[1] hardware trigger status
- * data[2] Software clear status
- * data[3] Overflow status
- * data[4] Timer actual value
- */
-static int apci035_timer_read(struct comedi_device *dev,
-                             struct comedi_subdevice *s,
-                             struct comedi_insn *insn,
-                             unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_Status; /*  Status register */
-
-       i_WatchdogNbr = insn->unused[0];
-
-       /* Get the status */
-       ui_Status = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 16);
-
-       /* Get the software trigger status */
-       data[0] = ((ui_Status >> 1) & 1);
-
-       /* Get the hardware trigger status */
-       data[1] = ((ui_Status >> 2) & 1);
-
-       /* Get the software clear status */
-       data[2] = ((ui_Status >> 3) & 1);
-
-       /* Get the overflow status */
-       data[3] = ((ui_Status >> 0) & 1);
-       if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER)
-               data[4] = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0);
-
-       return insn->n;
-}
-
-/*
- * Configures The Analog Input Subdevice
- *
- * data[0] Warning delay value
- */
-static int apci035_ai_config(struct comedi_device *dev,
-                            struct comedi_subdevice *s,
-                            struct comedi_insn *insn,
-                            unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-
-       devpriv->tsk_Current = current;
-       outl(0x200 | 0, devpriv->iobase + 128 + 0x4);
-       outl(0, devpriv->iobase + 128 + 0);
-
-       /* Initialise the warning value */
-       outl(0x300 | 0, devpriv->iobase + 128 + 0x4);
-       outl((data[0] << 8), devpriv->iobase + 128 + 0);
-       outl(0x200000UL, devpriv->iobase + 128 + 12);
-
-       return insn->n;
-}
-
-/*
- * Read value of the selected channel
- *
- * data[0] Digital Value Of Input
- */
-static int apci035_ai_read(struct comedi_device *dev,
-                          struct comedi_subdevice *s,
-                          struct comedi_insn *insn,
-                          unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_CommandRegister;
-
-       /*  Set the start */
-       ui_CommandRegister = 0x80000;
-
-       /* Write the command register */
-       outl(ui_CommandRegister, devpriv->iobase + 128 + 8);
-
-       /* Read the digital value of the input */
-       data[0] = inl(devpriv->iobase + 128 + 28);
-       return insn->n;
-}
-
-static int apci035_reset(struct comedi_device *dev)
-{
-       struct addi_private *devpriv = dev->private;
-       int i_Count;
-
-       for (i_Count = 1; i_Count <= 4; i_Count++) {
-               i_WatchdogNbr = i_Count;
-
-               /* stop all timers */
-               outl(0x0, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0);
-       }
-       outl(0x0, devpriv->iobase + 128 + 12);  /* Disable the warning delay */
-
-       return 0;
-}
-
-static void apci035_interrupt(int irq, void *d)
-{
-       struct comedi_device *dev = d;
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_StatusRegister1;
-       unsigned int ui_StatusRegister2;
-       unsigned int ui_ReadCommand;
-       unsigned int ui_ChannelNumber;
-       unsigned int ui_DigitalTemperature;
-
-       if (i_Temp == 1) {
-               i_WatchdogNbr = i_Flag;
-               i_Flag = i_Flag + 1;
-       }
-
-       /* Read the interrupt status register of temperature Warning */
-       ui_StatusRegister1 = inl(devpriv->iobase + 128 + 16);
-
-       /* Read the interrupt status register for Watchdog/timer */
-       ui_StatusRegister2 =
-               inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 20);
-
-       /* Test if warning relay interrupt */
-       if ((((ui_StatusRegister1) & 0x8) == 0x8)) {
-
-               /* Disable the temperature warning */
-               ui_ReadCommand = inl(devpriv->iobase + 128 + 12);
-               ui_ReadCommand = ui_ReadCommand & 0xFFDF0000UL;
-               outl(ui_ReadCommand, devpriv->iobase + 128 + 12);
-
-               /* Read the channel number */
-               ui_ChannelNumber = inl(devpriv->iobase + 128 + 60);
-
-               /* Read the digital temperature value */
-               ui_DigitalTemperature = inl(devpriv->iobase + 128 + 60);
-
-               /*  send signal to the sample */
-               send_sig(SIGIO, devpriv->tsk_Current, 0);
-
-       } else if ((ui_StatusRegister2 & 0x1) == 0x1) {
-               /*  send signal to the sample */
-               send_sig(SIGIO, devpriv->tsk_Current, 0);
-       }
-}
index 0ea081e..bfa9228 100644 (file)
@@ -158,7 +158,7 @@ static int apci1500_di_config(struct comedi_device *dev,
                              struct comedi_insn *insn,
                              unsigned int *data)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci1500_private *devpriv = dev->private;
        int i_PatternPolarity = 0, i_PatternTransition = 0, i_PatternMask = 0;
        int i_MaxChannel = 0, i_Count = 0, i_EventMask = 0;
        int i_PatternTransitionCount = 0, i_RegValue;
@@ -466,7 +466,7 @@ static int apci1500_di_write(struct comedi_device *dev,
                             struct comedi_insn *insn,
                             unsigned int *data)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci1500_private *devpriv = dev->private;
        int i_Event1InterruptStatus = 0, i_Event2InterruptStatus =
                0, i_RegValue;
 
@@ -653,7 +653,7 @@ static int apci1500_di_read(struct comedi_device *dev,
                            struct comedi_insn *insn,
                            unsigned int *data)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci1500_private *devpriv = dev->private;
        int i_DummyRead = 0;
 
        /* Software reset */
@@ -789,7 +789,7 @@ static int apci1500_di_insn_bits(struct comedi_device *dev,
                                 struct comedi_insn *insn,
                                 unsigned int *data)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci1500_private *devpriv = dev->private;
 
        data[1] = inw(devpriv->i_IobaseAddon + APCI1500_DIGITAL_IP);
 
@@ -807,7 +807,7 @@ static int apci1500_do_config(struct comedi_device *dev,
                              struct comedi_insn *insn,
                              unsigned int *data)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci1500_private *devpriv = dev->private;
 
        devpriv->b_OutputMemoryStatus = data[0];
        return insn->n;
@@ -821,7 +821,7 @@ static int apci1500_do_write(struct comedi_device *dev,
                             struct comedi_insn *insn,
                             unsigned int *data)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci1500_private *devpriv = dev->private;
        static unsigned int ui_Temp;
        unsigned int ui_Temp1;
        unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec);  /*  get the channel */
@@ -981,7 +981,7 @@ static int apci1500_timer_config(struct comedi_device *dev,
                                 struct comedi_insn *insn,
                                 unsigned int *data)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci1500_private *devpriv = dev->private;
        int i_TimerCounterMode, i_MasterConfiguration;
 
        devpriv->tsk_Current = current;
@@ -1471,7 +1471,7 @@ static int apci1500_timer_write(struct comedi_device *dev,
                                struct comedi_insn *insn,
                                unsigned int *data)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci1500_private *devpriv = dev->private;
        int i_CommandAndStatusValue;
 
        switch (data[0]) {
@@ -1731,7 +1731,7 @@ static int apci1500_timer_bits(struct comedi_device *dev,
                               struct comedi_insn *insn,
                               unsigned int *data)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci1500_private *devpriv = dev->private;
        int i_CommandAndStatusValue;
 
        switch (data[0]) {
@@ -1895,7 +1895,7 @@ static int apci1500_do_bits(struct comedi_device *dev,
                            struct comedi_insn *insn,
                            unsigned int *data)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci1500_private *devpriv = dev->private;
        unsigned int ui_Status;
        int i_RegValue;
        int i_Constant;
@@ -2011,11 +2011,11 @@ static int apci1500_do_bits(struct comedi_device *dev,
        return insn->n;
 }
 
-static void apci1500_interrupt(int irq, void *d)
+static irqreturn_t apci1500_interrupt(int irq, void *d)
 {
 
        struct comedi_device *dev = d;
-       struct addi_private *devpriv = dev->private;
+       struct apci1500_private *devpriv = dev->private;
        unsigned int ui_InterruptStatus = 0;
        int i_RegValue = 0;
 
@@ -2180,11 +2180,13 @@ static void apci1500_interrupt(int irq, void *d)
                        "Interrupt from unknown source\n");
 
        }
+
+       return IRQ_HANDLED;
 }
 
 static int apci1500_reset(struct comedi_device *dev)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci1500_private *devpriv = dev->private;
        int i_DummyRead = 0;
 
        i_TimerCounter1Init = 0;
index 98de969..ad9949c 100644 (file)
 #define ADDIDATA_TIMER                                 0
 #define ADDIDATA_COUNTER                               1
 #define ADDIDATA_WATCHDOG                              2
-#define APCI1564_COUNTER1                              0
-#define APCI1564_COUNTER2                              1
-#define APCI1564_COUNTER3                              2
-#define APCI1564_COUNTER4                              3
 
 /*
  * devpriv->amcc_iobase Register Map
@@ -79,6 +75,7 @@ static int apci1564_timer_config(struct comedi_device *dev,
                                 unsigned int *data)
 {
        struct apci1564_private *devpriv = dev->private;
+       unsigned int chan = CR_CHAN(insn->chanspec);
        unsigned int ul_Command1 = 0;
 
        devpriv->tsk_current = current;
@@ -97,13 +94,11 @@ static int apci1564_timer_config(struct comedi_device *dev,
                        outl(0x0, devpriv->amcc_iobase + APCI1564_DO_IRQ_REG);
                        outl(0x0, devpriv->amcc_iobase + APCI1564_WDOG_IRQ_REG);
                        outl(0x0, dev->iobase +
-                           APCI1564_COUNTER_IRQ_REG(APCI1564_COUNTER1));
+                           APCI1564_COUNTER_IRQ_REG(0));
                        outl(0x0, dev->iobase +
-                           APCI1564_COUNTER_IRQ_REG(APCI1564_COUNTER2));
+                           APCI1564_COUNTER_IRQ_REG(1));
                        outl(0x0, dev->iobase +
-                           APCI1564_COUNTER_IRQ_REG(APCI1564_COUNTER3));
-                       outl(0x0, dev->iobase +
-                           APCI1564_COUNTER_IRQ_REG(APCI1564_COUNTER4));
+                           APCI1564_COUNTER_IRQ_REG(2));
                } else {
                        /* disable Timer interrupt */
                        outl(0x0, devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG);
@@ -121,19 +116,18 @@ static int apci1564_timer_config(struct comedi_device *dev,
                outl(ul_Command1, devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG);
        } else if (data[0] == ADDIDATA_COUNTER) {
                devpriv->timer_select_mode = ADDIDATA_COUNTER;
-               devpriv->mode_select_register = data[5];
 
                /* First Stop The Counter */
                ul_Command1 = inl(dev->iobase +
-                                APCI1564_COUNTER_CTRL_REG(data[5] - 1));
+                                APCI1564_COUNTER_CTRL_REG(chan));
                ul_Command1 = ul_Command1 & 0xFFFFF9FEUL;
                /* Stop The Timer */
                outl(ul_Command1, dev->iobase +
-                                       APCI1564_COUNTER_CTRL_REG(data[5] - 1));
+                                       APCI1564_COUNTER_CTRL_REG(chan));
 
                /* Set the reload value */
                outl(data[3], dev->iobase +
-                                       APCI1564_COUNTER_RELOAD_REG(data[5] - 1));
+                                       APCI1564_COUNTER_RELOAD_REG(chan));
 
                /* Set the mode :             */
                /* - Disable the hardware     */
@@ -147,17 +141,17 @@ static int apci1564_timer_config(struct comedi_device *dev,
                        (ul_Command1 & 0xFFFC19E2UL) | 0x80000UL |
                        (unsigned int) ((unsigned int) data[4] << 16UL);
                outl(ul_Command1, dev->iobase +
-                                       APCI1564_COUNTER_CTRL_REG(data[5] - 1));
+                                       APCI1564_COUNTER_CTRL_REG(chan));
 
                /*  Enable or Disable Interrupt */
                ul_Command1 = (ul_Command1 & 0xFFFFF9FD) | (data[1] << 1);
                outl(ul_Command1, dev->iobase +
-                                       APCI1564_COUNTER_CTRL_REG(data[5] - 1));
+                                       APCI1564_COUNTER_CTRL_REG(chan));
 
                /* Set the Up/Down selection */
                ul_Command1 = (ul_Command1 & 0xFFFBF9FFUL) | (data[6] << 18);
                outl(ul_Command1, dev->iobase +
-                                       APCI1564_COUNTER_CTRL_REG(data[5] - 1));
+                                       APCI1564_COUNTER_CTRL_REG(chan));
        } else {
                dev_err(dev->class_dev, "Invalid subdevice.\n");
        }
@@ -176,6 +170,7 @@ static int apci1564_timer_write(struct comedi_device *dev,
                                unsigned int *data)
 {
        struct apci1564_private *devpriv = dev->private;
+       unsigned int chan = CR_CHAN(insn->chanspec);
        unsigned int ul_Command1 = 0;
 
        if (devpriv->timer_select_mode == ADDIDATA_TIMER) {
@@ -195,7 +190,7 @@ static int apci1564_timer_write(struct comedi_device *dev,
        } else if (devpriv->timer_select_mode == ADDIDATA_COUNTER) {
                ul_Command1 =
                        inl(dev->iobase +
-                          APCI1564_COUNTER_CTRL_REG(devpriv->mode_select_register - 1));
+                          APCI1564_COUNTER_CTRL_REG(chan));
                if (data[1] == 1) {
                        /* Start the Counter subdevice */
                        ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL;
@@ -208,7 +203,7 @@ static int apci1564_timer_write(struct comedi_device *dev,
                        ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x400;
                }
                outl(ul_Command1, dev->iobase +
-                    APCI1564_COUNTER_CTRL_REG(devpriv->mode_select_register - 1));
+                    APCI1564_COUNTER_CTRL_REG(chan));
        } else {
                dev_err(dev->class_dev, "Invalid subdevice.\n");
        }
@@ -224,6 +219,7 @@ static int apci1564_timer_read(struct comedi_device *dev,
                               unsigned int *data)
 {
        struct apci1564_private *devpriv = dev->private;
+       unsigned int chan = CR_CHAN(insn->chanspec);
        unsigned int ul_Command1 = 0;
 
        if (devpriv->timer_select_mode == ADDIDATA_TIMER) {
@@ -236,10 +232,10 @@ static int apci1564_timer_read(struct comedi_device *dev,
                /*  Read the Counter Actual Value. */
                data[0] =
                        inl(dev->iobase +
-                           APCI1564_COUNTER_REG(devpriv->mode_select_register - 1));
+                           APCI1564_COUNTER_REG(chan));
                ul_Command1 =
                        inl(dev->iobase +
-                           APCI1564_COUNTER_STATUS_REG(devpriv->mode_select_register - 1));
+                           APCI1564_COUNTER_STATUS_REG(chan));
 
                /* Get the software trigger status */
                data[1] = (unsigned char) ((ul_Command1 >> 1) & 1);
index 2950815..975ee5f 100644 (file)
@@ -40,8 +40,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
   +----------+-----------+------------------------------------------------+
 */
 
-#include <linux/delay.h>
-
 /*
  * ADDON RELATED ADDITIONS
  */
@@ -98,24 +96,12 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
 #define        APCI3120_SET4DIGITALOUTPUTON    1
 #define APCI3120_SET4DIGITALOUTPUTOFF  0
 
-/* analog output SELECT BIT */
-#define APCI3120_ANALOG_OP_CHANNEL_1   0x0000
-#define APCI3120_ANALOG_OP_CHANNEL_2   0x4000
-#define APCI3120_ANALOG_OP_CHANNEL_3   0x8000
-#define APCI3120_ANALOG_OP_CHANNEL_4   0xc000
-#define APCI3120_ANALOG_OP_CHANNEL_5   0x0000
-#define APCI3120_ANALOG_OP_CHANNEL_6   0x4000
-#define APCI3120_ANALOG_OP_CHANNEL_7   0x8000
-#define APCI3120_ANALOG_OP_CHANNEL_8   0xc000
-
 /* Enable external trigger bit in nWrAddress */
 #define APCI3120_ENABLE_EXT_TRIGGER    0x8000
 
 /* ANALOG OUTPUT AND INPUT DEFINE */
 #define APCI3120_UNIPOLAR              0x80
 #define APCI3120_BIPOLAR               0x00
-#define APCI3120_ANALOG_OUTPUT_1       0x08
-#define APCI3120_ANALOG_OUTPUT_2       0x0a
 #define APCI3120_1_GAIN                        0x00
 #define APCI3120_2_GAIN                        0x10
 #define APCI3120_5_GAIN                        0x20
@@ -200,23 +186,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
                                         APCI3120_DISABLE_TIMER1 &      \
                                         APCI3120_DISABLE_TIMER2)
 
-#define MAX_ANALOGINPUT_CHANNELS       32
-
-struct str_AnalogReadInformation {
-       /* EOC or EOS */
-       unsigned char b_Type;
-       /* Interrupt use or not */
-       unsigned char b_InterruptFlag;
-       /* Selection of the conversion time */
-       unsigned int ui_ConvertTiming;
-       /* Number of channel to read */
-       unsigned char b_NbrOfChannel;
-       /* Number of the channel to be read */
-       unsigned int ui_ChannelList[MAX_ANALOGINPUT_CHANNELS];
-       /* Gain of each channel */
-       unsigned int ui_RangeList[MAX_ANALOGINPUT_CHANNELS];
-};
-
 /* ANALOG INPUT RANGE */
 static const struct comedi_lrange range_apci3120_ai = {
        8, {
@@ -231,23 +200,12 @@ static const struct comedi_lrange range_apci3120_ai = {
        }
 };
 
-/* ANALOG OUTPUT RANGE */
-static const struct comedi_lrange range_apci3120_ao = {
-       2, {
-               BIP_RANGE(10),
-               UNI_RANGE(10)
-       }
-};
-
-
-/* FUNCTION DEFINITIONS */
 static int apci3120_ai_insn_config(struct comedi_device *dev,
                                   struct comedi_subdevice *s,
                                   struct comedi_insn *insn,
                                   unsigned int *data)
 {
-       const struct addi_board *this_board = dev->board_ptr;
-       struct addi_private *devpriv = dev->private;
+       struct apci3120_private *devpriv = dev->private;
        unsigned int i;
 
        if ((data[0] != APCI3120_EOC_MODE) && (data[0] != APCI3120_EOS_MODE))
@@ -261,8 +219,7 @@ static int apci3120_ai_insn_config(struct comedi_device *dev,
                /* Test the number of the channel */
                for (i = 0; i < data[3]; i++) {
 
-                       if (CR_CHAN(data[4 + i]) >=
-                               this_board->i_NbrAiChannel) {
+                       if (CR_CHAN(data[4 + i]) >= s->n_chan) {
                                dev_err(dev->class_dev, "bad channel list\n");
                                return -2;
                        }
@@ -302,7 +259,7 @@ static int apci3120_setup_chan_list(struct comedi_device *dev,
                                    unsigned int *chanlist,
                                    char check)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci3120_private *devpriv = dev->private;
        unsigned int i;
        unsigned int gain;
        unsigned short us_TmpValue;
@@ -351,8 +308,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
                                 struct comedi_insn *insn,
                                 unsigned int *data)
 {
-       const struct addi_board *this_board = dev->board_ptr;
-       struct addi_private *devpriv = dev->private;
+       struct apci3120_private *devpriv = dev->private;
        unsigned short us_ConvertTiming, us_TmpValue, i;
        unsigned char b_Tmp;
 
@@ -377,12 +333,11 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
                 * Testing if board have the new Quartz and calculate the time value
                 * to set in the timer
                 */
-               us_TmpValue =
-                       (unsigned short) inw(devpriv->iobase + APCI3120_RD_STATUS);
+               us_TmpValue = inw(dev->iobase + APCI3120_RD_STATUS);
 
                /* EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001 */
                if ((us_TmpValue & 0x00B0) == 0x00B0
-                       || !strcmp(this_board->pc_DriverName, "apci3001")) {
+                       || !strcmp(dev->board_name, "apci3001")) {
                        us_ConvertTiming = (us_ConvertTiming * 2) - 2;
                } else {
                        us_ConvertTiming =
@@ -398,7 +353,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
                        /*
                         * Testing the interrupt flag and set the EOC bit Clears the FIFO
                         */
-                       inw(devpriv->iobase + APCI3120_RESET_FIFO);
+                       inw(dev->iobase + APCI3120_RESET_FIFO);
 
                        /*  Initialize the sequence array */
                        if (!apci3120_setup_chan_list(dev, s, 1,
@@ -411,7 +366,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
                                b_TimerSelectMode & 0xFC) |
                                APCI3120_TIMER_0_MODE_4;
                        outb(devpriv->b_TimerSelectMode,
-                               devpriv->iobase + APCI3120_TIMER_CRT1);
+                            dev->iobase + APCI3120_TIMER_CRT1);
 
                        /*  Reset the scan bit and Disables the  EOS, DMA, EOC interrupt */
                        devpriv->b_ModeSelectRegister =
@@ -426,7 +381,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
                                        b_ModeSelectRegister &
                                        APCI3120_DISABLE_EOS_INT) |
                                        APCI3120_ENABLE_EOC_INT;
-                               inw(devpriv->iobase);
+                               inw(dev->iobase + 0);
 
                        } else {
                                devpriv->b_ModeSelectRegister =
@@ -436,7 +391,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
                        }
 
                        outb(devpriv->b_ModeSelectRegister,
-                               devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
+                            dev->iobase + APCI3120_WRITE_MODE_SELECT);
 
                        /*  Sets gate 0 */
                        devpriv->us_OutputRegister =
@@ -444,17 +399,17 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
                                us_OutputRegister & APCI3120_CLEAR_PA_PR) |
                                APCI3120_ENABLE_TIMER0;
                        outw(devpriv->us_OutputRegister,
-                               devpriv->iobase + APCI3120_WR_ADDRESS);
+                            dev->iobase + APCI3120_WR_ADDRESS);
 
                        /*  Select Timer 0 */
                        b_Tmp = ((devpriv->
                                        b_DigitalOutputRegister) & 0xF0) |
                                APCI3120_SELECT_TIMER_0_WORD;
-                       outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0);
+                       outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0);
 
                        /* Set the conversion time */
                        outw(us_ConvertTiming,
-                               devpriv->iobase + APCI3120_TIMER_VALUE);
+                            dev->iobase + APCI3120_TIMER_VALUE);
 
                        us_TmpValue =
                                (unsigned short) inw(dev->iobase + APCI3120_RD_STATUS);
@@ -463,26 +418,25 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
 
                                do {
                                        /*  Waiting for the end of conversion */
-                                       us_TmpValue =
-                                               inw(devpriv->iobase +
-                                               APCI3120_RD_STATUS);
+                                       us_TmpValue = inw(dev->iobase +
+                                                         APCI3120_RD_STATUS);
                                } while ((us_TmpValue & APCI3120_EOC) ==
                                        APCI3120_EOC);
 
                                /* Read the result in FIFO  and put it in insn data pointer */
-                               us_TmpValue = inw(devpriv->iobase + 0);
+                               us_TmpValue = inw(dev->iobase + 0);
                                *data = us_TmpValue;
 
-                               inw(devpriv->iobase + APCI3120_RESET_FIFO);
+                               inw(dev->iobase + APCI3120_RESET_FIFO);
                        }
 
                        break;
 
                case APCI3120_EOS_MODE:
 
-                       inw(devpriv->iobase);
+                       inw(dev->iobase + 0);
                        /*  Clears the FIFO */
-                       inw(devpriv->iobase + APCI3120_RESET_FIFO);
+                       inw(dev->iobase + APCI3120_RESET_FIFO);
                        /*  clear PA PR  and disable timer 0 */
 
                        devpriv->us_OutputRegister =
@@ -491,7 +445,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
                                APCI3120_DISABLE_TIMER0;
 
                        outw(devpriv->us_OutputRegister,
-                               devpriv->iobase + APCI3120_WR_ADDRESS);
+                            dev->iobase + APCI3120_WR_ADDRESS);
 
                        if (!apci3120_setup_chan_list(dev, s,
                                        devpriv->ui_AiNbrofChannels,
@@ -504,24 +458,24 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
                                b_TimerSelectMode & 0xFC) |
                                APCI3120_TIMER_0_MODE_2;
                        outb(devpriv->b_TimerSelectMode,
-                               devpriv->iobase + APCI3120_TIMER_CRT1);
+                            dev->iobase + APCI3120_TIMER_CRT1);
 
                        /* Select Timer 0 */
                        b_Tmp = ((devpriv->
                                        b_DigitalOutputRegister) & 0xF0) |
                                APCI3120_SELECT_TIMER_0_WORD;
-                       outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0);
+                       outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0);
 
                        /* Set the conversion time */
                        outw(us_ConvertTiming,
-                               devpriv->iobase + APCI3120_TIMER_VALUE);
+                            dev->iobase + APCI3120_TIMER_VALUE);
 
                        /* Set the scan bit */
                        devpriv->b_ModeSelectRegister =
                                devpriv->
                                b_ModeSelectRegister | APCI3120_ENABLE_SCAN;
                        outb(devpriv->b_ModeSelectRegister,
-                               devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
+                            dev->iobase + APCI3120_WRITE_MODE_SELECT);
 
                        /* If Interrupt function is loaded */
                        if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) {
@@ -531,7 +485,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
                                        b_ModeSelectRegister &
                                        APCI3120_DISABLE_EOC_INT) |
                                        APCI3120_ENABLE_EOS_INT;
-                               inw(devpriv->iobase);
+                               inw(dev->iobase + 0);
 
                        } else
                                devpriv->b_ModeSelectRegister =
@@ -540,34 +494,33 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
                                        APCI3120_DISABLE_ALL_INTERRUPT_WITHOUT_TIMER;
 
                        outb(devpriv->b_ModeSelectRegister,
-                               devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
+                            dev->iobase + APCI3120_WRITE_MODE_SELECT);
 
-                       inw(devpriv->iobase + APCI3120_RD_STATUS);
+                       inw(dev->iobase + APCI3120_RD_STATUS);
 
                        /* Sets gate 0 */
                        devpriv->us_OutputRegister =
                                devpriv->
                                us_OutputRegister | APCI3120_ENABLE_TIMER0;
                        outw(devpriv->us_OutputRegister,
-                               devpriv->iobase + APCI3120_WR_ADDRESS);
+                            dev->iobase + APCI3120_WR_ADDRESS);
 
                        /* Start conversion */
-                       outw(0, devpriv->iobase + APCI3120_START_CONVERSION);
+                       outw(0, dev->iobase + APCI3120_START_CONVERSION);
 
                        /* Waiting of end of conversion if interrupt is not installed */
                        if (devpriv->b_EocEosInterrupt == APCI3120_DISABLE) {
                                /* Waiting the end of conversion */
                                do {
-                                       us_TmpValue =
-                                               inw(devpriv->iobase +
-                                               APCI3120_RD_STATUS);
+                                       us_TmpValue = inw(dev->iobase +
+                                                         APCI3120_RD_STATUS);
                                } while ((us_TmpValue & APCI3120_EOS) !=
                                         APCI3120_EOS);
 
                                for (i = 0; i < devpriv->ui_AiNbrofChannels;
                                        i++) {
                                        /* Read the result in FIFO and write them in shared memory */
-                                       us_TmpValue = inw(devpriv->iobase);
+                                       us_TmpValue = inw(dev->iobase);
                                        data[i] = (unsigned int) us_TmpValue;
                                }
 
@@ -588,7 +541,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
 
 static int apci3120_reset(struct comedi_device *dev)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci3120_private *devpriv = dev->private;
        unsigned int i;
        unsigned short us_TmpValue;
 
@@ -611,22 +564,6 @@ static int apci3120_reset(struct comedi_device *dev)
        devpriv->us_OutputRegister = 0;
        outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
 
-       /*
-        * Code to set the all anolog o/p channel to 0v 8191 is decimal
-        * value for zero(0 v)volt in bipolar mode(default)
-        */
-       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_1, dev->iobase + APCI3120_ANALOG_OUTPUT_1);      /* channel 1 */
-       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_2, dev->iobase + APCI3120_ANALOG_OUTPUT_1);      /* channel 2 */
-       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_3, dev->iobase + APCI3120_ANALOG_OUTPUT_1);      /* channel 3 */
-       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_4, dev->iobase + APCI3120_ANALOG_OUTPUT_1);      /* channel 4 */
-
-       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_5, dev->iobase + APCI3120_ANALOG_OUTPUT_2);      /* channel 5 */
-       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_6, dev->iobase + APCI3120_ANALOG_OUTPUT_2);      /* channel 6 */
-       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_7, dev->iobase + APCI3120_ANALOG_OUTPUT_2);      /* channel 7 */
-       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_8, dev->iobase + APCI3120_ANALOG_OUTPUT_2);      /* channel 8 */
-
-       udelay(10);
-
        inw(dev->iobase + 0);   /* make a dummy read */
        inb(dev->iobase + APCI3120_RESET_FIFO); /*  flush FIFO */
        inw(dev->iobase + APCI3120_RD_STATUS);  /*  flush A/D status register */
@@ -641,7 +578,7 @@ static int apci3120_reset(struct comedi_device *dev)
 
 static int apci3120_exttrig_enable(struct comedi_device *dev)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci3120_private *devpriv = dev->private;
 
        devpriv->us_OutputRegister |= APCI3120_ENABLE_EXT_TRIGGER;
        outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
@@ -650,7 +587,7 @@ static int apci3120_exttrig_enable(struct comedi_device *dev)
 
 static int apci3120_exttrig_disable(struct comedi_device *dev)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci3120_private *devpriv = dev->private;
 
        devpriv->us_OutputRegister &= ~APCI3120_ENABLE_EXT_TRIGGER;
        outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
@@ -660,19 +597,19 @@ static int apci3120_exttrig_disable(struct comedi_device *dev)
 static int apci3120_cancel(struct comedi_device *dev,
                           struct comedi_subdevice *s)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci3120_private *devpriv = dev->private;
 
        /*  Disable A2P Fifo write and AMWEN signal */
-       outw(0, devpriv->i_IobaseAddon + 4);
+       outw(0, devpriv->addon + 4);
 
        /* Disable Bus Master ADD ON */
-       outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0);
-       outw(0, devpriv->i_IobaseAddon + 2);
-       outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0);
-       outw(0, devpriv->i_IobaseAddon + 2);
+       outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->addon + 0);
+       outw(0, devpriv->addon + 2);
+       outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->addon + 0);
+       outw(0, devpriv->addon + 2);
 
        /* Disable BUS Master PCI */
-       outl(0, devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR);
+       outl(0, devpriv->amcc + AMCC_OP_REG_MCSR);
 
        /* Disable ext trigger */
        apci3120_exttrig_disable(dev);
@@ -698,7 +635,7 @@ static int apci3120_cancel(struct comedi_device *dev,
        devpriv->ai_running = 0;
        devpriv->b_InterruptMode = APCI3120_EOC_MODE;
        devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
-       apci3120_reset(dev);
+
        return 0;
 }
 
@@ -781,13 +718,16 @@ static int apci3120_cyclic_ai(int mode,
                              struct comedi_device *dev,
                              struct comedi_subdevice *s)
 {
-       const struct addi_board *this_board = dev->board_ptr;
-       struct addi_private *devpriv = dev->private;
+       struct apci3120_private *devpriv = dev->private;
        struct comedi_cmd *cmd = &s->async->cmd;
        unsigned char b_Tmp;
-       unsigned int ui_Tmp, ui_DelayTiming = 0, ui_TimerValue1 = 0, dmalen0 =
-               0, dmalen1 = 0, ui_TimerValue2 =
-               0, ui_TimerValue0, ui_ConvertTiming;
+       unsigned int ui_DelayTiming = 0;
+       unsigned int ui_TimerValue1 = 0;
+       unsigned int dmalen0 = 0;
+       unsigned int dmalen1 = 0;
+       unsigned int ui_TimerValue2 = 0;
+       unsigned int ui_TimerValue0;
+       unsigned int ui_ConvertTiming;
        unsigned short us_TmpValue;
 
        /* Resets the FIFO */
@@ -802,7 +742,7 @@ static int apci3120_cyclic_ai(int mode,
 
        /* Clear Timer Write TC int */
        outl(APCI3120_CLEAR_WRITE_TC_INT,
-               devpriv->i_IobaseAmcc + APCI3120_AMCC_OP_REG_INTCSR);
+            devpriv->amcc + APCI3120_AMCC_OP_REG_INTCSR);
 
        /* Disables All Timer     */
        /* Sets PR and PA to 0    */
@@ -814,7 +754,7 @@ static int apci3120_cyclic_ai(int mode,
 
        /* Resets the FIFO */
        /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */
-       inb(devpriv->iobase + APCI3120_RESET_FIFO);
+       inb(dev->iobase + APCI3120_RESET_FIFO);
        /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
 
        devpriv->ui_AiActualScan = 0;
@@ -838,7 +778,7 @@ static int apci3120_cyclic_ai(int mode,
        /* EL241003 Begin: add this section to replace floats calculation by integer calculations */
        /* EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001 */
        if ((us_TmpValue & 0x00B0) == 0x00B0
-               || !strcmp(this_board->pc_DriverName, "apci3001")) {
+               || !strcmp(dev->board_name, "apci3001")) {
                ui_TimerValue0 = ui_ConvertTiming * 2 - 2000;
                ui_TimerValue0 = ui_TimerValue0 / 1000;
 
@@ -1007,6 +947,8 @@ static int apci3120_cyclic_ai(int mode,
                }
        } else {
                /* If DMA Enabled */
+               struct apci3120_dmabuf *dmabuf0 = &devpriv->dmabuf[0];
+               struct apci3120_dmabuf *dmabuf1 = &devpriv->dmabuf[1];
                unsigned int scan_bytes = cmd->scan_end_arg * sizeof(short);
 
                devpriv->b_InterruptMode = APCI3120_DMA_MODE;
@@ -1018,8 +960,8 @@ static int apci3120_cyclic_ai(int mode,
                outb(devpriv->b_ModeSelectRegister,
                        dev->iobase + APCI3120_WRITE_MODE_SELECT);
 
-               dmalen0 = devpriv->ui_DmaBufferSize[0];
-               dmalen1 = devpriv->ui_DmaBufferSize[1];
+               dmalen0 = dmabuf0->size;
+               dmalen1 = dmabuf1->size;
 
                if (cmd->stop_src == TRIG_COUNT) {
                        /*
@@ -1054,8 +996,8 @@ static int apci3120_cyclic_ai(int mode,
                        if (dmalen1 > s->async->prealloc_bufsz)
                                dmalen1 = s->async->prealloc_bufsz;
                }
-               devpriv->ui_DmaBufferUsesize[0] = dmalen0;
-               devpriv->ui_DmaBufferUsesize[1] = dmalen1;
+               dmabuf0->use_size = dmalen0;
+               dmabuf1->use_size = dmalen1;
 
                /* Initialize DMA */
 
@@ -1063,31 +1005,29 @@ static int apci3120_cyclic_ai(int mode,
                 * Set Transfer count enable bit and A2P_fifo reset bit in AGCSTS
                 * register 1
                 */
-               ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO;
-               outl(ui_Tmp, devpriv->i_IobaseAmcc + AMCC_OP_REG_AGCSTS);
+               outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO,
+                    devpriv->amcc + AMCC_OP_REG_AGCSTS);
 
                /*  changed  since 16 bit interface for add on */
                /* ENABLE BUS MASTER */
-               outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0);
-               outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW,
-                       devpriv->i_IobaseAddon + 2);
+               outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->addon + 0);
+               outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW, devpriv->addon + 2);
 
-               outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0);
-               outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH,
-                       devpriv->i_IobaseAddon + 2);
+               outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->addon + 0);
+               outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->addon + 2);
 
                /*
                 * TO VERIFIED BEGIN JK 07.05.04: Comparison between WIN32 and Linux
                 * driver
                 */
-               outw(0x1000, devpriv->i_IobaseAddon + 2);
+               outw(0x1000, devpriv->addon + 2);
                /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
 
                /* 2 No change */
                /* A2P FIFO MANAGEMENT */
                /* A2P fifo reset & transfer control enable */
-               outl(APCI3120_A2P_FIFO_MANAGEMENT, devpriv->i_IobaseAmcc +
-                       APCI3120_AMCC_OP_MCSR);
+               outl(APCI3120_A2P_FIFO_MANAGEMENT,
+                    devpriv->amcc + APCI3120_AMCC_OP_MCSR);
 
                /*
                 * 3
@@ -1097,14 +1037,12 @@ static int apci3120_cyclic_ai(int mode,
                 */
 
                /*  DMA Start Address Low */
-               outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0);
-               outw((devpriv->ul_DmaBufferHw[0] & 0xFFFF),
-                       devpriv->i_IobaseAddon + 2);
+               outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->addon + 0);
+               outw(dmabuf0->hw & 0xffff, devpriv->addon + 2);
 
                /* DMA Start Address High */
-               outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0);
-               outw((devpriv->ul_DmaBufferHw[0] / 65536),
-                       devpriv->i_IobaseAddon + 2);
+               outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->addon + 0);
+               outw((dmabuf0->hw >> 16) & 0xffff, devpriv->addon + 2);
 
                /*
                 * 4
@@ -1113,19 +1051,17 @@ static int apci3120_cyclic_ai(int mode,
                 */
 
                /* Nbr of acquisition LOW */
-               outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0);
-               outw((devpriv->ui_DmaBufferUsesize[0] & 0xFFFF),
-                       devpriv->i_IobaseAddon + 2);
+               outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->addon + 0);
+               outw(dmabuf0->use_size & 0xffff, devpriv->addon + 2);
 
                /* Nbr of acquisition HIGH */
-               outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0);
-               outw((devpriv->ui_DmaBufferUsesize[0] / 65536),
-                       devpriv->i_IobaseAddon + 2);
+               outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->addon + 0);
+               outw((dmabuf0->use_size >> 16) & 0xffff, devpriv->addon + 2);
 
                /*
                 * 5
                 * To configure A2P FIFO testing outl(
-                * FIFO_ADVANCE_ON_BYTE_2,devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR);
+                * FIFO_ADVANCE_ON_BYTE_2, devpriv->amcc + AMCC_OP_REG_INTCSR);
                 */
 
                /* A2P FIFO RESET */
@@ -1133,7 +1069,7 @@ static int apci3120_cyclic_ai(int mode,
                 * TO VERIFY BEGIN JK 07.05.04: Comparison between WIN32 and Linux
                 * driver
                 */
-               outl(0x04000000UL, devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR);
+               outl(0x04000000UL, devpriv->amcc + AMCC_OP_REG_MCSR);
                /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
 
                /*
@@ -1150,17 +1086,16 @@ static int apci3120_cyclic_ai(int mode,
                /* A2P FIFO CONFIGURATE, END OF DMA intERRUPT INIT */
                outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 |
                                APCI3120_ENABLE_WRITE_TC_INT),
-                       devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);
+                       devpriv->amcc + AMCC_OP_REG_INTCSR);
 
                /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */
                /* ENABLE A2P FIFO WRITE AND ENABLE AMWEN */
-               outw(3, devpriv->i_IobaseAddon + 4);
+               outw(3, devpriv->addon + 4);
                /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
 
                /* A2P FIFO RESET */
                /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */
-               outl(0x04000000UL,
-                       devpriv->i_IobaseAmcc + APCI3120_AMCC_OP_MCSR);
+               outl(0x04000000UL, devpriv->amcc + APCI3120_AMCC_OP_MCSR);
                /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
        }
 
@@ -1204,7 +1139,7 @@ static int apci3120_cyclic_ai(int mode,
 static int apci3120_ai_cmd(struct comedi_device *dev,
                           struct comedi_subdevice *s)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci3120_private *devpriv = dev->private;
        struct comedi_cmd *cmd = &s->async->cmd;
 
        /* loading private structure with cmd structure inputs */
@@ -1229,7 +1164,7 @@ static void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,
                                                  unsigned short *dma_buffer,
                                                  unsigned int num_samples)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci3120_private *devpriv = dev->private;
        struct comedi_cmd *cmd = &s->async->cmd;
 
        devpriv->ui_AiActualScan +=
@@ -1237,7 +1172,7 @@ static void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,
        s->async->cur_chan += num_samples;
        s->async->cur_chan %= cmd->scan_end_arg;
 
-       cfc_write_array_to_buffer(s, dma_buffer, num_samples * sizeof(short));
+       comedi_buf_write_samples(s, dma_buffer, num_samples);
 }
 
 /*
@@ -1249,21 +1184,19 @@ static void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,
 static void apci3120_interrupt_dma(int irq, void *d)
 {
        struct comedi_device *dev = d;
-       struct addi_private *devpriv = dev->private;
+       struct apci3120_private *devpriv = dev->private;
        struct comedi_subdevice *s = dev->read_subdev;
        struct comedi_cmd *cmd = &s->async->cmd;
-       unsigned int next_dma_buf, samplesinbuf;
-       unsigned long low_word, high_word, var;
+       struct apci3120_dmabuf *dmabuf;
+       unsigned int samplesinbuf;
        unsigned int ui_Tmp;
 
-       samplesinbuf =
-               devpriv->ui_DmaBufferUsesize[devpriv->ui_DmaActualBuffer] -
-               inl(devpriv->i_IobaseAmcc + AMCC_OP_REG_MWTC);
+       dmabuf = &devpriv->dmabuf[devpriv->ui_DmaActualBuffer];
 
-       if (samplesinbuf <
-               devpriv->ui_DmaBufferUsesize[devpriv->ui_DmaActualBuffer]) {
+       samplesinbuf = dmabuf->use_size - inl(devpriv->amcc + AMCC_OP_REG_MWTC);
+
+       if (samplesinbuf < dmabuf->use_size)
                dev_err(dev->class_dev, "Interrupted DMA transfer!\n");
-       }
        if (samplesinbuf & 1) {
                dev_err(dev->class_dev, "Odd count of bytes in DMA ring!\n");
                apci3120_cancel(dev, s);
@@ -1272,72 +1205,58 @@ static void apci3120_interrupt_dma(int irq, void *d)
        samplesinbuf = samplesinbuf >> 1;       /*  number of received samples */
        if (devpriv->b_DmaDoubleBuffer) {
                /*  switch DMA buffers if is used double buffering */
-               next_dma_buf = 1 - devpriv->ui_DmaActualBuffer;
+               struct apci3120_dmabuf *next_dmabuf;
+
+               next_dmabuf = &devpriv->dmabuf[1 - devpriv->ui_DmaActualBuffer];
 
                ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO;
-               outl(ui_Tmp, devpriv->i_IobaseAddon + AMCC_OP_REG_AGCSTS);
+               outl(ui_Tmp, devpriv->amcc + AMCC_OP_REG_AGCSTS);
 
                /*  changed  since 16 bit interface for add on */
-               outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0);
-               outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW,
-                       devpriv->i_IobaseAddon + 2);
-               outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0);
-               outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); /*  0x1000 is out putted in windows driver */
-
-               var = devpriv->ul_DmaBufferHw[next_dma_buf];
-               low_word = var & 0xffff;
-               var = devpriv->ul_DmaBufferHw[next_dma_buf];
-               high_word = var / 65536;
+               outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->addon + 0);
+               outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW, devpriv->addon + 2);
+               outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->addon + 0);
+               outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->addon + 2); /*  0x1000 is out putted in windows driver */
 
                /* DMA Start Address Low */
-               outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0);
-               outw(low_word, devpriv->i_IobaseAddon + 2);
+               outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->addon + 0);
+               outw(next_dmabuf->hw & 0xffff, devpriv->addon + 2);
 
                /* DMA Start Address High */
-               outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0);
-               outw(high_word, devpriv->i_IobaseAddon + 2);
-
-               var = devpriv->ui_DmaBufferUsesize[next_dma_buf];
-               low_word = var & 0xffff;
-               var = devpriv->ui_DmaBufferUsesize[next_dma_buf];
-               high_word = var / 65536;
+               outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->addon + 0);
+               outw((next_dmabuf->hw >> 16) & 0xffff, devpriv->addon + 2);
 
                /* Nbr of acquisition LOW */
-               outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0);
-               outw(low_word, devpriv->i_IobaseAddon + 2);
+               outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->addon + 0);
+               outw(next_dmabuf->use_size & 0xffff, devpriv->addon + 2);
 
                /* Nbr of acquisition HIGH */
-               outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0);
-               outw(high_word, devpriv->i_IobaseAddon + 2);
+               outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->addon + 0);
+               outw((next_dmabuf->use_size > 16) & 0xffff, devpriv->addon + 2);
 
                /*
                 * To configure A2P FIFO
                 * ENABLE A2P FIFO WRITE AND ENABLE AMWEN
                 * AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03
                 */
-               outw(3, devpriv->i_IobaseAddon + 4);
+               outw(3, devpriv->addon + 4);
                /* initialise end of dma interrupt  AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) */
-               outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 |
-                               APCI3120_ENABLE_WRITE_TC_INT),
-                       devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);
+               outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 |
+                    APCI3120_ENABLE_WRITE_TC_INT,
+                    devpriv->amcc + AMCC_OP_REG_INTCSR);
 
        }
        if (samplesinbuf) {
-               v_APCI3120_InterruptDmaMoveBlock16bit(dev, s,
-                       devpriv->ul_DmaBufferVirtual[devpriv->
-                               ui_DmaActualBuffer], samplesinbuf);
+               v_APCI3120_InterruptDmaMoveBlock16bit(dev, s, dmabuf->virt,
+                                                     samplesinbuf);
 
-               if (!(cmd->flags & CMDF_WAKE_EOS)) {
+               if (!(cmd->flags & CMDF_WAKE_EOS))
                        s->async->events |= COMEDI_CB_EOS;
-                       comedi_event(dev, s);
-               }
        }
        if (cmd->stop_src == TRIG_COUNT)
                if (devpriv->ui_AiActualScan >= cmd->stop_arg) {
                        /*  all data sampled */
-                       apci3120_cancel(dev, s);
                        s->async->events |= COMEDI_CB_EOA;
-                       comedi_event(dev, s);
                        return;
                }
 
@@ -1348,50 +1267,41 @@ static void apci3120_interrupt_dma(int irq, void *d)
                 * restart DMA if is not used double buffering
                 * ADDED REINITIALISE THE DMA
                 */
-               ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO;
-               outl(ui_Tmp, devpriv->i_IobaseAddon + AMCC_OP_REG_AGCSTS);
+               outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO,
+                    devpriv->amcc + AMCC_OP_REG_AGCSTS);
 
                /*  changed  since 16 bit interface for add on */
-               outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0);
-               outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW,
-                       devpriv->i_IobaseAddon + 2);
-               outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0);
-               outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2);
+               outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->addon + 0);
+               outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW, devpriv->addon + 2);
+               outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->addon + 0);
+               outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->addon + 2);
                /*
                 * A2P FIFO MANAGEMENT
                 * A2P fifo reset & transfer control enable
                 */
                outl(APCI3120_A2P_FIFO_MANAGEMENT,
-                       devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR);
-
-               var = devpriv->ul_DmaBufferHw[0];
-               low_word = var & 0xffff;
-               var = devpriv->ul_DmaBufferHw[0];
-               high_word = var / 65536;
-               outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0);
-               outw(low_word, devpriv->i_IobaseAddon + 2);
-               outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0);
-               outw(high_word, devpriv->i_IobaseAddon + 2);
-
-               var = devpriv->ui_DmaBufferUsesize[0];
-               low_word = var & 0xffff;        /* changed */
-               var = devpriv->ui_DmaBufferUsesize[0];
-               high_word = var / 65536;
-               outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0);
-               outw(low_word, devpriv->i_IobaseAddon + 2);
-               outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0);
-               outw(high_word, devpriv->i_IobaseAddon + 2);
+                    devpriv->amcc + AMCC_OP_REG_MCSR);
+
+               outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->addon + 0);
+               outw(dmabuf->hw & 0xffff, devpriv->addon + 2);
+               outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->addon + 0);
+               outw((dmabuf->hw >> 16) & 0xffff, devpriv->addon + 2);
+
+               outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->addon + 0);
+               outw(dmabuf->use_size & 0xffff, devpriv->addon + 2);
+               outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->addon + 0);
+               outw((dmabuf->use_size >> 16) & 0xffff, devpriv->addon + 2);
 
                /*
                 * To configure A2P FIFO
                 * ENABLE A2P FIFO WRITE AND ENABLE AMWEN
                 * AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03
                 */
-               outw(3, devpriv->i_IobaseAddon + 4);
+               outw(3, devpriv->addon + 4);
                /* initialise end of dma interrupt  AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) */
-               outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 |
-                               APCI3120_ENABLE_WRITE_TC_INT),
-                       devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);
+               outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 |
+                    APCI3120_ENABLE_WRITE_TC_INT,
+                    devpriv->amcc + AMCC_OP_REG_INTCSR);
        }
 }
 
@@ -1401,30 +1311,23 @@ static void apci3120_interrupt_dma(int irq, void *d)
  */
 static int apci3120_interrupt_handle_eos(struct comedi_device *dev)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci3120_private *devpriv = dev->private;
        struct comedi_subdevice *s = dev->read_subdev;
-       int n_chan, i;
-       int err = 1;
+       unsigned short val;
+       int i;
 
-       n_chan = devpriv->ui_AiNbrofChannels;
-
-       for (i = 0; i < n_chan; i++)
-               err &= comedi_buf_put(s, inw(dev->iobase + 0));
-
-       s->async->events |= COMEDI_CB_EOS;
-
-       if (err == 0)
-               s->async->events |= COMEDI_CB_OVERFLOW;
-
-       comedi_event(dev, s);
+       for (i = 0; i < devpriv->ui_AiNbrofChannels; i++) {
+               val = inw(dev->iobase + 0);
+               comedi_buf_write_samples(s, &val, 1);
+       }
 
        return 0;
 }
 
-static void apci3120_interrupt(int irq, void *d)
+static irqreturn_t apci3120_interrupt(int irq, void *d)
 {
        struct comedi_device *dev = d;
-       struct addi_private *devpriv = dev->private;
+       struct apci3120_private *devpriv = dev->private;
        struct comedi_subdevice *s = dev->read_subdev;
        unsigned short int_daq;
        unsigned int int_amcc, ui_Check, i;
@@ -1434,14 +1337,14 @@ static void apci3120_interrupt(int irq, void *d)
        ui_Check = 1;
 
        int_daq = inw(dev->iobase + APCI3120_RD_STATUS) & 0xf000;       /*  get IRQ reasons */
-       int_amcc = inl(devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);     /*  get AMCC int register */
+       int_amcc = inl(devpriv->amcc + AMCC_OP_REG_INTCSR);
 
        if ((!int_daq) && (!(int_amcc & ANY_S593X_INT))) {
                dev_err(dev->class_dev, "IRQ from unknown source\n");
-               return;
+               return IRQ_NONE;
        }
 
-       outl(int_amcc | 0x00ff0000, devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);        /*  shutdown IRQ reasons in AMCC */
+       outl(int_amcc | 0x00ff0000, devpriv->amcc + AMCC_OP_REG_INTCSR);
 
        int_daq = (int_daq >> 12) & 0xF;
 
@@ -1451,7 +1354,7 @@ static void apci3120_interrupt(int irq, void *d)
                devpriv->b_ExttrigEnable = APCI3120_DISABLE;
        }
        /* clear the timer 2 interrupt */
-       inb(devpriv->i_IobaseAmcc + APCI3120_TIMER_STATUS_REGISTER);
+       inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER);
 
        if (int_amcc & MASTER_ABORT_INT)
                dev_err(dev->class_dev, "AMCC IRQ - MASTER DMA ABORT!\n");
@@ -1464,8 +1367,7 @@ static void apci3120_interrupt(int irq, void *d)
                if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) {
 
                        /*  Read the AI Value */
-                       devpriv->ui_AiReadData[0] =
-                               (unsigned int) inw(devpriv->iobase + 0);
+                       devpriv->ui_AiReadData[0] = inw(dev->iobase + 0);
                        devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
                        send_sig(SIGIO, devpriv->tsk_Current, 0);       /*  send signal to the sample */
                } else {
@@ -1474,8 +1376,7 @@ static void apci3120_interrupt(int irq, void *d)
                                devpriv->
                                b_ModeSelectRegister & APCI3120_DISABLE_EOC_INT;
                        outb(devpriv->b_ModeSelectRegister,
-                               devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
-
+                            dev->iobase + APCI3120_WRITE_MODE_SELECT);
                }
        }
 
@@ -1499,7 +1400,7 @@ static void apci3120_interrupt(int irq, void *d)
                                ui_Check = 0;
                                for (i = 0; i < devpriv->ui_AiNbrofChannels;
                                        i++) {
-                                       us_TmpValue = inw(devpriv->iobase + 0);
+                                       us_TmpValue = inw(dev->iobase + 0);
                                        devpriv->ui_AiReadData[i] =
                                                (unsigned int) us_TmpValue;
                                }
@@ -1539,13 +1440,7 @@ static void apci3120_interrupt(int irq, void *d)
                        outw(devpriv->us_OutputRegister,
                                dev->iobase + APCI3120_WR_ADDRESS);
 
-                       /* stop timer 0 and timer 1 */
-                       apci3120_cancel(dev, s);
-
-                       /* UPDATE-0.7.57->0.7.68comedi_done(dev,s); */
                        s->async->events |= COMEDI_CB_EOA;
-                       comedi_event(dev, s);
-
                        break;
 
                case APCI3120_TIMER:
@@ -1582,8 +1477,7 @@ static void apci3120_interrupt(int irq, void *d)
 
                        /* Clear Timer Write TC int */
                        outl(APCI3120_CLEAR_WRITE_TC_INT,
-                               devpriv->i_IobaseAmcc +
-                               APCI3120_AMCC_OP_REG_INTCSR);
+                            devpriv->amcc + APCI3120_AMCC_OP_REG_INTCSR);
 
                        /* Clears the timer status register */
                        inw(dev->iobase + APCI3120_TIMER_STATUS_REGISTER);
@@ -1598,6 +1492,9 @@ static void apci3120_interrupt(int irq, void *d)
                }
 
        }
+       comedi_handle_events(dev, s);
+
+       return IRQ_HANDLED;
 }
 
 /*
@@ -1613,8 +1510,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev,
                                      struct comedi_insn *insn,
                                      unsigned int *data)
 {
-       const struct addi_board *this_board = dev->board_ptr;
-       struct addi_private *devpriv = dev->private;
+       struct apci3120_private *devpriv = dev->private;
        unsigned int ui_Timervalue2;
        unsigned short us_TmpValue;
        unsigned char b_Tmp;
@@ -1626,14 +1522,14 @@ static int apci3120_config_insn_timer(struct comedi_device *dev,
 
        ui_Timervalue2 = data[1] / 1000;        /*  convert nano seconds  to u seconds */
 
-       us_TmpValue = (unsigned short) inw(devpriv->iobase + APCI3120_RD_STATUS);
+       us_TmpValue = inw(dev->iobase + APCI3120_RD_STATUS);
 
        /*
         * EL250804: Testing if board APCI3120 have the new Quartz or if it
         * is an APCI3001 and calculate the time value to set in the timer
         */
        if ((us_TmpValue & 0x00B0) == 0x00B0
-               || !strcmp(this_board->pc_DriverName, "apci3001")) {
+               || !strcmp(dev->board_name, "apci3001")) {
                /* Calculate the time value to set in the timer */
                ui_Timervalue2 = ui_Timervalue2 / 50;
        } else {
@@ -1644,7 +1540,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev,
        /* Reset gate 2 of Timer 2 to disable it (Set Bit D14 to 0) */
        devpriv->us_OutputRegister =
                devpriv->us_OutputRegister & APCI3120_DISABLE_TIMER2;
-       outw(devpriv->us_OutputRegister, devpriv->iobase + APCI3120_WR_ADDRESS);
+       outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
 
        /*  Disable TIMER Interrupt */
        devpriv->b_ModeSelectRegister =
@@ -1657,14 +1553,14 @@ static int apci3120_config_insn_timer(struct comedi_device *dev,
                b_ModeSelectRegister & APCI3120_DISABLE_EOC_INT &
                APCI3120_DISABLE_EOS_INT;
        outb(devpriv->b_ModeSelectRegister,
-               devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
+            dev->iobase + APCI3120_WRITE_MODE_SELECT);
        if (data[0] == APCI3120_TIMER) {        /* initialize timer */
                /* Set the Timer 2 in mode 2(Timer) */
                devpriv->b_TimerSelectMode =
                        (devpriv->
                        b_TimerSelectMode & 0x0F) | APCI3120_TIMER_2_MODE_2;
                outb(devpriv->b_TimerSelectMode,
-                       devpriv->iobase + APCI3120_TIMER_CRT1);
+                    dev->iobase + APCI3120_TIMER_CRT1);
 
                /*
                 * Configure the timer 2 for writing the LOW unsigned short of timer
@@ -1678,17 +1574,17 @@ static int apci3120_config_insn_timer(struct comedi_device *dev,
                b_Tmp = ((devpriv->
                                b_DigitalOutputRegister) & 0xF0) |
                        APCI3120_SELECT_TIMER_2_LOW_WORD;
-               outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0);
+               outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0);
                outw(ui_Timervalue2 & 0xffff,
-                       devpriv->iobase + APCI3120_TIMER_VALUE);
+                    dev->iobase + APCI3120_TIMER_VALUE);
 
                /* Writing HIGH unsigned short */
                b_Tmp = ((devpriv->
                                b_DigitalOutputRegister) & 0xF0) |
                        APCI3120_SELECT_TIMER_2_HIGH_WORD;
-               outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0);
+               outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0);
                outw((ui_Timervalue2 >> 16) & 0xffff,
-                       devpriv->iobase + APCI3120_TIMER_VALUE);
+                    dev->iobase + APCI3120_TIMER_VALUE);
                /*  timer2 in Timer mode enabled */
                devpriv->b_Timer2Mode = APCI3120_TIMER;
 
@@ -1699,7 +1595,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev,
                        (devpriv->
                        b_TimerSelectMode & 0x0F) | APCI3120_TIMER_2_MODE_5;
                outb(devpriv->b_TimerSelectMode,
-                       devpriv->iobase + APCI3120_TIMER_CRT1);
+                    dev->iobase + APCI3120_TIMER_CRT1);
 
                /*
                 * Configure the timer 2 for writing the LOW unsigned short of timer
@@ -1713,18 +1609,18 @@ static int apci3120_config_insn_timer(struct comedi_device *dev,
                b_Tmp = ((devpriv->
                                b_DigitalOutputRegister) & 0xF0) |
                        APCI3120_SELECT_TIMER_2_LOW_WORD;
-               outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0);
+               outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0);
                outw(ui_Timervalue2 & 0xffff,
-                       devpriv->iobase + APCI3120_TIMER_VALUE);
+                    dev->iobase + APCI3120_TIMER_VALUE);
 
                /* Writing HIGH unsigned short */
                b_Tmp = ((devpriv->
                                b_DigitalOutputRegister) & 0xF0) |
                        APCI3120_SELECT_TIMER_2_HIGH_WORD;
-               outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0);
+               outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0);
 
                outw((ui_Timervalue2 >> 16) & 0xffff,
-                       devpriv->iobase + APCI3120_TIMER_VALUE);
+                    dev->iobase + APCI3120_TIMER_VALUE);
                /* watchdog enabled */
                devpriv->b_Timer2Mode = APCI3120_WATCHDOG;
 
@@ -1751,8 +1647,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev,
                                     struct comedi_insn *insn,
                                     unsigned int *data)
 {
-       const struct addi_board *this_board = dev->board_ptr;
-       struct addi_private *devpriv = dev->private;
+       struct apci3120_private *devpriv = dev->private;
        unsigned int ui_Timervalue2 = 0;
        unsigned short us_TmpValue;
        unsigned char b_Tmp;
@@ -1780,7 +1675,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev,
        case APCI3120_START:
 
                /*  Reset FC_TIMER BIT */
-               inb(devpriv->iobase + APCI3120_TIMER_STATUS_REGISTER);
+               inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER);
                if (devpriv->b_Timer2Mode == APCI3120_TIMER) {  /* start timer */
                        /* Enable Timer */
                        devpriv->b_ModeSelectRegister =
@@ -1810,7 +1705,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev,
                                APCI3120_DISABLE_TIMER_INT;
                }
                outb(devpriv->b_ModeSelectRegister,
-                       devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
+                    dev->iobase + APCI3120_WRITE_MODE_SELECT);
 
                if (devpriv->b_Timer2Mode == APCI3120_TIMER) {  /* start timer */
                        /* For Timer mode is  Gate2 must be activated   timer started */
@@ -1818,7 +1713,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev,
                                devpriv->
                                us_OutputRegister | APCI3120_ENABLE_TIMER2;
                        outw(devpriv->us_OutputRegister,
-                               devpriv->iobase + APCI3120_WR_ADDRESS);
+                            dev->iobase + APCI3120_WR_ADDRESS);
                }
 
                break;
@@ -1844,16 +1739,16 @@ static int apci3120_write_insn_timer(struct comedi_device *dev,
 
                /*  Write above states  to register */
                outb(devpriv->b_ModeSelectRegister,
-                       devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
+                    dev->iobase + APCI3120_WRITE_MODE_SELECT);
 
                /*  Reset Gate 2 */
                devpriv->us_OutputRegister =
                        devpriv->us_OutputRegister & APCI3120_DISABLE_TIMER_INT;
                outw(devpriv->us_OutputRegister,
-                       devpriv->iobase + APCI3120_WR_ADDRESS);
+                    dev->iobase + APCI3120_WR_ADDRESS);
 
                /*  Reset FC_TIMER BIT */
-               inb(devpriv->iobase + APCI3120_TIMER_STATUS_REGISTER);
+               inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER);
 
                break;
 
@@ -1863,15 +1758,14 @@ static int apci3120_write_insn_timer(struct comedi_device *dev,
                                "timer2 not configured in TIMER MODE\n");
                        return -EINVAL;
                }
-               us_TmpValue =
-                       (unsigned short) inw(devpriv->iobase + APCI3120_RD_STATUS);
+               us_TmpValue = inw(dev->iobase + APCI3120_RD_STATUS);
 
                /*
                 * EL250804: Testing if board APCI3120 have the new Quartz or if it
                 * is an APCI3001 and calculate the time value to set in the timer
                 */
                if ((us_TmpValue & 0x00B0) == 0x00B0
-                       || !strcmp(this_board->pc_DriverName, "apci3001")) {
+                       || !strcmp(dev->board_name, "apci3001")) {
                        /* Calculate the time value to set in the timer */
                        ui_Timervalue2 = ui_Timervalue2 / 50;
                } else {
@@ -1882,19 +1776,19 @@ static int apci3120_write_insn_timer(struct comedi_device *dev,
                b_Tmp = ((devpriv->
                                b_DigitalOutputRegister) & 0xF0) |
                        APCI3120_SELECT_TIMER_2_LOW_WORD;
-               outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0);
+               outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0);
 
                outw(ui_Timervalue2 & 0xffff,
-                       devpriv->iobase + APCI3120_TIMER_VALUE);
+                    dev->iobase + APCI3120_TIMER_VALUE);
 
                /* Writing HIGH unsigned short */
                b_Tmp = ((devpriv->
                                b_DigitalOutputRegister) & 0xF0) |
                        APCI3120_SELECT_TIMER_2_HIGH_WORD;
-               outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0);
+               outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0);
 
                outw((ui_Timervalue2 >> 16) & 0xffff,
-                       devpriv->iobase + APCI3120_TIMER_VALUE);
+                    dev->iobase + APCI3120_TIMER_VALUE);
 
                break;
        default:
@@ -1917,7 +1811,7 @@ static int apci3120_read_insn_timer(struct comedi_device *dev,
                                    struct comedi_insn *insn,
                                    unsigned int *data)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci3120_private *devpriv = dev->private;
        unsigned char b_Tmp;
        unsigned short us_TmpValue, us_TmpValue_2, us_StatusValue;
 
@@ -1931,29 +1825,29 @@ static int apci3120_read_insn_timer(struct comedi_device *dev,
                b_Tmp = ((devpriv->
                                b_DigitalOutputRegister) & 0xF0) |
                        APCI3120_SELECT_TIMER_2_LOW_WORD;
-               outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0);
+               outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0);
 
-               us_TmpValue = inw(devpriv->iobase + APCI3120_TIMER_VALUE);
+               us_TmpValue = inw(dev->iobase + APCI3120_TIMER_VALUE);
 
                /* Read the HIGH unsigned short of Timer 2 register */
                b_Tmp = ((devpriv->
                                b_DigitalOutputRegister) & 0xF0) |
                        APCI3120_SELECT_TIMER_2_HIGH_WORD;
-               outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0);
+               outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0);
 
-               us_TmpValue_2 = inw(devpriv->iobase + APCI3120_TIMER_VALUE);
+               us_TmpValue_2 = inw(dev->iobase + APCI3120_TIMER_VALUE);
 
                /*  combining both words */
                data[0] = (unsigned int) ((us_TmpValue) | ((us_TmpValue_2) << 16));
 
        } else {                        /*  Read watch dog status */
 
-               us_StatusValue = inw(devpriv->iobase + APCI3120_RD_STATUS);
+               us_StatusValue = inw(dev->iobase + APCI3120_RD_STATUS);
                us_StatusValue =
                        ((us_StatusValue & APCI3120_FC_TIMER) >> 12) & 1;
                if (us_StatusValue == 1) {
                        /*  RESET FC_TIMER BIT */
-                       inb(devpriv->iobase + APCI3120_TIMER_STATUS_REGISTER);
+                       inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER);
                }
                data[0] = us_StatusValue;       /*  when data[0] = 1 then the watch dog has rundown */
        }
@@ -1965,11 +1859,10 @@ static int apci3120_di_insn_bits(struct comedi_device *dev,
                                 struct comedi_insn *insn,
                                 unsigned int *data)
 {
-       struct addi_private *devpriv = dev->private;
        unsigned int val;
 
        /* the input channels are bits 11:8 of the status reg */
-       val = inw(devpriv->iobase + APCI3120_RD_STATUS);
+       val = inw(dev->iobase + APCI3120_RD_STATUS);
        data[1] = (val >> 8) & 0xf;
 
        return insn->n;
@@ -1980,14 +1873,14 @@ static int apci3120_do_insn_bits(struct comedi_device *dev,
                                 struct comedi_insn *insn,
                                 unsigned int *data)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci3120_private *devpriv = dev->private;
 
        if (comedi_dio_update_state(s, data)) {
                /* The do channels are bits 7:4 of the do register */
                devpriv->b_DigitalOutputRegister = s->state << 4;
 
                outb(devpriv->b_DigitalOutputRegister,
-                    devpriv->iobase + APCI3120_DIGITAL_OUTPUT);
+                    dev->iobase + APCI3120_DIGITAL_OUTPUT);
        }
 
        data[1] = s->state;
@@ -1995,56 +1888,40 @@ static int apci3120_do_insn_bits(struct comedi_device *dev,
        return insn->n;
 }
 
+static int apci3120_ao_ready(struct comedi_device *dev,
+                            struct comedi_subdevice *s,
+                            struct comedi_insn *insn,
+                            unsigned long context)
+{
+       unsigned int status;
+
+       status = inw(dev->iobase + APCI3120_RD_STATUS);
+       if (status & 0x0001)    /* waiting for DA_READY */
+               return 0;
+       return -EBUSY;
+}
+
 static int apci3120_ao_insn_write(struct comedi_device *dev,
                                  struct comedi_subdevice *s,
                                  struct comedi_insn *insn,
                                  unsigned int *data)
 {
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_Range, ui_Channel;
-       unsigned short us_TmpValue;
+       unsigned int chan = CR_CHAN(insn->chanspec);
+       int i;
 
-       ui_Range = CR_RANGE(insn->chanspec);
-       ui_Channel = CR_CHAN(insn->chanspec);
+       for (i = 0; i < insn->n; i++) {
+               unsigned int val = data[i];
+               int ret;
 
-       if (ui_Range) {         /*  if 1 then unipolar */
+               ret = comedi_timeout(dev, s, insn, apci3120_ao_ready, 0);
+               if (ret)
+                       return ret;
 
-               if (data[0] != 0)
-                       data[0] =
-                               ((((ui_Channel & 0x03) << 14) & 0xC000) | (1 <<
-                                       13) | (data[0] + 8191));
-               else
-                       data[0] =
-                               ((((ui_Channel & 0x03) << 14) & 0xC000) | (1 <<
-                                       13) | 8192);
-
-       } else {                        /*  if 0 then   bipolar */
-               data[0] =
-                       ((((ui_Channel & 0x03) << 14) & 0xC000) | (0 << 13) |
-                       data[0]);
+               outw(APCI3120_AO_MUX(chan) | APCI3120_AO_DATA(val),
+                    dev->iobase + APCI3120_AO_REG(chan));
 
+               s->readback[chan] = val;
        }
 
-       do {                    /* Waiting of DA_READY BIT */
-               us_TmpValue =
-                       ((unsigned short) inw(devpriv->iobase +
-                               APCI3120_RD_STATUS)) & 0x0001;
-       } while (us_TmpValue != 0x0001);
-
-       if (ui_Channel <= 3)
-               /*
-                * for channel 0-3 out at the register 1 (wrDac1-8) data[i]
-                * typecasted to ushort since word write is to be done
-                */
-               outw((unsigned short) data[0],
-                       devpriv->iobase + APCI3120_ANALOG_OUTPUT_1);
-       else
-               /*
-                * for channel 4-7 out at the register 2 (wrDac5-8) data[i]
-                * typecasted to ushort since word write is to be done
-                */
-               outw((unsigned short) data[0],
-                       devpriv->iobase + APCI3120_ANALOG_OUTPUT_2);
-
        return insn->n;
 }
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
deleted file mode 100644 (file)
index 5e321f9..0000000
+++ /dev/null
@@ -1,3003 +0,0 @@
-/**
-@verbatim
-
-Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
-
-       ADDI-DATA GmbH
-       Dieselstrasse 3
-       D-77833 Ottersweier
-       Tel: +19(0)7223/9493-0
-       Fax: +49(0)7223/9493-92
-       http://www.addi-data.com
-       info@addi-data.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.
-
-@endverbatim
-*/
-/*
-
-  +-----------------------------------------------------------------------+
-  | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |
-  +-----------------------------------------------------------------------+
-  | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |
-  | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |
-  +-------------------------------+---------------------------------------+
-  | Project     : APCI-3200       | Compiler   : GCC                      |
-  | Module name : hwdrv_apci3200.c| Version    : 2.96                     |
-  +-------------------------------+---------------------------------------+
-  | Project manager: Eric Stolz   | Date       :  02/12/2002              |
-  +-------------------------------+---------------------------------------+
-  | Description :   Hardware Layer Access For APCI-3200                   |
-  +-----------------------------------------------------------------------+
-  |                             UPDATES                                   |
-  +----------+-----------+------------------------------------------------+
-  |   Date   |   Author  |          Description of updates                |
-  +----------+-----------+------------------------------------------------+
-  | 02.07.04 | J. Krauth | Modification from the driver in order to       |
-  |          |           | correct some errors when using several boards. |
-  |          |           |                                                |
-  |          |           |                                                |
-  +----------+-----------+------------------------------------------------+
-  | 26.10.04 | J. Krauth | - Update for COMEDI 0.7.68                     |
-  |          |           | - Read eeprom value                            |
-  |          |           | - Append APCI-3300                             |
-  +----------+-----------+------------------------------------------------+
-*/
-
-/* Card Specific information */
-/* #define APCI3200_ADDRESS_RANGE      264 */
-
-/* Analog Input related Defines */
-#define APCI3200_AI_OFFSET_GAIN                0
-#define APCI3200_AI_SC_TEST            4
-#define APCI3200_AI_IRQ                        8
-#define APCI3200_AI_AUTOCAL            12
-#define APCI3200_RELOAD_CONV_TIME_VAL  32
-#define APCI3200_CONV_TIME_TIME_BASE   36
-#define APCI3200_RELOAD_DELAY_TIME_VAL 40
-#define APCI3200_DELAY_TIME_TIME_BASE  44
-#define APCI3200_AI_MODULE1            0
-#define APCI3200_AI_MODULE2            64
-#define APCI3200_AI_MODULE3            128
-#define APCI3200_AI_MODULE4            192
-#define TRUE                           1
-#define FALSE                          0
-#define APCI3200_AI_EOSIRQ             16
-#define APCI3200_AI_EOS                        20
-#define APCI3200_AI_CHAN_ID            24
-#define APCI3200_AI_CHAN_VAL           28
-#define ANALOG_INPUT                   0
-#define TEMPERATURE                    1
-#define RESISTANCE                     2
-
-#define ENABLE_EXT_TRIG                        1
-#define ENABLE_EXT_GATE                        2
-#define ENABLE_EXT_TRIG_GATE           3
-
-#define APCI3200_MAXVOLT               2.5
-#define ADDIDATA_GREATER_THAN_TEST     0
-#define ADDIDATA_LESS_THAN_TEST                1
-
-#define ADDIDATA_UNIPOLAR              1
-#define ADDIDATA_BIPOLAR               2
-
-#define MAX_MODULE                     4
-
-/* ANALOG INPUT RANGE */
-static const struct comedi_lrange range_apci3200_ai = {
-       8, {
-               BIP_RANGE(10),
-               BIP_RANGE(5),
-               BIP_RANGE(2),
-               BIP_RANGE(1),
-               UNI_RANGE(10),
-               UNI_RANGE(5),
-               UNI_RANGE(2),
-               UNI_RANGE(1)
-       }
-};
-
-static const struct comedi_lrange range_apci3300_ai = {
-       4, {
-               UNI_RANGE(10),
-               UNI_RANGE(5),
-               UNI_RANGE(2),
-               UNI_RANGE(1)
-       }
-};
-
-int MODULE_NO;
-struct {
-       int i_Gain;
-       int i_Polarity;
-       int i_OffsetRange;
-       int i_Coupling;
-       int i_SingleDiff;
-       int i_AutoCalibration;
-       unsigned int ui_ReloadValue;
-       unsigned int ui_TimeUnitReloadVal;
-       int i_Interrupt;
-       int i_ModuleSelection;
-} Config_Parameters_Module1, Config_Parameters_Module2,
-    Config_Parameters_Module3, Config_Parameters_Module4;
-
-
-struct str_ADDIDATA_RTDStruct {
-       unsigned int ul_NumberOfValue;
-       unsigned int *pul_ResistanceValue;
-       unsigned int *pul_TemperatureValue;
-};
-
-struct str_Module {
-       unsigned long ul_CurrentSourceCJC;
-       unsigned long ul_CurrentSource[5];
-       unsigned long ul_GainFactor[8]; /*  Gain Factor */
-       unsigned int w_GainValue[10];
-};
-
-struct str_BoardInfos {
-
-       int i_CJCAvailable;
-       int i_CJCPolarity;
-       int i_CJCGain;
-       int i_InterruptFlag;
-       int i_ADDIDATAPolarity;
-       int i_ADDIDATAGain;
-       int i_AutoCalibration;
-       int i_ADDIDATAConversionTime;
-       int i_ADDIDATAConversionTimeUnit;
-       int i_ADDIDATAType;
-       int i_ChannelNo;
-       int i_ChannelCount;
-       int i_ScanType;
-       int i_FirstChannel;
-       int i_LastChannel;
-       int i_Sum;
-       int i_Offset;
-       unsigned int ui_Channel_num;
-       int i_Count;
-       int i_Initialised;
-       unsigned int ui_InterruptChannelValue[144];     /* Buffer */
-       unsigned char b_StructInitialized;
-       /* 7 is the maximal number of channels */
-       unsigned int ui_ScanValueArray[7 + 12]; 
-
-       int i_ConnectionType;
-       int i_NbrOfModule;
-       struct str_Module s_Module[MAX_MODULE];
-};
-
-/* BEGIN JK 06.07.04: Management of sevrals boards */
-/*
-  int i_CJCAvailable=1;
-  int i_CJCPolarity=0;
-  int i_CJCGain=2;/* changed from 0 to 2 */
-  int i_InterruptFlag=0;
-  int i_ADDIDATAPolarity;
-  int i_ADDIDATAGain;
-  int i_AutoCalibration=0;   /* : auto calibration */
-  int i_ADDIDATAConversionTime;
-  int i_ADDIDATAConversionTimeUnit;
-  int i_ADDIDATAType;
-  int i_ChannelNo;
-  int i_ChannelCount=0;
-  int i_ScanType;
-  int i_FirstChannel;
-  int i_LastChannel;
-  int i_Sum=0;
-  int i_Offset;
-  unsigned int ui_Channel_num=0;
-  static int i_Count=0;
-  int i_Initialised=0;
-  unsigned int ui_InterruptChannelValue[96]; /* Buffer */
-*/
-struct str_BoardInfos s_BoardInfos[100];       /*  100 will be the max number of boards to be used */
-/* END JK 06.07.04: Management of sevrals boards */
-
-#define AMCC_OP_REG_MCSR       0x3c
-#define EEPROM_BUSY            0x80000000
-#define NVCMD_LOAD_LOW         (0x4 << 5)      /* nvRam load low command */
-#define NVCMD_LOAD_HIGH                (0x5 << 5)      /* nvRam load high command */
-#define NVCMD_BEGIN_READ       (0x7 << 5)      /* nvRam begin read command */
-#define NVCMD_BEGIN_WRITE      (0x6 << 5)      /* EEPROM begin write command */
-
-static int i_AddiHeaderRW_ReadEeprom(int i_NbOfWordsToRead,
-                                    unsigned int dw_PCIBoardEepromAddress,
-                                    unsigned short w_EepromStartAddress,
-                                    unsigned short *pw_DataRead)
-{
-       unsigned int dw_eeprom_busy = 0;
-       int i_Counter = 0;
-       int i_WordCounter;
-       int i;
-       unsigned char pb_ReadByte[1];
-       unsigned char b_ReadLowByte = 0;
-       unsigned char b_ReadHighByte = 0;
-       unsigned char b_SelectedAddressLow = 0;
-       unsigned char b_SelectedAddressHigh = 0;
-       unsigned short w_ReadWord = 0;
-
-       for (i_WordCounter = 0; i_WordCounter < i_NbOfWordsToRead;
-               i_WordCounter++) {
-               do {
-                       dw_eeprom_busy =
-                               inl(dw_PCIBoardEepromAddress +
-                               AMCC_OP_REG_MCSR);
-                       dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
-               } while (dw_eeprom_busy == EEPROM_BUSY);
-
-               for (i_Counter = 0; i_Counter < 2; i_Counter++) {
-                       b_SelectedAddressLow = (w_EepromStartAddress + i_Counter) % 256;        /* Read the low 8 bit part */
-                       b_SelectedAddressHigh = (w_EepromStartAddress + i_Counter) / 256;       /* Read the high 8 bit part */
-
-                       /* Select the load low address mode */
-                       outb(NVCMD_LOAD_LOW,
-                               dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
-                               3);
-
-                       /* Wait on busy */
-                       do {
-                               dw_eeprom_busy =
-                                       inl(dw_PCIBoardEepromAddress +
-                                       AMCC_OP_REG_MCSR);
-                               dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
-                       } while (dw_eeprom_busy == EEPROM_BUSY);
-
-                       /* Load the low address */
-                       outb(b_SelectedAddressLow,
-                               dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
-                               2);
-
-                       /* Wait on busy */
-                       do {
-                               dw_eeprom_busy =
-                                       inl(dw_PCIBoardEepromAddress +
-                                       AMCC_OP_REG_MCSR);
-                               dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
-                       } while (dw_eeprom_busy == EEPROM_BUSY);
-
-                       /* Select the load high address mode */
-                       outb(NVCMD_LOAD_HIGH,
-                               dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
-                               3);
-
-                       /* Wait on busy */
-                       do {
-                               dw_eeprom_busy =
-                                       inl(dw_PCIBoardEepromAddress +
-                                       AMCC_OP_REG_MCSR);
-                               dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
-                       } while (dw_eeprom_busy == EEPROM_BUSY);
-
-                       /* Load the high address */
-                       outb(b_SelectedAddressHigh,
-                               dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
-                               2);
-
-                       /* Wait on busy */
-                       do {
-                               dw_eeprom_busy =
-                                       inl(dw_PCIBoardEepromAddress +
-                                       AMCC_OP_REG_MCSR);
-                               dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
-                       } while (dw_eeprom_busy == EEPROM_BUSY);
-
-                       /* Select the READ mode */
-                       outb(NVCMD_BEGIN_READ,
-                               dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
-                               3);
-
-                       /* Wait on busy */
-                       do {
-                               dw_eeprom_busy =
-                                       inl(dw_PCIBoardEepromAddress +
-                                       AMCC_OP_REG_MCSR);
-                               dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
-                       } while (dw_eeprom_busy == EEPROM_BUSY);
-
-                       /* Read data into the EEPROM */
-                       *pb_ReadByte =
-                               inb(dw_PCIBoardEepromAddress +
-                               AMCC_OP_REG_MCSR + 2);
-
-                       /* Wait on busy */
-                       do {
-                               dw_eeprom_busy =
-                                       inl(dw_PCIBoardEepromAddress +
-                                       AMCC_OP_REG_MCSR);
-                               dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
-                       } while (dw_eeprom_busy == EEPROM_BUSY);
-
-                       /* Select the upper address part */
-                       if (i_Counter == 0)
-                               b_ReadLowByte = pb_ReadByte[0];
-                       else
-                               b_ReadHighByte = pb_ReadByte[0];
-
-
-                       /* Sleep */
-                       msleep(1);
-
-               }
-               w_ReadWord =
-                       (b_ReadLowByte | (((unsigned short)b_ReadHighByte) *
-                               256));
-
-               pw_DataRead[i_WordCounter] = w_ReadWord;
-
-               w_EepromStartAddress += 2;      /*  to read the next word */
-
-       }                       /*  for (...) i_NbOfWordsToRead */
-       return 0;
-}
-
-static void v_GetAPCI3200EepromCalibrationValue(unsigned int dw_PCIBoardEepromAddress,
-                                               struct str_BoardInfos *BoardInformations)
-{
-       unsigned short w_AnalogInputMainHeaderAddress;
-       unsigned short w_AnalogInputComponentAddress;
-       unsigned short w_NumberOfModuls = 0;
-       unsigned short w_CurrentSources[2];
-       unsigned short w_ModulCounter = 0;
-       unsigned short w_FirstHeaderSize = 0;
-       unsigned short w_NumberOfInputs = 0;
-       unsigned short w_CJCFlag = 0;
-       unsigned short w_NumberOfGainValue = 0;
-       unsigned short w_SingleHeaderAddress = 0;
-       unsigned short w_SingleHeaderSize = 0;
-       unsigned short w_Input = 0;
-       unsigned short w_GainFactorAddress = 0;
-       unsigned short w_GainFactorValue[2];
-       unsigned short w_GainIndex = 0;
-       unsigned short w_GainValue = 0;
-
-  /*****************************************/
-  /** Get the Analog input header address **/
-  /*****************************************/
-       i_AddiHeaderRW_ReadEeprom(1,    /* i_NbOfWordsToRead */
-               dw_PCIBoardEepromAddress, 0x116,        /* w_EepromStartAddress: Analog input header address */
-               &w_AnalogInputMainHeaderAddress);
-
-  /*******************************************/
-  /** Compute the real analog input address **/
-  /*******************************************/
-       w_AnalogInputMainHeaderAddress = w_AnalogInputMainHeaderAddress + 0x100;
-
-  /******************************/
-  /** Get the number of moduls **/
-  /******************************/
-       i_AddiHeaderRW_ReadEeprom(1,    /* i_NbOfWordsToRead */
-               dw_PCIBoardEepromAddress, w_AnalogInputMainHeaderAddress + 0x02,        /* w_EepromStartAddress: Number of conponment */
-               &w_NumberOfModuls);
-
-       for (w_ModulCounter = 0; w_ModulCounter < w_NumberOfModuls;
-               w_ModulCounter++) {
-      /***********************************/
-      /** Compute the component address **/
-      /***********************************/
-               w_AnalogInputComponentAddress =
-                       w_AnalogInputMainHeaderAddress +
-                       (w_FirstHeaderSize * w_ModulCounter) + 0x04;
-
-      /****************************/
-      /** Read first header size **/
-      /****************************/
-               i_AddiHeaderRW_ReadEeprom(1,    /* i_NbOfWordsToRead */
-                       dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress,        /*  Address of the first header */
-                       &w_FirstHeaderSize);
-
-               w_FirstHeaderSize = w_FirstHeaderSize >> 4;
-
-      /***************************/
-      /** Read number of inputs **/
-      /***************************/
-               i_AddiHeaderRW_ReadEeprom(1,    /* i_NbOfWordsToRead */
-                       dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 0x06, /*  Number of inputs for the first modul */
-                       &w_NumberOfInputs);
-
-               w_NumberOfInputs = w_NumberOfInputs >> 4;
-
-      /***********************/
-      /** Read the CJC flag **/
-      /***********************/
-               i_AddiHeaderRW_ReadEeprom(1,    /* i_NbOfWordsToRead */
-                       dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 0x08, /*  CJC flag */
-                       &w_CJCFlag);
-
-               w_CJCFlag = (w_CJCFlag >> 3) & 0x1;     /*  Get only the CJC flag */
-
-      /*******************************/
-      /** Read number of gain value **/
-      /*******************************/
-               i_AddiHeaderRW_ReadEeprom(1,    /* i_NbOfWordsToRead */
-                       dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 0x44, /*  Number of gain value */
-                       &w_NumberOfGainValue);
-
-               w_NumberOfGainValue = w_NumberOfGainValue & 0xFF;
-
-      /***********************************/
-      /** Compute single header address **/
-      /***********************************/
-               w_SingleHeaderAddress =
-                       w_AnalogInputComponentAddress + 0x46 +
-                       (((w_NumberOfGainValue / 16) + 1) * 2) +
-                       (6 * w_NumberOfGainValue) +
-                       (4 * (((w_NumberOfGainValue / 16) + 1) * 2));
-
-      /********************************************/
-      /** Read current sources value for input 1 **/
-      /********************************************/
-               i_AddiHeaderRW_ReadEeprom(1,    /* i_NbOfWordsToRead */
-                       dw_PCIBoardEepromAddress, w_SingleHeaderAddress,        /* w_EepromStartAddress: Single header address */
-                       &w_SingleHeaderSize);
-
-               w_SingleHeaderSize = w_SingleHeaderSize >> 4;
-
-      /*************************************/
-      /** Read gain factor for the module **/
-      /*************************************/
-               w_GainFactorAddress = w_AnalogInputComponentAddress;
-
-               for (w_GainIndex = 0; w_GainIndex < w_NumberOfGainValue;
-                       w_GainIndex++) {
-         /************************************/
-         /** Read gain value for the module **/
-         /************************************/
-                       i_AddiHeaderRW_ReadEeprom(1,    /* i_NbOfWordsToRead */
-                               dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 70 + (2 * (1 + (w_NumberOfGainValue / 16))) + (0x02 * w_GainIndex),   /*  Gain value */
-                               &w_GainValue);
-
-                       BoardInformations->s_Module[w_ModulCounter].
-                               w_GainValue[w_GainIndex] = w_GainValue;
-
-         /*************************************/
-         /** Read gain factor for the module **/
-         /*************************************/
-                       i_AddiHeaderRW_ReadEeprom(2,    /* i_NbOfWordsToRead */
-                               dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 70 + ((2 * w_NumberOfGainValue) + (2 * (1 + (w_NumberOfGainValue / 16)))) + (0x04 * w_GainIndex),     /*  Gain factor */
-                               w_GainFactorValue);
-
-                       BoardInformations->s_Module[w_ModulCounter].
-                               ul_GainFactor[w_GainIndex] =
-                               (w_GainFactorValue[1] << 16) +
-                               w_GainFactorValue[0];
-               }
-
-      /***************************************************************/
-      /** Read current source value for each channels of the module **/
-      /***************************************************************/
-               for (w_Input = 0; w_Input < w_NumberOfInputs; w_Input++) {
-         /********************************************/
-         /** Read current sources value for input 1 **/
-         /********************************************/
-                       i_AddiHeaderRW_ReadEeprom(2,    /* i_NbOfWordsToRead */
-                               dw_PCIBoardEepromAddress,
-                               (w_Input * w_SingleHeaderSize) +
-                               w_SingleHeaderAddress + 0x0C, w_CurrentSources);
-
-         /************************************/
-         /** Save the current sources value **/
-         /************************************/
-                       BoardInformations->s_Module[w_ModulCounter].
-                               ul_CurrentSource[w_Input] =
-                               (w_CurrentSources[0] +
-                               ((w_CurrentSources[1] & 0xFFF) << 16));
-               }
-
-      /***************************************/
-      /** Read the CJC current source value **/
-      /***************************************/
-               i_AddiHeaderRW_ReadEeprom(2,    /* i_NbOfWordsToRead */
-                       dw_PCIBoardEepromAddress,
-                       (w_Input * w_SingleHeaderSize) + w_SingleHeaderAddress +
-                       0x0C, w_CurrentSources);
-
-      /************************************/
-      /** Save the current sources value **/
-      /************************************/
-               BoardInformations->s_Module[w_ModulCounter].
-                       ul_CurrentSourceCJC =
-                       (w_CurrentSources[0] +
-                       ((w_CurrentSources[1] & 0xFFF) << 16));
-       }
-}
-
-static int i_APCI3200_GetChannelCalibrationValue(struct comedi_device *dev,
-                                                unsigned int ui_Channel_num,
-                                                unsigned int *CJCCurrentSource,
-                                                unsigned int *ChannelCurrentSource,
-                                                unsigned int *ChannelGainFactor)
-{
-       int i_DiffChannel = 0;
-       int i_Module = 0;
-
-       /* Test if single or differential mode */
-       if (s_BoardInfos[dev->minor].i_ConnectionType == 1) {
-               /* if diff */
-
-               if (ui_Channel_num <= 1)
-                       i_DiffChannel = ui_Channel_num, i_Module = 0;
-               else if ((ui_Channel_num >= 2) && (ui_Channel_num <= 3))
-                       i_DiffChannel = ui_Channel_num - 2, i_Module = 1;
-               else if ((ui_Channel_num >= 4) && (ui_Channel_num <= 5))
-                       i_DiffChannel = ui_Channel_num - 4, i_Module = 2;
-               else if ((ui_Channel_num >= 6) && (ui_Channel_num <= 7))
-                       i_DiffChannel = ui_Channel_num - 6, i_Module = 3;
-
-       } else {
-               /*  if single */
-               if ((ui_Channel_num == 0) || (ui_Channel_num == 1))
-                       i_DiffChannel = 0, i_Module = 0;
-               else if ((ui_Channel_num == 2) || (ui_Channel_num == 3))
-                       i_DiffChannel = 1, i_Module = 0;
-               else if ((ui_Channel_num == 4) || (ui_Channel_num == 5))
-                       i_DiffChannel = 0, i_Module = 1;
-               else if ((ui_Channel_num == 6) || (ui_Channel_num == 7))
-                       i_DiffChannel = 1, i_Module = 1;
-               else if ((ui_Channel_num == 8) || (ui_Channel_num == 9))
-                       i_DiffChannel = 0, i_Module = 2;
-               else if ((ui_Channel_num == 10) || (ui_Channel_num == 11))
-                       i_DiffChannel = 1, i_Module = 2;
-               else if ((ui_Channel_num == 12) || (ui_Channel_num == 13))
-                       i_DiffChannel = 0, i_Module = 3;
-               else if ((ui_Channel_num == 14) || (ui_Channel_num == 15))
-                       i_DiffChannel = 1, i_Module = 3;
-       }
-
-       /* Test if thermocouple or RTD mode */
-       *CJCCurrentSource =
-               s_BoardInfos[dev->minor].s_Module[i_Module].ul_CurrentSourceCJC;
-
-       *ChannelCurrentSource =
-               s_BoardInfos[dev->minor].s_Module[i_Module].
-               ul_CurrentSource[i_DiffChannel];
-       /*       } */
-       /*    } */
-
-       /* Channle gain factor */
-       *ChannelGainFactor =
-               s_BoardInfos[dev->minor].s_Module[i_Module].
-               ul_GainFactor[s_BoardInfos[dev->minor].i_ADDIDATAGain];
-       /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-
-       return 0;
-}
-
-static int apci3200_di_insn_bits(struct comedi_device *dev,
-                                struct comedi_subdevice *s,
-                                struct comedi_insn *insn,
-                                unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-
-       data[1] = inl(devpriv->i_IobaseReserved) & 0xf;
-
-       return insn->n;
-}
-
-static int apci3200_do_insn_bits(struct comedi_device *dev,
-                                struct comedi_subdevice *s,
-                                struct comedi_insn *insn,
-                                unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-
-       s->state = inl(devpriv->i_IobaseAddon) & 0xf;
-
-       if (comedi_dio_update_state(s, data))
-               outl(s->state, devpriv->i_IobaseAddon);
-
-       data[1] = s->state;
-
-       return insn->n;
-}
-
-static int i_APCI3200_Read1AnalogInputChannel(struct comedi_device *dev,
-                                             struct comedi_subdevice *s,
-                                             struct comedi_insn *insn,
-                                             unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_EOC = 0;
-       unsigned int ui_ChannelNo = 0;
-       unsigned int ui_CommandRegister = 0;
-
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* ui_ChannelNo=i_ChannelNo; */
-       ui_ChannelNo = s_BoardInfos[dev->minor].i_ChannelNo;
-
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-  /*********************************/
-       /* Write the channel to configure */
-  /*********************************/
-       /* Begin JK 20.10.2004: Bad channel value is used when using differential mode */
-       /* outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); */
-       /* outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); */
-       outl(0 | s_BoardInfos[dev->minor].i_ChannelNo,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x4);
-       /* End JK 20.10.2004: Bad channel value is used when using differential mode */
-
-  /*******************************/
-       /* Set the convert timing unit */
-  /*******************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-
-       /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
-       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
-
-  /**************************/
-       /* Set the convert timing */
-  /**************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-
-       /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
-       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
-
-  /**************************************************************************/
-       /* Set the start end stop index to the selected channel and set the start */
-  /**************************************************************************/
-
-       ui_CommandRegister = ui_ChannelNo | (ui_ChannelNo << 8) | 0x80000;
-
-       /*Test if the interrupt is enable */
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == 1) {
-               /* Enable the interrupt */
-               ui_CommandRegister = ui_CommandRegister | 0x00100000;
-       }
-
-  /******************************/
-       /* Write the command register */
-  /******************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-
-       /* outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8); */
-       outl(ui_CommandRegister,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
-
-       /*Test if interrupt is enable */
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == 0) {
-               do {
-         /*************************/
-                       /*Read the EOC Status bit */
-         /*************************/
-
-                       /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */
-                       ui_EOC = inl(devpriv->iobase +
-                               s_BoardInfos[dev->minor].i_Offset + 20) & 1;
-
-               } while (ui_EOC != 1);
-
-      /***************************************/
-               /* Read the digital value of the input */
-      /***************************************/
-
-               /* data[0] = inl (devpriv->iobase+i_Offset + 28); */
-               data[0] =
-                       inl(devpriv->iobase +
-                       s_BoardInfos[dev->minor].i_Offset + 28);
-               /* END JK 06.07.04: Management of sevrals boards */
-
-       }
-       return 0;
-}
-
-static int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device *dev,
-                                                unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_Temp = 0, ui_EOC = 0;
-       unsigned int ui_CommandRegister = 0;
-
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-  /*********************************/
-       /* Write the channel to configure */
-  /*********************************/
-       /* Begin JK 20.10.2004: This seems not necessary ! */
-       /* outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); */
-       /* outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); */
-       /* End JK 20.10.2004: This seems not necessary ! */
-
-  /*******************************/
-       /* Set the convert timing unit */
-  /*******************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
-       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
-  /**************************/
-       /* Set the convert timing */
-  /**************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
-       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
-  /*****************************/
-       /*Read the calibration offset */
-  /*****************************/
-       /* ui_Temp = inl(devpriv->iobase+i_Offset + 12); */
-       ui_Temp = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
-
-  /*********************************/
-       /*Configure the Offset Conversion */
-  /*********************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl((ui_Temp | 0x00020000), devpriv->iobase+i_Offset + 12); */
-       outl((ui_Temp | 0x00020000),
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
-  /*******************************/
-       /*Initialise ui_CommandRegister */
-  /*******************************/
-
-       ui_CommandRegister = 0;
-
-       /*Test if the interrupt is enable */
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == 1) {
-               /*Enable the interrupt */
-               ui_CommandRegister = ui_CommandRegister | 0x00100000;
-       }
-
-  /**********************/
-       /*Start the conversion */
-  /**********************/
-       ui_CommandRegister = ui_CommandRegister | 0x00080000;
-
-  /***************************/
-       /*Write the command regiter */
-  /***************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8); */
-       outl(ui_CommandRegister,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
-
-       /*Test if interrupt is enable */
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == 0) {
-               do {
-         /*******************/
-                       /*Read the EOC flag */
-         /*******************/
-
-                       /* ui_EOC = inl (devpriv->iobase+i_Offset + 20) & 1; */
-                       ui_EOC = inl(devpriv->iobase +
-                               s_BoardInfos[dev->minor].i_Offset + 20) & 1;
-
-               } while (ui_EOC != 1);
-
-      /**************************************************/
-               /*Read the digital value of the calibration Offset */
-      /**************************************************/
-
-               /* data[0] = inl(devpriv->iobase+i_Offset+ 28); */
-               data[0] =
-                       inl(devpriv->iobase +
-                       s_BoardInfos[dev->minor].i_Offset + 28);
-       }
-       return 0;
-}
-
-static int i_APCI3200_ReadCalibrationGainValue(struct comedi_device *dev,
-                                              unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_EOC = 0;
-       int ui_CommandRegister = 0;
-
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-  /*********************************/
-       /* Write the channel to configure */
-  /*********************************/
-       /* Begin JK 20.10.2004: This seems not necessary ! */
-       /* outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); */
-       /* outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); */
-       /* End JK 20.10.2004: This seems not necessary ! */
-
-  /***************************/
-       /*Read the calibration gain */
-  /***************************/
-  /*******************************/
-       /* Set the convert timing unit */
-  /*******************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
-       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
-  /**************************/
-       /* Set the convert timing */
-  /**************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
-       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
-  /*******************************/
-       /*Configure the Gain Conversion */
-  /*******************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(0x00040000 , devpriv->iobase+i_Offset + 12); */
-       outl(0x00040000,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
-
-  /*******************************/
-       /*Initialise ui_CommandRegister */
-  /*******************************/
-
-       ui_CommandRegister = 0;
-
-       /*Test if the interrupt is enable */
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == 1) {
-               /*Enable the interrupt */
-               ui_CommandRegister = ui_CommandRegister | 0x00100000;
-       }
-
-  /**********************/
-       /*Start the conversion */
-  /**********************/
-
-       ui_CommandRegister = ui_CommandRegister | 0x00080000;
-  /***************************/
-       /*Write the command regiter */
-  /***************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8); */
-       outl(ui_CommandRegister,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
-
-       /*Test if interrupt is enable */
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == 0) {
-               do {
-
-         /*******************/
-                       /*Read the EOC flag */
-         /*******************/
-
-                       /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */
-                       ui_EOC = inl(devpriv->iobase +
-                               s_BoardInfos[dev->minor].i_Offset + 20) & 1;
-
-               } while (ui_EOC != 1);
-
-      /************************************************/
-               /*Read the digital value of the calibration Gain */
-      /************************************************/
-
-               /* data[0] = inl(devpriv->iobase+i_Offset + 28); */
-               data[0] =
-                       inl(devpriv->iobase +
-                       s_BoardInfos[dev->minor].i_Offset + 28);
-
-       }
-       return 0;
-}
-
-static int i_APCI3200_ReadCJCValue(struct comedi_device *dev,
-                                  unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_EOC = 0;
-       int ui_CommandRegister = 0;
-
-  /******************************/
-       /*Set the converting time unit */
-  /******************************/
-
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-
-       /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
-       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
-  /**************************/
-       /* Set the convert timing */
-  /**************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-
-       /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
-       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
-
-  /******************************/
-       /*Configure the CJC Conversion */
-  /******************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-
-       /* outl( 0x00000400 , devpriv->iobase+i_Offset + 4); */
-       outl(0x00000400,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4);
-  /*******************************/
-       /*Initialise dw_CommandRegister */
-  /*******************************/
-       ui_CommandRegister = 0;
-       /*Test if the interrupt is enable */
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == 1) {
-               /*Enable the interrupt */
-               ui_CommandRegister = ui_CommandRegister | 0x00100000;
-       }
-
-  /**********************/
-       /*Start the conversion */
-  /**********************/
-
-       ui_CommandRegister = ui_CommandRegister | 0x00080000;
-
-  /***************************/
-       /*Write the command regiter */
-  /***************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8); */
-       outl(ui_CommandRegister,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
-
-       /*Test if interrupt is enable */
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == 0) {
-               do {
-
-         /*******************/
-                       /*Read the EOC flag */
-         /*******************/
-
-                       /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */
-                       ui_EOC = inl(devpriv->iobase +
-                               s_BoardInfos[dev->minor].i_Offset + 20) & 1;
-
-               } while (ui_EOC != 1);
-
-      /***********************************/
-               /*Read the digital value of the CJC */
-      /***********************************/
-
-               /* data[0] = inl(devpriv->iobase+i_Offset + 28); */
-               data[0] =
-                       inl(devpriv->iobase +
-                       s_BoardInfos[dev->minor].i_Offset + 28);
-       }
-       return 0;
-}
-
-static int i_APCI3200_ReadCJCCalOffset(struct comedi_device *dev,
-                                      unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_EOC = 0;
-       int ui_CommandRegister = 0;
-
-  /*******************************************/
-       /*Read calibration offset value for the CJC */
-  /*******************************************/
-  /*******************************/
-       /* Set the convert timing unit */
-  /*******************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
-       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
-  /**************************/
-       /* Set the convert timing */
-  /**************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
-       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
-  /******************************/
-       /*Configure the CJC Conversion */
-  /******************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(0x00000400 , devpriv->iobase+i_Offset + 4); */
-       outl(0x00000400,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4);
-  /*********************************/
-       /*Configure the Offset Conversion */
-  /*********************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(0x00020000, devpriv->iobase+i_Offset + 12); */
-       outl(0x00020000,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
-  /*******************************/
-       /*Initialise ui_CommandRegister */
-  /*******************************/
-       ui_CommandRegister = 0;
-       /*Test if the interrupt is enable */
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == 1) {
-               /*Enable the interrupt */
-               ui_CommandRegister = ui_CommandRegister | 0x00100000;
-       }
-
-  /**********************/
-       /*Start the conversion */
-  /**********************/
-       ui_CommandRegister = ui_CommandRegister | 0x00080000;
-  /***************************/
-       /*Write the command regiter */
-  /***************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(ui_CommandRegister,devpriv->iobase+i_Offset + 8); */
-       outl(ui_CommandRegister,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == 0) {
-               do {
-         /*******************/
-                       /*Read the EOC flag */
-         /*******************/
-                       /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */
-                       ui_EOC = inl(devpriv->iobase +
-                               s_BoardInfos[dev->minor].i_Offset + 20) & 1;
-               } while (ui_EOC != 1);
-
-      /**************************************************/
-               /*Read the digital value of the calibration Offset */
-      /**************************************************/
-               /* data[0] = inl(devpriv->iobase+i_Offset + 28); */
-               data[0] =
-                       inl(devpriv->iobase +
-                       s_BoardInfos[dev->minor].i_Offset + 28);
-       }
-       return 0;
-}
-
-static int i_APCI3200_ReadCJCCalGain(struct comedi_device *dev,
-                                    unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_EOC = 0;
-       int ui_CommandRegister = 0;
-
-  /*******************************/
-       /* Set the convert timing unit */
-  /*******************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
-       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
-  /**************************/
-       /* Set the convert timing */
-  /**************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
-       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
-  /******************************/
-       /*Configure the CJC Conversion */
-  /******************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(0x00000400,devpriv->iobase+i_Offset + 4); */
-       outl(0x00000400,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4);
-  /*******************************/
-       /*Configure the Gain Conversion */
-  /*******************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(0x00040000,devpriv->iobase+i_Offset + 12); */
-       outl(0x00040000,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
-
-  /*******************************/
-       /*Initialise dw_CommandRegister */
-  /*******************************/
-       ui_CommandRegister = 0;
-       /*Test if the interrupt is enable */
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == 1) {
-               /*Enable the interrupt */
-               ui_CommandRegister = ui_CommandRegister | 0x00100000;
-       }
-  /**********************/
-       /*Start the conversion */
-  /**********************/
-       ui_CommandRegister = ui_CommandRegister | 0x00080000;
-  /***************************/
-       /*Write the command regiter */
-  /***************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(ui_CommandRegister ,devpriv->iobase+i_Offset + 8); */
-       outl(ui_CommandRegister,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == 0) {
-               do {
-         /*******************/
-                       /*Read the EOC flag */
-         /*******************/
-                       /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */
-                       ui_EOC = inl(devpriv->iobase +
-                               s_BoardInfos[dev->minor].i_Offset + 20) & 1;
-               } while (ui_EOC != 1);
-      /************************************************/
-               /*Read the digital value of the calibration Gain */
-      /************************************************/
-               /* data[0] = inl (devpriv->iobase+i_Offset + 28); */
-               data[0] =
-                       inl(devpriv->iobase +
-                       s_BoardInfos[dev->minor].i_Offset + 28);
-       }
-       return 0;
-}
-
-static int apci3200_reset(struct comedi_device *dev)
-{
-       struct addi_private *devpriv = dev->private;
-       int i_Temp;
-       unsigned int dw_Dummy;
-
-       /* i_InterruptFlag=0; */
-       /* i_Initialised==0; */
-       /* i_Count=0; */
-       /* i_Sum=0; */
-
-       s_BoardInfos[dev->minor].i_InterruptFlag = 0;
-       s_BoardInfos[dev->minor].i_Initialised = 0;
-       s_BoardInfos[dev->minor].i_Count = 0;
-       s_BoardInfos[dev->minor].i_Sum = 0;
-       s_BoardInfos[dev->minor].b_StructInitialized = 0;
-
-       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);
-       outl(0, devpriv->i_IobaseAddon);        /* Resets the output */
-  /***************/
-       /*Empty the buffer */
-  /**************/
-       for (i_Temp = 0; i_Temp <= 95; i_Temp++) {
-               /* ui_InterruptChannelValue[i_Temp]=0; */
-               s_BoardInfos[dev->minor].ui_InterruptChannelValue[i_Temp] = 0;
-       }                       /* for(i_Temp=0;i_Temp<=95;i_Temp++) */
-  /*****************************/
-       /*Reset the START and IRQ bit */
-  /*****************************/
-       for (i_Temp = 0; i_Temp <= 192;) {
-               while (((inl(devpriv->iobase + i_Temp + 12) >> 19) & 1) != 1) ;
-               outl(0, devpriv->iobase + i_Temp + 8);
-               i_Temp = i_Temp + 64;
-       }                       /* for(i_Temp=0;i_Temp<=192;i_Temp+64) */
-       return 0;
-}
-
-/*
- * Read value of the selected channel
- *
- * data[0]  : Digital Value Of Input
- * data[1]  : Calibration Offset Value
- * data[2]  : Calibration Gain Value
- * data[3]  : CJC value
- * data[4]  : CJC offset value
- * data[5]  : CJC gain value
- * data[6] : CJC current source from eeprom
- * data[7] : Channel current source from eeprom
- * data[8] : Channle gain factor from eeprom
- */
-static int apci3200_ai_read(struct comedi_device *dev,
-                           struct comedi_subdevice *s,
-                           struct comedi_insn *insn,
-                           unsigned int *data)
-{
-       unsigned int ui_DummyValue = 0;
-       int i_ConvertCJCCalibration;
-       int i = 0;
-
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* if(i_Initialised==0) */
-       if (s_BoardInfos[dev->minor].i_Initialised == 0)
-               /* END JK 06.07.04: Management of sevrals boards */
-       {
-               apci3200_reset(dev);
-               return -EINVAL;
-       }                       /* if(i_Initialised==0); */
-
-       switch (insn->unused[0]) {
-       case 0:
-
-               i_APCI3200_Read1AnalogInputChannel(dev, s, insn,
-                       &ui_DummyValue);
-               /* BEGIN JK 06.07.04: Management of sevrals boards */
-               /* ui_InterruptChannelValue[i_Count+0]=ui_DummyValue; */
-               s_BoardInfos[dev->minor].
-                       ui_InterruptChannelValue[s_BoardInfos[dev->minor].
-                       i_Count + 0] = ui_DummyValue;
-               /* END JK 06.07.04: Management of sevrals boards */
-
-               /* Begin JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-               i_APCI3200_GetChannelCalibrationValue(dev,
-                       s_BoardInfos[dev->minor].ui_Channel_num,
-                       &s_BoardInfos[dev->minor].
-                       ui_InterruptChannelValue[s_BoardInfos[dev->minor].
-                               i_Count + 6],
-                       &s_BoardInfos[dev->minor].
-                       ui_InterruptChannelValue[s_BoardInfos[dev->minor].
-                               i_Count + 7],
-                       &s_BoardInfos[dev->minor].
-                       ui_InterruptChannelValue[s_BoardInfos[dev->minor].
-                               i_Count + 8]);
-               /* End JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-
-               /* BEGIN JK 06.07.04: Management of sevrals boards */
-               /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1)) */
-               if ((s_BoardInfos[dev->minor].i_ADDIDATAType == 2)
-                       && (s_BoardInfos[dev->minor].i_InterruptFlag == FALSE)
-                       && (s_BoardInfos[dev->minor].i_CJCAvailable == 1))
-                       /* END JK 06.07.04: Management of sevrals boards */
-               {
-                       i_APCI3200_ReadCJCValue(dev, &ui_DummyValue);
-                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                       /* ui_InterruptChannelValue[i_Count + 3]=ui_DummyValue; */
-                       s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[s_BoardInfos[dev->
-                                       minor].i_Count + 3] = ui_DummyValue;
-                       /* END JK 06.07.04: Management of sevrals boards */
-               }               /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)) */
-               else {
-                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                       /* ui_InterruptChannelValue[i_Count + 3]=0; */
-                       s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[s_BoardInfos[dev->
-                                       minor].i_Count + 3] = 0;
-                       /* END JK 06.07.04: Management of sevrals boards */
-               }               /* elseif((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1)) */
-
-               /* BEGIN JK 06.07.04: Management of sevrals boards */
-               /* if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE)) */
-               if ((s_BoardInfos[dev->minor].i_AutoCalibration == FALSE)
-                       && (s_BoardInfos[dev->minor].i_InterruptFlag == FALSE))
-                       /* END JK 06.07.04: Management of sevrals boards */
-               {
-                       i_APCI3200_ReadCalibrationOffsetValue(dev,
-                               &ui_DummyValue);
-                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                       /* ui_InterruptChannelValue[i_Count + 1]=ui_DummyValue; */
-                       s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[s_BoardInfos[dev->
-                                       minor].i_Count + 1] = ui_DummyValue;
-                       /* END JK 06.07.04: Management of sevrals boards */
-                       i_APCI3200_ReadCalibrationGainValue(dev,
-                               &ui_DummyValue);
-                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                       /* ui_InterruptChannelValue[i_Count + 2]=ui_DummyValue; */
-                       s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[s_BoardInfos[dev->
-                                       minor].i_Count + 2] = ui_DummyValue;
-                       /* END JK 06.07.04: Management of sevrals boards */
-               }               /* if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE)) */
-
-               /* BEGIN JK 06.07.04: Management of sevrals boards */
-               /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)&& (i_CJCAvailable==1)) */
-               if ((s_BoardInfos[dev->minor].i_ADDIDATAType == 2)
-                       && (s_BoardInfos[dev->minor].i_InterruptFlag == FALSE)
-                       && (s_BoardInfos[dev->minor].i_CJCAvailable == 1))
-                       /* END JK 06.07.04: Management of sevrals boards */
-               {
-         /**********************************************************/
-                       /*Test if the Calibration channel must be read for the CJC */
-         /**********************************************************/
-         /**********************************/
-                       /*Test if the polarity is the same */
-         /**********************************/
-                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                       /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */
-                       if (s_BoardInfos[dev->minor].i_CJCPolarity !=
-                               s_BoardInfos[dev->minor].i_ADDIDATAPolarity)
-                               /* END JK 06.07.04: Management of sevrals boards */
-                       {
-                               i_ConvertCJCCalibration = 1;
-                       }       /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */
-                       else {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* if(i_CJCGain==i_ADDIDATAGain) */
-                               if (s_BoardInfos[dev->minor].i_CJCGain ==
-                                       s_BoardInfos[dev->minor].i_ADDIDATAGain)
-                                       /* END JK 06.07.04: Management of sevrals boards */
-                               {
-                                       i_ConvertCJCCalibration = 0;
-                               }       /* if(i_CJCGain==i_ADDIDATAGain) */
-                               else {
-                                       i_ConvertCJCCalibration = 1;
-                               }       /* elseif(i_CJCGain==i_ADDIDATAGain) */
-                       }       /* elseif(i_CJCPolarity!=i_ADDIDATAPolarity) */
-                       if (i_ConvertCJCCalibration == 1) {
-                               i_APCI3200_ReadCJCCalOffset(dev,
-                                       &ui_DummyValue);
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* ui_InterruptChannelValue[i_Count+4]=ui_DummyValue; */
-                               s_BoardInfos[dev->minor].
-                                       ui_InterruptChannelValue[s_BoardInfos
-                                       [dev->minor].i_Count + 4] =
-                                       ui_DummyValue;
-                               /* END JK 06.07.04: Management of sevrals boards */
-
-                               i_APCI3200_ReadCJCCalGain(dev, &ui_DummyValue);
-
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* ui_InterruptChannelValue[i_Count+5]=ui_DummyValue; */
-                               s_BoardInfos[dev->minor].
-                                       ui_InterruptChannelValue[s_BoardInfos
-                                       [dev->minor].i_Count + 5] =
-                                       ui_DummyValue;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                       }       /* if(i_ConvertCJCCalibration==1) */
-                       else {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* ui_InterruptChannelValue[i_Count+4]=0; */
-                               /* ui_InterruptChannelValue[i_Count+5]=0; */
-
-                               s_BoardInfos[dev->minor].
-                                       ui_InterruptChannelValue[s_BoardInfos
-                                       [dev->minor].i_Count + 4] = 0;
-                               s_BoardInfos[dev->minor].
-                                       ui_InterruptChannelValue[s_BoardInfos
-                                       [dev->minor].i_Count + 5] = 0;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                       }       /* elseif(i_ConvertCJCCalibration==1) */
-               }               /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)) */
-
-               /* BEGIN JK 06.07.04: Management of sevrals boards */
-               /* if(i_ScanType!=1) */
-               if (s_BoardInfos[dev->minor].i_ScanType != 1) {
-                       /* i_Count=0; */
-                       s_BoardInfos[dev->minor].i_Count = 0;
-               }               /* if(i_ScanType!=1) */
-               else {
-                       /* i_Count=i_Count +6; */
-                       /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-                       /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count +6; */
-                       s_BoardInfos[dev->minor].i_Count =
-                               s_BoardInfos[dev->minor].i_Count + 9;
-                       /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-               }               /* else if(i_ScanType!=1) */
-
-               /* if((i_ScanType==1) &&(i_InterruptFlag==1)) */
-               if ((s_BoardInfos[dev->minor].i_ScanType == 1)
-                       && (s_BoardInfos[dev->minor].i_InterruptFlag == 1)) {
-                       /* i_Count=i_Count-6; */
-                       /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-                       /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count-6; */
-                       s_BoardInfos[dev->minor].i_Count =
-                               s_BoardInfos[dev->minor].i_Count - 9;
-                       /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-               }
-               /* if(i_ScanType==0) */
-               if (s_BoardInfos[dev->minor].i_ScanType == 0) {
-                       /*
-                          data[0]= ui_InterruptChannelValue[0];
-                          data[1]= ui_InterruptChannelValue[1];
-                          data[2]= ui_InterruptChannelValue[2];
-                          data[3]= ui_InterruptChannelValue[3];
-                          data[4]= ui_InterruptChannelValue[4];
-                          data[5]= ui_InterruptChannelValue[5];
-                        */
-                       data[0] =
-                               s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[0];
-                       data[1] =
-                               s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[1];
-                       data[2] =
-                               s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[2];
-                       data[3] =
-                               s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[3];
-                       data[4] =
-                               s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[4];
-                       data[5] =
-                               s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[5];
-
-                       /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-                       i_APCI3200_GetChannelCalibrationValue(dev,
-                               s_BoardInfos[dev->minor].ui_Channel_num,
-                               &data[6], &data[7], &data[8]);
-                       /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-               }
-               break;
-       case 1:
-
-               for (i = 0; i < insn->n; i++) {
-                       /* data[i]=ui_InterruptChannelValue[i]; */
-                       data[i] =
-                               s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[i];
-               }
-
-               /* i_Count=0; */
-               /* i_Sum=0; */
-               /* if(i_ScanType==1) */
-               s_BoardInfos[dev->minor].i_Count = 0;
-               s_BoardInfos[dev->minor].i_Sum = 0;
-               if (s_BoardInfos[dev->minor].i_ScanType == 1) {
-                       /* i_Initialised=0; */
-                       /* i_InterruptFlag=0; */
-                       s_BoardInfos[dev->minor].i_Initialised = 0;
-                       s_BoardInfos[dev->minor].i_InterruptFlag = 0;
-                       /* END JK 06.07.04: Management of sevrals boards */
-               }
-               break;
-       default:
-               printk("\nThe parameters passed are in error\n");
-               apci3200_reset(dev);
-               return -EINVAL;
-       }                       /* switch(insn->unused[0]) */
-
-       return insn->n;
-}
-
-/*
- * Configures The Analog Input Subdevice
- *
- * data[0]  = 0  Normal AI
- *         = 1  RTD
- *         = 2  THERMOCOUPLE
- * data[1]  = Gain To Use
- * data[2]  = 0  Bipolar
- *         = 1  Unipolar
- * data[3]  = Offset Range
- * data[4]  = 0  DC Coupling
- *         = 1  AC Coupling
- * data[5]  = 0  Single
- *         = 1  Differential
- * data[6]  = TimerReloadValue
- * data[7]  = ConvertingTimeUnit
- * data[8]  = 0  Analog voltage measurement
- *         = 1  Resistance measurement
- *         = 2  Temperature measurement
- * data[9]  = 0  Interrupt Disable
- *         = 1  INterrupt Enable
- * data[10] = Type of Thermocouple
- * data[11] = single channel Module Number
- * data[12] = 0  Single Read
- *         = 1  Read more channel
- *         = 2  Single scan
- *         = 3  Continuous Scan
- * data[13] = Number of channels to read
- * data[14] = 0  RTD not used
- *         = 1  RTD 2 wire connection
- *         = 2  RTD 3 wire connection
- *         = 3  RTD 4 wire connection
- */
-static int apci3200_ai_config(struct comedi_device *dev,
-                             struct comedi_subdevice *s,
-                             struct comedi_insn *insn,
-                             unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int ul_Config = 0, ul_Temp = 0;
-       unsigned int ui_ChannelNo = 0;
-       unsigned int ui_Dummy = 0;
-       int i_err = 0;
-
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /*  Initialize the structure */
-       if (s_BoardInfos[dev->minor].b_StructInitialized != 1) {
-               s_BoardInfos[dev->minor].i_CJCAvailable = 1;
-               s_BoardInfos[dev->minor].i_CJCPolarity = 0;
-               s_BoardInfos[dev->minor].i_CJCGain = 2; /* changed from 0 to 2 */
-               s_BoardInfos[dev->minor].i_InterruptFlag = 0;
-               s_BoardInfos[dev->minor].i_AutoCalibration = 0; /* : auto calibration */
-               s_BoardInfos[dev->minor].i_ChannelCount = 0;
-               s_BoardInfos[dev->minor].i_Sum = 0;
-               s_BoardInfos[dev->minor].ui_Channel_num = 0;
-               s_BoardInfos[dev->minor].i_Count = 0;
-               s_BoardInfos[dev->minor].i_Initialised = 0;
-               s_BoardInfos[dev->minor].b_StructInitialized = 1;
-
-               /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-               s_BoardInfos[dev->minor].i_ConnectionType = 0;
-               /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-
-               /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-               memset(s_BoardInfos[dev->minor].s_Module, 0,
-                       sizeof(s_BoardInfos[dev->minor].s_Module[MAX_MODULE]));
-
-               v_GetAPCI3200EepromCalibrationValue(devpriv->i_IobaseAmcc,
-                       &s_BoardInfos[dev->minor]);
-               /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-       }
-
-       if (data[0] != 0 && data[0] != 1 && data[0] != 2) {
-               printk("\nThe selection of acquisition type is in error\n");
-               i_err++;
-       }                       /* if(data[0]!=0 && data[0]!=1 && data[0]!=2) */
-       if (data[0] == 1) {
-               if (data[14] != 0 && data[14] != 1 && data[14] != 2
-                       && data[14] != 4) {
-                       printk("\n Error in selection of RTD connection type\n");
-                       i_err++;
-               }               /* if(data[14]!=0 && data[14]!=1 && data[14]!=2 && data[14]!=4) */
-       }                       /* if(data[0]==1 ) */
-       if (data[1] < 0 || data[1] > 7) {
-               printk("\nThe selection of gain is in error\n");
-               i_err++;
-       }                       /*  if(data[1]<0 || data[1]>7) */
-       if (data[2] != 0 && data[2] != 1) {
-               printk("\nThe selection of polarity is in error\n");
-               i_err++;
-       }                       /* if(data[2]!=0 &&  data[2]!=1) */
-       if (data[3] != 0) {
-               printk("\nThe selection of offset range  is in error\n");
-               i_err++;
-       }                       /*  if(data[3]!=0) */
-       if (data[4] != 0 && data[4] != 1) {
-               printk("\nThe selection of coupling is in error\n");
-               i_err++;
-       }                       /* if(data[4]!=0 &&  data[4]!=1) */
-       if (data[5] != 0 && data[5] != 1) {
-               printk("\nThe selection of single/differential mode is in error\n");
-               i_err++;
-       }                       /* if(data[5]!=0 &&  data[5]!=1) */
-       if (data[8] != 0 && data[8] != 1 && data[2] != 2) {
-               printk("\nError in selection of functionality\n");
-       }                       /* if(data[8]!=0 && data[8]!=1 && data[2]!=2) */
-       if (data[12] == 0 || data[12] == 1) {
-               if (data[6] != 20 && data[6] != 40 && data[6] != 80
-                       && data[6] != 160) {
-                       printk("\nThe selection of conversion time reload value is in error\n");
-                       i_err++;
-               }               /*  if (data[6]!=20 && data[6]!=40 && data[6]!=80 && data[6]!=160 ) */
-               if (data[7] != 2) {
-                       printk("\nThe selection of conversion time unit  is in error\n");
-                       i_err++;
-               }               /*  if(data[7]!=2) */
-       }
-       if (data[9] != 0 && data[9] != 1) {
-               printk("\nThe selection of interrupt enable is in error\n");
-               i_err++;
-       }                       /* if(data[9]!=0 &&  data[9]!=1) */
-       if (data[11] < 0 || data[11] > 4) {
-               printk("\nThe selection of module is in error\n");
-               i_err++;
-       }                       /* if(data[11] <0 ||  data[11]>1) */
-       if (data[12] < 0 || data[12] > 3) {
-               printk("\nThe selection of singlechannel/scan selection is in error\n");
-               i_err++;
-       }                       /* if(data[12] < 0 ||  data[12]> 3) */
-       if (data[13] < 0 || data[13] > 16) {
-               printk("\nThe selection of number of channels is in error\n");
-               i_err++;
-       }                       /*  if(data[13] <0 ||data[13] >15) */
-
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /*
-          i_ChannelCount=data[13];
-          i_ScanType=data[12];
-          i_ADDIDATAPolarity = data[2];
-          i_ADDIDATAGain=data[1];
-          i_ADDIDATAConversionTime=data[6];
-          i_ADDIDATAConversionTimeUnit=data[7];
-          i_ADDIDATAType=data[0];
-        */
-
-       /*  Save acquisition configuration for the actual board */
-       s_BoardInfos[dev->minor].i_ChannelCount = data[13];
-       s_BoardInfos[dev->minor].i_ScanType = data[12];
-       s_BoardInfos[dev->minor].i_ADDIDATAPolarity = data[2];
-       s_BoardInfos[dev->minor].i_ADDIDATAGain = data[1];
-       s_BoardInfos[dev->minor].i_ADDIDATAConversionTime = data[6];
-       s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit = data[7];
-       s_BoardInfos[dev->minor].i_ADDIDATAType = data[0];
-       /* Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-       s_BoardInfos[dev->minor].i_ConnectionType = data[5];
-       /* End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-       /* END JK 06.07.04: Management of sevrals boards */
-
-       /* Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-       memset(s_BoardInfos[dev->minor].ui_ScanValueArray, 0, (7 + 12) * sizeof(unsigned int)); /*  7 is the maximal number of channels */
-       /* End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-
-       /* BEGIN JK 02.07.04 : This while can't be do, it block the process when using severals boards */
-       /* while(i_InterruptFlag==1) */
-       while (s_BoardInfos[dev->minor].i_InterruptFlag == 1) {
-#ifndef MSXBOX
-               udelay(1);
-#else
-               /*  In the case where the driver is compiled for the MSX-Box */
-               /*  we used a printk to have a little delay because udelay */
-               /*  seems to be broken under the MSX-Box. */
-               /*  This solution hat to be studied. */
-               printk("");
-#endif
-       }
-       /* END JK 02.07.04 : This while can't be do, it block the process when using severals boards */
-
-       ui_ChannelNo = CR_CHAN(insn->chanspec); /*  get the channel */
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* i_ChannelNo=ui_ChannelNo; */
-       /* ui_Channel_num =ui_ChannelNo; */
-
-       s_BoardInfos[dev->minor].i_ChannelNo = ui_ChannelNo;
-       s_BoardInfos[dev->minor].ui_Channel_num = ui_ChannelNo;
-
-       /* END JK 06.07.04: Management of sevrals boards */
-
-       if (data[5] == 0) {
-               if (ui_ChannelNo > 15) {
-                       printk("\nThe Selection of the channel is in error\n");
-                       i_err++;
-               }               /*  if(ui_ChannelNo>15) */
-       }                       /* if(data[5]==0) */
-       else {
-               if (data[14] == 2) {
-                       if (ui_ChannelNo > 3) {
-                               printk("\nThe Selection of the channel is in error\n");
-                               i_err++;
-                       }       /*  if(ui_ChannelNo>3) */
-               }               /* if(data[14]==2) */
-               else {
-                       if (ui_ChannelNo > 7) {
-                               printk("\nThe Selection of the channel is in error\n");
-                               i_err++;
-                       }       /*  if(ui_ChannelNo>7) */
-               }               /* elseif(data[14]==2) */
-       }                       /* elseif(data[5]==0) */
-       if (data[12] == 0 || data[12] == 1) {
-               switch (data[5]) {
-               case 0:
-                       if (ui_ChannelNo <= 3) {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* i_Offset=0; */
-                               s_BoardInfos[dev->minor].i_Offset = 0;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                       }       /* if(ui_ChannelNo <=3) */
-                       if (ui_ChannelNo >= 4 && ui_ChannelNo <= 7) {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* i_Offset=64; */
-                               s_BoardInfos[dev->minor].i_Offset = 64;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                       }       /* if(ui_ChannelNo >=4 && ui_ChannelNo <=7) */
-                       if (ui_ChannelNo >= 8 && ui_ChannelNo <= 11) {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* i_Offset=128; */
-                               s_BoardInfos[dev->minor].i_Offset = 128;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                       }       /* if(ui_ChannelNo >=8 && ui_ChannelNo <=11) */
-                       if (ui_ChannelNo >= 12 && ui_ChannelNo <= 15) {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* i_Offset=192; */
-                               s_BoardInfos[dev->minor].i_Offset = 192;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                       }       /* if(ui_ChannelNo >=12 && ui_ChannelNo <=15) */
-                       break;
-               case 1:
-                       if (data[14] == 2) {
-                               if (ui_ChannelNo == 0) {
-                                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                                       /* i_Offset=0; */
-                                       s_BoardInfos[dev->minor].i_Offset = 0;
-                                       /* END JK 06.07.04: Management of sevrals boards */
-                               }       /* if(ui_ChannelNo ==0 ) */
-                               if (ui_ChannelNo == 1) {
-                                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                                       /* i_Offset=0; */
-                                       s_BoardInfos[dev->minor].i_Offset = 64;
-                                       /* END JK 06.07.04: Management of sevrals boards */
-                               }       /*  if(ui_ChannelNo ==1) */
-                               if (ui_ChannelNo == 2) {
-                                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                                       /* i_Offset=128; */
-                                       s_BoardInfos[dev->minor].i_Offset = 128;
-                                       /* END JK 06.07.04: Management of sevrals boards */
-                               }       /* if(ui_ChannelNo ==2 ) */
-                               if (ui_ChannelNo == 3) {
-                                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                                       /* i_Offset=192; */
-                                       s_BoardInfos[dev->minor].i_Offset = 192;
-                                       /* END JK 06.07.04: Management of sevrals boards */
-                               }       /* if(ui_ChannelNo ==3) */
-
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* i_ChannelNo=0; */
-                               s_BoardInfos[dev->minor].i_ChannelNo = 0;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                               ui_ChannelNo = 0;
-                               break;
-                       }       /* if(data[14]==2) */
-                       if (ui_ChannelNo <= 1) {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* i_Offset=0; */
-                               s_BoardInfos[dev->minor].i_Offset = 0;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                       }       /* if(ui_ChannelNo <=1) */
-                       if (ui_ChannelNo >= 2 && ui_ChannelNo <= 3) {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* i_ChannelNo=i_ChannelNo-2; */
-                               /* i_Offset=64; */
-                               s_BoardInfos[dev->minor].i_ChannelNo =
-                                       s_BoardInfos[dev->minor].i_ChannelNo -
-                                       2;
-                               s_BoardInfos[dev->minor].i_Offset = 64;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                               ui_ChannelNo = ui_ChannelNo - 2;
-                       }       /* if(ui_ChannelNo >=2 && ui_ChannelNo <=3) */
-                       if (ui_ChannelNo >= 4 && ui_ChannelNo <= 5) {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* i_ChannelNo=i_ChannelNo-4; */
-                               /* i_Offset=128; */
-                               s_BoardInfos[dev->minor].i_ChannelNo =
-                                       s_BoardInfos[dev->minor].i_ChannelNo -
-                                       4;
-                               s_BoardInfos[dev->minor].i_Offset = 128;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                               ui_ChannelNo = ui_ChannelNo - 4;
-                       }       /* if(ui_ChannelNo >=4 && ui_ChannelNo <=5) */
-                       if (ui_ChannelNo >= 6 && ui_ChannelNo <= 7) {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* i_ChannelNo=i_ChannelNo-6; */
-                               /* i_Offset=192; */
-                               s_BoardInfos[dev->minor].i_ChannelNo =
-                                       s_BoardInfos[dev->minor].i_ChannelNo -
-                                       6;
-                               s_BoardInfos[dev->minor].i_Offset = 192;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                               ui_ChannelNo = ui_ChannelNo - 6;
-                       }       /* if(ui_ChannelNo >=6 && ui_ChannelNo <=7) */
-                       break;
-
-               default:
-                       printk("\n This selection of polarity does not exist\n");
-                       i_err++;
-               }               /* switch(data[2]) */
-       }                       /* if(data[12]==0 || data[12]==1) */
-       else {
-               switch (data[11]) {
-               case 1:
-                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                       /* i_Offset=0; */
-                       s_BoardInfos[dev->minor].i_Offset = 0;
-                       /* END JK 06.07.04: Management of sevrals boards */
-                       break;
-               case 2:
-                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                       /* i_Offset=64; */
-                       s_BoardInfos[dev->minor].i_Offset = 64;
-                       /* END JK 06.07.04: Management of sevrals boards */
-                       break;
-               case 3:
-                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                       /* i_Offset=128; */
-                       s_BoardInfos[dev->minor].i_Offset = 128;
-                       /* END JK 06.07.04: Management of sevrals boards */
-                       break;
-               case 4:
-                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                       /* i_Offset=192; */
-                       s_BoardInfos[dev->minor].i_Offset = 192;
-                       /* END JK 06.07.04: Management of sevrals boards */
-                       break;
-               default:
-                       printk("\nError in module selection\n");
-                       i_err++;
-               }               /*  switch(data[11]) */
-       }                       /*  elseif(data[12]==0 || data[12]==1) */
-       if (i_err) {
-               apci3200_reset(dev);
-               return -EINVAL;
-       }
-       /* if(i_ScanType!=1) */
-       if (s_BoardInfos[dev->minor].i_ScanType != 1) {
-               /* BEGIN JK 06.07.04: Management of sevrals boards */
-               /* i_Count=0; */
-               /* i_Sum=0; */
-               s_BoardInfos[dev->minor].i_Count = 0;
-               s_BoardInfos[dev->minor].i_Sum = 0;
-               /* END JK 06.07.04: Management of sevrals boards */
-       }                       /* if(i_ScanType!=1) */
-
-       ul_Config =
-               data[1] | (data[2] << 6) | (data[5] << 7) | (data[3] << 8) |
-               (data[4] << 9);
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* END JK 06.07.04: Management of sevrals boards */
-  /*********************************/
-       /* Write the channel to configure */
-  /*********************************/
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* outl(0 | ui_ChannelNo , devpriv->iobase+i_Offset + 0x4); */
-       outl(0 | ui_ChannelNo,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x4);
-       /* END JK 06.07.04: Management of sevrals boards */
-
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* END JK 06.07.04: Management of sevrals boards */
-  /**************************/
-       /* Reset the configuration */
-  /**************************/
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* outl(0 , devpriv->iobase+i_Offset + 0x0); */
-       outl(0, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x0);
-       /* END JK 06.07.04: Management of sevrals boards */
-
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* END JK 06.07.04: Management of sevrals boards */
-
-  /***************************/
-       /* Write the configuration */
-  /***************************/
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* outl(ul_Config , devpriv->iobase+i_Offset + 0x0); */
-       outl(ul_Config,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x0);
-       /* END JK 06.07.04: Management of sevrals boards */
-
-  /***************************/
-       /*Reset the calibration bit */
-  /***************************/
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* ul_Temp = inl(devpriv->iobase+i_Offset + 12); */
-       ul_Temp = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
-       /* END JK 06.07.04: Management of sevrals boards */
-
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* END JK 06.07.04: Management of sevrals boards */
-
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* outl((ul_Temp & 0xFFF9FFFF) , devpriv->iobase+.i_Offset + 12); */
-       outl((ul_Temp & 0xFFF9FFFF),
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
-       /* END JK 06.07.04: Management of sevrals boards */
-
-       if (data[9] == 1) {
-               devpriv->tsk_Current = current;
-               /* BEGIN JK 06.07.04: Management of sevrals boards */
-               /* i_InterruptFlag=1; */
-               s_BoardInfos[dev->minor].i_InterruptFlag = 1;
-               /* END JK 06.07.04: Management of sevrals boards */
-       }                       /*  if(data[9]==1) */
-       else {
-               /* BEGIN JK 06.07.04: Management of sevrals boards */
-               /* i_InterruptFlag=0; */
-               s_BoardInfos[dev->minor].i_InterruptFlag = 0;
-               /* END JK 06.07.04: Management of sevrals boards */
-       }                       /* else  if(data[9]==1) */
-
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* i_Initialised=1; */
-       s_BoardInfos[dev->minor].i_Initialised = 1;
-       /* END JK 06.07.04: Management of sevrals boards */
-
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* if(i_ScanType==1) */
-       if (s_BoardInfos[dev->minor].i_ScanType == 1)
-               /* END JK 06.07.04: Management of sevrals boards */
-       {
-               /* BEGIN JK 06.07.04: Management of sevrals boards */
-               /* i_Sum=i_Sum+1; */
-               s_BoardInfos[dev->minor].i_Sum =
-                       s_BoardInfos[dev->minor].i_Sum + 1;
-               /* END JK 06.07.04: Management of sevrals boards */
-
-               insn->unused[0] = 0;
-               apci3200_ai_read(dev, s, insn, &ui_Dummy);
-       }
-
-       return insn->n;
-}
-
-/*
- * Tests the Selected Anlog Input Channel
- *
- * data[0] = 0  TestAnalogInputShortCircuit
- *        = 1  TestAnalogInputConnection
- *
- * data[0] : Digital value obtained
- * data[1] : calibration offset
- * data[2] : calibration gain
- */
-static int apci3200_ai_bits_test(struct comedi_device *dev,
-                                struct comedi_subdevice *s,
-                                struct comedi_insn *insn,
-                                unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_Configuration = 0;
-       int i_Temp;             /* ,i_TimeUnit; */
-
-       /* if(i_Initialised==0) */
-
-       if (s_BoardInfos[dev->minor].i_Initialised == 0) {
-               apci3200_reset(dev);
-               return -EINVAL;
-       }                       /* if(i_Initialised==0); */
-       if (data[0] != 0 && data[0] != 1) {
-               printk("\nError in selection of functionality\n");
-               apci3200_reset(dev);
-               return -EINVAL;
-       }                       /* if(data[0]!=0 && data[0]!=1) */
-
-       if (data[0] == 1)       /* Perform Short Circuit TEST */
-       {
-      /**************************/
-               /*Set the short-cicuit bit */
-      /**************************/
-               /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-               while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].
-                                               i_Offset + 12) >> 19) & 1) !=
-                       1) ;
-               /* outl((0x00001000 |i_ChannelNo) , devpriv->iobase+i_Offset + 4); */
-               outl((0x00001000 | s_BoardInfos[dev->minor].i_ChannelNo),
-                       devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                       4);
-      /*************************/
-               /*Set the time unit to ns */
-      /*************************/
-               /* i_TimeUnit= i_ADDIDATAConversionTimeUnit;
-                  i_ADDIDATAConversionTimeUnit= 1; */
-               /* i_Temp= i_InterruptFlag ; */
-               i_Temp = s_BoardInfos[dev->minor].i_InterruptFlag;
-               s_BoardInfos[dev->minor].i_InterruptFlag = 0;
-               i_APCI3200_Read1AnalogInputChannel(dev, s, insn, data);
-               /* if(i_AutoCalibration == FALSE) */
-               if (s_BoardInfos[dev->minor].i_AutoCalibration == FALSE) {
-                       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-                       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].
-                                                       i_Offset +
-                                                       12) >> 19) & 1) != 1) ;
-
-                       /* outl((0x00001000 |i_ChannelNo) , devpriv->iobase+i_Offset + 4); */
-                       outl((0x00001000 | s_BoardInfos[dev->minor].
-                                       i_ChannelNo),
-                               devpriv->iobase +
-                               s_BoardInfos[dev->minor].i_Offset + 4);
-                       data++;
-                       i_APCI3200_ReadCalibrationOffsetValue(dev, data);
-                       data++;
-                       i_APCI3200_ReadCalibrationGainValue(dev, data);
-               }
-       } else {
-               /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-               while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].
-                                               i_Offset + 12) >> 19) & 1) !=
-                       1) ;
-               /* outl((0x00000800|i_ChannelNo) , devpriv->iobase+i_Offset + 4); */
-               outl((0x00000800 | s_BoardInfos[dev->minor].i_ChannelNo),
-                       devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                       4);
-               /* ui_Configuration = inl(devpriv->iobase+i_Offset + 0); */
-               ui_Configuration =
-                       inl(devpriv->iobase +
-                       s_BoardInfos[dev->minor].i_Offset + 0);
-      /*************************/
-               /*Set the time unit to ns */
-      /*************************/
-               /* i_TimeUnit= i_ADDIDATAConversionTimeUnit;
-                  i_ADDIDATAConversionTimeUnit= 1; */
-               /* i_Temp= i_InterruptFlag ; */
-               i_Temp = s_BoardInfos[dev->minor].i_InterruptFlag;
-               s_BoardInfos[dev->minor].i_InterruptFlag = 0;
-               i_APCI3200_Read1AnalogInputChannel(dev, s, insn, data);
-               /* if(i_AutoCalibration == FALSE) */
-               if (s_BoardInfos[dev->minor].i_AutoCalibration == FALSE) {
-                       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-                       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].
-                                                       i_Offset +
-                                                       12) >> 19) & 1) != 1) ;
-                       /* outl((0x00000800|i_ChannelNo) , devpriv->iobase+i_Offset + 4); */
-                       outl((0x00000800 | s_BoardInfos[dev->minor].
-                                       i_ChannelNo),
-                               devpriv->iobase +
-                               s_BoardInfos[dev->minor].i_Offset + 4);
-                       data++;
-                       i_APCI3200_ReadCalibrationOffsetValue(dev, data);
-                       data++;
-                       i_APCI3200_ReadCalibrationGainValue(dev, data);
-               }
-       }
-       /* i_InterruptFlag=i_Temp ; */
-       s_BoardInfos[dev->minor].i_InterruptFlag = i_Temp;
-       return insn->n;
-}
-
-static int apci3200_ai_write(struct comedi_device *dev,
-                            struct comedi_subdevice *s,
-                            struct comedi_insn *insn,
-                            unsigned int *data)
-{
-       apci3200_reset(dev);
-       return insn->n;
-}
-
-static int apci3200_ai_cmdtest(struct comedi_device *dev,
-                              struct comedi_subdevice *s,
-                              struct comedi_cmd *cmd)
-{
-
-       int err = 0;
-       unsigned int ui_ConvertTime = 0;
-       unsigned int ui_ConvertTimeBase = 0;
-       unsigned int ui_DelayTime = 0;
-       unsigned int ui_DelayTimeBase = 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 */
-
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
-                                       TRIG_TIMER | TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
-
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == 0)
-               err |= -EINVAL;
-
-       if (err) {
-               apci3200_reset(dev);
-               return 1;
-       }
-
-       /* Step 2a : make sure trigger sources are unique */
-
-       err |= cfc_check_trigger_is_unique(&cmd->start_src);
-       err |= cfc_check_trigger_is_unique(&cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(&cmd->stop_src);
-
-       /* Step 2b : and mutually compatible */
-
-       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]; */
-       s_BoardInfos[dev->minor].i_LastChannel = cmd->chanlist[1];
-
-       if (cmd->convert_src == TRIG_TIMER) {
-               ui_ConvertTime = cmd->convert_arg & 0xFFFF;
-               ui_ConvertTimeBase = cmd->convert_arg >> 16;
-               if (ui_ConvertTime != 20 && ui_ConvertTime != 40
-                       && ui_ConvertTime != 80 && ui_ConvertTime != 160)
-               {
-                       printk("\nThe selection of conversion time reload value is in error\n");
-                       err++;
-               }               /*  if (ui_ConvertTime!=20 && ui_ConvertTime!=40 && ui_ConvertTime!=80 && ui_ConvertTime!=160 ) */
-               if (ui_ConvertTimeBase != 2) {
-                       printk("\nThe selection of conversion time unit  is in error\n");
-                       err++;
-               }               /* if(ui_ConvertTimeBase!=2) */
-       } else {
-               ui_ConvertTime = 0;
-               ui_ConvertTimeBase = 0;
-       }
-       if (cmd->scan_begin_src == TRIG_FOLLOW) {
-               ui_DelayTime = 0;
-               ui_DelayTimeBase = 0;
-       }                       /* if(cmd->scan_begin_src==TRIG_FOLLOW) */
-       else {
-               ui_DelayTime = cmd->scan_begin_arg & 0xFFFF;
-               ui_DelayTimeBase = cmd->scan_begin_arg >> 16;
-               if (ui_DelayTimeBase != 2 && ui_DelayTimeBase != 3) {
-                       err++;
-                       printk("\nThe Delay time base selection is in error\n");
-               }
-               if (ui_DelayTime < 1 || ui_DelayTime > 1023) {
-                       err++;
-                       printk("\nThe Delay time value is in error\n");
-               }
-               if (err) {
-                       apci3200_reset(dev);
-                       return 3;
-               }
-               fpu_begin();
-               d_SCANTimeNewUnit = (double)ui_DelayTime;
-               /* i_NbrOfChannel= i_LastChannel-i_FirstChannel + 4; */
-               i_NbrOfChannel =
-                       s_BoardInfos[dev->minor].i_LastChannel -
-                       s_BoardInfos[dev->minor].i_FirstChannel + 4;
-      /**********************************************************/
-               /*calculate the total conversion time for all the channels */
-      /**********************************************************/
-               d_ConversionTimeForAllChannels =
-                       (double)((double)ui_ConvertTime /
-                       (double)i_NbrOfChannel);
-
-      /*******************************/
-               /*Convert the frequence in time */
-      /*******************************/
-               d_ConversionTimeForAllChannels =
-                       (double)1.0 / d_ConversionTimeForAllChannels;
-               ui_ConvertTimeBase = 3;
-      /***********************************/
-               /*Test if the time unit is the same */
-      /***********************************/
-
-               if (ui_DelayTimeBase <= ui_ConvertTimeBase) {
-
-                       for (i_Cpt = 0;
-                               i_Cpt < (ui_ConvertTimeBase - ui_DelayTimeBase);
-                               i_Cpt++) {
-
-                               d_ConversionTimeForAllChannels =
-                                       d_ConversionTimeForAllChannels * 1000;
-                               d_ConversionTimeForAllChannels =
-                                       d_ConversionTimeForAllChannels + 1;
-                       }
-               } else {
-                       for (i_Cpt = 0;
-                               i_Cpt < (ui_DelayTimeBase - ui_ConvertTimeBase);
-                               i_Cpt++) {
-                               d_SCANTimeNewUnit = d_SCANTimeNewUnit * 1000;
-
-                       }
-               }
-
-               if (d_ConversionTimeForAllChannels >= d_SCANTimeNewUnit) {
-
-                       printk("\nSCAN Delay value cannot be used\n");
-         /*********************************/
-                       /*SCAN Delay value cannot be used */
-         /*********************************/
-                       err++;
-               }
-               fpu_end();
-       }                       /* else if(cmd->scan_begin_src==TRIG_FOLLOW) */
-
-       if (err) {
-               apci3200_reset(dev);
-               return 4;
-       }
-
-       return 0;
-}
-
-static int apci3200_cancel(struct comedi_device *dev,
-                          struct comedi_subdevice *s)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_Configuration = 0;
-
-       /* i_InterruptFlag=0; */
-       /* i_Initialised=0; */
-       /* i_Count=0; */
-       /* i_Sum=0; */
-       s_BoardInfos[dev->minor].i_InterruptFlag = 0;
-       s_BoardInfos[dev->minor].i_Initialised = 0;
-       s_BoardInfos[dev->minor].i_Count = 0;
-       s_BoardInfos[dev->minor].i_Sum = 0;
-
-  /*******************/
-       /*Read the register */
-  /*******************/
-       /* ui_Configuration = inl(devpriv->iobase+i_Offset + 8); */
-       ui_Configuration =
-               inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
-  /*****************************/
-       /*Reset the START and IRQ bit */
-  /*****************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl((ui_Configuration & 0xFFE7FFFF),devpriv->iobase+i_Offset + 8); */
-       outl((ui_Configuration & 0xFFE7FFFF),
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
-       return 0;
-}
-
-/*
- * Does asynchronous acquisition
- * Determines the mode 1 or 2.
- */
-static int apci3200_ai_cmd(struct comedi_device *dev,
-                          struct comedi_subdevice *s)
-{
-       struct addi_private *devpriv = dev->private;
-       struct comedi_cmd *cmd = &s->async->cmd;
-       unsigned int ui_Configuration = 0;
-       /* INT  i_CurrentSource = 0; */
-       unsigned int ui_Trigger = 0;
-       unsigned int ui_TriggerEdge = 0;
-       unsigned int ui_Triggermode = 0;
-       unsigned int ui_ScanMode = 0;
-       unsigned int ui_ConvertTime = 0;
-       unsigned int ui_ConvertTimeBase = 0;
-       unsigned int ui_DelayTime = 0;
-       unsigned int ui_DelayTimeBase = 0;
-       unsigned int ui_DelayMode = 0;
-
-       /* i_FirstChannel=cmd->chanlist[0]; */
-       /* i_LastChannel=cmd->chanlist[1]; */
-       s_BoardInfos[dev->minor].i_FirstChannel = cmd->chanlist[0];
-       s_BoardInfos[dev->minor].i_LastChannel = cmd->chanlist[1];
-       if (cmd->start_src == TRIG_EXT) {
-               ui_Trigger = 1;
-               ui_TriggerEdge = cmd->start_arg & 0xFFFF;
-               ui_Triggermode = cmd->start_arg >> 16;
-       }                       /* if(cmd->start_src==TRIG_EXT) */
-       else {
-               ui_Trigger = 0;
-       }                       /* elseif(cmd->start_src==TRIG_EXT) */
-
-       if (cmd->stop_src == TRIG_COUNT) {
-               ui_ScanMode = 0;
-       }                       /*  if (cmd->stop_src==TRIG_COUNT) */
-       else {
-               ui_ScanMode = 2;
-       }                       /* else if (cmd->stop_src==TRIG_COUNT) */
-
-       if (cmd->scan_begin_src == TRIG_FOLLOW) {
-               ui_DelayTime = 0;
-               ui_DelayTimeBase = 0;
-               ui_DelayMode = 0;
-       }                       /* if(cmd->scan_begin_src==TRIG_FOLLOW) */
-       else {
-               ui_DelayTime = cmd->scan_begin_arg & 0xFFFF;
-               ui_DelayTimeBase = cmd->scan_begin_arg >> 16;
-               ui_DelayMode = 1;
-       }                       /* else if(cmd->scan_begin_src==TRIG_FOLLOW) */
-       if (cmd->convert_src == TRIG_TIMER) {
-               ui_ConvertTime = cmd->convert_arg & 0xFFFF;
-               ui_ConvertTimeBase = cmd->convert_arg >> 16;
-       } else {
-               ui_ConvertTime = 0;
-               ui_ConvertTimeBase = 0;
-       }
-
-       /*  if(i_ADDIDATAType ==1 || ((i_ADDIDATAType==2))) */
-       /*    { */
-  /**************************************************/
-       /*Read the old configuration of the current source */
-  /**************************************************/
-       /* ui_Configuration = inl(devpriv->iobase+i_Offset + 12); */
-       ui_Configuration =
-               inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
-  /***********************************************/
-       /*Write the configuration of the current source */
-  /***********************************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl((ui_Configuration & 0xFFC00000 ), devpriv->iobase+i_Offset +12); */
-       outl((ui_Configuration & 0xFFC00000),
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
-       /*  } */
-       ui_Configuration = 0;
-
-       /* ui_Configuration = i_FirstChannel |(i_LastChannel << 8)| 0x00100000 | */
-       ui_Configuration =
-               s_BoardInfos[dev->minor].i_FirstChannel | (s_BoardInfos[dev->
-                       minor].
-               i_LastChannel << 8) | 0x00100000 | (ui_Trigger << 24) |
-               (ui_TriggerEdge << 25) | (ui_Triggermode << 27) | (ui_DelayMode
-               << 18) | (ui_ScanMode << 16);
-
-  /*************************/
-       /*Write the Configuration */
-  /*************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl( ui_Configuration, devpriv->iobase+i_Offset + 0x8); */
-       outl(ui_Configuration,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x8);
-  /***********************/
-       /*Write the Delay Value */
-  /***********************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(ui_DelayTime,devpriv->iobase+i_Offset + 40); */
-       outl(ui_DelayTime,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 40);
-  /***************************/
-       /*Write the Delay time base */
-  /***************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(ui_DelayTimeBase,devpriv->iobase+i_Offset + 44); */
-       outl(ui_DelayTimeBase,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 44);
-  /*********************************/
-       /*Write the conversion time value */
-  /*********************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(ui_ConvertTime,devpriv->iobase+i_Offset + 32); */
-       outl(ui_ConvertTime,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
-
-  /********************************/
-       /*Write the conversion time base */
-  /********************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(ui_ConvertTimeBase,devpriv->iobase+i_Offset + 36); */
-       outl(ui_ConvertTimeBase,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
-  /*******************/
-       /*Read the register */
-  /*******************/
-       /* ui_Configuration = inl(devpriv->iobase+i_Offset + 4); */
-       ui_Configuration =
-               inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4);
-  /******************/
-       /*Set the SCAN bit */
-  /******************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-
-       /* outl(((ui_Configuration & 0x1E0FF) | 0x00002000),devpriv->iobase+i_Offset + 4); */
-       outl(((ui_Configuration & 0x1E0FF) | 0x00002000),
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4);
-  /*******************/
-       /*Read the register */
-  /*******************/
-       ui_Configuration = 0;
-       /* ui_Configuration = inl(devpriv->iobase+i_Offset + 8); */
-       ui_Configuration =
-               inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
-
-  /*******************/
-       /*Set the START bit */
-  /*******************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl((ui_Configuration | 0x00080000),devpriv->iobase+i_Offset + 8); */
-       outl((ui_Configuration | 0x00080000),
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
-       return 0;
-}
-
-/*
- * This function copies the acquired data(from FIFO) to Comedi buffer.
- */
-static int i_APCI3200_InterruptHandleEos(struct comedi_device *dev)
-{
-       struct addi_private *devpriv = dev->private;
-       struct comedi_subdevice *s = dev->read_subdev;
-       unsigned int ui_StatusRegister = 0;
-
-       /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-       /* comedi_async *async = s->async; */
-       /* UINT *data; */
-       /* data=async->data+async->buf_int_ptr;//new samples added from here onwards */
-       int n = 0, i = 0;
-       /* END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-
-  /************************************/
-       /*Read the interrupt status register */
-  /************************************/
-       /* ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16); */
-       ui_StatusRegister =
-               inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 16);
-
-  /*************************/
-       /*Test if interrupt occur */
-  /*************************/
-
-       if ((ui_StatusRegister & 0x2) == 0x2) {
-      /*************************/
-               /*Read the channel number */
-      /*************************/
-               /* ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24); */
-               /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-               /* This value is not used */
-               /* ui_ChannelNumber = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 24); */
-               /* END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-
-      /*************************************/
-               /*Read the digital Analog Input value */
-      /*************************************/
-
-               /* data[i_Count] = inl(devpriv->iobase+i_Offset + 28); */
-               /* Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-               /* data[s_BoardInfos [dev->minor].i_Count] = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 28); */
-               s_BoardInfos[dev->minor].ui_ScanValueArray[s_BoardInfos[dev->
-                               minor].i_Count] =
-                       inl(devpriv->iobase +
-                       s_BoardInfos[dev->minor].i_Offset + 28);
-               /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-
-               /* if((i_Count == (i_LastChannel-i_FirstChannel+3))) */
-               if ((s_BoardInfos[dev->minor].i_Count ==
-                               (s_BoardInfos[dev->minor].i_LastChannel -
-                                       s_BoardInfos[dev->minor].
-                                       i_FirstChannel + 3))) {
-
-                       /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-                       s_BoardInfos[dev->minor].i_Count++;
-
-                       for (i = s_BoardInfos[dev->minor].i_FirstChannel;
-                               i <= s_BoardInfos[dev->minor].i_LastChannel;
-                               i++) {
-                               i_APCI3200_GetChannelCalibrationValue(dev, i,
-                                       &s_BoardInfos[dev->minor].
-                                       ui_ScanValueArray[s_BoardInfos[dev->
-                                                       minor].i_Count + ((i -
-                                                               s_BoardInfos
-                                                               [dev->minor].
-                                                               i_FirstChannel)
-                                                       * 3)],
-                                       &s_BoardInfos[dev->minor].
-                                       ui_ScanValueArray[s_BoardInfos[dev->
-                                                       minor].i_Count + ((i -
-                                                               s_BoardInfos
-                                                               [dev->minor].
-                                                               i_FirstChannel)
-                                                       * 3) + 1],
-                                       &s_BoardInfos[dev->minor].
-                                       ui_ScanValueArray[s_BoardInfos[dev->
-                                                       minor].i_Count + ((i -
-                                                               s_BoardInfos
-                                                               [dev->minor].
-                                                               i_FirstChannel)
-                                                       * 3) + 2]);
-                       }
-
-                       /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-
-                       /* i_Count=-1; */
-
-                       s_BoardInfos[dev->minor].i_Count = -1;
-
-                       /* async->buf_int_count+=(i_LastChannel-i_FirstChannel+4)*sizeof(unsigned int); */
-                       /* Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-                       /* async->buf_int_count+=(s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+4)*sizeof(unsigned int); */
-                       /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-                       /* async->buf_int_ptr+=(i_LastChannel-i_FirstChannel+4)*sizeof(unsigned int); */
-                       /* Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-                       /* async->buf_int_ptr+=(s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+4)*sizeof(unsigned int); */
-                       /* comedi_eos(dev,s); */
-
-                       /*  Set the event type (Comedi Buffer End Of Scan) */
-                       s->async->events |= COMEDI_CB_EOS;
-
-                       /*  Test if enougth memory is available and allocate it for 7 values */
-                       n = comedi_buf_write_alloc(s,
-                               (7 + 12) * sizeof(unsigned int));
-
-                       /*  If not enough memory available, event is set to Comedi Buffer Error */
-                       if (n > ((7 + 12) * sizeof(unsigned int))) {
-                               printk("\ncomedi_buf_write_alloc n = %i", n);
-                               s->async->events |= COMEDI_CB_ERROR;
-                       }
-                       /*  Write all 7 scan values in the comedi buffer */
-                       comedi_buf_memcpy_to(s, 0,
-                               (unsigned int *) s_BoardInfos[dev->minor].
-                               ui_ScanValueArray, (7 + 12) * sizeof(unsigned int));
-
-                       /*  Update comedi buffer pinters indexes */
-                       comedi_buf_write_free(s,
-                               (7 + 12) * sizeof(unsigned int));
-
-                       /*  Send events */
-                       comedi_event(dev, s);
-                       /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-
-                       /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-                       /*  */
-                       /* if (s->async->buf_int_ptr>=s->async->data_len) //  for buffer rool over */
-                       /*   { */
-                       /*     /* buffer rollover */ */
-                       /*     s->async->buf_int_ptr=0; */
-                       /*     comedi_eobuf(dev,s); */
-                       /*   } */
-                       /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-               }
-               /* i_Count++; */
-               s_BoardInfos[dev->minor].i_Count++;
-       }
-       /* i_InterruptFlag=0; */
-       s_BoardInfos[dev->minor].i_InterruptFlag = 0;
-       return 0;
-}
-
-static void apci3200_interrupt(int irq, void *d)
-{
-       struct comedi_device *dev = d;
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_StatusRegister = 0;
-       unsigned int ui_ChannelNumber = 0;
-       int i_CalibrationFlag = 0;
-       int i_CJCFlag = 0;
-       unsigned int ui_DummyValue = 0;
-       unsigned int ui_DigitalTemperature = 0;
-       unsigned int ui_DigitalInput = 0;
-       int i_ConvertCJCCalibration;
-       /* BEGIN JK TEST */
-       int i_ReturnValue = 0;
-       /* END JK TEST */
-
-       /* switch(i_ScanType) */
-       switch (s_BoardInfos[dev->minor].i_ScanType) {
-       case 0:
-       case 1:
-               /* switch(i_ADDIDATAType) */
-               switch (s_BoardInfos[dev->minor].i_ADDIDATAType) {
-               case 0:
-               case 1:
-
-         /************************************/
-                       /*Read the interrupt status register */
-         /************************************/
-                       /* ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16); */
-                       ui_StatusRegister =
-                               inl(devpriv->iobase +
-                               s_BoardInfos[dev->minor].i_Offset + 16);
-                       if ((ui_StatusRegister & 0x2) == 0x2) {
-                               /* i_CalibrationFlag = ((inl(devpriv->iobase+i_Offset + 12) & 0x00060000) >> 17); */
-                               i_CalibrationFlag =
-                                       ((inl(devpriv->iobase +
-                                                       s_BoardInfos[dev->
-                                                               minor].
-                                                       i_Offset +
-                                                       12) & 0x00060000) >>
-                                       17);
-             /*************************/
-                               /*Read the channel number */
-             /*************************/
-                               /* ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24); */
-
-             /*************************************/
-                               /*Read the digital analog input value */
-             /*************************************/
-                               /* ui_DigitalInput = inl(devpriv->iobase+i_Offset + 28); */
-                               ui_DigitalInput =
-                                       inl(devpriv->iobase +
-                                       s_BoardInfos[dev->minor].i_Offset + 28);
-
-             /***********************************************/
-                               /* Test if the value read is the channel value */
-             /***********************************************/
-                               if (i_CalibrationFlag == 0) {
-                                       /* ui_InterruptChannelValue[i_Count + 0] = ui_DigitalInput; */
-                                       s_BoardInfos[dev->minor].
-                                               ui_InterruptChannelValue
-                                               [s_BoardInfos[dev->minor].
-                                               i_Count + 0] = ui_DigitalInput;
-
-                                       /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-                                       /*
-                                          i_APCI3200_GetChannelCalibrationValue (dev, s_BoardInfos [dev->minor].ui_Channel_num,
-                                          &s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 6],
-                                          &s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 7],
-                                          &s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 8]);
-                                        */
-                                       /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-
-                 /******************************************************/
-                                       /*Start the conversion of the calibration offset value */
-                 /******************************************************/
-                                       i_APCI3200_ReadCalibrationOffsetValue
-                                               (dev, &ui_DummyValue);
-                               }       /* if (i_CalibrationFlag == 0) */
-             /**********************************************************/
-                               /* Test if the value read is the calibration offset value */
-             /**********************************************************/
-
-                               if (i_CalibrationFlag == 1) {
-
-                 /******************/
-                                       /* Save the value */
-                 /******************/
-
-                                       /* ui_InterruptChannelValue[i_Count + 1] = ui_DigitalInput; */
-                                       s_BoardInfos[dev->minor].
-                                               ui_InterruptChannelValue
-                                               [s_BoardInfos[dev->minor].
-                                               i_Count + 1] = ui_DigitalInput;
-
-                 /******************************************************/
-                                       /* Start the conversion of the calibration gain value */
-                 /******************************************************/
-                                       i_APCI3200_ReadCalibrationGainValue(dev,
-                                               &ui_DummyValue);
-                               }       /* if (i_CalibrationFlag == 1) */
-             /******************************************************/
-                               /*Test if the value read is the calibration gain value */
-             /******************************************************/
-
-                               if (i_CalibrationFlag == 2) {
-
-                 /****************/
-                                       /*Save the value */
-                 /****************/
-                                       /* ui_InterruptChannelValue[i_Count + 2] = ui_DigitalInput; */
-                                       s_BoardInfos[dev->minor].
-                                               ui_InterruptChannelValue
-                                               [s_BoardInfos[dev->minor].
-                                               i_Count + 2] = ui_DigitalInput;
-                                       /* if(i_ScanType==1) */
-                                       if (s_BoardInfos[dev->minor].
-                                               i_ScanType == 1) {
-
-                                               /* i_InterruptFlag=0; */
-                                               s_BoardInfos[dev->minor].
-                                                       i_InterruptFlag = 0;
-                                               /* i_Count=i_Count + 6; */
-                                               /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-                                               /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count + 6; */
-                                               s_BoardInfos[dev->minor].
-                                                       i_Count =
-                                                       s_BoardInfos[dev->
-                                                       minor].i_Count + 9;
-                                               /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-                                       }       /* if(i_ScanType==1) */
-                                       else {
-                                               /* i_Count=0; */
-                                               s_BoardInfos[dev->minor].
-                                                       i_Count = 0;
-                                       }       /* elseif(i_ScanType==1) */
-                                       /* if(i_ScanType!=1) */
-                                       if (s_BoardInfos[dev->minor].
-                                               i_ScanType != 1) {
-                                               i_ReturnValue = send_sig(SIGIO, devpriv->tsk_Current, 0);       /*  send signal to the sample */
-                                       }       /* if(i_ScanType!=1) */
-                                       else {
-                                               /* if(i_ChannelCount==i_Sum) */
-                                               if (s_BoardInfos[dev->minor].
-                                                       i_ChannelCount ==
-                                                       s_BoardInfos[dev->
-                                                               minor].i_Sum) {
-                                                       send_sig(SIGIO, devpriv->tsk_Current, 0);       /*  send signal to the sample */
-                                               }
-                                       }       /* if(i_ScanType!=1) */
-                               }       /* if (i_CalibrationFlag == 2) */
-                       }       /*  if ((ui_StatusRegister & 0x2) == 0x2) */
-
-                       break;
-
-               case 2:
-         /************************************/
-                       /*Read the interrupt status register */
-         /************************************/
-
-                       /* ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16); */
-                       ui_StatusRegister =
-                               inl(devpriv->iobase +
-                               s_BoardInfos[dev->minor].i_Offset + 16);
-         /*************************/
-                       /*Test if interrupt occur */
-         /*************************/
-
-                       if ((ui_StatusRegister & 0x2) == 0x2) {
-
-                               /* i_CJCFlag = ((inl(devpriv->iobase+i_Offset + 4) & 0x00000400) >> 10); */
-                               i_CJCFlag =
-                                       ((inl(devpriv->iobase +
-                                                       s_BoardInfos[dev->
-                                                               minor].
-                                                       i_Offset +
-                                                       4) & 0x00000400) >> 10);
-
-                               /* i_CalibrationFlag = ((inl(devpriv->iobase+i_Offset + 12) & 0x00060000) >> 17); */
-                               i_CalibrationFlag =
-                                       ((inl(devpriv->iobase +
-                                                       s_BoardInfos[dev->
-                                                               minor].
-                                                       i_Offset +
-                                                       12) & 0x00060000) >>
-                                       17);
-
-             /*************************/
-                               /*Read the channel number */
-             /*************************/
-
-                               /* ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24); */
-                               ui_ChannelNumber =
-                                       inl(devpriv->iobase +
-                                       s_BoardInfos[dev->minor].i_Offset + 24);
-                               /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-                               s_BoardInfos[dev->minor].ui_Channel_num =
-                                       ui_ChannelNumber;
-                               /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-
-             /************************************/
-                               /*Read the digital temperature value */
-             /************************************/
-                               /* ui_DigitalTemperature = inl(devpriv->iobase+i_Offset + 28); */
-                               ui_DigitalTemperature =
-                                       inl(devpriv->iobase +
-                                       s_BoardInfos[dev->minor].i_Offset + 28);
-
-             /*********************************************/
-                               /*Test if the value read is the channel value */
-             /*********************************************/
-
-                               if ((i_CalibrationFlag == 0)
-                                       && (i_CJCFlag == 0)) {
-                                       /* ui_InterruptChannelValue[i_Count + 0]=ui_DigitalTemperature; */
-                                       s_BoardInfos[dev->minor].
-                                               ui_InterruptChannelValue
-                                               [s_BoardInfos[dev->minor].
-                                               i_Count + 0] =
-                                               ui_DigitalTemperature;
-
-                 /*********************************/
-                                       /*Start the conversion of the CJC */
-                 /*********************************/
-                                       i_APCI3200_ReadCJCValue(dev,
-                                               &ui_DummyValue);
-
-                               }       /* if ((i_CalibrationFlag == 0) && (i_CJCFlag == 0)) */
-
-                /*****************************************/
-                               /*Test if the value read is the CJC value */
-                /*****************************************/
-
-                               if ((i_CJCFlag == 1)
-                                       && (i_CalibrationFlag == 0)) {
-                                       /* ui_InterruptChannelValue[i_Count + 3]=ui_DigitalTemperature; */
-                                       s_BoardInfos[dev->minor].
-                                               ui_InterruptChannelValue
-                                               [s_BoardInfos[dev->minor].
-                                               i_Count + 3] =
-                                               ui_DigitalTemperature;
-
-                 /******************************************************/
-                                       /*Start the conversion of the calibration offset value */
-                 /******************************************************/
-                                       i_APCI3200_ReadCalibrationOffsetValue
-                                               (dev, &ui_DummyValue);
-                               }       /*  if ((i_CJCFlag == 1) && (i_CalibrationFlag == 0)) */
-
-                /********************************************************/
-                               /*Test if the value read is the calibration offset value */
-                /********************************************************/
-
-                               if ((i_CalibrationFlag == 1)
-                                       && (i_CJCFlag == 0)) {
-                                       /* ui_InterruptChannelValue[i_Count + 1]=ui_DigitalTemperature; */
-                                       s_BoardInfos[dev->minor].
-                                               ui_InterruptChannelValue
-                                               [s_BoardInfos[dev->minor].
-                                               i_Count + 1] =
-                                               ui_DigitalTemperature;
-
-                 /****************************************************/
-                                       /*Start the conversion of the calibration gain value */
-                 /****************************************************/
-                                       i_APCI3200_ReadCalibrationGainValue(dev,
-                                               &ui_DummyValue);
-
-                               }       /* if ((i_CalibrationFlag == 1) && (i_CJCFlag == 0)) */
-
-             /******************************************************/
-                               /*Test if the value read is the calibration gain value */
-             /******************************************************/
-
-                               if ((i_CalibrationFlag == 2)
-                                       && (i_CJCFlag == 0)) {
-                                       /* ui_InterruptChannelValue[i_Count + 2]=ui_DigitalTemperature; */
-                                       s_BoardInfos[dev->minor].
-                                               ui_InterruptChannelValue
-                                               [s_BoardInfos[dev->minor].
-                                               i_Count + 2] =
-                                               ui_DigitalTemperature;
-
-                 /**********************************************************/
-                                       /*Test if the Calibration channel must be read for the CJC */
-                 /**********************************************************/
-
-                                       /*Test if the polarity is the same */
-                 /**********************************/
-                                       /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */
-                                       if (s_BoardInfos[dev->minor].
-                                               i_CJCPolarity !=
-                                               s_BoardInfos[dev->minor].
-                                               i_ADDIDATAPolarity) {
-                                               i_ConvertCJCCalibration = 1;
-                                       }       /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */
-                                       else {
-                                               /* if(i_CJCGain==i_ADDIDATAGain) */
-                                               if (s_BoardInfos[dev->minor].
-                                                       i_CJCGain ==
-                                                       s_BoardInfos[dev->
-                                                               minor].
-                                                       i_ADDIDATAGain) {
-                                                       i_ConvertCJCCalibration
-                                                               = 0;
-                                               }       /* if(i_CJCGain==i_ADDIDATAGain) */
-                                               else {
-                                                       i_ConvertCJCCalibration
-                                                               = 1;
-                                               }       /* elseif(i_CJCGain==i_ADDIDATAGain) */
-                                       }       /* elseif(i_CJCPolarity!=i_ADDIDATAPolarity) */
-                                       if (i_ConvertCJCCalibration == 1) {
-                     /****************************************************************/
-                                               /*Start the conversion of the calibration gain value for the CJC */
-                     /****************************************************************/
-                                               i_APCI3200_ReadCJCCalOffset(dev,
-                                                       &ui_DummyValue);
-
-                                       }       /* if(i_ConvertCJCCalibration==1) */
-                                       else {
-                                               /* ui_InterruptChannelValue[i_Count + 4]=0; */
-                                               /* ui_InterruptChannelValue[i_Count + 5]=0; */
-                                               s_BoardInfos[dev->minor].
-                                                       ui_InterruptChannelValue
-                                                       [s_BoardInfos[dev->
-                                                               minor].i_Count +
-                                                       4] = 0;
-                                               s_BoardInfos[dev->minor].
-                                                       ui_InterruptChannelValue
-                                                       [s_BoardInfos[dev->
-                                                               minor].i_Count +
-                                                       5] = 0;
-                                       }       /* elseif(i_ConvertCJCCalibration==1) */
-                               }       /* else if ((i_CalibrationFlag == 2) && (i_CJCFlag == 0)) */
-
-                /********************************************************************/
-                               /*Test if the value read is the calibration offset value for the CJC */
-                /********************************************************************/
-
-                               if ((i_CalibrationFlag == 1)
-                                       && (i_CJCFlag == 1)) {
-                                       /* ui_InterruptChannelValue[i_Count + 4]=ui_DigitalTemperature; */
-                                       s_BoardInfos[dev->minor].
-                                               ui_InterruptChannelValue
-                                               [s_BoardInfos[dev->minor].
-                                               i_Count + 4] =
-                                               ui_DigitalTemperature;
-
-                 /****************************************************************/
-                                       /*Start the conversion of the calibration gain value for the CJC */
-                 /****************************************************************/
-                                       i_APCI3200_ReadCJCCalGain(dev,
-                                               &ui_DummyValue);
-
-                               }       /* if ((i_CalibrationFlag == 1) && (i_CJCFlag == 1)) */
-
-             /******************************************************************/
-                               /*Test if the value read is the calibration gain value for the CJC */
-             /******************************************************************/
-
-                               if ((i_CalibrationFlag == 2)
-                                       && (i_CJCFlag == 1)) {
-                                       /* ui_InterruptChannelValue[i_Count + 5]=ui_DigitalTemperature; */
-                                       s_BoardInfos[dev->minor].
-                                               ui_InterruptChannelValue
-                                               [s_BoardInfos[dev->minor].
-                                               i_Count + 5] =
-                                               ui_DigitalTemperature;
-
-                                       /* if(i_ScanType==1) */
-                                       if (s_BoardInfos[dev->minor].
-                                               i_ScanType == 1) {
-
-                                               /* i_InterruptFlag=0; */
-                                               s_BoardInfos[dev->minor].
-                                                       i_InterruptFlag = 0;
-                                               /* i_Count=i_Count + 6; */
-                                               /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-                                               /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count + 6; */
-                                               s_BoardInfos[dev->minor].
-                                                       i_Count =
-                                                       s_BoardInfos[dev->
-                                                       minor].i_Count + 9;
-                                               /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-                                       }       /* if(i_ScanType==1) */
-                                       else {
-                                               /* i_Count=0; */
-                                               s_BoardInfos[dev->minor].
-                                                       i_Count = 0;
-                                       }       /* elseif(i_ScanType==1) */
-
-                                       /* if(i_ScanType!=1) */
-                                       if (s_BoardInfos[dev->minor].
-                                               i_ScanType != 1) {
-                                               send_sig(SIGIO, devpriv->tsk_Current, 0);       /*  send signal to the sample */
-                                       }       /* if(i_ScanType!=1) */
-                                       else {
-                                               /* if(i_ChannelCount==i_Sum) */
-                                               if (s_BoardInfos[dev->minor].
-                                                       i_ChannelCount ==
-                                                       s_BoardInfos[dev->
-                                                               minor].i_Sum) {
-                                                       send_sig(SIGIO, devpriv->tsk_Current, 0);       /*  send signal to the sample */
-
-                                               }       /* if(i_ChannelCount==i_Sum) */
-                                       }       /* else if(i_ScanType!=1) */
-                               }       /* if ((i_CalibrationFlag == 2) && (i_CJCFlag == 1)) */
-
-                       }       /* else if ((ui_StatusRegister & 0x2) == 0x2) */
-                       break;
-               }               /* switch(i_ADDIDATAType) */
-               break;
-       case 2:
-       case 3:
-               i_APCI3200_InterruptHandleEos(dev);
-               break;
-       }                       /* switch(i_ScanType) */
-       return;
-}
diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c
deleted file mode 100644 (file)
index af70c84..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-#include <linux/module.h>
-#include <linux/pci.h>
-
-#include "../comedidev.h"
-#include "comedi_fc.h"
-#include "amcc_s5933.h"
-
-#include "addi-data/addi_common.h"
-
-#define ADDIDATA_WATCHDOG 2    /*  Or shold it be something else */
-
-#include "addi-data/addi_eeprom.c"
-#include "addi-data/hwdrv_apci035.c"
-#include "addi-data/addi_common.c"
-
-static const struct addi_board apci035_boardtypes[] = {
-       {
-               .pc_DriverName          = "apci035",
-               .i_IorangeBase1         = APCI035_ADDRESS_RANGE,
-               .i_PCIEeprom            = 1,
-               .pc_EepromChip          = "S5920",
-               .i_NbrAiChannel         = 16,
-               .i_NbrAiChannelDiff     = 8,
-               .i_AiChannelList        = 16,
-               .i_AiMaxdata            = 0xff,
-               .pr_AiRangelist         = &range_apci035_ai,
-               .i_Timer                = 1,
-               .ui_MinAcquisitiontimeNs = 10000,
-               .ui_MinDelaytimeNs      = 100000,
-               .interrupt              = apci035_interrupt,
-               .reset                  = apci035_reset,
-               .ai_config              = apci035_ai_config,
-               .ai_read                = apci035_ai_read,
-               .timer_config           = apci035_timer_config,
-               .timer_write            = apci035_timer_write,
-               .timer_read             = apci035_timer_read,
-       },
-};
-
-static int apci035_auto_attach(struct comedi_device *dev,
-                              unsigned long context)
-{
-       dev->board_ptr = &apci035_boardtypes[0];
-
-       return addi_auto_attach(dev, context);
-}
-
-static struct comedi_driver apci035_driver = {
-       .driver_name    = "addi_apci_035",
-       .module         = THIS_MODULE,
-       .auto_attach    = apci035_auto_attach,
-       .detach         = i_ADDI_Detach,
-};
-
-static int apci035_pci_probe(struct pci_dev *dev,
-                            const struct pci_device_id *id)
-{
-       return comedi_pci_auto_config(dev, &apci035_driver, id->driver_data);
-}
-
-static const struct pci_device_id apci035_pci_table[] = {
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA,  0x0300) },
-       { 0 }
-};
-MODULE_DEVICE_TABLE(pci, apci035_pci_table);
-
-static struct pci_driver apci035_pci_driver = {
-       .name           = "addi_apci_035",
-       .id_table       = apci035_pci_table,
-       .probe          = apci035_pci_probe,
-       .remove         = comedi_pci_auto_unconfig,
-};
-module_comedi_pci_driver(apci035_driver, apci035_pci_driver);
-
-MODULE_AUTHOR("Comedi http://www.comedi.org");
-MODULE_DESCRIPTION("Comedi low-level driver");
-MODULE_LICENSE("GPL");
index 840cb28..bf14165 100644 (file)
@@ -258,9 +258,8 @@ static irqreturn_t apci1032_interrupt(int irq, void *d)
        outl(ctrl & ~APCI1032_CTRL_INT_ENA, dev->iobase + APCI1032_CTRL_REG);
 
        s->state = inl(dev->iobase + APCI1032_STATUS_REG) & 0xffff;
-       comedi_buf_put(s, s->state);
-       s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
-       comedi_event(dev, s);
+       comedi_buf_write_samples(s, &s->state, 1);
+       comedi_handle_events(dev, s);
 
        /* enable the interrupt */
        outl(ctrl, dev->iobase + APCI1032_CTRL_REG);
index b7a284a..de8d74f 100644 (file)
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
 
 #include "../comedidev.h"
 #include "comedi_fc.h"
 #include "amcc_s5933.h"
 
-#include "addi-data/addi_common.h"
+struct apci1500_private {
+       int iobase;
+       int i_IobaseAmcc;
+       int i_IobaseAddon;
+       int i_IobaseReserved;
+       unsigned char b_OutputMemoryStatus;
+       struct task_struct *tsk_Current;
+};
 
-#include "addi-data/addi_eeprom.c"
 #include "addi-data/hwdrv_apci1500.c"
-#include "addi-data/addi_common.c"
-
-static const struct addi_board apci1500_boardtypes[] = {
-       {
-               .pc_DriverName          = "apci1500",
-               .i_IorangeBase1         = APCI1500_ADDRESS_RANGE,
-               .i_PCIEeprom            = 0,
-               .i_NbrDiChannel         = 16,
-               .i_NbrDoChannel         = 16,
-               .i_DoMaxdata            = 0xffff,
-               .i_Timer                = 1,
-               .interrupt              = apci1500_interrupt,
-               .reset                  = apci1500_reset,
-               .di_config              = apci1500_di_config,
-               .di_read                = apci1500_di_read,
-               .di_write               = apci1500_di_write,
-               .di_bits                = apci1500_di_insn_bits,
-               .do_config              = apci1500_do_config,
-               .do_write               = apci1500_do_write,
-               .do_bits                = apci1500_do_bits,
-               .timer_config           = apci1500_timer_config,
-               .timer_write            = apci1500_timer_write,
-               .timer_read             = apci1500_timer_read,
-               .timer_bits             = apci1500_timer_bits,
-       },
-};
 
 static int apci1500_auto_attach(struct comedi_device *dev,
                                unsigned long context)
 {
-       dev->board_ptr = &apci1500_boardtypes[0];
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+       struct apci1500_private *devpriv;
+       struct comedi_subdevice *s;
+       int ret;
+
+       devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
+       if (!devpriv)
+               return -ENOMEM;
+
+       ret = comedi_pci_enable(dev);
+       if (ret)
+               return ret;
+
+       dev->iobase = pci_resource_start(pcidev, 1);
+       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);
+
+       if (pcidev->irq > 0) {
+               ret = request_irq(pcidev->irq, apci1500_interrupt, IRQF_SHARED,
+                                 dev->board_name, dev);
+               if (ret == 0)
+                       dev->irq = pcidev->irq;
+       }
+
+       ret = comedi_alloc_subdevices(dev, 3);
+       if (ret)
+               return ret;
 
-       return addi_auto_attach(dev, context);
+       /*  Allocate and Initialise DI Subdevice Structures */
+       s = &dev->subdevices[0];
+       s->type = COMEDI_SUBD_DI;
+       s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON;
+       s->n_chan = 16;
+       s->maxdata = 1;
+       s->range_table = &range_digital;
+       s->insn_config = apci1500_di_config;
+       s->insn_read = apci1500_di_read;
+       s->insn_write = apci1500_di_write;
+       s->insn_bits = apci1500_di_insn_bits;
+
+       /*  Allocate and Initialise DO Subdevice Structures */
+       s = &dev->subdevices[1];
+       s->type = COMEDI_SUBD_DO;
+       s->subdev_flags =
+               SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
+       s->n_chan = 16;
+       s->maxdata = 1;
+       s->range_table = &range_digital;
+       s->insn_config = apci1500_do_config;
+       s->insn_write = apci1500_do_write;
+       s->insn_bits = apci1500_do_bits;
+
+       /*  Allocate and Initialise Timer Subdevice Structures */
+       s = &dev->subdevices[2];
+       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 = apci1500_timer_write;
+       s->insn_read = apci1500_timer_read;
+       s->insn_config = apci1500_timer_config;
+       s->insn_bits = apci1500_timer_bits;
+
+       apci1500_reset(dev);
+
+       return 0;
+}
+
+static void apci1500_detach(struct comedi_device *dev)
+{
+       if (dev->iobase)
+               apci1500_reset(dev);
+       comedi_pci_detach(dev);
 }
 
 static struct comedi_driver apci1500_driver = {
        .driver_name    = "addi_apci_1500",
        .module         = THIS_MODULE,
        .auto_attach    = apci1500_auto_attach,
-       .detach         = i_ADDI_Detach,
+       .detach         = apci1500_detach,
 };
 
 static int apci1500_pci_probe(struct pci_dev *dev,
index 688b015..c328230 100644 (file)
@@ -37,7 +37,6 @@ struct apci1564_private {
        unsigned int mode2;             /* falling-edge/low level channels */
        unsigned int ctrl;              /* interrupt mode OR (edge) . AND (level) */
        unsigned char timer_select_mode;
-       unsigned char mode_select_register;
        struct task_struct *tsk_current;
 };
 
@@ -65,10 +64,9 @@ static int apci1564_reset(struct comedi_device *dev)
        outl(0x0, devpriv->amcc_iobase + APCI1564_TIMER_RELOAD_REG);
 
        /* Reset the counter registers */
-       outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(APCI1564_COUNTER1));
-       outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(APCI1564_COUNTER2));
-       outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(APCI1564_COUNTER3));
-       outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(APCI1564_COUNTER4));
+       outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(0));
+       outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(1));
+       outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(2));
 
        return 0;
 }
@@ -95,9 +93,8 @@ static irqreturn_t apci1564_interrupt(int irq, void *d)
 
                s->state = inl(dev->iobase + APCI1564_DI_INT_STATUS_REG)
                               & 0xffff;
-               comedi_buf_put(s, s->state);
-               s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
-               comedi_event(dev, s);
+               comedi_buf_write_samples(s, &s->state, 1);
+               comedi_handle_events(dev, s);
 
                /* enable the interrupt */
                outl(status, devpriv->amcc_iobase + APCI1564_DI_IRQ_REG);
@@ -435,9 +432,8 @@ static int apci1564_auto_attach(struct comedi_device *dev,
        s = &dev->subdevices[3];
        s->type         = COMEDI_SUBD_TIMER;
        s->subdev_flags = SDF_WRITEABLE;
-       s->n_chan       = 1;
+       s->n_chan       = 3;
        s->maxdata      = 0;
-       s->len_chanlist = 1;
        s->range_table  = &range_digital;
        s->insn_write   = apci1564_timer_write;
        s->insn_read    = apci1564_timer_read;
index aea3da3..7a5659f 100644 (file)
@@ -178,7 +178,6 @@ static irqreturn_t apci2032_interrupt(int irq, void *d)
        struct comedi_cmd *cmd = &s->async->cmd;
        struct apci2032_int_private *subpriv;
        unsigned int val;
-       bool do_event = false;
 
        if (!dev->attached)
                return IRQ_NONE;
@@ -212,27 +211,21 @@ static irqreturn_t apci2032_interrupt(int irq, void *d)
                                bits |= (1 << i);
                }
 
-               if (comedi_buf_put(s, bits)) {
-                       s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
+               if (comedi_buf_write_samples(s, &bits, 1)) {
                        if (cmd->stop_src == TRIG_COUNT &&
                            subpriv->stop_count > 0) {
                                subpriv->stop_count--;
                                if (subpriv->stop_count == 0) {
                                        /* end of acquisition */
                                        s->async->events |= COMEDI_CB_EOA;
-                                       apci2032_int_stop(dev, s);
                                }
                        }
-               } else {
-                       apci2032_int_stop(dev, s);
-                       s->async->events |= COMEDI_CB_OVERFLOW;
                }
-               do_event = true;
        }
 
        spin_unlock(&subpriv->spinlock);
-       if (do_event)
-               comedi_event(dev, s);
+
+       comedi_handle_events(dev, s);
 
        return IRQ_HANDLED;
 }
@@ -303,7 +296,7 @@ static int apci2032_auto_attach(struct comedi_device *dev,
                        return -ENOMEM;
                spin_lock_init(&subpriv->spinlock);
                s->private      = subpriv;
-               s->subdev_flags = SDF_READABLE | SDF_CMD_READ;
+               s->subdev_flags = SDF_READABLE | SDF_CMD_READ | SDF_PACKED;
                s->len_chanlist = 2;
                s->do_cmdtest   = apci2032_int_cmdtest;
                s->do_cmd       = apci2032_int_cmd;
index ba71e24..e5dbbdf 100644 (file)
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
 
 #include "../comedidev.h"
 #include "comedi_fc.h"
 #include "amcc_s5933.h"
 
-#include "addi-data/addi_common.h"
+/*
+ * PCI BAR 0 register map (devpriv->amcc)
+ * see amcc_s5933.h for register and bit defines
+ */
 
-#include "addi-data/hwdrv_apci3120.c"
+/*
+ * PCI BAR 1 register map (dev->iobase)
+ */
+#define APCI3120_AO_REG(x)                     (0x08 + (((x) / 4) * 2))
+#define APCI3120_AO_MUX(x)                     (((x) & 0x3) << 14)
+#define APCI3120_AO_DATA(x)                    ((x) << 0)
+
+/*
+ * PCI BAR 2 register map (devpriv->addon)
+ */
 
 enum apci3120_boardid {
        BOARD_APCI3120,
        BOARD_APCI3001,
 };
 
-static const struct addi_board apci3120_boardtypes[] = {
+struct apci3120_board {
+       const char *name;
+       unsigned int ai_is_16bit:1;
+       unsigned int has_ao:1;
+};
+
+static const struct apci3120_board apci3120_boardtypes[] = {
        [BOARD_APCI3120] = {
-               .pc_DriverName          = "apci3120",
-               .i_NbrAiChannel         = 16,
-               .i_NbrAiChannelDiff     = 8,
-               .i_AiChannelList        = 16,
-               .i_NbrAoChannel         = 8,
-               .i_AiMaxdata            = 0xffff,
-               .i_AoMaxdata            = 0x3fff,
-               .i_NbrDiChannel         = 4,
-               .i_NbrDoChannel         = 4,
-               .i_DoMaxdata            = 0x0f,
-               .interrupt              = apci3120_interrupt,
+               .name           = "apci3120",
+               .ai_is_16bit    = 1,
+               .has_ao         = 1,
        },
        [BOARD_APCI3001] = {
-               .pc_DriverName          = "apci3001",
-               .i_NbrAiChannel         = 16,
-               .i_NbrAiChannelDiff     = 8,
-               .i_AiChannelList        = 16,
-               .i_AiMaxdata            = 0xfff,
-               .i_NbrDiChannel         = 4,
-               .i_NbrDoChannel         = 4,
-               .i_DoMaxdata            = 0x0f,
-               .interrupt              = apci3120_interrupt,
+               .name           = "apci3001",
        },
 };
 
-static irqreturn_t v_ADDI_Interrupt(int irq, void *d)
+struct apci3120_dmabuf {
+       unsigned short *virt;
+       dma_addr_t hw;
+       unsigned int size;
+       unsigned int use_size;
+};
+
+struct apci3120_private {
+       unsigned long amcc;
+       unsigned long addon;
+       unsigned int ui_AiActualScan;
+       unsigned int ui_AiNbrofChannels;
+       unsigned int ui_AiChannelList[32];
+       unsigned int ui_AiReadData[32];
+       unsigned short us_UseDma;
+       unsigned char b_DmaDoubleBuffer;
+       unsigned int ui_DmaActualBuffer;
+       struct apci3120_dmabuf dmabuf[2];
+       unsigned char b_DigitalOutputRegister;
+       unsigned char b_TimerSelectMode;
+       unsigned char b_ModeSelectRegister;
+       unsigned short us_OutputRegister;
+       unsigned char b_Timer2Mode;
+       unsigned char b_Timer2Interrupt;
+       unsigned int ai_running:1;
+       unsigned char b_InterruptMode;
+       unsigned char b_EocEosInterrupt;
+       unsigned int ui_EocEosConversionTime;
+       unsigned char b_ExttrigEnable;
+       struct task_struct *tsk_Current;
+};
+
+#include "addi-data/hwdrv_apci3120.c"
+
+static void apci3120_dma_alloc(struct comedi_device *dev)
+{
+       struct apci3120_private *devpriv = dev->private;
+       struct apci3120_dmabuf *dmabuf;
+       int order;
+       int i;
+
+       for (i = 0; i < 2; i++) {
+               dmabuf = &devpriv->dmabuf[i];
+               for (order = 2; order >= 0; order--) {
+                       dmabuf->virt = dma_alloc_coherent(dev->hw_dev,
+                                                         PAGE_SIZE << order,
+                                                         &dmabuf->hw,
+                                                         GFP_KERNEL);
+                       if (dmabuf->virt)
+                               break;
+               }
+               if (!dmabuf->virt)
+                       break;
+               dmabuf->size = PAGE_SIZE << order;
+
+               if (i == 0)
+                       devpriv->us_UseDma = 1;
+               if (i == 1)
+                       devpriv->b_DmaDoubleBuffer = 1;
+       }
+}
+
+static void apci3120_dma_free(struct comedi_device *dev)
 {
-       struct comedi_device *dev = d;
-       const struct addi_board *this_board = dev->board_ptr;
+       struct apci3120_private *devpriv = dev->private;
+       struct apci3120_dmabuf *dmabuf;
+       int i;
 
-       this_board->interrupt(irq, d);
-       return IRQ_RETVAL(1);
+       if (!devpriv)
+               return;
+
+       for (i = 0; i < 2; i++) {
+               dmabuf = &devpriv->dmabuf[i];
+               if (dmabuf->virt) {
+                       dma_free_coherent(dev->hw_dev, dmabuf->size,
+                                         dmabuf->virt, dmabuf->hw);
+               }
+       }
 }
 
 static int apci3120_auto_attach(struct comedi_device *dev,
                                unsigned long context)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
-       const struct addi_board *this_board = NULL;
-       struct addi_private *devpriv;
+       const struct apci3120_board *this_board = NULL;
+       struct apci3120_private *devpriv;
        struct comedi_subdevice *s;
-       int ret, order, i;
+       int ret;
 
        if (context < ARRAY_SIZE(apci3120_boardtypes))
                this_board = &apci3120_boardtypes[context];
        if (!this_board)
                return -ENODEV;
        dev->board_ptr = this_board;
-       dev->board_name = this_board->pc_DriverName;
+       dev->board_name = this_board->name;
 
        devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
        if (!devpriv)
@@ -76,136 +151,96 @@ static int apci3120_auto_attach(struct comedi_device *dev,
        pci_set_master(pcidev);
 
        dev->iobase = pci_resource_start(pcidev, 1);
-       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);
+       devpriv->amcc = pci_resource_start(pcidev, 0);
+       devpriv->addon = pci_resource_start(pcidev, 2);
+
+       apci3120_reset(dev);
 
        if (pcidev->irq > 0) {
-               ret = request_irq(pcidev->irq, v_ADDI_Interrupt, IRQF_SHARED,
+               ret = request_irq(pcidev->irq, apci3120_interrupt, IRQF_SHARED,
                                  dev->board_name, dev);
-               if (ret == 0)
+               if (ret == 0) {
                        dev->irq = pcidev->irq;
-       }
-
-       /* Allocate DMA buffers */
-       for (i = 0; i < 2; i++) {
-               for (order = 2; order >= 0; order--) {
-                       devpriv->ul_DmaBufferVirtual[i] =
-                           dma_alloc_coherent(dev->hw_dev, PAGE_SIZE << order,
-                                              &devpriv->ul_DmaBufferHw[i],
-                                              GFP_KERNEL);
 
-                       if (devpriv->ul_DmaBufferVirtual[i])
-                               break;
+                       apci3120_dma_alloc(dev);
                }
-               if (!devpriv->ul_DmaBufferVirtual[i])
-                       break;
-               devpriv->ui_DmaBufferSize[i] = PAGE_SIZE << order;
        }
-       if (devpriv->ul_DmaBufferVirtual[0])
-               devpriv->us_UseDma = 1;
-
-       if (devpriv->ul_DmaBufferVirtual[1])
-               devpriv->b_DmaDoubleBuffer = 1;
 
        ret = comedi_alloc_subdevices(dev, 5);
        if (ret)
                return ret;
 
-       /*  Allocate and Initialise AI Subdevice Structures */
+       /* Analog Input subdevice */
        s = &dev->subdevices[0];
-       dev->read_subdev = s;
-       s->type = COMEDI_SUBD_AI;
-       s->subdev_flags =
-               SDF_READABLE | SDF_COMMON | SDF_GROUND
-               | SDF_DIFF;
-       if (this_board->i_NbrAiChannel)
-               s->n_chan = this_board->i_NbrAiChannel;
-       else
-               s->n_chan = this_board->i_NbrAiChannelDiff;
-       s->maxdata = this_board->i_AiMaxdata;
-       s->len_chanlist = this_board->i_AiChannelList;
-       s->range_table = &range_apci3120_ai;
-
-       s->insn_config = apci3120_ai_insn_config;
-       s->insn_read = apci3120_ai_insn_read;
-       s->do_cmdtest = apci3120_ai_cmdtest;
-       s->do_cmd = apci3120_ai_cmd;
-       s->cancel = apci3120_cancel;
-
-       /*  Allocate and Initialise AO Subdevice Structures */
+       s->type         = COMEDI_SUBD_AI;
+       s->subdev_flags = SDF_READABLE | SDF_COMMON | SDF_GROUND | SDF_DIFF;
+       s->n_chan       = 16;
+       s->maxdata      = this_board->ai_is_16bit ? 0xffff : 0x0fff;
+       s->range_table  = &range_apci3120_ai;
+       s->insn_config  = apci3120_ai_insn_config;
+       s->insn_read    = apci3120_ai_insn_read;
+       if (0 /* dev->irq */) {
+               dev->read_subdev = s;
+               s->subdev_flags |= SDF_CMD_READ;
+               s->len_chanlist = s->n_chan;
+               s->do_cmdtest   = apci3120_ai_cmdtest;
+               s->do_cmd       = apci3120_ai_cmd;
+               s->cancel       = apci3120_cancel;
+       }
+
+       /* Analog Output subdevice */
        s = &dev->subdevices[1];
-       if (this_board->i_NbrAoChannel) {
-               s->type = COMEDI_SUBD_AO;
-               s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
-               s->n_chan = this_board->i_NbrAoChannel;
-               s->maxdata = this_board->i_AoMaxdata;
-               s->len_chanlist = this_board->i_NbrAoChannel;
-               s->range_table = &range_apci3120_ao;
-               s->insn_write = apci3120_ao_insn_write;
+       if (this_board->has_ao) {
+               s->type         = COMEDI_SUBD_AO;
+               s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
+               s->n_chan       = 8;
+               s->maxdata      = 0x3fff;
+               s->range_table  = &range_bipolar10;
+               s->insn_write   = apci3120_ao_insn_write;
+               s->insn_read    = comedi_readback_insn_read;
+
+               ret = comedi_alloc_subdev_readback(s);
+               if (ret)
+                       return ret;
        } else {
-               s->type = COMEDI_SUBD_UNUSED;
+               s->type         = COMEDI_SUBD_UNUSED;
        }
 
-       /*  Allocate and Initialise DI Subdevice Structures */
+       /* Digital Input subdevice */
        s = &dev->subdevices[2];
-       s->type = COMEDI_SUBD_DI;
-       s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON;
-       s->n_chan = this_board->i_NbrDiChannel;
-       s->maxdata = 1;
-       s->len_chanlist = this_board->i_NbrDiChannel;
-       s->range_table = &range_digital;
-       s->insn_bits = apci3120_di_insn_bits;
-
-       /*  Allocate and Initialise DO Subdevice Structures */
+       s->type         = COMEDI_SUBD_DI;
+       s->subdev_flags = SDF_READABLE;
+       s->n_chan       = 4;
+       s->maxdata      = 1;
+       s->range_table  = &range_digital;
+       s->insn_bits    = apci3120_di_insn_bits;
+
+       /* Digital Output subdevice */
        s = &dev->subdevices[3];
-       s->type = COMEDI_SUBD_DO;
-       s->subdev_flags =
-               SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
-       s->n_chan = this_board->i_NbrDoChannel;
-       s->maxdata = this_board->i_DoMaxdata;
-       s->len_chanlist = this_board->i_NbrDoChannel;
-       s->range_table = &range_digital;
-       s->insn_bits = apci3120_do_insn_bits;
-
-       /*  Allocate and Initialise Timer Subdevice Structures */
+       s->type         = COMEDI_SUBD_DO;
+       s->subdev_flags = SDF_WRITEABLE;
+       s->n_chan       = 4;
+       s->maxdata      = 1;
+       s->range_table  = &range_digital;
+       s->insn_bits    = apci3120_do_insn_bits;
+
+       /* Timer subdevice */
        s = &dev->subdevices[4];
-       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->type         = COMEDI_SUBD_TIMER;
+       s->subdev_flags = SDF_WRITEABLE | SDF_READABLE;
+       s->n_chan       = 1;
+       s->maxdata      = 0x00ffffff;
+       s->insn_write   = apci3120_write_insn_timer;
+       s->insn_read    = apci3120_read_insn_timer;
+       s->insn_config  = apci3120_config_insn_timer;
 
-       s->insn_write = apci3120_write_insn_timer;
-       s->insn_read = apci3120_read_insn_timer;
-       s->insn_config = apci3120_config_insn_timer;
-
-       apci3120_reset(dev);
        return 0;
 }
 
 static void apci3120_detach(struct comedi_device *dev)
 {
-       struct addi_private *devpriv = dev->private;
-
-       if (dev->iobase)
-               apci3120_reset(dev);
        comedi_pci_detach(dev);
-       if (devpriv) {
-               unsigned int i;
-
-               for (i = 0; i < 2; i++) {
-                       if (devpriv->ul_DmaBufferVirtual[i]) {
-                               dma_free_coherent(dev->hw_dev,
-                                                 devpriv->ui_DmaBufferSize[i],
-                                                 devpriv->
-                                                 ul_DmaBufferVirtual[i],
-                                                 devpriv->ul_DmaBufferHw[i]);
-                       }
-               }
-       }
+       apci3120_dma_free(dev);
 }
 
 static struct comedi_driver apci3120_driver = {
diff --git a/drivers/staging/comedi/drivers/addi_apci_3200.c b/drivers/staging/comedi/drivers/addi_apci_3200.c
deleted file mode 100644 (file)
index fe6897e..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-#include <linux/module.h>
-#include <linux/pci.h>
-
-#include <asm/i387.h>
-
-#include "../comedidev.h"
-#include "comedi_fc.h"
-#include "amcc_s5933.h"
-
-#include "addi-data/addi_common.h"
-
-static void fpu_begin(void)
-{
-       kernel_fpu_begin();
-}
-
-static void fpu_end(void)
-{
-       kernel_fpu_end();
-}
-
-#include "addi-data/addi_eeprom.c"
-#include "addi-data/hwdrv_apci3200.c"
-#include "addi-data/addi_common.c"
-
-enum apci3200_boardid {
-       BOARD_APCI3200,
-       BOARD_APCI3300,
-};
-
-static const struct addi_board apci3200_boardtypes[] = {
-       [BOARD_APCI3200] = {
-               .pc_DriverName          = "apci3200",
-               .i_IorangeBase1         = 256,
-               .i_PCIEeprom            = 1,
-               .pc_EepromChip          = "S5920",
-               .i_NbrAiChannel         = 16,
-               .i_NbrAiChannelDiff     = 8,
-               .i_AiChannelList        = 16,
-               .i_AiMaxdata            = 0x3ffff,
-               .pr_AiRangelist         = &range_apci3200_ai,
-               .i_NbrDiChannel         = 4,
-               .i_NbrDoChannel         = 4,
-               .ui_MinAcquisitiontimeNs = 10000,
-               .ui_MinDelaytimeNs      = 100000,
-               .interrupt              = apci3200_interrupt,
-               .reset                  = apci3200_reset,
-               .ai_config              = apci3200_ai_config,
-               .ai_read                = apci3200_ai_read,
-               .ai_write               = apci3200_ai_write,
-               .ai_bits                = apci3200_ai_bits_test,
-               .ai_cmdtest             = apci3200_ai_cmdtest,
-               .ai_cmd                 = apci3200_ai_cmd,
-               .ai_cancel              = apci3200_cancel,
-               .di_bits                = apci3200_di_insn_bits,
-               .do_bits                = apci3200_do_insn_bits,
-       },
-       [BOARD_APCI3300] = {
-               .pc_DriverName          = "apci3300",
-               .i_IorangeBase1         = 256,
-               .i_PCIEeprom            = 1,
-               .pc_EepromChip          = "S5920",
-               .i_NbrAiChannelDiff     = 8,
-               .i_AiChannelList        = 8,
-               .i_AiMaxdata            = 0x3ffff,
-               .pr_AiRangelist         = &range_apci3300_ai,
-               .i_NbrDiChannel         = 4,
-               .i_NbrDoChannel         = 4,
-               .ui_MinAcquisitiontimeNs = 10000,
-               .ui_MinDelaytimeNs      = 100000,
-               .interrupt              = apci3200_interrupt,
-               .reset                  = apci3200_reset,
-               .ai_config              = apci3200_ai_config,
-               .ai_read                = apci3200_ai_read,
-               .ai_write               = apci3200_ai_write,
-               .ai_bits                = apci3200_ai_bits_test,
-               .ai_cmdtest             = apci3200_ai_cmdtest,
-               .ai_cmd                 = apci3200_ai_cmd,
-               .ai_cancel              = apci3200_cancel,
-               .di_bits                = apci3200_di_insn_bits,
-               .do_bits                = apci3200_do_insn_bits,
-       },
-};
-
-static int apci3200_auto_attach(struct comedi_device *dev,
-                               unsigned long context)
-{
-       const struct addi_board *board = NULL;
-
-       if (context < ARRAY_SIZE(apci3200_boardtypes))
-               board = &apci3200_boardtypes[context];
-       if (!board)
-               return -ENODEV;
-       dev->board_ptr = board;
-
-       return addi_auto_attach(dev, context);
-}
-
-static struct comedi_driver apci3200_driver = {
-       .driver_name    = "addi_apci_3200",
-       .module         = THIS_MODULE,
-       .auto_attach    = apci3200_auto_attach,
-       .detach         = i_ADDI_Detach,
-};
-
-static int apci3200_pci_probe(struct pci_dev *dev,
-                             const struct pci_device_id *id)
-{
-       return comedi_pci_auto_config(dev, &apci3200_driver, id->driver_data);
-}
-
-static const struct pci_device_id apci3200_pci_table[] = {
-       { PCI_VDEVICE(ADDIDATA, 0x3000), BOARD_APCI3200 },
-       { PCI_VDEVICE(ADDIDATA, 0x3007), BOARD_APCI3300 },
-       { 0 }
-};
-MODULE_DEVICE_TABLE(pci, apci3200_pci_table);
-
-static struct pci_driver apci3200_pci_driver = {
-       .name           = "addi_apci_3200",
-       .id_table       = apci3200_pci_table,
-       .probe          = apci3200_pci_probe,
-       .remove         = comedi_pci_auto_unconfig,
-};
-module_comedi_pci_driver(apci3200_driver, apci3200_pci_driver);
index a296bd5..db3ee9c 100644 (file)
@@ -371,10 +371,10 @@ static irqreturn_t apci3xxx_irq_handler(int irq, void *d)
                writel(status, dev->mmio + 16);
 
                val = readl(dev->mmio + 28);
-               comedi_buf_put(s, val);
+               comedi_buf_write_samples(s, &val, 1);
 
                s->async->events |= COMEDI_CB_EOA;
-               comedi_event(dev, s);
+               comedi_handle_events(dev, s);
 
                return IRQ_HANDLED;
        }
index d18d8f2..18f5f7f 100644 (file)
@@ -477,9 +477,8 @@ static void pci9111_handle_fifo_half_full(struct comedi_device *dev,
             devpriv->ai_bounce_buffer, samples);
 
        if (devpriv->scan_delay < 1) {
-               total = cfc_write_array_to_buffer(s,
-                                                 devpriv->ai_bounce_buffer,
-                                                 samples * sizeof(short));
+               total = comedi_buf_write_samples(s, devpriv->ai_bounce_buffer,
+                                                samples);
        } else {
                unsigned int pos = 0;
                unsigned int to_read;
@@ -492,9 +491,9 @@ static void pci9111_handle_fifo_half_full(struct comedi_device *dev,
                                if (to_read > samples - pos)
                                        to_read = samples - pos;
 
-                               total += cfc_write_array_to_buffer(s,
+                               total += comedi_buf_write_samples(s,
                                                devpriv->ai_bounce_buffer + pos,
-                                               to_read * sizeof(short));
+                                               to_read);
                        } else {
                                to_read = devpriv->chunk_num_samples -
                                          devpriv->chunk_counter;
@@ -561,7 +560,7 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device)
                        dev_dbg(dev->class_dev, "fifo overflow\n");
                        outb(0, dev->iobase + PCI9111_INT_CLR_REG);
                        async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
-                       cfc_handle_events(dev, s);
+                       comedi_handle_events(dev, s);
 
                        return IRQ_HANDLED;
                }
@@ -578,7 +577,7 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device)
 
        spin_unlock_irqrestore(&dev->spinlock, irq_flags);
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 
        return IRQ_HANDLED;
 }
index e18fd95..cb2c485 100644 (file)
@@ -472,26 +472,21 @@ static unsigned int defragment_dma_buffer(struct comedi_device *dev,
        return j;
 }
 
-static int move_block_from_dma(struct comedi_device *dev,
-                              struct comedi_subdevice *s,
-                              unsigned short *dma_buffer,
-                              unsigned int num_samples)
+static void move_block_from_dma(struct comedi_device *dev,
+                               struct comedi_subdevice *s,
+                               unsigned short *dma_buffer,
+                               unsigned int num_samples)
 {
        struct pci9118_private *devpriv = dev->private;
        struct comedi_cmd *cmd = &s->async->cmd;
-       unsigned int num_bytes;
 
        num_samples = defragment_dma_buffer(dev, s, dma_buffer, num_samples);
        devpriv->ai_act_scan +=
            (s->async->cur_chan + num_samples) / cmd->scan_end_arg;
        s->async->cur_chan += num_samples;
        s->async->cur_chan %= cmd->scan_end_arg;
-       num_bytes =
-           cfc_write_array_to_buffer(s, dma_buffer,
-                                     num_samples * sizeof(short));
-       if (num_bytes < num_samples * sizeof(short))
-               return -1;
-       return 0;
+
+       comedi_buf_write_samples(s, dma_buffer, num_samples);
 }
 
 static void pci9118_exttrg_enable(struct comedi_device *dev, bool enable)
@@ -617,7 +612,7 @@ static void interrupt_pci9118_ai_onesample(struct comedi_device *dev,
 
        sampl = inl(dev->iobase + PCI9118_AI_FIFO_REG);
 
-       cfc_write_to_buffer(s, sampl);
+       comedi_buf_write_samples(s, &sampl, 1);
        s->async->cur_chan++;
        if (s->async->cur_chan >= cmd->scan_end_arg) {
                                                        /* one scan done */
@@ -766,7 +761,7 @@ static irqreturn_t pci9118_interrupt(int irq, void *d)
                interrupt_pci9118_ai_onesample(dev, s);
 
 interrupt_exit:
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
        return IRQ_HANDLED;
 }
 
index 5539bd2..c5422f3 100644 (file)
@@ -749,14 +749,14 @@ static void pci1710_handle_every_sample(struct comedi_device *dev,
        if (status & Status_FE) {
                dev_dbg(dev->class_dev, "A/D FIFO empty (%4x)\n", status);
                s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
-               cfc_handle_events(dev, s);
+               comedi_handle_events(dev, s);
                return;
        }
        if (status & Status_FF) {
                dev_dbg(dev->class_dev,
                        "A/D FIFO Full status (Fatal Error!) (%4x)\n", status);
                s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
-               cfc_handle_events(dev, s);
+               comedi_handle_events(dev, s);
                return;
        }
 
@@ -770,7 +770,8 @@ static void pci1710_handle_every_sample(struct comedi_device *dev,
                        break;
                }
 
-               comedi_buf_put(s, val & s->maxdata);
+               val &= s->maxdata;
+               comedi_buf_write_samples(s, &val, 1);
 
                s->async->cur_chan++;
                if (s->async->cur_chan >= cmd->chanlist_len)
@@ -790,7 +791,7 @@ static void pci1710_handle_every_sample(struct comedi_device *dev,
 
        outb(0, dev->iobase + PCI171x_CLRINT);  /*  clear our INT request */
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 }
 
 /*
@@ -814,7 +815,8 @@ static int move_block_from_fifo(struct comedi_device *dev,
                        return ret;
                }
 
-               comedi_buf_put(s, val & s->maxdata);
+               val &= s->maxdata;
+               comedi_buf_write_samples(s, &val, 1);
 
                s->async->cur_chan++;
                if (s->async->cur_chan >= cmd->chanlist_len) {
@@ -837,14 +839,14 @@ static void pci1710_handle_fifo(struct comedi_device *dev,
        if (!(m & Status_FH)) {
                dev_dbg(dev->class_dev, "A/D FIFO not half full! (%4x)\n", m);
                s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
-               cfc_handle_events(dev, s);
+               comedi_handle_events(dev, s);
                return;
        }
        if (m & Status_FF) {
                dev_dbg(dev->class_dev,
                        "A/D FIFO Full status (Fatal Error!) (%4x)\n", m);
                s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
-               cfc_handle_events(dev, s);
+               comedi_handle_events(dev, s);
                return;
        }
 
@@ -865,12 +867,12 @@ static void pci1710_handle_fifo(struct comedi_device *dev,
            devpriv->ai_act_scan >= cmd->stop_arg) {
                /* all data sampled */
                s->async->events |= COMEDI_CB_EOA;
-               cfc_handle_events(dev, s);
+               comedi_handle_events(dev, s);
                return;
        }
        outb(0, dev->iobase + PCI171x_CLRINT);  /*  clear our INT request */
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 }
 
 /*
index 2c1bfb0..c306226 100644 (file)
@@ -267,24 +267,15 @@ static void dio200_read_scan_intr(struct comedi_device *dev,
                if (triggered & (1U << ch))
                        val |= (1U << n);
        }
-       /* Write the scan to the buffer. */
-       if (comedi_buf_put(s, val)) {
-               s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS);
-       } else {
-               /* Error!  Stop acquisition.  */
-               dio200_stop_intr(dev, s);
-               s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW;
-               dev_err(dev->class_dev, "buffer overflow\n");
-       }
+
+       comedi_buf_write_samples(s, &val, 1);
 
        /* Check for end of acquisition. */
        if (cmd->stop_src == TRIG_COUNT) {
                if (subpriv->stopcount > 0) {
                        subpriv->stopcount--;
-                       if (subpriv->stopcount == 0) {
+                       if (subpriv->stopcount == 0)
                                s->async->events |= COMEDI_CB_EOA;
-                               dio200_stop_intr(dev, s);
-                       }
                }
        }
 }
@@ -297,13 +288,11 @@ static int dio200_handle_read_intr(struct comedi_device *dev,
        unsigned triggered;
        unsigned intstat;
        unsigned cur_enabled;
-       unsigned int oldevents;
        unsigned long flags;
 
        triggered = 0;
 
        spin_lock_irqsave(&subpriv->spinlock, flags);
-       oldevents = s->async->events;
        if (board->has_int_sce) {
                /*
                 * Collect interrupt sources that have triggered and disable
@@ -356,8 +345,7 @@ static int dio200_handle_read_intr(struct comedi_device *dev,
        }
        spin_unlock_irqrestore(&subpriv->spinlock, flags);
 
-       if (oldevents != s->async->events)
-               comedi_event(dev, s);
+       comedi_handle_events(dev, s);
 
        return (triggered != 0);
 }
@@ -469,7 +457,7 @@ static int dio200_subdev_intr_init(struct comedi_device *dev,
                dio200_write8(dev, subpriv->ofs, 0);
 
        s->type = COMEDI_SUBD_DI;
-       s->subdev_flags = SDF_READABLE | SDF_CMD_READ;
+       s->subdev_flags = SDF_READABLE | SDF_CMD_READ | SDF_PACKED;
        if (board->has_int_sce) {
                s->n_chan = DIO200_MAX_ISNS;
                s->len_chanlist = DIO200_MAX_ISNS;
index 963c5d8..be87172 100644 (file)
@@ -135,9 +135,8 @@ static irqreturn_t pc236_interrupt(int irq, void *d)
 
        handled = pc236_intr_check(dev);
        if (dev->attached && handled) {
-               comedi_buf_put(s, 0);
-               s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
-               comedi_event(dev, s);
+               comedi_buf_write_samples(s, &s->state, 1);
+               comedi_handle_events(dev, s);
        }
        return IRQ_RETVAL(handled);
 }
index 3bbbb57..342779f 100644 (file)
@@ -514,14 +514,13 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev,
 {
        struct pci224_private *devpriv = dev->private;
        struct comedi_cmd *cmd = &s->async->cmd;
-       unsigned int bytes_per_scan = cfc_bytes_per_scan(s);
        unsigned int num_scans;
        unsigned int room;
        unsigned short dacstat;
        unsigned int i, n;
 
        /* Determine number of scans available in buffer. */
-       num_scans = comedi_buf_read_n_available(s) / bytes_per_scan;
+       num_scans = comedi_buf_read_n_available(s) / comedi_bytes_per_scan(s);
        if (cmd->stop_src == TRIG_COUNT) {
                /* Fixed number of scans. */
                if (num_scans > devpriv->ao_stop_count)
@@ -537,7 +536,7 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev,
                    devpriv->ao_stop_count == 0) {
                        /* FIFO empty at end of counted acquisition. */
                        s->async->events |= COMEDI_CB_EOA;
-                       cfc_handle_events(dev, s);
+                       comedi_handle_events(dev, s);
                        return;
                }
                break;
@@ -568,8 +567,8 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev,
 
        /* Process scans. */
        for (n = 0; n < num_scans; n++) {
-               cfc_read_array_from_buffer(s, &devpriv->ao_scan_vals[0],
-                                          bytes_per_scan);
+               comedi_buf_read_samples(s, &devpriv->ao_scan_vals[0],
+                                       cmd->chanlist_len);
                for (i = 0; i < cmd->chanlist_len; i++) {
                        outw(devpriv->ao_scan_vals[devpriv->ao_scan_order[i]],
                             dev->iobase + PCI224_DACDATA);
@@ -618,7 +617,7 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev,
                outw(devpriv->daccon, dev->iobase + PCI224_DACCON);
        }
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 }
 
 static int pci224_ao_inttrig_start(struct comedi_device *dev,
index 01796cd..44c967f 100644 (file)
@@ -35,7 +35,7 @@
  * automatically.
  *
  * The PCI230+ and PCI260+ have the same PCI device IDs as the PCI230 and
- * PCI260, but can be distinguished by the the size of the PCI regions.  A
+ * PCI260, but can be distinguished by the size of the PCI regions.  A
  * card will be configured as a "+" model if detected as such.
  *
  * Subdevices:
@@ -1075,34 +1075,30 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev,
                                    struct comedi_subdevice *s)
 {
        struct pci230_private *devpriv = dev->private;
-       unsigned short data;
-       int i, ret;
        struct comedi_async *async = s->async;
        struct comedi_cmd *cmd = &async->cmd;
+       unsigned short data;
+       int i;
 
        if (cmd->stop_src == TRIG_COUNT && devpriv->ao_scan_count == 0)
                return;
+
        for (i = 0; i < cmd->chanlist_len; i++) {
                unsigned int chan = CR_CHAN(cmd->chanlist[i]);
 
-               /* Read sample from Comedi's circular buffer. */
-               ret = comedi_buf_get(s, &data);
-               if (ret == 0) {
-                       s->async->events |= COMEDI_CB_OVERFLOW;
-                       pci230_ao_stop(dev, s);
-                       dev_err(dev->class_dev, "AO buffer underrun\n");
+               if (!comedi_buf_read_samples(s, &data, 1)) {
+                       async->events |= COMEDI_CB_OVERFLOW;
                        return;
                }
                pci230_ao_write_nofifo(dev, data, chan);
                s->readback[chan] = data;
        }
-       async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
+
        if (cmd->stop_src == TRIG_COUNT) {
                devpriv->ao_scan_count--;
                if (devpriv->ao_scan_count == 0) {
                        /* End of acquisition. */
                        async->events |= COMEDI_CB_EOA;
-                       pci230_ao_stop(dev, s);
                }
        }
 }
@@ -1122,12 +1118,11 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev,
        unsigned short dacstat;
        unsigned int i, n;
        unsigned int events = 0;
-       bool running;
 
        /* Get DAC FIFO status. */
        dacstat = inw(devpriv->daqio + PCI230_DACCON);
        /* Determine number of scans available in buffer. */
-       num_scans = comedi_buf_read_n_available(s) / cfc_bytes_per_scan(s);
+       num_scans = comedi_buf_read_n_available(s) / comedi_bytes_per_scan(s);
        if (cmd->stop_src == TRIG_COUNT) {
                /* Fixed number of scans. */
                if (num_scans > devpriv->ao_scan_count)
@@ -1175,12 +1170,12 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev,
                                unsigned int chan = CR_CHAN(cmd->chanlist[i]);
                                unsigned short datum;
 
-                               comedi_buf_get(s, &datum);
+                               comedi_buf_read_samples(s, &datum, 1);
                                pci230_ao_write_fifo(dev, datum, chan);
                                s->readback[chan] = datum;
                        }
                }
-               events |= COMEDI_CB_EOS | COMEDI_CB_BLOCK;
+
                if (cmd->stop_src == TRIG_COUNT) {
                        devpriv->ao_scan_count -= num_scans;
                        if (devpriv->ao_scan_count == 0) {
@@ -1204,15 +1199,8 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev,
                        events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
                }
        }
-       if (events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW)) {
-               /* Stopping AO due to completion or error. */
-               pci230_ao_stop(dev, s);
-               running = false;
-       } else {
-               running = true;
-       }
        async->events |= events;
-       return running;
+       return !(async->events & COMEDI_CB_CANCEL_MASK);
 }
 
 static int pci230_ao_inttrig_scan_begin(struct comedi_device *dev,
@@ -1235,7 +1223,7 @@ static int pci230_ao_inttrig_scan_begin(struct comedi_device *dev,
                /* Not using DAC FIFO. */
                spin_unlock_irqrestore(&devpriv->ao_stop_spinlock, irqflags);
                pci230_handle_ao_nofifo(dev, s);
-               comedi_event(dev, s);
+               comedi_handle_events(dev, s);
        } else {
                /* Using DAC FIFO. */
                /* Read DACSWTRIG register to trigger conversion. */
@@ -1265,7 +1253,7 @@ static void pci230_ao_start(struct comedi_device *dev,
 
                /* Preload FIFO data. */
                run = pci230_handle_ao_fifo(dev, s);
-               comedi_event(dev, s);
+               comedi_handle_events(dev, s);
                if (!run) {
                        /* Stopped. */
                        return;
@@ -2065,6 +2053,7 @@ static void pci230_handle_ai(struct comedi_device *dev,
        unsigned int i;
        unsigned int todo;
        unsigned int fifoamount;
+       unsigned short val;
 
        /* Determine number of samples to read. */
        if (cmd->stop_src != TRIG_COUNT) {
@@ -2111,12 +2100,10 @@ static void pci230_handle_ai(struct comedi_device *dev,
                                fifoamount = 1;
                        }
                }
-               /* Read sample and store in Comedi's circular buffer. */
-               if (comedi_buf_put(s, pci230_ai_read(dev)) == 0) {
-                       events |= COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW;
-                       dev_err(dev->class_dev, "AI buffer overflow\n");
-                       break;
-               }
+
+               val = pci230_ai_read(dev);
+               comedi_buf_write_samples(s, &val, 1);
+
                fifoamount--;
                devpriv->ai_scan_pos++;
                if (devpriv->ai_scan_pos == scanlen) {
@@ -2129,16 +2116,9 @@ static void pci230_handle_ai(struct comedi_device *dev,
        if (cmd->stop_src == TRIG_COUNT && devpriv->ai_scan_count == 0) {
                /* End of acquisition. */
                events |= COMEDI_CB_EOA;
-       } else {
-               /* More samples required, tell Comedi to block. */
-               events |= COMEDI_CB_BLOCK;
        }
        async->events |= events;
-       if (async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR |
-                            COMEDI_CB_OVERFLOW)) {
-               /* disable hardware conversions */
-               pci230_ai_stop(dev, s);
-       } else {
+       if (!(async->events & COMEDI_CB_CANCEL_MASK)) {
                /* update FIFO interrupt trigger level */
                pci230_ai_update_fifo_trigger_level(dev, s);
        }
@@ -2355,7 +2335,8 @@ static irqreturn_t pci230_interrupt(int irq, void *d)
        unsigned char status_int, valid_status_int, temp_ier;
        struct comedi_device *dev = (struct comedi_device *)d;
        struct pci230_private *devpriv = dev->private;
-       struct comedi_subdevice *s;
+       struct comedi_subdevice *s_ao = dev->write_subdev;
+       struct comedi_subdevice *s_ai = dev->read_subdev;
        unsigned long irqflags;
 
        /* Read interrupt status/enable register. */
@@ -2385,23 +2366,14 @@ static irqreturn_t pci230_interrupt(int irq, void *d)
         * two.
         */
 
-       if (valid_status_int & PCI230_INT_ZCLK_CT1) {
-               s = dev->write_subdev;
-               pci230_handle_ao_nofifo(dev, s);
-               comedi_event(dev, s);
-       }
+       if (valid_status_int & PCI230_INT_ZCLK_CT1)
+               pci230_handle_ao_nofifo(dev, s_ao);
 
-       if (valid_status_int & PCI230P2_INT_DAC) {
-               s = dev->write_subdev;
-               pci230_handle_ao_fifo(dev, s);
-               comedi_event(dev, s);
-       }
+       if (valid_status_int & PCI230P2_INT_DAC)
+               pci230_handle_ao_fifo(dev, s_ao);
 
-       if (valid_status_int & PCI230_INT_ADC) {
-               s = dev->read_subdev;
-               pci230_handle_ai(dev, s);
-               comedi_event(dev, s);
-       }
+       if (valid_status_int & PCI230_INT_ADC)
+               pci230_handle_ai(dev, s_ai);
 
        /* Reenable interrupts. */
        spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
@@ -2410,6 +2382,9 @@ static irqreturn_t pci230_interrupt(int irq, void *d)
        devpriv->intr_running = false;
        spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
 
+       comedi_handle_events(dev, s_ao);
+       comedi_handle_events(dev, s_ai);
+
        return IRQ_HANDLED;
 }
 
index 1ec363b..53afae0 100644 (file)
@@ -1134,32 +1134,39 @@ static int cb_pcidas_cancel(struct comedi_device *dev,
        return 0;
 }
 
+static void cb_pcidas_ao_load_fifo(struct comedi_device *dev,
+                                  struct comedi_subdevice *s,
+                                  unsigned int nsamples)
+{
+       struct cb_pcidas_private *devpriv = dev->private;
+       struct comedi_cmd *cmd = &s->async->cmd;
+       unsigned int nbytes;
+
+       if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count < nsamples)
+               nsamples = devpriv->ao_count;
+
+       nbytes = comedi_buf_read_samples(s, devpriv->ao_buffer, nsamples);
+       nsamples = nbytes / bytes_per_sample(s);
+       if (cmd->stop_src == TRIG_COUNT)
+               devpriv->ao_count -= nsamples;
+
+       outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer, nsamples);
+}
+
 static int cb_pcidas_ao_inttrig(struct comedi_device *dev,
                                struct comedi_subdevice *s,
                                unsigned int trig_num)
 {
        const struct cb_pcidas_board *thisboard = dev->board_ptr;
        struct cb_pcidas_private *devpriv = dev->private;
-       unsigned int num_bytes, num_points = thisboard->fifo_size;
        struct comedi_async *async = s->async;
-       struct comedi_cmd *cmd = &s->async->cmd;
+       struct comedi_cmd *cmd = &async->cmd;
        unsigned long flags;
 
        if (trig_num != cmd->start_arg)
                return -EINVAL;
 
-       /*  load up fifo */
-       if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count < num_points)
-               num_points = devpriv->ao_count;
-
-       num_bytes = cfc_read_array_from_buffer(s, devpriv->ao_buffer,
-                                              num_points * sizeof(short));
-       num_points = num_bytes / sizeof(short);
-
-       if (cmd->stop_src == TRIG_COUNT)
-               devpriv->ao_count -= num_points;
-       /*  write data to board's fifo */
-       outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer, num_bytes);
+       cb_pcidas_ao_load_fifo(dev, s, thisboard->fifo_size);
 
        /*  enable dac half-full and empty interrupts */
        spin_lock_irqsave(&dev->spinlock, flags);
@@ -1275,8 +1282,6 @@ static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status)
        struct comedi_subdevice *s = dev->write_subdev;
        struct comedi_async *async = s->async;
        struct comedi_cmd *cmd = &async->cmd;
-       unsigned int half_fifo = thisboard->fifo_size / 2;
-       unsigned int num_points;
        unsigned long flags;
 
        if (status & DAEMI) {
@@ -1295,23 +1300,8 @@ static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status)
                        async->events |= COMEDI_CB_EOA;
                }
        } else if (status & DAHFI) {
-               unsigned int num_bytes;
+               cb_pcidas_ao_load_fifo(dev, s, thisboard->fifo_size / 2);
 
-               /*  figure out how many points we are writing to fifo */
-               num_points = half_fifo;
-               if (cmd->stop_src == TRIG_COUNT &&
-                   devpriv->ao_count < num_points)
-                       num_points = devpriv->ao_count;
-               num_bytes =
-                   cfc_read_array_from_buffer(s, devpriv->ao_buffer,
-                                              num_points * sizeof(short));
-               num_points = num_bytes / sizeof(short);
-
-               if (cmd->stop_src == TRIG_COUNT)
-                       devpriv->ao_count -= num_points;
-               /*  write data to board's fifo */
-               outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer,
-                     num_points);
                /*  clear half-full interrupt latch */
                spin_lock_irqsave(&dev->spinlock, flags);
                outw(devpriv->adc_fifo_bits | DAHFI,
@@ -1319,7 +1309,7 @@ static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status)
                spin_unlock_irqrestore(&dev->spinlock, flags);
        }
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 }
 
 static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
@@ -1369,8 +1359,7 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
                }
                insw(devpriv->adc_fifo + ADCDATA, devpriv->ai_buffer,
                     num_samples);
-               cfc_write_array_to_buffer(s, devpriv->ai_buffer,
-                                         num_samples * sizeof(short));
+               comedi_buf_write_samples(s, devpriv->ai_buffer, num_samples);
                devpriv->count -= num_samples;
                if (cmd->stop_src == TRIG_COUNT && devpriv->count == 0)
                        async->events |= COMEDI_CB_EOA;
@@ -1382,11 +1371,14 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
                /*  else if fifo not empty */
        } else if (status & (ADNEI | EOBI)) {
                for (i = 0; i < timeout; i++) {
+                       unsigned short val;
+
                        /*  break if fifo is empty */
                        if ((ADNE & inw(devpriv->control_status +
                                        INT_ADCFIFO)) == 0)
                                break;
-                       cfc_write_to_buffer(s, inw(devpriv->adc_fifo));
+                       val = inw(devpriv->adc_fifo);
+                       comedi_buf_write_samples(s, &val, 1);
                        if (cmd->stop_src == TRIG_COUNT &&
                            --devpriv->count == 0) {
                                /* end of acquisition */
@@ -1419,7 +1411,7 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
                async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
        }
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 
        return IRQ_HANDLED;
 }
index 3b6bffc..9196680 100644 (file)
@@ -2689,9 +2689,10 @@ static void pio_drain_ai_fifo_16(struct comedi_device *dev)
                }
 
                for (i = 0; i < num_samples; i++) {
-                       cfc_write_to_buffer(s,
-                                           readw(devpriv->main_iobase +
-                                                 ADC_FIFO_REG));
+                       unsigned short val;
+
+                       val = readw(devpriv->main_iobase + ADC_FIFO_REG);
+                       comedi_buf_write_samples(s, &val, 1);
                }
 
        } while (read_segment != write_segment);
@@ -2722,11 +2723,15 @@ static void pio_drain_ai_fifo_32(struct comedi_device *dev)
 
        }
        for (i = 0; read_code != write_code && i < max_transfer;) {
+               unsigned short val;
+
                fifo_data = readl(dev->mmio + ADC_FIFO_REG);
-               cfc_write_to_buffer(s, fifo_data & 0xffff);
+               val = fifo_data & 0xffff;
+               comedi_buf_write_samples(s, &val, 1);
                i++;
                if (i < max_transfer) {
-                       cfc_write_to_buffer(s, (fifo_data >> 16) & 0xffff);
+                       val = (fifo_data >> 16) & 0xffff;
+                       comedi_buf_write_samples(s, &val, 1);
                        i++;
                }
                read_code = readw(devpriv->main_iobase + ADC_READ_PNTR_REG) &
@@ -2778,10 +2783,9 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel)
                                num_samples = devpriv->ai_count;
                        devpriv->ai_count -= num_samples;
                }
-               cfc_write_array_to_buffer(dev->read_subdev,
-                                         devpriv->ai_buffer[devpriv->
-                                                            ai_dma_index],
-                                         num_samples * sizeof(uint16_t));
+               comedi_buf_write_samples(dev->read_subdev,
+                               devpriv->ai_buffer[devpriv->ai_dma_index],
+                               num_samples);
                devpriv->ai_dma_index = (devpriv->ai_dma_index + 1) %
                                        ai_dma_ring_count(thisboard);
        }
@@ -2836,7 +2840,7 @@ static void handle_ai_interrupt(struct comedi_device *dev,
                async->events |= COMEDI_CB_EOA;
        }
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 }
 
 static inline unsigned int prev_ao_dma_index(struct comedi_device *dev)
@@ -2912,32 +2916,46 @@ static void restart_ao_dma(struct comedi_device *dev)
        dma_start_sync(dev, 0);
 }
 
+static unsigned int cb_pcidas64_ao_fill_buffer(struct comedi_device *dev,
+                                              struct comedi_subdevice *s,
+                                              unsigned short *dest,
+                                              unsigned int max_bytes)
+{
+       struct pcidas64_private *devpriv = dev->private;
+       struct comedi_cmd *cmd = &s->async->cmd;
+       unsigned int nsamples = max_bytes / bytes_per_sample(s);
+       unsigned int actual_bytes;
+
+       if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count < nsamples)
+               nsamples = devpriv->ao_count;
+
+       actual_bytes = comedi_buf_read_samples(s, dest, nsamples);
+       nsamples = actual_bytes / bytes_per_sample(s);
+       if (cmd->stop_src == TRIG_COUNT)
+               devpriv->ao_count -= nsamples;
+
+       return nsamples;
+}
+
 static unsigned int load_ao_dma_buffer(struct comedi_device *dev,
                                       const struct comedi_cmd *cmd)
 {
        struct pcidas64_private *devpriv = dev->private;
-       unsigned int num_bytes, buffer_index, prev_buffer_index;
+       struct comedi_subdevice *s = dev->write_subdev;
+       unsigned int buffer_index = devpriv->ao_dma_index;
+       unsigned int prev_buffer_index = prev_ao_dma_index(dev);
+       unsigned int nsamples;
+       unsigned int nbytes;
        unsigned int next_bits;
 
-       buffer_index = devpriv->ao_dma_index;
-       prev_buffer_index = prev_ao_dma_index(dev);
-
-       num_bytes = comedi_buf_read_n_available(dev->write_subdev);
-       if (num_bytes > DMA_BUFFER_SIZE)
-               num_bytes = DMA_BUFFER_SIZE;
-       if (cmd->stop_src == TRIG_COUNT && num_bytes > devpriv->ao_count)
-               num_bytes = devpriv->ao_count;
-       num_bytes -= num_bytes % bytes_in_sample;
-
-       if (num_bytes == 0)
+       nsamples = cb_pcidas64_ao_fill_buffer(dev, s,
+                                             devpriv->ao_buffer[buffer_index],
+                                             DMA_BUFFER_SIZE);
+       if (nsamples == 0)
                return 0;
 
-       num_bytes = cfc_read_array_from_buffer(dev->write_subdev,
-                                              devpriv->
-                                              ao_buffer[buffer_index],
-                                              num_bytes);
-       devpriv->ao_dma_desc[buffer_index].transfer_size =
-               cpu_to_le32(num_bytes);
+       nbytes = nsamples * bytes_per_sample(s);
+       devpriv->ao_dma_desc[buffer_index].transfer_size = cpu_to_le32(nbytes);
        /* set end of chain bit so we catch underruns */
        next_bits = le32_to_cpu(devpriv->ao_dma_desc[buffer_index].next);
        next_bits |= PLX_END_OF_CHAIN_BIT;
@@ -2949,9 +2967,8 @@ static unsigned int load_ao_dma_buffer(struct comedi_device *dev,
        devpriv->ao_dma_desc[prev_buffer_index].next = cpu_to_le32(next_bits);
 
        devpriv->ao_dma_index = (buffer_index + 1) % AO_DMA_RING_COUNT;
-       devpriv->ao_count -= num_bytes;
 
-       return num_bytes;
+       return nbytes;
 }
 
 static void load_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
@@ -3020,7 +3037,7 @@ static void handle_ao_interrupt(struct comedi_device *dev,
                if (ao_stopped_by_error(dev, cmd))
                        async->events |= COMEDI_CB_ERROR;
        }
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 }
 
 static irqreturn_t handle_interrupt(int irq, void *d)
@@ -3191,7 +3208,9 @@ static void set_dac_interval_regs(struct comedi_device *dev,
 static int prep_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
 {
        struct pcidas64_private *devpriv = dev->private;
-       unsigned int num_bytes;
+       struct comedi_subdevice *s = dev->write_subdev;
+       unsigned int nsamples;
+       unsigned int nbytes;
        int i;
 
        /* clear queue pointer too, since external queue has
@@ -3199,22 +3218,22 @@ static int prep_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
        writew(0, devpriv->main_iobase + ADC_QUEUE_CLEAR_REG);
        writew(0, devpriv->main_iobase + DAC_BUFFER_CLEAR_REG);
 
-       num_bytes = (DAC_FIFO_SIZE / 2) * bytes_in_sample;
-       if (cmd->stop_src == TRIG_COUNT &&
-           num_bytes / bytes_in_sample > devpriv->ao_count)
-               num_bytes = devpriv->ao_count * bytes_in_sample;
-       num_bytes = cfc_read_array_from_buffer(dev->write_subdev,
-                                              devpriv->ao_bounce_buffer,
-                                              num_bytes);
-       for (i = 0; i < num_bytes / bytes_in_sample; i++) {
+       nsamples = cb_pcidas64_ao_fill_buffer(dev, s,
+                                             devpriv->ao_bounce_buffer,
+                                             DAC_FIFO_SIZE);
+       if (nsamples == 0)
+               return -1;
+
+       for (i = 0; i < nsamples; i++) {
                writew(devpriv->ao_bounce_buffer[i],
                       devpriv->main_iobase + DAC_FIFO_REG);
        }
-       devpriv->ao_count -= num_bytes / bytes_in_sample;
+
        if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count == 0)
                return 0;
-       num_bytes = load_ao_dma_buffer(dev, cmd);
-       if (num_bytes == 0)
+
+       nbytes = load_ao_dma_buffer(dev, cmd);
+       if (nbytes == 0)
                return -1;
        load_ao_dma(dev, cmd);
 
index fe4d254..73e5c96 100644 (file)
@@ -1,40 +1,45 @@
 /*
-    comedi/drivers/cb_pcimdas.c
-    Comedi driver for Computer Boards PCIM-DAS1602/16
-
-    COMEDI - Linux Control and Measurement Device Interface
-    Copyright (C) 2000 David A. Schleef <ds@schleef.org>
-
-    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.
-*/
+ * comedi/drivers/cb_pcimdas.c
+ * Comedi driver for Computer Boards PCIM-DAS1602/16 and PCIe-DAS1602/16
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 2000 David A. Schleef <ds@schleef.org>
+ *
+ * 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.
+ */
+
 /*
-Driver: cb_pcimdas
-Description: Measurement Computing PCI Migration series boards
-Devices: [ComputerBoards] PCIM-DAS1602/16 (cb_pcimdas)
-Author: Richard Bytheway
-Updated: Wed, 13 Nov 2002 12:34:56 +0000
-Status: experimental
-
-Written to support the PCIM-DAS1602/16 on a 2.4 series kernel.
-
-Configuration Options:
-    [0] - PCI bus number
-    [1] - PCI slot number
-
-Developed from cb_pcidas and skel by Richard Bytheway (mocelet@sucs.org).
-Only supports DIO, AO and simple AI in it's present form.
-No interrupts, multi channel or FIFO AI,
-although the card looks like it could support this.
-See http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf for more details.
-*/
+ * Driver: cb_pcimdas
+ * Description: Measurement Computing PCI Migration series boards
+ * Devices: [ComputerBoards] PCIM-DAS1602/16 (cb_pcimdas), PCIe-DAS1602/16
+ * Author: Richard Bytheway
+ * Updated: Mon, 13 Oct 2014 11:57:39 +0000
+ * Status: experimental
+ *
+ * Written to support the PCIM-DAS1602/16 and PCIe-DAS1602/16.
+ *
+ * Configuration Options:
+ *   none
+ *
+ * Manual configuration of PCI(e) cards is not supported; they are configured
+ * automatically.
+ *
+ * Developed from cb_pcidas and skel by Richard Bytheway (mocelet@sucs.org).
+ * Only supports DIO, AO and simple AI in it's present form.
+ * No interrupts, multi channel or FIFO AI,
+ * although the card looks like it could support this.
+ *
+ * http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf
+ * http://www.mccdaq.com/PDFs/Manuals/pcie-das1602-16.pdf
+ */
 
 #include <linux/module.h>
 #include <linux/pci.h>
@@ -45,7 +50,7 @@ See http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf for more details.
 #include "plx9052.h"
 #include "8255.h"
 
-/* Registers for the PCIM-DAS1602/16 */
+/* Registers for the PCIM-DAS1602/16 and PCIe-DAS1602/16 */
 
 /* DAC Offsets */
 #define ADC_TRIG 0
@@ -251,7 +256,8 @@ static int cb_pcimdas_pci_probe(struct pci_dev *dev,
 }
 
 static const struct pci_device_id cb_pcimdas_pci_table[] = {
-       { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0056) },
+       { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0056) },       /* PCIM-DAS1602/16 */
+       { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0115) },       /* PCIe-DAS1602/16 */
        { 0 }
 };
 MODULE_DEVICE_TABLE(pci, cb_pcimdas_pci_table);
@@ -265,5 +271,5 @@ static struct pci_driver cb_pcimdas_pci_driver = {
 module_comedi_pci_driver(cb_pcimdas_driver, cb_pcimdas_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
-MODULE_DESCRIPTION("Comedi low-level driver");
+MODULE_DESCRIPTION("Comedi driver for PCIM-DAS1602/16 and PCIe-DAS1602/16");
 MODULE_LICENSE("GPL");
index 8450c99..5d19861 100644 (file)
@@ -262,12 +262,10 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
                        {
                                /* Append dev:subdev to devpriv->name */
                                char buf[20];
-                               int left =
-                                   MAX_BOARD_NAME - strlen(devpriv->name) - 1;
                                snprintf(buf, sizeof(buf), "%u:%u ",
                                         bdev->minor, bdev->subdev);
-                               buf[sizeof(buf) - 1] = 0;
-                               strncat(devpriv->name, buf, left);
+                               strlcat(devpriv->name, buf,
+                                       sizeof(devpriv->name));
                        }
 
                }
index ce28359..756be93 100644 (file)
 
 #include "../comedidev.h"
 
-static inline unsigned int cfc_bytes_per_scan(struct comedi_subdevice *s)
-{
-       return comedi_bytes_per_scan(s);
-}
-
-static inline void cfc_inc_scan_progress(struct comedi_subdevice *s,
-                                        unsigned int num_bytes)
-{
-       comedi_inc_scan_progress(s, num_bytes);
-}
-
-static inline unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *s,
-                                                    const void *data,
-                                                    unsigned int num_bytes)
-{
-       return comedi_write_array_to_buffer(s, data, num_bytes);
-}
-
-static inline unsigned int cfc_write_to_buffer(struct comedi_subdevice *s,
-                                              unsigned short data)
-{
-       return comedi_write_array_to_buffer(s, &data, sizeof(data));
-};
-
-static inline unsigned int cfc_write_long_to_buffer(struct comedi_subdevice *s,
-                                                   unsigned int data)
-{
-       return comedi_write_array_to_buffer(s, &data, sizeof(data));
-};
-
-static inline unsigned int
-cfc_read_array_from_buffer(struct comedi_subdevice *s, void *data,
-                          unsigned int num_bytes)
-{
-       return comedi_read_array_from_buffer(s, data, num_bytes);
-}
-
-static inline unsigned int cfc_handle_events(struct comedi_device *dev,
-                                            struct comedi_subdevice *s)
-{
-       return comedi_handle_events(dev, s);
-}
-
 /**
  * cfc_check_trigger_src() - trivially validate a comedi_cmd trigger source
  * @src: pointer to the trigger source to validate
index bf00298..3bac903 100644 (file)
@@ -225,10 +225,9 @@ static irqreturn_t parport_interrupt(int irq, void *d)
        if (!(ctrl & PARPORT_CTRL_IRQ_ENA))
                return IRQ_NONE;
 
-       comedi_buf_put(s, 0);
-       s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
+       comedi_buf_write_samples(s, &s->state, 1);
+       comedi_handle_events(dev, s);
 
-       comedi_event(dev, s);
        return IRQ_HANDLED;
 }
 
index 00c03df..8c348bb 100644 (file)
@@ -52,18 +52,24 @@ zero volts).
 
 #include "comedi_fc.h"
 #include <linux/timer.h>
+#include <linux/ktime.h>
 
 #define N_CHANS 8
 
+enum waveform_state_bits {
+       WAVEFORM_AI_RUNNING = 0
+};
+
 /* Data unique to this driver */
 struct waveform_private {
        struct timer_list timer;
-       struct timeval last;            /* time last timer interrupt occurred */
+       ktime_t last;   /* time last timer interrupt occurred */
        unsigned int uvolt_amplitude;   /* waveform amplitude in microvolts */
        unsigned long usec_period;      /* waveform period in microseconds */
        unsigned long usec_current;     /* current time (mod waveform period) */
        unsigned long usec_remainder;   /* usec since last scan */
        unsigned long ai_count;         /* number of conversions remaining */
+       unsigned long state_bits;
        unsigned int scan_period;       /* scan period in usec */
        unsigned int convert_period;    /* conversion period in usec */
        unsigned int ao_loopbacks[N_CHANS];
@@ -164,20 +170,23 @@ static void waveform_ai_interrupt(unsigned long arg)
 {
        struct comedi_device *dev = (struct comedi_device *)arg;
        struct waveform_private *devpriv = dev->private;
-       struct comedi_async *async = dev->read_subdev->async;
+       struct comedi_subdevice *s = dev->read_subdev;
+       struct comedi_async *async = s->async;
        struct comedi_cmd *cmd = &async->cmd;
        unsigned int i, j;
        /* all times in microsec */
        unsigned long elapsed_time;
        unsigned int num_scans;
-       struct timeval now;
+       ktime_t now;
        bool stopping = false;
 
-       do_gettimeofday(&now);
+       /* check command is still active */
+       if (!test_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits))
+               return;
+
+       now = ktime_get();
 
-       elapsed_time =
-           1000000 * (now.tv_sec - devpriv->last.tv_sec) + now.tv_usec -
-           devpriv->last.tv_usec;
+       elapsed_time = ktime_to_us(ktime_sub(now, devpriv->last));
        devpriv->last = now;
        num_scans =
            (devpriv->usec_remainder + elapsed_time) / devpriv->scan_period;
@@ -203,7 +212,7 @@ static void waveform_ai_interrupt(unsigned long arg)
                                               devpriv->usec_current +
                                                   i * devpriv->scan_period +
                                                   j * devpriv->convert_period);
-                       cfc_write_to_buffer(dev->read_subdev, sample);
+                       comedi_buf_write_samples(s, &sample, 1);
                }
        }
 
@@ -216,7 +225,7 @@ static void waveform_ai_interrupt(unsigned long arg)
        else
                mod_timer(&devpriv->timer, jiffies + 1);
 
-       comedi_event(dev, dev->read_subdev);
+       comedi_handle_events(dev, s);
 }
 
 static int waveform_ai_cmdtest(struct comedi_device *dev,
@@ -316,11 +325,16 @@ static int waveform_ai_cmd(struct comedi_device *dev,
        else    /* TRIG_TIMER */
                devpriv->convert_period = cmd->convert_arg / nano_per_micro;
 
-       do_gettimeofday(&devpriv->last);
-       devpriv->usec_current = devpriv->last.tv_usec % devpriv->usec_period;
+       devpriv->last = ktime_get();
+       devpriv->usec_current =
+               ((u32)ktime_to_us(devpriv->last)) % devpriv->usec_period;
        devpriv->usec_remainder = 0;
 
        devpriv->timer.expires = jiffies + 1;
+       /* mark command as active */
+       smp_mb__before_atomic();
+       set_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits);
+       smp_mb__after_atomic();
        add_timer(&devpriv->timer);
        return 0;
 }
@@ -330,7 +344,11 @@ static int waveform_ai_cancel(struct comedi_device *dev,
 {
        struct waveform_private *devpriv = dev->private;
 
-       del_timer_sync(&devpriv->timer);
+       /* mark command as no longer active */
+       clear_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits);
+       smp_mb__after_atomic();
+       /* cannot call del_timer_sync() as may be called from timer routine */
+       del_timer(&devpriv->timer);
        return 0;
 }
 
@@ -432,7 +450,7 @@ static void waveform_detach(struct comedi_device *dev)
        struct waveform_private *devpriv = dev->private;
 
        if (devpriv)
-               waveform_ai_cancel(dev, dev->read_subdev);
+               del_timer_sync(&devpriv->timer);
 }
 
 static struct comedi_driver waveform_driver = {
index 2d8e86c..8e512b2 100644 (file)
@@ -541,6 +541,7 @@ static void das16_interrupt(struct comedi_device *dev)
        struct comedi_cmd *cmd = &async->cmd;
        unsigned long spin_flags;
        unsigned long dma_flags;
+       unsigned int nsamples;
        int num_bytes, residue;
        int buffer_index;
 
@@ -583,21 +584,25 @@ static void das16_interrupt(struct comedi_device *dev)
 
        spin_unlock_irqrestore(&dev->spinlock, spin_flags);
 
-       cfc_write_array_to_buffer(s,
-                                 devpriv->dma_buffer[buffer_index], num_bytes);
+       nsamples = num_bytes / bytes_per_sample(s);
+       comedi_buf_write_samples(s, devpriv->dma_buffer[buffer_index],
+                                nsamples);
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 }
 
 static void das16_timer_interrupt(unsigned long arg)
 {
        struct comedi_device *dev = (struct comedi_device *)arg;
        struct das16_private_struct *devpriv = dev->private;
+       unsigned long flags;
 
        das16_interrupt(dev);
 
+       spin_lock_irqsave(&dev->spinlock, flags);
        if (devpriv->timer_running)
                mod_timer(&devpriv->timer, jiffies + timer_period());
+       spin_unlock_irqrestore(&dev->spinlock, flags);
 }
 
 static int das16_ai_check_chanlist(struct comedi_device *dev,
@@ -764,7 +769,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
                return -1;
        }
 
-       devpriv->adc_byte_count = cmd->stop_arg * cfc_bytes_per_scan(s);
+       devpriv->adc_byte_count = cmd->stop_arg * comedi_bytes_per_scan(s);
 
        if (devpriv->can_burst)
                outb(DAS1600_CONV_DISABLE, dev->iobase + DAS1600_CONV_REG);
@@ -814,7 +819,8 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
        enable_dma(devpriv->dma_chan);
        release_dma_lock(flags);
 
-       /*  set up interrupt */
+       /*  set up timer */
+       spin_lock_irqsave(&dev->spinlock, flags);
        devpriv->timer_running = 1;
        devpriv->timer.expires = jiffies + timer_period();
        add_timer(&devpriv->timer);
@@ -823,6 +829,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
 
        if (devpriv->can_burst)
                outb(0, dev->iobase + DAS1600_CONV_REG);
+       spin_unlock_irqrestore(&dev->spinlock, flags);
 
        return 0;
 }
@@ -1226,6 +1233,8 @@ static void das16_detach(struct comedi_device *dev)
        int i;
 
        if (devpriv) {
+               if (devpriv->timer.data)
+                       del_timer_sync(&devpriv->timer);
                if (dev->iobase)
                        das16_reset(dev);
 
index 24b63c4..54ccffc 100644 (file)
@@ -442,8 +442,7 @@ static void das16m1_handler(struct comedi_device *dev, unsigned int status)
                num_samples = FIFO_SIZE;
        insw(dev->iobase, devpriv->ai_buffer, num_samples);
        munge_sample_array(devpriv->ai_buffer, num_samples);
-       cfc_write_array_to_buffer(s, devpriv->ai_buffer,
-                                 num_samples * sizeof(short));
+       comedi_buf_write_samples(s, devpriv->ai_buffer, num_samples);
        devpriv->adc_count += num_samples;
 
        if (cmd->stop_src == TRIG_COUNT) {
@@ -460,7 +459,7 @@ static void das16m1_handler(struct comedi_device *dev, unsigned int status)
                dev_err(dev->class_dev, "fifo overflow\n");
        }
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 }
 
 static int das16m1_poll(struct comedi_device *dev, struct comedi_subdevice *s)
index a53d87c..246a186 100644 (file)
@@ -488,8 +488,7 @@ static void das1800_handle_fifo_half_full(struct comedi_device *dev,
                numPoints = devpriv->count;
        insw(dev->iobase + DAS1800_FIFO, devpriv->ai_buf0, numPoints);
        munge_data(dev, devpriv->ai_buf0, numPoints);
-       cfc_write_array_to_buffer(s, devpriv->ai_buf0,
-                                 numPoints * sizeof(devpriv->ai_buf0[0]));
+       comedi_buf_write_samples(s, devpriv->ai_buf0, numPoints);
        if (cmd->stop_src == TRIG_COUNT)
                devpriv->count -= numPoints;
 }
@@ -512,7 +511,7 @@ static void das1800_handle_fifo_not_empty(struct comedi_device *dev,
                if (!unipolar)
                        ;
                dpnt = munge_bipolar_sample(dev, dpnt);
-               cfc_write_to_buffer(s, dpnt);
+               comedi_buf_write_samples(s, &dpnt, 1);
                if (cmd->stop_src == TRIG_COUNT)
                        devpriv->count--;
        }
@@ -543,7 +542,7 @@ static void das1800_flush_dma_channel(struct comedi_device *dev,
                num_samples = devpriv->count;
 
        munge_data(dev, buffer, num_samples);
-       cfc_write_array_to_buffer(s, buffer, num_bytes);
+       comedi_buf_write_samples(s, buffer, num_samples);
        if (cmd->stop_src == TRIG_COUNT)
                devpriv->count -= num_samples;
 }
@@ -649,14 +648,13 @@ static void das1800_ai_handler(struct comedi_device *dev)
                das1800_handle_fifo_not_empty(dev, s);
        }
 
-       async->events |= COMEDI_CB_BLOCK;
        /* if the card's fifo has overflowed */
        if (status & OVF) {
                /*  clear OVF interrupt bit */
                outb(CLEAR_INTR_MASK & ~OVF, dev->iobase + DAS1800_STATUS);
                dev_err(dev->class_dev, "FIFO overflow\n");
                async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
-               cfc_handle_events(dev, s);
+               comedi_handle_events(dev, s);
                return;
        }
        /*  stop taking data if appropriate */
@@ -674,7 +672,7 @@ static void das1800_ai_handler(struct comedi_device *dev)
                async->events |= COMEDI_CB_EOA;
        }
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 }
 
 static int das1800_ai_poll(struct comedi_device *dev,
index d75e552..6013099 100644 (file)
@@ -511,17 +511,16 @@ static irqreturn_t das800_interrupt(int irq, void *d)
 
                /* if there are more data points to collect */
                if (cmd->stop_src == TRIG_NONE || devpriv->count > 0) {
-                       /* write data point to buffer */
-                       cfc_write_to_buffer(s, val & s->maxdata);
+                       val &= s->maxdata;
+                       comedi_buf_write_samples(s, &val, 1);
                        devpriv->count--;
                }
        }
-       async->events |= COMEDI_CB_BLOCK;
 
        if (fifo_overflow) {
                spin_unlock_irqrestore(&dev->spinlock, irq_flags);
                async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
-               cfc_handle_events(dev, s);
+               comedi_handle_events(dev, s);
                return IRQ_HANDLED;
        }
 
@@ -537,7 +536,7 @@ static irqreturn_t das800_interrupt(int irq, void *d)
                das800_disable(dev);
                async->events |= COMEDI_CB_EOA;
        }
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
        return IRQ_HANDLED;
 }
 
index 7215e09..fc2c0db 100644 (file)
@@ -501,7 +501,7 @@ static irqreturn_t dmm32at_isr(int irq, void *d)
 
                        /* invert sign bit to make range unsigned */
                        samp = ((msb ^ 0x0080) << 8) + lsb;
-                       comedi_buf_put(s, samp);
+                       comedi_buf_write_samples(s, &samp, 1);
                }
 
                if (devpriv->ai_scans_left != 0xffffffff) {     /* TRIG_COUNT */
@@ -514,8 +514,7 @@ static irqreturn_t dmm32at_isr(int irq, void *d)
                        }
 
                }
-               /* flush the buffer */
-               comedi_event(dev, s);
+               comedi_handle_events(dev, s);
        }
 
        /* reset the interrupt */
index 9216c35..9805be1 100644 (file)
@@ -230,7 +230,7 @@ static irqreturn_t dt2814_interrupt(int irq, void *d)
 
                s->async->events |= COMEDI_CB_EOA;
        }
-       comedi_event(dev, s);
+       comedi_handle_events(dev, s);
        return IRQ_HANDLED;
 }
 
index cc974a5..1d9fa37 100644 (file)
@@ -449,13 +449,29 @@ static void dt282x_munge(struct comedi_device *dev,
        }
 }
 
+static unsigned int dt282x_ao_setup_dma(struct comedi_device *dev,
+                                       struct comedi_subdevice *s,
+                                       int cur_dma)
+{
+       struct dt282x_private *devpriv = dev->private;
+       void *ptr = devpriv->dma[cur_dma].buf;
+       unsigned int nsamples = devpriv->dma_maxsize / bytes_per_sample(s);
+       unsigned int nbytes;
+
+       nbytes = comedi_buf_read_samples(s, ptr, nsamples);
+       if (nbytes)
+               dt282x_prep_ao_dma(dev, cur_dma, nbytes);
+       else
+               dev_err(dev->class_dev, "AO underrun\n");
+
+       return nbytes;
+}
+
 static void dt282x_ao_dma_interrupt(struct comedi_device *dev,
                                    struct comedi_subdevice *s)
 {
        struct dt282x_private *devpriv = dev->private;
        int cur_dma = devpriv->current_dma_index;
-       void *ptr = devpriv->dma[cur_dma].buf;
-       int size;
 
        outw(devpriv->supcsr | DT2821_SUPCSR_CLRDMADNE,
             dev->iobase + DT2821_SUPCSR_REG);
@@ -464,13 +480,8 @@ static void dt282x_ao_dma_interrupt(struct comedi_device *dev,
 
        devpriv->current_dma_index = 1 - cur_dma;
 
-       size = cfc_read_array_from_buffer(s, ptr, devpriv->dma_maxsize);
-       if (size == 0) {
-               dev_err(dev->class_dev, "AO underrun\n");
+       if (!dt282x_ao_setup_dma(dev, s, cur_dma))
                s->async->events |= COMEDI_CB_OVERFLOW;
-       } else {
-               dt282x_prep_ao_dma(dev, cur_dma, size);
-       }
 }
 
 static void dt282x_ai_dma_interrupt(struct comedi_device *dev,
@@ -480,6 +491,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev,
        int cur_dma = devpriv->current_dma_index;
        void *ptr = devpriv->dma[cur_dma].buf;
        int size = devpriv->dma[cur_dma].size;
+       unsigned int nsamples = size / bytes_per_sample(s);
        int ret;
 
        outw(devpriv->supcsr | DT2821_SUPCSR_CLRDMADNE,
@@ -490,13 +502,11 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev,
        devpriv->current_dma_index = 1 - cur_dma;
 
        dt282x_munge(dev, s, ptr, size);
-       ret = cfc_write_array_to_buffer(s, ptr, size);
-       if (ret != size) {
-               s->async->events |= COMEDI_CB_OVERFLOW;
+       ret = comedi_buf_write_samples(s, ptr, nsamples);
+       if (ret != size)
                return;
-       }
 
-       devpriv->nread -= size / 2;
+       devpriv->nread -= nsamples;
        if (devpriv->nread < 0) {
                dev_info(dev->class_dev, "nread off by one\n");
                devpriv->nread = 0;
@@ -555,7 +565,6 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
        }
 #if 0
        if (adcsr & DT2821_ADCSR_ADDONE) {
-               int ret;
                unsigned short data;
 
                data = inw(dev->iobase + DT2821_ADDAT_REG);
@@ -563,10 +572,7 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
                if (devpriv->ad_2scomp)
                        data = comedi_offset_munge(s, data);
 
-               ret = comedi_buf_put(s, data);
-
-               if (ret == 0)
-                       s->async->events |= COMEDI_CB_OVERFLOW;
+               comedi_buf_write_samples(s, &data, 1);
 
                devpriv->nread--;
                if (!devpriv->nread) {
@@ -579,8 +585,8 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
                handled = 1;
        }
 #endif
-       cfc_handle_events(dev, s);
-       cfc_handle_events(dev, s_ao);
+       comedi_handle_events(dev, s);
+       comedi_handle_events(dev, s_ao);
 
        return IRQ_RETVAL(handled);
 }
@@ -916,26 +922,15 @@ static int dt282x_ao_inttrig(struct comedi_device *dev,
 {
        struct dt282x_private *devpriv = dev->private;
        struct comedi_cmd *cmd = &s->async->cmd;
-       int size;
 
        if (trig_num != cmd->start_src)
                return -EINVAL;
 
-       size = cfc_read_array_from_buffer(s, devpriv->dma[0].buf,
-                                         devpriv->dma_maxsize);
-       if (size == 0) {
-               dev_err(dev->class_dev, "AO underrun\n");
+       if (!dt282x_ao_setup_dma(dev, s, 0))
                return -EPIPE;
-       }
-       dt282x_prep_ao_dma(dev, 0, size);
 
-       size = cfc_read_array_from_buffer(s, devpriv->dma[1].buf,
-                                         devpriv->dma_maxsize);
-       if (size == 0) {
-               dev_err(dev->class_dev, "AO underrun\n");
+       if (!dt282x_ao_setup_dma(dev, s, 1))
                return -EPIPE;
-       }
-       dt282x_prep_ao_dma(dev, 1, size);
 
        outw(devpriv->supcsr | DT2821_SUPCSR_STRIG,
             dev->iobase + DT2821_SUPCSR_REG);
index 8255610..c2058ba 100644 (file)
@@ -315,7 +315,7 @@ static void dt3k_ai_empty_fifo(struct comedi_device *dev,
 
        for (i = 0; i < count; i++) {
                data = readw(dev->mmio + DPR_ADC_buffer + rear);
-               comedi_buf_put(s, data);
+               comedi_buf_write_samples(s, &data, 1);
                rear++;
                if (rear >= AI_FIFO_DEPTH)
                        rear = 0;
@@ -351,10 +351,8 @@ static irqreturn_t dt3k_interrupt(int irq, void *d)
 
        status = readw(dev->mmio + DPR_Intr_Flag);
 
-       if (status & DT3000_ADFULL) {
+       if (status & DT3000_ADFULL)
                dt3k_ai_empty_fifo(dev, s);
-               s->async->events |= COMEDI_CB_BLOCK;
-       }
 
        if (status & (DT3000_ADSWERR | DT3000_ADHWERR))
                s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
@@ -363,7 +361,7 @@ static irqreturn_t dt3k_interrupt(int irq, void *d)
        if (debug_n_ints >= 10)
                s->async->events |= COMEDI_CB_EOA;
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
        return IRQ_HANDLED;
 }
 
index b8975a4..58a99e8 100644 (file)
@@ -196,8 +196,8 @@ static void gsc_hpdi_drain_dma(struct comedi_device *dev, unsigned int channel)
                                size = devpriv->dio_count;
                        devpriv->dio_count -= size;
                }
-               cfc_write_array_to_buffer(s, devpriv->desc_dio_buffer[idx],
-                                         size * sizeof(uint32_t));
+               comedi_buf_write_samples(s, devpriv->desc_dio_buffer[idx],
+                                        size);
                idx++;
                idx %= devpriv->num_dma_descriptors;
                start = le32_to_cpu(devpriv->dma_desc[idx].pci_start_addr);
@@ -272,7 +272,7 @@ static irqreturn_t gsc_hpdi_interrupt(int irq, void *d)
        if (devpriv->dio_count == 0)
                async->events |= COMEDI_CB_EOA;
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 
        return IRQ_HANDLED;
 }
index 6561b00..b5115d8 100644 (file)
@@ -44,8 +44,6 @@ broken.
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
-#include <linux/list.h>
-#include <linux/spinlock.h>
 
 #include "../comedidev.h"
 
@@ -53,10 +51,7 @@ broken.
 #include "8253.h"
 #include "plx9052.h"
 
-#if 0
-/* file removed due to GPL incompatibility */
-#include "me4000_fw.h"
-#endif
+#define ME4000_FIRMWARE                "me4000_firmware.bin"
 
 /*
  * ME4000 Register map and bit defines
@@ -333,27 +328,20 @@ static const struct comedi_lrange me4000_ai_range = {
        }
 };
 
-#define FIRMWARE_NOT_AVAILABLE 1
-#if FIRMWARE_NOT_AVAILABLE
-extern unsigned char *xilinx_firm;
-#endif
-
-static int xilinx_download(struct comedi_device *dev)
+static int me4000_xilinx_download(struct comedi_device *dev,
+                                 const u8 *data, size_t size,
+                                 unsigned long context)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
        struct me4000_info *info = dev->private;
        unsigned long xilinx_iobase = pci_resource_start(pcidev, 5);
-       u32 value = 0;
-       wait_queue_head_t queue;
-       int idx = 0;
-       int size = 0;
-       unsigned int intcsr;
+       unsigned int file_length;
+       unsigned int val;
+       unsigned int i;
 
        if (!xilinx_iobase)
                return -ENODEV;
 
-       init_waitqueue_head(&queue);
-
        /*
         * Set PLX local interrupt 2 polarity to high.
         * Interrupt is thrown by init pin of xilinx.
@@ -361,61 +349,58 @@ static int xilinx_download(struct comedi_device *dev)
        outl(PLX9052_INTCSR_LI2POL, info->plx_regbase + PLX9052_INTCSR);
 
        /* Set /CS and /WRITE of the Xilinx */
-       value = inl(info->plx_regbase + PLX9052_CNTRL);
-       value |= PLX9052_CNTRL_UIO2_DATA;
-       outl(value, info->plx_regbase + PLX9052_CNTRL);
+       val = inl(info->plx_regbase + PLX9052_CNTRL);
+       val |= PLX9052_CNTRL_UIO2_DATA;
+       outl(val, info->plx_regbase + PLX9052_CNTRL);
 
        /* Init Xilinx with CS1 */
        inb(xilinx_iobase + 0xC8);
 
        /* Wait until /INIT pin is set */
        udelay(20);
-       intcsr = inl(info->plx_regbase + PLX9052_INTCSR);
-       if (!(intcsr & PLX9052_INTCSR_LI2STAT)) {
+       val = inl(info->plx_regbase + PLX9052_INTCSR);
+       if (!(val & PLX9052_INTCSR_LI2STAT)) {
                dev_err(dev->class_dev, "Can't init Xilinx\n");
                return -EIO;
        }
 
        /* Reset /CS and /WRITE of the Xilinx */
-       value = inl(info->plx_regbase + PLX9052_CNTRL);
-       value &= ~PLX9052_CNTRL_UIO2_DATA;
-       outl(value, info->plx_regbase + PLX9052_CNTRL);
-       if (FIRMWARE_NOT_AVAILABLE) {
-               dev_err(dev->class_dev,
-                       "xilinx firmware unavailable due to licensing, aborting");
-               return -EIO;
-       } else {
-               /* Download Xilinx firmware */
-               size = (xilinx_firm[0] << 24) + (xilinx_firm[1] << 16) +
-                   (xilinx_firm[2] << 8) + xilinx_firm[3];
-               udelay(10);
+       val = inl(info->plx_regbase + PLX9052_CNTRL);
+       val &= ~PLX9052_CNTRL_UIO2_DATA;
+       outl(val, info->plx_regbase + PLX9052_CNTRL);
 
-               for (idx = 0; idx < size; idx++) {
-                       outb(xilinx_firm[16 + idx], xilinx_iobase);
-                       udelay(10);
+       /* Download Xilinx firmware */
+       file_length = (((unsigned int)data[0] & 0xff) << 24) +
+                     (((unsigned int)data[1] & 0xff) << 16) +
+                     (((unsigned int)data[2] & 0xff) << 8) +
+                     ((unsigned int)data[3] & 0xff);
+       udelay(10);
 
-                       /* Check if BUSY flag is low */
-                       if (inl(info->plx_regbase + PLX9052_CNTRL) & PLX9052_CNTRL_UIO1_DATA) {
-                               dev_err(dev->class_dev,
-                                       "Xilinx is still busy (idx = %d)\n",
-                                       idx);
-                               return -EIO;
-                       }
+       for (i = 0; i < file_length; i++) {
+               outb(data[16 + i], xilinx_iobase);
+               udelay(10);
+
+               /* Check if BUSY flag is low */
+               val = inl(info->plx_regbase + PLX9052_CNTRL);
+               if (val & PLX9052_CNTRL_UIO1_DATA) {
+                       dev_err(dev->class_dev,
+                               "Xilinx is still busy (i = %d)\n", i);
+                       return -EIO;
                }
        }
 
        /* If done flag is high download was successful */
-       if (inl(info->plx_regbase + PLX9052_CNTRL) & PLX9052_CNTRL_UIO0_DATA) {
-       } else {
+       val = inl(info->plx_regbase + PLX9052_CNTRL);
+       if (!(val & PLX9052_CNTRL_UIO0_DATA)) {
                dev_err(dev->class_dev, "DONE flag is not set\n");
                dev_err(dev->class_dev, "Download not successful\n");
                return -EIO;
        }
 
        /* Set /CS and /WRITE */
-       value = inl(info->plx_regbase + PLX9052_CNTRL);
-       value |= PLX9052_CNTRL_UIO2_DATA;
-       outl(value, info->plx_regbase + PLX9052_CNTRL);
+       val = inl(info->plx_regbase + PLX9052_CNTRL);
+       val |= PLX9052_CNTRL_UIO2_DATA;
+       outl(val, info->plx_regbase + PLX9052_CNTRL);
 
        return 0;
 }
@@ -1092,8 +1077,6 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
                } else if ((tmp & ME4000_AI_STATUS_BIT_FF_DATA)
                           && !(tmp & ME4000_AI_STATUS_BIT_HF_DATA)
                           && (tmp & ME4000_AI_STATUS_BIT_EF_DATA)) {
-                       s->async->events |= COMEDI_CB_BLOCK;
-
                        c = ME4000_AI_FIFO_COUNT / 2;
                } else {
                        dev_err(dev->class_dev,
@@ -1119,7 +1102,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
                        lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0xFFFF;
                        lval ^= 0x8000;
 
-                       if (!comedi_buf_put(s, lval)) {
+                       if (!comedi_buf_write_samples(s, &lval, 1)) {
                                /*
                                 * Buffer overflow, so stop conversion
                                 * and disable all interrupts
@@ -1128,11 +1111,6 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
                                tmp &= ~(ME4000_AI_CTRL_BIT_HF_IRQ |
                                         ME4000_AI_CTRL_BIT_SC_IRQ);
                                outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
-
-                               s->async->events |= COMEDI_CB_OVERFLOW;
-
-                               dev_err(dev->class_dev, "Buffer overflow\n");
-
                                break;
                        }
                }
@@ -1146,7 +1124,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
 
        if (inl(dev->iobase + ME4000_IRQ_STATUS_REG) &
            ME4000_IRQ_STATUS_BIT_SC) {
-               s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOA;
+               s->async->events |= COMEDI_CB_EOA;
 
                /*
                 * Acquisition is complete, so stop
@@ -1164,11 +1142,8 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
                        lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0xFFFF;
                        lval ^= 0x8000;
 
-                       if (!comedi_buf_put(s, lval)) {
-                               dev_err(dev->class_dev, "Buffer overflow\n");
-                               s->async->events |= COMEDI_CB_OVERFLOW;
+                       if (!comedi_buf_write_samples(s, &lval, 1))
                                break;
-                       }
                }
 
                /* Work is done, so reset the interrupt */
@@ -1178,8 +1153,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
                outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
        }
 
-       if (s->async->events)
-               comedi_event(dev, s);
+       comedi_handle_events(dev, s);
 
        return IRQ_HANDLED;
 }
@@ -1397,8 +1371,9 @@ static int me4000_auto_attach(struct comedi_device *dev,
        if (!info->plx_regbase || !dev->iobase || !info->timer_regbase)
                return -ENODEV;
 
-       result = xilinx_download(dev);
-       if (result)
+       result = comedi_load_firmware(dev, &pcidev->dev, ME4000_FIRMWARE,
+                                     me4000_xilinx_download, 0);
+       if (result < 0)
                return result;
 
        me4000_reset(dev);
@@ -1561,3 +1536,4 @@ module_comedi_pci_driver(me4000_driver, me4000_pci_driver);
 MODULE_AUTHOR("Comedi http://www.comedi.org");
 MODULE_DESCRIPTION("Comedi low-level driver");
 MODULE_LICENSE("GPL");
+MODULE_FIRMWARE(ME4000_FIRMWARE);
index 4f78290..ffc9e61 100644 (file)
@@ -494,13 +494,10 @@ EXPORT_SYMBOL_GPL(mite_bytes_read_from_memory_ub);
 unsigned mite_dma_tcr(struct mite_channel *mite_chan)
 {
        struct mite_struct *mite = mite_chan->mite;
-       int tcr;
        int lkar;
 
        lkar = readl(mite->mite_io_addr + MITE_LKAR(mite_chan->channel));
-       tcr = readl(mite->mite_io_addr + MITE_TCR(mite_chan->channel));
-
-       return tcr;
+       return readl(mite->mite_io_addr + MITE_TCR(mite_chan->channel));
 }
 EXPORT_SYMBOL_GPL(mite_dma_tcr);
 
@@ -542,7 +539,7 @@ int mite_sync_input_dma(struct mite_channel *mite_chan,
                return 0;
 
        comedi_buf_write_free(s, count);
-       cfc_inc_scan_progress(s, count);
+       comedi_inc_scan_progress(s, count);
        async->events |= COMEDI_CB_BLOCK;
        return 0;
 }
@@ -553,7 +550,7 @@ int mite_sync_output_dma(struct mite_channel *mite_chan,
 {
        struct comedi_async *async = s->async;
        struct comedi_cmd *cmd = &async->cmd;
-       u32 stop_count = cmd->stop_arg * cfc_bytes_per_scan(s);
+       u32 stop_count = cmd->stop_arg * comedi_bytes_per_scan(s);
        unsigned int old_alloc_count = async->buf_read_alloc_count;
        u32 nbytes_ub, nbytes_lb;
        int count;
index 45fb601..f99847f 100644 (file)
@@ -208,9 +208,8 @@ static irqreturn_t ni6527_interrupt(int irq, void *d)
                return IRQ_NONE;
 
        if (status & NI6527_STATUS_EDGE) {
-               comedi_buf_put(s, 0);
-               s->async->events |= COMEDI_CB_EOS;
-               comedi_event(dev, s);
+               comedi_buf_write_samples(s, &s->state, 1);
+               comedi_handle_events(dev, s);
        }
 
        writeb(NI6527_CLR_IRQS, dev->mmio + NI6527_CLR_REG);
@@ -238,9 +237,6 @@ static int ni6527_intr_cmdtest(struct comedi_device *dev,
        /* Step 2a : make sure trigger sources are unique */
        /* Step 2b : and mutually compatible */
 
-       if (err)
-               return 2;
-
        /* Step 3: check if arguments are trivially valid */
 
        err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
index 3b64286..bcb326e 100644 (file)
@@ -508,9 +508,9 @@ static irqreturn_t ni_65xx_interrupt(int irq, void *d)
        writeb(NI_65XX_CLR_EDGE_INT | NI_65XX_CLR_OVERFLOW_INT,
               dev->mmio + NI_65XX_CLR_REG);
 
-       comedi_buf_put(s, 0);
-       s->async->events |= COMEDI_CB_EOS;
-       comedi_event(dev, s);
+       comedi_buf_write_samples(s, &s->state, 1);
+       comedi_handle_events(dev, s);
+
        return IRQ_HANDLED;
 }
 
@@ -534,9 +534,6 @@ static int ni_65xx_intr_cmdtest(struct comedi_device *dev,
        /* Step 2a : make sure trigger sources are unique */
        /* Step 2b : and mutually compatible */
 
-       if (err)
-               return 2;
-
        /* Step 3: check if arguments are trivially valid */
 
        err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
index 5b6794c..1e4dd82 100644 (file)
@@ -780,7 +780,7 @@ static void ni_660x_handle_gpct_interrupt(struct comedi_device *dev,
        struct ni_gpct *counter = s->private;
 
        ni_tio_handle_interrupt(counter, s);
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 }
 
 static irqreturn_t ni_660x_interrupt(int irq, void *d)
index 72ec857..5c17def 100644 (file)
@@ -188,14 +188,14 @@ static irqreturn_t a2150_interrupt(int irq, void *d)
        if (status & OVFL_BIT) {
                dev_err(dev->class_dev, "fifo overflow\n");
                async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
-               cfc_handle_events(dev, s);
+               comedi_handle_events(dev, s);
        }
 
        if ((status & DMA_TC_BIT) == 0) {
                dev_err(dev->class_dev,
                        "caught non-dma interrupt?  Aborting.\n");
                async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
-               cfc_handle_events(dev, s);
+               comedi_handle_events(dev, s);
                return IRQ_HANDLED;
        }
 
@@ -237,7 +237,7 @@ static irqreturn_t a2150_interrupt(int irq, void *d)
                dpnt = devpriv->dma_buffer[i];
                /*  convert from 2's complement to unsigned coding */
                dpnt ^= 0x8000;
-               cfc_write_to_buffer(s, dpnt);
+               comedi_buf_write_samples(s, &dpnt, 1);
                if (cmd->stop_src == TRIG_COUNT) {
                        if (--devpriv->count == 0) {    /* end of acquisition */
                                async->events |= COMEDI_CB_EOA;
@@ -253,9 +253,7 @@ static irqreturn_t a2150_interrupt(int irq, void *d)
        }
        release_dma_lock(flags);
 
-       async->events |= COMEDI_CB_BLOCK;
-
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 
        /* clear interrupt */
        outw(0x00, dev->iobase + DMA_TC_CLEAR_REG);
index fc3c19d..2bac693 100644 (file)
@@ -217,10 +217,12 @@ static irqreturn_t atmio16d_interrupt(int irq, void *d)
 {
        struct comedi_device *dev = d;
        struct comedi_subdevice *s = dev->read_subdev;
+       unsigned short val;
 
-       comedi_buf_put(s, inw(dev->iobase + AD_FIFO_REG));
+       val = inw(dev->iobase + AD_FIFO_REG);
+       comedi_buf_write_samples(s, &val, 1);
+       comedi_handle_events(dev, s);
 
-       comedi_event(dev, s);
        return IRQ_HANDLED;
 }
 
index 35bc2c2..6852203 100644 (file)
@@ -818,7 +818,7 @@ static int labpc_drain_fifo(struct comedi_device *dev)
                        devpriv->count--;
                }
                data = labpc_read_adc_fifo(dev);
-               cfc_write_to_buffer(dev->read_subdev, data);
+               comedi_buf_write_samples(dev->read_subdev, &data, 1);
                devpriv->stat1 = devpriv->read_byte(dev, STAT1_REG);
        }
        if (i == timeout) {
@@ -876,7 +876,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d)
                /* clear error interrupt */
                devpriv->write_byte(dev, 0x1, ADC_FIFO_CLEAR_REG);
                async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
-               cfc_handle_events(dev, s);
+               comedi_handle_events(dev, s);
                dev_err(dev->class_dev, "overrun\n");
                return IRQ_HANDLED;
        }
@@ -896,7 +896,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d)
                /*  clear error interrupt */
                devpriv->write_byte(dev, 0x1, ADC_FIFO_CLEAR_REG);
                async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
-               cfc_handle_events(dev, s);
+               comedi_handle_events(dev, s);
                dev_err(dev->class_dev, "overflow\n");
                return IRQ_HANDLED;
        }
@@ -914,7 +914,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d)
                        async->events |= COMEDI_CB_EOA;
        }
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
        return IRQ_HANDLED;
 }
 
index 967202e..6d38605 100644 (file)
@@ -91,7 +91,6 @@ void labpc_drain_dma(struct comedi_device *dev)
        int status;
        unsigned long flags;
        unsigned int max_points, num_points, residue, leftover;
-       int i;
 
        status = devpriv->stat1;
 
@@ -122,9 +121,7 @@ void labpc_drain_dma(struct comedi_device *dev)
                        leftover = max_points;
        }
 
-       /* write data to comedi buffer */
-       for (i = 0; i < num_points; i++)
-               cfc_write_to_buffer(s, devpriv->dma_buffer[i]);
+       comedi_buf_write_samples(s, devpriv->dma_buffer, num_points);
 
        if (cmd->stop_src == TRIG_COUNT)
                devpriv->count -= num_points;
@@ -133,8 +130,6 @@ void labpc_drain_dma(struct comedi_device *dev)
        set_dma_addr(devpriv->dma_chan, devpriv->dma_addr);
        set_dma_count(devpriv->dma_chan, leftover * sample_size);
        release_dma_lock(flags);
-
-       async->events |= COMEDI_CB_BLOCK;
 }
 EXPORT_SYMBOL_GPL(labpc_drain_dma);
 
index 320b080..18e68cd 100644 (file)
@@ -686,13 +686,12 @@ static inline void ni_set_ai_dma_channel(struct comedi_device *dev, int channel)
 {
        unsigned bitfield;
 
-       if (channel >= 0) {
+       if (channel >= 0)
                bitfield =
                    (ni_stc_dma_channel_select_bitfield(channel) <<
                     AI_DMA_Select_Shift) & AI_DMA_Select_Mask;
-       } else {
+       else
                bitfield = 0;
-       }
        ni_set_bitfield(dev, AI_AO_Select, AI_DMA_Select_Mask, bitfield);
 }
 
@@ -701,13 +700,12 @@ static inline void ni_set_ao_dma_channel(struct comedi_device *dev, int channel)
 {
        unsigned bitfield;
 
-       if (channel >= 0) {
+       if (channel >= 0)
                bitfield =
                    (ni_stc_dma_channel_select_bitfield(channel) <<
                     AO_DMA_Select_Shift) & AO_DMA_Select_Mask;
-       } else {
+       else
                bitfield = 0;
-       }
        ni_set_bitfield(dev, AI_AO_Select, AO_DMA_Select_Mask, bitfield);
 }
 
@@ -1134,13 +1132,10 @@ static void ni_ao_fifo_load(struct comedi_device *dev,
        unsigned short d;
        u32 packed_data;
        int range;
-       int err = 1;
 
        chan = async->cur_chan;
        for (i = 0; i < n; i++) {
-               err &= comedi_buf_get(s, &d);
-               if (err == 0)
-                       break;
+               comedi_buf_read_samples(s, &d, 1);
 
                range = CR_RANGE(cmd->chanlist[chan]);
 
@@ -1148,9 +1143,7 @@ static void ni_ao_fifo_load(struct comedi_device *dev,
                        packed_data = d & 0xffff;
                        /* 6711 only has 16 bit wide ao fifo */
                        if (!devpriv->is_6711) {
-                               err &= comedi_buf_get(s, &d);
-                               if (err == 0)
-                                       break;
+                               comedi_buf_read_samples(s, &d, 1);
                                chan++;
                                i++;
                                packed_data |= (d << 16) & 0xffff0000;
@@ -1163,8 +1156,6 @@ static void ni_ao_fifo_load(struct comedi_device *dev,
                chan %= cmd->chanlist_len;
        }
        async->cur_chan = chan;
-       if (err == 0)
-               async->events |= COMEDI_CB_OVERFLOW;
 }
 
 /*
@@ -1201,8 +1192,6 @@ static int ni_ao_fifo_half_empty(struct comedi_device *dev,
 
        ni_ao_fifo_load(dev, s, n);
 
-       s->async->events |= COMEDI_CB_BLOCK;
-
        return 1;
 }
 
@@ -1237,44 +1226,42 @@ static void ni_ai_fifo_read(struct comedi_device *dev,
 {
        struct ni_private *devpriv = dev->private;
        struct comedi_async *async = s->async;
+       u32 dl;
+       unsigned short data;
        int i;
 
        if (devpriv->is_611x) {
-               unsigned short data[2];
-               u32 dl;
-
                for (i = 0; i < n / 2; i++) {
                        dl = ni_readl(dev, ADC_FIFO_Data_611x);
                        /* This may get the hi/lo data in the wrong order */
-                       data[0] = (dl >> 16) & 0xffff;
-                       data[1] = dl & 0xffff;
-                       cfc_write_array_to_buffer(s, data, sizeof(data));
+                       data = (dl >> 16) & 0xffff;
+                       comedi_buf_write_samples(s, &data, 1);
+                       data = dl & 0xffff;
+                       comedi_buf_write_samples(s, &data, 1);
                }
                /* Check if there's a single sample stuck in the FIFO */
                if (n % 2) {
                        dl = ni_readl(dev, ADC_FIFO_Data_611x);
-                       data[0] = dl & 0xffff;
-                       cfc_write_to_buffer(s, data[0]);
+                       data = dl & 0xffff;
+                       comedi_buf_write_samples(s, &data, 1);
                }
        } else if (devpriv->is_6143) {
-               unsigned short data[2];
-               u32 dl;
-
                /*  This just reads the FIFO assuming the data is present, no checks on the FIFO status are performed */
                for (i = 0; i < n / 2; i++) {
                        dl = ni_readl(dev, AIFIFO_Data_6143);
 
-                       data[0] = (dl >> 16) & 0xffff;
-                       data[1] = dl & 0xffff;
-                       cfc_write_array_to_buffer(s, data, sizeof(data));
+                       data = (dl >> 16) & 0xffff;
+                       comedi_buf_write_samples(s, &data, 1);
+                       data = dl & 0xffff;
+                       comedi_buf_write_samples(s, &data, 1);
                }
                if (n % 2) {
                        /* Assume there is a single sample stuck in the FIFO */
                        /* Get stranded sample into FIFO */
                        ni_writel(dev, 0x01, AIFIFO_Control_6143);
                        dl = ni_readl(dev, AIFIFO_Data_6143);
-                       data[0] = (dl >> 16) & 0xffff;
-                       cfc_write_to_buffer(s, data[0]);
+                       data = (dl >> 16) & 0xffff;
+                       comedi_buf_write_samples(s, &data, 1);
                }
        } else {
                if (n > sizeof(devpriv->ai_fifo_buffer) /
@@ -1288,9 +1275,7 @@ static void ni_ai_fifo_read(struct comedi_device *dev,
                        devpriv->ai_fifo_buffer[i] =
                            ni_readw(dev, ADC_FIFO_Data_Register);
                }
-               cfc_write_array_to_buffer(s, devpriv->ai_fifo_buffer,
-                                         n *
-                                         sizeof(devpriv->ai_fifo_buffer[0]));
+               comedi_buf_write_samples(s, devpriv->ai_fifo_buffer, n);
        }
 }
 
@@ -1313,8 +1298,8 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev)
 {
        struct ni_private *devpriv = dev->private;
        struct comedi_subdevice *s = dev->read_subdev;
-       unsigned short data[2];
        u32 dl;
+       unsigned short data;
        unsigned short fifo_empty;
        int i;
 
@@ -1324,9 +1309,10 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev)
                        dl = ni_readl(dev, ADC_FIFO_Data_611x);
 
                        /* This may get the hi/lo data in the wrong order */
-                       data[0] = (dl >> 16);
-                       data[1] = (dl & 0xffff);
-                       cfc_write_array_to_buffer(s, data, sizeof(data));
+                       data = dl >> 16;
+                       comedi_buf_write_samples(s, &data, 1);
+                       data = dl & 0xffff;
+                       comedi_buf_write_samples(s, &data, 1);
                }
        } else if (devpriv->is_6143) {
                i = 0;
@@ -1334,9 +1320,10 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev)
                        dl = ni_readl(dev, AIFIFO_Data_6143);
 
                        /* This may get the hi/lo data in the wrong order */
-                       data[0] = (dl >> 16);
-                       data[1] = (dl & 0xffff);
-                       cfc_write_array_to_buffer(s, data, sizeof(data));
+                       data = dl >> 16;
+                       comedi_buf_write_samples(s, &data, 1);
+                       data = dl & 0xffff;
+                       comedi_buf_write_samples(s, &data, 1);
                        i += 2;
                }
                /*  Check if stranded sample is present */
@@ -1344,8 +1331,8 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev)
                        /* Get stranded sample into FIFO */
                        ni_writel(dev, 0x01, AIFIFO_Control_6143);
                        dl = ni_readl(dev, AIFIFO_Data_6143);
-                       data[0] = (dl >> 16) & 0xffff;
-                       cfc_write_to_buffer(s, data[0]);
+                       data = (dl >> 16) & 0xffff;
+                       comedi_buf_write_samples(s, &data, 1);
                }
 
        } else {
@@ -1364,10 +1351,7 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev)
                                devpriv->ai_fifo_buffer[i] =
                                    ni_readw(dev, ADC_FIFO_Data_Register);
                        }
-                       cfc_write_array_to_buffer(s, devpriv->ai_fifo_buffer,
-                                                 i *
-                                                 sizeof(devpriv->
-                                                        ai_fifo_buffer[0]));
+                       comedi_buf_write_samples(s, devpriv->ai_fifo_buffer, i);
                }
        }
 }
@@ -1386,7 +1370,7 @@ static void get_last_sample_611x(struct comedi_device *dev)
        if (ni_readb(dev, XXX_Status) & 0x80) {
                dl = ni_readl(dev, ADC_FIFO_Data_611x);
                data = (dl & 0xffff);
-               cfc_write_to_buffer(s, data);
+               comedi_buf_write_samples(s, &data, 1);
        }
 }
 
@@ -1408,7 +1392,7 @@ static void get_last_sample_6143(struct comedi_device *dev)
 
                /* This may get the hi/lo data in the wrong order */
                data = (dl >> 16) & 0xffff;
-               cfc_write_to_buffer(s, data);
+               comedi_buf_write_samples(s, &data, 1);
        }
 }
 
@@ -1462,7 +1446,7 @@ static void handle_gpct_interrupt(struct comedi_device *dev,
 
        ni_tio_handle_interrupt(&devpriv->counter_dev->counters[counter_index],
                                s);
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 #endif
 }
 
@@ -1518,7 +1502,7 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
                        if (comedi_is_subdevice_running(s)) {
                                s->async->events |=
                                    COMEDI_CB_ERROR | COMEDI_CB_EOA;
-                               cfc_handle_events(dev, s);
+                               comedi_handle_events(dev, s);
                        }
                        return;
                }
@@ -1533,7 +1517,7 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
                        if (status & (AI_Overrun_St | AI_Overflow_St))
                                s->async->events |= COMEDI_CB_OVERFLOW;
 
-                       cfc_handle_events(dev, s);
+                       comedi_handle_events(dev, s);
                        return;
                }
                if (status & AI_SC_TC_St) {
@@ -1559,7 +1543,7 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
        if ((status & AI_STOP_St))
                ni_handle_eos(dev, s);
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 }
 
 static void ack_b_interrupt(struct comedi_device *dev, unsigned short b_status)
@@ -1635,7 +1619,7 @@ static void handle_b_interrupt(struct comedi_device *dev,
        }
 #endif
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 }
 
 static void ni_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s,
@@ -3515,9 +3499,6 @@ static int ni_cdio_cmdtest(struct comedi_device *dev,
        /* Step 2a : make sure trigger sources are unique */
        /* Step 2b : and mutually compatible */
 
-       if (err)
-               return 2;
-
        /* Step 3: check if arguments are trivially valid */
 
        err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
@@ -3693,7 +3674,7 @@ static void handle_cdio_interrupt(struct comedi_device *dev)
                          M_Offset_CDIO_Command);
                /* s->async->events |= COMEDI_CB_EOA; */
        }
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 }
 
 static int ni_serial_hw_readwrite8(struct comedi_device *dev,
index 5252cba..db7e8aa 100644 (file)
@@ -384,11 +384,7 @@ static irqreturn_t nidio_interrupt(int irq, void *d)
        struct comedi_subdevice *s = dev->read_subdev;
        struct comedi_async *async = s->async;
        struct mite_struct *mite = devpriv->mite;
-
-       /* int i, j; */
-       unsigned int auxdata = 0;
-       unsigned short data1 = 0;
-       unsigned short data2 = 0;
+       unsigned int auxdata;
        int flags;
        int status;
        int work = 0;
@@ -451,13 +447,9 @@ static irqreturn_t nidio_interrupt(int irq, void *d)
                                        goto out;
                                }
                                auxdata = readl(dev->mmio + Group_1_FIFO);
-                               data1 = auxdata & 0xffff;
-                               data2 = (auxdata & 0xffff0000) >> 16;
-                               comedi_buf_put(s, data1);
-                               comedi_buf_put(s, data2);
+                               comedi_buf_write_samples(s, &auxdata, 1);
                                flags = readb(dev->mmio + Group_1_Flags);
                        }
-                       async->events |= COMEDI_CB_BLOCK;
                }
 
                if (flags & CountExpired) {
@@ -485,7 +477,7 @@ static irqreturn_t nidio_interrupt(int irq, void *d)
        }
 
 out:
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 #if 0
        if (!tag)
                writeb(0x03, dev->mmio + Master_DMA_And_Interrupt_Control);
index 29efce3..131e904 100644 (file)
@@ -1464,7 +1464,7 @@ struct ni_private {
 
        unsigned short ai_fifo_buffer[0x2000];
        uint8_t eeprom_buffer[M_SERIES_EEPROM_SIZE];
-       uint32_t serial_number;
+       __be32 serial_number;
 
        struct mite_struct *mite;
        struct mite_channel *ai_mite_chan;
index 26e7291..6037bec 100644 (file)
@@ -371,9 +371,8 @@ static void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter,
                          of gate interrupt via dma read/write
                           and report bogus gate errors */
                        if (counter->counter_dev->variant !=
-                           ni_gpct_variant_660x) {
+                           ni_gpct_variant_660x)
                                *gate_error = 1;
-                       }
                }
        }
        if (gxx_status & GI_TC_ERROR(cidx)) {
@@ -450,11 +449,10 @@ void ni_tio_handle_interrupt(struct ni_gpct *counter,
                return;
        }
        gpct_mite_status = mite_get_status(counter->mite_chan);
-       if (gpct_mite_status & CHSR_LINKC) {
+       if (gpct_mite_status & CHSR_LINKC)
                writel(CHOR_CLRLC,
                       counter->mite_chan->mite->mite_io_addr +
                       MITE_CHOR(counter->mite_chan->channel));
-       }
        mite_sync_input_dma(counter->mite_chan, s);
        spin_unlock_irqrestore(&counter->lock, flags);
 }
index 47f4887..48a79b8 100644 (file)
@@ -213,16 +213,12 @@ static irqreturn_t pcl711_interrupt(int irq, void *d)
 
        outb(PCL711_INT_STAT_CLR, dev->iobase + PCL711_INT_STAT_REG);
 
-       if (comedi_buf_put(s, data) == 0) {
-               s->async->events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
-       } else {
-               s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
-               if (cmd->stop_src == TRIG_COUNT && !(--devpriv->ntrig)) {
-                       pcl711_ai_set_mode(dev, PCL711_MODE_SOFTTRIG);
+       if (comedi_buf_write_samples(s, &data, 1)) {
+               if (cmd->stop_src == TRIG_COUNT && !(--devpriv->ntrig))
                        s->async->events |= COMEDI_CB_EOA;
-               }
        }
-       comedi_event(dev, s);
+       comedi_handle_events(dev, s);
+
        return IRQ_HANDLED;
 }
 
index dc179bd..a1ac567 100644 (file)
@@ -235,9 +235,8 @@ static irqreturn_t pcl726_interrupt(int irq, void *d)
        if (devpriv->cmd_running) {
                pcl726_intr_cancel(dev, s);
 
-               comedi_buf_put(s, 0);
-               s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS);
-               comedi_event(dev, s);
+               comedi_buf_write_samples(s, &s->state, 1);
+               comedi_handle_events(dev, s);
        }
 
        return IRQ_HANDLED;
index fd5ea6e..eef6462 100644 (file)
@@ -556,8 +556,8 @@ static void pcl812_ai_setup_dma(struct comedi_device *dev,
 
        /*  we use EOS, so adapt DMA buffer to one scan */
        if (devpriv->ai_eos) {
-               devpriv->dmabytestomove[0] = cfc_bytes_per_scan(s);
-               devpriv->dmabytestomove[1] = cfc_bytes_per_scan(s);
+               devpriv->dmabytestomove[0] = comedi_bytes_per_scan(s);
+               devpriv->dmabytestomove[1] = comedi_bytes_per_scan(s);
                devpriv->dma_runs_to_end = 1;
        } else {
                devpriv->dmabytestomove[0] = devpriv->hwdmasize;
@@ -572,7 +572,7 @@ static void pcl812_ai_setup_dma(struct comedi_device *dev,
                        devpriv->dma_runs_to_end = 1;
                } else {
                        /*  how many samples we must transfer? */
-                       bytes = cmd->stop_arg * cfc_bytes_per_scan(s);
+                       bytes = cmd->stop_arg * comedi_bytes_per_scan(s);
 
                        /*  how many DMA pages we must fill */
                        devpriv->dma_runs_to_end =
@@ -844,8 +844,6 @@ static bool pcl812_ai_next_chan(struct comedi_device *dev,
        struct pcl812_private *devpriv = dev->private;
        struct comedi_cmd *cmd = &s->async->cmd;
 
-       s->async->events |= COMEDI_CB_BLOCK;
-
        s->async->cur_chan++;
        if (s->async->cur_chan >= cmd->chanlist_len) {
                s->async->cur_chan = 0;
@@ -868,6 +866,7 @@ static void pcl812_handle_eoc(struct comedi_device *dev,
 {
        struct comedi_cmd *cmd = &s->async->cmd;
        unsigned int next_chan;
+       unsigned short val;
 
        if (pcl812_ai_eoc(dev, s, NULL, 0)) {
                dev_dbg(dev->class_dev, "A/D cmd IRQ without DRDY!\n");
@@ -875,7 +874,8 @@ static void pcl812_handle_eoc(struct comedi_device *dev,
                return;
        }
 
-       comedi_buf_put(s, pcl812_ai_get_sample(dev, s));
+       val = pcl812_ai_get_sample(dev, s);
+       comedi_buf_write_samples(s, &val, 1);
 
        /* Set up next channel. Added by abbotti 2010-01-20, but untested. */
        next_chan = s->async->cur_chan + 1;
@@ -893,9 +893,11 @@ static void transfer_from_dma_buf(struct comedi_device *dev,
                                  unsigned int bufptr, unsigned int len)
 {
        unsigned int i;
+       unsigned short val;
 
        for (i = len; i; i--) {
-               comedi_buf_put(s, ptr[bufptr++]);
+               val = ptr[bufptr++];
+               comedi_buf_write_samples(s, &val, 1);
 
                if (!pcl812_ai_next_chan(dev, s))
                        break;
@@ -939,7 +941,7 @@ static irqreturn_t pcl812_interrupt(int irq, void *d)
 
        pcl812_ai_clear_eoc(dev);
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
        return IRQ_HANDLED;
 }
 
index aa64871..a471c3d 100644 (file)
@@ -160,7 +160,7 @@ static void pcl816_ai_setup_dma(struct comedi_device *dev,
        bytes = devpriv->hwdmasize;
        if (cmd->stop_src == TRIG_COUNT) {
                /*  how many */
-               bytes = cmd->stop_arg * cfc_bytes_per_scan(s);
+               bytes = cmd->stop_arg * comedi_bytes_per_scan(s);
 
                /*  how many DMA pages we must fill */
                devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize;
@@ -289,8 +289,6 @@ static bool pcl816_ai_next_chan(struct comedi_device *dev,
        struct pcl816_private *devpriv = dev->private;
        struct comedi_cmd *cmd = &s->async->cmd;
 
-       s->async->events |= COMEDI_CB_BLOCK;
-
        s->async->cur_chan++;
        if (s->async->cur_chan >= cmd->chanlist_len) {
                s->async->cur_chan = 0;
@@ -313,10 +311,12 @@ static void transfer_from_dma_buf(struct comedi_device *dev,
                                  unsigned short *ptr,
                                  unsigned int bufptr, unsigned int len)
 {
+       unsigned short val;
        int i;
 
        for (i = 0; i < len; i++) {
-               comedi_buf_put(s, ptr[bufptr++]);
+               val = ptr[bufptr++];
+               comedi_buf_write_samples(s, &val, 1);
 
                if (!pcl816_ai_next_chan(dev, s))
                        return;
@@ -355,7 +355,7 @@ static irqreturn_t pcl816_interrupt(int irq, void *d)
 
        pcl816_ai_clear_eoc(dev);
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
        return IRQ_HANDLED;
 }
 
@@ -566,7 +566,7 @@ static int pcl816_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s)
        devpriv->ai_poll_ptr = top1;    /*  new buffer position */
        spin_unlock_irqrestore(&dev->spinlock, flags);
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
 
        return comedi_buf_n_bytes_ready(s);
 }
index ac19e83..e6d897b 100644 (file)
@@ -352,7 +352,7 @@ static void pcl818_ai_setup_dma(struct comedi_device *dev,
        disable_dma(devpriv->dma);      /*  disable dma */
        bytes = devpriv->hwdmasize;
        if (cmd->stop_src == TRIG_COUNT) {
-               bytes = cmd->stop_arg * cfc_bytes_per_scan(s);
+               bytes = cmd->stop_arg * comedi_bytes_per_scan(s);
                devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize;
                devpriv->last_dma_run = bytes % devpriv->hwdmasize;
                devpriv->dma_runs_to_end--;
@@ -521,8 +521,6 @@ static bool pcl818_ai_next_chan(struct comedi_device *dev,
        struct pcl818_private *devpriv = dev->private;
        struct comedi_cmd *cmd = &s->async->cmd;
 
-       s->async->events |= COMEDI_CB_BLOCK;
-
        devpriv->act_chanlist_pos++;
        if (devpriv->act_chanlist_pos >= devpriv->act_chanlist_len)
                devpriv->act_chanlist_pos = 0;
@@ -560,7 +558,7 @@ static void pcl818_handle_eoc(struct comedi_device *dev,
        if (pcl818_ai_dropout(dev, s, chan))
                return;
 
-       comedi_buf_put(s, val);
+       comedi_buf_write_samples(s, &val, 1);
 
        pcl818_ai_next_chan(dev, s);
 }
@@ -589,7 +587,7 @@ static void pcl818_handle_dma(struct comedi_device *dev,
                if (pcl818_ai_dropout(dev, s, chan))
                        break;
 
-               comedi_buf_put(s, val);
+               comedi_buf_write_samples(s, &val, 1);
 
                if (!pcl818_ai_next_chan(dev, s))
                        break;
@@ -630,7 +628,7 @@ static void pcl818_handle_fifo(struct comedi_device *dev,
                if (pcl818_ai_dropout(dev, s, chan))
                        break;
 
-               comedi_buf_put(s, val);
+               comedi_buf_write_samples(s, &val, 1);
 
                if (!pcl818_ai_next_chan(dev, s))
                        break;
@@ -669,7 +667,7 @@ static irqreturn_t pcl818_interrupt(int irq, void *d)
 
        pcl818_ai_clear_eoc(dev);
 
-       cfc_handle_events(dev, s);
+       comedi_handle_events(dev, s);
        return IRQ_HANDLED;
 }
 
index fc40ee2..df47967 100644 (file)
@@ -337,7 +337,6 @@ static void pcmmio_handle_dio_intr(struct comedi_device *dev,
 {
        struct pcmmio_private *devpriv = dev->private;
        struct comedi_cmd *cmd = &s->async->cmd;
-       unsigned int oldevents = s->async->events;
        unsigned int val = 0;
        unsigned long flags;
        int i;
@@ -357,31 +356,19 @@ static void pcmmio_handle_dio_intr(struct comedi_device *dev,
                        val |= (1 << i);
        }
 
-       /* Write the scan to the buffer. */
-       if (comedi_buf_put(s, val) &&
-           comedi_buf_put(s, val >> 16)) {
-               s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS);
-       } else {
-               /* Overflow! Stop acquisition!! */
-               /* TODO: STOP_ACQUISITION_CALL_HERE!! */
-               pcmmio_stop_intr(dev, s);
-       }
+       comedi_buf_write_samples(s, &val, 1);
 
        /* Check for end of acquisition. */
        if (cmd->stop_src == TRIG_COUNT && devpriv->stop_count > 0) {
                devpriv->stop_count--;
-               if (devpriv->stop_count == 0) {
+               if (devpriv->stop_count == 0)
                        s->async->events |= COMEDI_CB_EOA;
-                       /* TODO: STOP_ACQUISITION_CALL_HERE!! */
-                       pcmmio_stop_intr(dev, s);
-               }
        }
 
 done:
        spin_unlock_irqrestore(&devpriv->spinlock, flags);
 
-       if (oldevents != s->async->events)
-               comedi_event(dev, s);
+       comedi_handle_events(dev, s);
 }
 
 static irqreturn_t interrupt_pcmmio(int irq, void *d)
@@ -774,7 +761,7 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        s->insn_config  = pcmmio_dio_insn_config;
        if (dev->irq) {
                dev->read_subdev = s;
-               s->subdev_flags |= SDF_CMD_READ;
+               s->subdev_flags |= SDF_CMD_READ | SDF_LSAMPL | SDF_PACKED;
                s->len_chanlist = s->n_chan;
                s->cancel       = pcmmio_cancel;
                s->do_cmd       = pcmmio_cmd;
index d4fe2ec..18c2ac2 100644 (file)
@@ -317,7 +317,6 @@ static void pcmuio_handle_intr_subdev(struct comedi_device *dev,
        int asic = pcmuio_subdevice_to_asic(s);
        struct pcmuio_asic *chip = &devpriv->asics[asic];
        struct comedi_cmd *cmd = &s->async->cmd;
-       unsigned oldevents = s->async->events;
        unsigned int val = 0;
        unsigned long flags;
        unsigned int i;
@@ -337,33 +336,21 @@ static void pcmuio_handle_intr_subdev(struct comedi_device *dev,
                        val |= (1 << i);
        }
 
-       /* Write the scan to the buffer. */
-       if (comedi_buf_put(s, val) &&
-           comedi_buf_put(s, val >> 16)) {
-               s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS);
-       } else {
-               /* Overflow! Stop acquisition!! */
-               /* TODO: STOP_ACQUISITION_CALL_HERE!! */
-               pcmuio_stop_intr(dev, s);
-       }
+       comedi_buf_write_samples(s, &val, 1);
 
        /* Check for end of acquisition. */
        if (cmd->stop_src == TRIG_COUNT) {
                if (chip->stop_count > 0) {
                        chip->stop_count--;
-                       if (chip->stop_count == 0) {
+                       if (chip->stop_count == 0)
                                s->async->events |= COMEDI_CB_EOA;
-                               /* TODO: STOP_ACQUISITION_CALL_HERE!! */
-                               pcmuio_stop_intr(dev, s);
-                       }
                }
        }
 
 done:
        spin_unlock_irqrestore(&chip->spinlock, flags);
 
-       if (oldevents != s->async->events)
-               comedi_event(dev, s);
+       comedi_handle_events(dev, s);
 }
 
 static int pcmuio_handle_asic_interrupt(struct comedi_device *dev, int asic)
@@ -614,7 +601,8 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                if ((i == 0 && dev->irq) || (i == 2 && devpriv->irq2)) {
                        /* setup the interrupt subdevice */
                        dev->read_subdev = s;
-                       s->subdev_flags |= SDF_CMD_READ;
+                       s->subdev_flags |= SDF_CMD_READ | SDF_LSAMPL |
+                                          SDF_PACKED;
                        s->len_chanlist = s->n_chan;
                        s->cancel       = pcmuio_cancel;
                        s->do_cmd       = pcmuio_cmd;
index 6407df0..f6c678e 100644 (file)
@@ -221,7 +221,7 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id)
                        data |= inb(dev->iobase + DAQP_FIFO) << 8;
                        data ^= 0x8000;
 
-                       comedi_buf_put(s, data);
+                       comedi_buf_write_samples(s, &data, 1);
 
                        /* If there's a limit, decrement it
                         * and stop conversion if zero
@@ -245,9 +245,7 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id)
                        s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
                }
 
-               s->async->events |= COMEDI_CB_BLOCK;
-
-               cfc_handle_events(dev, s);
+               comedi_handle_events(dev, s);
        }
        return IRQ_HANDLED;
 }
index 7d4cb14..888238e 100644 (file)
@@ -623,36 +623,7 @@ static int ai_read_n(struct comedi_device *dev, struct comedi_subdevice *s,
                        d = comedi_offset_munge(s, d);
                d &= s->maxdata;
 
-               if (!comedi_buf_put(s, d))
-                       return -1;
-
-               if (devpriv->ai_count > 0)      /* < 0, means read forever */
-                       devpriv->ai_count--;
-       }
-       return 0;
-}
-
-/*
-  unknown amout of data is waiting in fifo.
-*/
-static int ai_read_dregs(struct comedi_device *dev, struct comedi_subdevice *s)
-{
-       struct rtd_private *devpriv = dev->private;
-
-       while (readl(dev->mmio + LAS0_ADC) & FS_ADC_NOT_EMPTY) {
-               unsigned short d = readw(devpriv->las1 + LAS1_ADC_FIFO);
-
-               if (0 == devpriv->ai_count) {   /* done */
-                       continue;       /* read rest */
-               }
-
-               d = d >> 3;     /* low 3 bits are marker lines */
-               if (test_bit(s->async->cur_chan, devpriv->chan_is_bipolar))
-                       /* convert to comedi unsigned data */
-                       d = comedi_offset_munge(s, d);
-               d &= s->maxdata;
-
-               if (!comedi_buf_put(s, d))
+               if (!comedi_buf_write_samples(s, &d, 1))
                        return -1;
 
                if (devpriv->ai_count > 0)      /* < 0, means read forever */
@@ -703,8 +674,6 @@ static irqreturn_t rtd_interrupt(int irq, void *d)
 
                        if (0 == devpriv->ai_count)
                                goto xfer_done;
-
-                       comedi_event(dev, s);
                } else if (devpriv->xfer_count > 0) {
                        if (fifo_status & FS_ADC_NOT_EMPTY) {
                                /* FIFO not empty */
@@ -713,8 +682,6 @@ static irqreturn_t rtd_interrupt(int irq, void *d)
 
                                if (0 == devpriv->ai_count)
                                        goto xfer_done;
-
-                               comedi_event(dev, s);
                        }
                }
        }
@@ -726,28 +693,16 @@ static irqreturn_t rtd_interrupt(int irq, void *d)
        /* clear the interrupt */
        writew(status, dev->mmio + LAS0_CLEAR);
        readw(dev->mmio + LAS0_CLEAR);
+
+       comedi_handle_events(dev, s);
+
        return IRQ_HANDLED;
 
 xfer_abort:
-       writel(0, dev->mmio + LAS0_ADC_FIFO_CLEAR);
        s->async->events |= COMEDI_CB_ERROR;
-       devpriv->ai_count = 0;  /* stop and don't transfer any more */
-       /* fall into xfer_done */
 
 xfer_done:
-       /* pacer stop source: SOFTWARE */
-       writel(0, dev->mmio + LAS0_PACER_STOP);
-       writel(0, dev->mmio + LAS0_PACER);      /* stop pacer */
-       writel(0, dev->mmio + LAS0_ADC_CONVERSION);
-       writew(0, dev->mmio + LAS0_IT);
-
-       if (devpriv->ai_count > 0) {    /* there shouldn't be anything left */
-               fifo_status = readl(dev->mmio + LAS0_ADC);
-               ai_read_dregs(dev, s);  /* read anything left in FIFO */
-       }
-
-       s->async->events |= COMEDI_CB_EOA;      /* signal end to comedi */
-       comedi_event(dev, s);
+       s->async->events |= COMEDI_CB_EOA;
 
        /* clear the interrupt */
        status = readw(dev->mmio + LAS0_IT);
@@ -757,6 +712,8 @@ xfer_done:
        fifo_status = readl(dev->mmio + LAS0_ADC);
        overrun = readl(dev->mmio + LAS0_OVERRUN) & 0xffff;
 
+       comedi_handle_events(dev, s);
+
        return IRQ_HANDLED;
 }
 
@@ -1083,6 +1040,7 @@ static int rtd_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
        devpriv->ai_count = 0;  /* stop and don't transfer any more */
        status = readw(dev->mmio + LAS0_IT);
        overrun = readl(dev->mmio + LAS0_OVERRUN) & 0xffff;
+       writel(0, dev->mmio + LAS0_ADC_FIFO_CLEAR);
        return 0;
 }
 
index 0e7621e..6976bb0 100644 (file)
@@ -1480,7 +1480,6 @@ static bool s626_handle_eos_interrupt(struct comedi_device *dev)
         * from the final ADC of the previous poll list scan.
         */
        uint32_t *readaddr = (uint32_t *)devpriv->ana_buf.logical_base + 1;
-       bool finished = false;
        int i;
 
        /* get the data and hand it over to comedi */
@@ -1494,8 +1493,7 @@ static bool s626_handle_eos_interrupt(struct comedi_device *dev)
                tempdata = s626_ai_reg_to_uint(*readaddr);
                readaddr++;
 
-               /* put data into read buffer */
-               cfc_write_to_buffer(s, tempdata);
+               comedi_buf_write_samples(s, &tempdata, 1);
        }
 
        /* end of scan occurs */
@@ -1505,25 +1503,16 @@ static bool s626_handle_eos_interrupt(struct comedi_device *dev)
                devpriv->ai_sample_count--;
                if (devpriv->ai_sample_count <= 0) {
                        devpriv->ai_cmd_running = 0;
-
-                       /* Stop RPS program */
-                       s626_mc_disable(dev, S626_MC1_ERPS1, S626_P_MC1);
-
-                       /* send end of acquisition */
                        async->events |= COMEDI_CB_EOA;
-
-                       /* disable master interrupt */
-                       finished = true;
                }
        }
 
        if (devpriv->ai_cmd_running && cmd->scan_begin_src == TRIG_EXT)
                s626_dio_set_irq(dev, cmd->scan_begin_arg);
 
-       /* tell comedi that data is there */
-       comedi_event(dev, s);
+       comedi_handle_events(dev, s);
 
-       return finished;
+       return !devpriv->ai_cmd_running;
 }
 
 static irqreturn_t s626_irq_handler(int irq, void *d)
@@ -1970,13 +1959,13 @@ static int s626_ns_to_timer(unsigned int *nanosec, unsigned int flags)
        switch (flags & CMDF_ROUND_MASK) {
        case CMDF_ROUND_NEAREST:
        default:
-               divider = (*nanosec + base / 2) / base;
+               divider = DIV_ROUND_CLOSEST(*nanosec, base);
                break;
        case CMDF_ROUND_DOWN:
                divider = (*nanosec) / base;
                break;
        case CMDF_ROUND_UP:
-               divider = (*nanosec + base - 1) / base;
+               divider = DIV_ROUND_UP(*nanosec, base);
                break;
        }
 
index 5adbfed..579e6bc 100644 (file)
@@ -1,37 +1,34 @@
 /*
  comedi/drivers/usbdux.c
-   Copyright (C) 2003-2007 Bernd Porr, Bernd.Porr@f2s.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.
usbdux.c
+ * Copyright (C) 2003-2014 Bernd Porr, mail@berndporr.me.uk
+ *
* 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.
  */
+
 /*
-Driver: usbdux
-Description: University of Stirling USB DAQ & INCITE Technology Limited
-Devices: [ITL] USB-DUX (usbdux.o)
-Author: Bernd Porr <BerndPorr@f2s.com>
-Updated: 8 Dec 2008
-Status: Stable
-Configuration options:
-  You have to upload firmware with the -i option. The
-  firmware is usually installed under /usr/share/usb or
-  /usr/local/share/usb or /lib/firmware.
-
-Connection scheme for the counter at the digital port:
-  0=/CLK0, 1=UP/DOWN0, 2=RESET0, 4=/CLK1, 5=UP/DOWN1, 6=RESET1.
-  The sampling rate of the counter is approximately 500Hz.
-
-Please note that under USB2.0 the length of the channel list determines
-the max sampling rate. If you sample only one channel you get 8kHz
-sampling rate. If you sample two channels you get 4kHz and so on.
-*/
+ * Driver: usbdux
+ * Description: University of Stirling USB DAQ & INCITE Technology Limited
+ * Devices: (ITL) USB-DUX [usbdux]
+ * Author: Bernd Porr <mail@berndporr.me.uk>
+ * Updated: 10 Oct 2014
+ * Status: Stable
+ * Connection scheme for the counter at the digital port:
+ * 0=/CLK0, 1=UP/DOWN0, 2=RESET0, 4=/CLK1, 5=UP/DOWN1, 6=RESET1.
+ * The sampling rate of the counter is approximately 500Hz.
+ *
+ * Note that under USB2.0 the length of the channel list determines
+ * the max sampling rate. If you sample only one channel you get 8kHz
+ * sampling rate. If you sample two channels you get 4kHz and so on.
+ */
+
 /*
  * I must give credit here to Chris Baugher who
  * wrote the driver for AT-MIO-16d. I used some parts of this
@@ -253,128 +250,111 @@ static int usbdux_ai_cancel(struct comedi_device *dev,
        return 0;
 }
 
-/* analogue IN - interrupt service routine */
+static void usbduxsub_ai_handle_urb(struct comedi_device *dev,
+                                   struct comedi_subdevice *s,
+                                   struct urb *urb)
+{
+       struct usbdux_private *devpriv = dev->private;
+       struct comedi_async *async = s->async;
+       struct comedi_cmd *cmd = &async->cmd;
+       int ret;
+       int i;
+
+       devpriv->ai_counter--;
+       if (devpriv->ai_counter == 0) {
+               devpriv->ai_counter = devpriv->ai_timer;
+
+               if (cmd->stop_src == TRIG_COUNT) {
+                       devpriv->ai_sample_count--;
+                       if (devpriv->ai_sample_count < 0) {
+                               async->events |= COMEDI_CB_EOA;
+                               return;
+                       }
+               }
+
+               /* get the data from the USB bus and hand it over to comedi */
+               for (i = 0; i < cmd->chanlist_len; i++) {
+                       unsigned int range = CR_RANGE(cmd->chanlist[i]);
+                       uint16_t val = le16_to_cpu(devpriv->in_buf[i]);
+
+                       /* bipolar data is two's-complement */
+                       if (comedi_range_is_bipolar(s, range))
+                               val ^= ((s->maxdata + 1) >> 1);
+
+                       /* transfer data */
+                       if (!comedi_buf_write_samples(s, &val, 1))
+                               return;
+               }
+       }
+
+       /* if command is still running, resubmit urb */
+       if (!(async->events & COMEDI_CB_CANCEL_MASK)) {
+               urb->dev = comedi_to_usb_dev(dev);
+               ret = usb_submit_urb(urb, GFP_ATOMIC);
+               if (ret < 0) {
+                       dev_err(dev->class_dev,
+                               "urb resubmit failed in int-context! err=%d\n",
+                               ret);
+                       if (ret == -EL2NSYNC)
+                               dev_err(dev->class_dev,
+                                       "buggy USB host controller or bug in IRQ handler!\n");
+                       async->events |= COMEDI_CB_ERROR;
+               }
+       }
+}
+
 static void usbduxsub_ai_isoc_irq(struct urb *urb)
 {
        struct comedi_device *dev = urb->context;
        struct comedi_subdevice *s = dev->read_subdev;
+       struct comedi_async *async = s->async;
        struct usbdux_private *devpriv = dev->private;
-       struct comedi_cmd *cmd = &s->async->cmd;
-       int i, err;
 
-       /* first we test if something unusual has just happened */
+       /* exit if not running a command, do not resubmit urb */
+       if (!devpriv->ai_cmd_running)
+               return;
+
        switch (urb->status) {
        case 0:
                /* copy the result in the transfer buffer */
                memcpy(devpriv->in_buf, urb->transfer_buffer, SIZEINBUF);
+               usbduxsub_ai_handle_urb(dev, s, urb);
                break;
+
        case -EILSEQ:
-               /* error in the ISOchronous data */
-               /* we don't copy the data into the transfer buffer */
-               /* and recycle the last data byte */
+               /*
+                * error in the ISOchronous data
+                * we don't copy the data into the transfer buffer
+                * and recycle the last data byte
+                */
                dev_dbg(dev->class_dev, "CRC error in ISO IN stream\n");
+               usbduxsub_ai_handle_urb(dev, s, urb);
                break;
 
        case -ECONNRESET:
        case -ENOENT:
        case -ESHUTDOWN:
        case -ECONNABORTED:
-               /* happens after an unlink command */
-               if (devpriv->ai_cmd_running) {
-                       s->async->events |= COMEDI_CB_EOA;
-                       s->async->events |= COMEDI_CB_ERROR;
-                       comedi_event(dev, s);
-                       /* stop the transfer w/o unlink */
-                       usbdux_ai_stop(dev, 0);
-               }
-               return;
+               /* after an unlink command, unplug, ... etc */
+               async->events |= COMEDI_CB_ERROR;
+               break;
 
        default:
-               /* a real error on the bus */
-               /* pass error to comedi if we are really running a command */
-               if (devpriv->ai_cmd_running) {
-                       dev_err(dev->class_dev,
-                               "Non-zero urb status received in ai intr context: %d\n",
-                               urb->status);
-                       s->async->events |= COMEDI_CB_EOA;
-                       s->async->events |= COMEDI_CB_ERROR;
-                       comedi_event(dev, s);
-                       /* don't do an unlink here */
-                       usbdux_ai_stop(dev, 0);
-               }
-               return;
+               /* a real error */
+               dev_err(dev->class_dev,
+                       "Non-zero urb status received in ai intr context: %d\n",
+                       urb->status);
+               async->events |= COMEDI_CB_ERROR;
+               break;
        }
 
        /*
-        * at this point we are reasonably sure that nothing dodgy has happened
-        * are we running a command?
+        * comedi_handle_events() cannot be used in this driver. The (*cancel)
+        * operation would unlink the urb.
         */
-       if (unlikely(!devpriv->ai_cmd_running)) {
-               /*
-                * not running a command, do not continue execution if no
-                * asynchronous command is running in particular not resubmit
-                */
-               return;
-       }
-
-       urb->dev = comedi_to_usb_dev(dev);
-
-       /* resubmit the urb */
-       err = usb_submit_urb(urb, GFP_ATOMIC);
-       if (unlikely(err < 0)) {
-               dev_err(dev->class_dev,
-                       "urb resubmit failed in int-context! err=%d\n", err);
-               if (err == -EL2NSYNC)
-                       dev_err(dev->class_dev,
-                               "buggy USB host controller or bug in IRQ handler!\n");
-               s->async->events |= COMEDI_CB_EOA;
-               s->async->events |= COMEDI_CB_ERROR;
-               comedi_event(dev, s);
-               /* don't do an unlink here */
+       if (async->events & COMEDI_CB_CANCEL_MASK)
                usbdux_ai_stop(dev, 0);
-               return;
-       }
-
-       devpriv->ai_counter--;
-       if (likely(devpriv->ai_counter > 0))
-               return;
-
-       /* timer zero, transfer measurements to comedi */
-       devpriv->ai_counter = devpriv->ai_timer;
-
-       /* test, if we transmit only a fixed number of samples */
-       if (cmd->stop_src == TRIG_COUNT) {
-               /* not continuous, fixed number of samples */
-               devpriv->ai_sample_count--;
-               /* all samples received? */
-               if (devpriv->ai_sample_count < 0) {
-                       /* prevent a resubmit next time */
-                       usbdux_ai_stop(dev, 0);
-                       /* say comedi that the acquistion is over */
-                       s->async->events |= COMEDI_CB_EOA;
-                       comedi_event(dev, s);
-                       return;
-               }
-       }
-       /* get the data from the USB bus and hand it over to comedi */
-       for (i = 0; i < cmd->chanlist_len; i++) {
-               unsigned int range = CR_RANGE(cmd->chanlist[i]);
-               uint16_t val = le16_to_cpu(devpriv->in_buf[i]);
-
-               /* bipolar data is two's-complement */
-               if (comedi_range_is_bipolar(s, range))
-                       val ^= ((s->maxdata + 1) >> 1);
 
-               /* transfer data */
-               err = comedi_buf_put(s, val);
-               if (unlikely(err == 0)) {
-                       /* buffer overflow */
-                       usbdux_ai_stop(dev, 0);
-                       return;
-               }
-       }
-       /* tell comedi that data is there */
-       s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
        comedi_event(dev, s);
 }
 
@@ -402,69 +382,25 @@ static int usbdux_ao_cancel(struct comedi_device *dev,
        return 0;
 }
 
-static void usbduxsub_ao_isoc_irq(struct urb *urb)
+static void usbduxsub_ao_handle_urb(struct comedi_device *dev,
+                                   struct comedi_subdevice *s,
+                                   struct urb *urb)
 {
-       struct comedi_device *dev = urb->context;
-       struct comedi_subdevice *s = dev->write_subdev;
        struct usbdux_private *devpriv = dev->private;
-       struct comedi_cmd *cmd = &s->async->cmd;
+       struct comedi_async *async = s->async;
+       struct comedi_cmd *cmd = &async->cmd;
        uint8_t *datap;
        int ret;
        int i;
 
-       switch (urb->status) {
-       case 0:
-               /* success */
-               break;
-
-       case -ECONNRESET:
-       case -ENOENT:
-       case -ESHUTDOWN:
-       case -ECONNABORTED:
-               /* after an unlink command, unplug, ... etc */
-               /* no unlink needed here. Already shutting down. */
-               if (devpriv->ao_cmd_running) {
-                       s->async->events |= COMEDI_CB_EOA;
-                       comedi_event(dev, s);
-                       usbdux_ao_stop(dev, 0);
-               }
-               return;
-
-       default:
-               /* a real error */
-               if (devpriv->ao_cmd_running) {
-                       dev_err(dev->class_dev,
-                               "Non-zero urb status received in ao intr context: %d\n",
-                               urb->status);
-                       s->async->events |= COMEDI_CB_ERROR;
-                       s->async->events |= COMEDI_CB_EOA;
-                       comedi_event(dev, s);
-                       /* we do an unlink if we are in the high speed mode */
-                       usbdux_ao_stop(dev, 0);
-               }
-               return;
-       }
-
-       /* are we actually running? */
-       if (!devpriv->ao_cmd_running)
-               return;
-
-       /* normal operation: executing a command in this subdevice */
        devpriv->ao_counter--;
-       if ((int)devpriv->ao_counter <= 0) {
-               /* timer zero */
+       if (devpriv->ao_counter == 0) {
                devpriv->ao_counter = devpriv->ao_timer;
 
-               /* handle non continous acquisition */
                if (cmd->stop_src == TRIG_COUNT) {
-                       /* fixed number of samples */
                        devpriv->ao_sample_count--;
                        if (devpriv->ao_sample_count < 0) {
-                               /* all samples transmitted */
-                               usbdux_ao_stop(dev, 0);
-                               s->async->events |= COMEDI_CB_EOA;
-                               comedi_event(dev, s);
-                               /* no resubmit of the urb */
+                               async->events |= COMEDI_CB_EOA;
                                return;
                        }
                }
@@ -476,26 +412,25 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb)
                        unsigned int chan = CR_CHAN(cmd->chanlist[i]);
                        unsigned short val;
 
-                       ret = comedi_buf_get(s, &val);
-                       if (ret < 0) {
+                       if (!comedi_buf_read_samples(s, &val, 1)) {
                                dev_err(dev->class_dev, "buffer underflow\n");
-                               s->async->events |= (COMEDI_CB_EOA |
-                                                    COMEDI_CB_OVERFLOW);
+                               async->events |= COMEDI_CB_OVERFLOW;
+                               return;
                        }
+
                        /* pointer to the DA */
                        *datap++ = val & 0xff;
                        *datap++ = (val >> 8) & 0xff;
                        *datap++ = chan << 6;
                        s->readback[chan] = val;
-
-                       s->async->events |= COMEDI_CB_BLOCK;
-                       comedi_event(dev, s);
                }
        }
-       urb->transfer_buffer_length = SIZEOUTBUF;
-       urb->dev = comedi_to_usb_dev(dev);
-       urb->status = 0;
-       if (devpriv->ao_cmd_running) {
+
+       /* if command is still running, resubmit urb for BULK transfer */
+       if (!(async->events & COMEDI_CB_CANCEL_MASK)) {
+               urb->transfer_buffer_length = SIZEOUTBUF;
+               urb->dev = comedi_to_usb_dev(dev);
+               urb->status = 0;
                if (devpriv->high_speed)
                        urb->interval = 8;      /* uframes */
                else
@@ -512,16 +447,54 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb)
                        if (ret == -EL2NSYNC)
                                dev_err(dev->class_dev,
                                        "buggy USB host controller or bug in IRQ handling!\n");
-
-                       s->async->events |= COMEDI_CB_EOA;
-                       s->async->events |= COMEDI_CB_ERROR;
-                       comedi_event(dev, s);
-                       /* don't do an unlink here */
-                       usbdux_ao_stop(dev, 0);
+                       async->events |= COMEDI_CB_ERROR;
                }
        }
 }
 
+static void usbduxsub_ao_isoc_irq(struct urb *urb)
+{
+       struct comedi_device *dev = urb->context;
+       struct comedi_subdevice *s = dev->write_subdev;
+       struct comedi_async *async = s->async;
+       struct usbdux_private *devpriv = dev->private;
+
+       /* exit if not running a command, do not resubmit urb */
+       if (!devpriv->ao_cmd_running)
+               return;
+
+       switch (urb->status) {
+       case 0:
+               usbduxsub_ao_handle_urb(dev, s, urb);
+               break;
+
+       case -ECONNRESET:
+       case -ENOENT:
+       case -ESHUTDOWN:
+       case -ECONNABORTED:
+               /* after an unlink command, unplug, ... etc */
+               async->events |= COMEDI_CB_ERROR;
+               break;
+
+       default:
+               /* a real error */
+               dev_err(dev->class_dev,
+                       "Non-zero urb status received in ao intr context: %d\n",
+                       urb->status);
+               async->events |= COMEDI_CB_ERROR;
+               break;
+       }
+
+       /*
+        * comedi_handle_events() cannot be used in this driver. The (*cancel)
+        * operation would unlink the urb.
+        */
+       if (async->events & COMEDI_CB_CANCEL_MASK)
+               usbdux_ao_stop(dev, 0);
+
+       comedi_event(dev, s);
+}
+
 static int usbdux_submit_urbs(struct comedi_device *dev,
                              struct urb **urbs, int num_urbs,
                              int input_urb)
index f85818d..70ec2f5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (C) 2004 Bernd Porr, Bernd.Porr@f2s.com
+ *  Copyright (C) 2004-2014 Bernd Porr, mail@berndporr.me.uk
  *
  * 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
  * GNU General Public License for more details.
  */
 
+/*
+ * Driver: usbduxfast
+ * Description: University of Stirling USB DAQ & INCITE Technology Limited
+ * Devices: (ITL) USB-DUX [usbduxfast]
+ * Author: Bernd Porr <mail@berndporr.me.uk>
+ * Updated: 10 Oct 2014
+ * Status: stable
+ */
+
 /*
  * I must give credit here to Chris Baugher who
  * wrote the driver for AT-MIO-16d. I used some parts of this
@@ -227,114 +236,85 @@ static int usbduxfast_ai_cancel(struct comedi_device *dev,
        return ret;
 }
 
-/*
- * analogue IN
- * interrupt service routine
- */
+static void usbduxfast_ai_handle_urb(struct comedi_device *dev,
+                                    struct comedi_subdevice *s,
+                                    struct urb *urb)
+{
+       struct usbduxfast_private *devpriv = dev->private;
+       struct comedi_async *async = s->async;
+       struct comedi_cmd *cmd = &async->cmd;
+       int ret;
+
+       if (devpriv->ignore) {
+               devpriv->ignore--;
+       } else {
+               unsigned int nbytes = urb->actual_length;
+               unsigned int nsamples = nbytes / bytes_per_sample(s);
+
+               if (cmd->stop_src == TRIG_COUNT) {
+                       if (devpriv->ai_sample_count < nsamples) {
+                               nsamples = devpriv->ai_sample_count;
+                               async->events |= COMEDI_CB_EOA;
+                       }
+                       devpriv->ai_sample_count -= nsamples;
+               }
+
+               comedi_buf_write_samples(s, urb->transfer_buffer, nsamples);
+       }
+
+       /* if command is still running, resubmit urb for BULK transfer */
+       if (!(async->events & COMEDI_CB_CANCEL_MASK)) {
+               urb->dev = comedi_to_usb_dev(dev);
+               urb->status = 0;
+               ret = usb_submit_urb(urb, GFP_ATOMIC);
+               if (ret < 0) {
+                       dev_err(dev->class_dev, "urb resubm failed: %d", ret);
+                       async->events |= COMEDI_CB_ERROR;
+               }
+       }
+}
+
 static void usbduxfast_ai_interrupt(struct urb *urb)
 {
        struct comedi_device *dev = urb->context;
        struct comedi_subdevice *s = dev->read_subdev;
        struct comedi_async *async = s->async;
-       struct comedi_cmd *cmd = &async->cmd;
-       struct usb_device *usb = comedi_to_usb_dev(dev);
        struct usbduxfast_private *devpriv = dev->private;
-       int n, err;
 
-       /* are we running a command? */
-       if (unlikely(!devpriv->ai_cmd_running)) {
-               /*
-                * not running a command
-                * do not continue execution if no asynchronous command
-                * is running in particular not resubmit
-                */
+       /* exit if not running a command, do not resubmit urb */
+       if (!devpriv->ai_cmd_running)
                return;
-       }
 
-       /* first we test if something unusual has just happened */
        switch (urb->status) {
        case 0:
+               usbduxfast_ai_handle_urb(dev, s, urb);
                break;
 
-               /*
-                * happens after an unlink command or when the device
-                * is plugged out
-                */
        case -ECONNRESET:
        case -ENOENT:
        case -ESHUTDOWN:
        case -ECONNABORTED:
-               /* tell this comedi */
-               async->events |= COMEDI_CB_EOA;
+               /* after an unlink command, unplug, ... etc */
                async->events |= COMEDI_CB_ERROR;
-               comedi_event(dev, s);
-               /* stop the transfer w/o unlink */
-               usbduxfast_ai_stop(dev, 0);
-               return;
+               break;
 
        default:
+               /* a real error */
                dev_err(dev->class_dev,
                        "non-zero urb status received in ai intr context: %d\n",
                        urb->status);
-               async->events |= COMEDI_CB_EOA;
                async->events |= COMEDI_CB_ERROR;
-               comedi_event(dev, s);
-               usbduxfast_ai_stop(dev, 0);
-               return;
-       }
-
-       if (!devpriv->ignore) {
-               if (cmd->stop_src == TRIG_COUNT) {
-                       /* not continuous, fixed number of samples */
-                       n = urb->actual_length / sizeof(uint16_t);
-                       if (unlikely(devpriv->ai_sample_count < n)) {
-                               unsigned int num_bytes;
-
-                               /* partial sample received */
-                               num_bytes = devpriv->ai_sample_count *
-                                           sizeof(uint16_t);
-                               cfc_write_array_to_buffer(s,
-                                                         urb->transfer_buffer,
-                                                         num_bytes);
-                               usbduxfast_ai_stop(dev, 0);
-                               /* tell comedi that the acquistion is over */
-                               async->events |= COMEDI_CB_EOA;
-                               comedi_event(dev, s);
-                               return;
-                       }
-                       devpriv->ai_sample_count -= n;
-               }
-               /* write the full buffer to comedi */
-               err = cfc_write_array_to_buffer(s, urb->transfer_buffer,
-                                               urb->actual_length);
-               if (unlikely(err == 0)) {
-                       /* buffer overflow */
-                       usbduxfast_ai_stop(dev, 0);
-                       return;
-               }
-
-               /* tell comedi that data is there */
-               comedi_event(dev, s);
-       } else {
-               /* ignore this packet */
-               devpriv->ignore--;
+               break;
        }
 
        /*
-        * command is still running
-        * resubmit urb for BULK transfer
+        * comedi_handle_events() cannot be used in this driver. The (*cancel)
+        * operation would unlink the urb.
         */
-       urb->dev = usb;
-       urb->status = 0;
-       err = usb_submit_urb(urb, GFP_ATOMIC);
-       if (err < 0) {
-               dev_err(dev->class_dev,
-                       "urb resubm failed: %d", err);
-               async->events |= COMEDI_CB_EOA;
-               async->events |= COMEDI_CB_ERROR;
-               comedi_event(dev, s);
+       if (async->events & COMEDI_CB_CANCEL_MASK)
                usbduxfast_ai_stop(dev, 0);
-       }
+
+       comedi_event(dev, s);
 }
 
 static int usbduxfast_submit_urb(struct comedi_device *dev)
index ebd68e3..7b7698c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * usbduxsigma.c
- * Copyright (C) 2011 Bernd Porr, Bernd.Porr@f2s.com
+ * Copyright (C) 2011-2014 Bernd Porr, mail@berndporr.me.uk
  *
  * 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
@@ -17,9 +17,9 @@
  * Driver: usbduxsigma
  * Description: University of Stirling USB DAQ & INCITE Technology Limited
  * Devices: (ITL) USB-DUX [usbduxsigma]
- * Author: Bernd Porr <BerndPorr@f2s.com>
- * Updated: 8 Nov 2011
- * Status: testing
+ * Author: Bernd Porr <mail@berndporr.me.uk>
+ * Updated: 10 Oct 2014
+ * Status: stable
  */
 
 /*
@@ -211,23 +211,79 @@ static int usbduxsigma_ai_cancel(struct comedi_device *dev,
        return 0;
 }
 
-static void usbduxsigma_ai_urb_complete(struct urb *urb)
+static void usbduxsigma_ai_handle_urb(struct comedi_device *dev,
+                                     struct comedi_subdevice *s,
+                                     struct urb *urb)
 {
-       struct comedi_device *dev = urb->context;
        struct usbduxsigma_private *devpriv = dev->private;
-       struct comedi_subdevice *s = dev->read_subdev;
-       struct comedi_cmd *cmd = &s->async->cmd;
+       struct comedi_async *async = s->async;
+       struct comedi_cmd *cmd = &async->cmd;
        unsigned int dio_state;
        uint32_t val;
        int ret;
        int i;
 
-       /* first we test if something unusual has just happened */
+       devpriv->ai_counter--;
+       if (devpriv->ai_counter == 0) {
+               devpriv->ai_counter = devpriv->ai_timer;
+
+               if (cmd->stop_src == TRIG_COUNT) {
+                       devpriv->ai_sample_count--;
+                       if (devpriv->ai_sample_count < 0) {
+                               async->events |= COMEDI_CB_EOA;
+                               return;
+                       }
+               }
+
+               /* get the state of the dio pins to allow external trigger */
+               dio_state = be32_to_cpu(devpriv->in_buf[0]);
+
+               /* get the data from the USB bus and hand it over to comedi */
+               for (i = 0; i < cmd->chanlist_len; i++) {
+                       /* transfer data, note first byte is the DIO state */
+                       val = be32_to_cpu(devpriv->in_buf[i+1]);
+                       val &= 0x00ffffff;      /* strip status byte */
+                       val ^= 0x00800000;      /* convert to unsigned */
+
+                       if (!comedi_buf_write_samples(s, &val, 1))
+                               return;
+               }
+       }
+
+       /* if command is still running, resubmit urb */
+       if (!(async->events & COMEDI_CB_CANCEL_MASK)) {
+               urb->dev = comedi_to_usb_dev(dev);
+               ret = usb_submit_urb(urb, GFP_ATOMIC);
+               if (ret < 0) {
+                       dev_err(dev->class_dev,
+                               "%s: urb resubmit failed (%d)\n",
+                               __func__, ret);
+                       if (ret == -EL2NSYNC)
+                               dev_err(dev->class_dev,
+                                       "buggy USB host controller or bug in IRQ handler\n");
+                       async->events |= COMEDI_CB_ERROR;
+               }
+       }
+}
+
+static void usbduxsigma_ai_urb_complete(struct urb *urb)
+{
+       struct comedi_device *dev = urb->context;
+       struct usbduxsigma_private *devpriv = dev->private;
+       struct comedi_subdevice *s = dev->read_subdev;
+       struct comedi_async *async = s->async;
+
+       /* exit if not running a command, do not resubmit urb */
+       if (!devpriv->ai_cmd_running)
+               return;
+
        switch (urb->status) {
        case 0:
                /* copy the result in the transfer buffer */
                memcpy(devpriv->in_buf, urb->transfer_buffer, SIZEINBUF);
+               usbduxsigma_ai_handle_urb(dev, s, urb);
                break;
+
        case -EILSEQ:
                /*
                 * error in the ISOchronous data
@@ -235,7 +291,7 @@ static void usbduxsigma_ai_urb_complete(struct urb *urb)
                 * and recycle the last data byte
                 */
                dev_dbg(dev->class_dev, "CRC error in ISO IN stream\n");
-
+               usbduxsigma_ai_handle_urb(dev, s, urb);
                break;
 
        case -ECONNRESET:
@@ -243,86 +299,24 @@ static void usbduxsigma_ai_urb_complete(struct urb *urb)
        case -ESHUTDOWN:
        case -ECONNABORTED:
                /* happens after an unlink command */
-               if (devpriv->ai_cmd_running) {
-                       usbduxsigma_ai_stop(dev, 0);    /* w/o unlink */
-                       /* we are still running a command, tell comedi */
-                       s->async->events |= (COMEDI_CB_EOA | COMEDI_CB_ERROR);
-                       comedi_event(dev, s);
-               }
-               return;
+               async->events |= COMEDI_CB_ERROR;
+               break;
 
        default:
-               /*
-                * a real error on the bus
-                * pass error to comedi if we are really running a command
-                */
-               if (devpriv->ai_cmd_running) {
-                       dev_err(dev->class_dev,
-                               "%s: non-zero urb status (%d)\n",
-                               __func__, urb->status);
-                       usbduxsigma_ai_stop(dev, 0);    /* w/o unlink */
-                       s->async->events |= (COMEDI_CB_EOA | COMEDI_CB_ERROR);
-                       comedi_event(dev, s);
-               }
-               return;
-       }
-
-       if (unlikely(!devpriv->ai_cmd_running))
-               return;
-
-       urb->dev = comedi_to_usb_dev(dev);
-
-       ret = usb_submit_urb(urb, GFP_ATOMIC);
-       if (unlikely(ret < 0)) {
-               dev_err(dev->class_dev, "%s: urb resubmit failed (%d)\n",
-                       __func__, ret);
-               if (ret == -EL2NSYNC)
-                       dev_err(dev->class_dev,
-                               "buggy USB host controller or bug in IRQ handler\n");
-               usbduxsigma_ai_stop(dev, 0);    /* w/o unlink */
-               s->async->events |= (COMEDI_CB_EOA | COMEDI_CB_ERROR);
-               comedi_event(dev, s);
-               return;
-       }
-
-       /* get the state of the dio pins to allow external trigger */
-       dio_state = be32_to_cpu(devpriv->in_buf[0]);
-
-       devpriv->ai_counter--;
-       if (likely(devpriv->ai_counter > 0))
-               return;
-
-       /* timer zero, transfer measurements to comedi */
-       devpriv->ai_counter = devpriv->ai_timer;
-
-       if (cmd->stop_src == TRIG_COUNT) {
-               /* not continuous, fixed number of samples */
-               devpriv->ai_sample_count--;
-               if (devpriv->ai_sample_count < 0) {
-                       usbduxsigma_ai_stop(dev, 0);    /* w/o unlink */
-                       /* acquistion is over, tell comedi */
-                       s->async->events |= COMEDI_CB_EOA;
-                       comedi_event(dev, s);
-                       return;
-               }
+               /* a real error */
+               dev_err(dev->class_dev, "%s: non-zero urb status (%d)\n",
+                       __func__, urb->status);
+               async->events |= COMEDI_CB_ERROR;
+               break;
        }
 
-       /* get the data from the USB bus and hand it over to comedi */
-       for (i = 0; i < cmd->chanlist_len; i++) {
-               /* transfer data, note first byte is the DIO state */
-               val = be32_to_cpu(devpriv->in_buf[i+1]);
-               val &= 0x00ffffff;      /* strip status byte */
-               val ^= 0x00800000;      /* convert to unsigned */
+       /*
+        * comedi_handle_events() cannot be used in this driver. The (*cancel)
+        * operation would unlink the urb.
+        */
+       if (async->events & COMEDI_CB_CANCEL_MASK)
+               usbduxsigma_ai_stop(dev, 0);
 
-               ret = cfc_write_array_to_buffer(s, &val, sizeof(uint32_t));
-               if (unlikely(ret == 0)) {
-                       /* buffer overflow */
-                       usbduxsigma_ai_stop(dev, 0);    /* w/o unlink */
-                       return;
-               }
-       }
-       /* tell comedi that data is there */
-       s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS);
        comedi_event(dev, s);
 }
 
@@ -349,62 +343,25 @@ static int usbduxsigma_ao_cancel(struct comedi_device *dev,
        return 0;
 }
 
-static void usbduxsigma_ao_urb_complete(struct urb *urb)
+static void usbduxsigma_ao_handle_urb(struct comedi_device *dev,
+                                     struct comedi_subdevice *s,
+                                     struct urb *urb)
 {
-       struct comedi_device *dev = urb->context;
        struct usbduxsigma_private *devpriv = dev->private;
-       struct comedi_subdevice *s = dev->write_subdev;
-       struct comedi_cmd *cmd = &s->async->cmd;
+       struct comedi_async *async = s->async;
+       struct comedi_cmd *cmd = &async->cmd;
        uint8_t *datap;
        int ret;
        int i;
 
-       switch (urb->status) {
-       case 0:
-               /* success */
-               break;
-
-       case -ECONNRESET:
-       case -ENOENT:
-       case -ESHUTDOWN:
-       case -ECONNABORTED:
-               /* happens after an unlink command */
-               if (devpriv->ao_cmd_running) {
-                       usbduxsigma_ao_stop(dev, 0);    /* w/o unlink */
-                       s->async->events |= COMEDI_CB_EOA;
-                       comedi_event(dev, s);
-               }
-               return;
-
-       default:
-               /* a real error */
-               if (devpriv->ao_cmd_running) {
-                       dev_err(dev->class_dev,
-                               "%s: non-zero urb status (%d)\n",
-                               __func__, urb->status);
-                       usbduxsigma_ao_stop(dev, 0);    /* w/o unlink */
-                       s->async->events |= (COMEDI_CB_ERROR | COMEDI_CB_EOA);
-                       comedi_event(dev, s);
-               }
-               return;
-       }
-
-       if (!devpriv->ao_cmd_running)
-               return;
-
        devpriv->ao_counter--;
-       if ((int)devpriv->ao_counter <= 0) {
-               /* timer zero, transfer from comedi */
+       if (devpriv->ao_counter == 0) {
                devpriv->ao_counter = devpriv->ao_timer;
 
                if (cmd->stop_src == TRIG_COUNT) {
-                       /* not continuous, fixed number of samples */
                        devpriv->ao_sample_count--;
                        if (devpriv->ao_sample_count < 0) {
-                               usbduxsigma_ao_stop(dev, 0);    /* w/o unlink */
-                               /* acquistion is over, tell comedi */
-                               s->async->events |= COMEDI_CB_EOA;
-                               comedi_event(dev, s);
+                               async->events |= COMEDI_CB_EOA;
                                return;
                        }
                }
@@ -416,46 +373,86 @@ static void usbduxsigma_ao_urb_complete(struct urb *urb)
                        unsigned int chan = CR_CHAN(cmd->chanlist[i]);
                        unsigned short val;
 
-                       ret = comedi_buf_get(s, &val);
-                       if (ret < 0) {
+                       if (!comedi_buf_read_samples(s, &val, 1)) {
                                dev_err(dev->class_dev, "buffer underflow\n");
-                               s->async->events |= (COMEDI_CB_EOA |
-                                                    COMEDI_CB_OVERFLOW);
+                               async->events |= COMEDI_CB_OVERFLOW;
+                               return;
                        }
+
                        *datap++ = val;
                        *datap++ = chan;
                        s->readback[chan] = val;
-
-                       s->async->events |= COMEDI_CB_BLOCK;
-                       comedi_event(dev, s);
                }
        }
 
-       urb->transfer_buffer_length = SIZEOUTBUF;
-       urb->dev = comedi_to_usb_dev(dev);
-       urb->status = 0;
-       if (devpriv->high_speed)
-               urb->interval = 8;      /* uframes */
-       else
-               urb->interval = 1;      /* frames */
-       urb->number_of_packets = 1;
-       urb->iso_frame_desc[0].offset = 0;
-       urb->iso_frame_desc[0].length = SIZEOUTBUF;
-       urb->iso_frame_desc[0].status = 0;
-       ret = usb_submit_urb(urb, GFP_ATOMIC);
-       if (ret < 0) {
-               dev_err(dev->class_dev,
-                       "%s: urb resubmit failed (%d)\n",
-                       __func__, ret);
-               if (ret == -EL2NSYNC)
+       /* if command is still running, resubmit urb */
+       if (!(async->events & COMEDI_CB_CANCEL_MASK)) {
+               urb->transfer_buffer_length = SIZEOUTBUF;
+               urb->dev = comedi_to_usb_dev(dev);
+               urb->status = 0;
+               if (devpriv->high_speed)
+                       urb->interval = 8;      /* uframes */
+               else
+                       urb->interval = 1;      /* frames */
+               urb->number_of_packets = 1;
+               urb->iso_frame_desc[0].offset = 0;
+               urb->iso_frame_desc[0].length = SIZEOUTBUF;
+               urb->iso_frame_desc[0].status = 0;
+               ret = usb_submit_urb(urb, GFP_ATOMIC);
+               if (ret < 0) {
                        dev_err(dev->class_dev,
-                               "buggy USB host controller or bug in IRQ handler\n");
-               usbduxsigma_ao_stop(dev, 0);    /* w/o unlink */
-               s->async->events |= (COMEDI_CB_EOA | COMEDI_CB_ERROR);
-               comedi_event(dev, s);
+                               "%s: urb resubmit failed (%d)\n",
+                               __func__, ret);
+                       if (ret == -EL2NSYNC)
+                               dev_err(dev->class_dev,
+                                       "buggy USB host controller or bug in IRQ handler\n");
+                       async->events |= COMEDI_CB_ERROR;
+               }
        }
 }
 
+static void usbduxsigma_ao_urb_complete(struct urb *urb)
+{
+       struct comedi_device *dev = urb->context;
+       struct usbduxsigma_private *devpriv = dev->private;
+       struct comedi_subdevice *s = dev->write_subdev;
+       struct comedi_async *async = s->async;
+
+       /* exit if not running a command, do not resubmit urb */
+       if (!devpriv->ao_cmd_running)
+               return;
+
+       switch (urb->status) {
+       case 0:
+               usbduxsigma_ao_handle_urb(dev, s, urb);
+               break;
+
+       case -ECONNRESET:
+       case -ENOENT:
+       case -ESHUTDOWN:
+       case -ECONNABORTED:
+               /* happens after an unlink command */
+               async->events |= COMEDI_CB_ERROR;
+               break;
+
+       default:
+               /* a real error */
+               dev_err(dev->class_dev, "%s: non-zero urb status (%d)\n",
+                       __func__, urb->status);
+               async->events |= COMEDI_CB_ERROR;
+               break;
+       }
+
+       /*
+        * comedi_handle_events() cannot be used in this driver. The (*cancel)
+        * operation would unlink the urb.
+        */
+       if (async->events & COMEDI_CB_CANCEL_MASK)
+               usbduxsigma_ao_stop(dev, 0);
+
+       comedi_event(dev, s);
+}
+
 static int usbduxsigma_submit_urbs(struct comedi_device *dev,
                                   struct urb **urbs, int num_urbs,
                                   int input_urb)
index b684954..9a1dc56 100644 (file)
@@ -97,39 +97,6 @@ int do_rangeinfo_ioctl(struct comedi_device *dev,
        return 0;
 }
 
-static int aref_invalid(struct comedi_subdevice *s, unsigned int chanspec)
-{
-       unsigned int aref;
-
-       /*  disable reporting invalid arefs... maybe someday */
-       return 0;
-
-       aref = CR_AREF(chanspec);
-       switch (aref) {
-       case AREF_DIFF:
-               if (s->subdev_flags & SDF_DIFF)
-                       return 0;
-               break;
-       case AREF_COMMON:
-               if (s->subdev_flags & SDF_COMMON)
-                       return 0;
-               break;
-       case AREF_GROUND:
-               if (s->subdev_flags & SDF_GROUND)
-                       return 0;
-               break;
-       case AREF_OTHER:
-               if (s->subdev_flags & SDF_OTHER)
-                       return 0;
-               break;
-       default:
-               break;
-       }
-       dev_dbg(s->device->class_dev, "subdevice does not support aref %i",
-               aref);
-       return 1;
-}
-
 /**
  * comedi_check_chanlist() - Validate each element in a chanlist.
  * @s: comedi_subdevice struct
@@ -153,8 +120,7 @@ int comedi_check_chanlist(struct comedi_subdevice *s, int n,
                else
                        range_len = 0;
                if (chan >= s->n_chan ||
-                   CR_RANGE(chanspec) >= range_len ||
-                   aref_invalid(s, chanspec)) {
+                   CR_RANGE(chanspec) >= range_len) {
                        dev_warn(dev->class_dev,
                                 "bad chanlist[%d]=0x%08x chan=%d range length=%d\n",
                                 i, chanspec, chan, range_len);
index edf9ff2..7f265ce 100644 (file)
@@ -278,7 +278,7 @@ static void cp_tm1217_get_data(struct cp_tm1217_device *ts)
 
 static irqreturn_t cp_tm1217_sample_thread(int irq, void *handle)
 {
-       struct cp_tm1217_device *ts = (struct cp_tm1217_device *) handle;
+       struct cp_tm1217_device *ts = handle;
        u8 req[2];
        int retval;
 
index d0be1ce..ed356f1 100644 (file)
@@ -71,6 +71,7 @@ MODULE_DESCRIPTION("Driver for the Digi International EPCA PCI based product lin
 MODULE_SUPPORTED_DEVICE("dgap");
 
 static int dgap_start(void);
+static void dgap_stop(void);
 static void dgap_init_globals(void);
 static struct board_t *dgap_found_board(struct pci_dev *pdev, int id,
                                        int boardnum);
@@ -78,8 +79,8 @@ static void dgap_cleanup_board(struct board_t *brd);
 static void dgap_poll_handler(ulong dummy);
 static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
 static void dgap_remove_one(struct pci_dev *dev);
-static int dgap_do_remap(struct board_t *brd);
-static void dgap_release_remap(struct board_t *brd);
+static int dgap_remap(struct board_t *brd);
+static void dgap_unmap(struct board_t *brd);
 static irqreturn_t dgap_intr(int irq, void *voidbrd);
 
 static int dgap_tty_open(struct tty_struct *tty, struct file *file);
@@ -479,19 +480,20 @@ static int dgap_init_module(void)
 
        rc = pci_register_driver(&dgap_driver);
        if (rc)
-               goto err_cleanup;
+               goto err_stop;
 
        rc = dgap_create_driver_sysfiles(&dgap_driver);
        if (rc)
-               goto err_cleanup;
+               goto err_unregister;
 
        dgap_driver_state = DRIVER_READY;
 
        return 0;
 
-err_cleanup:
-
-       dgap_cleanup_module();
+err_unregister:
+       pci_unregister_driver(&dgap_driver);
+err_stop:
+       dgap_stop();
 
        return rc;
 }
@@ -561,6 +563,21 @@ failed_class:
        return rc;
 }
 
+static void dgap_stop(void)
+{
+       unsigned long lock_flags;
+
+       spin_lock_irqsave(&dgap_poll_lock, lock_flags);
+       dgap_poll_stop = 1;
+       spin_unlock_irqrestore(&dgap_poll_lock, lock_flags);
+
+       del_timer_sync(&dgap_poll_timer);
+
+       device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0));
+       class_destroy(dgap_class);
+       unregister_chrdev(DIGI_DGAP_MAJOR, "dgap");
+}
+
 static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        int rc;
@@ -621,7 +638,7 @@ free_flipbuf:
        dgap_free_flipbuf(brd);
 cleanup_brd:
        dgap_cleanup_nodes();
-       dgap_release_remap(brd);
+       dgap_unmap(brd);
        kfree(brd);
 
        return rc;
@@ -639,7 +656,7 @@ static void dgap_remove_one(struct pci_dev *dev)
  */
 static void dgap_cleanup_module(void)
 {
-       int i;
+       unsigned int i;
        ulong lock_flags;
 
        spin_lock_irqsave(&dgap_poll_lock, lock_flags);
@@ -674,7 +691,7 @@ static void dgap_cleanup_module(void)
  */
 static void dgap_cleanup_board(struct board_t *brd)
 {
-       int i;
+       unsigned int i;
 
        if (!brd || brd->magic != DGAP_BOARD_MAGIC)
                return;
@@ -683,7 +700,7 @@ static void dgap_cleanup_board(struct board_t *brd)
 
        tasklet_kill(&brd->helper_tasklet);
 
-       dgap_release_remap(brd);
+       dgap_unmap(brd);
 
        /* Free all allocated channels structs */
        for (i = 0; i < MAXPORTS ; i++)
@@ -804,7 +821,7 @@ static struct board_t *dgap_found_board(struct pci_dev *pdev, int id,
        tasklet_init(&brd->helper_tasklet, dgap_poll_tasklet,
                        (unsigned long) brd);
 
-       ret = dgap_do_remap(brd);
+       ret = dgap_remap(brd);
        if (ret)
                goto free_brd;
 
@@ -979,7 +996,7 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type,
 /*
  * Remap PCI memory.
  */
-static int dgap_do_remap(struct board_t *brd)
+static int dgap_remap(struct board_t *brd)
 {
        if (!brd || brd->magic != DGAP_BOARD_MAGIC)
                return -EIO;
@@ -1011,17 +1028,12 @@ static int dgap_do_remap(struct board_t *brd)
        return 0;
 }
 
-static void dgap_release_remap(struct board_t *brd)
+static void dgap_unmap(struct board_t *brd)
 {
-       if (brd->re_map_membase) {
-               release_mem_region(brd->membase, 0x200000);
-               iounmap(brd->re_map_membase);
-       }
-
-       if (brd->re_map_port) {
-               release_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000);
-               iounmap(brd->re_map_port);
-       }
+       iounmap(brd->re_map_port);
+       iounmap(brd->re_map_membase);
+       release_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000);
+       release_mem_region(brd->membase, 0x200000);
 }
 /*****************************************************************************
 *
@@ -1051,7 +1063,7 @@ static void dgap_release_remap(struct board_t *brd)
 
 static void dgap_poll_handler(ulong dummy)
 {
-       int i;
+       unsigned int i;
        struct board_t *brd;
        unsigned long lock_flags;
        ulong new_time;
@@ -1155,7 +1167,7 @@ schedule_poller:
  */
 static irqreturn_t dgap_intr(int irq, void *voidbrd)
 {
-       struct board_t *brd = (struct board_t *) voidbrd;
+       struct board_t *brd = voidbrd;
 
        if (!brd)
                return IRQ_NONE;
@@ -1184,7 +1196,7 @@ static irqreturn_t dgap_intr(int irq, void *voidbrd)
  */
 static void dgap_init_globals(void)
 {
-       int i;
+       unsigned int i;
 
        for (i = 0; i < MAXBOARDS; i++)
                dgap_board[i] = NULL;
@@ -1503,7 +1515,7 @@ static void dgap_tty_free(struct board_t *brd)
 static void dgap_cleanup_tty(struct board_t *brd)
 {
        struct device *dev;
-       int i;
+       unsigned int i;
 
        dgap_boards_by_major[brd->serial_driver->major] = NULL;
        brd->dgap_serial_major = 0;
@@ -2629,7 +2641,6 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf,
        char __iomem *vaddr;
        u16 head, tail, tmask, remain;
        int bufcount, n;
-       int orig_count;
        ulong lock_flags;
 
        if (!tty)
@@ -2650,13 +2661,6 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf,
        if (!count)
                return 0;
 
-       /*
-        * Store original amount of characters passed in.
-        * This helps to figure out if we should ask the FEP
-        * to send us an event when it has more space available.
-        */
-       orig_count = count;
-
        spin_lock_irqsave(&ch->ch_lock, lock_flags);
 
        /* Get our space available for the channel from the board */
@@ -4117,7 +4121,7 @@ static void dgap_do_bios_load(struct board_t *brd, const u8 *ubios, int len)
 {
        u8 __iomem *addr;
        uint offset;
-       int i;
+       unsigned int i;
 
        if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase)
                return;
@@ -4213,7 +4217,7 @@ static void dgap_do_fep_load(struct board_t *brd, const u8 *ufep, int len)
                u8 string[100];
                u8 __iomem *config;
                u8 *xconfig;
-               int i = 0;
+               unsigned int i = 0;
 
                xconfig = dgap_create_config_string(brd, string);
 
@@ -4289,7 +4293,7 @@ static void dgap_do_reset_board(struct board_t *brd)
        u8 check;
        u32 check1;
        u32 check2;
-       int i;
+       unsigned int i;
 
        if (!brd || (brd->magic != DGAP_BOARD_MAGIC) ||
            !brd->re_map_membase || !brd->re_map_port)
@@ -5626,7 +5630,7 @@ static ssize_t dgap_ports_state_show(struct device *p,
 {
        struct board_t *bd;
        int count = 0;
-       int i;
+       unsigned int i;
 
        bd = dgap_verify_board(p);
        if (!bd)
@@ -5647,7 +5651,7 @@ static ssize_t dgap_ports_baud_show(struct device *p,
 {
        struct board_t *bd;
        int count = 0;
-       int i;
+       unsigned int i;
 
        bd = dgap_verify_board(p);
        if (!bd)
@@ -5668,7 +5672,7 @@ static ssize_t dgap_ports_msignals_show(struct device *p,
 {
        struct board_t *bd;
        int count = 0;
-       int i;
+       unsigned int i;
 
        bd = dgap_verify_board(p);
        if (!bd)
@@ -5705,7 +5709,7 @@ static ssize_t dgap_ports_iflag_show(struct device *p,
 {
        struct board_t *bd;
        int count = 0;
-       int i;
+       unsigned int i;
 
        bd = dgap_verify_board(p);
        if (!bd)
@@ -5725,7 +5729,7 @@ static ssize_t dgap_ports_cflag_show(struct device *p,
 {
        struct board_t *bd;
        int count = 0;
-       int i;
+       unsigned int i;
 
        bd = dgap_verify_board(p);
        if (!bd)
@@ -5745,7 +5749,7 @@ static ssize_t dgap_ports_oflag_show(struct device *p,
 {
        struct board_t *bd;
        int count = 0;
-       int i;
+       unsigned int i;
 
        bd = dgap_verify_board(p);
        if (!bd)
@@ -5765,7 +5769,7 @@ static ssize_t dgap_ports_lflag_show(struct device *p,
 {
        struct board_t *bd;
        int count = 0;
-       int i;
+       unsigned int i;
 
        bd = dgap_verify_board(p);
        if (!bd)
@@ -5785,7 +5789,7 @@ static ssize_t dgap_ports_digi_flag_show(struct device *p,
 {
        struct board_t *bd;
        int count = 0;
-       int i;
+       unsigned int i;
 
        bd = dgap_verify_board(p);
        if (!bd)
@@ -5805,7 +5809,7 @@ static ssize_t dgap_ports_rxcount_show(struct device *p,
 {
        struct board_t *bd;
        int count = 0;
-       int i;
+       unsigned int i;
 
        bd = dgap_verify_board(p);
        if (!bd)
@@ -5825,7 +5829,7 @@ static ssize_t dgap_ports_txcount_show(struct device *p,
 {
        struct board_t *bd;
        int count = 0;
-       int i;
+       unsigned int i;
 
        bd = dgap_verify_board(p);
        if (!bd)
@@ -7024,7 +7028,7 @@ static char *dgap_sindex(char *string, char *group)
        char *ptr;
 
        if (!string || !group)
-               return (char *) NULL;
+               return NULL;
 
        if (*group == '^') {
                group++;
@@ -7045,7 +7049,7 @@ static char *dgap_sindex(char *string, char *group)
                }
        }
 
-       return (char *) NULL;
+       return NULL;
 }
 
 /*
index a17f4f6..bedc522 100644 (file)
@@ -724,10 +724,8 @@ static void cls_tasklet(unsigned long data)
        int state = 0;
        int ports = 0;
 
-       if (!bd || bd->magic != DGNC_BOARD_MAGIC) {
-               APR(("poll_tasklet() - NULL or bad bd.\n"));
+       if (!bd || bd->magic != DGNC_BOARD_MAGIC)
                return;
-       }
 
        /* Cache a couple board values */
        spin_lock_irqsave(&bd->bd_lock, flags);
@@ -794,25 +792,17 @@ static void cls_tasklet(unsigned long data)
  */
 static irqreturn_t cls_intr(int irq, void *voidbrd)
 {
-       struct dgnc_board *brd = (struct dgnc_board *) voidbrd;
+       struct dgnc_board *brd = voidbrd;
        uint i = 0;
        unsigned char poll_reg;
        unsigned long flags;
 
-       if (!brd) {
-               APR(("Received interrupt (%d) with null board associated\n",
-                                                                        irq));
-               return IRQ_NONE;
-       }
-
        /*
-        * Check to make sure its for us.
+        * Check to make sure it didn't receive interrupt with a null board
+        * associated or a board pointer that wasn't ours.
         */
-       if (brd->magic != DGNC_BOARD_MAGIC) {
-               APR(("Received interrupt (%d) with a board pointer that wasn't ours!\n",
-                         irq));
+       if (!brd || brd->magic != DGNC_BOARD_MAGIC)
                return IRQ_NONE;
-       }
 
        spin_lock_irqsave(&brd->bd_intr_lock, flags);
 
@@ -928,8 +918,6 @@ static void cls_copy_data_from_uart_to_queue(struct channel_t *ch)
                ch->ch_equeue[head] = linestatus & (UART_LSR_BI | UART_LSR_PE
                                                                 | UART_LSR_FE);
                ch->ch_rqueue[head] = readb(&ch->ch_cls_uart->txrx);
-               dgnc_sniff_nowait_nolock(ch, "UART READ",
-                                                ch->ch_rqueue + head, 1);
 
                qleft--;
 
@@ -964,7 +952,6 @@ static int cls_drain(struct tty_struct *tty, uint seconds)
        unsigned long flags;
        struct channel_t *ch;
        struct un_t *un;
-       int rc = 0;
 
        if (!tty || tty->magic != TTY_MAGIC)
                return -ENXIO;
@@ -984,12 +971,11 @@ static int cls_drain(struct tty_struct *tty, uint seconds)
        /*
         * NOTE: Do something with time passed in.
         */
-       rc = wait_event_interruptible(un->un_flags_wait,
-                                        ((un->un_flags & UN_EMPTY) == 0));
 
        /* If ret is non-zero, user ctrl-c'ed us */
 
-       return rc;
+       return wait_event_interruptible(un->un_flags_wait,
+                                        ((un->un_flags & UN_EMPTY) == 0));
 }
 
 
@@ -1098,8 +1084,6 @@ static void cls_copy_data_from_queue_to_uart(struct channel_t *ch)
                        ch->ch_tun.un_flags |= (UN_EMPTY);
                }
                writeb(ch->ch_wqueue[ch->ch_w_tail], &ch->ch_cls_uart->txrx);
-               dgnc_sniff_nowait_nolock(ch, "UART WRITE",
-                                           ch->ch_wqueue + ch->ch_w_tail, 1);
                ch->ch_w_tail++;
                ch->ch_w_tail &= WQUEUEMASK;
                ch->ch_txcount++;
index 2154665..ba98ff3 100644 (file)
@@ -49,16 +49,6 @@ MODULE_AUTHOR("Digi International, http://www.digi.com");
 MODULE_DESCRIPTION("Driver for the Digi International Neo and Classic PCI based product line");
 MODULE_SUPPORTED_DEVICE("dgnc");
 
-/*
- * insmod command line overrideable parameters
- *
- * NOTE: we use a set of macros to create the variables, which allows
- * us to specify the variable type, name, initial value, and description.
- */
-PARM_INT(debug,                0x00,           0644,   "Driver debugging level");
-PARM_INT(rawreadok,    1,              0644,   "Bypass flip buffers on input");
-PARM_INT(trcbuf_size,  0x100000,       0644,   "Debugging trace buffer size.");
-
 /**************************************************************************
  *
  * protos for this file
@@ -207,8 +197,6 @@ static int __init dgnc_init_module(void)
 {
        int rc = 0;
 
-       APR(("%s, Digi International Part Number %s\n", DG_NAME, DG_PART));
-
        /*
         * Initialize global stuff
         */
@@ -254,8 +242,6 @@ static int dgnc_start(void)
        /* make sure that the globals are init'd before we do anything else */
        dgnc_init_globals();
 
-       APR(("For the tools package or updated drivers please visit http://www.digi.com\n"));
-
        /*
         * Register our base character device into the kernel.
         * This allows the download daemon to connect to the downld device
@@ -265,7 +251,7 @@ static int dgnc_start(void)
         */
        rc = register_chrdev(0, "dgnc", &dgnc_BoardFops);
        if (rc <= 0) {
-               APR(("Can't register dgnc driver device (%d)\n", rc));
+               pr_err(DRVSTR ": Can't register dgnc driver device (%d)\n", rc);
                return -ENXIO;
        }
        dgnc_Major = rc;
@@ -281,7 +267,7 @@ static int dgnc_start(void)
        rc = dgnc_tty_preinit();
 
        if (rc < 0) {
-               APR(("tty preinit - not enough memory (%d)\n", rc));
+               pr_err(DRVSTR ": tty preinit - not enough memory (%d)\n", rc);
                return rc;
        }
 
@@ -468,7 +454,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
                brd->membase = pci_resource_start(pdev, 4);
 
                if (!brd->membase) {
-                       APR(("card has no PCI IO resources, failing board.\n"));
+                       dev_err(&brd->pdev->dev,
+                               "Card has no PCI IO resources, failing.\n");
                        return -ENODEV;
                }
 
@@ -555,7 +542,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
                break;
 
        default:
-               APR(("Did not find any compatible Neo or Classic PCI boards in system.\n"));
+               dev_err(&brd->pdev->dev,
+                       "Didn't find any compatible Neo/Classic PCI boards.\n");
                return -ENXIO;
 
        }
@@ -567,7 +555,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
        rc = dgnc_tty_register(brd);
        if (rc < 0) {
                dgnc_tty_uninit(brd);
-               APR(("Can't register tty devices (%d)\n", rc));
+               pr_err(DRVSTR ": Can't register tty devices (%d)\n", rc);
                brd->state = BOARD_FAILED;
                brd->dpastatus = BD_NOFEP;
                goto failed;
@@ -575,7 +563,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
        rc = dgnc_finalize_board_init(brd);
        if (rc < 0) {
-               APR(("Can't finalize board init (%d)\n", rc));
+               pr_err(DRVSTR ": Can't finalize board init (%d)\n", rc);
                brd->state = BOARD_FAILED;
                brd->dpastatus = BD_NOFEP;
 
@@ -585,7 +573,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
        rc = dgnc_tty_init(brd);
        if (rc < 0) {
                dgnc_tty_uninit(brd);
-               APR(("Can't init tty devices (%d)\n", rc));
+               pr_err(DRVSTR ": Can't init tty devices (%d)\n", rc);
                brd->state = BOARD_FAILED;
                brd->dpastatus = BD_NOFEP;
 
@@ -744,9 +732,6 @@ static void dgnc_init_globals(void)
 {
        int i = 0;
 
-       dgnc_rawreadok          = rawreadok;
-       dgnc_trcbuf_size        = trcbuf_size;
-       dgnc_debug              = debug;
        dgnc_NumBoards          = 0;
 
        for (i = 0; i < MAXBOARDS; i++)
index f901957..a8157eb 100644 (file)
  *
  *************************************************************************/
 
-/*
- * Driver identification, error and debugging statments
- *
- * In theory, you can change all occurrences of "digi" in the next
- * three lines, and the driver printk's will all automagically change.
- *
- * APR((fmt, args, ...));      Always prints message
- */
+/* Driver identification and error statments */
 #define        PROCSTR         "dgnc"                  /* /proc entries         */
 #define        DEVSTR          "/dev/dg/dgnc"          /* /dev entries          */
-#define        DRVSTR          "dgnc"                  /* Driver name string
-                                                * displayed by APR      */
-#define        APR(args)       do { printk(DRVSTR": "); printk args; \
-                          } while (0)
-#define        RAPR(args)      do { printk args; } while (0)
+#define        DRVSTR          "dgnc"                  /* Driver name string    */
 
 #define TRC_TO_CONSOLE 1
 
-/*
- * Debugging levels can be set using debug insmod variable
- * They can also be compiled out completely.
- */
-
-#define        DBG_INIT                (dgnc_debug & 0x01)
-#define        DBG_BASIC               (dgnc_debug & 0x02)
-#define        DBG_CORE                (dgnc_debug & 0x04)
-
-#define        DBG_OPEN                (dgnc_debug & 0x08)
-#define        DBG_CLOSE               (dgnc_debug & 0x10)
-#define        DBG_READ                (dgnc_debug & 0x20)
-#define        DBG_WRITE               (dgnc_debug & 0x40)
-
-#define        DBG_IOCTL               (dgnc_debug & 0x80)
-
-#define        DBG_PROC                (dgnc_debug & 0x100)
-#define        DBG_PARAM               (dgnc_debug & 0x200)
-#define        DBG_PSCAN               (dgnc_debug & 0x400)
-#define        DBG_EVENT               (dgnc_debug & 0x800)
-
-#define        DBG_DRAIN               (dgnc_debug & 0x1000)
-#define        DBG_MSIGS               (dgnc_debug & 0x2000)
-
-#define        DBG_MGMT                (dgnc_debug & 0x4000)
-#define        DBG_INTR                (dgnc_debug & 0x8000)
-
-#define        DBG_CARR                (dgnc_debug & 0x10000)
-
 /* Number of boards we support at once. */
 #define        MAXBOARDS       20
 #define        MAXPORTS        8
 #define   _POSIX_VDISABLE '\0'
 #endif
 
-#define SNIFF_MAX      65536           /* Sniff buffer size (2^n) */
-#define SNIFF_MASK     (SNIFF_MAX - 1) /* Sniff wrap mask */
 
 /*
  * All the possible states the driver can be while being loaded.
@@ -342,13 +300,6 @@ struct un_t {
 #define CH_FORCED_STOP  0x20000                /* Output is forcibly stopped   */
 #define CH_FORCED_STOPI 0x40000                /* Input is forcibly stopped    */
 
-/*
- * Definitions for ch_sniff_flags
- */
-#define SNIFF_OPEN     0x1
-#define SNIFF_WAIT_DATA        0x2
-#define SNIFF_WAIT_SPACE 0x4
-
 
 /* Our Read/Error/Write queue sizes */
 #define RQUEUEMASK     0x1FFF          /* 8 K - 1 */
@@ -442,21 +393,13 @@ struct channel_t {
        struct proc_dir_entry *proc_entry_pointer;
        struct dgnc_proc_entry *dgnc_channel_table;
 
-       uint ch_sniff_in;
-       uint ch_sniff_out;
-       char *ch_sniff_buf;             /* Sniff buffer for proc */
-       ulong ch_sniff_flags;           /* Channel flags                */
-       wait_queue_head_t ch_sniff_wait;
 };
 
 /*
  * Our Global Variables.
  */
 extern uint            dgnc_Major;             /* Our driver/mgmt major        */
-extern int             dgnc_debug;             /* Debug variable               */
-extern int             dgnc_rawreadok;         /* Set if user wants rawreads   */
 extern int             dgnc_poll_tick;         /* Poll interval - 20 ms        */
-extern int             dgnc_trcbuf_size;       /* Size of the ringbuffer       */
 extern spinlock_t      dgnc_global_lock;       /* Driver global spinlock       */
 extern uint            dgnc_NumBoards;         /* Total number of boards       */
 extern struct dgnc_board       *dgnc_Board[MAXBOARDS]; /* Array of board structs       */
index eaec7e6..566cad0 100644 (file)
 # endif
 
 
-#  define PARM_STR(VAR, INIT, PERM, DESC) \
-               static char *VAR = INIT; \
-               char *dgnc_##VAR; \
-               module_param(VAR, charp, PERM); \
-               MODULE_PARM_DESC(VAR, DESC);
-
-#  define PARM_INT(VAR, INIT, PERM, DESC) \
-               static int VAR = INIT; \
-               int dgnc_##VAR; \
-               module_param(VAR, int, PERM); \
-               MODULE_PARM_DESC(VAR, DESC);
-
-#  define PARM_ULONG(VAR, INIT, PERM, DESC) \
-               static ulong VAR = INIT; \
-               ulong dgnc_##VAR; \
-               module_param(VAR, long, PERM); \
-               MODULE_PARM_DESC(VAR, DESC);
-
 #endif /* ! __DGNC_KCOMPAT_H */
index a5bd08f..c9a8a98 100644 (file)
@@ -530,10 +530,11 @@ static inline void neo_parse_lsr(struct dgnc_board *brd, uint port)
        int linestatus;
        unsigned long flags;
 
-       if (!brd)
-               return;
-
-       if (brd->magic != DGNC_BOARD_MAGIC)
+       /*
+        * Check to make sure it didn't receive interrupt with a null board
+        * associated or a board pointer that wasn't ours.
+        */
+       if (!brd || brd->magic != DGNC_BOARD_MAGIC)
                return;
 
        if (port > brd->maxports)
@@ -869,10 +870,8 @@ static void neo_tasklet(unsigned long data)
        int state = 0;
        int ports = 0;
 
-       if (!bd || bd->magic != DGNC_BOARD_MAGIC) {
-               APR(("poll_tasklet() - NULL or bad bd.\n"));
+       if (!bd || bd->magic != DGNC_BOARD_MAGIC)
                return;
-       }
 
        /* Cache a couple board values */
        spin_lock_irqsave(&bd->bd_lock, flags);
@@ -945,7 +944,7 @@ static void neo_tasklet(unsigned long data)
  */
 static irqreturn_t neo_intr(int irq, void *voidbrd)
 {
-       struct dgnc_board *brd = (struct dgnc_board *) voidbrd;
+       struct dgnc_board *brd = voidbrd;
        struct channel_t *ch;
        int port = 0;
        int type = 0;
@@ -955,18 +954,12 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
        unsigned long flags;
        unsigned long flags2;
 
-       if (!brd) {
-               APR(("Received interrupt (%d) with null board associated\n", irq));
-               return IRQ_NONE;
-       }
-
        /*
-        * Check to make sure its for us.
+        * Check to make sure it didn't receive interrupt with a null board
+        * associated or a board pointer that wasn't ours.
         */
-       if (brd->magic != DGNC_BOARD_MAGIC) {
-               APR(("Received interrupt (%d) with a board pointer that wasn't ours!\n", irq));
+       if (!brd || brd->magic != DGNC_BOARD_MAGIC)
                return IRQ_NONE;
-       }
 
        brd->intr_count++;
 
@@ -1224,7 +1217,6 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch)
 
                /* Copy data from uart to the queue */
                memcpy_fromio(ch->ch_rqueue + head, &ch->ch_neo_uart->txrxburst, n);
-               dgnc_sniff_nowait_nolock(ch, "UART READ", ch->ch_rqueue + head, n);
 
                /*
                 * Since RX_FIFO_DATA_ERROR was 0, we are guarenteed
@@ -1310,7 +1302,6 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch)
 
                memcpy_fromio(ch->ch_rqueue + head, &ch->ch_neo_uart->txrxburst, 1);
                ch->ch_equeue[head] = (unsigned char) linestatus;
-               dgnc_sniff_nowait_nolock(ch, "UART READ", ch->ch_rqueue + head, 1);
 
                /* Ditch any remaining linestatus value. */
                linestatus = 0;
@@ -1563,7 +1554,6 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch)
                }
 
                memcpy_toio(&ch->ch_neo_uart->txrxburst, ch->ch_wqueue + tail, s);
-               dgnc_sniff_nowait_nolock(ch, "UART WRITE", ch->ch_wqueue + tail, s);
 
                /* Add and flip queue if needed */
                tail = (tail + s) & WQUEUEMASK;
index 6c3b387..2fd34ca 100644 (file)
@@ -63,39 +63,6 @@ static ssize_t dgnc_driver_maxboards_show(struct device_driver *ddp, char *buf)
 }
 static DRIVER_ATTR(maxboards, S_IRUSR, dgnc_driver_maxboards_show, NULL);
 
-static ssize_t dgnc_driver_debug_show(struct device_driver *ddp, char *buf)
-{
-       return snprintf(buf, PAGE_SIZE, "0x%x\n", dgnc_debug);
-}
-
-static ssize_t dgnc_driver_debug_store(struct device_driver *ddp, const char *buf, size_t count)
-{
-       int ret;
-
-       ret = sscanf(buf, "0x%x\n", &dgnc_debug);
-       if (ret != 1)
-               return -EINVAL;
-       return count;
-}
-static DRIVER_ATTR(debug, (S_IRUSR | S_IWUSR), dgnc_driver_debug_show, dgnc_driver_debug_store);
-
-
-static ssize_t dgnc_driver_rawreadok_show(struct device_driver *ddp, char *buf)
-{
-       return snprintf(buf, PAGE_SIZE, "0x%x\n", dgnc_rawreadok);
-}
-
-static ssize_t dgnc_driver_rawreadok_store(struct device_driver *ddp, const char *buf, size_t count)
-{
-       int ret;
-
-       ret = sscanf(buf, "0x%x\n", &dgnc_rawreadok);
-       if (ret != 1)
-               return -EINVAL;
-       return count;
-}
-static DRIVER_ATTR(rawreadok, (S_IRUSR | S_IWUSR), dgnc_driver_rawreadok_show, dgnc_driver_rawreadok_store);
-
 
 static ssize_t dgnc_driver_pollrate_show(struct device_driver *ddp, char *buf)
 {
@@ -122,8 +89,6 @@ void dgnc_create_driver_sysfiles(struct pci_driver *dgnc_driver)
        rc |= driver_create_file(driverfs, &driver_attr_version);
        rc |= driver_create_file(driverfs, &driver_attr_boards);
        rc |= driver_create_file(driverfs, &driver_attr_maxboards);
-       rc |= driver_create_file(driverfs, &driver_attr_debug);
-       rc |= driver_create_file(driverfs, &driver_attr_rawreadok);
        rc |= driver_create_file(driverfs, &driver_attr_pollrate);
        if (rc)
                printk(KERN_ERR "DGNC: sysfs driver_create_file failed!\n");
@@ -137,8 +102,6 @@ void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver)
        driver_remove_file(driverfs, &driver_attr_version);
        driver_remove_file(driverfs, &driver_attr_boards);
        driver_remove_file(driverfs, &driver_attr_maxboards);
-       driver_remove_file(driverfs, &driver_attr_debug);
-       driver_remove_file(driverfs, &driver_attr_rawreadok);
        driver_remove_file(driverfs, &driver_attr_pollrate);
 }
 
index 03c1506..f81a375 100644 (file)
@@ -49,7 +49,6 @@
 #include <linux/delay.h>       /* For udelay */
 #include <linux/uaccess.h>     /* For copy_from_user/copy_to_user */
 #include <linux/pci.h>
-
 #include "dgnc_driver.h"
 #include "dgnc_tty.h"
 #include "dgnc_types.h"
@@ -233,7 +232,8 @@ int dgnc_tty_register(struct dgnc_board *brd)
                /* Register tty devices */
                rc = tty_register_driver(&brd->SerialDriver);
                if (rc < 0) {
-                       APR(("Can't register tty device (%d)\n", rc));
+                       dev_dbg(&brd->pdev->dev,
+                               "Can't register tty device (%d)\n", rc);
                        return rc;
                }
                brd->dgnc_Major_Serial_Registered = TRUE;
@@ -281,7 +281,9 @@ int dgnc_tty_register(struct dgnc_board *brd)
                /* Register Transparent Print devices */
                rc = tty_register_driver(&brd->PrintDriver);
                if (rc < 0) {
-                       APR(("Can't register Transparent Print device (%d)\n", rc));
+                       dev_dbg(&brd->pdev->dev,
+                               "Can't register Transparent Print device(%d)\n",
+                               rc);
                        return rc;
                }
                brd->dgnc_Major_TransparentPrint_Registered = TRUE;
@@ -371,7 +373,6 @@ int dgnc_tty_init(struct dgnc_board *brd)
                init_waitqueue_head(&ch->ch_flags_wait);
                init_waitqueue_head(&ch->ch_tun.un_flags_wait);
                init_waitqueue_head(&ch->ch_pun.un_flags_wait);
-               init_waitqueue_head(&ch->ch_sniff_wait);
 
                {
                        struct device *classp;
@@ -446,127 +447,6 @@ void dgnc_tty_uninit(struct dgnc_board *brd)
 
 #define TMPBUFLEN (1024)
 
-/*
- * dgnc_sniff - Dump data out to the "sniff" buffer if the
- * proc sniff file is opened...
- */
-void dgnc_sniff_nowait_nolock(struct channel_t *ch, unsigned char *text, unsigned char *buf, int len)
-{
-       struct timeval tv;
-       int n;
-       int r;
-       int nbuf;
-       int i;
-       int tmpbuflen;
-       char *tmpbuf;
-       char *p;
-       int too_much_data;
-
-       tmpbuf = kzalloc(TMPBUFLEN, GFP_ATOMIC);
-       if (!tmpbuf)
-               return;
-       p = tmpbuf;
-
-       /* Leave if sniff not open */
-       if (!(ch->ch_sniff_flags & SNIFF_OPEN))
-               goto exit;
-
-       do_gettimeofday(&tv);
-
-       /* Create our header for data dump */
-       p += sprintf(p, "<%ld %ld><%s><", tv.tv_sec, tv.tv_usec, text);
-       tmpbuflen = p - tmpbuf;
-
-       do {
-               too_much_data = 0;
-
-               for (i = 0; i < len && tmpbuflen < (TMPBUFLEN - 4); i++) {
-                       p += sprintf(p, "%02x ", *buf);
-                       buf++;
-                       tmpbuflen = p - tmpbuf;
-               }
-
-               if (tmpbuflen < (TMPBUFLEN - 4)) {
-                       if (i > 0)
-                               p += sprintf(p - 1, "%s\n", ">");
-                       else
-                               p += sprintf(p, "%s\n", ">");
-               } else {
-                       too_much_data = 1;
-                       len -= i;
-               }
-
-               nbuf = strlen(tmpbuf);
-               p = tmpbuf;
-
-               /*
-                *  Loop while data remains.
-                */
-               while (nbuf > 0 && ch->ch_sniff_buf) {
-                       /*
-                        *  Determine the amount of available space left in the
-                        *  buffer.  If there's none, wait until some appears.
-                        */
-                       n = (ch->ch_sniff_out - ch->ch_sniff_in - 1) & SNIFF_MASK;
-
-                       /*
-                        * If there is no space left to write to in our sniff buffer,
-                        * we have no choice but to drop the data.
-                        * We *cannot* sleep here waiting for space, because this
-                        * function was probably called by the interrupt/timer routines!
-                        */
-                       if (n == 0)
-                               goto exit;
-
-                       /*
-                        * Copy as much data as will fit.
-                        */
-
-                       if (n > nbuf)
-                               n = nbuf;
-
-                       r = SNIFF_MAX - ch->ch_sniff_in;
-
-                       if (r <= n) {
-                               memcpy(ch->ch_sniff_buf + ch->ch_sniff_in, p, r);
-
-                               n -= r;
-                               ch->ch_sniff_in = 0;
-                               p += r;
-                               nbuf -= r;
-                       }
-
-                       memcpy(ch->ch_sniff_buf + ch->ch_sniff_in, p, n);
-
-                       ch->ch_sniff_in += n;
-                       p += n;
-                       nbuf -= n;
-
-                       /*
-                        *  Wakeup any thread waiting for data
-                        */
-                       if (ch->ch_sniff_flags & SNIFF_WAIT_DATA) {
-                               ch->ch_sniff_flags &= ~SNIFF_WAIT_DATA;
-                               wake_up_interruptible(&ch->ch_sniff_wait);
-                       }
-               }
-
-               /*
-                * If the user sent us too much data to push into our tmpbuf,
-                * we need to keep looping around on all the data.
-                */
-               if (too_much_data) {
-                       p = tmpbuf;
-                       tmpbuflen = 0;
-               }
-
-       } while (too_much_data);
-
-exit:
-       kfree(tmpbuf);
-}
-
-
 /*=======================================================================
  *
  *     dgnc_wmove - Write data to transmit queue.
@@ -781,8 +661,6 @@ void dgnc_input(struct channel_t *ch)
                        tty_insert_flip_string(tp->port, ch->ch_rqueue + tail, s);
                }
 
-               dgnc_sniff_nowait_nolock(ch, "USER READ", ch->ch_rqueue + tail, s);
-
                tail += s;
                n -= s;
                /* Flip queue if needed */
@@ -1546,14 +1424,18 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file)
                 * one, we've got real problems, since it means the
                 * serial port won't be shutdown.
                 */
-               APR(("tty->count is 1, un open count is %d\n", un->un_open_count));
+               dev_dbg(tty->dev,
+                       "tty->count is 1, un open count is %d\n",
+                       un->un_open_count);
                un->un_open_count = 1;
        }
 
        if (un->un_open_count)
                un->un_open_count--;
        else
-               APR(("bad serial port open count of %d\n", un->un_open_count));
+               dev_dbg(tty->dev,
+                       "bad serial port open count of %d\n",
+                       un->un_open_count);
 
        ch->ch_open_count--;
 
@@ -1974,7 +1856,6 @@ static int dgnc_tty_write(struct tty_struct *tty,
        if (n >= remain) {
                n -= remain;
                memcpy(ch->ch_wqueue + head, buf, remain);
-               dgnc_sniff_nowait_nolock(ch, "USER WRITE", ch->ch_wqueue + head, remain);
                head = 0;
                buf += remain;
        }
@@ -1985,7 +1866,6 @@ static int dgnc_tty_write(struct tty_struct *tty,
                 */
                remain = n;
                memcpy(ch->ch_wqueue + head, buf, remain);
-               dgnc_sniff_nowait_nolock(ch, "USER WRITE", ch->ch_wqueue + head, remain);
                head += remain;
        }
 
@@ -2325,8 +2205,6 @@ static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, uns
        if (!bd || bd->magic != DGNC_BOARD_MAGIC)
                return ret;
 
-       ret = 0;
-
        ret = get_user(arg, value);
        if (ret)
                return ret;
@@ -3089,7 +2967,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
                struct digi_getcounter buf;
 
                buf.norun = ch->ch_err_overrun;
-               buf.noflow = 0;         /* The driver doesn't keep this stat */
+               buf.noflow = 0;         /* The driver doesn't keep this stat */
                buf.nframe = ch->ch_err_frame;
                buf.nparity = ch->ch_err_parity;
                buf.nbreak = ch->ch_err_break;
index 58eef25..3975f04 100644 (file)
@@ -37,6 +37,4 @@ void  dgnc_carrier(struct channel_t *ch);
 void   dgnc_wakeup_writes(struct channel_t *ch);
 void   dgnc_check_queue_flow_control(struct channel_t *ch);
 
-void   dgnc_sniff_nowait_nolock(struct channel_t *ch, unsigned char *text, unsigned char *buf, int nbuf);
-
 #endif
index 1ae0013..0261d0b 100644 (file)
@@ -2622,7 +2622,7 @@ static int nbu2ss_ep_enable(
                return -EINVAL;
        }
 
-       ep_type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
+       ep_type = usb_endpoint_type(desc);
        if ((ep_type == USB_ENDPOINT_XFER_CONTROL)
                || (ep_type == USB_ENDPOINT_XFER_ISOC)) {
 
@@ -2644,7 +2644,7 @@ static int nbu2ss_ep_enable(
        spin_lock_irqsave(&udc->lock, flags);
 
        ep->desc = desc;
-       ep->epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
+       ep->epnum = usb_endpoint_num(desc);
        ep->direct = desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK;
        ep->ep_type = ep_type;
        ep->wedged = 0;
@@ -2722,8 +2722,7 @@ static void nbu2ss_ep_free_request(
        if (_req != NULL) {
                req = container_of(_req, struct nbu2ss_req, req);
 
-               if (req != NULL)
-                       kfree(req);
+               kfree(req);
        }
 }
 
index 44575c7..25b06d3 100644 (file)
@@ -810,18 +810,18 @@ static void ft1000_send_cmd (struct net_device *dev, u16 *ptempbuffer, int size,
         */
        spin_lock_irqsave(&info->dpram_lock, flags);
 
-    /* Make sure SLOWQ doorbell is clear */
-    tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
-    i=0;
-    while (tempword & FT1000_DB_DPRAM_TX) {
-        mdelay(10);
-        i++;
-        if (i==10) {
-            spin_unlock_irqrestore(&info->dpram_lock, flags);
-            return;
-        }
-        tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
-    }
+       /* Make sure SLOWQ doorbell is clear */
+       tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
+       i = 0;
+       while (tempword & FT1000_DB_DPRAM_TX) {
+               mdelay(10);
+               i++;
+               if (i == 10) {
+                       spin_unlock_irqrestore(&info->dpram_lock, flags);
+                       return;
+               }
+               tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
+       }
 
        if (info->AsicID == ELECTRABUZZ_ID) {
                ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
@@ -997,8 +997,8 @@ static void ft1000_proc_drvmsg(struct net_device *dev)
     }
     else {
         tempword = FT1000_DPRAM_MAG_RX_BASE;
-    }
-    if ( ft1000_receive_cmd(dev, &cmdbuffer[0], MAX_CMD_SQSIZE, &tempword) ) {
+               }
+               if (ft1000_receive_cmd(dev, &cmdbuffer[0], MAX_CMD_SQSIZE, &tempword)) {
 
                /* Get the message type which is total_len + PSEUDO header + msgtype + message body */
                pdrvmsg = (struct drv_msg *) & cmdbuffer[0];
@@ -1224,7 +1224,7 @@ static void ft1000_proc_drvmsg(struct net_device *dev)
                 for (i=1; i<7; i++) {
                     ppseudo_hdr->checksum ^= *pmsg++;
                 }
-                               pmsg = (u16 *) & tempbuffer[16];
+                               pmsg = (u16 *) &tempbuffer[16];
                                *pmsg++ = htons(RSP_DRV_ERR_RPT_MSG);
                                *pmsg++ = htons(0x000e);
                                *pmsg++ = htons(info->DSP_TIME[0]);
@@ -1270,7 +1270,6 @@ static int ft1000_parse_dpram_msg(struct net_device *dev)
        u16 nxtph;
        u16 total_len;
        int i = 0;
-       int cnt;
        unsigned long flags;
 
        doorbell = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
@@ -1336,7 +1335,6 @@ static int ft1000_parse_dpram_msg(struct net_device *dev)
                          total_len);
                if ((total_len < MAX_CMD_SQSIZE) && (total_len > sizeof(struct pseudo_hdr))) {
             total_len += nxtph;
-            cnt = 0;
                        /*
                         * ft1000_read_reg will return a value that needs to be byteswap
                         * in order to get DSP_QID_OFFSET.
@@ -1758,7 +1756,7 @@ static int ft1000_copy_up_pkt(struct net_device *dev)
                 SUCCESS
 
   -------------------------------------------------------------------------*/
-static int ft1000_copy_down_pkt(struct net_device *dev, u16 * packet, u16 len)
+static int ft1000_copy_down_pkt(struct net_device *dev, u16 *packet, u16 len)
 {
        struct ft1000_info *info = netdev_priv(dev);
        struct ft1000_pcmcia *pcmcia = info->priv;
@@ -2004,7 +2002,7 @@ static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
 static irqreturn_t ft1000_interrupt(int irq, void *dev_id)
 {
-       struct net_device *dev = (struct net_device *)dev_id;
+       struct net_device *dev = dev_id;
        struct ft1000_info *info = netdev_priv(dev);
        u16 tempword;
        u16 inttype;
@@ -2154,14 +2152,14 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link,
        if (flarion_ft1000_cnt > 1) {
                flarion_ft1000_cnt--;
 
-               printk(KERN_INFO
-                          "ft1000: This driver can not support more than one instance\n");
+               dev_info(&link->dev,
+                          "This driver can not support more than one instance\n");
                return NULL;
        }
 
        dev = alloc_etherdev(sizeof(struct ft1000_info));
        if (!dev) {
-               printk(KERN_ERR "ft1000: failed to allocate etherdev\n");
+               dev_err(&link->dev, "Failed to allocate etherdev\n");
                return NULL;
        }
 
@@ -2209,17 +2207,17 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link,
        dev->irq = link->irq;
        dev->base_addr = link->resource[0]->start;
        if (pcmcia_get_mac_from_cis(link, dev)) {
-               printk(KERN_ERR "ft1000: Could not read mac address\n");
+               netdev_err(dev, "Could not read mac address\n");
                goto err_dev;
        }
 
        if (request_irq(dev->irq, ft1000_interrupt, IRQF_SHARED, dev->name, dev)) {
-               printk(KERN_ERR "ft1000: Could not request_irq\n");
+               netdev_err(dev, "Could not request_irq\n");
                goto err_dev;
        }
 
        if (request_region(dev->base_addr, 256, dev->name) == NULL) {
-               printk(KERN_ERR "ft1000: Could not request_region\n");
+               netdev_err(dev, "Could not request_region\n");
                goto err_irq;
        }
 
index 0f347ab..4397ada 100644 (file)
@@ -38,7 +38,7 @@
 #include <linux/debugfs.h>
 #include "ft1000_usb.h"
 
-static int ft1000_flarion_cnt = 0;
+static int ft1000_flarion_cnt;
 
 static int ft1000_open(struct inode *inode, struct file *file);
 static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait);
@@ -365,7 +365,7 @@ static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait)
     /* DEBUG("ft1000_poll_dev called\n"); */
     if (ft1000_flarion_cnt == 0) {
         DEBUG("FT1000:ft1000_poll_dev called when ft1000_flarion_cnt is zero\n");
-        return (-EBADF);
+        return -EBADF;
     }
 
     /* Search for matching file object */
@@ -379,7 +379,7 @@ static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait)
     /* Could not find application info block */
     if (i == MAX_NUM_APP) {
         DEBUG("FT1000:ft1000_ioctl:Could not find application info block\n");
-        return (-EACCES);
+        return -EACCES;
     }
 
     if (list_empty(&dev->app_info[i].app_sqlist) == 0) {
@@ -433,7 +433,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
 
     if (ft1000_flarion_cnt == 0) {
         DEBUG("FT1000:ft1000_ioctl called when ft1000_flarion_cnt is zero\n");
-        return (-EBADF);
+        return -EBADF;
     }
 
     /* DEBUG("FT1000:ft1000_ioctl:command = 0x%x argument = 0x%8x\n", command, (u32)argument); */
@@ -540,17 +540,14 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
             /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_SET_DPRAM called\n");*/
 
 
-            if (ft1000_flarion_cnt == 0) {
-                return (-EBADF);
-            }
+            if (ft1000_flarion_cnt == 0)
+                return -EBADF;
 
-            if (ft1000dev->DrvMsgPend) {
-                return (-ENOTTY);
-            }
+            if (ft1000dev->DrvMsgPend)
+                return -ENOTTY;
 
-            if (ft1000dev->fProvComplete == 0) {
-                return (-EACCES);
-            }
+            if (ft1000dev->fProvComplete == 0)
+                return -EACCES;
 
             ft1000dev->fAppMsgPend = 1;
 
@@ -677,9 +674,8 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
 
             /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM called\n"); */
 
-            if (ft1000_flarion_cnt == 0) {
-                return (-EBADF);
-            }
+            if (ft1000_flarion_cnt == 0)
+                return -EBADF;
 
             /* Search for matching file object */
             for (i=0; i<MAX_NUM_APP; i++) {
@@ -762,7 +758,7 @@ static int ft1000_release(struct inode *inode, struct file *file)
 
     if (ft1000_flarion_cnt == 0) {
         ft1000dev->appcnt--;
-        return (-EBADF);
+        return -EBADF;
     }
 
     /* Search for matching file object */
index 37707da..fe882bd 100644 (file)
@@ -653,7 +653,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
 
        state = STATE_START_DWNLD;
 
-       file_hdr = (struct dsp_file_hdr *)pFileStart;
+       file_hdr = pFileStart;
 
        ft1000_write_register(ft1000dev, 0x800, FT1000_REG_MAG_WATERMARK);
 
@@ -837,7 +837,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
                                        if (word_length & 0x1)
                                                word_length++;
 
-                                       word_length = (word_length / 2);
+                                       word_length = word_length / 2;
 
                                        for (; word_length > 0; word_length--) {        /* In words */
 
@@ -871,7 +871,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
                                        if (word_length & 0x1)
                                                word_length++;
 
-                                       word_length = (word_length / 2);
+                                       word_length = word_length / 2;
 
                                        for (; word_length > 0; word_length--) {        /* In words */
 
index c657639..73eede1 100644 (file)
@@ -626,7 +626,7 @@ static void gdm_lte_netif_rx(struct net_device *dev, char *buf,
                        void *addr = buf + sizeof(struct iphdr) +
                                sizeof(struct udphdr) +
                                offsetof(struct dhcp_packet, chaddr);
-                       memcpy(nic->dest_mac_addr, addr, ETH_ALEN);
+                       ether_addr_copy(nic->dest_mac_addr, addr);
                }
        }
 
@@ -639,7 +639,7 @@ static void gdm_lte_netif_rx(struct net_device *dev, char *buf,
        }
 
        /* Format the data so that it can be put to skb */
-       memcpy(mac_header_data, nic->dest_mac_addr, ETH_ALEN);
+       ether_addr_copy(mac_header_data, nic->dest_mac_addr);
        memcpy(mac_header_data + ETH_ALEN, nic->src_mac_addr, ETH_ALEN);
 
        vlan_eth.h_vlan_TCI = htons(nic->vlan_id);
@@ -842,9 +842,9 @@ static void form_mac_address(u8 *dev_addr, u8 *nic_src, u8 *nic_dest,
 {
        /* Form the dev_addr */
        if (!mac_address)
-               memcpy(dev_addr, gdm_lte_macaddr, ETH_ALEN);
+               ether_addr_copy(dev_addr, gdm_lte_macaddr);
        else
-               memcpy(dev_addr, mac_address, ETH_ALEN);
+               ether_addr_copy(dev_addr, mac_address);
 
        /* The last byte of the mac address
         * should be less than or equal to 0xFC
@@ -858,7 +858,7 @@ static void form_mac_address(u8 *dev_addr, u8 *nic_src, u8 *nic_dest,
        memcpy(nic_src, dev_addr, 3);
 
        /* Copy the nic_dest from dev_addr*/
-       memcpy(nic_dest, dev_addr, ETH_ALEN);
+       ether_addr_copy(nic_dest, dev_addr);
 }
 
 static void validate_mac_address(u8 *mac_address)
index 0163b24..3d50383 100644 (file)
 #define RETRY_TIMER 30 /* msec */
 
 struct mux_pkt_header {
-       unsigned int start_flag;
-       unsigned int seq_num;
-       unsigned int payload_size;
-       unsigned short packet_type;
+       __le32 start_flag;
+       __le32 seq_num;
+       __le32 payload_size;
+       __le16 packet_type;
        unsigned char data[0];
 };
 
index f5a3378..9cab54b 100644 (file)
@@ -115,7 +115,7 @@ static void gdm_wimax_event_rcv(struct net_device *dev, u16 type, void *msg,
 {
        struct nic *nic = netdev_priv(dev);
 
-       u8 *buf = (u8 *)msg;
+       u8 *buf = msg;
        u16 hci_cmd =  (buf[0]<<8) | buf[1];
        u16 hci_len = (buf[2]<<8) | buf[3];
 
@@ -605,10 +605,8 @@ static void gdm_wimax_netif_rx(struct net_device *dev, char *buf, int len)
        int ret;
 
        skb = dev_alloc_skb(len + 2);
-       if (!skb) {
-               netdev_err(dev, "%s: dev_alloc_skb failed!\n", __func__);
+       if (!skb)
                return;
-       }
        skb_reserve(skb, 2);
 
        dev->stats.rx_packets++;
index 6aa9d7c..6da7285 100644 (file)
@@ -46,27 +46,6 @@ static char  *file = "xlinx_fpga_firmware.bit";
 module_param(file, charp, S_IRUGO);
 MODULE_PARM_DESC(file, "Xilinx FPGA firmware file.");
 
-#ifdef DEBUG_FPGA
-static void datadump(char *msg, void *m, int n)
-{
-       int i;
-       unsigned char *c;
-
-       pr_info("=== %s ===\n", msg);
-
-       c = m;
-
-       for (i = 0; i < n; i++) {
-               if ((i&0xf) == 0)
-                       pr_info(KERN_INFO "\n  0x%4x: ", i);
-
-               pr_info("%02X ", c[i]);
-       }
-
-       pr_info("\n");
-}
-#endif /* DEBUG_FPGA */
-
 static void read_bitstream(char *bitdata, char *buf, int *offset, int rdsize)
 {
        memcpy(buf, bitdata + *offset, rdsize);
@@ -157,12 +136,10 @@ static void gs_print_header(struct fpgaimage *fimage)
 static void gs_read_bitstream(struct fpgaimage *fimage)
 {
        char *bitdata;
-       int size;
        int offset;
 
        offset = 0;
        bitdata = (char *)fimage->fw_entry->data;
-       size = fimage->fw_entry->size;
 
        readmagic_bitstream(bitdata, &offset);
        readinfo_bitstream(bitdata, fimage->filename, &offset);
@@ -195,15 +172,15 @@ static int gs_read_image(struct fpgaimage *fimage)
        return 0;
 }
 
-static int gs_load_image(struct fpgaimage *fimage, char *file)
+static int gs_load_image(struct fpgaimage *fimage, char *fw_file)
 {
        int err;
 
-       pr_info("load fpgaimage %s\n", file);
+       pr_info("load fpgaimage %s\n", fw_file);
 
-       err = request_firmware(&fimage->fw_entry, file, &firmware_pdev->dev);
+       err = request_firmware(&fimage->fw_entry, fw_file, &firmware_pdev->dev);
        if (err != 0) {
-               pr_err("firmware %s is missing, cannot continue.\n", file);
+               pr_err("firmware %s is missing, cannot continue.\n", fw_file);
                return err;
        }
 
@@ -220,9 +197,9 @@ static int gs_download_image(struct fpgaimage *fimage, enum wbus bus_bytes)
        size = fimage->lendata;
 
 #ifdef DEBUG_FPGA
-       datadump("bitfile sample", bitdata, 0x100);
+       print_hex_dump_bytes("bitfile sample: ", DUMP_PREFIX_OFFSET,
+                            bitdata, 0x100);
 #endif /* DEBUG_FPGA */
-
        if (!xl_supported_prog_bus_width(bus_bytes)) {
                pr_err("unsupported program bus width %d\n",
                                bus_bytes);
@@ -316,10 +293,8 @@ static int gs_fpgaboot(void)
        struct fpgaimage        *fimage;
 
        fimage = kmalloc(sizeof(struct fpgaimage), GFP_KERNEL);
-       if (fimage == NULL) {
-               pr_err("No memory is available\n");
-               goto err_out;
-       }
+       if (!fimage)
+               return -ENOMEM;
 
        err = gs_load_image(fimage, file);
        if (err) {
@@ -361,50 +336,44 @@ err_out2:
 err_out1:
        kfree(fimage);
 
-err_out:
        return -1;
 
 }
 
 static int __init gs_fpgaboot_init(void)
 {
-       int err, r;
-
-       r = -1;
+       int err;
 
        pr_info("FPGA DOWNLOAD --->\n");
 
        pr_info("FPGA image file name: %s\n", file);
 
        err = init_driver();
-       if (err != 0) {
+       if (err) {
                pr_err("FPGA DRIVER INIT FAIL!!\n");
-               return r;
+               return err;
        }
 
        err = xl_init_io();
        if (err) {
                pr_err("GPIO INIT FAIL!!\n");
-               r = -1;
                goto errout;
        }
 
        err = gs_fpgaboot();
        if (err) {
                pr_err("FPGA DOWNLOAD FAIL!!\n");
-               r = -1;
                goto errout;
        }
 
        pr_info("FPGA DOWNLOAD DONE <---\n");
 
-       r = 0;
-       return r;
+       return 0;
 
 errout:
        finish_driver();
 
-       return r;
+       return err;
 }
 
 static void __exit gs_fpgaboot_exit(void)
index 044ea19..31dfb21 100644 (file)
@@ -47,6 +47,7 @@ int size_from_channelarray(struct iio_channel_info *channels, int num_channels)
 {
        int bytes = 0;
        int i = 0;
+
        while (i < num_channels) {
                if (bytes % channels[i].bytes == 0)
                        channels[i].location = bytes;
@@ -74,12 +75,14 @@ void print2byte(int input, struct iio_channel_info *info)
        input = input >> info->shift;
        if (info->is_signed) {
                int16_t val = input;
+
                val &= (1 << info->bits_used) - 1;
                val = (int16_t)(val << (16 - info->bits_used)) >>
                        (16 - info->bits_used);
                printf("%05f ", ((float)val + info->offset)*info->scale);
        } else {
                uint16_t val = input;
+
                val &= (1 << info->bits_used) - 1;
                printf("%05f ", ((float)val + info->offset)*info->scale);
        }
@@ -97,6 +100,7 @@ void process_scan(char *data,
                  int num_channels)
 {
        int k;
+
        for (k = 0; k < num_channels; k++)
                switch (channels[k].bytes) {
                        /* only a few cases implemented so far */
index 569d6f8..940ed23 100644 (file)
@@ -69,16 +69,29 @@ static const char * const iio_modifier_names[] = {
        [IIO_MOD_X] = "x",
        [IIO_MOD_Y] = "y",
        [IIO_MOD_Z] = "z",
+       [IIO_MOD_X_AND_Y] = "x&y",
+       [IIO_MOD_X_AND_Z] = "x&z",
+       [IIO_MOD_Y_AND_Z] = "y&z",
+       [IIO_MOD_X_AND_Y_AND_Z] = "x&y&z",
+       [IIO_MOD_X_OR_Y] = "x|y",
+       [IIO_MOD_X_OR_Z] = "x|z",
+       [IIO_MOD_Y_OR_Z] = "y|z",
+       [IIO_MOD_X_OR_Y_OR_Z] = "x|y|z",
        [IIO_MOD_LIGHT_BOTH] = "both",
        [IIO_MOD_LIGHT_IR] = "ir",
        [IIO_MOD_ROOT_SUM_SQUARED_X_Y] = "sqrt(x^2+y^2)",
        [IIO_MOD_SUM_SQUARED_X_Y_Z] = "x^2+y^2+z^2",
-       [IIO_MOD_LIGHT_BOTH] = "both",
-       [IIO_MOD_LIGHT_IR] = "ir",
        [IIO_MOD_LIGHT_CLEAR] = "clear",
        [IIO_MOD_LIGHT_RED] = "red",
        [IIO_MOD_LIGHT_GREEN] = "green",
        [IIO_MOD_LIGHT_BLUE] = "blue",
+       [IIO_MOD_QUATERNION] = "quaternion",
+       [IIO_MOD_TEMP_AMBIENT] = "ambient",
+       [IIO_MOD_TEMP_OBJECT] = "object",
+       [IIO_MOD_NORTH_MAGN] = "from_north_magnetic",
+       [IIO_MOD_NORTH_TRUE] = "from_north_true",
+       [IIO_MOD_NORTH_MAGN_TILT_COMP] = "from_north_magnetic_tilt_comp",
+       [IIO_MOD_NORTH_TRUE_TILT_COMP] = "from_north_true_tilt_comp",
 };
 
 static bool event_is_known(struct iio_event_data *event)
@@ -118,6 +131,14 @@ static bool event_is_known(struct iio_event_data *event)
        case IIO_MOD_X:
        case IIO_MOD_Y:
        case IIO_MOD_Z:
+       case IIO_MOD_X_AND_Y:
+       case IIO_MOD_X_AND_Z:
+       case IIO_MOD_Y_AND_Z:
+       case IIO_MOD_X_AND_Y_AND_Z:
+       case IIO_MOD_X_OR_Y:
+       case IIO_MOD_X_OR_Z:
+       case IIO_MOD_Y_OR_Z:
+       case IIO_MOD_X_OR_Y_OR_Z:
        case IIO_MOD_LIGHT_BOTH:
        case IIO_MOD_LIGHT_IR:
        case IIO_MOD_ROOT_SUM_SQUARED_X_Y:
@@ -126,6 +147,13 @@ static bool event_is_known(struct iio_event_data *event)
        case IIO_MOD_LIGHT_RED:
        case IIO_MOD_LIGHT_GREEN:
        case IIO_MOD_LIGHT_BLUE:
+       case IIO_MOD_QUATERNION:
+       case IIO_MOD_TEMP_AMBIENT:
+       case IIO_MOD_TEMP_OBJECT:
+       case IIO_MOD_NORTH_MAGN:
+       case IIO_MOD_NORTH_TRUE:
+       case IIO_MOD_NORTH_MAGN_TILT_COMP:
+       case IIO_MOD_NORTH_TRUE_TILT_COMP:
                break;
        default:
                return false;
index 0973a09..568eff0 100644 (file)
@@ -34,6 +34,7 @@ inline int iioutils_break_up_name(const char *full_name,
        char *current;
        char *w, *r;
        char *working;
+
        current = strdup(full_name);
        working = strtok(current, "_\0");
        w = working;
@@ -335,6 +336,7 @@ inline int build_channel_array(const char *device_dir,
                if (strcmp(ent->d_name + strlen(ent->d_name) - strlen("_en"),
                           "_en") == 0) {
                        int current_enabled = 0;
+
                        current = &(*ci_array)[count++];
                        ret = asprintf(&filename,
                                       "%s/%s", scan_el_dir, ent->d_name);
@@ -506,6 +508,7 @@ inline int _write_sysfs_int(char *filename, char *basedir, int val, int verify)
        FILE *sysfsfp;
        int test;
        char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
+
        if (temp == NULL)
                return -ENOMEM;
        sprintf(temp, "%s/%s", basedir, filename);
@@ -554,6 +557,7 @@ int _write_sysfs_string(char *filename, char *basedir, char *val, int verify)
        int ret = 0;
        FILE  *sysfsfp;
        char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
+
        if (temp == NULL) {
                printf("Memory allocation failed\n");
                return -ENOMEM;
@@ -614,6 +618,7 @@ int read_sysfs_posint(char *filename, char *basedir)
        int ret;
        FILE  *sysfsfp;
        char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
+
        if (temp == NULL) {
                printf("Memory allocation failed");
                return -ENOMEM;
@@ -636,6 +641,7 @@ int read_sysfs_float(char *filename, char *basedir, float *val)
        int ret = 0;
        FILE  *sysfsfp;
        char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
+
        if (temp == NULL) {
                printf("Memory allocation failed");
                return -ENOMEM;
@@ -658,6 +664,7 @@ int read_sysfs_string(const char *filename, const char *basedir, char *str)
        int ret = 0;
        FILE  *sysfsfp;
        char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
+
        if (temp == NULL) {
                printf("Memory allocation failed");
                return -ENOMEM;
index 24ae969..98a0de0 100644 (file)
@@ -46,6 +46,7 @@ static int dump_channels(const char *dev_dir_name)
 {
        DIR *dp;
        const struct dirent *ent;
+
        dp = opendir(dev_dir_name);
        if (dp == NULL)
                return -errno;
@@ -62,17 +63,17 @@ static int dump_one_device(const char *dev_dir_name)
 {
        char name[IIO_MAX_NAME_LENGTH];
        int dev_idx;
+       int retval;
 
-       sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_device),
+       retval = sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_device),
                        "%i", &dev_idx);
+       if (retval != 1)
+               return -EINVAL;
        read_sysfs_string("name", dev_dir_name, name);
        printf("Device %03d: %s\n", dev_idx, name);
 
-       if (verblevel >= VERBLEVEL_SENSORS) {
-               int ret = dump_channels(dev_dir_name);
-               if (ret)
-                       return ret;
-       }
+       if (verblevel >= VERBLEVEL_SENSORS)
+               return dump_channels(dev_dir_name);
        return 0;
 }
 
@@ -80,9 +81,12 @@ static int dump_one_trigger(const char *dev_dir_name)
 {
        char name[IIO_MAX_NAME_LENGTH];
        int dev_idx;
+       int retval;
 
-       sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_trigger),
+       retval = sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_trigger),
                        "%i", &dev_idx);
+       if (retval != 1)
+               return -EINVAL;
        read_sysfs_string("name", dev_dir_name, name);
        printf("Trigger %03d: %s\n", dev_idx, name);
        return 0;
@@ -107,6 +111,7 @@ static void dump_devices(void)
        while (ent = readdir(dp), ent != NULL) {
                if (check_prefix(ent->d_name, type_device)) {
                        char *dev_dir_name;
+
                        asprintf(&dev_dir_name, "%s%s", iio_dir, ent->d_name);
                        dump_one_device(dev_dir_name);
                        free(dev_dir_name);
@@ -118,6 +123,7 @@ static void dump_devices(void)
        while (ent = readdir(dp), ent != NULL) {
                if (check_prefix(ent->d_name, type_trigger)) {
                        char *dev_dir_name;
+
                        asprintf(&dev_dir_name, "%s%s", iio_dir, ent->d_name);
                        dump_one_trigger(dev_dir_name);
                        free(dev_dir_name);
index ad45dfb..07b7ffa 100644 (file)
@@ -9,53 +9,71 @@ config ADIS16201
        select IIO_ADIS_LIB
        select IIO_ADIS_LIB_BUFFER if IIO_BUFFER
        help
-         Say yes here to build support for Analog Devices adis16201 dual-axis
+         Say Y here to build support for Analog Devices adis16201 dual-axis
          digital inclinometer and accelerometer.
 
+         To compile this driver as a module, say M here: the module will
+         be called adis16201.
+
 config ADIS16203
        tristate "Analog Devices ADIS16203 Programmable 360 Degrees Inclinometer"
        depends on SPI
        select IIO_ADIS_LIB
        select IIO_ADIS_LIB_BUFFER if IIO_BUFFER
        help
-         Say yes here to build support for Analog Devices adis16203 Programmable
+         Say Y here to build support for Analog Devices adis16203 Programmable
          360 Degrees Inclinometer.
 
+         To compile this driver as a module, say M here: the module will be
+         called adis16203.
+
 config ADIS16204
        tristate "Analog Devices ADIS16204 Programmable High-g Digital Impact Sensor and Recorder"
        depends on SPI
        select IIO_ADIS_LIB
        select IIO_ADIS_LIB_BUFFER if IIO_BUFFER
        help
-         Say yes here to build support for Analog Devices adis16204 Programmable
+         Say Y here to build support for Analog Devices adis16204 Programmable
          High-g Digital Impact Sensor and Recorder.
 
+         To compile this driver as a module, say M here: the module will be
+         called adis16204.
+
 config ADIS16209
        tristate "Analog Devices ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer"
        depends on SPI
        select IIO_ADIS_LIB
        select IIO_ADIS_LIB_BUFFER if IIO_BUFFER
        help
-         Say yes here to build support for Analog Devices adis16209 dual-axis digital inclinometer
+         Say Y here to build support for Analog Devices adis16209 dual-axis digital inclinometer
          and accelerometer.
 
+         To compile this driver as a module, say M here: the module will be
+         called adis16209.
+
 config ADIS16220
        tristate "Analog Devices ADIS16220 Programmable Digital Vibration Sensor"
        depends on SPI
        select IIO_ADIS_LIB
        help
-         Say yes here to build support for Analog Devices adis16220 programmable
+         Say Y here to build support for Analog Devices adis16220 programmable
          digital vibration sensor.
 
+         To compile this driver as a module, say M here: the module will be
+         called adis16220.
+
 config ADIS16240
        tristate "Analog Devices ADIS16240 Programmable Impact Sensor and Recorder"
        depends on SPI
        select IIO_ADIS_LIB
        select IIO_ADIS_LIB_BUFFER if IIO_BUFFER
        help
-         Say yes here to build support for Analog Devices adis16240 programmable
+         Say Y here to build support for Analog Devices adis16240 programmable
          impact Sensor and recorder.
 
+         To compile this driver as a module, say M here: the module will be
+         called adis16240.
+
 config LIS3L02DQ
        tristate "ST Microelectronics LIS3L02DQ Accelerometer Driver"
        depends on SPI
@@ -63,16 +81,21 @@ config LIS3L02DQ
        depends on !IIO_BUFFER || IIO_KFIFO_BUF
        depends on GPIOLIB
        help
-         Say yes here to build SPI support for the ST microelectronics
+         Say Y here to build SPI support for the ST microelectronics
          accelerometer. The driver supplies direct access via sysfs files
          and an event interface via a character device.
 
+         To compile this driver as a module, say M here: the module will be
+         called lis3l02dq.
+
 config SCA3000
        depends on IIO_BUFFER
        depends on SPI
        tristate "VTI SCA3000 series accelerometers"
        help
-         Say yes here to build support for the VTI SCA3000 series of SPI
+         Say Y here to build support for the VTI SCA3000 series of SPI
          accelerometers. These devices use a hardware ring buffer.
 
+         To compile this driver as a module, say M here: the module will be
+         called sca3000.
 endmenu
index c110a25..f6526aa 100644 (file)
@@ -223,7 +223,8 @@ static int ad7192_setup(struct ad7192_state *st,
        id &= AD7192_ID_MASK;
 
        if (id != st->devid)
-               dev_warn(&st->sd.spi->dev, "device ID query failed (0x%X)\n", id);
+               dev_warn(&st->sd.spi->dev, "device ID query failed (0x%X)\n",
+                       id);
 
        switch (pdata->clock_source_sel) {
        case AD7192_CLK_EXT_MCLK1_2:
index d215edf..4d48707 100644 (file)
@@ -188,7 +188,7 @@ static void ad7280_delay(struct ad7280_state *st)
        if (st->readback_delay_us < 50)
                udelay(st->readback_delay_us);
        else
-               msleep(1);
+               usleep_range(250, 500);
 }
 
 static int __ad7280_read32(struct ad7280_state *st, unsigned *val)
index 6a8ecd7..7303983 100644 (file)
@@ -23,7 +23,7 @@ static int ad7606_spi_read_block(struct device *dev,
        int i, ret;
        unsigned short *data = buf;
 
-       ret = spi_read(spi, (u8 *)buf, count * 2);
+       ret = spi_read(spi, buf, count * 2);
        if (ret < 0) {
                dev_err(&spi->dev, "SPI read error\n");
                return ret;
index 734a7e4..48b1c37 100644 (file)
@@ -152,7 +152,8 @@ static ssize_t ad7816_show_available_modes(struct device *dev,
        return sprintf(buf, "full\npower-save\n");
 }
 
-static IIO_DEVICE_ATTR(available_modes, S_IRUGO, ad7816_show_available_modes, NULL, 0);
+static IIO_DEVICE_ATTR(available_modes, S_IRUGO, ad7816_show_available_modes,
+                       NULL, 0);
 
 static ssize_t ad7816_show_channel(struct device *dev,
                struct device_attribute *attr,
index a876ce7..84a53a9 100644 (file)
@@ -116,7 +116,7 @@ static const struct iio_chan_spec lpc32xx_adc_iio_channels[] = {
 
 static irqreturn_t lpc32xx_adc_isr(int irq, void *dev_id)
 {
-       struct lpc32xx_adc_info *info = (struct lpc32xx_adc_info *) dev_id;
+       struct lpc32xx_adc_info *info = dev_id;
 
        /* Read value and clear irq */
        info->value = __raw_readl(LPC32XX_ADC_VALUE(info->adc_base)) &
index 2a29b9b..6757f10 100644 (file)
@@ -455,7 +455,8 @@ static void mxs_lradc_setup_ts_channel(struct mxs_lradc *lradc, unsigned ch)
         * SoC's delay unit and start the conversion later
         * and automatically.
         */
-       mxs_lradc_reg_wrt(lradc, LRADC_DELAY_TRIGGER(0) | /* don't trigger ADC */
+       mxs_lradc_reg_wrt(lradc,
+               LRADC_DELAY_TRIGGER(0) | /* don't trigger ADC */
                LRADC_DELAY_TRIGGER_DELAYS(1 << 3) | /* trigger DELAY unit#3 */
                LRADC_DELAY_KICK |
                LRADC_DELAY_DELAY(lradc->settling_delay),
@@ -513,7 +514,8 @@ static void mxs_lradc_setup_ts_pressure(struct mxs_lradc *lradc, unsigned ch1,
         * SoC's delay unit and start the conversion later
         * and automatically.
         */
-       mxs_lradc_reg_wrt(lradc, LRADC_DELAY_TRIGGER(0) | /* don't trigger ADC */
+       mxs_lradc_reg_wrt(lradc,
+               LRADC_DELAY_TRIGGER(0) | /* don't trigger ADC */
                LRADC_DELAY_TRIGGER_DELAYS(1 << 3) | /* trigger DELAY unit#3 */
                LRADC_DELAY_KICK |
                LRADC_DELAY_DELAY(lradc->settling_delay), LRADC_DELAY(2));
index c5492ba..de37b35 100644 (file)
@@ -98,7 +98,7 @@ 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(st->clk);
 
-       count = (apb_clk + val - 1) / val;
+       count = DIV_ROUND_UP(apb_clk, val);
        clk_low = count / 2;
        clk_high = count - clk_low;
        st->current_clk = apb_clk / count;
@@ -226,7 +226,7 @@ static const struct iio_chan_spec spear_adc_iio_channels[] = {
 
 static irqreturn_t spear_adc_isr(int irq, void *dev_id)
 {
-       struct spear_adc_state *st = (struct spear_adc_state *)dev_id;
+       struct spear_adc_state *st = dev_id;
 
        /* Read value to clear IRQ */
        st->value = spear_adc_get_average(st);
index e6795e0..0ed7e13 100644 (file)
@@ -10,6 +10,9 @@ config ADT7316
          Say yes here to build support for Analog Devices ADT7316, ADT7317, ADT7318
          and ADT7516, ADT7517, ADT7519 temperature sensors, ADC and DAC.
 
+         To compile this driver as a module, choose M here: the module will
+         be called adt7316.
+
 config ADT7316_SPI
        tristate "support SPI bus connection"
        depends on SPI && ADT7316
@@ -18,6 +21,9 @@ config ADT7316_SPI
          Say yes here to build SPI bus support for Analog Devices ADT7316/7/8
          and ADT7516/7/9.
 
+         To compile this driver as a module, choose M here: the module will
+         be called adt7316_spi.
+
 config ADT7316_I2C
        tristate "support I2C bus connection"
        depends on I2C && ADT7316
@@ -25,4 +31,7 @@ config ADT7316_I2C
          Say yes here to build I2C bus support for Analog Devices ADT7316/7/8
          and ADT7516/7/9.
 
+         To compile this driver as a module, choose M here: the module will
+         be called adt7316_i2c.
+
 endmenu
index ec50bf3..ec40fbb 100644 (file)
@@ -30,6 +30,7 @@ extern const struct dev_pm_ops adt7316_pm_ops;
 #else
 #define ADT7316_PM_OPS NULL
 #endif
-int adt7316_probe(struct device *dev, struct adt7316_bus *bus, const char *name);
+int adt7316_probe(struct device *dev, struct adt7316_bus *bus,
+                  const char *name);
 
 #endif
index 88b199b..f62f68f 100644 (file)
@@ -7,7 +7,10 @@ config ADIS16060
        tristate "Analog Devices ADIS16060 Yaw Rate Gyroscope with SPI driver"
        depends on SPI
        help
-         Say yes here to build support for Analog Devices adis16060 wide bandwidth
+         Say Y (yes) here to build support for Analog Devices adis16060 wide bandwidth
          yaw rate gyroscope with SPI.
 
+         To compile this driver as a module, say M here: the module will be
+         called adis16060. If unsure, say N.
+
 endmenu
index e0d88fa..423f96b 100644 (file)
@@ -1040,8 +1040,8 @@ static ssize_t tsl2x7x_als_persistence_show(struct device *dev,
        y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.als_time) + 1;
        z = y * TSL2X7X_MIN_ITIME;
        filter_delay = z * (chip->tsl2x7x_settings.persistence & 0x0F);
-       y = (filter_delay / 1000);
-       z = (filter_delay % 1000);
+       y = filter_delay / 1000;
+       z = filter_delay % 1000;
 
        return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
 }
@@ -1086,8 +1086,8 @@ static ssize_t tsl2x7x_prox_persistence_show(struct device *dev,
        y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.prx_time) + 1;
        z = y * TSL2X7X_MIN_ITIME;
        filter_delay = z * ((chip->tsl2x7x_settings.persistence & 0xF0) >> 4);
-       y = (filter_delay / 1000);
-       z = (filter_delay % 1000);
+       y = filter_delay / 1000;
+       z = filter_delay % 1000;
 
        return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
 }
@@ -1573,8 +1573,7 @@ static struct attribute *tsl2x7x_ALS_device_attrs[] = {
        &dev_attr_power_state.attr,
        &dev_attr_in_illuminance0_calibscale_available.attr,
        &dev_attr_in_illuminance0_integration_time.attr,
-       &iio_const_attr_in_illuminance0_integration_time_available\
-       .dev_attr.attr,
+       &iio_const_attr_in_illuminance0_integration_time_available.dev_attr.attr,
        &dev_attr_in_illuminance0_target_input.attr,
        &dev_attr_in_illuminance0_calibrate.attr,
        &dev_attr_in_illuminance0_lux_table.attr,
@@ -1591,8 +1590,7 @@ static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = {
        &dev_attr_power_state.attr,
        &dev_attr_in_illuminance0_calibscale_available.attr,
        &dev_attr_in_illuminance0_integration_time.attr,
-       &iio_const_attr_in_illuminance0_integration_time_available\
-       .dev_attr.attr,
+       &iio_const_attr_in_illuminance0_integration_time_available.dev_attr.attr,
        &dev_attr_in_illuminance0_target_input.attr,
        &dev_attr_in_illuminance0_calibrate.attr,
        &dev_attr_in_illuminance0_lux_table.attr,
@@ -1611,8 +1609,7 @@ static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = {
        &dev_attr_power_state.attr,
        &dev_attr_in_illuminance0_calibscale_available.attr,
        &dev_attr_in_illuminance0_integration_time.attr,
-       &iio_const_attr_in_illuminance0_integration_time_available\
-       .dev_attr.attr,
+       &iio_const_attr_in_illuminance0_integration_time_available.dev_attr.attr,
        &dev_attr_in_illuminance0_target_input.attr,
        &dev_attr_in_illuminance0_calibrate.attr,
        &dev_attr_in_illuminance0_lux_table.attr,
index e53274b..64cd370 100644 (file)
@@ -10,6 +10,9 @@ config ADE7753
          Say yes here to build support for Analog Devices ADE7753 Single-Phase Multifunction
          Metering IC with di/dt Sensor Interface.
 
+         To compile this driver as a module, choose M here: the
+         module will be called ade7753.
+
 config ADE7754
        tristate "Analog Devices ADE7754 Polyphase Multifunction Energy Metering IC Driver"
        depends on SPI
@@ -17,6 +20,9 @@ config ADE7754
          Say yes here to build support for Analog Devices ADE7754 Polyphase
          Multifunction Energy Metering IC Driver.
 
+         To compile this driver as a module, choose M here: the
+         module will be called ade7754.
+
 config ADE7758
        tristate "Analog Devices ADE7758 Poly Phase Multifunction Energy Metering IC Driver"
        depends on SPI
@@ -26,6 +32,9 @@ config ADE7758
          Say yes here to build support for Analog Devices ADE7758 Polyphase
          Multifunction Energy Metering IC with Per Phase Information Driver.
 
+         To compile this driver as a module, choose M here: the
+         module will be called ade7758.
+
 config ADE7759
        tristate "Analog Devices ADE7759 Active Energy Metering IC Driver"
        depends on SPI
@@ -33,6 +42,9 @@ config ADE7759
          Say yes here to build support for Analog Devices ADE7758 Active Energy
          Metering IC with di/dt Sensor Interface.
 
+         To compile this driver as a module, choose M here: the
+         module will be called ade7759.
+
 config ADE7854
        tristate "Analog Devices ADE7854/58/68/78 Polyphase Multifunction Energy Metering IC Driver"
        depends on SPI || I2C
@@ -40,6 +52,9 @@ config ADE7854
          Say yes here to build support for Analog Devices ADE7854/58/68/78 Polyphase
          Multifunction Energy Metering IC Driver.
 
+         To compile this driver as a module, choose M here: the
+         module will be called ade7854.
+
 config ADE7854_I2C
        tristate "support I2C bus connection"
        depends on ADE7854 && I2C
index 2fd18c6..710a2f3 100644 (file)
@@ -1,4 +1,4 @@
-#
+  #
 # Industrial I/O standalone triggers
 #
 comment "Triggers - standalone"
@@ -12,6 +12,9 @@ config IIO_PERIODIC_RTC_TRIGGER
          Provides support for using periodic capable real time
          clocks as IIO triggers.
 
+         To compile this driver as a module, choose M here: the
+         module will be called iio-trig-periodic-rtc.
+
 config IIO_BFIN_TMR_TRIGGER
        tristate "Blackfin TIMER trigger"
        depends on BLACKFIN
index 8f0a2ff..d1df701 100644 (file)
@@ -72,7 +72,8 @@ static ssize_t iio_trig_periodic_write_freq(struct device *dev,
        if (val > 0) {
                ret = rtc_irq_set_freq(trig_info->rtc, &trig_info->task, val);
                if (ret == 0 && trig_info->state && trig_info->frequency == 0)
-                       ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, 1);
+                       ret = rtc_irq_set_state(trig_info->rtc,
+                                               &trig_info->task, 1);
        } else if (val == 0) {
                ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, 0);
        } else
index 9cb222e..3ca1acd 100644 (file)
@@ -632,7 +632,8 @@ static int imx_drm_platform_probe(struct platform_device *pdev)
                                continue;
                        }
 
-                       component_match_add(&pdev->dev, &match, compare_of, remote);
+                       component_match_add(&pdev->dev, &match, compare_of,
+                                           remote);
                        of_node_put(remote);
                }
                of_node_put(port);
index 42c651b..f22b2ac 100644 (file)
@@ -665,7 +665,8 @@ static int imx_tve_bind(struct device *dev, struct device *master, void *data)
 
        ret = regmap_read(tve->regmap, TVE_COM_CONF_REG, &val);
        if (ret < 0) {
-               dev_err(dev, "failed to read configuration register: %d\n", ret);
+               dev_err(dev, "failed to read configuration register: %d\n",
+                       ret);
                return ret;
        }
        if (val != 0x00100000) {
index 8f5cdd5..bc479a7 100644 (file)
@@ -2411,7 +2411,7 @@ kiblnd_hdev_setup_mrs(kib_hca_dev_t *hdev)
                goto out;
        }
 
-       mr_size = (1ULL << hdev->ibh_mr_shift);
+       mr_size = 1ULL << hdev->ibh_mr_shift;
        mm_size = (unsigned long)high_memory - PAGE_OFFSET;
 
        hdev->ibh_nmrs = (int)((mm_size + mr_size - 1) >> hdev->ibh_mr_shift);
@@ -3081,7 +3081,7 @@ kiblnd_startup (lnet_ni_t *ni)
        LIBCFS_ALLOC(net, sizeof(*net));
        ni->ni_data = net;
        if (net == NULL)
-               goto failed;
+               goto net_failed;
 
        do_gettimeofday(&tv);
        net->ibn_incarnation = (((__u64)tv.tv_sec) * 1000000) + tv.tv_usec;
@@ -3147,6 +3147,7 @@ failed:
        if (net->ibn_dev == NULL && ibdev != NULL)
                kiblnd_destroy_dev(ibdev);
 
+net_failed:
        kiblnd_shutdown(ni);
 
        CDEBUG(D_NET, "kiblnd_startup failed\n");
index 60bc2ae..5e6e4e2 100644 (file)
@@ -37,6 +37,7 @@
 #define DEBUG_SUBSYSTEM S_LNET
 #include "../../include/linux/lnet/lib-lnet.h"
 #include <linux/log2.h>
+#include <linux/ktime.h>
 
 #define D_LNI D_CONSOLE
 
@@ -417,17 +418,9 @@ static __u64
 lnet_create_interface_cookie(void)
 {
        /* NB the interface cookie in wire handles guards against delayed
-        * replies and ACKs appearing valid after reboot. Initialisation time,
-        * even if it's only implemented to millisecond resolution is probably
-        * easily good enough. */
-       struct timeval tv;
-       __u64     cookie;
-
-       do_gettimeofday(&tv);
-       cookie = tv.tv_sec;
-       cookie *= 1000000;
-       cookie += tv.tv_usec;
-       return cookie;
+        * replies and ACKs appearing valid after reboot.
+        */
+       return ktime_get_ns();
 }
 
 static char *
index e4d906a..3225c06 100644 (file)
@@ -218,7 +218,7 @@ lnet_md_deconstruct(lnet_libmd_t *lmd, lnet_md_t *umd)
        lnet_eq2handle(&umd->eq_handle, lmd->md_eq);
 }
 
-int
+static int
 lnet_md_validate(lnet_md_t *umd)
 {
        if (umd->start == NULL && umd->length != 0) {
index 4b9567d..5754725 100644 (file)
@@ -561,7 +561,7 @@ lnet_extract_kiov(int dst_niov, lnet_kiov_t *dst,
 }
 EXPORT_SYMBOL(lnet_extract_kiov);
 
-void
+static void
 lnet_ni_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
             unsigned int offset, unsigned int mlen, unsigned int rlen)
 {
@@ -599,7 +599,7 @@ lnet_ni_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
                lnet_finalize(ni, msg, rc);
 }
 
-void
+static void
 lnet_setpayloadbuffer(lnet_msg_t *msg)
 {
        lnet_libmd_t *md = msg->msg_md;
@@ -639,7 +639,7 @@ lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target,
        msg->msg_hdr.payload_length = cpu_to_le32(len);
 }
 
-void
+static void
 lnet_ni_send(lnet_ni_t *ni, lnet_msg_t *msg)
 {
        void   *priv = msg->msg_private;
@@ -654,7 +654,7 @@ lnet_ni_send(lnet_ni_t *ni, lnet_msg_t *msg)
                lnet_finalize(ni, msg, rc);
 }
 
-int
+static int
 lnet_ni_eager_recv(lnet_ni_t *ni, lnet_msg_t *msg)
 {
        int     rc;
@@ -679,7 +679,7 @@ lnet_ni_eager_recv(lnet_ni_t *ni, lnet_msg_t *msg)
 }
 
 /* NB: caller shall hold a ref on 'lp' as I'd drop lnet_net_lock */
-void
+static void
 lnet_ni_query_locked(lnet_ni_t *ni, lnet_peer_t *lp)
 {
        unsigned long last_alive = 0;
@@ -731,7 +731,7 @@ lnet_peer_is_alive(lnet_peer_t *lp, unsigned long now)
 
 /* NB: returns 1 when alive, 0 when dead, negative when error;
  *     may drop the lnet_net_lock */
-int
+static int
 lnet_peer_alive_locked(lnet_peer_t *lp)
 {
        unsigned long now = cfs_time_current();
@@ -871,7 +871,7 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send)
 }
 
 
-lnet_rtrbufpool_t *
+static lnet_rtrbufpool_t *
 lnet_msg2bufpool(lnet_msg_t *msg)
 {
        lnet_rtrbufpool_t       *rbp;
@@ -891,7 +891,7 @@ lnet_msg2bufpool(lnet_msg_t *msg)
        return rbp;
 }
 
-int
+static int
 lnet_post_routed_recv_locked(lnet_msg_t *msg, int do_recv)
 {
        /* lnet_parse is going to lnet_net_unlock immediately after this, so it
index be31dfc..17e1643 100644 (file)
@@ -35,7 +35,7 @@
 #define DEBUG_SUBSYSTEM S_LNET
 #include "../../include/linux/lnet/lib-lnet.h"
 
-int
+static int
 lolnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
 {
        LASSERT(!lntmsg->msg_routing);
@@ -44,7 +44,7 @@ lolnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
        return lnet_parse(ni, &lntmsg->msg_hdr, ni->ni_nid, lntmsg, 0);
 }
 
-int
+static int
 lolnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
            int delayed, unsigned int niov,
            struct iovec *iov, lnet_kiov_t *kiov,
@@ -86,7 +86,7 @@ lolnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
 
 static int lolnd_instanced;
 
-void
+static void
 lolnd_shutdown(lnet_ni_t *ni)
 {
        CDEBUG(D_NET, "shutdown\n");
@@ -95,7 +95,7 @@ lolnd_shutdown(lnet_ni_t *ni)
        lolnd_instanced = 0;
 }
 
-int
+static int
 lolnd_startup(lnet_ni_t *ni)
 {
        LASSERT(ni->ni_lnd == &the_lolnd);
index e84d59d..3c23677 100644 (file)
@@ -43,7 +43,7 @@ MODULE_PARM_DESC(config_on_load, "configure network at module load");
 
 static struct mutex lnet_config_mutex;
 
-int
+static int
 lnet_configure(void *arg)
 {
        /* 'arg' only there so I can be passed to cfs_create_thread() */
@@ -63,7 +63,7 @@ lnet_configure(void *arg)
        return rc;
 }
 
-int
+static int
 lnet_unconfigure(void)
 {
        int   refcount;
@@ -83,7 +83,7 @@ lnet_unconfigure(void)
        return (refcount == 0) ? 0 : -EBUSY;
 }
 
-int
+static int
 lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data)
 {
        int   rc;
@@ -110,7 +110,7 @@ lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data)
 
 DECLARE_IOCTL_HANDLER(lnet_ioctl_handler, lnet_ioctl);
 
-int
+static int __init
 init_lnet(void)
 {
        int               rc;
@@ -135,7 +135,7 @@ init_lnet(void)
        return 0;
 }
 
-void
+static void __exit
 fini_lnet(void)
 {
        int rc;
index 6e8f7e2..d9645f6 100644 (file)
@@ -164,8 +164,8 @@ static int proc_lnet_stats(struct ctl_table *table, int write,
                                 __proc_lnet_stats);
 }
 
-int proc_lnet_routes(struct ctl_table *table, int write, void __user *buffer,
-                    size_t *lenp, loff_t *ppos)
+static int proc_lnet_routes(struct ctl_table *table, int write,
+                           void __user *buffer, size_t *lenp, loff_t *ppos)
 {
        const int       tmpsiz = 256;
        char            *tmpstr;
@@ -290,8 +290,8 @@ int proc_lnet_routes(struct ctl_table *table, int write, void __user *buffer,
        return rc;
 }
 
-int proc_lnet_routers(struct ctl_table *table, int write, void __user *buffer,
-                     size_t *lenp, loff_t *ppos)
+static int proc_lnet_routers(struct ctl_table *table, int write,
+                            void __user *buffer, size_t *lenp, loff_t *ppos)
 {
        int     rc = 0;
        char      *tmpstr;
@@ -425,8 +425,8 @@ int proc_lnet_routers(struct ctl_table *table, int write, void __user *buffer,
        return rc;
 }
 
-int proc_lnet_peers(struct ctl_table *table, int write, void __user *buffer,
-                   size_t *lenp, loff_t *ppos)
+static int proc_lnet_peers(struct ctl_table *table, int write,
+                          void __user *buffer, size_t *lenp, loff_t *ppos)
 {
        const int               tmpsiz  = 256;
        struct lnet_peer_table  *ptable;
@@ -657,8 +657,8 @@ static int proc_lnet_buffers(struct ctl_table *table, int write,
                                 __proc_lnet_buffers);
 }
 
-int proc_lnet_nis(struct ctl_table *table, int write, void __user *buffer,
-                 size_t *lenp, loff_t *ppos)
+static int proc_lnet_nis(struct ctl_table *table, int write,
+                        void __user *buffer, size_t *lenp, loff_t *ppos)
 {
        int     tmpsiz = 128 * LNET_CPT_NUMBER;
        int     rc = 0;
index a94f336..463da07 100644 (file)
@@ -233,7 +233,7 @@ brw_fill_bulk(srpc_bulk_t *bk, int pattern, __u64 magic)
        }
 }
 
-int
+static int
 brw_check_bulk(srpc_bulk_t *bk, int pattern, __u64 magic)
 {
        int      i;
@@ -358,7 +358,7 @@ out:
        return;
 }
 
-void
+static void
 brw_server_rpc_done(srpc_server_rpc_t *rpc)
 {
        srpc_bulk_t *blk = rpc->srpc_bulk;
@@ -378,7 +378,7 @@ brw_server_rpc_done(srpc_server_rpc_t *rpc)
        sfw_free_pages(rpc);
 }
 
-int
+static int
 brw_bulk_ready(srpc_server_rpc_t *rpc, int status)
 {
        __u64        magic = BRW_MAGIC;
@@ -414,7 +414,7 @@ brw_bulk_ready(srpc_server_rpc_t *rpc, int status)
        return 0;
 }
 
-int
+static int
 brw_server_handle(struct srpc_server_rpc *rpc)
 {
        struct srpc_service     *sv = rpc->srpc_scd->scd_svc;
index ae7b0fc..5bc6153 100644 (file)
@@ -45,7 +45,7 @@
 #include "../../include/linux/lnet/lnetst.h"
 #include "console.h"
 
-int
+static int
 lst_session_new_ioctl(lstio_session_new_args_t *args)
 {
        char      *name;
@@ -82,7 +82,7 @@ lst_session_new_ioctl(lstio_session_new_args_t *args)
        return rc;
 }
 
-int
+static int
 lst_session_end_ioctl(lstio_session_end_args_t *args)
 {
        if (args->lstio_ses_key != console_session.ses_key)
@@ -91,7 +91,7 @@ lst_session_end_ioctl(lstio_session_end_args_t *args)
        return lstcon_session_end();
 }
 
-int
+static int
 lst_session_info_ioctl(lstio_session_info_args_t *args)
 {
        /* no checking of key */
@@ -113,7 +113,7 @@ lst_session_info_ioctl(lstio_session_info_args_t *args)
                                   args->lstio_ses_nmlen);
 }
 
-int
+static int
 lst_debug_ioctl(lstio_debug_args_t *args)
 {
        char   *name   = NULL;
@@ -194,7 +194,7 @@ out:
        return rc;
 }
 
-int
+static int
 lst_group_add_ioctl(lstio_group_add_args_t *args)
 {
        char       *name;
@@ -228,7 +228,7 @@ lst_group_add_ioctl(lstio_group_add_args_t *args)
        return rc;
 }
 
-int
+static int
 lst_group_del_ioctl(lstio_group_del_args_t *args)
 {
        int     rc;
@@ -262,7 +262,7 @@ lst_group_del_ioctl(lstio_group_del_args_t *args)
        return rc;
 }
 
-int
+static int
 lst_group_update_ioctl(lstio_group_update_args_t *args)
 {
        int     rc;
@@ -320,7 +320,7 @@ lst_group_update_ioctl(lstio_group_update_args_t *args)
        return rc;
 }
 
-int
+static int
 lst_nodes_add_ioctl(lstio_group_nodes_args_t *args)
 {
        unsigned feats;
@@ -365,7 +365,7 @@ lst_nodes_add_ioctl(lstio_group_nodes_args_t *args)
        return rc;
 }
 
-int
+static int
 lst_group_list_ioctl(lstio_group_list_args_t *args)
 {
        if (args->lstio_grp_key != console_session.ses_key)
@@ -382,7 +382,7 @@ lst_group_list_ioctl(lstio_group_list_args_t *args)
                              args->lstio_grp_namep);
 }
 
-int
+static int
 lst_group_info_ioctl(lstio_group_info_args_t *args)
 {
        char       *name;
@@ -446,7 +446,7 @@ lst_group_info_ioctl(lstio_group_info_args_t *args)
        return 0;
 }
 
-int
+static int
 lst_batch_add_ioctl(lstio_batch_add_args_t *args)
 {
        int          rc;
@@ -480,7 +480,7 @@ lst_batch_add_ioctl(lstio_batch_add_args_t *args)
        return rc;
 }
 
-int
+static int
 lst_batch_run_ioctl(lstio_batch_run_args_t *args)
 {
        int          rc;
@@ -515,7 +515,7 @@ lst_batch_run_ioctl(lstio_batch_run_args_t *args)
        return rc;
 }
 
-int
+static int
 lst_batch_stop_ioctl(lstio_batch_stop_args_t *args)
 {
        int          rc;
@@ -551,7 +551,7 @@ lst_batch_stop_ioctl(lstio_batch_stop_args_t *args)
        return rc;
 }
 
-int
+static int
 lst_batch_query_ioctl(lstio_batch_query_args_t *args)
 {
        char   *name;
@@ -593,7 +593,7 @@ lst_batch_query_ioctl(lstio_batch_query_args_t *args)
        return rc;
 }
 
-int
+static int
 lst_batch_list_ioctl(lstio_batch_list_args_t *args)
 {
        if (args->lstio_bat_key != console_session.ses_key)
@@ -610,7 +610,7 @@ lst_batch_list_ioctl(lstio_batch_list_args_t *args)
                              args->lstio_bat_namep);
 }
 
-int
+static int
 lst_batch_info_ioctl(lstio_batch_info_args_t *args)
 {
        char       *name;
@@ -675,7 +675,7 @@ lst_batch_info_ioctl(lstio_batch_info_args_t *args)
        return rc;
 }
 
-int
+static int
 lst_stat_query_ioctl(lstio_stat_args_t *args)
 {
        int          rc;
index a3a60d6..9999b0d 100644 (file)
@@ -88,7 +88,7 @@ lstcon_rpc_done(srpc_client_rpc_t *rpc)
        spin_unlock(&rpc->crpc_lock);
 }
 
-int
+static int
 lstcon_rpc_init(lstcon_node_t *nd, int service, unsigned feats,
                int bulk_npg, int bulk_len, int embedded, lstcon_rpc_t *crpc)
 {
@@ -113,7 +113,7 @@ lstcon_rpc_init(lstcon_node_t *nd, int service, unsigned feats,
        return 0;
 }
 
-int
+static int
 lstcon_rpc_prep(lstcon_node_t *nd, int service, unsigned feats,
                int bulk_npg, int bulk_len, lstcon_rpc_t **crpcpp)
 {
@@ -182,7 +182,7 @@ lstcon_rpc_put(lstcon_rpc_t *crpc)
        atomic_dec(&console_session.ses_rpc_counter);
 }
 
-void
+static void
 lstcon_rpc_post(lstcon_rpc_t *crpc)
 {
        lstcon_rpc_trans_t *trans = crpc->crp_trans;
@@ -383,7 +383,7 @@ lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout)
        return rc;
 }
 
-int
+static int
 lstcon_rpc_get_reply(lstcon_rpc_t *crpc, srpc_msg_t **msgpp)
 {
        lstcon_node_t   *nd  = crpc->crp_node;
@@ -718,7 +718,7 @@ lstcon_next_id(int idx, int nkiov, lnet_kiov_t *kiov)
        return &pid[idx % SFW_ID_PER_PAGE];
 }
 
-int
+static int
 lstcon_dstnodes_prep(lstcon_group_t *grp, int idx,
                     int dist, int span, int nkiov, lnet_kiov_t *kiov)
 {
@@ -772,7 +772,7 @@ lstcon_dstnodes_prep(lstcon_group_t *grp, int idx,
        return 0;
 }
 
-int
+static int
 lstcon_pingrpc_prep(lst_test_ping_param_t *param, srpc_test_reqst_t *req)
 {
        test_ping_req_t *prq = &req->tsr_u.ping;
@@ -783,7 +783,7 @@ lstcon_pingrpc_prep(lst_test_ping_param_t *param, srpc_test_reqst_t *req)
        return 0;
 }
 
-int
+static int
 lstcon_bulkrpc_v0_prep(lst_test_bulk_param_t *param, srpc_test_reqst_t *req)
 {
        test_bulk_req_t *brq = &req->tsr_u.bulk_v0;
@@ -795,7 +795,7 @@ lstcon_bulkrpc_v0_prep(lst_test_bulk_param_t *param, srpc_test_reqst_t *req)
        return 0;
 }
 
-int
+static int
 lstcon_bulkrpc_v1_prep(lst_test_bulk_param_t *param, srpc_test_reqst_t *req)
 {
        test_bulk_req_v1_t *brq = &req->tsr_u.bulk_v1;
@@ -915,7 +915,7 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
        return rc;
 }
 
-int
+static int
 lstcon_sesnew_stat_reply(lstcon_rpc_trans_t *trans,
                         lstcon_node_t *nd, srpc_msg_t *reply)
 {
@@ -1162,7 +1162,7 @@ lstcon_rpc_trans_ndlist(struct list_head *ndlist,
        return rc;
 }
 
-void
+static void
 lstcon_rpc_pinger(void *arg)
 {
        stt_timer_t     *ptimer = (stt_timer_t *)arg;
index df04ab7..82cc94b 100644 (file)
@@ -156,7 +156,7 @@ sfw_register_test (srpc_service_t *service, sfw_test_client_ops_t *cliops)
        return 0;
 }
 
-void
+static void
 sfw_add_session_timer (void)
 {
        sfw_session_t *sn = sfw_data.fw_session;
@@ -176,7 +176,7 @@ sfw_add_session_timer (void)
        return;
 }
 
-int
+static int
 sfw_del_session_timer (void)
 {
        sfw_session_t *sn = sfw_data.fw_session;
@@ -238,7 +238,7 @@ sfw_deactivate_session (void)
 }
 
 
-void
+static void
 sfw_session_expired (void *data)
 {
        sfw_session_t *sn = data;
@@ -284,7 +284,7 @@ sfw_init_session(sfw_session_t *sn, lst_sid_t sid,
 }
 
 /* completion handler for incoming framework RPCs */
-void
+static void
 sfw_server_rpc_done(struct srpc_server_rpc *rpc)
 {
        struct srpc_service     *sv     = rpc->srpc_scd->scd_svc;
@@ -302,7 +302,7 @@ sfw_server_rpc_done(struct srpc_server_rpc *rpc)
        return;
 }
 
-void
+static void
 sfw_client_rpc_fini (srpc_client_rpc_t *rpc)
 {
        LASSERT (rpc->crpc_bulk.bk_niov == 0);
@@ -325,7 +325,7 @@ sfw_client_rpc_fini (srpc_client_rpc_t *rpc)
        spin_unlock(&sfw_data.fw_lock);
 }
 
-sfw_batch_t *
+static sfw_batch_t *
 sfw_find_batch (lst_bid_t bid)
 {
        sfw_session_t *sn = sfw_data.fw_session;
@@ -341,7 +341,7 @@ sfw_find_batch (lst_bid_t bid)
        return NULL;
 }
 
-sfw_batch_t *
+static sfw_batch_t *
 sfw_bid2batch (lst_bid_t bid)
 {
        sfw_session_t *sn = sfw_data.fw_session;
@@ -367,7 +367,7 @@ sfw_bid2batch (lst_bid_t bid)
        return bat;
 }
 
-int
+static int
 sfw_get_stats (srpc_stat_reqst_t *request, srpc_stat_reply_t *reply)
 {
        sfw_session_t  *sn = sfw_data.fw_session;
@@ -479,7 +479,7 @@ sfw_make_session(srpc_mksn_reqst_t *request, srpc_mksn_reply_t *reply)
        return 0;
 }
 
-int
+static int
 sfw_remove_session (srpc_rmsn_reqst_t *request, srpc_rmsn_reply_t *reply)
 {
        sfw_session_t *sn = sfw_data.fw_session;
@@ -511,7 +511,7 @@ sfw_remove_session (srpc_rmsn_reqst_t *request, srpc_rmsn_reply_t *reply)
        return 0;
 }
 
-int
+static int
 sfw_debug_session (srpc_debug_reqst_t *request, srpc_debug_reply_t *reply)
 {
        sfw_session_t *sn = sfw_data.fw_session;
@@ -532,7 +532,7 @@ sfw_debug_session (srpc_debug_reqst_t *request, srpc_debug_reply_t *reply)
        return 0;
 }
 
-void
+static void
 sfw_test_rpc_fini (srpc_client_rpc_t *rpc)
 {
        sfw_test_unit_t     *tsu = rpc->crpc_priv;
@@ -554,7 +554,7 @@ sfw_test_buffers(sfw_test_instance_t *tsi)
        return max(SFW_TEST_WI_MIN, nbuf + SFW_TEST_WI_EXTRA);
 }
 
-int
+static int
 sfw_load_test(struct sfw_test_instance *tsi)
 {
        struct sfw_test_case    *tsc;
@@ -591,7 +591,7 @@ sfw_load_test(struct sfw_test_instance *tsi)
        return 0;
 }
 
-void
+static void
 sfw_unload_test(struct sfw_test_instance *tsi)
 {
        struct sfw_test_case *tsc = sfw_find_test_case(tsi->tsi_service);
@@ -609,7 +609,7 @@ sfw_unload_test(struct sfw_test_instance *tsi)
        return;
 }
 
-void
+static void
 sfw_destroy_test_instance (sfw_test_instance_t *tsi)
 {
        srpc_client_rpc_t *rpc;
@@ -643,7 +643,7 @@ clean:
        return;
 }
 
-void
+static void
 sfw_destroy_batch (sfw_batch_t *tsb)
 {
        sfw_test_instance_t *tsi;
@@ -682,7 +682,7 @@ sfw_destroy_session (sfw_session_t *sn)
        return;
 }
 
-void
+static void
 sfw_unpack_addtest_req(srpc_msg_t *msg)
 {
        srpc_test_reqst_t *req = &msg->msg_body.tes_reqst;
@@ -727,7 +727,7 @@ sfw_unpack_addtest_req(srpc_msg_t *msg)
        return;
 }
 
-int
+static int
 sfw_add_test_instance (sfw_batch_t *tsb, srpc_server_rpc_t *rpc)
 {
        srpc_msg_t        *msg = &rpc->srpc_reqstbuf->buf_msg;
@@ -865,7 +865,7 @@ sfw_test_unit_done (sfw_test_unit_t *tsu)
        return;
 }
 
-void
+static void
 sfw_test_rpc_done (srpc_client_rpc_t *rpc)
 {
        sfw_test_unit_t     *tsu = rpc->crpc_priv;
@@ -944,7 +944,7 @@ sfw_create_test_rpc(sfw_test_unit_t *tsu, lnet_process_id_t peer,
        return 0;
 }
 
-int
+static int
 sfw_run_test (swi_workitem_t *wi)
 {
        sfw_test_unit_t     *tsu = wi->swi_workitem.wi_data;
@@ -994,7 +994,7 @@ test_done:
        return 1;
 }
 
-int
+static int
 sfw_run_batch (sfw_batch_t *tsb)
 {
        swi_workitem_t      *wi;
@@ -1072,7 +1072,7 @@ sfw_stop_batch (sfw_batch_t *tsb, int force)
        return 0;
 }
 
-int
+static int
 sfw_query_batch (sfw_batch_t *tsb, int testidx, srpc_batch_reply_t *reply)
 {
        sfw_test_instance_t *tsi;
@@ -1117,7 +1117,7 @@ sfw_alloc_pages(struct srpc_server_rpc *rpc, int cpt, int npages, int len,
        return 0;
 }
 
-int
+static int
 sfw_add_test (srpc_server_rpc_t *rpc)
 {
        sfw_session_t     *sn = sfw_data.fw_session;
@@ -1187,7 +1187,7 @@ sfw_add_test (srpc_server_rpc_t *rpc)
        return 0;
 }
 
-int
+static int
 sfw_control_batch (srpc_batch_reqst_t *request, srpc_batch_reply_t *reply)
 {
        sfw_session_t *sn = sfw_data.fw_session;
@@ -1228,7 +1228,7 @@ sfw_control_batch (srpc_batch_reqst_t *request, srpc_batch_reply_t *reply)
        return 0;
 }
 
-int
+static int
 sfw_handle_server_rpc(struct srpc_server_rpc *rpc)
 {
        struct srpc_service     *sv = rpc->srpc_scd->scd_svc;
@@ -1334,7 +1334,7 @@ sfw_handle_server_rpc(struct srpc_server_rpc *rpc)
        return rc;
 }
 
-int
+static int
 sfw_bulk_ready(struct srpc_server_rpc *rpc, int status)
 {
        struct srpc_service     *sv = rpc->srpc_scd->scd_svc;
index 6dd4309..92520c2 100644 (file)
@@ -55,7 +55,7 @@ static int lst_init_step = LST_INIT_NONE;
 struct cfs_wi_sched *lst_sched_serial;
 struct cfs_wi_sched **lst_sched_test;
 
-void
+static void
 lnet_selftest_fini(void)
 {
        int     i;
@@ -90,18 +90,7 @@ lnet_selftest_fini(void)
        return;
 }
 
-void
-lnet_selftest_structure_assertion(void)
-{
-       CLASSERT(sizeof(srpc_msg_t) == 160);
-       CLASSERT(sizeof(srpc_test_reqst_t) == 70);
-       CLASSERT(offsetof(srpc_msg_t, msg_body.tes_reqst.tsr_concur) == 72);
-       CLASSERT(offsetof(srpc_msg_t, msg_body.tes_reqst.tsr_ndest) == 78);
-       CLASSERT(sizeof(srpc_stat_reply_t) == 136);
-       CLASSERT(sizeof(srpc_stat_reqst_t) == 28);
-}
-
-int
+static int
 lnet_selftest_init(void)
 {
        int     nscheds;
index 750cac4..d8c0df6 100644 (file)
@@ -44,7 +44,7 @@
 
 #define LST_PING_TEST_MAGIC     0xbabeface
 
-int ping_srv_workitems = SFW_TEST_WI_MAX;
+static int ping_srv_workitems = SFW_TEST_WI_MAX;
 module_param(ping_srv_workitems, int, 0644);
 MODULE_PARM_DESC(ping_srv_workitems, "# PING server workitems");
 
index a9f29d8..c9a1a45 100644 (file)
@@ -87,7 +87,7 @@ void srpc_set_counters (const srpc_counters_t *cnt)
        spin_unlock(&srpc_data.rpc_glock);
 }
 
-int
+static int
 srpc_add_bulk_page(srpc_bulk_t *bk, struct page *pg, int i, int nob)
 {
        nob = min(nob, (int)PAGE_CACHE_SIZE);
@@ -170,7 +170,7 @@ srpc_next_id (void)
        return id;
 }
 
-void
+static void
 srpc_init_server_rpc(struct srpc_server_rpc *rpc,
                     struct srpc_service_cd *scd,
                     struct srpc_buffer *buffer)
@@ -351,7 +351,7 @@ srpc_remove_service (srpc_service_t *sv)
        return 0;
 }
 
-int
+static int
 srpc_post_passive_rdma(int portal, int local, __u64 matchbits, void *buf,
                       int len, int options, lnet_process_id_t peer,
                       lnet_handle_md_t *mdh, srpc_event_t *ev)
@@ -391,7 +391,7 @@ srpc_post_passive_rdma(int portal, int local, __u64 matchbits, void *buf,
        return 0;
 }
 
-int
+static int
 srpc_post_active_rdma(int portal, __u64 matchbits, void *buf, int len,
                      int options, lnet_process_id_t peer, lnet_nid_t self,
                      lnet_handle_md_t *mdh, srpc_event_t *ev)
@@ -443,7 +443,7 @@ srpc_post_active_rdma(int portal, __u64 matchbits, void *buf, int len,
        return 0;
 }
 
-int
+static int
 srpc_post_active_rqtbuf(lnet_process_id_t peer, int service, void *buf,
                        int len, lnet_handle_md_t *mdh, srpc_event_t *ev)
 {
@@ -452,7 +452,7 @@ srpc_post_active_rqtbuf(lnet_process_id_t peer, int service, void *buf,
                                     LNET_NID_ANY, mdh, ev);
 }
 
-int
+static int
 srpc_post_passive_rqtbuf(int service, int local, void *buf, int len,
                         lnet_handle_md_t *mdh, srpc_event_t *ev)
 {
@@ -466,7 +466,7 @@ srpc_post_passive_rqtbuf(int service, int local, void *buf, int len,
                                      LNET_MD_OP_PUT, any, mdh, ev);
 }
 
-int
+static int
 srpc_service_post_buffer(struct srpc_service_cd *scd, struct srpc_buffer *buf)
 {
        struct srpc_service     *sv = scd->scd_svc;
@@ -697,7 +697,7 @@ srpc_finish_service(struct srpc_service *sv)
 }
 
 /* called with sv->sv_lock held */
-void
+static void
 srpc_service_recycle_buffer(struct srpc_service_cd *scd, srpc_buffer_t *buf)
 {
        if (!scd->scd_svc->sv_shuttingdown && scd->scd_buf_adjust >= 0) {
@@ -787,7 +787,7 @@ srpc_shutdown_service(srpc_service_t *sv)
        }
 }
 
-int
+static int
 srpc_send_request (srpc_client_rpc_t *rpc)
 {
        srpc_event_t *ev = &rpc->crpc_reqstev;
@@ -807,7 +807,7 @@ srpc_send_request (srpc_client_rpc_t *rpc)
        return rc;
 }
 
-int
+static int
 srpc_prepare_reply (srpc_client_rpc_t *rpc)
 {
        srpc_event_t *ev = &rpc->crpc_replyev;
@@ -831,7 +831,7 @@ srpc_prepare_reply (srpc_client_rpc_t *rpc)
        return rc;
 }
 
-int
+static int
 srpc_prepare_bulk (srpc_client_rpc_t *rpc)
 {
        srpc_bulk_t  *bk = &rpc->crpc_bulk;
@@ -863,7 +863,7 @@ srpc_prepare_bulk (srpc_client_rpc_t *rpc)
        return rc;
 }
 
-int
+static int
 srpc_do_bulk (srpc_server_rpc_t *rpc)
 {
        srpc_event_t  *ev = &rpc->srpc_ev;
@@ -891,7 +891,7 @@ srpc_do_bulk (srpc_server_rpc_t *rpc)
 }
 
 /* only called from srpc_handle_rpc */
-void
+static void
 srpc_server_rpc_done(srpc_server_rpc_t *rpc, int status)
 {
        struct srpc_service_cd  *scd = rpc->srpc_scd;
@@ -1066,7 +1066,7 @@ srpc_handle_rpc(swi_workitem_t *wi)
        return 0;
 }
 
-void
+static void
 srpc_client_rpc_expired (void *data)
 {
        srpc_client_rpc_t *rpc = data;
@@ -1108,7 +1108,7 @@ srpc_add_client_rpc_timer (srpc_client_rpc_t *rpc)
  *
  * Upon exit the RPC expiry timer is not queued and the handler is not
  * running on any CPU. */
-void
+static void
 srpc_del_client_rpc_timer (srpc_client_rpc_t *rpc)
 {
        /* timer not planted or already exploded */
@@ -1129,7 +1129,7 @@ srpc_del_client_rpc_timer (srpc_client_rpc_t *rpc)
        }
 }
 
-void
+static void
 srpc_client_rpc_done (srpc_client_rpc_t *rpc, int status)
 {
        swi_workitem_t *wi = &rpc->crpc_wi;
@@ -1393,7 +1393,7 @@ srpc_send_reply(struct srpc_server_rpc *rpc)
 }
 
 /* when in kernel always called with LNET_LOCK() held, and in thread context */
-void
+static void
 srpc_lnet_ev_handler(lnet_event_t *ev)
 {
        struct srpc_service_cd  *scd;
index 91d4caa..f8352c2 100644 (file)
@@ -121,7 +121,7 @@ stt_del_timer(stt_timer_t *timer)
 }
 
 /* called with stt_data.stt_lock held */
-int
+static int
 stt_expire_list(struct list_head *slot, unsigned long now)
 {
        int       expired = 0;
@@ -145,7 +145,7 @@ stt_expire_list(struct list_head *slot, unsigned long now)
        return expired;
 }
 
-int
+static int
 stt_check_timers(unsigned long *last)
 {
        int     expired = 0;
@@ -168,7 +168,7 @@ stt_check_timers(unsigned long *last)
 }
 
 
-int
+static int
 stt_timer_main(void *arg)
 {
        cfs_block_allsigs();
@@ -187,7 +187,7 @@ stt_timer_main(void *arg)
        return 0;
 }
 
-int
+static int
 stt_start_timer_thread(void)
 {
        struct task_struct *task;
index 212ebae..be4c7d9 100644 (file)
@@ -617,7 +617,7 @@ struct dt_index_operations {
                int        (*load)(const struct lu_env *env,
                                      const struct dt_it *di, __u64 hash);
                int     (*key_rec)(const struct lu_env *env,
-                                     const struct dt_it *di, voidkey_rec);
+                                     const struct dt_it *di, void *key_rec);
        } dio_it;
 };
 
@@ -667,7 +667,7 @@ static inline int lu_device_is_dt(const struct lu_device *d)
        return ergo(d != NULL, d->ld_type->ldt_tags & LU_DEVICE_DT);
 }
 
-static inline struct dt_device * lu2dt_dev(struct lu_device *l)
+static inline struct dt_device *lu2dt_dev(struct lu_device *l)
 {
        LASSERT(lu_device_is_dt(l));
        return container_of0(l, struct dt_device, dd_lu_dev);
index e94ab34..8156b4c 100644 (file)
@@ -91,8 +91,6 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
 # define inode_dio_read(i)             atomic_inc(&(i)->i_dio_count)
 /* inode_dio_done(i) use as-is for read unlock */
 
-#define TREE_READ_LOCK_IRQ(mapping)    spin_lock_irq(&(mapping)->tree_lock)
-#define TREE_READ_UNLOCK_IRQ(mapping)  spin_unlock_irq(&(mapping)->tree_lock)
 
 #ifndef FS_HAS_FIEMAP
 #define FS_HAS_FIEMAP                  (0)
@@ -139,8 +137,7 @@ ll_quota_on(struct super_block *sb, int off, int ver, char *name, int remount)
                                           );
                path_put(&path);
                return rc;
-       }
-       else
+       } else
                return -ENOSYS;
 }
 
@@ -149,8 +146,7 @@ static inline int ll_quota_off(struct super_block *sb, int off, int remount)
        if (sb->s_qcop->quota_off) {
                return sb->s_qcop->quota_off(sb, off
                                            );
-       }
-       else
+       } else
                return -ENOSYS;
 }
 
index ccb6cd4..cfe503b 100644 (file)
@@ -374,8 +374,8 @@ static inline void s2dhms(struct dhms *ts, time_t secs)
 #define JOBSTATS_PROCNAME_UID          "procname_uid"
 #define JOBSTATS_NODELOCAL             "nodelocal"
 
-extern int lprocfs_write_frac_helper(const char *buffer, unsigned long count,
-                                    int *val, int mult);
+extern int lprocfs_write_frac_helper(const char __user *buffer,
+                                    unsigned long count, int *val, int mult);
 extern int lprocfs_read_frac_helper(char *buffer, unsigned long count,
                                    long val, int mult);
 #if defined (CONFIG_PROC_FS)
@@ -557,7 +557,7 @@ extern void lprocfs_free_obd_stats(struct obd_device *obddev);
 extern void lprocfs_free_md_stats(struct obd_device *obddev);
 struct obd_export;
 struct nid_stat;
-extern int lprocfs_add_clear_entry(struct obd_device * obd,
+extern int lprocfs_add_clear_entry(struct obd_device *obd,
                                   struct proc_dir_entry *entry);
 extern int lprocfs_exp_setup(struct obd_export *exp,
                             lnet_nid_t *peer_nid, int *newnid);
@@ -647,7 +647,7 @@ extern int lprocfs_rd_kbytesavail(struct seq_file *m, void *data);
 extern int lprocfs_rd_filestotal(struct seq_file *m, void *data);
 extern int lprocfs_rd_filesfree(struct seq_file *m, void *data);
 
-extern int lprocfs_write_helper(const char *buffer, unsigned long count,
+extern int lprocfs_write_helper(const char __user *buffer, unsigned long count,
                                int *val);
 extern int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult);
 extern int lprocfs_write_u64_helper(const char *buffer, unsigned long count,
index 6015ee5..2ddb2b0 100644 (file)
@@ -1120,7 +1120,7 @@ struct lu_context_key {
 };
 
 #define LU_KEY_INIT(mod, type)                             \
-       static voidmod##_key_init(const struct lu_context *ctx, \
+       static void *mod##_key_init(const struct lu_context *ctx, \
                                    struct lu_context_key *key)   \
        {                                                        \
                type *value;                                  \
@@ -1137,7 +1137,7 @@ struct lu_context_key {
 
 #define LU_KEY_FINI(mod, type)                                       \
        static void mod##_key_fini(const struct lu_context *ctx,            \
-                                   struct lu_context_key *key, voiddata) \
+                                   struct lu_context_key *key, void *data) \
        {                                                                  \
                type *info = data;                                        \
                                                                            \
index ab6b9ea..fe19534 100644 (file)
@@ -154,7 +154,7 @@ static inline __u32 capa_expiry(struct lustre_capa *capa)
 }
 
 void _debug_capa(struct lustre_capa *, struct libcfs_debug_msg_data *,
-                const char *fmt, ... );
+                const char *fmt, ...);
 #define DEBUG_CAPA(level, capa, fmt, args...)                            \
 do {                                                                      \
        if (((level) & D_CANTMASK) != 0 ||                                   \
index 14ac46f..83bc0a9 100644 (file)
@@ -1446,7 +1446,7 @@ static inline void check_res_locked(struct ldlm_resource *res)
        assert_spin_locked(&res->lr_lock);
 }
 
-struct ldlm_resource * lock_res_and_lock(struct ldlm_lock *lock);
+struct ldlm_resource *lock_res_and_lock(struct ldlm_lock *lock);
 void unlock_res_and_lock(struct ldlm_lock *lock);
 
 /* ldlm_pool.c */
index b94f76a..0f8f76c 100644 (file)
@@ -74,7 +74,7 @@ typedef struct {
 extern ext_acl_xattr_header *
 lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size);
 extern int
-lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, int size,
+lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size,
                              posix_acl_xattr_header **out);
 extern void
 lustre_posix_acl_xattr_free(posix_acl_xattr_header *header, int size);
index 12c7590..bf13563 100644 (file)
@@ -85,7 +85,7 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id);
 
 /* client.c */
 
-int client_sanobd_setup(struct obd_device *obddev, struct lustre_cfglcfg);
+int client_sanobd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg);
 struct client_obd *client_conn2cli(struct lustre_handle *conn);
 
 struct md_open_data;
index 0a024d3..36396d1 100644 (file)
@@ -2627,12 +2627,7 @@ __u32 lustre_msg_get_timeout(struct lustre_msg *msg);
 __u32 lustre_msg_get_service_time(struct lustre_msg *msg);
 char *lustre_msg_get_jobid(struct lustre_msg *msg);
 __u32 lustre_msg_get_cksum(struct lustre_msg *msg);
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0)
-__u32 lustre_msg_calc_cksum(struct lustre_msg *msg, int compat18);
-#else
-# warning "remove checksum compatibility support for b1_8"
 __u32 lustre_msg_calc_cksum(struct lustre_msg *msg);
-#endif
 void lustre_msg_set_handle(struct lustre_msg *msg,
                           struct lustre_handle *handle);
 void lustre_msg_set_type(struct lustre_msg *msg, __u32 type);
@@ -2951,7 +2946,7 @@ void ptlrpcd_decref(void);
  * procfs output related functions
  * @{
  */
-const charll_opcode2str(__u32 opcode);
+const char *ll_opcode2str(__u32 opcode);
 #if defined (CONFIG_PROC_FS)
 void ptlrpc_lprocfs_register_obd(struct obd_device *obd);
 void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd);
index 882e40b..4a29261 100644 (file)
@@ -414,7 +414,7 @@ do {                                                            \
 #define EXP_MD_COUNTER_INCREMENT(exp, op)
 #endif
 
-static inline int lprocfs_nid_ldlm_stats_init(struct nid_stattmp)
+static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat *tmp)
 {
        /* Always add in ldlm_stats */
        tmp->nid_ldlm_stats = lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC
index f997566..06cf6d2 100644 (file)
@@ -244,7 +244,7 @@ typedef enum ldlm_policy_res ldlm_policy_res_t;
                                                                            \
                return lprocfs_rd_uint(m, &tmp);                            \
        }                                                                   \
-       struct __##var##__dummy_read {;} /* semicolon catcher */
+       struct __##var##__dummy_read {; } /* semicolon catcher */
 
 #define LDLM_POOL_PROC_WRITER(var, type)                                   \
        static int lprocfs_wr_##var(struct file *file, const char *buffer,  \
@@ -266,7 +266,7 @@ typedef enum ldlm_policy_res ldlm_policy_res_t;
                                                                            \
                return rc;                                                  \
        }                                                                   \
-       struct __##var##__dummy_write {;} /* semicolon catcher */
+       struct __##var##__dummy_write {; } /* semicolon catcher */
 
 static inline int is_granted_or_cancelled(struct ldlm_lock *lock)
 {
index 6054eee..c80c76a 100644 (file)
@@ -265,7 +265,7 @@ static void ldlm_pool_recalc_slv(struct ldlm_pool *pl)
         * SLV. And the opposite, the more grant plan is over-consumed
         * (load time) the faster drops SLV.
         */
-       slv_factor = (grant_usage << LDLM_POOL_SLV_SHIFT);
+       slv_factor = grant_usage << LDLM_POOL_SLV_SHIFT;
        do_div(slv_factor, limit);
        slv = slv * slv_factor;
        slv = dru(slv, LDLM_POOL_SLV_SHIFT, round_up);
@@ -1205,8 +1205,7 @@ int ldlm_pools_recalc(ldlm_side_t client)
                 * The rest is given to greedy namespaces.
                 */
                list_for_each_entry(ns, ldlm_namespace_list(client),
-                                       ns_list_chain)
-               {
+                                   ns_list_chain) {
                        if (!equal && ns->ns_appetite != LDLM_NAMESPACE_GREEDY)
                                continue;
 
index a785b7a..8b20a83 100644 (file)
@@ -501,7 +501,7 @@ cfs_hash_ops_t ldlm_ns_fid_hash_ops = {
        .hs_put  = ldlm_res_hop_put
 };
 
-typedef struct {
+struct ldlm_ns_hash_def {
        ldlm_ns_type_t  nsd_type;
        /** hash bucket bits */
        unsigned        nsd_bkt_bits;
@@ -509,9 +509,9 @@ typedef struct {
        unsigned        nsd_all_bits;
        /** hash operations */
        cfs_hash_ops_t *nsd_hops;
-} ldlm_ns_hash_def_t;
+};
 
-ldlm_ns_hash_def_t ldlm_ns_hash_defs[] = {
+struct ldlm_ns_hash_def ldlm_ns_hash_defs[] = {
        {
                .nsd_type       = LDLM_NS_TYPE_MDC,
                .nsd_bkt_bits   = 11,
@@ -563,7 +563,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
 {
        struct ldlm_namespace *ns = NULL;
        struct ldlm_ns_bucket *nsb;
-       ldlm_ns_hash_def_t    *nsd;
+       struct ldlm_ns_hash_def    *nsd;
        struct cfs_hash_bd        bd;
        int                 idx;
        int                 rc;
index ba43b30..2c15a9e 100644 (file)
@@ -412,7 +412,7 @@ int libcfs_debug_init(unsigned long bufsize)
                max = TCD_MAX_PAGES;
        } else {
                max = (max / num_possible_cpus());
-               max = (max << (20 - PAGE_CACHE_SHIFT));
+               max = max << (20 - PAGE_CACHE_SHIFT);
        }
        rc = cfs_tracefile_init(max);
 
index e73ca3d..92444b0 100644 (file)
@@ -103,18 +103,18 @@ int __cfs_fail_check_set(__u32 id, __u32 value, int set)
        }
 
        switch (set) {
-               case CFS_FAIL_LOC_NOSET:
-               case CFS_FAIL_LOC_VALUE:
-                       break;
-               case CFS_FAIL_LOC_ORSET:
-                       cfs_fail_loc |= value & ~(CFS_FAILED | CFS_FAIL_ONCE);
-                       break;
-               case CFS_FAIL_LOC_RESET:
-                       cfs_fail_loc = value;
-                       break;
-               default:
-                       LASSERTF(0, "called with bad set %u\n", set);
-                       break;
+       case CFS_FAIL_LOC_NOSET:
+       case CFS_FAIL_LOC_VALUE:
+               break;
+       case CFS_FAIL_LOC_ORSET:
+               cfs_fail_loc |= value & ~(CFS_FAILED | CFS_FAIL_ONCE);
+               break;
+       case CFS_FAIL_LOC_RESET:
+               cfs_fail_loc = value;
+               break;
+       default:
+               LASSERTF(0, "called with bad set %u\n", set);
+               break;
        }
 
        return 1;
index 3b67b7b..32da783 100644 (file)
@@ -1371,8 +1371,7 @@ cfs_hash_lookup(struct cfs_hash *hs, const void *key)
 EXPORT_SYMBOL(cfs_hash_lookup);
 
 static void
-cfs_hash_for_each_enter(struct cfs_hash *hs)
-{
+cfs_hash_for_each_enter(struct cfs_hash *hs) {
        LASSERT(!cfs_hash_is_exiting(hs));
 
        if (!cfs_hash_with_rehash(hs))
@@ -1397,8 +1396,7 @@ cfs_hash_for_each_enter(struct cfs_hash *hs)
 }
 
 static void
-cfs_hash_for_each_exit(struct cfs_hash *hs)
-{
+cfs_hash_for_each_exit(struct cfs_hash *hs) {
        int remained;
        int bits;
 
@@ -1429,8 +1427,7 @@ cfs_hash_for_each_exit(struct cfs_hash *hs)
  */
 static __u64
 cfs_hash_for_each_tight(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
-                       void *data, int remove_safe)
-{
+                       void *data, int remove_safe) {
        struct hlist_node     *hnode;
        struct hlist_node     *pos;
        struct cfs_hash_bd       bd;
@@ -1523,8 +1520,7 @@ EXPORT_SYMBOL(cfs_hash_for_each);
 
 void
 cfs_hash_for_each_safe(struct cfs_hash *hs,
-                      cfs_hash_for_each_cb_t func, void *data)
-{
+                      cfs_hash_for_each_cb_t func, void *data) {
        cfs_hash_for_each_tight(hs, func, data, 1);
 }
 EXPORT_SYMBOL(cfs_hash_for_each_safe);
@@ -1572,8 +1568,8 @@ EXPORT_SYMBOL(cfs_hash_size_get);
  * two cases, so iteration has to be stopped on change.
  */
 static int
-cfs_hash_for_each_relax(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, void *data)
-{
+cfs_hash_for_each_relax(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
+                       void *data) {
        struct hlist_node *hnode;
        struct hlist_node *tmp;
        struct cfs_hash_bd     bd;
@@ -1634,8 +1630,7 @@ cfs_hash_for_each_relax(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, void *
 
 int
 cfs_hash_for_each_nolock(struct cfs_hash *hs,
-                        cfs_hash_for_each_cb_t func, void *data)
-{
+                        cfs_hash_for_each_cb_t func, void *data) {
        if (cfs_hash_with_no_lock(hs) ||
            cfs_hash_with_rehash_key(hs) ||
            !cfs_hash_with_no_itemref(hs))
@@ -1667,8 +1662,7 @@ EXPORT_SYMBOL(cfs_hash_for_each_nolock);
  */
 int
 cfs_hash_for_each_empty(struct cfs_hash *hs,
-                       cfs_hash_for_each_cb_t func, void *data)
-{
+                       cfs_hash_for_each_cb_t func, void *data) {
        unsigned  i = 0;
 
        if (cfs_hash_with_no_lock(hs))
@@ -1726,8 +1720,7 @@ EXPORT_SYMBOL(cfs_hash_hlist_for_each);
    */
 void
 cfs_hash_for_each_key(struct cfs_hash *hs, const void *key,
-                     cfs_hash_for_each_cb_t func, void *data)
-{
+                     cfs_hash_for_each_cb_t func, void *data) {
        struct hlist_node   *hnode;
        struct cfs_hash_bd       bds[2];
        unsigned            i;
index dbb81b6..31a5581 100644 (file)
@@ -38,7 +38,7 @@
 #include "../../include/linux/libcfs/libcfs.h"
 
 /** Global CPU partition table */
-struct cfs_cpt_table   *cfs_cpt_table __read_mostly = NULL;
+struct cfs_cpt_table   *cfs_cpt_table __read_mostly;
 EXPORT_SYMBOL(cfs_cpt_table);
 
 #ifndef HAVE_LIBCFS_CPT
index bbe2c68..83d3f08 100644 (file)
@@ -365,8 +365,8 @@ static int __proc_cpt_table(void *data, int write,
                if (rc >= 0)
                        break;
 
-               LIBCFS_FREE(buf, len);
                if (rc == -EFBIG) {
+                       LIBCFS_FREE(buf, len);
                        len <<= 1;
                        continue;
                }
index b0bb709..661b2cf 100644 (file)
@@ -163,7 +163,7 @@ static int ll_dir_filler(void *_hash, struct page *page0)
 
        LASSERT(max_pages > 0 && max_pages <= MD_MAX_BRW_PAGES);
 
-       page_pool = kzalloc(sizeof(page) * max_pages, GFP_NOFS);
+       page_pool = kcalloc(max_pages, sizeof(page), GFP_NOFS);
        if (page_pool) {
                page_pool[0] = page0;
        } else {
@@ -275,14 +275,14 @@ static struct page *ll_dir_page_locate(struct inode *dir, __u64 *hash,
        struct page *page;
        int found;
 
-       TREE_READ_LOCK_IRQ(mapping);
+       spin_lock_irq(&mapping->tree_lock);
        found = radix_tree_gang_lookup(&mapping->page_tree,
                                       (void **)&page, offset, 1);
        if (found > 0) {
                struct lu_dirpage *dp;
 
                page_cache_get(page);
-               TREE_READ_UNLOCK_IRQ(mapping);
+               spin_unlock_irq(&mapping->tree_lock);
                /*
                 * In contrast to find_lock_page() we are sure that directory
                 * page cannot be truncated (while DLM lock is held) and,
@@ -326,7 +326,7 @@ static struct page *ll_dir_page_locate(struct inode *dir, __u64 *hash,
                }
 
        } else {
-               TREE_READ_UNLOCK_IRQ(mapping);
+               spin_unlock_irq(&mapping->tree_lock);
                page = NULL;
        }
        return page;
@@ -1384,7 +1384,7 @@ lmv_out_free:
                if (copy_from_user(lumv1, lumv1p, sizeof(*lumv1)))
                        return -EFAULT;
 
-               if ((lumv1->lmm_magic == LOV_USER_MAGIC_V3) ) {
+               if (lumv1->lmm_magic == LOV_USER_MAGIC_V3) {
                        if (copy_from_user(&lumv3, lumv3p, sizeof(lumv3)))
                                return -EFAULT;
                }
@@ -1509,8 +1509,7 @@ out_rmdir:
                                               cmd == LL_IOC_MDC_GETINFO)) {
                                rc = 0;
                                goto skip_lmm;
-                       }
-                       else
+                       } else
                                goto out_req;
                }
 
@@ -1694,64 +1693,6 @@ out_poll:
                OBD_FREE_PTR(check);
                return rc;
        }
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0)
-       case LL_IOC_QUOTACTL_18: {
-               /* copy the old 1.x quota struct for internal use, then copy
-                * back into old format struct.  For 1.8 compatibility. */
-               struct if_quotactl_18 *qctl_18;
-               struct if_quotactl *qctl_20;
-
-               qctl_18 = kzalloc(sizeof(*qctl_18), GFP_NOFS);
-               if (!qctl_18)
-                       return -ENOMEM;
-
-               qctl_20 = kzalloc(sizeof(*qctl_20), GFP_NOFS);
-               if (!qctl_20) {
-                       rc = -ENOMEM;
-                       goto out_quotactl_18;
-               }
-
-               if (copy_from_user(qctl_18, (void *)arg, sizeof(*qctl_18))) {
-                       rc = -ENOMEM;
-                       goto out_quotactl_20;
-               }
-
-               QCTL_COPY(qctl_20, qctl_18);
-               qctl_20->qc_idx = 0;
-
-               /* XXX: dqb_valid was borrowed as a flag to mark that
-                *      only mds quota is wanted */
-               if (qctl_18->qc_cmd == Q_GETQUOTA &&
-                   qctl_18->qc_dqblk.dqb_valid) {
-                       qctl_20->qc_valid = QC_MDTIDX;
-                       qctl_20->qc_dqblk.dqb_valid = 0;
-               } else if (qctl_18->obd_uuid.uuid[0] != '\0') {
-                       qctl_20->qc_valid = QC_UUID;
-                       qctl_20->obd_uuid = qctl_18->obd_uuid;
-               } else {
-                       qctl_20->qc_valid = QC_GENERAL;
-               }
-
-               rc = quotactl_ioctl(sbi, qctl_20);
-
-               if (rc == 0) {
-                       QCTL_COPY(qctl_18, qctl_20);
-                       qctl_18->obd_uuid = qctl_20->obd_uuid;
-
-                       if (copy_to_user((void *)arg, qctl_18,
-                                            sizeof(*qctl_18)))
-                               rc = -EFAULT;
-               }
-
-out_quotactl_20:
-               OBD_FREE_PTR(qctl_20);
-out_quotactl_18:
-               OBD_FREE_PTR(qctl_18);
-               return rc;
-       }
-#else
-#warning "remove old LL_IOC_QUOTACTL_18 compatibility code"
-#endif /* LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0) */
        case LL_IOC_QUOTACTL: {
                struct if_quotactl *qctl;
 
index c99b741..a5acc98 100644 (file)
@@ -247,7 +247,7 @@ int ll_md_real_close(struct inode *inode, fmode_t fmode)
                return 0;
        }
 
-       och=*och_p;
+       och = *och_p;
        *och_p = NULL;
        mutex_unlock(&lli->lli_och_mutex);
 
@@ -297,7 +297,8 @@ static int ll_md_close(struct obd_export *md_exp, struct inode *inode,
                __u64 flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_TEST_LOCK;
                struct lustre_handle lockh;
                struct inode *inode = file->f_dentry->d_inode;
-               ldlm_policy_data_t policy = {.l_inodebits={MDS_INODELOCK_OPEN}};
+               ldlm_policy_data_t policy = {
+                .l_inodebits = {MDS_INODELOCK_OPEN} };
 
                mutex_lock(&lli->lli_och_mutex);
                if (fd->fd_omode & FMODE_WRITE) {
@@ -368,7 +369,7 @@ int ll_file_release(struct inode *inode, struct file *file)
        fd = LUSTRE_FPRIVATE(file);
        LASSERT(fd != NULL);
 
-       /* The last ref on @file, maybe not the the owner pid of statahead.
+       /* The last ref on @file, maybe not the owner pid of statahead.
         * Different processes can open the same dir, "ll_opendir_key" means:
         * it is me that should stop the statahead thread. */
        if (S_ISDIR(inode->i_mode) && lli->lli_opendir_key == fd &&
@@ -2866,7 +2867,7 @@ ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits,
                            struct lustre_handle *lockh, __u64 flags,
                            ldlm_mode_t mode)
 {
-       ldlm_policy_data_t policy = { .l_inodebits = {bits}};
+       ldlm_policy_data_t policy = { .l_inodebits = {bits} };
        struct lu_fid *fid;
        ldlm_mode_t rc;
 
index 36aa0fd..2845aab 100644 (file)
@@ -1509,24 +1509,6 @@ static inline void d_lustre_revalidate(struct dentry *dentry)
        spin_unlock(&dentry->d_lock);
 }
 
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0)
-/* Compatibility for old (1.8) compiled userspace quota code */
-struct if_quotactl_18 {
-       __u32              qc_cmd;
-       __u32              qc_type;
-       __u32              qc_id;
-       __u32              qc_stat;
-       struct obd_dqinfo       qc_dqinfo;
-       struct obd_dqblk        qc_dqblk;
-       char                obd_type[16];
-       struct obd_uuid  obd_uuid;
-};
-#define LL_IOC_QUOTACTL_18           _IOWR('f', 162, struct if_quotactl_18 *)
-/* End compatibility for old (1.8) compiled userspace quota code */
-#else
-#warning "remove old LL_IOC_QUOTACTL_18 compatibility code"
-#endif /* LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0) */
-
 enum {
        LL_LAYOUT_GEN_NONE  = ((__u32)-2),      /* layout lock was cancelled */
        LL_LAYOUT_GEN_EMPTY = ((__u32)-1)       /* for empty layout */
index a8bcc51..afb433a 100644 (file)
@@ -250,7 +250,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
 
        data->ocd_brw_size = MD_MAX_BRW_SIZE;
 
-       err = obd_connect(NULL, &sbi->ll_md_exp, obd, &sbi->ll_sb_uuid, data, NULL);
+       err = obd_connect(NULL, &sbi->ll_md_exp, obd, &sbi->ll_sb_uuid,
+                         data, NULL);
        if (err == -EBUSY) {
                LCONSOLE_ERROR_MSG(0x14f, "An MDT (md %s) is performing "
                                   "recovery, of which this client is not a "
@@ -712,6 +713,7 @@ void lustre_dump_dentry(struct dentry *dentry, int recur)
 
        list_for_each(tmp, &dentry->d_subdirs) {
                struct dentry *d = list_entry(tmp, struct dentry, d_u.d_child);
+
                lustre_dump_dentry(d, recur - 1);
        }
 }
@@ -756,9 +758,9 @@ void ll_kill_super(struct super_block *sb)
                return;
 
        sbi = ll_s2sbi(sb);
-       /* we need to restore s_dev from changed for clustered NFS before put_super
-        * because new kernels have cached s_dev and change sb->s_dev in
-        * put_super not affected real removing devices */
+       /* we need to restore s_dev from changed for clustered NFS before
+        * put_super because new kernels have cached s_dev and change sb->s_dev
+        * in put_super not affected real removing devices */
        if (sbi) {
                sb->s_dev = sbi->ll_sdev_orig;
                sbi->ll_umounting = 1;
@@ -816,25 +818,6 @@ static int ll_options(char *options, int *flags)
                        *flags &= ~tmp;
                        goto next;
                }
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 5, 50, 0)
-               tmp = ll_set_opt("acl", s1, LL_SBI_ACL);
-               if (tmp) {
-                       /* Ignore deprecated mount option.  The client will
-                        * always try to mount with ACL support, whether this
-                        * is used depends on whether server supports it. */
-                       LCONSOLE_ERROR_MSG(0x152, "Ignoring deprecated "
-                                                 "mount option 'acl'.\n");
-                       goto next;
-               }
-               tmp = ll_set_opt("noacl", s1, LL_SBI_ACL);
-               if (tmp) {
-                       LCONSOLE_ERROR_MSG(0x152, "Ignoring deprecated "
-                                                 "mount option 'noacl'.\n");
-                       goto next;
-               }
-#else
-#warning "{no}acl options have been deprecated since 1.8, please remove them"
-#endif
                tmp = ll_set_opt("remote_client", s1, LL_SBI_RMT_CLIENT);
                if (tmp) {
                        *flags |= tmp;
@@ -1121,9 +1104,8 @@ void ll_put_super(struct super_block *sb)
        }
 
        next = 0;
-       while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) !=NULL) {
+       while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)))
                class_manual_cleanup(obd);
-       }
 
        if (sbi->ll_flags & LL_SBI_VERBOSE)
                LCONSOLE_WARN("Unmounted %s\n", profilenm ? profilenm : "");
@@ -1152,6 +1134,7 @@ struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock)
        lock_res_and_lock(lock);
        if (lock->l_resource->lr_lvb_inode) {
                struct ll_inode_info *lli;
+
                lli = ll_i2info(lock->l_resource->lr_lvb_inode);
                if (lli->lli_inode_magic == LLI_INODE_MAGIC) {
                        inode = igrab(lock->l_resource->lr_lvb_inode);
@@ -1732,11 +1715,11 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
        if (body->valid & OBD_MD_FLTYPE)
                inode->i_mode = (inode->i_mode & ~S_IFMT)|(body->mode & S_IFMT);
        LASSERT(inode->i_mode != 0);
-       if (S_ISREG(inode->i_mode)) {
-               inode->i_blkbits = min(PTLRPC_MAX_BRW_BITS + 1, LL_MAX_BLKSIZE_BITS);
-       } else {
+       if (S_ISREG(inode->i_mode))
+               inode->i_blkbits = min(PTLRPC_MAX_BRW_BITS + 1,
+                                      LL_MAX_BLKSIZE_BITS);
+       else
                inode->i_blkbits = inode->i_sb->s_blocksize_bits;
-       }
        if (body->valid & OBD_MD_FLUID)
                inode->i_uid = make_kuid(&init_user_ns, body->uid);
        if (body->valid & OBD_MD_FLGID)
@@ -1850,6 +1833,7 @@ void ll_read_inode2(struct inode *inode, void *opaque)
 
        if (S_ISREG(inode->i_mode)) {
                struct ll_sb_info *sbi = ll_i2sbi(inode);
+
                inode->i_op = &ll_file_inode_operations;
                inode->i_fop = sbi->ll_fop;
                inode->i_mapping->a_ops = (struct address_space_operations *)&ll_aops;
@@ -1880,8 +1864,8 @@ void ll_delete_inode(struct inode *inode)
 
        /* Workaround for LU-118 */
        if (inode->i_data.nrpages) {
-               TREE_READ_LOCK_IRQ(&inode->i_data);
-               TREE_READ_UNLOCK_IRQ(&inode->i_data);
+               spin_lock_irq(&inode->i_data.tree_lock);
+               spin_unlock_irq(&inode->i_data.tree_lock);
                LASSERTF(inode->i_data.nrpages == 0,
                         "inode=%lu/%u(%p) nrpages=%lu, see "
                         "http://jira.whamcloud.com/browse/LU-118\n",
@@ -2166,7 +2150,13 @@ int ll_obd_statfs(struct inode *inode, void *arg)
        __u32 flags;
        int len = 0, rc;
 
-       if (!inode || !(sbi = ll_i2sbi(inode))) {
+       if (!inode) {
+               rc = -EINVAL;
+               goto out_statfs;
+       }
+
+       sbi = ll_i2sbi(inode);
+       if (!sbi) {
                rc = -EINVAL;
                goto out_statfs;
        }
@@ -2398,7 +2388,7 @@ char *ll_get_fsname(struct super_block *sb, char *buf, int buflen)
        return buf;
 }
 
-static charll_d_path(struct dentry *dentry, char *buf, int bufsize)
+static char *ll_d_path(struct dentry *dentry, char *buf, int bufsize)
 {
        char *path = NULL;
 
index 264e5ec..e0f39fe 100644 (file)
@@ -793,11 +793,11 @@ static int __init lloop_init(void)
        if (ll_iocontrol_magic == NULL)
                goto out_mem1;
 
-       loop_dev = kzalloc(max_loop * sizeof(*loop_dev), GFP_KERNEL);
+       loop_dev = kcalloc(max_loop, sizeof(*loop_dev), GFP_KERNEL);
        if (!loop_dev)
                goto out_mem1;
 
-       disks = kzalloc(max_loop * sizeof(*disks), GFP_KERNEL);
+       disks = kcalloc(max_loop, sizeof(*disks), GFP_KERNEL);
        if (!disks)
                goto out_mem2;
 
index 3b3df9f..4dc1bfa 100644 (file)
@@ -227,8 +227,9 @@ static int ll_max_readahead_mb_seq_show(struct seq_file *m, void *v)
        return lprocfs_seq_read_frac_helper(m, pages_number, mult);
 }
 
-static ssize_t ll_max_readahead_mb_seq_write(struct file *file, const char *buffer,
-                                        size_t count, loff_t *off)
+static ssize_t ll_max_readahead_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);
@@ -269,7 +270,7 @@ static int ll_max_readahead_per_file_mb_seq_show(struct seq_file *m, void *v)
 }
 
 static ssize_t ll_max_readahead_per_file_mb_seq_write(struct file *file,
-                                                 const char *buffer,
+                                                 const char __user *buffer,
                                                  size_t count, loff_t *off)
 {
        struct super_block *sb = ((struct seq_file *)file->private_data)->private;
@@ -313,7 +314,7 @@ static int ll_max_read_ahead_whole_mb_seq_show(struct seq_file *m, void *unused)
 }
 
 static ssize_t ll_max_read_ahead_whole_mb_seq_write(struct file *file,
-                                               const char *buffer,
+                                               const char __user *buffer,
                                                size_t count, loff_t *off)
 {
        struct super_block *sb = ((struct seq_file *)file->private_data)->private;
@@ -469,8 +470,9 @@ static int ll_checksum_seq_show(struct seq_file *m, void *v)
        return seq_printf(m, "%u\n", (sbi->ll_flags & LL_SBI_CHECKSUM) ? 1 : 0);
 }
 
-static ssize_t ll_checksum_seq_write(struct file *file, const char *buffer,
-                                size_t count, loff_t *off)
+static ssize_t ll_checksum_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);
@@ -504,8 +506,9 @@ static int ll_max_rw_chunk_seq_show(struct seq_file *m, void *v)
        return seq_printf(m, "%lu\n", ll_s2sbi(sb)->ll_max_rw_chunk);
 }
 
-static ssize_t ll_max_rw_chunk_seq_write(struct file *file, const char *buffer,
-                                    size_t count, loff_t *off)
+static ssize_t ll_max_rw_chunk_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;
        int rc, val;
@@ -533,8 +536,8 @@ static int ll_rd_track_id(struct seq_file *m, enum stats_track_type type)
        }
 }
 
-static int ll_wr_track_id(const char *buffer, unsigned long count, void *data,
-                         enum stats_track_type type)
+static int ll_wr_track_id(const char __user *buffer, unsigned long count,
+                         void *data, enum stats_track_type type)
 {
        struct super_block *sb = data;
        int rc, pid;
@@ -556,8 +559,9 @@ static int ll_track_pid_seq_show(struct seq_file *m, void *v)
        return ll_rd_track_id(m, STATS_TRACK_PID);
 }
 
-static ssize_t ll_track_pid_seq_write(struct file *file, const char *buffer,
-                                 size_t count, loff_t *off)
+static ssize_t ll_track_pid_seq_write(struct file *file,
+                                     const char __user *buffer,
+                                     size_t count, loff_t *off)
 {
        struct seq_file *seq = file->private_data;
        return ll_wr_track_id(buffer, count, seq->private, STATS_TRACK_PID);
@@ -569,8 +573,9 @@ static int ll_track_ppid_seq_show(struct seq_file *m, void *v)
        return ll_rd_track_id(m, STATS_TRACK_PPID);
 }
 
-static ssize_t ll_track_ppid_seq_write(struct file *file, const char *buffer,
-                                  size_t count, loff_t *off)
+static ssize_t ll_track_ppid_seq_write(struct file *file,
+                                      const char __user *buffer,
+                                      size_t count, loff_t *off)
 {
        struct seq_file *seq = file->private_data;
        return ll_wr_track_id(buffer, count, seq->private, STATS_TRACK_PPID);
@@ -582,8 +587,9 @@ static int ll_track_gid_seq_show(struct seq_file *m, void *v)
        return ll_rd_track_id(m, STATS_TRACK_GID);
 }
 
-static ssize_t ll_track_gid_seq_write(struct file *file, const char *buffer,
-                                 size_t count, loff_t *off)
+static ssize_t ll_track_gid_seq_write(struct file *file,
+                                     const char __user *buffer,
+                                     size_t count, loff_t *off)
 {
        struct seq_file *seq = file->private_data;
        return ll_wr_track_id(buffer, count, seq->private, STATS_TRACK_GID);
@@ -598,8 +604,9 @@ static int ll_statahead_max_seq_show(struct seq_file *m, void *v)
        return seq_printf(m, "%u\n", sbi->ll_sa_max);
 }
 
-static ssize_t ll_statahead_max_seq_write(struct file *file, const char *buffer,
-                                     size_t count, loff_t *off)
+static ssize_t ll_statahead_max_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);
@@ -628,8 +635,9 @@ static int ll_statahead_agl_seq_show(struct seq_file *m, void *v)
                        sbi->ll_flags & LL_SBI_AGL_ENABLED ? 1 : 0);
 }
 
-static ssize_t ll_statahead_agl_seq_write(struct file *file, const char *buffer,
-                                     size_t count, loff_t *off)
+static ssize_t ll_statahead_agl_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);
@@ -672,8 +680,9 @@ static int ll_lazystatfs_seq_show(struct seq_file *m, void *v)
                        (sbi->ll_flags & LL_SBI_LAZYSTATFS) ? 1 : 0);
 }
 
-static ssize_t ll_lazystatfs_seq_write(struct file *file, const char *buffer,
-                                  size_t count, loff_t *off)
+static ssize_t ll_lazystatfs_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);
@@ -787,7 +796,8 @@ static int ll_xattr_cache_seq_show(struct seq_file *m, void *v)
        return rc;
 }
 
-static ssize_t ll_xattr_cache_seq_write(struct file *file, const char *buffer,
+static ssize_t ll_xattr_cache_seq_write(struct file *file,
+                                       const char __user *buffer,
                                        size_t count, loff_t *off)
 {
        struct seq_file *seq = file->private_data;
@@ -813,7 +823,7 @@ LPROC_SEQ_FOPS(ll_xattr_cache);
 
 static struct lprocfs_vars lprocfs_llite_obd_vars[] = {
        { "uuid",         &ll_sb_uuid_fops,       NULL, 0 },
-       //{ "mntpt_path",   ll_rd_path,      0, 0 },
+       /* { "mntpt_path",   ll_rd_path,             0, 0 }, */
        { "fstype",       &ll_fstype_fops,        NULL, 0 },
        { "site",         &ll_site_stats_fops,    NULL, 0 },
        { "blocksize",    &ll_blksize_fops,       NULL, 0 },
@@ -823,7 +833,7 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = {
        { "filestotal",   &ll_filestotal_fops,    NULL, 0 },
        { "filesfree",    &ll_filesfree_fops,     NULL, 0 },
        { "client_type",  &ll_client_type_fops,   NULL, 0 },
-       //{ "filegroups",   lprocfs_rd_filegroups,  0, 0 },
+       /* { "filegroups",   lprocfs_rd_filegroups,  0, 0 }, */
        { "max_read_ahead_mb", &ll_max_readahead_mb_fops, NULL },
        { "max_read_ahead_per_file_mb", &ll_max_readahead_per_file_mb_fops,
                NULL },
index 7a68c1e..2971a26 100644 (file)
@@ -948,7 +948,7 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name,
 
 /* Try to find the child dentry by its name.
    If found, put the result fid into @fid. */
-static void ll_get_child_fid(struct inode * dir, struct qstr *name,
+static void ll_get_child_fid(struct inode *dir, struct qstr *name,
                             struct lu_fid *fid)
 {
        struct dentry *parent, *child;
@@ -1190,7 +1190,7 @@ static int ll_mknod(struct inode *dir, struct dentry *dchild, ll_umode_t mode,
                                old_encode_dev(rdev), dchild);
 }
 
-static int ll_unlink(struct inode * dir, struct dentry *dentry)
+static int ll_unlink(struct inode *dir, struct dentry *dentry)
 {
        return ll_unlink_generic(dir, NULL, dentry, &dentry->d_name);
 }
index 1f53b98..613d772 100644 (file)
@@ -145,7 +145,7 @@ static struct ll_cl_context *ll_cl_init(struct file *file,
                 */
                io->ci_lockreq = CILR_NEVER;
 
-               pos = (vmpage->index << PAGE_CACHE_SHIFT);
+               pos = vmpage->index << PAGE_CACHE_SHIFT;
 
                /* Create a temp IO to serve write. */
                result = cl_io_rw_init(env, io, CIT_WRITE, pos, PAGE_CACHE_SIZE);
index 4c77ae8..2f21304 100644 (file)
@@ -183,7 +183,7 @@ static int ll_set_page_dirty(struct page *vmpage)
        return __set_page_dirty_nobuffers(vmpage);
 }
 
-#define MAX_DIRECTIO_SIZE 2*1024*1024*1024UL
+#define MAX_DIRECTIO_SIZE (2*1024*1024*1024UL)
 
 static inline int ll_get_user_pages(int rw, unsigned long user_addr,
                                    size_t size, struct page ***pages,
@@ -417,7 +417,7 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb,
 
                result = iov_iter_get_pages_alloc(iter, &pages, count, &offs);
                if (likely(result > 0)) {
-                       int n = (result + offs + PAGE_SIZE - 1) / PAGE_SIZE;
+                       int n = DIV_ROUND_UP(result + offs, PAGE_SIZE);
                        result = ll_direct_IO_26_seg(env, io, rw, inode,
                                                     file->f_mapping,
                                                     result, file_offset,
@@ -535,7 +535,7 @@ const struct address_space_operations ll_aops = {
 #else
 const struct address_space_operations_ext ll_aops = {
        .orig_aops.readpage       = ll_readpage,
-//     .orig_aops.readpages      = ll_readpages,
+/*     .orig_aops.readpages      = ll_readpages, */
        .orig_aops.direct_IO      = ll_direct_IO_26,
        .orig_aops.writepage      = ll_writepage,
        .orig_aops.writepages     = ll_writepages,
index 06b71bc..85d451f 100644 (file)
@@ -915,7 +915,7 @@ static int do_sa_revalidate(struct inode *dir, struct ll_sa_entry *entry,
        return rc;
 }
 
-static void ll_statahead_one(struct dentry *parent, const charentry_name,
+static void ll_statahead_one(struct dentry *parent, const char *entry_name,
                             int entry_name_len)
 {
        struct inode         *dir    = parent->d_inode;
index e61dbed..6aff155 100644 (file)
@@ -162,7 +162,7 @@ static int __init init_lustre_lite(void)
 
        /* Nodes with small feet have little entropy
         * the NID for this node gives the most entropy in the low bits */
-       for (i=0; ; i++) {
+       for (i = 0; ; i++) {
                if (LNetGetId(i, &lnet_id) == -ENOENT) {
                        break;
                }
index d3f967a..168aafb 100644 (file)
@@ -709,7 +709,7 @@ static int vvp_io_fault_start(const struct lu_env *env,
        }
 
 
-       if (fio->ft_mkwrite ) {
+       if (fio->ft_mkwrite) {
                pgoff_t last_index;
                /*
                 * Capture the size while holding the lli_trunc_sem from above
index 252a619..3ad9796 100644 (file)
@@ -234,6 +234,9 @@ int ll_setxattr(struct dentry *dentry, const char *name,
                struct lov_user_md *lump = (struct lov_user_md *)value;
                int rc = 0;
 
+               if (size != 0 && size < sizeof(struct lov_user_md))
+                       return -EINVAL;
+
                /* Attributes that are saved via getxattr will always have
                 * the stripe_offset as 0.  Instead, the MDS should be
                 * allowed to pick the starting OST index.   b=17846 */
index 627cbe2..e2badf1 100644 (file)
@@ -126,9 +126,7 @@ static int ll_xattr_cache_add(struct list_head *cache,
                return -ENOMEM;
        }
 
-       xattr->xe_namelen = strlen(xattr_name) + 1;
-
-       xattr->xe_name = kzalloc(xattr->xe_namelen, GFP_NOFS);
+       xattr->xe_name = kstrdup(xattr_name, GFP_NOFS);
        if (!xattr->xe_name) {
                CDEBUG(D_CACHE, "failed to alloc xattr name %u\n",
                       xattr->xe_namelen);
@@ -141,7 +139,6 @@ static int ll_xattr_cache_add(struct list_head *cache,
                goto err_value;
        }
 
-       memcpy(xattr->xe_name, xattr_name, xattr->xe_namelen);
        memcpy(xattr->xe_value, xattr_val, xattr_val_len);
        xattr->xe_vallen = xattr_val_len;
        list_add(&xattr->xe_list, cache);
index 1a58212..9543c15 100644 (file)
@@ -2310,7 +2310,6 @@ retry:
 static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
 {
        struct lmv_obd *lmv = &obd->u.lmv;
-       int rc = 0;
 
        switch (stage) {
        case OBD_CLEANUP_EARLY:
@@ -2324,7 +2323,7 @@ static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
        default:
                break;
        }
-       return rc;
+       return 0;
 }
 
 static int lmv_get_info(const struct lu_env *env, struct obd_export *exp,
index 94dfd64..71ad166 100644 (file)
@@ -847,7 +847,6 @@ out:
 
 static int lov_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
 {
-       int rc = 0;
        struct lov_obd *lov = &obd->u.lov;
 
        switch (stage) {
@@ -865,7 +864,7 @@ static int lov_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
                break;
        }
 
-       return rc;
+       return 0;
 }
 
 static int lov_cleanup(struct obd_device *obd)
index 5edd6a3..5356d53 100644 (file)
@@ -438,8 +438,7 @@ int lov_getstripe(struct obd_export *exp, struct lov_stripe_md *lsm,
        if (copy_from_user(&lum, lump, lum_size)) {
                rc = -EFAULT;
                goto out_set;
-       }
-       else if ((lum.lmm_magic != LOV_USER_MAGIC) &&
+       } else if ((lum.lmm_magic != LOV_USER_MAGIC) &&
                 (lum.lmm_magic != LOV_USER_MAGIC_V3)) {
                rc = -EINVAL;
                goto out_set;
index bc263ad..bbef5c9 100644 (file)
@@ -510,8 +510,6 @@ static void do_requeue(struct config_llog_data *cld)
 
 static int mgc_requeue_thread(void *data)
 {
-       int rc = 0;
-
        CDEBUG(D_MGC, "Starting requeue thread\n");
 
        /* Keep trying failed locks periodically */
@@ -592,7 +590,7 @@ static int mgc_requeue_thread(void *data)
        complete(&rq_exit);
 
        CDEBUG(D_MGC, "Ending requeue thread\n");
-       return rc;
+       return 0;
 }
 
 /* Add a cld to the list to requeue.  Start the requeue thread if needed.
@@ -1055,8 +1053,6 @@ static int mgc_import_event(struct obd_device *obd,
                            struct obd_import *imp,
                            enum obd_import_event event)
 {
-       int rc = 0;
-
        LASSERT(imp->imp_obd == obd);
        CDEBUG(D_MGC, "import event %#x\n", event);
 
@@ -1090,7 +1086,7 @@ static int mgc_import_event(struct obd_device *obd,
                CERROR("Unknown import event %#x\n", event);
                LBUG();
        }
-       return rc;
+       return 0;
 }
 
 enum {
index 2619bfe..9a69f6b 100644 (file)
@@ -171,17 +171,17 @@ EXPORT_SYMBOL(lustre_posix_acl_xattr_2ext);
 /*
  * Filter out the "nobody" entries in the posix ACL.
  */
-int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, int size,
+int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size,
                                  posix_acl_xattr_header **out)
 {
        int count, i, j, rc = 0;
        __u32 id;
        posix_acl_xattr_header *new;
 
-       if (unlikely(size < 0))
-               return -EINVAL;
-       else if (!size)
+       if (!size)
                return 0;
+       if (size < sizeof(*new))
+               return -EINVAL;
 
        OBD_ALLOC(new, size);
        if (unlikely(new == NULL))
index cd1abce..8d80ea4 100644 (file)
@@ -302,7 +302,7 @@ int capa_encrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen)
 
        /* passing "aes" in a variable instead of a constant string keeps gcc
         * 4.3.2 happy */
-       tfm = crypto_alloc_blkcipher(alg, 0, 0 );
+       tfm = crypto_alloc_blkcipher(alg, 0, 0);
        if (IS_ERR(tfm)) {
                CERROR("failed to load transform for aes\n");
                return PTR_ERR(tfm);
@@ -355,7 +355,7 @@ int capa_decrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen)
 
        /* passing "aes" in a variable instead of a constant string keeps gcc
         * 4.3.2 happy */
-       tfm = crypto_alloc_blkcipher(alg, 0, 0 );
+       tfm = crypto_alloc_blkcipher(alg, 0, 0);
        if (IS_ERR(tfm)) {
                CERROR("failed to load transform for aes\n");
                return PTR_ERR(tfm);
@@ -407,7 +407,7 @@ EXPORT_SYMBOL(capa_cpy);
 
 void _debug_capa(struct lustre_capa *c,
                 struct libcfs_debug_msg_data *msgdata,
-                const char *fmt, ... )
+                const char *fmt, ...)
 {
        va_list args;
        va_start(args, fmt);
index 52256c2..e7be26e 100644 (file)
@@ -332,8 +332,7 @@ static struct dt_object *dt_reg_open(const struct lu_env *env,
        result = dt_lookup_dir(env, p, name, fid);
        if (result == 0){
                o = dt_locate(env, dt, fid);
-       }
-       else
+       } else
                o = ERR_PTR(result);
 
        return o;
@@ -950,8 +949,8 @@ int lprocfs_dt_rd_blksize(char *page, char **start, off_t off,
 {
        struct dt_device *dt = data;
        struct obd_statfs osfs;
-
        int rc = dt_statfs(NULL, dt, &osfs);
+
        if (rc == 0) {
                *eof = 1;
                rc = snprintf(page, count, "%u\n",
@@ -967,8 +966,8 @@ int lprocfs_dt_rd_kbytestotal(char *page, char **start, off_t off,
 {
        struct dt_device *dt = data;
        struct obd_statfs osfs;
-
        int rc = dt_statfs(NULL, dt, &osfs);
+
        if (rc == 0) {
                __u32 blk_size = osfs.os_bsize >> 10;
                __u64 result = osfs.os_blocks;
@@ -989,8 +988,8 @@ int lprocfs_dt_rd_kbytesfree(char *page, char **start, off_t off,
 {
        struct dt_device *dt = data;
        struct obd_statfs osfs;
-
        int rc = dt_statfs(NULL, dt, &osfs);
+
        if (rc == 0) {
                __u32 blk_size = osfs.os_bsize >> 10;
                __u64 result = osfs.os_bfree;
@@ -1011,8 +1010,8 @@ int lprocfs_dt_rd_kbytesavail(char *page, char **start, off_t off,
 {
        struct dt_device *dt = data;
        struct obd_statfs osfs;
-
        int rc = dt_statfs(NULL, dt, &osfs);
+
        if (rc == 0) {
                __u32 blk_size = osfs.os_bsize >> 10;
                __u64 result = osfs.os_bavail;
@@ -1033,8 +1032,8 @@ int lprocfs_dt_rd_filestotal(char *page, char **start, off_t off,
 {
        struct dt_device *dt = data;
        struct obd_statfs osfs;
-
        int rc = dt_statfs(NULL, dt, &osfs);
+
        if (rc == 0) {
                *eof = 1;
                rc = snprintf(page, count, "%llu\n", osfs.os_files);
@@ -1049,8 +1048,8 @@ int lprocfs_dt_rd_filesfree(char *page, char **start, off_t off,
 {
        struct dt_device *dt = data;
        struct obd_statfs osfs;
-
        int rc = dt_statfs(NULL, dt, &osfs);
+
        if (rc == 0) {
                *eof = 1;
                rc = snprintf(page, count, "%llu\n", osfs.os_ffree);
index c314e9c..ac8db2f 100644 (file)
@@ -317,7 +317,7 @@ struct obd_device *class_newdev(const char *type_name, const char *name)
                                         result->obd_minor, new_obd_minor);
 
                                obd_devs[result->obd_minor] = NULL;
-                               result->obd_name[0]='\0';
+                               result->obd_name[0] = '\0';
                         }
                        result = ERR_PTR(-EEXIST);
                        break;
@@ -524,8 +524,8 @@ void class_obd_list(void)
 /* Search for a client OBD connected to tgt_uuid.  If grp_uuid is
    specified, then only the client with that uuid is returned,
    otherwise any client connected to the tgt is returned. */
-struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid,
-                                         const char * typ_name,
+struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid,
+                                         const char *typ_name,
                                          struct obd_uuid *grp_uuid)
 {
        int i;
@@ -557,7 +557,7 @@ EXPORT_SYMBOL(class_find_client_obd);
    searching at *next, and if a device is found, the next index to look
    at is saved in *next. If next is NULL, then the first matching device
    will always be returned. */
-struct obd_device * class_devices_in_group(struct obd_uuid *grp_uuid, int *next)
+struct obd_device *class_devices_in_group(struct obd_uuid *grp_uuid, int *next)
 {
        int i;
 
@@ -1783,7 +1783,7 @@ EXPORT_SYMBOL(kuc_len);
  * @param p Pointer to payload area
  * @returns Pointer to kuc header
  */
-struct kuc_hdr * kuc_ptr(void *p)
+struct kuc_hdr *kuc_ptr(void *p)
 {
        struct kuc_hdr *lh = ((struct kuc_hdr *)p) - 1;
        LASSERT(lh->kuc_magic == KUC_MAGIC);
index 7eaaaa6..66ceab2 100644 (file)
@@ -166,14 +166,14 @@ int obd_ioctl_popdata(void *arg, void *data, int len)
 EXPORT_SYMBOL(obd_ioctl_popdata);
 
 /*  opening /dev/obd */
-static int obd_class_open(struct inode * inode, struct file * file)
+static int obd_class_open(struct inode *inode, struct file *file)
 {
        try_module_get(THIS_MODULE);
        return 0;
 }
 
 /*  closing /dev/obd */
-static int obd_class_release(struct inode * inode, struct file * file)
+static int obd_class_release(struct inode *inode, struct file *file)
 {
        module_put(THIS_MODULE);
        return 0;
index da769db..978d886 100644 (file)
@@ -42,7 +42,7 @@
 #include "llog_internal.h"
 
 /* helper functions for calling the llog obd methods */
-static struct llog_ctxtllog_new_ctxt(struct obd_device *obd)
+static struct llog_ctxt *llog_new_ctxt(struct obd_device *obd)
 {
        struct llog_ctxt *ctxt;
 
index 61e04af..686bc18 100644 (file)
@@ -177,7 +177,7 @@ int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val,
 }
 EXPORT_SYMBOL(lprocfs_read_frac_helper);
 
-int lprocfs_write_frac_helper(const char *buffer, unsigned long count,
+int lprocfs_write_frac_helper(const char __user *buffer, unsigned long count,
                              int *val, int mult)
 {
        char kernbuf[20], *end, *pbuf;
@@ -1819,7 +1819,7 @@ __s64 lprocfs_read_helper(struct lprocfs_counter *lc,
 }
 EXPORT_SYMBOL(lprocfs_read_helper);
 
-int lprocfs_write_helper(const char *buffer, unsigned long count,
+int lprocfs_write_helper(const char __user *buffer, unsigned long count,
                         int *val)
 {
        return lprocfs_write_frac_helper(buffer, count, val, 1);
index 5e7b3d7..47213a9 100644 (file)
@@ -835,7 +835,7 @@ int class_del_conn(struct obd_device *obd, struct lustre_cfg *lcfg)
 
 LIST_HEAD(lustre_profile_list);
 
-struct lustre_profile *class_get_profile(const char * prof)
+struct lustre_profile *class_get_profile(const char *prof)
 {
        struct lustre_profile *lprof;
 
index 98e4290..a6ad875 100644 (file)
@@ -698,14 +698,16 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env,
        int cleanup = 0;
 
        OBD_ALLOC_PTR(ed);
-       if (ed == NULL)
-               GOTO(out, rc = -ENOMEM);
+       if (ed == NULL) {
+               rc = -ENOMEM;
+               goto out;
+       }
 
        cleanup = 1;
        cd = &ed->ed_cl;
        rc = cl_device_init(cd, t);
        if (rc)
-               GOTO(out, rc);
+               goto out;
 
        cd->cd_lu_dev.ld_ops = &echo_device_lu_ops;
        cd->cd_ops = &echo_device_cl_ops;
@@ -719,24 +721,26 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env,
        if (tgt == NULL) {
                CERROR("Can not find tgt device %s\n",
                        lustre_cfg_string(cfg, 1));
-               GOTO(out, rc = -ENODEV);
+               rc = -ENODEV;
+               goto out;
        }
 
        next = tgt->obd_lu_dev;
        if (!strcmp(tgt->obd_type->typ_name, LUSTRE_MDT_NAME)) {
                CERROR("echo MDT client must be run on server\n");
-               GOTO(out, rc = -EOPNOTSUPP);
+               rc = -EOPNOTSUPP;
+               goto out;
        }
 
        rc = echo_site_init(env, ed);
        if (rc)
-               GOTO(out, rc);
+               goto out;
 
        cleanup = 3;
 
        rc = echo_client_setup(env, obd, cfg);
        if (rc)
-               GOTO(out, rc);
+               goto out;
 
        ed->ed_ec = &obd->u.echo_client;
        cleanup = 4;
@@ -749,15 +753,17 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env,
        tgt_type_name = tgt->obd_type->typ_name;
        if (next != NULL) {
                LASSERT(next != NULL);
-               if (next->ld_site != NULL)
-                       GOTO(out, rc = -EBUSY);
+               if (next->ld_site != NULL) {
+                       rc = -EBUSY;
+                       goto out;
+               }
 
                next->ld_site = &ed->ed_site->cs_lu;
                rc = next->ld_type->ldt_ops->ldto_device_init(env, next,
                                                next->ld_type->ldt_name,
                                                              NULL);
                if (rc)
-                       GOTO(out, rc);
+                       goto out;
 
                /* Tricky case, I have to determine the obd type since
                 * CLIO uses the different parameters to initialize
@@ -968,15 +974,19 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d,
 
        fid  = &info->eti_fid;
        rc = ostid_to_fid(fid, &lsm->lsm_oi, 0);
-       if (rc != 0)
-               GOTO(out, eco = ERR_PTR(rc));
+       if (rc != 0) {
+               eco = ERR_PTR(rc);
+               goto out;
+       }
 
        /* In the function below, .hs_keycmp resolves to
         * lu_obj_hop_keycmp() */
        /* coverity[overrun-buffer-val] */
        obj = cl_object_find(env, echo_dev2cl(d), fid, &conf->eoc_cl);
-       if (IS_ERR(obj))
-               GOTO(out, eco = (void *)obj);
+       if (IS_ERR(obj)) {
+               eco = (void *)obj;
+               goto out;
+       }
 
        eco = cl2echo_obj(obj);
        if (eco->eo_deleted) {
@@ -1076,7 +1086,7 @@ static int cl_echo_enqueue(struct echo_object *eco, u64 start, u64 end,
        io->ci_ignore_layout = 1;
        result = cl_io_init(env, io, CIT_MISC, echo_obj2cl(eco));
        if (result < 0)
-               GOTO(out, result);
+               goto out;
        LASSERT(result == 0);
 
        result = cl_echo_enqueue0(env, eco, start, end, mode, cookie, 0);
@@ -1182,7 +1192,7 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, u64 offset,
        io->ci_ignore_layout = 1;
        rc = cl_io_init(env, io, CIT_MISC, obj);
        if (rc < 0)
-               GOTO(out, rc);
+               goto out;
        LASSERT(rc == 0);
 
 
@@ -1191,7 +1201,7 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, u64 offset,
                              rw == READ ? LCK_PR : LCK_PW, &lh.cookie,
                              CEF_NEVER);
        if (rc < 0)
-               GOTO(error_lock, rc);
+               goto error_lock;
 
        for (i = 0; i < npages; i++) {
                LASSERT(pages[i]);
@@ -1318,7 +1328,7 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed,
        rc = echo_alloc_memmd(ed, &lsm);
        if (rc < 0) {
                CERROR("Cannot allocate md: rc = %d\n", rc);
-               GOTO(failed, rc);
+               goto failed;
        }
 
        if (ulsm != NULL) {
@@ -1326,7 +1336,7 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed,
 
                rc = echo_copyin_lsm (ed, lsm, ulsm, ulsm_nob);
                if (rc != 0)
-                       GOTO(failed, rc);
+                       goto failed;
 
                if (lsm->lsm_stripe_count == 0)
                        lsm->lsm_stripe_count = ec->ec_nstripes;
@@ -1363,7 +1373,7 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed,
                rc = obd_create(env, ec->ec_exp, oa, &lsm, oti);
                if (rc != 0) {
                        CERROR("Cannot create objects: rc = %d\n", rc);
-                       GOTO(failed, rc);
+                       goto failed;
                }
                created = 1;
        }
@@ -1373,8 +1383,10 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed,
        oa->o_valid |= OBD_MD_FLID;
 
        eco = cl_echo_object_find(ed, &lsm);
-       if (IS_ERR(eco))
-               GOTO(failed, rc = PTR_ERR(eco));
+       if (IS_ERR(eco)) {
+               rc = PTR_ERR(eco);
+               goto failed;
+       }
        cl_echo_object_put(eco);
 
        CDEBUG(D_INFO, "oa oid "DOSTID"\n", POSTID(&oa->o_oi));
@@ -1642,8 +1654,10 @@ static int echo_client_prep_commit(const struct lu_env *env,
        OBD_ALLOC(lnb, npages * sizeof(struct niobuf_local));
        OBD_ALLOC(rnb, npages * sizeof(struct niobuf_remote));
 
-       if (lnb == NULL || rnb == NULL)
-               GOTO(out, ret = -ENOMEM);
+       if (lnb == NULL || rnb == NULL) {
+               ret = -ENOMEM;
+               goto out;
+       }
 
        if (rw == OBD_BRW_WRITE && async)
                brw_flags |= OBD_BRW_ASYNC;
@@ -1671,7 +1685,7 @@ static int echo_client_prep_commit(const struct lu_env *env,
                ret = obd_preprw(env, rw, exp, oa, 1, &ioo, rnb, &lpages,
                                 lnb, oti, NULL);
                if (ret != 0)
-                       GOTO(out, ret);
+                       goto out;
                LASSERT(lpages == npages);
 
                for (i = 0; i < lpages; i++) {
@@ -1704,7 +1718,7 @@ static int echo_client_prep_commit(const struct lu_env *env,
                ret = obd_commitrw(env, rw, exp, oa, 1, &ioo,
                                   rnb, npages, lnb, oti, ret);
                if (ret != 0)
-                       GOTO(out, ret);
+                       goto out;
 
                /* Reset oti otherwise it would confuse ldiskfs. */
                memset(oti, 0, sizeof(*oti));
@@ -1862,21 +1876,27 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                return -ENOMEM;
 
        rc = lu_env_init(env, LCT_DT_THREAD);
-       if (rc)
-               GOTO(out, rc = -ENOMEM);
+       if (rc) {
+               rc = -ENOMEM;
+               goto out;
+       }
 
        switch (cmd) {
        case OBD_IOC_CREATE:                /* may create echo object */
-               if (!capable(CFS_CAP_SYS_ADMIN))
-                       GOTO (out, rc = -EPERM);
+               if (!capable(CFS_CAP_SYS_ADMIN)) {
+                       rc = -EPERM;
+                       goto out;
+               }
 
                rc = echo_create_object(env, ed, 1, oa, data->ioc_pbuf1,
                                        data->ioc_plen1, &dummy_oti);
-               GOTO(out, rc);
+               goto out;
 
        case OBD_IOC_DESTROY:
-               if (!capable(CFS_CAP_SYS_ADMIN))
-                       GOTO (out, rc = -EPERM);
+               if (!capable(CFS_CAP_SYS_ADMIN)) {
+                       rc = -EPERM;
+                       goto out;
+               }
 
                rc = echo_get_object(&eco, ed, oa);
                if (rc == 0) {
@@ -1886,7 +1906,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                                eco->eo_deleted = 1;
                        echo_put_object(eco);
                }
-               GOTO(out, rc);
+               goto out;
 
        case OBD_IOC_GETATTR:
                rc = echo_get_object(&eco, ed, oa);
@@ -1897,11 +1917,13 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                        rc = obd_getattr(env, ec->ec_exp, &oinfo);
                        echo_put_object(eco);
                }
-               GOTO(out, rc);
+               goto out;
 
        case OBD_IOC_SETATTR:
-               if (!capable(CFS_CAP_SYS_ADMIN))
-                       GOTO (out, rc = -EPERM);
+               if (!capable(CFS_CAP_SYS_ADMIN)) {
+                       rc = -EPERM;
+                       goto out;
+               }
 
                rc = echo_get_object(&eco, ed, oa);
                if (rc == 0) {
@@ -1912,17 +1934,19 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                        rc = obd_setattr(env, ec->ec_exp, &oinfo, NULL);
                        echo_put_object(eco);
                }
-               GOTO(out, rc);
+               goto out;
 
        case OBD_IOC_BRW_WRITE:
-               if (!capable(CFS_CAP_SYS_ADMIN))
-                       GOTO (out, rc = -EPERM);
+               if (!capable(CFS_CAP_SYS_ADMIN)) {
+                       rc = -EPERM;
+                       goto out;
+               }
 
                rw = OBD_BRW_WRITE;
                /* fall through */
        case OBD_IOC_BRW_READ:
                rc = echo_client_brw_ioctl(env, rw, exp, data, &dummy_oti);
-               GOTO(out, rc);
+               goto out;
 
        case ECHO_IOC_GET_STRIPE:
                rc = echo_get_object(&eco, ed, oa);
@@ -1931,11 +1955,13 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                                              data->ioc_plen1);
                        echo_put_object(eco);
                }
-               GOTO(out, rc);
+               goto out;
 
        case ECHO_IOC_SET_STRIPE:
-               if (!capable(CFS_CAP_SYS_ADMIN))
-                       GOTO (out, rc = -EPERM);
+               if (!capable(CFS_CAP_SYS_ADMIN)) {
+                       rc = -EPERM;
+                       goto out;
+               }
 
                if (data->ioc_pbuf1 == NULL) {  /* unset */
                        rc = echo_get_object(&eco, ed, oa);
@@ -1948,25 +1974,28 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                                                data->ioc_pbuf1,
                                                data->ioc_plen1, &dummy_oti);
                }
-               GOTO (out, rc);
+               goto out;
 
        case ECHO_IOC_ENQUEUE:
-               if (!capable(CFS_CAP_SYS_ADMIN))
-                       GOTO (out, rc = -EPERM);
+               if (!capable(CFS_CAP_SYS_ADMIN)) {
+                       rc = -EPERM;
+                       goto out;
+               }
 
                rc = echo_client_enqueue(exp, oa,
                                         data->ioc_conn1, /* lock mode */
                                         data->ioc_offset,
                                         data->ioc_count);/*extent*/
-               GOTO (out, rc);
+               goto out;
 
        case ECHO_IOC_CANCEL:
                rc = echo_client_cancel(exp, oa);
-               GOTO (out, rc);
+               goto out;
 
        default:
                CERROR ("echo_ioctl(): unrecognised ioctl %#x\n", cmd);
-               GOTO (out, rc = -ENOTTY);
+               rc = -ENOTTY;
+               goto out;
        }
 
 out:
@@ -2084,11 +2113,13 @@ static int echo_client_disconnect(struct obd_export *exp)
 {
        int                  rc;
 
-       if (exp == NULL)
-               GOTO(out, rc = -EINVAL);
+       if (exp == NULL) {
+               rc = -EINVAL;
+               goto out;
+       }
 
        rc = class_disconnect(exp);
-       GOTO(out, rc);
+       goto out;
  out:
        return rc;
 }
index 7734d66..ec04935 100644 (file)
@@ -536,10 +536,9 @@ static int osc_extent_merge(const struct lu_env *env, struct osc_extent *cur,
 /**
  * Drop user count of osc_extent, and unplug IO asynchronously.
  */
-int osc_extent_release(const struct lu_env *env, struct osc_extent *ext)
+void osc_extent_release(const struct lu_env *env, struct osc_extent *ext)
 {
        struct osc_object *obj = ext->oe_obj;
-       int rc = 0;
 
        LASSERT(atomic_read(&ext->oe_users) > 0);
        LASSERT(sanity_check(ext) == 0);
@@ -571,7 +570,6 @@ int osc_extent_release(const struct lu_env *env, struct osc_extent *ext)
                osc_io_unplug_async(env, osc_cli(obj), obj);
        }
        osc_extent_put(env, ext);
-       return rc;
 }
 
 static inline int overlapped(struct osc_extent *ex1, struct osc_extent *ex2)
index ebbd95c..365b278 100644 (file)
@@ -678,7 +678,7 @@ struct osc_extent {
 
 int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext,
                      int sent, int rc);
-int osc_extent_release(const struct lu_env *env, struct osc_extent *ext);
+void osc_extent_release(const struct lu_env *env, struct osc_extent *ext);
 
 /** @} osc */
 
index 44657a0..ca16c08 100644 (file)
@@ -3217,8 +3217,6 @@ out_ptlrpcd:
 
 static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
 {
-       int rc = 0;
-
        switch (stage) {
        case OBD_CLEANUP_EARLY: {
                struct obd_import *imp;
@@ -3253,7 +3251,7 @@ static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
                break;
                }
        }
-       return rc;
+       return 0;
 }
 
 int osc_cleanup(struct obd_device *obd)
index 5b83371..78364ec 100644 (file)
@@ -980,18 +980,7 @@ EXPORT_SYMBOL(RMF_CONN);
 struct req_msg_field RMF_CONNECT_DATA =
        DEFINE_MSGF("cdata",
                    RMF_F_NO_SIZE_CHECK /* we allow extra space for interop */,
-#if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(2, 7, 50, 0)
                    sizeof(struct obd_connect_data),
-#else
-/* For interoperability with 1.8 and 2.0 clients/servers.
- * The RPC verification code allows larger RPC buffers, but not
- * smaller buffers.  Until we no longer need to keep compatibility
- * with older servers/clients we can only check that the buffer
- * size is at least as large as obd_connect_data_v1.  That is not
- * not in itself harmful, since the chance of just corrupting this
- * field is low.  See JIRA LU-16 for details. */
-                   sizeof(struct obd_connect_data_v1),
-#endif
                    lustre_swab_connect, NULL);
 EXPORT_SYMBOL(RMF_CONNECT_DATA);
 
index 87b9764..0c3f667 100644 (file)
@@ -175,7 +175,7 @@ const char *ll_opcode2str(__u32 opcode)
        return ll_rpc_opcode_table[offset].opname;
 }
 
-const charll_eopcode2str(__u32 opcode)
+const char *ll_eopcode2str(__u32 opcode)
 {
        LASSERT(ll_eopcode_table[opcode].opcode == opcode);
        return ll_eopcode_table[opcode].opname;
@@ -694,8 +694,7 @@ default_queue:
        if (queue == PTLRPC_NRS_QUEUE_HP && !nrs_svc_has_hp(svc)) {
                rc = -ENODEV;
                goto out;
-       }
-       else if (queue == PTLRPC_NRS_QUEUE_BOTH && !nrs_svc_has_hp(svc))
+       } else if (queue == PTLRPC_NRS_QUEUE_BOTH && !nrs_svc_has_hp(svc))
                queue = PTLRPC_NRS_QUEUE_REG;
 
        /**
index 50556db..60552f4 100644 (file)
@@ -1313,43 +1313,17 @@ __u32 lustre_msg_get_cksum(struct lustre_msg *msg)
        }
 }
 
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0)
-/*
- * In 1.6 and 1.8 the checksum was computed only on struct ptlrpc_body as
- * it was in 1.6 (88 bytes, smaller than the full size in 1.8).  It makes
- * more sense to compute the checksum on the full ptlrpc_body, regardless
- * of what size it is, but in order to keep interoperability with 1.8 we
- * can optionally also checksum only the first 88 bytes (caller decides). */
-# define ptlrpc_body_cksum_size_compat18        88
-
-__u32 lustre_msg_calc_cksum(struct lustre_msg *msg, int compat18)
-#else
-# warning "remove checksum compatibility support for b1_8"
 __u32 lustre_msg_calc_cksum(struct lustre_msg *msg)
-#endif
 {
        switch (msg->lm_magic) {
        case LUSTRE_MSG_MAGIC_V2: {
                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0)
-               __u32 crc;
-               unsigned int hsize = 4;
-               __u32 len = compat18 ? ptlrpc_body_cksum_size_compat18 :
-                           lustre_msg_buflen(msg, MSG_PTLRPC_BODY_OFF);
-               LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
-               cfs_crypto_hash_digest(CFS_HASH_ALG_CRC32, (unsigned char *)pb,
-                                      len, NULL, 0, (unsigned char *)&crc,
-                                      &hsize);
-               return crc;
-#else
-# warning "remove checksum compatibility support for b1_8"
                __u32 crc;
                unsigned int hsize = 4;
                cfs_crypto_hash_digest(CFS_HASH_ALG_CRC32, (unsigned char *)pb,
                                   lustre_msg_buflen(msg, MSG_PTLRPC_BODY_OFF),
                                   NULL, 0, (unsigned char *)&crc, &hsize);
                return crc;
-#endif
        }
        default:
                CERROR("incorrect message magic: %08x\n", msg->lm_magic);
index 20341b2..b9cbbbd 100644 (file)
@@ -428,7 +428,7 @@ EXPORT_SYMBOL(ptlrpc_pinger_del_import);
  * Register a timeout callback to the pinger list, and the callback will
  * be called when timeout happens.
  */
-struct timeout_itemptlrpc_new_timeout(int time, enum timeout_event event,
+struct timeout_item *ptlrpc_new_timeout(int time, enum timeout_event event,
                                        timeout_cb_t cb, void *data)
 {
        struct timeout_item *ti;
@@ -448,7 +448,7 @@ struct timeout_item* ptlrpc_new_timeout(int time, enum timeout_event event,
 }
 
 /**
- * Register timeout event on the the pinger thread.
+ * Register timeout event on the pinger thread.
  * Note: the timeout list is an sorted list with increased timeout value.
  */
 static struct timeout_item*
index 4ce7685..6ac8a83 100644 (file)
@@ -209,7 +209,7 @@ EXPORT_SYMBOL(sptlrpc_flavor2name_bulk);
 
 char *sptlrpc_flavor2name(struct sptlrpc_flavor *sf, char *buf, int bufsize)
 {
-       snprintf(buf, bufsize, "%s", sptlrpc_flavor2name_base(sf->sf_rpc));
+       strlcpy(buf, sptlrpc_flavor2name_base(sf->sf_rpc), bufsize);
 
        /*
         * currently we don't support customized bulk specification for
@@ -220,10 +220,9 @@ char *sptlrpc_flavor2name(struct sptlrpc_flavor *sf, char *buf, int bufsize)
 
                bspec[0] = '-';
                sptlrpc_flavor2name_bulk(sf, &bspec[1], sizeof(bspec) - 1);
-               strncat(buf, bspec, bufsize);
+               strlcat(buf, bspec, bufsize);
        }
 
-       buf[bufsize - 1] = '\0';
        return buf;
 }
 EXPORT_SYMBOL(sptlrpc_flavor2name);
index 099cec3..4e13243 100644 (file)
@@ -101,16 +101,7 @@ int null_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req)
 
        if (req->rq_early) {
                cksums = lustre_msg_get_cksum(req->rq_repdata);
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0)
-               if (lustre_msghdr_get_flags(req->rq_reqmsg) &
-                   MSGHDR_CKSUM_INCOMPAT18)
-                       cksumc = lustre_msg_calc_cksum(req->rq_repmsg, 0);
-               else
-                       cksumc = lustre_msg_calc_cksum(req->rq_repmsg, 1);
-#else
-# warning "remove checksum compatibility support for b1_8"
                cksumc = lustre_msg_calc_cksum(req->rq_repmsg);
-#endif
                if (cksumc != cksums) {
                        CDEBUG(D_SEC,
                               "early reply checksum mismatch: %08x != %08x\n",
@@ -371,16 +362,7 @@ int null_authorize(struct ptlrpc_request *req)
        } else {
                __u32 cksum;
 
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0)
-               if (lustre_msghdr_get_flags(req->rq_reqmsg) &
-                   MSGHDR_CKSUM_INCOMPAT18)
-                       cksum = lustre_msg_calc_cksum(rs->rs_repbuf, 0);
-               else
-                       cksum = lustre_msg_calc_cksum(rs->rs_repbuf, 1);
-#else
-# warning "remove checksum compatibility support for b1_8"
                cksum = lustre_msg_calc_cksum(rs->rs_repbuf);
-#endif
                lustre_msg_set_cksum(rs->rs_repbuf, cksum);
                req->rq_reply_off = 0;
        }
index 73e7b2c..657ea48 100644 (file)
@@ -527,7 +527,7 @@ static int slot_reset(struct dvb_ca_en50221 *ca, int slot)
                u8 val;
 #endif
                for (i = 0; i < 100; i++) {
-                       msleep(10);
+                       usleep_range(10000, 11000);
 #if 0
                        read_reg(ci, 0x06, &val);
                        dev_info(&ci->i2c->dev, "%d:%02x\n", i, val);
index cf42046..d81b29e 100644 (file)
@@ -120,8 +120,8 @@ struct vpfe_ipipe_device {
        enum ipipe_input_entity input;
        unsigned int output;
        struct v4l2_ctrl_handler ctrls;
-       void *__iomem base_addr;
-       void *__iomem isp5_base_addr;
+       void __iomem *base_addr;
+       void __iomem *isp5_base_addr;
        struct ipipe_module_params config;
 };
 
index b2daf5e..e2cdbb1 100644 (file)
@@ -24,7 +24,7 @@
 #define IPIPE_MODE_CONTINUOUS          0
 #define IPIPE_MODE_SINGLE_SHOT         1
 
-static void ipipe_clock_enable(void *__iomem base_addr)
+static void ipipe_clock_enable(void __iomem *base_addr)
 {
        /* enable IPIPE MMR for register write access */
        regw_ip(base_addr, IPIPE_GCK_MMR_DEFAULT, IPIPE_GCK_MMR);
@@ -34,7 +34,7 @@ static void ipipe_clock_enable(void *__iomem base_addr)
 }
 
 static void
-rsz_set_common_params(void *__iomem rsz_base, struct resizer_params *params)
+rsz_set_common_params(void __iomem *rsz_base, struct resizer_params *params)
 {
        struct rsz_common_params *rsz_common = &params->rsz_common;
        u32 val;
@@ -66,7 +66,7 @@ rsz_set_common_params(void *__iomem rsz_base, struct resizer_params *params)
 }
 
 static void
-rsz_set_rsz_regs(void *__iomem rsz_base, unsigned int rsz_id,
+rsz_set_rsz_regs(void __iomem *rsz_base, unsigned int rsz_id,
                 struct resizer_params *params)
 {
        struct resizer_scale_param *rsc_params;
@@ -171,7 +171,7 @@ rsz_set_rsz_regs(void *__iomem rsz_base, unsigned int rsz_id,
 
 /*set the registers of either RSZ0 or RSZ1 */
 static void
-ipipe_setup_resizer(void *__iomem rsz_base, struct resizer_params *params)
+ipipe_setup_resizer(void __iomem *rsz_base, struct resizer_params *params)
 {
        /* enable MMR gate to write to Resizer */
        regw_rsz(rsz_base, 1, RSZ_GCK_MMR);
@@ -302,8 +302,8 @@ int config_rsz_hw(struct vpfe_resizer_device *resizer,
                  struct resizer_params *config)
 {
        struct vpfe_device *vpfe_dev = to_vpfe_device(resizer);
-       void *__iomem ipipe_base = vpfe_dev->vpfe_ipipe.base_addr;
-       void *__iomem rsz_base = vpfe_dev->vpfe_resizer.base_addr;
+       void __iomem *ipipe_base = vpfe_dev->vpfe_ipipe.base_addr;
+       void __iomem *rsz_base = vpfe_dev->vpfe_resizer.base_addr;
 
        /* enable VPSS clock */
        vpss_enable_clock(VPSS_IPIPE_CLOCK, 1);
@@ -315,7 +315,7 @@ int config_rsz_hw(struct vpfe_resizer_device *resizer,
 }
 
 static void
-rsz_set_y_address(void *__iomem rsz_base, unsigned int address,
+rsz_set_y_address(void __iomem *rsz_base, unsigned int address,
                  unsigned int offset)
 {
        u32 val;
@@ -330,7 +330,7 @@ rsz_set_y_address(void *__iomem rsz_base, unsigned int address,
 }
 
 static void
-rsz_set_c_address(void *__iomem rsz_base, unsigned int address,
+rsz_set_c_address(void __iomem *rsz_base, unsigned int address,
                  unsigned int offset)
 {
        u32 val;
@@ -352,7 +352,7 @@ rsz_set_c_address(void *__iomem rsz_base, unsigned int address,
  * @address: the address to set
  */
 int
-resizer_set_outaddr(void *__iomem rsz_base, struct resizer_params *params,
+resizer_set_outaddr(void __iomem *rsz_base, struct resizer_params *params,
                    int resize_no, unsigned int address)
 {
        struct resizer_scale_param *rsc_param;
@@ -411,7 +411,7 @@ resizer_set_outaddr(void *__iomem rsz_base, struct resizer_params *params,
 }
 
 void
-ipipe_set_lutdpc_regs(void *__iomem base_addr, void *__iomem isp5_base_addr,
+ipipe_set_lutdpc_regs(void __iomem *base_addr, void __iomem *isp5_base_addr,
                      struct vpfe_ipipe_lutdpc *dpc)
 {
        u32 max_tbl_size = LUT_DPC_MAX_SIZE >> 1;
@@ -446,7 +446,7 @@ ipipe_set_lutdpc_regs(void *__iomem base_addr, void *__iomem isp5_base_addr,
 }
 
 static void
-set_dpc_thresholds(void *__iomem base_addr,
+set_dpc_thresholds(void __iomem *base_addr,
                   struct vpfe_ipipe_otfdpc_2_0_cfg *dpc_thr)
 {
        regw_ip(base_addr, dpc_thr->corr_thr.r & OTFDPC_DPC2_THR_MASK,
@@ -467,7 +467,7 @@ set_dpc_thresholds(void *__iomem base_addr,
                DPC_OTF_2D_THR_B);
 }
 
-void ipipe_set_otfdpc_regs(void *__iomem base_addr,
+void ipipe_set_otfdpc_regs(void __iomem *base_addr,
                           struct vpfe_ipipe_otfdpc *otfdpc)
 {
        struct vpfe_ipipe_otfdpc_2_0_cfg *dpc_2_0 = &otfdpc->alg_cfg.dpc_2_0;
@@ -523,7 +523,7 @@ void ipipe_set_otfdpc_regs(void *__iomem base_addr,
 
 /* 2D Noise filter */
 void
-ipipe_set_d2f_regs(void *__iomem base_addr, unsigned int id,
+ipipe_set_d2f_regs(void __iomem *base_addr, unsigned int id,
                   struct vpfe_ipipe_nf *noise_filter)
 {
 
@@ -571,7 +571,7 @@ ipipe_set_d2f_regs(void *__iomem base_addr, unsigned int id,
        (((decimal & 0x1f) | ((integer & 0x7) << 5)))
 
 /* Green Imbalance Correction */
-void ipipe_set_gic_regs(void *__iomem base_addr, struct vpfe_ipipe_gic *gic)
+void ipipe_set_gic_regs(void __iomem *base_addr, struct vpfe_ipipe_gic *gic)
 {
        u32 val;
 
@@ -609,7 +609,7 @@ void ipipe_set_gic_regs(void *__iomem base_addr, struct vpfe_ipipe_gic *gic)
 #define IPIPE_U13Q9(decimal, integer) \
        (((decimal & 0x1ff) | ((integer & 0xf) << 9)))
 /* White balance */
-void ipipe_set_wb_regs(void *__iomem base_addr, struct vpfe_ipipe_wb *wb)
+void ipipe_set_wb_regs(void __iomem *base_addr, struct vpfe_ipipe_wb *wb)
 {
        u32 val;
 
@@ -635,7 +635,7 @@ void ipipe_set_wb_regs(void *__iomem base_addr, struct vpfe_ipipe_wb *wb)
 }
 
 /* CFA */
-void ipipe_set_cfa_regs(void *__iomem base_addr, struct vpfe_ipipe_cfa *cfa)
+void ipipe_set_cfa_regs(void __iomem *base_addr, struct vpfe_ipipe_cfa *cfa)
 {
        ipipe_clock_enable(base_addr);
 
@@ -671,7 +671,7 @@ void ipipe_set_cfa_regs(void *__iomem base_addr, struct vpfe_ipipe_cfa *cfa)
 }
 
 void
-ipipe_set_rgb2rgb_regs(void *__iomem base_addr, unsigned int id,
+ipipe_set_rgb2rgb_regs(void __iomem *base_addr, unsigned int id,
                       struct vpfe_ipipe_rgb2rgb *rgb)
 {
        u32 offset_mask = RGB2RGB_1_OFST_MASK;
@@ -724,7 +724,7 @@ ipipe_set_rgb2rgb_regs(void *__iomem base_addr, unsigned int id,
 }
 
 static void
-ipipe_update_gamma_tbl(void *__iomem isp5_base_addr,
+ipipe_update_gamma_tbl(void __iomem *isp5_base_addr,
        struct vpfe_ipipe_gamma_entry *table, int size, u32 addr)
 {
        int count;
@@ -738,7 +738,7 @@ ipipe_update_gamma_tbl(void *__iomem isp5_base_addr,
 }
 
 void
-ipipe_set_gamma_regs(void *__iomem base_addr, void *__iomem isp5_base_addr,
+ipipe_set_gamma_regs(void __iomem *base_addr, void __iomem *isp5_base_addr,
                          struct vpfe_ipipe_gamma *gamma)
 {
        int table_size;
@@ -770,7 +770,7 @@ ipipe_set_gamma_regs(void *__iomem base_addr, void *__iomem isp5_base_addr,
 }
 
 void
-ipipe_set_3d_lut_regs(void *__iomem base_addr, void *__iomem isp5_base_addr,
+ipipe_set_3d_lut_regs(void __iomem *base_addr, void __iomem *isp5_base_addr,
                           struct vpfe_ipipe_3d_lut *lut_3d)
 {
        struct vpfe_ipipe_3d_lut_entry *tbl;
@@ -819,7 +819,7 @@ ipipe_set_3d_lut_regs(void *__iomem base_addr, void *__iomem isp5_base_addr,
 
 /* Lumina adjustments */
 void
-ipipe_set_lum_adj_regs(void *__iomem base_addr, struct ipipe_lum_adj *lum_adj)
+ipipe_set_lum_adj_regs(void __iomem *base_addr, struct ipipe_lum_adj *lum_adj)
 {
        u32 val;
 
@@ -834,7 +834,7 @@ ipipe_set_lum_adj_regs(void *__iomem base_addr, struct ipipe_lum_adj *lum_adj)
 #define IPIPE_S12Q8(decimal, integer) \
        (((decimal & 0xff) | ((integer & 0xf) << 8)))
 
-void ipipe_set_rgb2ycbcr_regs(void *__iomem base_addr,
+void ipipe_set_rgb2ycbcr_regs(void __iomem *base_addr,
                              struct vpfe_ipipe_rgb2yuv *yuv)
 {
        u32 val;
@@ -866,7 +866,7 @@ void ipipe_set_rgb2ycbcr_regs(void *__iomem base_addr,
 
 /* YUV 422 conversion */
 void
-ipipe_set_yuv422_conv_regs(void *__iomem base_addr,
+ipipe_set_yuv422_conv_regs(void __iomem *base_addr,
                           struct vpfe_ipipe_yuv422_conv *conv)
 {
        u32 val;
@@ -879,7 +879,7 @@ ipipe_set_yuv422_conv_regs(void *__iomem base_addr,
 }
 
 void
-ipipe_set_gbce_regs(void *__iomem base_addr, void *__iomem isp5_base_addr,
+ipipe_set_gbce_regs(void __iomem *base_addr, void __iomem *isp5_base_addr,
                    struct vpfe_ipipe_gbce *gbce)
 {
        unsigned int count;
@@ -906,7 +906,7 @@ ipipe_set_gbce_regs(void *__iomem base_addr, void *__iomem isp5_base_addr,
 }
 
 void
-ipipe_set_ee_regs(void *__iomem base_addr, void *__iomem isp5_base_addr,
+ipipe_set_ee_regs(void __iomem *base_addr, void __iomem *isp5_base_addr,
                  struct vpfe_ipipe_yee *ee)
 {
        unsigned int count;
@@ -950,7 +950,7 @@ ipipe_set_ee_regs(void *__iomem base_addr, void *__iomem isp5_base_addr,
 }
 
 /* Chromatic Artifact Correction. CAR */
-static void ipipe_set_mf(void *__iomem base_addr)
+static void ipipe_set_mf(void __iomem *base_addr)
 {
        /* typ to dynamic switch */
        regw_ip(base_addr, VPFE_IPIPE_CAR_DYN_SWITCH, CAR_TYP);
@@ -959,7 +959,7 @@ static void ipipe_set_mf(void *__iomem base_addr)
 }
 
 static void
-ipipe_set_gain_ctrl(void *__iomem base_addr, struct vpfe_ipipe_car *car)
+ipipe_set_gain_ctrl(void __iomem *base_addr, struct vpfe_ipipe_car *car)
 {
        regw_ip(base_addr, VPFE_IPIPE_CAR_CHR_GAIN_CTRL, CAR_TYP);
        regw_ip(base_addr, car->hpf, CAR_HPF_TYP);
@@ -975,7 +975,7 @@ ipipe_set_gain_ctrl(void *__iomem base_addr, struct vpfe_ipipe_car *car)
                CAR_GN2_MIN);
 }
 
-void ipipe_set_car_regs(void *__iomem base_addr, struct vpfe_ipipe_car *car)
+void ipipe_set_car_regs(void __iomem *base_addr, struct vpfe_ipipe_car *car)
 {
        u32 val;
 
@@ -1010,7 +1010,7 @@ void ipipe_set_car_regs(void *__iomem base_addr, struct vpfe_ipipe_car *car)
 }
 
 /* Chromatic Gain Suppression */
-void ipipe_set_cgs_regs(void *__iomem base_addr, struct vpfe_ipipe_cgs *cgs)
+void ipipe_set_cgs_regs(void __iomem *base_addr, struct vpfe_ipipe_cgs *cgs)
 {
        ipipe_clock_enable(base_addr);
        regw_ip(base_addr, cgs->en, CGS_EN);
@@ -1025,12 +1025,12 @@ void ipipe_set_cgs_regs(void *__iomem base_addr, struct vpfe_ipipe_cgs *cgs)
        regw_ip(base_addr, cgs->h_min, CGS_GN1_H_MIN);
 }
 
-void rsz_src_enable(void *__iomem rsz_base, int enable)
+void rsz_src_enable(void __iomem *rsz_base, int enable)
 {
        regw_rsz(rsz_base, enable, RSZ_SRC_EN);
 }
 
-int rsz_enable(void *__iomem rsz_base, int rsz_id, int enable)
+int rsz_enable(void __iomem *rsz_base, int rsz_id, int enable)
 {
        if (rsz_id == RSZ_A) {
                regw_rsz(rsz_base, enable, RSZ_EN_A);
index 81176fb..2bf2f7a 100644 (file)
 #define RSZ_RGB_TYP_SHIFT              0
 #define RSZ_RGB_ALPHA_MASK             0xff
 
-static inline u32 regr_ip(void *__iomem addr, u32 offset)
+static inline u32 regr_ip(void __iomem *addr, u32 offset)
 {
        return readl(addr + offset);
 }
 
-static inline void regw_ip(void *__iomem addr, u32 val, u32 offset)
+static inline void regw_ip(void __iomem *addr, u32 val, u32 offset)
 {
        writel(val, addr + offset);
 }
 
-static inline u32 w_ip_table(void *__iomem addr, u32 val, u32 offset)
+static inline u32 w_ip_table(void __iomem *addr, u32 val, u32 offset)
 {
        writel(val, addr + offset);
 
        return val;
 }
 
-static inline u32 regr_rsz(void *__iomem addr, u32 offset)
+static inline u32 regr_rsz(void __iomem *addr, u32 offset)
 {
        return readl(addr + offset);
 }
 
-static inline u32 regw_rsz(void *__iomem addr, u32 val, u32 offset)
+static inline u32 regw_rsz(void __iomem *addr, u32 val, u32 offset)
 {
        writel(val, addr + offset);
 
@@ -520,39 +520,39 @@ static inline u32 regw_rsz(void *__iomem addr, u32 val, u32 offset)
 }
 
 int config_ipipe_hw(struct vpfe_ipipe_device *ipipe);
-int resizer_set_outaddr(void *__iomem rsz_base, struct resizer_params *params,
+int resizer_set_outaddr(void __iomem *rsz_base, struct resizer_params *params,
                        int resize_no, unsigned int address);
-int rsz_enable(void *__iomem rsz_base, int rsz_id, int enable);
-void rsz_src_enable(void *__iomem rsz_base, int enable);
+int rsz_enable(void __iomem *rsz_base, int rsz_id, int enable);
+void rsz_src_enable(void __iomem *rsz_base, int enable);
 void rsz_set_in_pix_format(unsigned char y_c);
 int config_rsz_hw(struct vpfe_resizer_device *resizer,
                  struct resizer_params *config);
-void ipipe_set_d2f_regs(void *__iomem base_addr, unsigned int id,
+void ipipe_set_d2f_regs(void __iomem *base_addr, unsigned int id,
        struct vpfe_ipipe_nf *noise_filter);
-void ipipe_set_rgb2rgb_regs(void *__iomem base_addr, unsigned int id,
+void ipipe_set_rgb2rgb_regs(void __iomem *base_addr, unsigned int id,
        struct vpfe_ipipe_rgb2rgb *rgb);
-void ipipe_set_yuv422_conv_regs(void *__iomem base_addr,
+void ipipe_set_yuv422_conv_regs(void __iomem *base_addr,
        struct vpfe_ipipe_yuv422_conv *conv);
-void ipipe_set_lum_adj_regs(void *__iomem base_addr,
+void ipipe_set_lum_adj_regs(void __iomem *base_addr,
        struct ipipe_lum_adj *lum_adj);
-void ipipe_set_rgb2ycbcr_regs(void *__iomem base_addr,
+void ipipe_set_rgb2ycbcr_regs(void __iomem *base_addr,
        struct vpfe_ipipe_rgb2yuv *yuv);
-void ipipe_set_lutdpc_regs(void *__iomem base_addr,
-       void *__iomem isp5_base_addr, struct vpfe_ipipe_lutdpc *lutdpc);
-void ipipe_set_otfdpc_regs(void *__iomem base_addr,
+void ipipe_set_lutdpc_regs(void __iomem *base_addr,
+       void __iomem *isp5_base_addr, struct vpfe_ipipe_lutdpc *lutdpc);
+void ipipe_set_otfdpc_regs(void __iomem *base_addr,
        struct vpfe_ipipe_otfdpc *otfdpc);
-void ipipe_set_3d_lut_regs(void *__iomem base_addr,
-       void *__iomem isp5_base_addr, struct vpfe_ipipe_3d_lut *lut_3d);
-void ipipe_set_gamma_regs(void *__iomem base_addr,
-       void *__iomem isp5_base_addr, struct vpfe_ipipe_gamma *gamma);
-void ipipe_set_ee_regs(void *__iomem base_addr,
-       void *__iomem isp5_base_addr, struct vpfe_ipipe_yee *ee);
-void ipipe_set_gbce_regs(void *__iomem base_addr,
-       void *__iomem isp5_base_addr, struct vpfe_ipipe_gbce *gbce);
-void ipipe_set_gic_regs(void *__iomem base_addr, struct vpfe_ipipe_gic *gic);
-void ipipe_set_cfa_regs(void *__iomem base_addr, struct vpfe_ipipe_cfa *cfa);
-void ipipe_set_car_regs(void *__iomem base_addr, struct vpfe_ipipe_car *car);
-void ipipe_set_cgs_regs(void *__iomem base_addr, struct vpfe_ipipe_cgs *cgs);
-void ipipe_set_wb_regs(void *__iomem base_addr, struct vpfe_ipipe_wb *wb);
+void ipipe_set_3d_lut_regs(void __iomem *base_addr,
+       void __iomem *isp5_base_addr, struct vpfe_ipipe_3d_lut *lut_3d);
+void ipipe_set_gamma_regs(void __iomem *base_addr,
+       void __iomem *isp5_base_addr, struct vpfe_ipipe_gamma *gamma);
+void ipipe_set_ee_regs(void __iomem *base_addr,
+       void __iomem *isp5_base_addr, struct vpfe_ipipe_yee *ee);
+void ipipe_set_gbce_regs(void __iomem *base_addr,
+       void __iomem *isp5_base_addr, struct vpfe_ipipe_gbce *gbce);
+void ipipe_set_gic_regs(void __iomem *base_addr, struct vpfe_ipipe_gic *gic);
+void ipipe_set_cfa_regs(void __iomem *base_addr, struct vpfe_ipipe_cfa *cfa);
+void ipipe_set_car_regs(void __iomem *base_addr, struct vpfe_ipipe_car *car);
+void ipipe_set_cgs_regs(void __iomem *base_addr, struct vpfe_ipipe_cgs *cgs);
+void ipipe_set_wb_regs(void __iomem *base_addr, struct vpfe_ipipe_wb *wb);
 
 #endif         /* _DAVINCI_VPFE_DM365_IPIPE_HW_H */
index 6d4893b..413acbb 100644 (file)
@@ -421,7 +421,7 @@ static int
 ipipeif_get_config(struct v4l2_subdev *sd, void __user *arg)
 {
        struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
-       struct ipipeif_params *config = (struct ipipeif_params *)arg;
+       struct ipipeif_params *config = arg;
        struct device *dev = ipipeif->subdev.v4l2_dev->dev;
 
        if (!arg) {
@@ -462,7 +462,7 @@ ipipeif_get_config(struct v4l2_subdev *sd, void __user *arg)
 static long ipipeif_ioctl(struct v4l2_subdev *sd,
                          unsigned int cmd, void *arg)
 {
-       struct ipipeif_params *config = (struct ipipeif_params *)arg;
+       struct ipipeif_params *config = arg;
        int ret = -ENOIOCTLCMD;
 
        switch (cmd) {
index 608701f..cea3d61 100644 (file)
@@ -134,7 +134,7 @@ struct vpfe_ipipeif_device {
        unsigned int output;
        struct vpfe_video_device video_in;
        struct v4l2_ctrl_handler ctrls;
-       void *__iomem ipipeif_base_addr;
+       void __iomem *ipipeif_base_addr;
        struct ipipeif_params config;
        int dpcm_predictor;
        int gain;
index 0d535b0..fe66d98 100644 (file)
@@ -70,17 +70,17 @@ static const u32 isif_srggb_pattern =
        ISIF_COLPTN_Gb_G  << ISIF_CCOLP_CP15_4 |
        ISIF_COLPTN_B_Mg  << ISIF_CCOLP_CP17_6;
 
-static inline u32 isif_read(void *__iomem base_addr, u32 offset)
+static inline u32 isif_read(void __iomem *base_addr, u32 offset)
 {
        return readl(base_addr + offset);
 }
 
-static inline void isif_write(void *__iomem base_addr, u32 val, u32 offset)
+static inline void isif_write(void __iomem *base_addr, u32 val, u32 offset)
 {
        writel(val, base_addr + offset);
 }
 
-static inline u32 isif_merge(void *__iomem base_addr, u32 mask, u32 val,
+static inline u32 isif_merge(void __iomem *base_addr, u32 mask, u32 val,
                             u32 offset)
 {
        u32 new_val = (isif_read(base_addr, offset) & ~mask) | (val & mask);
@@ -646,7 +646,7 @@ static void isif_config_gain_offset(struct vpfe_isif_device *isif)
 {
        struct vpfe_isif_gain_offsets_adj *gain_off_ptr =
                &isif->isif_cfg.bayer.config_params.gain_offset;
-       void *__iomem base = isif->isif_cfg.base_addr;
+       void __iomem *base = isif->isif_cfg.base_addr;
        u32 val;
 
        val = ((gain_off_ptr->gain_sdram_en & 1) << GAIN_SDRAM_EN_SHIFT) |
@@ -1602,6 +1602,7 @@ isif_pad_get_crop(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
 
        if (crop->which == V4L2_SUBDEV_FORMAT_TRY) {
                struct v4l2_rect *rect;
+
                rect = v4l2_subdev_get_try_crop(fh, ISIF_PAD_SINK);
                memcpy(&crop->rect, rect, sizeof(*rect));
        } else {
@@ -1991,7 +1992,7 @@ int vpfe_isif_init(struct vpfe_isif_device *isif, struct platform_device *pdev)
        struct media_entity *me = &sd->entity;
        static resource_size_t res_len;
        struct resource *res;
-       void *__iomem addr;
+       void __iomem *addr;
        int status;
        int i = 0;
 
index 473fd2c..89e814e 100644 (file)
@@ -159,9 +159,9 @@ struct isif_oper_config {
        struct isif_params_raw bayer;
        enum isif_data_pack data_pack;
        struct isif_gain_values isif_gain_params;
-       void *__iomem base_addr;
-       void *__iomem linear_tbl0_addr;
-       void *__iomem linear_tbl1_addr;
+       void __iomem *base_addr;
+       void __iomem *linear_tbl0_addr;
+       void __iomem *linear_tbl1_addr;
 };
 
 #define ISIF_PAD_SINK      0
index 8828d6c..36fc15a 100644 (file)
@@ -149,7 +149,7 @@ configure_resizer_out_params(struct vpfe_resizer_device *resizer, int index,
                param->rsz_en[index] = DISABLE;
                return;
        }
-       output = (struct vpfe_rsz_output_spec *)output_spec;
+       output = output_spec;
        param->rsz_en[index] = ENABLE;
        if (partial) {
                param->rsz_rsc_param[index].h_flip = output->h_flip;
@@ -633,7 +633,7 @@ resizer_calculate_normal_f_div_param(struct device *dev, int input_width,
        if (!(val % 2)) {
                h1 = val;
        } else {
-               val = (input_width << 7);
+               val = input_width << 7;
                val -= rsz >> 1;
                val /= rsz << 1;
                val <<= 1;
@@ -1218,12 +1218,12 @@ static long resizer_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
 
        switch (cmd) {
        case VIDIOC_VPFE_RSZ_S_CONFIG:
-               user_config = (struct vpfe_rsz_config *)arg;
+               user_config = arg;
                ret = resizer_set_configuration(resizer, user_config);
                break;
 
        case VIDIOC_VPFE_RSZ_G_CONFIG:
-               user_config = (struct vpfe_rsz_config *)arg;
+               user_config = arg;
                if (!user_config->config) {
                        dev_err(dev, "error in VIDIOC_VPFE_RSZ_G_CONFIG\n");
                        return -EINVAL;
index 59a7942..93b0f44 100644 (file)
@@ -228,7 +228,7 @@ struct vpfe_resizer_device {
        struct dm365_resizer_device             resizer_a;
        struct dm365_resizer_device             resizer_b;
        struct resizer_params                   config;
-       void *__iomem base_addr;
+       void __iomem *base_addr;
 };
 
 int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz,
index 4c806ba..44f5655 100644 (file)
@@ -56,11 +56,6 @@ static unsigned char do_get_bits(void);
 #define DRIVER_NAME "lirc_bt829"
 
 static bool debug;
-#define dprintk(fmt, args...)                                           \
-       do {                                                             \
-               if (debug)                                               \
-                       printk(KERN_DEBUG DRIVER_NAME ": "fmt, ## args); \
-       } while (0)
 
 static int atir_minor;
 static phys_addr_t pci_addr_phys;
@@ -101,7 +96,7 @@ static int atir_add_to_buf(void *data, struct lirc_buffer *buf)
        status = poll_main();
        key = (status >> 8) & 0xFF;
        if (status & 0xFF) {
-               dprintk("reading key %02X\n", key);
+               dev_dbg(atir_driver.dev, "reading key %02X\n", key);
                lirc_buffer_write(buf, &key);
                return 0;
        }
@@ -110,13 +105,13 @@ static int atir_add_to_buf(void *data, struct lirc_buffer *buf)
 
 static int atir_set_use_inc(void *data)
 {
-       dprintk("driver is opened\n");
+       dev_dbg(atir_driver.dev, "driver is opened\n");
        return 0;
 }
 
 static void atir_set_use_dec(void *data)
 {
-       dprintk("driver is closed\n");
+       dev_dbg(atir_driver.dev, "driver is closed\n");
 }
 
 int init_module(void)
@@ -154,7 +149,8 @@ int init_module(void)
                rc = atir_minor;
                goto err_unmap;
        }
-       dprintk("driver is registered on minor %d\n", atir_minor);
+       dev_dbg(atir_driver.dev, "driver is registered on minor %d\n",
+                               atir_minor);
 
        return 0;
 
index 431d1e8..fd5d3d2 100644 (file)
@@ -282,7 +282,7 @@ static void send_fragment(struct igorplug *ir, struct lirc_buffer *buf,
 static int igorplugusb_remote_poll(void *data, struct lirc_buffer *buf)
 {
        int ret;
-       struct igorplug *ir = (struct igorplug *)data;
+       struct igorplug *ir = data;
 
        if (!ir || !ir->usbdev)  /* Has the device been removed? */
                return -ENODEV;
index 7aca44f..f98418c 100644 (file)
@@ -495,7 +495,7 @@ static int ir_open(void *data)
        /* prevent races with disconnect */
        mutex_lock(&driver_lock);
 
-       context = (struct imon_context *)data;
+       context = data;
 
        /* initial IR protocol decode variables */
        context->rx.count = 0;
@@ -516,7 +516,7 @@ static void ir_close(void *data)
 {
        struct imon_context *context;
 
-       context = (struct imon_context *)data;
+       context = data;
        if (!context) {
                pr_err("%s: no context for device\n", __func__);
                return;
@@ -572,29 +572,6 @@ static void submit_data(struct imon_context *context)
        wake_up(&context->driver->rbuf->wait_poll);
 }
 
-static inline int tv2int(const struct timeval *a, const struct timeval *b)
-{
-       int usecs = 0;
-       int sec   = 0;
-
-       if (b->tv_usec > a->tv_usec) {
-               usecs = 1000000;
-               sec--;
-       }
-
-       usecs += a->tv_usec - b->tv_usec;
-
-       sec += a->tv_sec - b->tv_sec;
-       sec *= 1000;
-       usecs /= 1000;
-       sec += usecs;
-
-       if (sec < 0)
-               sec = 1000;
-
-       return sec;
-}
-
 /**
  * Process the incoming packet
  */
@@ -623,8 +600,8 @@ static void imon_incoming_packet(struct imon_context *context,
        if (debug) {
                dev_info(dev, "raw packet: ");
                for (i = 0; i < len; ++i)
-                       printk("%02x ", buf[i]);
-               printk("\n");
+                       dev_dbg(dev, "%02x ", buf[i]);
+               dev_dbg(dev, "\n");
        }
 
        /*
index c20ef56..123ddf6 100644 (file)
@@ -488,7 +488,7 @@ static int ir_open(void *data)
        /* prevent races with disconnect */
        mutex_lock(&disconnect_lock);
 
-       context = (struct sasem_context *) data;
+       context = data;
 
        mutex_lock(&context->ctx_lock);
 
@@ -530,7 +530,7 @@ static void ir_close(void *data)
 {
        struct sasem_context *context;
 
-       context = (struct sasem_context *)data;
+       context = data;
        if (!context) {
                pr_err("%s: no context for device\n", __func__);
                return;
@@ -583,10 +583,10 @@ static void incoming_packet(struct sasem_context *context,
        }
 
        if (debug) {
-               printk(KERN_INFO "Incoming data: ");
+               pr_info("Incoming data: ");
                for (i = 0; i < 8; ++i)
-                       printk(KERN_CONT "%02x ", buf[i]);
-               printk(KERN_CONT "\n");
+                       pr_cont("%02x ", buf[i]);
+               pr_cont("\n");
        }
 
        /*
index 2ee55ea..4af82e6 100644 (file)
@@ -140,12 +140,6 @@ static int rx_buf[RBUF_LEN];
 static unsigned int rx_tail, rx_head;
 
 static bool debug;
-#define dprintk(fmt, args...)                                          \
-       do {                                                            \
-               if (debug)                                              \
-                       printk(KERN_DEBUG LIRC_DRIVER_NAME ": "         \
-                               fmt, ## args);                          \
-       } while (0)
 
 /* SECTION: Prototypes */
 
@@ -322,7 +316,7 @@ static void add_read_queue(int flag, unsigned long val)
        unsigned int new_rx_tail;
        int newval;
 
-       dprintk("add flag %d with val %lu\n", flag, val);
+       pr_debug("add flag %d with val %lu\n", flag, val);
 
        newval = val & PULSE_MASK;
 
@@ -342,7 +336,7 @@ static void add_read_queue(int flag, unsigned long val)
        }
        new_rx_tail = (rx_tail + 1) & (RBUF_LEN - 1);
        if (new_rx_tail == rx_head) {
-               dprintk("Buffer overrun.\n");
+               pr_debug("Buffer overrun.\n");
                return;
        }
        rx_buf[rx_tail] = newval;
@@ -439,7 +433,8 @@ static void sir_timeout(unsigned long data)
                outb(UART_FCR_CLEAR_RCVR, io + UART_FCR);
                /* determine 'virtual' pulse end: */
                pulse_end = delta(&last_tv, &last_intr_tv);
-               dprintk("timeout add %d for %lu usec\n", last_value, pulse_end);
+               dev_dbg(driver.dev, "timeout add %d for %lu usec\n",
+                                   last_value, pulse_end);
                add_read_queue(last_value, pulse_end);
                last_value = 0;
                last_tv = last_intr_tv;
@@ -479,14 +474,15 @@ static irqreturn_t sir_interrupt(int irq, void *dev_id)
                                do_gettimeofday(&curr_tv);
                                deltv = delta(&last_tv, &curr_tv);
                                deltintrtv = delta(&last_intr_tv, &curr_tv);
-                               dprintk("t %lu, d %d\n", deltintrtv, (int)data);
+                               dev_dbg(driver.dev, "t %lu, d %d\n",
+                                                   deltintrtv, (int)data);
                                /*
                                 * if nothing came in last X cycles,
                                 * it was gap
                                 */
                                if (deltintrtv > TIME_CONST * threshold) {
                                        if (last_value) {
-                                               dprintk("GAP\n");
+                                               dev_dbg(driver.dev, "GAP\n");
                                                /* simulate signal change */
                                                add_read_queue(last_value,
                                                               deltv -
index 567feba..52f8e91 100644 (file)
@@ -152,23 +152,12 @@ struct tx_data_struct {
 static struct tx_data_struct *tx_data;
 static struct mutex tx_data_lock;
 
-#define zilog_notify(s, args...) printk(KERN_NOTICE KBUILD_MODNAME ": " s, \
-                                       ## args)
-#define zilog_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args)
-#define zilog_info(s, args...) printk(KERN_INFO KBUILD_MODNAME ": " s, ## args)
 
 /* module parameters */
 static bool debug;     /* debug output */
 static bool tx_only;   /* only handle the IR Tx function */
 static int minor = -1; /* minor number */
 
-#define dprintk(fmt, args...)                                          \
-       do {                                                            \
-               if (debug)                                              \
-                       printk(KERN_DEBUG KBUILD_MODNAME ": " fmt,      \
-                                ## args);                              \
-       } while (0)
-
 
 /* struct IR reference counting */
 static struct IR *get_ir_device(struct IR *ir, bool ir_devices_lock_held)
@@ -333,7 +322,7 @@ static int add_to_buf(struct IR *ir)
        struct IR_tx *tx;
 
        if (lirc_buffer_full(rbuf)) {
-               dprintk("buffer overflow\n");
+               dev_dbg(ir->l.dev, "buffer overflow\n");
                return -EOVERFLOW;
        }
 
@@ -379,16 +368,17 @@ static int add_to_buf(struct IR *ir)
                 */
                ret = i2c_master_send(rx->c, sendbuf, 1);
                if (ret != 1) {
-                       zilog_error("i2c_master_send failed with %d\n", ret);
+                       dev_err(ir->l.dev, "i2c_master_send failed with %d\n",
+                                          ret);
                        if (failures >= 3) {
                                mutex_unlock(&ir->ir_lock);
-                               zilog_error("unable to read from the IR chip "
+                               dev_err(ir->l.dev, "unable to read from the IR chip "
                                            "after 3 resets, giving up\n");
                                break;
                        }
 
                        /* Looks like the chip crashed, reset it */
-                       zilog_error("polling the IR receiver chip failed, "
+                       dev_err(ir->l.dev, "polling the IR receiver chip failed, "
                                    "trying reset\n");
 
                        set_current_state(TASK_UNINTERRUPTIBLE);
@@ -415,13 +405,14 @@ static int add_to_buf(struct IR *ir)
                ret = i2c_master_recv(rx->c, keybuf, sizeof(keybuf));
                mutex_unlock(&ir->ir_lock);
                if (ret != sizeof(keybuf)) {
-                       zilog_error("i2c_master_recv failed with %d -- "
+                       dev_err(ir->l.dev, "i2c_master_recv failed with %d -- "
                                    "keeping last read buffer\n", ret);
                } else {
                        rx->b[0] = keybuf[3];
                        rx->b[1] = keybuf[4];
                        rx->b[2] = keybuf[5];
-                       dprintk("key (0x%02x/0x%02x)\n", rx->b[0], rx->b[1]);
+                       dev_dbg(ir->l.dev, "key (0x%02x/0x%02x)\n",
+                                          rx->b[0], rx->b[1]);
                }
 
                /* key pressed ? */
@@ -472,7 +463,7 @@ static int lirc_thread(void *arg)
        struct IR *ir = arg;
        struct lirc_buffer *rbuf = ir->l.rbuf;
 
-       dprintk("poll thread started\n");
+       dev_dbg(ir->l.dev, "poll thread started\n");
 
        while (!kthread_should_stop()) {
                set_current_state(TASK_INTERRUPTIBLE);
@@ -500,7 +491,7 @@ static int lirc_thread(void *arg)
                        wake_up_interruptible(&rbuf->wait_poll);
        }
 
-       dprintk("poll thread ended\n");
+       dev_dbg(ir->l.dev, "poll thread ended\n");
        return 0;
 }
 
@@ -644,7 +635,7 @@ static int get_key_data(unsigned char *buf,
        return -EPROTO;
 
 corrupt:
-       zilog_error("firmware is corrupt\n");
+       pr_err("firmware is corrupt\n");
        return -EFAULT;
 }
 
@@ -662,10 +653,11 @@ static int send_data_block(struct IR_tx *tx, unsigned char *data_block)
                buf[0] = (unsigned char)(i + 1);
                for (j = 0; j < tosend; ++j)
                        buf[1 + j] = data_block[i + j];
-               dprintk("%*ph", 5, buf);
+               dev_dbg(tx->ir->l.dev, "%*ph", 5, buf);
                ret = i2c_master_send(tx->c, buf, tosend + 1);
                if (ret != tosend + 1) {
-                       zilog_error("i2c_master_send failed with %d\n", ret);
+                       dev_err(tx->ir->l.dev, "i2c_master_send failed with %d\n",
+                                              ret);
                        return ret < 0 ? ret : -EFAULT;
                }
                i += tosend;
@@ -689,7 +681,7 @@ static int send_boot_data(struct IR_tx *tx)
        buf[1] = 0x20;
        ret = i2c_master_send(tx->c, buf, 2);
        if (ret != 2) {
-               zilog_error("i2c_master_send failed with %d\n", ret);
+               dev_err(tx->ir->l.dev, "i2c_master_send failed with %d\n", ret);
                return ret < 0 ? ret : -EFAULT;
        }
 
@@ -706,21 +698,22 @@ static int send_boot_data(struct IR_tx *tx)
        }
 
        if (ret != 1) {
-               zilog_error("i2c_master_send failed with %d\n", ret);
+               dev_err(tx->ir->l.dev, "i2c_master_send failed with %d\n", ret);
                return ret < 0 ? ret : -EFAULT;
        }
 
        /* Here comes the firmware version... (hopefully) */
        ret = i2c_master_recv(tx->c, buf, 4);
        if (ret != 4) {
-               zilog_error("i2c_master_recv failed with %d\n", ret);
+               dev_err(tx->ir->l.dev, "i2c_master_recv failed with %d\n", ret);
                return 0;
        }
        if ((buf[0] != 0x80) && (buf[0] != 0xa0)) {
-               zilog_error("unexpected IR TX init response: %02x\n", buf[0]);
+               dev_err(tx->ir->l.dev, "unexpected IR TX init response: %02x\n",
+                                      buf[0]);
                return 0;
        }
-       zilog_notify("Zilog/Hauppauge IR blaster firmware version "
+       dev_notice(tx->ir->l.dev, "Zilog/Hauppauge IR blaster firmware version "
                     "%d.%d.%d loaded\n", buf[1], buf[2], buf[3]);
 
        return 0;
@@ -738,7 +731,7 @@ static void fw_unload_locked(void)
 
                vfree(tx_data);
                tx_data = NULL;
-               dprintk("successfully unloaded IR blaster firmware\n");
+               pr_debug("successfully unloaded IR blaster firmware\n");
        }
 }
 
@@ -768,17 +761,16 @@ static int fw_load(struct IR_tx *tx)
        /* Request codeset data file */
        ret = request_firmware(&fw_entry, "haup-ir-blaster.bin", tx->ir->l.dev);
        if (ret != 0) {
-               zilog_error("firmware haup-ir-blaster.bin not available (%d)\n",
+               dev_err(tx->ir->l.dev, "firmware haup-ir-blaster.bin not available (%d)\n",
                            ret);
                ret = ret < 0 ? ret : -EFAULT;
                goto out;
        }
-       dprintk("firmware of size %zu loaded\n", fw_entry->size);
+       dev_dbg(tx->ir->l.dev, "firmware of size %zu loaded\n", fw_entry->size);
 
        /* Parse the file */
        tx_data = vmalloc(sizeof(*tx_data));
        if (tx_data == NULL) {
-               zilog_error("out of memory\n");
                release_firmware(fw_entry);
                ret = -ENOMEM;
                goto out;
@@ -788,7 +780,6 @@ static int fw_load(struct IR_tx *tx)
        /* Copy the data so hotplug doesn't get confused and timeout */
        tx_data->datap = vmalloc(fw_entry->size);
        if (tx_data->datap == NULL) {
-               zilog_error("out of memory\n");
                release_firmware(fw_entry);
                vfree(tx_data);
                ret = -ENOMEM;
@@ -803,7 +794,7 @@ static int fw_load(struct IR_tx *tx)
        if (!read_uint8(&data, tx_data->endp, &version))
                goto corrupt;
        if (version != 1) {
-               zilog_error("unsupported code set file version (%u, expected"
+               dev_err(tx->ir->l.dev, "unsupported code set file version (%u, expected"
                            "1) -- please upgrade to a newer driver",
                            version);
                fw_unload_locked();
@@ -820,7 +811,8 @@ static int fw_load(struct IR_tx *tx)
                              &tx_data->num_code_sets))
                goto corrupt;
 
-       dprintk("%u IR blaster codesets loaded\n", tx_data->num_code_sets);
+       dev_dbg(tx->ir->l.dev, "%u IR blaster codesets loaded\n",
+                              tx_data->num_code_sets);
 
        tx_data->code_sets = vmalloc(
                tx_data->num_code_sets * sizeof(char *));
@@ -884,7 +876,7 @@ static int fw_load(struct IR_tx *tx)
        goto out;
 
 corrupt:
-       zilog_error("firmware is corrupt\n");
+       dev_err(tx->ir->l.dev, "firmware is corrupt\n");
        fw_unload_locked();
        ret = -EFAULT;
 
@@ -904,9 +896,9 @@ static ssize_t read(struct file *filep, char __user *outbuf, size_t n,
        unsigned int m;
        DECLARE_WAITQUEUE(wait, current);
 
-       dprintk("read called\n");
+       dev_dbg(ir->l.dev, "read called\n");
        if (n % rbuf->chunk_size) {
-               dprintk("read result = -EINVAL\n");
+               dev_dbg(ir->l.dev, "read result = -EINVAL\n");
                return -EINVAL;
        }
 
@@ -950,7 +942,7 @@ static ssize_t read(struct file *filep, char __user *outbuf, size_t n,
                        unsigned char buf[MAX_XFER_SIZE];
 
                        if (rbuf->chunk_size > sizeof(buf)) {
-                               zilog_error("chunk_size is too big (%d)!\n",
+                               dev_err(ir->l.dev, "chunk_size is too big (%d)!\n",
                                            rbuf->chunk_size);
                                ret = -EINVAL;
                                break;
@@ -964,7 +956,7 @@ static ssize_t read(struct file *filep, char __user *outbuf, size_t n,
                                retries++;
                        }
                        if (retries >= 5) {
-                               zilog_error("Buffer read failed!\n");
+                               dev_err(ir->l.dev, "Buffer read failed!\n");
                                ret = -EIO;
                        }
                }
@@ -974,7 +966,8 @@ static ssize_t read(struct file *filep, char __user *outbuf, size_t n,
        put_ir_rx(rx, false);
        set_current_state(TASK_RUNNING);
 
-       dprintk("read result = %d (%s)\n", ret, ret ? "Error" : "OK");
+       dev_dbg(ir->l.dev, "read result = %d (%s)\n",
+                          ret, ret ? "Error" : "OK");
 
        return ret ? ret : written;
 }
@@ -990,7 +983,7 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key)
        ret = get_key_data(data_block, code, key);
 
        if (ret == -EPROTO) {
-               zilog_error("failed to get data for code %u, key %u -- check "
+               dev_err(tx->ir->l.dev, "failed to get data for code %u, key %u -- check "
                            "lircd.conf entries\n", code, key);
                return ret;
        } else if (ret != 0)
@@ -1006,7 +999,7 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key)
        buf[1] = 0x40;
        ret = i2c_master_send(tx->c, buf, 2);
        if (ret != 2) {
-               zilog_error("i2c_master_send failed with %d\n", ret);
+               dev_err(tx->ir->l.dev, "i2c_master_send failed with %d\n", ret);
                return ret < 0 ? ret : -EFAULT;
        }
 
@@ -1019,18 +1012,18 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key)
        }
 
        if (ret != 1) {
-               zilog_error("i2c_master_send failed with %d\n", ret);
+               dev_err(tx->ir->l.dev, "i2c_master_send failed with %d\n", ret);
                return ret < 0 ? ret : -EFAULT;
        }
 
        /* Send finished download? */
        ret = i2c_master_recv(tx->c, buf, 1);
        if (ret != 1) {
-               zilog_error("i2c_master_recv failed with %d\n", ret);
+               dev_err(tx->ir->l.dev, "i2c_master_recv failed with %d\n", ret);
                return ret < 0 ? ret : -EFAULT;
        }
        if (buf[0] != 0xA0) {
-               zilog_error("unexpected IR TX response #1: %02x\n",
+               dev_err(tx->ir->l.dev, "unexpected IR TX response #1: %02x\n",
                        buf[0]);
                return -EFAULT;
        }
@@ -1040,7 +1033,7 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key)
        buf[1] = 0x80;
        ret = i2c_master_send(tx->c, buf, 2);
        if (ret != 2) {
-               zilog_error("i2c_master_send failed with %d\n", ret);
+               dev_err(tx->ir->l.dev, "i2c_master_send failed with %d\n", ret);
                return ret < 0 ? ret : -EFAULT;
        }
 
@@ -1050,7 +1043,7 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key)
         * going to skip this whole mess and say we're done on the HD PVR
         */
        if (!tx->post_tx_ready_poll) {
-               dprintk("sent code %u, key %u\n", code, key);
+               dev_dbg(tx->ir->l.dev, "sent code %u, key %u\n", code, key);
                return 0;
        }
 
@@ -1066,11 +1059,11 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key)
                ret = i2c_master_send(tx->c, buf, 1);
                if (ret == 1)
                        break;
-               dprintk("NAK expected: i2c_master_send "
+               dev_dbg(tx->ir->l.dev, "NAK expected: i2c_master_send "
                        "failed with %d (try %d)\n", ret, i+1);
        }
        if (ret != 1) {
-               zilog_error("IR TX chip never got ready: last i2c_master_send "
+               dev_err(tx->ir->l.dev, "IR TX chip never got ready: last i2c_master_send "
                            "failed with %d\n", ret);
                return ret < 0 ? ret : -EFAULT;
        }
@@ -1078,16 +1071,17 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key)
        /* Seems to be an 'ok' response */
        i = i2c_master_recv(tx->c, buf, 1);
        if (i != 1) {
-               zilog_error("i2c_master_recv failed with %d\n", ret);
+               dev_err(tx->ir->l.dev, "i2c_master_recv failed with %d\n", ret);
                return -EFAULT;
        }
        if (buf[0] != 0x80) {
-               zilog_error("unexpected IR TX response #2: %02x\n", buf[0]);
+               dev_err(tx->ir->l.dev, "unexpected IR TX response #2: %02x\n",
+                                      buf[0]);
                return -EFAULT;
        }
 
        /* Oh good, it worked */
-       dprintk("sent code %u, key %u\n", code, key);
+       dev_dbg(tx->ir->l.dev, "sent code %u, key %u\n", code, key);
        return 0;
 }
 
@@ -1173,11 +1167,11 @@ static ssize_t write(struct file *filep, const char __user *buf, size_t n,
                 */
                if (ret != 0) {
                        /* Looks like the chip crashed, reset it */
-                       zilog_error("sending to the IR transmitter chip "
+                       dev_err(tx->ir->l.dev, "sending to the IR transmitter chip "
                                    "failed, trying reset\n");
 
                        if (failures >= 3) {
-                               zilog_error("unable to send to the IR chip "
+                               dev_err(tx->ir->l.dev, "unable to send to the IR chip "
                                            "after 3 resets, giving up\n");
                                mutex_unlock(&ir->ir_lock);
                                mutex_unlock(&tx->client_lock);
@@ -1212,7 +1206,7 @@ static unsigned int poll(struct file *filep, poll_table *wait)
        struct lirc_buffer *rbuf = ir->l.rbuf;
        unsigned int ret;
 
-       dprintk("poll called\n");
+       dev_dbg(ir->l.dev, "poll called\n");
 
        rx = get_ir_rx(ir);
        if (rx == NULL) {
@@ -1220,7 +1214,7 @@ static unsigned int poll(struct file *filep, poll_table *wait)
                 * Revisit this, if our poll function ever reports writeable
                 * status for Tx
                 */
-               dprintk("poll result = POLLERR\n");
+               dev_dbg(ir->l.dev, "poll result = POLLERR\n");
                return POLLERR;
        }
 
@@ -1233,7 +1227,8 @@ static unsigned int poll(struct file *filep, poll_table *wait)
        /* Indicate what ops could happen immediately without blocking */
        ret = lirc_buffer_empty(rbuf) ? 0 : (POLLIN|POLLRDNORM);
 
-       dprintk("poll result = %s\n", ret ? "POLLIN|POLLRDNORM" : "none");
+       dev_dbg(ir->l.dev, "poll result = %s\n",
+                          ret ? "POLLIN|POLLRDNORM" : "none");
        return ret;
 }
 
@@ -1340,7 +1335,7 @@ static int close(struct inode *node, struct file *filep)
        struct IR *ir = filep->private_data;
 
        if (ir == NULL) {
-               zilog_error("close: no private_data attached to the file!\n");
+               dev_err(ir->l.dev, "close: no private_data attached to the file!\n");
                return -ENODEV;
        }
 
@@ -1452,7 +1447,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
        int ret;
        bool tx_probe = false;
 
-       dprintk("%s: %s on i2c-%d (%s), client addr=0x%02x\n",
+       pr_debug("%s: %s on i2c-%d (%s), client addr=0x%02x\n",
                __func__, id->name, adap->nr, adap->name, client->addr);
 
        /*
@@ -1465,7 +1460,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
        else if (tx_only) /* module option */
                return -ENXIO;
 
-       zilog_info("probing IR %s on %s (i2c-%d)\n",
+       pr_info("probing IR %s on %s (i2c-%d)\n",
                   tx_probe ? "Tx" : "Rx", adap->name, adap->nr);
 
        mutex_lock(&ir_devices_lock);
@@ -1547,7 +1542,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
 
                /* Proceed only if the Rx client is also ready or not needed */
                if (rx == NULL && !tx_only) {
-                       zilog_info("probe of IR Tx on %s (i2c-%d) done. Waiting"
+                       dev_info(tx->ir->l.dev, "probe of IR Tx on %s (i2c-%d) done. Waiting"
                                   " on IR Rx.\n", adap->name, adap->nr);
                        goto out_ok;
                }
@@ -1586,7 +1581,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
                                       "zilog-rx-i2c-%d", adap->nr);
                if (IS_ERR(rx->task)) {
                        ret = PTR_ERR(rx->task);
-                       zilog_error("%s: could not start IR Rx polling thread"
+                       dev_err(tx->ir->l.dev, "%s: could not start IR Rx polling thread"
                                    "\n", __func__);
                        /* Failed kthread, so put back the ir ref */
                        put_ir_device(ir, true);
@@ -1599,7 +1594,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
 
                /* Proceed only if the Tx client is also ready */
                if (tx == NULL) {
-                       zilog_info("probe of IR Rx on %s (i2c-%d) done. Waiting"
+                       pr_info("probe of IR Rx on %s (i2c-%d) done. Waiting"
                                   " on IR Tx.\n", adap->name, adap->nr);
                        goto out_ok;
                }
@@ -1609,12 +1604,12 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
        ir->l.minor = minor; /* module option: user requested minor number */
        ir->l.minor = lirc_register_driver(&ir->l);
        if (ir->l.minor < 0 || ir->l.minor >= MAX_IRCTL_DEVICES) {
-               zilog_error("%s: \"minor\" must be between 0 and %d (%d)!\n",
+               dev_err(tx->ir->l.dev, "%s: \"minor\" must be between 0 and %d (%d)!\n",
                            __func__, MAX_IRCTL_DEVICES-1, ir->l.minor);
                ret = -EBADRQC;
                goto out_put_xx;
        }
-       zilog_info("IR unit on %s (i2c-%d) registered as lirc%d and ready\n",
+       dev_info(ir->l.dev, "IR unit on %s (i2c-%d) registered as lirc%d and ready\n",
                   adap->name, adap->nr, ir->l.minor);
 
 out_ok:
@@ -1623,7 +1618,7 @@ out_ok:
        if (tx != NULL)
                put_ir_tx(tx, true);
        put_ir_device(ir, true);
-       zilog_info("probe of IR %s on %s (i2c-%d) done\n",
+       dev_info(ir->l.dev, "probe of IR %s on %s (i2c-%d) done\n",
                   tx_probe ? "Tx" : "Rx", adap->name, adap->nr);
        mutex_unlock(&ir_devices_lock);
        return 0;
@@ -1636,7 +1631,7 @@ out_put_xx:
 out_put_ir:
        put_ir_device(ir, true);
 out_no_ir:
-       zilog_error("%s: probing IR %s on %s (i2c-%d) failed with %d\n",
+       dev_err(ir->l.dev, "%s: probing IR %s on %s (i2c-%d) failed with %d\n",
                    __func__, tx_probe ? "Tx" : "Rx", adap->name, adap->nr,
                   ret);
        mutex_unlock(&ir_devices_lock);
@@ -1647,7 +1642,7 @@ static int __init zilog_init(void)
 {
        int ret;
 
-       zilog_notify("Zilog/Hauppauge IR driver initializing\n");
+       pr_notice("Zilog/Hauppauge IR driver initializing\n");
 
        mutex_init(&tx_data_lock);
 
@@ -1655,9 +1650,9 @@ static int __init zilog_init(void)
 
        ret = i2c_add_driver(&driver);
        if (ret)
-               zilog_error("initialization failed\n");
+               pr_err("initialization failed\n");
        else
-               zilog_notify("initialization complete\n");
+               pr_notice("initialization complete\n");
 
        return ret;
 }
@@ -1667,7 +1662,7 @@ static void __exit zilog_exit(void)
        i2c_del_driver(&driver);
        /* if loaded */
        fw_unload();
-       zilog_notify("Zilog/Hauppauge IR driver unloaded\n");
+       pr_notice("Zilog/Hauppauge IR driver unloaded\n");
 }
 
 module_init(zilog_init);
index d590b3e..36d81e0 100644 (file)
@@ -326,7 +326,7 @@ static int omap24xxcam_vbq_alloc_mmap_buffer(struct videobuf_buffer *vb)
                dma->sglen++;
                i++;
 
-               alloc_size = (PAGE_SIZE << order);
+               alloc_size = PAGE_SIZE << order;
 
                /* clear pages before giving them to user space */
                memset(page_address(page), 0, alloc_size);
@@ -1737,10 +1737,8 @@ static int omap24xxcam_probe(struct platform_device *pdev)
        int irq;
 
        cam = kzalloc(sizeof(*cam), GFP_KERNEL);
-       if (!cam) {
-               dev_err(&pdev->dev, "could not allocate memory\n");
+       if (!cam)
                goto err;
-       }
 
        platform_set_drvdata(pdev, cam);
 
index 9d9ecf1..6a1f479 100644 (file)
@@ -751,7 +751,7 @@ static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p)
                (2457 * tgt_fps) / MAX_FPS;
        tgt_xclk *= 10000;
 
-       tgt_xclk = min(tgt_xclk, (u32)TCM825X_XCLK_MAX);
+       tgt_xclk = min_t(u32, tgt_xclk, TCM825X_XCLK_MAX);
        tgt_xclk = max(tgt_xclk, (u32)TCM825X_XCLK_MIN);
 
        p->u.bt656.clock_curr = tgt_xclk;
index d548371..6e9e869 100644 (file)
@@ -1357,10 +1357,8 @@ static int iss_probe(struct platform_device *pdev)
                return -EINVAL;
 
        iss = devm_kzalloc(&pdev->dev, sizeof(*iss), GFP_KERNEL);
-       if (!iss) {
-               dev_err(&pdev->dev, "Could not allocate memory\n");
+       if (!iss)
                return -ENOMEM;
-       }
 
        mutex_init(&iss->iss_mutex);
 
index 92c2d5b..47f86b3 100644 (file)
@@ -1231,7 +1231,7 @@ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname)
 
        v4l2_subdev_init(sd, &csi2_ops);
        sd->internal_ops = &csi2_internal_ops;
-       sprintf(name, "CSI2%s", subname);
+       snprintf(name, sizeof(name), "CSI2%s", subname);
        snprintf(sd->name, sizeof(sd->name), "OMAP4 ISS %s", name);
 
        sd->grp_id = 1 << 16;   /* group ID for iss subdevs */
index 5f9db4c..4337a2f 100644 (file)
@@ -640,8 +640,7 @@ static inline int __cvmx_usb_get_data_pid(struct cvmx_usb_pipe *pipe)
 {
        if (pipe->pid_toggle)
                return 2; /* Data1 */
-       else
-               return 0; /* Data0 */
+       return 0; /* Data0 */
 }
 
 /**
@@ -744,7 +743,7 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb,
         *     such that USB is as close as possible to 125Mhz
         */
        {
-               int divisor = (octeon_get_clock_rate()+125000000-1)/125000000;
+               int divisor = DIV_ROUND_UP(octeon_get_clock_rate(), 125000000);
                /* Lower than 4 doesn't seem to work properly */
                if (divisor < 4)
                        divisor = 4;
@@ -1328,7 +1327,8 @@ static void __cvmx_usb_poll_rx_fifo(struct cvmx_usb_state *usb)
 
        /* Loop writing the FIFO data for this packet into memory */
        while (bytes > 0) {
-               *ptr++ = __cvmx_usb_read_csr32(usb, USB_FIFO_ADDRESS(channel, usb->index));
+               *ptr++ = __cvmx_usb_read_csr32(usb,
+                               USB_FIFO_ADDRESS(channel, usb->index));
                bytes -= 4;
        }
        CVMX_SYNCW;
@@ -1479,7 +1479,8 @@ static void __cvmx_usb_fill_tx_fifo(struct cvmx_usb_state *usb, int channel)
                fifo = &usb->nonperiodic;
 
        fifo->entry[fifo->head].channel = channel;
-       fifo->entry[fifo->head].address = __cvmx_usb_read_csr64(usb, CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8);
+       fifo->entry[fifo->head].address = __cvmx_usb_read_csr64(usb,
+                       CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8);
        fifo->entry[fifo->head].size = (usbc_hctsiz.s.xfersize+3)>>2;
        fifo->head++;
        if (fifo->head > MAX_CHANNELS)
@@ -1607,8 +1608,8 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_state *usb,
         * Calculate the number of packets to transfer. If the length is zero
         * we still need to transfer one packet
         */
-       packets_to_transfer = (bytes_to_transfer + pipe->max_packet - 1) /
-               pipe->max_packet;
+       packets_to_transfer = DIV_ROUND_UP(bytes_to_transfer,
+                                          pipe->max_packet);
        if (packets_to_transfer == 0)
                packets_to_transfer = 1;
        else if ((packets_to_transfer > 1) &&
@@ -1700,7 +1701,9 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb,
                        usbc_hcintmsk.s.stallmsk = 1;
                        usbc_hcintmsk.s.xfercomplmsk = 1;
                }
-               __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTMSKX(channel, usb->index), usbc_hcintmsk.u32);
+               __cvmx_usb_write_csr32(usb,
+                               CVMX_USBCX_HCINTMSKX(channel, usb->index),
+                               usbc_hcintmsk.u32);
 
                /* Enable the channel interrupt to propagate */
                usbc_haintmsk.u32 = __cvmx_usb_read_csr32(usb,
@@ -1853,8 +1856,7 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb,
                 * zero we still need to transfer one packet
                 */
                packets_to_transfer =
-                       (bytes_to_transfer + pipe->max_packet - 1) /
-                       pipe->max_packet;
+                       DIV_ROUND_UP(bytes_to_transfer, pipe->max_packet);
                if (packets_to_transfer == 0)
                        packets_to_transfer = 1;
                else if ((packets_to_transfer > 1) &&
@@ -2881,9 +2883,11 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                                        struct usb_ctrlrequest *header =
                                                cvmx_phys_to_ptr(transaction->control_header);
                                        if (header->wLength)
-                                               transaction->stage = CVMX_USB_STAGE_DATA;
+                                               transaction->stage =
+                                                       CVMX_USB_STAGE_DATA;
                                        else
-                                               transaction->stage = CVMX_USB_STAGE_STATUS;
+                                               transaction->stage =
+                                                       CVMX_USB_STAGE_STATUS;
                                }
                                break;
                        case CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE:
@@ -2891,9 +2895,11 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                                        struct usb_ctrlrequest *header =
                                                cvmx_phys_to_ptr(transaction->control_header);
                                        if (header->wLength)
-                                               transaction->stage = CVMX_USB_STAGE_DATA;
+                                               transaction->stage =
+                                                       CVMX_USB_STAGE_DATA;
                                        else
-                                               transaction->stage = CVMX_USB_STAGE_STATUS;
+                                               transaction->stage =
+                                                       CVMX_USB_STAGE_STATUS;
                                }
                                break;
                        case CVMX_USB_STAGE_DATA:
@@ -3015,7 +3021,8 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                                 * is complete, the pipe sleeps until the next
                                 * schedule interval
                                 */
-                               if (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) {
+                               if (pipe->transfer_dir ==
+                                       CVMX_USB_DIRECTION_OUT) {
                                        /*
                                         * If no space left or this wasn't a max
                                         * size packet then this transfer is
index b2b6c3c..44e372f 100644 (file)
@@ -286,6 +286,7 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
                        did_work_request = 1;
                }
 
+#ifndef CONFIG_RPS
                if (rx_count == 0) {
                        /*
                         * First time through, see if there is enough
@@ -300,6 +301,7 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
                        if (backlog > budget * cores_in_use && napi != NULL)
                                cvm_oct_enable_one_cpu();
                }
+#endif
                rx_count++;
 
                skb_in_hw = USE_SKBUFFS_IN_HW && work->word2.s.bufs == 1;
index 4e54d85..b7a7854 100644 (file)
@@ -77,6 +77,7 @@ static DECLARE_TASKLET(cvm_oct_tx_cleanup_tasklet, cvm_oct_tx_do_cleanup, 0);
 static inline int32_t cvm_oct_adjust_skb_to_free(int32_t skb_to_free, int fau)
 {
        int32_t undo;
+
        undo = skb_to_free > 0 ? MAX_SKB_TO_FREE : skb_to_free +
                                                   MAX_SKB_TO_FREE;
        if (undo > 0)
@@ -89,6 +90,7 @@ static inline int32_t cvm_oct_adjust_skb_to_free(int32_t skb_to_free, int fau)
 static void cvm_oct_kick_tx_poll_watchdog(void)
 {
        union cvmx_ciu_timx ciu_timx;
+
        ciu_timx.u64 = 0;
        ciu_timx.s.one_shot = 1;
        ciu_timx.s.len = cvm_oct_tx_poll_interval;
@@ -118,9 +120,11 @@ static void cvm_oct_free_tx_skbs(struct net_device *dev)
                total_freed += skb_to_free;
                if (skb_to_free > 0) {
                        struct sk_buff *to_free_list = NULL;
+
                        spin_lock_irqsave(&priv->tx_free_list[qos].lock, flags);
                        while (skb_to_free > 0) {
                                struct sk_buff *t;
+
                                t = __skb_dequeue(&priv->tx_free_list[qos]);
                                t->next = to_free_list;
                                to_free_list = t;
@@ -131,6 +135,7 @@ static void cvm_oct_free_tx_skbs(struct net_device *dev)
                        /* Do the actual freeing outside of the lock. */
                        while (to_free_list) {
                                struct sk_buff *t = to_free_list;
+
                                to_free_list = to_free_list->next;
                                dev_kfree_skb_any(t);
                        }
@@ -258,6 +263,7 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev)
                            cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface));
                        if (gmx_prt_cfg.s.duplex == 0) {
                                int add_bytes = 64 - skb->len;
+
                                if ((skb_tail_pointer(skb) + add_bytes) <=
                                    skb_end_pointer(skb))
                                        memset(__skb_put(skb, add_bytes), 0,
@@ -289,6 +295,7 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev)
                CVM_OCT_SKB_CB(skb)[0] = hw_buffer.u64;
                for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
                        struct skb_frag_struct *fs = skb_shinfo(skb)->frags + i;
+
                        hw_buffer.s.addr = XKPHYS_TO_PHYS(
                                (u64)(page_address(fs->page.p) +
                                fs->page_offset));
@@ -495,6 +502,7 @@ skip_xmit:
 
        while (skb_to_free > 0) {
                struct sk_buff *t = __skb_dequeue(&priv->tx_free_list[qos]);
+
                t->next = to_free_list;
                to_free_list = t;
                skb_to_free--;
@@ -505,6 +513,7 @@ skip_xmit:
        /* Do the actual freeing outside of the lock. */
        while (to_free_list) {
                struct sk_buff *t = to_free_list;
+
                to_free_list = to_free_list->next;
                dev_kfree_skb_any(t);
        }
@@ -550,6 +559,7 @@ int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev)
 
        /* Get a work queue entry */
        cvmx_wqe_t *work = cvmx_fpa_alloc(CVMX_FPA_WQE_POOL);
+
        if (unlikely(work == NULL)) {
                printk_ratelimited("%s: Failed to allocate a work queue entry\n",
                                   dev->name);
@@ -713,6 +723,7 @@ static void cvm_oct_tx_do_cleanup(unsigned long arg)
        for (port = 0; port < TOTAL_NUMBER_OF_PORTS; port++) {
                if (cvm_oct_device[port]) {
                        struct net_device *dev = cvm_oct_device[port];
+
                        cvm_oct_free_tx_skbs(dev);
                }
        }
index 8f9e3fb..47d4277 100644 (file)
@@ -452,7 +452,7 @@ int cvm_oct_common_init(struct net_device *dev)
                mac = of_get_mac_address(priv->of_node);
 
        if (mac)
-               memcpy(dev->dev_addr, mac, ETH_ALEN);
+               ether_addr_copy(dev->dev_addr, mac);
        else
                eth_hw_addr_random(dev);
 
index e880452..27217d7 100644 (file)
@@ -730,7 +730,7 @@ void oz_hcd_pd_reset(void *hpd, void *hport)
 {
        /* Cleanup the current configuration and report reset to the core.
         */
-       struct oz_port *port = (struct oz_port *)hport;
+       struct oz_port *port = hport;
        struct oz_hcd *ozhcd = port->ozhcd;
 
        oz_dbg(ON, "PD Reset\n");
@@ -749,7 +749,7 @@ void oz_hcd_pd_reset(void *hpd, void *hport)
 void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, const u8 *desc,
                        int length, int offset, int total_size)
 {
-       struct oz_port *port = (struct oz_port *)hport;
+       struct oz_port *port = hport;
        struct urb *urb;
        int err = 0;
 
@@ -889,7 +889,7 @@ static void oz_hcd_complete_set_interface(struct oz_port *port, struct urb *urb,
 void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, const u8 *data,
        int data_len)
 {
-       struct oz_port *port = (struct oz_port *)hport;
+       struct oz_port *port = hport;
        struct urb *urb;
        struct usb_ctrlrequest *setup;
        struct usb_hcd *hcd = port->ozhcd->hcd;
@@ -1036,7 +1036,7 @@ static inline int oz_usb_get_frame_number(void)
 int oz_hcd_heartbeat(void *hport)
 {
        int rc = 0;
-       struct oz_port *port = (struct oz_port *)hport;
+       struct oz_port *port = hport;
        struct oz_hcd *ozhcd = port->ozhcd;
        struct oz_urb_link *urbl, *n;
        LIST_HEAD(xfr_list);
@@ -1914,7 +1914,7 @@ static void oz_get_hub_descriptor(struct usb_hcd *hcd,
        memset(desc, 0, sizeof(*desc));
        desc->bDescriptorType = 0x29;
        desc->bDescLength = 9;
-       desc->wHubCharacteristics = (__force __u16)cpu_to_le16(0x0001);
+       desc->wHubCharacteristics = cpu_to_le16(0x0001);
        desc->bNbrPorts = OZ_NB_PORTS;
 }
 
@@ -2032,11 +2032,11 @@ static int oz_clear_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex)
                break;
        case USB_PORT_FEAT_C_CONNECTION:
                oz_dbg(HUB, "USB_PORT_FEAT_C_CONNECTION\n");
-               clear_bits = (USB_PORT_STAT_C_CONNECTION << 16);
+               clear_bits = USB_PORT_STAT_C_CONNECTION << 16;
                break;
        case USB_PORT_FEAT_C_ENABLE:
                oz_dbg(HUB, "USB_PORT_FEAT_C_ENABLE\n");
-               clear_bits = (USB_PORT_STAT_C_ENABLE << 16);
+               clear_bits = USB_PORT_STAT_C_ENABLE << 16;
                break;
        case USB_PORT_FEAT_C_SUSPEND:
                oz_dbg(HUB, "USB_PORT_FEAT_C_SUSPEND\n");
@@ -2046,7 +2046,7 @@ static int oz_clear_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex)
                break;
        case USB_PORT_FEAT_C_RESET:
                oz_dbg(HUB, "USB_PORT_FEAT_C_RESET\n");
-               clear_bits = (USB_PORT_FEAT_C_RESET << 16);
+               clear_bits = USB_PORT_FEAT_C_RESET << 16;
                break;
        case USB_PORT_FEAT_TEST:
                oz_dbg(HUB, "USB_PORT_FEAT_TEST\n");
index be7ee01..d434d8c 100644 (file)
@@ -56,7 +56,7 @@ static int oz_usb_submit_elt(struct oz_elt_buf *eb, struct oz_elt_info *ei,
 int oz_usb_get_desc_req(void *hpd, u8 req_id, u8 req_type, u8 desc_type,
        u8 index, __le16 windex, int offset, int len)
 {
-       struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd;
+       struct oz_usb_ctx *usb_ctx = hpd;
        struct oz_pd *pd = usb_ctx->pd;
        struct oz_elt *elt;
        struct oz_get_desc_req *body;
@@ -92,7 +92,7 @@ int oz_usb_get_desc_req(void *hpd, u8 req_id, u8 req_type, u8 desc_type,
  */
 static int oz_usb_set_config_req(void *hpd, u8 req_id, u8 index)
 {
-       struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd;
+       struct oz_usb_ctx *usb_ctx = hpd;
        struct oz_pd *pd = usb_ctx->pd;
        struct oz_elt *elt;
        struct oz_elt_buf *eb = &pd->elt_buff;
@@ -115,7 +115,7 @@ static int oz_usb_set_config_req(void *hpd, u8 req_id, u8 index)
  */
 static int oz_usb_set_interface_req(void *hpd, u8 req_id, u8 index, u8 alt)
 {
-       struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd;
+       struct oz_usb_ctx *usb_ctx = hpd;
        struct oz_pd *pd = usb_ctx->pd;
        struct oz_elt *elt;
        struct oz_elt_buf *eb = &pd->elt_buff;
@@ -140,7 +140,7 @@ static int oz_usb_set_interface_req(void *hpd, u8 req_id, u8 index, u8 alt)
 static int oz_usb_set_clear_feature_req(void *hpd, u8 req_id, u8 type,
                        u8 recipient, u8 index, __le16 feature)
 {
-       struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd;
+       struct oz_usb_ctx *usb_ctx = hpd;
        struct oz_pd *pd = usb_ctx->pd;
        struct oz_elt *elt;
        struct oz_elt_buf *eb = &pd->elt_buff;
@@ -166,7 +166,7 @@ static int oz_usb_set_clear_feature_req(void *hpd, u8 req_id, u8 type,
 static int oz_usb_vendor_class_req(void *hpd, u8 req_id, u8 req_type,
        u8 request, __le16 value, __le16 index, const u8 *data, int data_len)
 {
-       struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd;
+       struct oz_usb_ctx *usb_ctx = hpd;
        struct oz_pd *pd = usb_ctx->pd;
        struct oz_elt *elt;
        struct oz_elt_buf *eb = &pd->elt_buff;
@@ -244,7 +244,7 @@ int oz_usb_control_req(void *hpd, u8 req_id, struct usb_ctrlrequest *setup,
  */
 int oz_usb_send_isoc(void *hpd, u8 ep_num, struct urb *urb)
 {
-       struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd;
+       struct oz_usb_ctx *usb_ctx = hpd;
        struct oz_pd *pd = usb_ctx->pd;
        struct oz_elt_buf *eb;
        int i;
index 6d1a320..98556ce 100644 (file)
@@ -1375,9 +1375,9 @@ static const struct file_operations lcd_fops = {
 };
 
 static struct miscdevice lcd_dev = {
-       LCD_MINOR,
-       "lcd",
-       &lcd_fops
+       .minor  = LCD_MINOR,
+       .name   = "lcd",
+       .fops   = &lcd_fops,
 };
 
 /* public function usable from the kernel for any purpose */
@@ -1652,9 +1652,9 @@ static const struct file_operations keypad_fops = {
 };
 
 static struct miscdevice keypad_dev = {
-       KEYPAD_MINOR,
-       "keypad",
-       &keypad_fops
+       .minor  = KEYPAD_MINOR,
+       .name   = "keypad",
+       .fops   = &keypad_fops,
 };
 
 static void keypad_send_key(const char *string, int max_len)
index 9224e02..d61842e 100644 (file)
@@ -888,7 +888,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf,  int len)
 
        pbss_network->Rssi = 0;
 
-       memcpy(pbss_network->MacAddress, myid(&(padapter->eeprompriv)), ETH_ALEN);
+       ether_addr_copy(pbss_network->MacAddress, myid(&(padapter->eeprompriv)));
 
        /* beacon interval */
        p = rtw_get_beacon_interval_from_ie(ie);/* 8: TimeStamp, 2: Beacon Interval 2:Capability */
@@ -1164,7 +1164,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
                if (!paclnode->valid) {
                        INIT_LIST_HEAD(&paclnode->list);
 
-                       memcpy(paclnode->addr, addr, ETH_ALEN);
+                       ether_addr_copy(paclnode->addr, addr);
 
                        paclnode->valid = true;
 
@@ -1186,7 +1186,6 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
 int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr)
 {
        struct list_head *plist, *phead;
-       int ret = 0;
        struct rtw_wlan_acl_node *paclnode;
        struct sta_priv *pstapriv = &padapter->stapriv;
        struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
@@ -1217,7 +1216,7 @@ int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr)
        spin_unlock_bh(&(pacl_node_q->lock));
 
        DBG_88E("%s, acl_num =%d\n", __func__, pacl_list->num);
-       return ret;
+       return 0;
 }
 
 static void update_bcn_fixed_ie(struct adapter *padapter)
@@ -1753,7 +1752,6 @@ u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta,
 int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset)
 {
        struct list_head *phead, *plist;
-       int ret = 0;
        struct sta_info *psta = NULL;
        struct sta_priv *pstapriv = &padapter->stapriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
@@ -1761,7 +1759,7 @@ int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset)
        u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 
        if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE)
-               return ret;
+               return 0;
 
        DBG_88E(FUNC_NDEV_FMT" with ch:%u, offset:%u\n",
                FUNC_NDEV_ARG(padapter->pnetdev), new_ch, ch_offset);
@@ -1782,13 +1780,12 @@ int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset)
 
        issue_action_spct_ch_switch(padapter, bc_addr, new_ch, ch_offset);
 
-       return ret;
+       return 0;
 }
 
 int rtw_sta_flush(struct adapter *padapter)
 {
        struct list_head *phead, *plist;
-       int ret = 0;
        struct sta_info *psta = NULL;
        struct sta_priv *pstapriv = &padapter->stapriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
@@ -1798,7 +1795,7 @@ int rtw_sta_flush(struct adapter *padapter)
        DBG_88E(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev));
 
        if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE)
-               return ret;
+               return 0;
 
        spin_lock_bh(&pstapriv->asoc_list_lock);
        phead = &pstapriv->asoc_list;
@@ -1822,7 +1819,7 @@ int rtw_sta_flush(struct adapter *padapter)
 
        associated_clients_update(padapter, true);
 
-       return ret;
+       return 0;
 }
 
 /* called > TSR LEVEL for USB or SDIO Interface*/
index 9935e66..dd24138 100644 (file)
@@ -167,7 +167,7 @@ int rtw_cmd_thread(void *context)
        struct cmd_obj *pcmd;
        u8 (*cmd_hdl)(struct adapter *padapter, u8 *pbuf);
        void (*pcmd_callback)(struct adapter *dev, struct cmd_obj *pcmd);
-       struct adapter *padapter = (struct adapter *)context;
+       struct adapter *padapter = context;
        struct cmd_priv *pcmdpriv = &(padapter->cmdpriv);
 
        allow_signal(SIGTERM);
@@ -433,8 +433,7 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct wlan_network *pnetwork)
 
        psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss;
        if (psecnetwork == NULL) {
-               if (pcmd != NULL)
-                       kfree(pcmd);
+               kfree(pcmd);
 
                res = _FAIL;
 
@@ -456,7 +455,7 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct wlan_network *pnetwork)
 
        psecnetwork->IELength = 0;
        /*  Added by Albert 2009/02/18 */
-       /*  If the the driver wants to use the bssid to create the connection. */
+       /*  If the driver wants to use the bssid to create the connection. */
        /*  If not,  we have to copy the connecting AP's MAC address to it so that */
        /*  the driver just has the bssid information for PMKIDList searching. */
 
index 1f72f7d..bc3fe10 100644 (file)
@@ -45,7 +45,7 @@ int proc_get_write_reg(char *page, char **start,
 int proc_set_write_reg(struct file *file, const char __user *buffer,
                unsigned long count, void *data)
 {
-       struct net_device *dev = (struct net_device *)data;
+       struct net_device *dev = data;
        struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
        char tmp[32];
        u32 addr, val, len;
@@ -577,7 +577,7 @@ int proc_get_rx_signal(char *page, char **start,
 int proc_set_rx_signal(struct file *file, const char __user *buffer,
                unsigned long count, void *data)
 {
-       struct net_device *dev = (struct net_device *)data;
+       struct net_device *dev = data;
        struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
        char tmp[32];
        u32 is_signal_dbg;
@@ -627,7 +627,7 @@ int proc_get_ht_enable(char *page, char **start,
 int proc_set_ht_enable(struct file *file, const char __user *buffer,
                unsigned long count, void *data)
 {
-       struct net_device *dev = (struct net_device *)data;
+       struct net_device *dev = data;
        struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
        struct registry_priv    *pregpriv = &padapter->registrypriv;
        char tmp[32];
@@ -669,7 +669,7 @@ int proc_get_cbw40_enable(char *page, char **start,
 int proc_set_cbw40_enable(struct file *file, const char __user *buffer,
                unsigned long count, void *data)
 {
-       struct net_device *dev = (struct net_device *)data;
+       struct net_device *dev = data;
        struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
        struct registry_priv    *pregpriv = &padapter->registrypriv;
        char tmp[32];
@@ -710,7 +710,7 @@ int proc_get_ampdu_enable(char *page, char **start,
 int proc_set_ampdu_enable(struct file *file, const char __user *buffer,
                unsigned long count, void *data)
 {
-       struct net_device *dev = (struct net_device *)data;
+       struct net_device *dev = data;
        struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
        struct registry_priv    *pregpriv = &padapter->registrypriv;
        char tmp[32];
@@ -771,7 +771,7 @@ int proc_get_rx_stbc(char *page, char **start,
 int proc_set_rx_stbc(struct file *file, const char __user *buffer,
                unsigned long count, void *data)
 {
-       struct net_device *dev = (struct net_device *)data;
+       struct net_device *dev = data;
        struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
        struct registry_priv    *pregpriv = &padapter->registrypriv;
        char tmp[32];
@@ -800,7 +800,7 @@ int proc_get_rssi_disp(char *page, char **start,
 int proc_set_rssi_disp(struct file *file, const char __user *buffer,
                unsigned long count, void *data)
 {
-       struct net_device *dev = (struct net_device *)data;
+       struct net_device *dev = data;
        struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
        char tmp[32];
        u32 enable = 0;
index 7006088..c47b157 100644 (file)
@@ -106,13 +106,13 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
        efuseTbl = kzalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL);
        if (efuseTbl == NULL) {
                DBG_88E("%s: alloc efuseTbl fail!\n", __func__);
-               goto exit;
+               return;
        }
 
        eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16));
        if (eFuseWord == NULL) {
                DBG_88E("%s: alloc eFuseWord fail!\n", __func__);
-               goto exit;
+               goto eFuseWord_failed;
        }
 
        /*  0. Refresh efuse init map as all oxFF. */
@@ -210,10 +210,10 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
        /*  */
 
 exit:
-       kfree(efuseTbl);
+       kfree(eFuseWord);
 
-       if (eFuseWord)
-               kfree(eFuseWord);
+eFuseWord_failed:
+       kfree(efuseTbl);
 }
 
 static void efuse_read_phymap_from_txpktbuf(
@@ -250,7 +250,7 @@ static void efuse_read_phymap_from_txpktbuf(
                while (!(reg_0x143 = usb_read8(adapter, REG_TXPKTBUF_DBG)) &&
                       (passing_time = rtw_get_passing_time_ms(start)) < 1000) {
                        DBG_88E("%s polling reg_0x143:0x%02x, reg_0x106:0x%02x\n", __func__, reg_0x143, usb_read8(adapter, 0x106));
-                       msleep(1);
+                       usleep_range(1000, 2000);
                }
 
                lo32 = usb_read32(adapter, REG_PKTBUF_DBG_DATA_L);
@@ -322,7 +322,6 @@ void efuse_ReadEFuse(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _si
                iol_read_efuse(Adapter, 0, _offset, _size_byte, pbuf);
                iol_mode_enable(Adapter, 0);
        }
-       return;
 }
 
 /* Do not support BT */
@@ -332,56 +331,56 @@ void EFUSE_GetEfuseDefinition(struct adapter *pAdapter, u8 efuseType, u8 type, v
        case TYPE_EFUSE_MAX_SECTION:
                {
                        u8 *pMax_section;
-                       pMax_section = (u8 *)pOut;
+                       pMax_section = pOut;
                        *pMax_section = EFUSE_MAX_SECTION_88E;
                }
                break;
        case TYPE_EFUSE_REAL_CONTENT_LEN:
                {
                        u16 *pu2Tmp;
-                       pu2Tmp = (u16 *)pOut;
+                       pu2Tmp = pOut;
                        *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E;
                }
                break;
        case TYPE_EFUSE_CONTENT_LEN_BANK:
                {
                        u16 *pu2Tmp;
-                       pu2Tmp = (u16 *)pOut;
+                       pu2Tmp = pOut;
                        *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E;
                }
                break;
        case TYPE_AVAILABLE_EFUSE_BYTES_BANK:
                {
                        u16 *pu2Tmp;
-                       pu2Tmp = (u16 *)pOut;
+                       pu2Tmp = pOut;
                        *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E);
                }
                break;
        case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL:
                {
                        u16 *pu2Tmp;
-                       pu2Tmp = (u16 *)pOut;
+                       pu2Tmp = pOut;
                        *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E);
                }
                break;
        case TYPE_EFUSE_MAP_LEN:
                {
                        u16 *pu2Tmp;
-                       pu2Tmp = (u16 *)pOut;
+                       pu2Tmp = pOut;
                        *pu2Tmp = (u16)EFUSE_MAP_LEN_88E;
                }
                break;
        case TYPE_EFUSE_PROTECT_BYTES_BANK:
                {
                        u8 *pu1Tmp;
-                       pu1Tmp = (u8 *)pOut;
+                       pu1Tmp = pOut;
                        *pu1Tmp = (u8)(EFUSE_OOB_PROTECT_BYTES_88E);
                }
                break;
        default:
                {
                        u8 *pu1Tmp;
-                       pu1Tmp = (u8 *)pOut;
+                       pu1Tmp = pOut;
                        *pu1Tmp = 0;
                }
                break;
index fc280ce..2faf6b2 100644 (file)
@@ -98,7 +98,6 @@ u8 rtw_do_join(struct adapter *padapter)
 
                                pibss = padapter->registrypriv.dev_network.MacAddress;
 
-                               memset(&pdev_network->Ssid, 0, sizeof(struct ndis_802_11_ssid));
                                memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid));
 
                                rtw_update_registrypriv_dev_network(padapter);
index 384be22..2aa6251 100644 (file)
@@ -28,7 +28,7 @@
 /*  */
 void BlinkTimerCallback(void *data)
 {
-       struct LED_871x *pLed = (struct LED_871x *)data;
+       struct LED_871x *pLed = data;
        struct adapter *padapter = pLed->padapter;
 
        if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped))
index 149c271..dec26a8 100644 (file)
@@ -674,7 +674,6 @@ void rtw_surveydone_event_callback(struct adapter   *adapter, u8 *pbuf)
 
                                        RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("switching to adhoc master\n"));
 
-                                       memset(&pdev_network->Ssid, 0, sizeof(struct ndis_802_11_ssid));
                                        memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid));
 
                                        rtw_update_registrypriv_dev_network(adapter);
@@ -1334,7 +1333,6 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf)
 
                        memcpy(pdev_network, &tgt_network->network, get_wlan_bssid_ex_sz(&tgt_network->network));
 
-                       memset(&pdev_network->Ssid, 0, sizeof(struct ndis_802_11_ssid));
                        memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid));
 
                        rtw_update_registrypriv_dev_network(adapter);
@@ -1364,7 +1362,7 @@ void rtw_cpwm_event_callback(struct adapter *padapter, u8 *pbuf)
 */
 void _rtw_join_timeout_handler (void *function_context)
 {
-       struct adapter *adapter = (struct adapter *)function_context;
+       struct adapter *adapter = function_context;
        struct  mlme_priv *pmlmepriv = &adapter->mlmepriv;
        int do_join_r;
 
@@ -1406,7 +1404,7 @@ void _rtw_join_timeout_handler (void *function_context)
 */
 void rtw_scan_timeout_handler (void *function_context)
 {
-       struct adapter *adapter = (struct adapter *)function_context;
+       struct adapter *adapter = function_context;
        struct  mlme_priv *pmlmepriv = &adapter->mlmepriv;
 
        DBG_88E(FUNC_ADPT_FMT" fw_state=%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv));
@@ -1437,7 +1435,7 @@ void rtw_dynamic_check_timer_handlder(void *function_context)
        struct registry_priv *pregistrypriv = &adapter->registrypriv;
 
        if (!adapter)
-               goto exit;
+               return;
        if (!adapter->hw_init_completed)
                goto exit;
        if ((adapter->bDriverStopped) || (adapter->bSurpriseRemoved))
index 5ba5099..a00ebcd 100644 (file)
@@ -945,7 +945,7 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame
        }
 
        pstat = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
-       if (pstat == (struct sta_info *)NULL) {
+       if (pstat == NULL) {
                status = _RSON_CLS2_;
                goto asoc_class2_error;
        }
@@ -4835,7 +4835,7 @@ void linked_status_chk(struct adapter *padapter)
 
 void survey_timer_hdl(void *function_context)
 {
-       struct adapter *padapter = (struct adapter *)function_context;
+       struct adapter *padapter = function_context;
        struct cmd_obj  *ph2c;
        struct sitesurvey_parm  *psurveyPara;
        struct cmd_priv                                 *pcmdpriv = &padapter->cmdpriv;
@@ -4912,7 +4912,7 @@ void link_timer_hdl(void *function_context)
 
 void addba_timer_hdl(void *function_context)
 {
-       struct sta_info *psta = (struct sta_info *)function_context;
+       struct sta_info *psta = function_context;
        struct ht_priv  *phtpriv;
 
        if (!psta)
index 27ed83c..768dbee 100644 (file)
@@ -284,7 +284,7 @@ exit:
 
 static void pwr_state_check_handler(void *FunctionContext)
 {
-       struct adapter *padapter = (struct adapter *)FunctionContext;
+       struct adapter *padapter = FunctionContext;
        rtw_ps_cmd(padapter);
 }
 
index 4d56dba..53a054c 100644 (file)
@@ -1949,7 +1949,7 @@ _err_exit:
 
 void rtw_reordering_ctrl_timeout_handler(void *pcontext)
 {
-       struct recv_reorder_ctrl *preorder_ctrl = (struct recv_reorder_ctrl *)pcontext;
+       struct recv_reorder_ctrl *preorder_ctrl = pcontext;
        struct adapter *padapter = preorder_ctrl->padapter;
        struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;
 
index f9096a5..1baa98e 100644 (file)
@@ -1219,7 +1219,7 @@ u32       rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe)
        pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset;
 
        /* 4 start to encrypt each fragment */
-       if ((pattrib->encrypt == _AES_)) {
+       if (pattrib->encrypt == _AES_) {
                if (pattrib->psta)
                        stainfo = pattrib->psta;
                else
@@ -1460,7 +1460,7 @@ u32       rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)
        u32     res = _SUCCESS;
        pframe = (unsigned char *)((struct recv_frame *)precvframe)->rx_data;
        /* 4 start to encrypt each fragment */
-       if ((prxattrib->encrypt == _AES_)) {
+       if (prxattrib->encrypt == _AES_) {
                stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]);
                if (stainfo != NULL) {
                        RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_decrypt: stainfo!= NULL!!!\n"));
index 33ccbbb..c495977 100644 (file)
@@ -1394,7 +1394,6 @@ unsigned char check_assoc_AP(u8 *pframe, uint len)
                                DBG_88E("link to Artheros AP\n");
                                return HT_IOT_PEER_ATHEROS;
                        } else if ((!memcmp(pIE->data, BROADCOM_OUI1, 3)) ||
-                                  (!memcmp(pIE->data, BROADCOM_OUI2, 3)) ||
                                   (!memcmp(pIE->data, BROADCOM_OUI2, 3))) {
                                DBG_88E("link to Broadcom AP\n");
                                return HT_IOT_PEER_BROADCOM;
index 80e8cc9..c2d166f 100644 (file)
@@ -173,7 +173,7 @@ static bool set_baseband_agc_config(struct adapter *adapt)
                u32 v1 = array[i];
                u32 v2 = array[i+1];
 
-               if (v1 < 0xCDCDCDCD){
+               if (v1 < 0xCDCDCDCD) {
                        phy_set_bb_reg(adapt, v1, bMaskDWord, v2);
                        udelay(1);
                }
index d6fe5e6..68db5c9 100644 (file)
@@ -181,7 +181,7 @@ static void rtl8188e_SetHalODMVar(struct adapter *Adapter, enum hal_odm_variable
        switch (eVariable) {
        case HAL_ODM_STA_INFO:
                {
-                       struct sta_info *psta = (struct sta_info *)pValue1;
+                       struct sta_info *psta = pValue1;
                        if (bSet) {
                                DBG_88E("### Set STA_(%d) info\n", psta->mac_id);
                                ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, psta);
index 7a4f754..a6ba53b 100644 (file)
@@ -25,7 +25,7 @@
 
 void dump_txrpt_ccx_88e(void *buf)
 {
-       struct txrpt_ccx_88e *txrpt_ccx = (struct txrpt_ccx_88e *)buf;
+       struct txrpt_ccx_88e *txrpt_ccx = buf;
 
        DBG_88E("%s:\n"
                "tag1:%u, pkt_num:%u, txdma_underflow:%u, int_bt:%u, int_tri:%u, int_ccx:%u\n"
index caf2ca3..ac6abac 100644 (file)
@@ -1673,7 +1673,7 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val)
                        pRegToSet = RegToSet_Normal; /*  0xb972a841; */
                        FactorToSet = *((u8 *)val);
                        if (FactorToSet <= 3) {
-                               FactorToSet = (1<<(FactorToSet + 2));
+                               FactorToSet = 1 << (FactorToSet + 2);
                                if (FactorToSet > 0xf)
                                        FactorToSet = 0xf;
 
index db7b44e..914f831 100644 (file)
@@ -83,9 +83,8 @@
 #define ODM_COMP_INIT                                  BIT31
 
 /*------------------------Export Marco Definition---------------------------*/
-#define DbgPrint       pr_info
 #define RT_PRINTK(fmt, args...)                                \
-       DbgPrint("%s(): " fmt, __func__, ## args);
+       pr_info("%s(): " fmt, __func__, ## args);
 
 #ifndef ASSERT
        #define ASSERT(expr)
 #define ODM_RT_TRACE(pDM_Odm, comp, level, fmt)                                \
        if (((comp) & pDM_Odm->DebugComponents) &&                      \
            (level <= pDM_Odm->DebugLevel)) {                           \
-               DbgPrint("[ODM-8188E] ");                               \
-               RT_PRINTK fmt;                                          \
-       }
-
-#define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt)                      \
-       if (((comp) & pDM_Odm->DebugComponents) &&                      \
-           (level <= pDM_Odm->DebugLevel)) {                           \
+               pr_info("[ODM-8188E] ");                                \
                RT_PRINTK fmt;                                          \
        }
 
 #define ODM_RT_ASSERT(pDM_Odm, expr, fmt)                              \
        if (!(expr)) {                                                  \
-               DbgPrint("Assertion failed! %s at ......\n", #expr);    \
-               DbgPrint("      ......%s,%s,line=%d\n", __FILE__,       \
+               pr_info("Assertion failed! %s at ......\n", #expr);     \
+               pr_info("      ......%s,%s,line=%d\n", __FILE__,        \
                        __func__, __LINE__);                            \
                RT_PRINTK fmt;                                          \
                ASSERT(false);                                          \
        }
-#define ODM_dbg_enter() { DbgPrint("==> %s\n", __func__); }
-#define ODM_dbg_exit() { DbgPrint("<== %s\n", __func__); }
-#define ODM_dbg_trace(str) { DbgPrint("%s:%s\n", __func__, str); }
-
-#define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr)           \
-       if (((comp) & pDM_Odm->DebugComponents) &&                      \
-           (level <= pDM_Odm->DebugLevel)) {                           \
-               int __i;                                                \
-               u8 *__ptr = (u8 *)ptr;                                  \
-               DbgPrint("[ODM] ");                                     \
-               DbgPrint(title_str);                                    \
-               DbgPrint(" ");                                          \
-               for (__i = 0; __i < 6; __i++)                           \
-                       DbgPrint("%02X%s", __ptr[__i], (__i == 5)?"":"-");\
-               DbgPrint("\n");                                         \
-       }
 
 void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm);
 
index d598fec..08ba7d3 100644 (file)
@@ -512,14 +512,12 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
        }
 
        if (ielen) {
-               buf = kzalloc(ielen, GFP_KERNEL);
+               buf = kmemdup(pie, ielen, GFP_KERNEL);
                if (buf == NULL) {
                        ret =  -ENOMEM;
                        goto exit;
                }
 
-               memcpy(buf, pie, ielen);
-
                /* dump */
                {
                        int i;
@@ -1136,7 +1134,8 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
                struct iw_scan_req *req = (struct iw_scan_req *)extra;
 
                if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
-                       int len = min((int)req->essid_len, IW_ESSID_MAX_SIZE);
+                       int len = min_t(int, req->essid_len,
+                                       IW_ESSID_MAX_SIZE);
 
                        memcpy(ssid[0].Ssid, req->essid, len);
                        ssid[0].SsidLength = len;
@@ -2699,10 +2698,8 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param,
 
        ie_len = len-12-2;/*  12 = param header, 2:no packed */
 
-       if (pmlmepriv->wps_beacon_ie) {
-               kfree(pmlmepriv->wps_beacon_ie);
-               pmlmepriv->wps_beacon_ie = NULL;
-       }
+       kfree(pmlmepriv->wps_beacon_ie);
+       pmlmepriv->wps_beacon_ie = NULL;
 
        if (ie_len > 0) {
                pmlmepriv->wps_beacon_ie = rtw_malloc(ie_len);
@@ -2736,10 +2733,8 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *par
 
        ie_len = len-12-2;/*  12 = param header, 2:no packed */
 
-       if (pmlmepriv->wps_probe_resp_ie) {
-               kfree(pmlmepriv->wps_probe_resp_ie);
-               pmlmepriv->wps_probe_resp_ie = NULL;
-       }
+       kfree(pmlmepriv->wps_probe_resp_ie);
+       pmlmepriv->wps_probe_resp_ie = NULL;
 
        if (ie_len > 0) {
                pmlmepriv->wps_probe_resp_ie = rtw_malloc(ie_len);
@@ -2768,10 +2763,8 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *par
 
        ie_len = len-12-2;/*  12 = param header, 2:no packed */
 
-       if (pmlmepriv->wps_assoc_resp_ie) {
-               kfree(pmlmepriv->wps_assoc_resp_ie);
-               pmlmepriv->wps_assoc_resp_ie = NULL;
-       }
+       kfree(pmlmepriv->wps_assoc_resp_ie);
+       pmlmepriv->wps_assoc_resp_ie = NULL;
 
        if (ie_len > 0) {
                pmlmepriv->wps_assoc_resp_ie = rtw_malloc(ie_len);
index 8af4a8d..abcb3a8 100644 (file)
@@ -51,7 +51,7 @@ void *rtw_malloc2d(int h, int w, int size)
 {
        int j;
 
-       void **a = (void **)kzalloc(h*sizeof(void *) + h*w*size, GFP_KERNEL);
+       void **a = kzalloc(h*sizeof(void *) + h*w*size, GFP_KERNEL);
        if (a == NULL) {
                pr_info("%s: alloc memory fail!\n", __func__);
                return NULL;
index 407a318..65a257f 100644 (file)
@@ -556,8 +556,6 @@ static void rtw_dev_remove(struct usb_interface *pusb_intf)
 
        RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-dev_remove()\n"));
        DBG_88E("-r871xu_dev_remove, done\n");
-
-       return;
 }
 
 static struct usb_driver rtl8188e_usb_drv = {
index ba1e178..7da85f9 100644 (file)
@@ -843,7 +843,7 @@ void usb_write_port_cancel(struct adapter *padapter)
 void rtl8188eu_recv_tasklet(void *priv)
 {
        struct sk_buff *pskb;
-       struct adapter *adapt = (struct adapter *)priv;
+       struct adapter *adapt = priv;
        struct recv_priv *precvpriv = &adapt->recvpriv;
 
        while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue))) {
@@ -862,7 +862,7 @@ void rtl8188eu_recv_tasklet(void *priv)
 void rtl8188eu_xmit_tasklet(void *priv)
 {
        int ret = false;
-       struct adapter *adapt = (struct adapter *)priv;
+       struct adapter *adapt = priv;
        struct xmit_priv *pxmitpriv = &adapt->xmitpriv;
 
        if (check_fwstate(&adapt->mlmepriv, _FW_UNDER_SURVEY))
index 0ffed2d..552d943 100644 (file)
@@ -1287,7 +1287,7 @@ void  rtl8192_tx_fill_desc(struct net_device *dev, struct tx_desc *pdesc,
 
 void  rtl8192_tx_fill_cmd_desc(struct net_device *dev,
                               struct tx_desc_cmd *entry,
-                              struct cb_desc *cb_desc, struct sk_buffskb)
+                              struct cb_desc *cb_desc, struct sk_buff *skb)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len,
@@ -1302,7 +1302,7 @@ void  rtl8192_tx_fill_cmd_desc(struct net_device *dev,
        if (cb_desc->bCmdOrInit == DESC_PACKET_TYPE_INIT) {
                entry->CmdInit = DESC_PACKET_TYPE_INIT;
        } else {
-               struct tx_desc * entry_tmp = (struct tx_desc *)entry;
+               struct tx_desc *entry_tmp = (struct tx_desc *)entry;
 
                entry_tmp->CmdInit = DESC_PACKET_TYPE_NORMAL;
                entry_tmp->Offset = sizeof(struct tx_fwinfo_8190pci) + 8;
index b6ce8c3..885315c 100644 (file)
@@ -1449,13 +1449,11 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool  bInCH14)
                          (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ;
 
                rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
-               TempVal = 0;
                TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] +
                          (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) +
                          (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16)+
                          (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24));
                rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal);
-               TempVal = 0;
                TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] +
                          (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ;
 
@@ -1465,13 +1463,11 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool  bInCH14)
                          (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ;
 
                rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
-               TempVal = 0;
                TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] +
                          (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) +
                          (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16)+
                          (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24));
                rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal);
-               TempVal = 0;
                TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] +
                          (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ;
 
@@ -1493,7 +1489,6 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev,      bool  bInCH
                rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
                RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n",
                        rCCK0_TxFilter1, TempVal);
-               TempVal = 0;
                TempVal =       CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] +
                                        (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3]<<8) +
                                        (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16)+
@@ -1501,7 +1496,6 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev,      bool  bInCH
                rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal);
                RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n",
                        rCCK0_TxFilter2, TempVal);
-               TempVal = 0;
                TempVal =       CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] +
                                        (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7]<<8) ;
 
@@ -1515,7 +1509,6 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev,      bool  bInCH
                rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
                RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n",
                        rCCK0_TxFilter1, TempVal);
-               TempVal = 0;
                TempVal =       CCKSwingTable_Ch14[priv->CCK_index][2] +
                                        (CCKSwingTable_Ch14[priv->CCK_index][3]<<8) +
                                        (CCKSwingTable_Ch14[priv->CCK_index][4]<<16)+
@@ -1523,7 +1516,6 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev,      bool  bInCH
                rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal);
                RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n",
                        rCCK0_TxFilter2, TempVal);
-               TempVal = 0;
                TempVal =       CCKSwingTable_Ch14[priv->CCK_index][6] +
                                        (CCKSwingTable_Ch14[priv->CCK_index][7]<<8) ;
 
index 6da5784..2866c12 100644 (file)
@@ -79,7 +79,7 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst,
        struct sk_buff *skb = NULL;
         struct rtllib_hdr_3addr *BAReq = NULL;
        u8 *tag = NULL;
-       u16 tmp = 0;
+       __le16 tmp = 0;
        u16 len = ieee->tx_headroom + 9;
 
        RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), frame(%d)"
@@ -115,14 +115,14 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst,
 
        if (ACT_ADDBARSP == type) {
                RT_TRACE(COMP_DBG, "====>to send ADDBARSP\n");
-               tmp = StatusCode;
+               tmp = cpu_to_le16(StatusCode);
                memcpy(tag, (u8 *)&tmp, 2);
                tag += 2;
        }
-       tmp = pBA->BaParamSet.shortData;
+       tmp = cpu_to_le16(pBA->BaParamSet.shortData);
        memcpy(tag, (u8 *)&tmp, 2);
        tag += 2;
-       tmp = pBA->BaTimeoutValue;
+       tmp = cpu_to_le16(pBA->BaTimeoutValue);
        memcpy(tag, (u8 *)&tmp, 2);
        tag += 2;
 
@@ -143,7 +143,7 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst,
        struct sk_buff *skb = NULL;
         struct rtllib_hdr_3addr *Delba = NULL;
        u8 *tag = NULL;
-       u16 tmp = 0;
+       __le16 tmp = 0;
        u16 len = 6 + ieee->tx_headroom;
 
        if (net_ratelimit())
@@ -178,10 +178,10 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst,
        *tag++ = ACT_CAT_BA;
        *tag++ = ACT_DELBA;
 
-       tmp = DelbaParamSet.shortData;
+       tmp = cpu_to_le16(DelbaParamSet.shortData);
        memcpy(tag, (u8 *)&tmp, 2);
        tag += 2;
-       tmp = ReasonCode;
+       tmp = cpu_to_le16(ReasonCode);
        memcpy(tag, (u8 *)&tmp, 2);
        tag += 2;
 
index 2d82f89..cef2dc2 100644 (file)
@@ -2762,8 +2762,6 @@ extern void rtllib_stop_scan(struct rtllib_device *ieee);
 extern bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan);
 extern void rtllib_stop_scan_syncro(struct rtllib_device *ieee);
 extern void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
-extern inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee);
-extern u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee);
 extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee,
                                          short pwr);
 extern void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl);
@@ -2944,12 +2942,12 @@ void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
 
 extern const long rtllib_wlan_frequencies[];
 
-extern inline void rtllib_increment_scans(struct rtllib_device *ieee)
+static inline void rtllib_increment_scans(struct rtllib_device *ieee)
 {
        ieee->scans++;
 }
 
-extern inline int rtllib_get_scans(struct rtllib_device *ieee)
+static inline int rtllib_get_scans(struct rtllib_device *ieee)
 {
        return ieee->scans;
 }
index 1c2014f..ca76ad0 100644 (file)
@@ -1415,10 +1415,6 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
        return 1;
 
  rx_dropped:
-       if (rxb != NULL) {
-               kfree(rxb);
-               rxb = NULL;
-       }
        ieee->stats.rx_dropped++;
 
        /* Returning 0 indicates to caller that we have not handled the SKB--
index abb6729..e970db4 100644 (file)
@@ -193,7 +193,7 @@ MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee)
        return QueryRate;
 }
 
-u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee)
+static u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee)
 {
        struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
        u8 rate;
@@ -343,7 +343,7 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb,
        }
 }
 
-inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee)
+static inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee)
 {
        unsigned int len, rate_len;
        u8 *tag;
@@ -1311,7 +1311,7 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,
        }
 
        if (beacon->bCkipSupported) {
-               static u8       AironetIeOui[] = {0x00, 0x01, 0x66};
+               static const u8 AironetIeOui[] = {0x00, 0x01, 0x66};
                u8      CcxAironetBuf[30];
                struct octet_string osCcxAironetIE;
 
@@ -1331,10 +1331,11 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,
        }
 
        if (beacon->bCcxRmEnable) {
-               static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00};
+               static const u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01,
+                       0x00};
                struct octet_string osCcxRmCap;
 
-               osCcxRmCap.Octet = CcxRmCapBuf;
+               osCcxRmCap.Octet = (u8 *) CcxRmCapBuf;
                osCcxRmCap.Length = sizeof(CcxRmCapBuf);
                tag = skb_put(skb, ccxrm_ie_len);
                *tag++ = MFIE_TYPE_GENERIC;
index 73de9e9..d401dbf 100644 (file)
@@ -713,8 +713,8 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee,
        while(!list_empty(&pTS->RxPendingPktList)) {
                IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): start RREORDER indicate\n",__func__);
                pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List);
-               ifSN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) ||
-                               SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq))
+               if (SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) ||
+                   SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq))
                {
                        /* This protect buffer from overflow. */
                        if(index >= REORDER_WIN_SIZE) {
@@ -800,9 +800,8 @@ static u8 parse_subframe(struct sk_buff *skb,
        // Null packet, don't indicate it to upper layer
        ChkLength = LLCOffset;/* + (Frame_WEP(frame)!=0 ?Adapter->MgntInfo.SecurityInfo.EncryptionHeadOverhead:0);*/
 
-       if( skb->len <= ChkLength ) {
+       if (skb->len <= ChkLength)
                return 0;
-       }
 
        skb_pull(skb, LLCOffset);
 
@@ -1035,10 +1034,9 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                {
 
                //      IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pRxTS->RxLastFragNum is %d,frag is %d,pRxTS->RxLastSeqNum is %d,seq is %d\n",__func__,pRxTS->RxLastFragNum,frag,pRxTS->RxLastSeqNum,WLAN_GET_SEQ_SEQ(sc));
-                       if(     (fc & (1<<11))  &&
-                                       (frag == pRxTS->RxLastFragNum) &&
-                                       (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum)   )
-                       {
+                       if ((fc & (1<<11)) &&
+                           (frag == pRxTS->RxLastFragNum) &&
+                           (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum)) {
                                goto rx_dropped;
                        }
                        else
@@ -2456,7 +2454,7 @@ static inline void ieee80211_process_probe_response(
        //       then wireless adapter should do active scan from ch1~11 and
        //       passive scan from ch12~14
 
-       if( !IsLegalChannel(ieee, network.channel) )
+       if (!IsLegalChannel(ieee, network.channel))
                return;
        if(ieee->bGlobalDomain)
        {
@@ -2465,8 +2463,7 @@ static inline void ieee80211_process_probe_response(
                        // Case 1: Country code
                        if(IS_COUNTRY_IE_VALID(ieee) )
                        {
-                               if( !IsLegalChannel(ieee, network.channel) )
-                               {
+                               if (!IsLegalChannel(ieee, network.channel)) {
                                        printk("GetScanInfo(): For Country code, filter probe response at channel(%d).\n", network.channel);
                                        return;
                                }
@@ -2487,8 +2484,7 @@ static inline void ieee80211_process_probe_response(
                        // Case 1: Country code
                        if(IS_COUNTRY_IE_VALID(ieee) )
                        {
-                               if( !IsLegalChannel(ieee, network.channel) )
-                               {
+                               if (!IsLegalChannel(ieee, network.channel)) {
                                        printk("GetScanInfo(): For Country code, filter beacon at channel(%d).\n",network.channel);
                                        return;
                                }
index a85bb23..9b87408 100644 (file)
@@ -411,7 +411,7 @@ static void ieee80211_send_probe(struct ieee80211_device *ieee)
        }
 }
 
-void ieee80211_send_probe_requests(struct ieee80211_device *ieee)
+static void ieee80211_send_probe_requests(struct ieee80211_device *ieee)
 {
        if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){
                ieee80211_send_probe(ieee);
@@ -517,7 +517,7 @@ static void ieee80211_softmac_scan_wq(struct work_struct *work)
                goto out;
        ieee->set_chan(ieee->dev, ieee->current_network.channel);
        if(channel_map[ieee->current_network.channel] == 1)
-       ieee80211_send_probe_requests(ieee);
+               ieee80211_send_probe_requests(ieee);
 
 
        queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME);
@@ -1043,10 +1043,9 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
        {
                ccxrm_ie_len = 6+2;
        }
-       if( beacon->BssCcxVerNumber >= 2 )
-       {
+       if (beacon->BssCcxVerNumber >= 2)
                cxvernum_ie_len = 5+2;
-       }
+
 #ifdef THOMAS_TURBO
        len = sizeof(struct ieee80211_assoc_request_frame)+ 2
                + beacon->ssid_len//essid tagged val
@@ -1103,7 +1102,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
        if(ieee->short_slot)
                hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT);
        if (wmm_info_len) //QOS
-       hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_QOS);
+               hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_QOS);
 
        hdr->listen_interval = 0xa; //FIXME
 
@@ -1118,8 +1117,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
        ieee80211_MFIE_Brate(ieee, &tag);
        ieee80211_MFIE_Grate(ieee, &tag);
        // For CCX 1 S13, CKIP. Added by Annie, 2006-08-14.
-       if( beacon->bCkipSupported )
-       {
+       if (beacon->bCkipSupported) {
                static u8       AironetIeOui[] = {0x00, 0x01, 0x66}; // "4500-client"
                u8      CcxAironetBuf[30];
                OCTET_STRING    osCcxAironetIE;
@@ -1158,8 +1156,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
                tag += osCcxRmCap.Length;
        }
 
-       if( beacon->BssCcxVerNumber >= 2 )
-       {
+       if (beacon->BssCcxVerNumber >= 2) {
                u8                      CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00};
                OCTET_STRING    osCcxVerNum;
                CcxVerNumBuf[4] = beacon->BssCcxVerNumber;
@@ -1533,7 +1530,7 @@ void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee)
                        break;
 
                if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies))
-               ieee80211_softmac_new_net(ieee, target);
+                       ieee80211_softmac_new_net(ieee, target);
        }
 
        spin_unlock_irqrestore(&ieee->lock, flags);
index 82ea533..644368d 100644 (file)
@@ -374,7 +374,7 @@ int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info
                goto out;
        }
 
-       if ( ieee->state == IEEE80211_LINKED){
+       if (ieee->state == IEEE80211_LINKED) {
                queue_work(ieee->wq, &ieee->wx_sync_scan_wq);
                /* intentionally forget to up sem */
                return 0;
index 57bef21..fca73c7 100644 (file)
@@ -529,8 +529,7 @@ static void ieee80211_query_protectionmode(struct ieee80211_device *ieee,
                }
                }
        // For test , CTS replace with RTS
-       if( 0 )
-       {
+       if (0) {
                tcb_desc->bCTSEnable    = true;
                tcb_desc->rts_rate = MGN_24M;
                tcb_desc->bRTSEnable    = true;
index 68f5ede..ae1b3cf 100644 (file)
@@ -172,7 +172,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
        iwe.cmd = IWEVCUSTOM;
        iwe.u.data.length = p - custom;
        if (iwe.u.data.length)
-       start = iwe_stream_add_point(info, start, stop, &iwe, custom);
+               start = iwe_stream_add_point(info, start, stop, &iwe, custom);
        /* Add quality statistics */
        /* TODO: Fix these values... */
        iwe.cmd = IWEVQUAL;
index 51552d4..cd196ce 100644 (file)
@@ -110,7 +110,7 @@ static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, P
        struct sk_buff *skb = NULL;
         struct ieee80211_hdr_3addr *BAReq = NULL;
        u8 *tag = NULL;
-       u16 tmp = 0;
+       __le16 tmp = 0;
        u16 len = ieee->tx_headroom + 9;
        //category(1) + action field(1) + Dialog Token(1) + BA Parameter Set(2) +  BA Timeout Value(2) +  BA Start SeqCtrl(2)(or StatusCode(2))
        IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), frame(%d) sentd to:%pM, ieee->dev:%p\n", __func__, type, Dst, ieee->dev);
@@ -196,7 +196,7 @@ static struct sk_buff *ieee80211_DELBA(
        struct sk_buff *skb = NULL;
         struct ieee80211_hdr_3addr *Delba = NULL;
        u8 *tag = NULL;
-       u16 tmp = 0;
+       __le16 tmp = 0;
        //len = head len + DELBA Parameter Set(2) + Reason Code(2)
        u16 len = 6 + ieee->tx_headroom;
 
@@ -342,8 +342,7 @@ int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb)
        PSEQUENCE_CONTROL pBaStartSeqCtrl = NULL;
        PRX_TS_RECORD   pTS = NULL;
 
-       if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9)
-       {
+       if (skb->len < sizeof(struct ieee80211_hdr_3addr) + 9) {
                IEEE80211_DEBUG(IEEE80211_DL_ERR,
                                " Invalid skb len in BAREQ(%d / %zu)\n",
                                skb->len,
@@ -444,8 +443,7 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb)
        PBA_PARAM_SET           pBaParamSet = NULL;
        u16                     ReasonCode;
 
-       if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9)
-       {
+       if (skb->len < sizeof(struct ieee80211_hdr_3addr) + 9) {
                IEEE80211_DEBUG(IEEE80211_DL_ERR,
                                " Invalid skb len in BARSP(%d / %zu)\n",
                                skb->len,
@@ -463,10 +461,9 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb)
 
        // Check the capability
        // Since we can always receive A-MPDU, we just check if it is under HT mode.
-       if(     ieee->current_network.qos_data.active == 0  ||
-               ieee->pHTInfo->bCurrentHTSupport == false ||
-               ieee->pHTInfo->bCurrentAMPDUEnable == false )
-       {
+       if (ieee->current_network.qos_data.active == 0  ||
+           ieee->pHTInfo->bCurrentHTSupport == false ||
+           ieee->pHTInfo->bCurrentAMPDUEnable == false) {
                IEEE80211_DEBUG(IEEE80211_DL_ERR, "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bCurrentAMPDUEnable);
                ReasonCode = DELBA_REASON_UNKNOWN_BA;
                goto OnADDBARsp_Reject;
@@ -577,8 +574,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb)
        u16                     *pReasonCode = NULL;
        u8                      *dst = NULL;
 
-       if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 6)
-       {
+       if (skb->len < sizeof(struct ieee80211_hdr_3addr) + 6) {
                IEEE80211_DEBUG(IEEE80211_DL_ERR,
                                " Invalid skb len in DELBA(%d / %zu)\n",
                                skb->len,
index 1ea2cd3..e60d926 100644 (file)
@@ -602,8 +602,7 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u
        // TODO: Nedd to take care of this part
        IEEE80211_DEBUG(IEEE80211_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk);
 
-       if( IsEncrypt)
-       {
+       if (IsEncrypt) {
                pCapELE->MPDUDensity    = 7; // 8us
                pCapELE->MaxRxAMPDUFactor       = 2; // 2 is for 32 K and 3 is 64K
        }
@@ -951,8 +950,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
        static u8                               EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33};               // For 11n EWC definition, 2007.07.17, by Emily
        static u8                               EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34};      // For 11n EWC definition, 2007.07.17, by Emily
 
-       if( pHTInfo->bCurrentHTSupport == false )
-       {
+       if (pHTInfo->bCurrentHTSupport == false) {
                IEEE80211_DEBUG(IEEE80211_DL_ERR, "<=== HTOnAssocRsp(): HT_DISABLE\n");
                return;
        }
@@ -1043,7 +1041,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
                // Replace MPDU factor declared in original association response frame format. 2007.08.20 by Emily
                if (ieee->current_network.bssht.bdRT2RTAggregation)
                {
-                       ifieee->pairwise_key_type != KEY_TYPE_NA)
+                       if (ieee->pairwise_key_type != KEY_TYPE_NA)
                                // Realtek may set 32k in security mode and 64k for others
                                pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
                        else
@@ -1332,8 +1330,7 @@ u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame)
 {
        if(ieee->pHTInfo->bCurrentHTSupport)
        {
-               if( (IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1)
-               {
+               if ((IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) {
                        IEEE80211_DEBUG(IEEE80211_DL_HT, "HT CONTROL FILED EXIST!!\n");
                        return true;
                }
index 929ac29..e031a25 100644 (file)
@@ -1791,8 +1791,8 @@ static void rtl8192_link_change(struct net_device *dev)
 }
 
 static struct ieee80211_qos_parameters def_qos_parameters = {
-       {3, 3, 3, 3},/* cw_min */
-       {7, 7, 7, 7},/* cw_max */
+       {cpu_to_le16(3), cpu_to_le16(3), cpu_to_le16(3), cpu_to_le16(3)},
+       {cpu_to_le16(7), cpu_to_le16(7), cpu_to_le16(7), cpu_to_le16(7)},
        {2, 2, 2, 2},/* aifs */
        {0, 0, 0, 0},/* flags */
        {0, 0, 0, 0} /* tx_op_limit */
@@ -1821,8 +1821,11 @@ static void rtl8192_qos_activate(struct work_struct *work)
        struct net_device *dev = priv->ieee80211->dev;
        struct ieee80211_qos_parameters *qos_parameters = &priv->ieee80211->current_network.qos_data.parameters;
        u8 mode = priv->ieee80211->current_network.mode;
-       u8  u1bAIFS;
+       u32  u1bAIFS;
        u32 u4bAcParam;
+       u32 op_limit;
+       u32 cw_max;
+       u32 cw_min;
        int i;
 
        mutex_lock(&priv->mutex);
@@ -1835,11 +1838,14 @@ static void rtl8192_qos_activate(struct work_struct *work)
        for (i = 0; i <  QOS_QUEUE_NUM; i++) {
                //Mode G/A: slotTimeTimer = 9; Mode B: 20
                u1bAIFS = qos_parameters->aifs[i] * ((mode&(IEEE_G|IEEE_N_24G)) ? 9 : 20) + aSifsTime;
-               u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[i]))<< AC_PARAM_TXOP_LIMIT_OFFSET)|
-                             (((u32)(qos_parameters->cw_max[i]))<< AC_PARAM_ECW_MAX_OFFSET)|
-                             (((u32)(qos_parameters->cw_min[i]))<< AC_PARAM_ECW_MIN_OFFSET)|
-                             ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET));
-
+               u1bAIFS <<= AC_PARAM_AIFS_OFFSET;
+               op_limit = (u32)le16_to_cpu(qos_parameters->tx_op_limit[i]);
+               op_limit <<= AC_PARAM_TXOP_LIMIT_OFFSET;
+               cw_max = (u32)le16_to_cpu(qos_parameters->cw_max[i]);
+               cw_max <<= AC_PARAM_ECW_MAX_OFFSET;
+               cw_min = (u32)le16_to_cpu(qos_parameters->cw_min[i]);
+               cw_min <<= AC_PARAM_ECW_MIN_OFFSET;
+               u4bAcParam = op_limit | cw_max | cw_min | u1bAIFS;
                write_nic_dword(dev, WDCAPARA_ADD[i], u4bAcParam);
        }
 
index b0b66fb..936565d 100644 (file)
@@ -1476,14 +1476,12 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool  bInCH14)
 
                rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
                //Write 0xa24 ~ 0xa27
-               TempVal = 0;
                TempVal =       priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[2] +
                                        (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[3]<<8) +
                                        (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[4]<<16)+
                                        (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[5]<<24);
                rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal);
                //Write 0xa28  0xa29
-               TempVal = 0;
                TempVal =       priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[6] +
                                        (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[7]<<8) ;
 
@@ -1496,14 +1494,12 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool  bInCH14)
 
                rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
                //Write 0xa24 ~ 0xa27
-               TempVal = 0;
                TempVal =       priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[2] +
                                        (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[3]<<8) +
                                        (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[4]<<16)+
                                        (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[5]<<24);
                rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal);
                //Write 0xa28  0xa29
-               TempVal = 0;
                TempVal =       priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[6] +
                                        (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[7]<<8) ;
 
@@ -1528,7 +1524,6 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev,      bool  bInCH
                RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n",
                        rCCK0_TxFilter1, TempVal);
                //Write 0xa24 ~ 0xa27
-               TempVal = 0;
                TempVal =       CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] +
                                        (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3]<<8) +
                                        (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16)+
@@ -1537,7 +1532,6 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev,      bool  bInCH
                RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n",
                        rCCK0_TxFilter2, TempVal);
                //Write 0xa28  0xa29
-               TempVal = 0;
                TempVal =       CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] +
                                        (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7]<<8) ;
 
@@ -1556,7 +1550,6 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev,      bool  bInCH
                RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n",
                        rCCK0_TxFilter1, TempVal);
                //Write 0xa24 ~ 0xa27
-               TempVal = 0;
                TempVal =       CCKSwingTable_Ch14[priv->CCK_index][2] +
                                        (CCKSwingTable_Ch14[priv->CCK_index][3]<<8) +
                                        (CCKSwingTable_Ch14[priv->CCK_index][4]<<16)+
@@ -1565,7 +1558,6 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev,      bool  bInCH
                RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n",
                        rCCK0_TxFilter2, TempVal);
                //Write 0xa28  0xa29
-               TempVal = 0;
                TempVal =       CCKSwingTable_Ch14[priv->CCK_index][6] +
                                        (CCKSwingTable_Ch14[priv->CCK_index][7]<<8) ;
 
@@ -1810,85 +1802,6 @@ void dm_change_dynamic_initgain_thresh(struct net_device *dev, u32 dm_type,
        }
 }      /* DM_ChangeDynamicInitGainThresh */
 
-void
-dm_change_rxpath_selection_setting(
-       struct net_device *dev,
-       s32             DM_Type,
-       s32             DM_Value)
-{
-       struct r8192_priv *priv = ieee80211_priv(dev);
-       prate_adaptive  pRA = (prate_adaptive)&(priv->rate_adaptive);
-
-
-       if(DM_Type == 0)
-       {
-               if(DM_Value > 1)
-                       DM_Value = 1;
-               DM_RxPathSelTable.Enable = (u8)DM_Value;
-       }
-       else if(DM_Type == 1)
-       {
-               if(DM_Value > 1)
-                       DM_Value = 1;
-               DM_RxPathSelTable.DbgMode = (u8)DM_Value;
-       }
-       else if(DM_Type == 2)
-       {
-               if(DM_Value > 40)
-                       DM_Value = 40;
-               DM_RxPathSelTable.SS_TH_low = (u8)DM_Value;
-       }
-       else if(DM_Type == 3)
-       {
-               if(DM_Value > 25)
-                       DM_Value = 25;
-               DM_RxPathSelTable.diff_TH = (u8)DM_Value;
-       }
-       else if(DM_Type == 4)
-       {
-               if(DM_Value >= CCK_Rx_Version_MAX)
-                       DM_Value = CCK_Rx_Version_1;
-               DM_RxPathSelTable.cck_method= (u8)DM_Value;
-       }
-       else if(DM_Type == 10)
-       {
-               if(DM_Value > 100)
-                       DM_Value = 50;
-               DM_RxPathSelTable.rf_rssi[0] = (u8)DM_Value;
-       }
-       else if(DM_Type == 11)
-       {
-               if(DM_Value > 100)
-                       DM_Value = 50;
-               DM_RxPathSelTable.rf_rssi[1] = (u8)DM_Value;
-       }
-       else if(DM_Type == 12)
-       {
-               if(DM_Value > 100)
-                       DM_Value = 50;
-               DM_RxPathSelTable.rf_rssi[2] = (u8)DM_Value;
-       }
-       else if(DM_Type == 13)
-       {
-               if(DM_Value > 100)
-                       DM_Value = 50;
-               DM_RxPathSelTable.rf_rssi[3] = (u8)DM_Value;
-       }
-       else if(DM_Type == 20)
-       {
-               if(DM_Value > 1)
-                       DM_Value = 1;
-               pRA->ping_rssi_enable = (u8)DM_Value;
-       }
-       else if(DM_Type == 21)
-       {
-               if(DM_Value > 30)
-                       DM_Value = 30;
-               pRA->ping_rssi_thresh_for_ra = DM_Value;
-       }
-}
-
-
 /*-----------------------------------------------------------------------------
  * Function:   dm_dig_init()
  *
@@ -3554,7 +3467,6 @@ static void dm_check_txrateandretrycount(struct net_device *dev)
 
 static void dm_send_rssi_tofw(struct net_device *dev)
 {
-       DCMD_TXCMD_T                    tx_cmd;
        struct r8192_priv *priv = ieee80211_priv(dev);
 
        // If we test chariot, we should stop the TX command ?
@@ -3562,9 +3474,6 @@ static void dm_send_rssi_tofw(struct net_device *dev)
        // 0x1e0(byte) to notify driver.
        write_nic_byte(dev, DRIVER_RSSI, (u8)priv->undecorated_smoothed_pwdb);
        return;
-       tx_cmd.Op               = TXCMD_SET_RX_RSSI;
-       tx_cmd.Length   = 4;
-       tx_cmd.Value            = priv->undecorated_smoothed_pwdb;
 }
 
 /*---------------------------Define function prototype------------------------*/
index 28f60d2..361d2d0 100644 (file)
@@ -171,7 +171,6 @@ static int r8192_wx_set_crcmon(struct net_device *dev,
        struct r8192_priv *priv = ieee80211_priv(dev);
        int *parms = (int *)extra;
        int enable = (parms[0] > 0);
-       short prev = priv->crcmon;
 
        down(&priv->wx_sem);
 
@@ -183,11 +182,6 @@ static int r8192_wx_set_crcmon(struct net_device *dev,
        DMESG("bad CRC in monitor mode are %s",
              priv->crcmon ? "accepted" : "rejected");
 
-       if (prev != priv->crcmon && priv->up) {
-               /* rtl8180_down(dev); */
-               /* rtl8180_up(dev); */
-       }
-
        up(&priv->wx_sem);
 
        return 0;
index f66ad8a..c230be2 100644 (file)
@@ -45,6 +45,7 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
        unsigned char       *seg_ptr;
        cb_desc             *tcb_desc;
        u8                  bLastIniPkt;
+       u8                  index;
 
        firmware_init_param(dev);
        //Fragmentation might be required
@@ -78,18 +79,19 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
                 * Transform from little endian to big endian
                 * and pending  zero
                 */
-               for (i=0; i < frag_length; i+=4) {
-                       *seg_ptr++ = ((i+0)<frag_length)?code_virtual_address[i+3]:0;
-                       *seg_ptr++ = ((i+1)<frag_length)?code_virtual_address[i+2]:0;
-                       *seg_ptr++ = ((i+2)<frag_length)?code_virtual_address[i+1]:0;
-                       *seg_ptr++ = ((i+3)<frag_length)?code_virtual_address[i+0]:0;
+               for (i = 0; i < frag_length; i += 4) {
+                       *seg_ptr++ = ((i+0) < frag_length)?code_virtual_address[i+3] : 0;
+                       *seg_ptr++ = ((i+1) < frag_length)?code_virtual_address[i+2] : 0;
+                       *seg_ptr++ = ((i+2) < frag_length)?code_virtual_address[i+1] : 0;
+                       *seg_ptr++ = ((i+3) < frag_length)?code_virtual_address[i+0] : 0;
                }
-               tcb_desc->txbuf_size= (u16)i;
+               tcb_desc->txbuf_size = (u16)i;
                skb_put(skb, i);
 
-               if (!priv->ieee80211->check_nic_enough_desc(dev,tcb_desc->queue_index)||
-                       (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index]))||\
-                       (priv->ieee80211->queue_stop)) {
+               index = tcb_desc->queue_index;
+               if (!priv->ieee80211->check_nic_enough_desc(dev, index) ||
+                      (!skb_queue_empty(&priv->ieee80211->skb_waitQ[index])) ||
+                      (priv->ieee80211->queue_stop)) {
                        RT_TRACE(COMP_FIRMWARE,"=====================================================> tx full!\n");
                        skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb);
                } else {
index c48c884..cfa2223 100644 (file)
 #define GET_COMMAND_PACKET_FRAG_THRESHOLD(v)   (4*(v/4) - 8 - USB_HWDESC_HEADER_LEN)
 //#endif
 
-typedef enum _firmware_init_step{
+typedef enum _firmware_init_step {
        FW_INIT_STEP0_BOOT = 0,
        FW_INIT_STEP1_MAIN = 1,
        FW_INIT_STEP2_DATA = 2,
-}firmware_init_step_e;
+} firmware_init_step_e;
 
-typedef enum _opt_rst_type{
+typedef enum _opt_rst_type {
        OPT_SYSTEM_RESET = 0,
        OPT_FIRMWARE_RESET = 1,
-}opt_rst_type_e;
+} opt_rst_type_e;
 
 #endif
index e9c15fe..0589602 100644 (file)
@@ -1463,6 +1463,7 @@ void rtl8192_SwChnl_WorkItem(struct net_device *dev)
 u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
+
        RT_TRACE(COMP_CH, "%s(), SwChnlInProgress: %d\n", __func__,
                 priv->SwChnlInProgress);
        if (!priv->up)
index 1d6ade0..324da34 100644 (file)
@@ -86,7 +86,7 @@ static u32 rtl871x_open_fw(struct _adapter *padapter, const u8 **ppmappedfw)
                        (int)padapter->fw->size);
                return 0;
        }
-       *ppmappedfw = (u8 *)((*praw)->data);
+       *ppmappedfw = (*praw)->data;
        return (*praw)->size;
 }
 
@@ -136,15 +136,10 @@ static void update_fwhdr(struct fw_hdr    *pfwhdr, const u8 *pmappedfw)
 static u8 chk_fwhdr(struct fw_hdr *pfwhdr, u32 ulfilelength)
 {
        u32     fwhdrsz, fw_sz;
-       u8 intf, rfconf;
 
        /* check signature */
        if ((pfwhdr->signature != 0x8712) && (pfwhdr->signature != 0x8192))
                return _FAIL;
-       /* check interface */
-       intf = (u8)((pfwhdr->version&0x3000) >> 12);
-       /* check rf_conf */
-       rfconf = (u8)((pfwhdr->version&0xC000) >> 14);
        /* check fw_priv_sze & sizeof(struct fw_priv) */
        if (pfwhdr->fw_priv_sz != sizeof(struct fw_priv))
                return _FAIL;
@@ -162,7 +157,7 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter)
        sint i;
        u8 tmp8, tmp8_a;
        u16 tmp16;
-       u32 maxlen = 0, tmp32; /* for compare usage */
+       u32 maxlen = 0; /* for compare usage */
        uint dump_imem_sz, imem_sz, dump_emem_sz, emem_sz; /* max = 49152; */
        struct fw_hdr fwhdr;
        u32 ulfilelength;       /* FW file size */
@@ -262,7 +257,7 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter)
                if (tmp8_a != (tmp8|BIT(2)))
                        goto exit_fail;
 
-               tmp32 = r8712_read32(padapter, TCR);
+               r8712_read32(padapter, TCR);
 
                /* 4.polling IMEM Ready */
                i = 100;
index fe9459e..5786808 100644 (file)
@@ -124,11 +124,10 @@ u8 *r8712_get_ie(u8 *pbuf, sint index, sint *len, sint limit)
                if (*p == index) {
                        *len = *(p + 1);
                        return p;
-               } else {
-                       tmp = *(p + 1);
-                       p += (tmp + 2);
-                       i += (tmp + 2);
                }
+               tmp = *(p + 1);
+               p += (tmp + 2);
+               i += (tmp + 2);
                if (i >= limit)
                        break;
        }
@@ -237,10 +236,9 @@ unsigned char *r8712_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit)
                                goto check_next_ie;
                        *wpa_ie_len = *(pbuf + 1);
                        return pbuf;
-               } else {
-                       *wpa_ie_len = 0;
-                       return NULL;
                }
+               *wpa_ie_len = 0;
+               return NULL;
 check_next_ie:
                limit = limit - (pbuf - pie) - 2 - len;
                if (limit <= 0)
@@ -370,13 +368,12 @@ int r8712_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher,
 int r8712_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len,
               u8 *wpa_ie, u16 *wpa_len)
 {
-       u8 authmode, sec_idx;
+       u8 authmode;
        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_);
-       sec_idx = 0;
        while (cnt < in_len) {
                authmode = in_ie[cnt];
                if ((authmode == _WPA_IE_ID_) &&
@@ -414,7 +411,7 @@ int r8712_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen)
                        cnt += in_ie[cnt+1]+2;
                        match = true;
                        break;
-               } else
+               }
                        cnt += in_ie[cnt+1]+2; /* goto next */
        }
        return match;
index d7a357b..5153ad9 100644 (file)
@@ -88,17 +88,13 @@ static inline u32 _down_sema(struct semaphore *sema)
 {
        if (down_interruptible(sema))
                return _FAIL;
-       else
-               return _SUCCESS;
+       return _SUCCESS;
 }
 
 static inline u32 end_of_queue_search(struct list_head *head,
                struct list_head *plist)
 {
-       if (head == plist)
-               return true;
-       else
-               return false;
+       return (head == plist);
 }
 
 static inline void sleep_schedulable(int ms)
index 495ee12..0631f36 100644 (file)
@@ -146,7 +146,7 @@ void r8712_os_read_port(struct _adapter *padapter, struct recv_buf *precvbuf)
        dev_kfree_skb_any(precvbuf->pskb);
        precvbuf->pskb = NULL;
        precvbuf->reuse = false;
-       if (precvbuf->irp_pending == false)
+       if (!precvbuf->irp_pending)
                r8712_read_port(padapter, precvpriv->ff_hwaddr, 0,
                         (unsigned char *)precvbuf);
 }
index 720e8a1..62e53cc 100644 (file)
@@ -157,10 +157,8 @@ static u8 read_bbreg_hdl(struct _adapter *padapter, u8 *pbuf)
 {
        u32 val;
        void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj      *pcmd);
-       struct readBB_parm *prdbbparm;
        struct cmd_obj *pcmd  = (struct cmd_obj *)pbuf;
 
-       prdbbparm = (struct readBB_parm *)pcmd->parmbuf;
        if (pcmd->rsp && pcmd->rspsz > 0)
                memcpy(pcmd->rsp, (u8 *)&val, pcmd->rspsz);
        pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
@@ -174,10 +172,8 @@ static u8 read_bbreg_hdl(struct _adapter *padapter, u8 *pbuf)
 static u8 write_bbreg_hdl(struct _adapter *padapter, u8 *pbuf)
 {
        void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
-       struct writeBB_parm *pwritebbparm;
        struct cmd_obj *pcmd  = (struct cmd_obj *)pbuf;
 
-       pwritebbparm = (struct writeBB_parm *)pcmd->parmbuf;
        pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
        if (pcmd_callback == NULL)
                r8712_free_cmd_obj(pcmd);
@@ -190,10 +186,8 @@ static u8 read_rfreg_hdl(struct _adapter *padapter, u8 *pbuf)
 {
        u32 val;
        void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
-       struct readRF_parm *prdrfparm;
        struct cmd_obj *pcmd  = (struct cmd_obj *)pbuf;
 
-       prdrfparm = (struct readRF_parm *)pcmd->parmbuf;
        if (pcmd->rsp && pcmd->rspsz > 0)
                memcpy(pcmd->rsp, (u8 *)&val, pcmd->rspsz);
        pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
@@ -207,10 +201,8 @@ static u8 read_rfreg_hdl(struct _adapter *padapter, u8 *pbuf)
 static u8 write_rfreg_hdl(struct _adapter *padapter, u8 *pbuf)
 {
        void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
-       struct writeRF_parm *pwriterfparm;
        struct cmd_obj *pcmd  = (struct cmd_obj *)pbuf;
 
-       pwriterfparm = (struct writeRF_parm *)pcmd->parmbuf;
        pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
        if (pcmd_callback == NULL)
                r8712_free_cmd_obj(pcmd);
@@ -222,9 +214,7 @@ static u8 write_rfreg_hdl(struct _adapter *padapter, u8 *pbuf)
 static u8 sys_suspend_hdl(struct _adapter *padapter, u8 *pbuf)
 {
        struct cmd_obj *pcmd  = (struct cmd_obj *)pbuf;
-       struct usb_suspend_parm *psetusbsuspend;
 
-       psetusbsuspend = (struct usb_suspend_parm *)pcmd->parmbuf;
        r8712_free_cmd_obj(pcmd);
        return H2C_SUCCESS;
 }
@@ -320,7 +310,7 @@ void r8712_fw_cmd_data(struct _adapter *pAdapter, u32 *value, u8 flag)
 int r8712_cmd_thread(void *context)
 {
        struct cmd_obj *pcmd;
-       unsigned int cmdsz, wr_sz, *pcmdbuf, *prspbuf;
+       unsigned int cmdsz, wr_sz, *pcmdbuf;
        struct tx_desc *pdesc;
        void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
        struct _adapter *padapter = (struct _adapter *)context;
@@ -342,7 +332,6 @@ _next:
                        continue;
                }
                pcmdbuf = (unsigned int *)pcmdpriv->cmd_buf;
-               prspbuf = (unsigned int *)pcmdpriv->rsp_buf;
                pdesc = (struct tx_desc *)pcmdbuf;
                memset(pdesc, 0, TXDESC_SIZE);
                pcmd = cmd_hdl_filter(padapter, pcmd);
index c9eeb42..d957169 100644 (file)
@@ -219,13 +219,12 @@ u16 r8712_efuse_get_current_size(struct _adapter *padapter)
 {
        int bContinual = true;
        u16 efuse_addr = 0;
-       u8 hoffset = 0, hworden = 0;
+       u8 hworden = 0;
        u8 efuse_data, word_cnts = 0;
 
        while (bContinual && efuse_one_byte_read(padapter, efuse_addr,
               &efuse_data) && (efuse_addr < efuse_available_max_size)) {
                if (efuse_data != 0xFF) {
-                       hoffset = (efuse_data >> 4) & 0x0F;
                        hworden =  efuse_data & 0x0F;
                        word_cnts = calculate_word_cnts(hworden);
                        /* read next header */
@@ -414,19 +413,18 @@ u8 r8712_efuse_pg_packet_write(struct _adapter *padapter, const u8 offset,
                                        bResult = false;
                        }
                        break;
-               } else { /* write header fail */
-                       bResult = false;
-                       if (0xFF == efuse_data)
-                               return bResult; /* nothing damaged. */
-                       /* call rescue procedure */
-                       if (fix_header(padapter, efuse_data, efuse_addr) ==
-                           false)
-                               return false; /* rescue fail */
-
-                       if (++repeat_times > _REPEAT_THRESHOLD_) /* fail */
-                               break;
-                       /* otherwise, take another risk... */
                }
+               /* write header fail */
+               bResult = false;
+               if (0xFF == efuse_data)
+                       return bResult; /* nothing damaged. */
+               /* call rescue procedure */
+               if (!fix_header(padapter, efuse_data, efuse_addr))
+                       return false; /* rescue fail */
+
+               if (++repeat_times > _REPEAT_THRESHOLD_) /* fail */
+                       break;
+               /* otherwise, take another risk... */
        }
        return bResult;
 }
@@ -541,15 +539,16 @@ u8 r8712_efuse_map_write(struct _adapter *padapter, u16 addr, u16 cnts,
                                }
                                idx++;
                                break;
-                       } else {
-                               if ((data[idx] != pktdata[i]) || (data[idx+1] !=
-                                    pktdata[i+1])) {
-                                       word_en &= ~BIT(i >> 1);
-                                       newdata[j++] = data[idx];
-                                       newdata[j++] = data[idx + 1];
-                               }
-                               idx += 2;
                        }
+
+                       if ((data[idx] != pktdata[i]) || (data[idx+1] !=
+                            pktdata[i+1])) {
+                               word_en &= ~BIT(i >> 1);
+                               newdata[j++] = data[idx];
+                               newdata[j++] = data[idx + 1];
+                       }
+                       idx += 2;
+
                        if (idx == cnts)
                                break;
                }
index b278062..27f38ac 100644 (file)
@@ -158,8 +158,6 @@ int r8712_free_recvframe(union recv_frame *precvframe,
 static void update_recvframe_attrib_from_recvstat(struct rx_pkt_attrib *pattrib,
                                           struct recv_stat *prxstat)
 {
-       u32 *pphy_info;
-       struct phy_stat *pphy_stat;
        u16 drvinfo_sz = 0;
 
        drvinfo_sz = (le32_to_cpu(prxstat->rxdw0)&0x000f0000)>>16;
@@ -189,10 +187,6 @@ static void update_recvframe_attrib_from_recvstat(struct rx_pkt_attrib *pattrib,
        /*Offset 16*/
        /*Offset 20*/
        /*phy_info*/
-       if (drvinfo_sz) {
-               pphy_stat = (struct phy_stat *)(prxstat+1);
-               pphy_info = (u32 *)prxstat+1;
-       }
 }
 
 /*perform defrag*/
@@ -200,7 +194,7 @@ static union recv_frame *recvframe_defrag(struct _adapter *adapter,
                                   struct  __queue *defrag_q)
 {
        struct list_head *plist, *phead;
-       u8      *data, wlanhdr_offset;
+       u8 wlanhdr_offset;
        u8      curfragnum;
        struct recv_frame_hdr *pfhdr, *pnfhdr;
        union recv_frame *prframe, *pnextrframe;
@@ -223,7 +217,6 @@ static union recv_frame *recvframe_defrag(struct _adapter *adapter,
        curfragnum++;
        plist = &defrag_q->queue;
        plist = plist->next;
-       data = get_recvframe_data(prframe);
        while (end_of_queue_search(phead, plist) == false) {
                pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u);
                pnfhdr = &pnextrframe->u.hdr;
@@ -436,13 +429,11 @@ void r8712_rxcmd_event_hdl(struct _adapter *padapter, void *prxcmdbuf)
 {
        uint voffset;
        u8 *poffset;
-       u16 pkt_len, cmd_len, drvinfo_sz;
-       u8 eid, cmd_seq;
+       u16 cmd_len, drvinfo_sz;
        struct recv_stat *prxstat;
 
        poffset = (u8 *)prxcmdbuf;
        voffset = *(uint *)poffset;
-       pkt_len = le32_to_cpu(voffset) & 0x00003fff;
        prxstat = (struct recv_stat *)prxcmdbuf;
        drvinfo_sz = ((le32_to_cpu(prxstat->rxdw0) & 0x000f0000) >> 16);
        drvinfo_sz = drvinfo_sz << 3;
@@ -450,8 +441,6 @@ void r8712_rxcmd_event_hdl(struct _adapter *padapter, void *prxcmdbuf)
        do {
                voffset  = *(uint *)poffset;
                cmd_len = (u16)(le32_to_cpu(voffset) & 0xffff);
-               cmd_seq = (u8)((le32_to_cpu(voffset) >> 24) & 0x7f);
-               eid = (u8)((le32_to_cpu(voffset) >> 16) & 0xff);
                r8712_event_handle(padapter, (uint *)poffset);
                poffset += (cmd_len + 8);/*8 bytes alignment*/
        } while (le32_to_cpu(voffset) & BIT(31));
index d9c1561..fe5e315 100644 (file)
@@ -205,12 +205,12 @@ void r8712_free_cmd_obj(struct cmd_obj *pcmd)
 {
        if ((pcmd->cmdcode != _JoinBss_CMD_) &&
            (pcmd->cmdcode != _CreateBss_CMD_))
-               kfree((unsigned char *)pcmd->parmbuf);
+               kfree(pcmd->parmbuf);
        if (pcmd->rsp != NULL) {
                if (pcmd->rspsz != 0)
-                       kfree((unsigned char *)pcmd->rsp);
+                       kfree(pcmd->rsp);
        }
-       kfree((unsigned char *)pcmd);
+       kfree(pcmd);
 }
 
 /*
@@ -232,7 +232,7 @@ u8 r8712_sitesurvey_cmd(struct _adapter *padapter,
                return _FAIL;
        psurveyPara = kmalloc(sizeof(*psurveyPara), GFP_ATOMIC);
        if (psurveyPara == NULL) {
-               kfree((unsigned char *) ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
        init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara,
@@ -264,7 +264,7 @@ u8 r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset)
                return _FAIL;
        pbsetdataratepara = kmalloc(sizeof(*pbsetdataratepara), GFP_ATOMIC);
        if (pbsetdataratepara == NULL) {
-               kfree((u8 *) ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
        init_h2fwcmd_w_parm_no_rsp(ph2c, pbsetdataratepara,
@@ -286,7 +286,7 @@ u8 r8712_set_chplan_cmd(struct _adapter *padapter, int chplan)
                return _FAIL;
        psetchplanpara = kmalloc(sizeof(*psetchplanpara), GFP_ATOMIC);
        if (psetchplanpara == NULL) {
-               kfree((u8 *) ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
        init_h2fwcmd_w_parm_no_rsp(ph2c, psetchplanpara,
@@ -307,7 +307,7 @@ u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset)
                return _FAIL;
        pssetbasicratepara = kmalloc(sizeof(*pssetbasicratepara), GFP_ATOMIC);
        if (pssetbasicratepara == NULL) {
-               kfree((u8 *) ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
        init_h2fwcmd_w_parm_no_rsp(ph2c, pssetbasicratepara,
@@ -329,7 +329,7 @@ u8 r8712_setptm_cmd(struct _adapter *padapter, u8 type)
                return _FAIL;
        pwriteptmparm = kmalloc(sizeof(*pwriteptmparm), GFP_ATOMIC);
        if (pwriteptmparm == NULL) {
-               kfree((u8 *) ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
        init_h2fwcmd_w_parm_no_rsp(ph2c, pwriteptmparm, GEN_CMD_CODE(_SetPT));
@@ -349,7 +349,7 @@ u8 r8712_setfwdig_cmd(struct _adapter *padapter, u8 type)
                return _FAIL;
        pwriteptmparm = kmalloc(sizeof(*pwriteptmparm), GFP_ATOMIC);
        if (pwriteptmparm == NULL) {
-               kfree((u8 *) ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
        init_h2fwcmd_w_parm_no_rsp(ph2c, pwriteptmparm, GEN_CMD_CODE(_SetDIG));
@@ -369,7 +369,7 @@ u8 r8712_setfwra_cmd(struct _adapter *padapter, u8 type)
                return _FAIL;
        pwriteptmparm = kmalloc(sizeof(*pwriteptmparm), GFP_ATOMIC);
        if (pwriteptmparm == NULL) {
-               kfree((u8 *) ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
        init_h2fwcmd_w_parm_no_rsp(ph2c, pwriteptmparm, GEN_CMD_CODE(_SetRA));
@@ -389,7 +389,7 @@ u8 r8712_setrfreg_cmd(struct _adapter  *padapter, u8 offset, u32 val)
                return _FAIL;
        pwriterfparm = kmalloc(sizeof(*pwriterfparm), GFP_ATOMIC);
        if (pwriterfparm == NULL) {
-               kfree((u8 *) ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
        init_h2fwcmd_w_parm_no_rsp(ph2c, pwriterfparm, GEN_CMD_CODE(_SetRFReg));
@@ -410,7 +410,7 @@ u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval)
                return _FAIL;
        prdrfparm = kmalloc(sizeof(*prdrfparm), GFP_ATOMIC);
        if (prdrfparm == NULL) {
-               kfree((u8 *) ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
        INIT_LIST_HEAD(&ph2c->list);
@@ -470,7 +470,6 @@ u8 r8712_createbss_cmd(struct _adapter *padapter)
 
 u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct wlan_network *pnetwork)
 {
-       u8 *auth;
        uint t_len = 0;
        struct ndis_wlan_bssid_ex *psecnetwork;
        struct cmd_obj          *pcmd;
@@ -517,7 +516,6 @@ u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct wlan_network *pnetwork)
                return _FAIL;
        }
        memcpy(psecnetwork, &pnetwork->network, t_len);
-       auth = &psecuritypriv->authenticator_ie[0];
        psecuritypriv->authenticator_ie[0] = (unsigned char)
                                             psecnetwork->IELength;
        if ((psecnetwork->IELength-12) < (256 - 1))
@@ -527,7 +525,7 @@ u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct wlan_network *pnetwork)
                memcpy(&psecuritypriv->authenticator_ie[1],
                        &psecnetwork->IEs[12], (256-1));
        psecnetwork->IELength = 0;
-       /* If the the driver wants to use the bssid to create the connection.
+       /* If the driver wants to use the bssid to create the connection.
         * If not,  we copy the connecting AP's MAC address to it so that
         * the driver just has the bssid information for PMKIDList searching.
         */
@@ -626,7 +624,7 @@ u8 r8712_disassoc_cmd(struct _adapter *padapter) /* for sta_mode */
                return _FAIL;
        pdisconnect = kmalloc(sizeof(*pdisconnect), GFP_ATOMIC);
        if (pdisconnect == NULL) {
-               kfree((u8 *)pdisconnect_cmd);
+               kfree(pdisconnect_cmd);
                return _FAIL;
        }
        init_h2fwcmd_w_parm_no_rsp(pdisconnect_cmd, pdisconnect,
@@ -648,7 +646,7 @@ u8 r8712_setopmode_cmd(struct _adapter *padapter,
                return _FAIL;
        psetop = kmalloc(sizeof(*psetop), GFP_ATOMIC);
        if (psetop == NULL) {
-               kfree((u8 *) ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
        init_h2fwcmd_w_parm_no_rsp(ph2c, psetop, _SetOpMode_CMD_);
@@ -672,13 +670,13 @@ u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key)
                return _FAIL;
        psetstakey_para = kmalloc(sizeof(*psetstakey_para), GFP_ATOMIC);
        if (psetstakey_para == NULL) {
-               kfree((u8 *) ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
        psetstakey_rsp = kmalloc(sizeof(*psetstakey_rsp), GFP_ATOMIC);
        if (psetstakey_rsp == NULL) {
-               kfree((u8 *) ph2c);
-               kfree((u8 *) psetstakey_para);
+               kfree(ph2c);
+               kfree(psetstakey_para);
                return _FAIL;
        }
        init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_);
@@ -712,7 +710,7 @@ u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode)
                return _FAIL;
        psetrfintfsparm = kmalloc(sizeof(*psetrfintfsparm), GFP_ATOMIC);
        if (psetrfintfsparm == NULL) {
-               kfree((unsigned char *) ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
        init_h2fwcmd_w_parm_no_rsp(ph2c, psetrfintfsparm,
@@ -734,7 +732,7 @@ u8 r8712_setrttbl_cmd(struct _adapter *padapter,
                return _FAIL;
        psetrttblparm = kmalloc(sizeof(*psetrttblparm), GFP_ATOMIC);
        if (psetrttblparm == NULL) {
-               kfree((unsigned char *)ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
        init_h2fwcmd_w_parm_no_rsp(ph2c, psetrttblparm,
@@ -755,7 +753,7 @@ u8 r8712_gettssi_cmd(struct _adapter *padapter, u8 offset, u8 *pval)
                return _FAIL;
        prdtssiparm = kmalloc(sizeof(*prdtssiparm), GFP_ATOMIC);
        if (prdtssiparm == NULL) {
-               kfree((unsigned char *) ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
        INIT_LIST_HEAD(&ph2c->list);
@@ -781,7 +779,7 @@ u8 r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr)
                return _FAIL;
        psetMacAddr_para = kmalloc(sizeof(*psetMacAddr_para), GFP_ATOMIC);
        if (psetMacAddr_para == NULL) {
-               kfree((u8 *) ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
        init_h2fwcmd_w_parm_no_rsp(ph2c, psetMacAddr_para,
@@ -803,13 +801,13 @@ u8 r8712_setassocsta_cmd(struct _adapter *padapter, u8 *mac_addr)
                return _FAIL;
        psetassocsta_para = kmalloc(sizeof(*psetassocsta_para), GFP_ATOMIC);
        if (psetassocsta_para == NULL) {
-               kfree((u8 *) ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
        psetassocsta_rsp = kmalloc(sizeof(*psetassocsta_rsp), GFP_ATOMIC);
        if (psetassocsta_rsp == NULL) {
-               kfree((u8 *)ph2c);
-               kfree((u8 *)psetassocsta_para);
+               kfree(ph2c);
+               kfree(psetassocsta_para);
                return _FAIL;
        }
        init_h2fwcmd_w_parm_no_rsp(ph2c, psetassocsta_para, _SetAssocSta_CMD_);
@@ -831,7 +829,7 @@ u8 r8712_addbareq_cmd(struct _adapter *padapter, u8 tid)
                return _FAIL;
        paddbareq_parm = kmalloc(sizeof(*paddbareq_parm), GFP_ATOMIC);
        if (paddbareq_parm == NULL) {
-               kfree((unsigned char *)ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
        paddbareq_parm->tid = tid;
@@ -852,7 +850,7 @@ u8 r8712_wdg_wk_cmd(struct _adapter *padapter)
                return _FAIL;
        pdrvintcmd_param = kmalloc(sizeof(*pdrvintcmd_param), GFP_ATOMIC);
        if (pdrvintcmd_param == NULL) {
-               kfree((unsigned char *)ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
        pdrvintcmd_param->i_cid = WDG_WK_CID;
@@ -1026,7 +1024,7 @@ u8 r8712_disconnectCtrlEx_cmd(struct _adapter *adapter, u32 enableDrvCtrl,
                return _FAIL;
        param = kzalloc(sizeof(*param), GFP_ATOMIC);
        if (param == NULL) {
-               kfree((unsigned char *) ph2c);
+               kfree(ph2c);
                return _FAIL;
        }
 
index d7b63ae..e4e5b13 100644 (file)
@@ -93,7 +93,7 @@ static uint register_intf_hdl(u8 *dev, struct intf_hdl *pintfhdl)
        pintfhdl->intf_option = 0;
        pintfhdl->adapter = dev;
        pintfhdl->intf_dev = (u8 *)&(adapter->dvobjpriv);
-       if (_init_intf_hdl(adapter, pintfhdl) == false)
+       if (!_init_intf_hdl(adapter, pintfhdl))
                goto register_intf_hdl_fail;
        return _SUCCESS;
 register_intf_hdl_fail:
@@ -142,7 +142,7 @@ uint r8712_alloc_io_queue(struct _adapter *adapter)
 alloc_io_queue_fail:
        if (pio_queue) {
                kfree(pio_queue->pallocated_free_ioreqs_buf);
-               kfree((u8 *)pio_queue);
+               kfree(pio_queue);
        }
        adapter->pio_queue = NULL;
        return _FAIL;
@@ -156,6 +156,6 @@ void r8712_free_io_queue(struct _adapter *adapter)
                kfree(pio_queue->pallocated_free_ioreqs_buf);
                adapter->pio_queue = NULL;
                unregister_intf_hdl(&pio_queue->intf);
-               kfree((u8 *)pio_queue);
+               kfree(pio_queue);
        }
 }
index 8e42ce0..73b7d86 100644 (file)
@@ -170,7 +170,7 @@ static inline char *translate_scan(struct _adapter *padapter,
        s8 *p;
        u32 i = 0, ht_ielen = 0;
        u16     cap, ht_cap = false, mcs_rate;
-       u8      rssi, bw_40MHz = 0, short_GI = 0;
+       u8 rssi;
 
        if ((pnetwork->network.Configuration.DSConfig < 1) ||
            (pnetwork->network.Configuration.DSConfig > 14)) {
@@ -197,10 +197,6 @@ static inline char *translate_scan(struct _adapter *padapter,
                ht_cap = true;
                pht_capie = (struct ieee80211_ht_cap *)(p + 2);
                memcpy(&mcs_rate , pht_capie->supp_mcs_set, 2);
-               bw_40MHz = (pht_capie->cap_info&IEEE80211_HT_CAP_SUP_WIDTH)
-                          ? 1 : 0;
-               short_GI = (pht_capie->cap_info&(IEEE80211_HT_CAP_SGI_20 |
-                           IEEE80211_HT_CAP_SGI_40)) ? 1 : 0;
        }
        /* Add the protocol name */
        iwe.cmd = SIOCGIWNAME;
@@ -287,12 +283,10 @@ static inline char *translate_scan(struct _adapter *padapter,
                u8 wpa_ie[255], rsn_ie[255];
                u16 wpa_len = 0, rsn_len = 0;
                int n;
-               sint out_len = 0;
 
-               out_len = r8712_get_sec_ie(pnetwork->network.IEs,
-                                          pnetwork->network.
-                                          IELength, rsn_ie, &rsn_len,
-                                          wpa_ie, &wpa_len);
+               r8712_get_sec_ie(pnetwork->network.IEs,
+                                pnetwork->network.IELength, rsn_ie, &rsn_len,
+                                wpa_ie, &wpa_len);
                if (wpa_len > 0) {
                        memset(buf, 0, MAX_WPA_IE_LEN);
                        n = sprintf(buf, "wpa_ie=");
@@ -505,14 +499,14 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
                }
        }
 exit:
-       kfree((u8 *)pwep);
+       kfree(pwep);
        return ret;
 }
 
 static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie,
                            unsigned short ielen)
 {
-       u8 *buf = NULL, *pos = NULL;
+       u8 *buf = NULL;
        int group_cipher = 0, pairwise_cipher = 0;
        int ret = 0;
 
@@ -522,7 +516,6 @@ static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie,
                buf = kmemdup(pie, ielen, GFP_ATOMIC);
                if (buf == NULL)
                        return -ENOMEM;
-               pos = buf;
                if (ielen < RSN_HEADER_LEN) {
                        ret  = -EINVAL;
                        goto exit;
@@ -1133,13 +1126,11 @@ static int r871x_wx_set_mlme(struct net_device *dev,
                             union iwreq_data *wrqu, char *extra)
 {
        int ret = 0;
-       u16 reason;
        struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
        struct iw_mlme *mlme = (struct iw_mlme *) extra;
 
        if (mlme == NULL)
                return -1;
-       reason = cpu_to_le16(mlme->reason_code);
        switch (mlme->cmd) {
        case IW_MLME_DEAUTH:
                if (!r8712_set_802_11_disassociate(padapter))
@@ -2216,7 +2207,7 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p)
        }
        if (ret == 0 && copy_to_user(p->pointer, param, p->length))
                ret = -EFAULT;
-       kfree((u8 *)param);
+       kfree(param);
        return ret;
 }
 
index 9d47eb4..6318a0e 100644 (file)
@@ -77,7 +77,7 @@ static u8 do_join(struct _adapter *padapter)
                /* when set_ssid/set_bssid for do_join(), but scanning queue
                 * is empty we try to issue sitesurvey firstly
                 */
-               if (pmlmepriv->sitesurveyctrl.traffic_busy == false)
+               if (!pmlmepriv->sitesurveyctrl.traffic_busy)
                        r8712_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid);
                return true;
        } else {
@@ -143,8 +143,7 @@ u8 r8712_set_802_11_bssid(struct _adapter *padapter, u8 *bssid)
            _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) {
                if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid,
                    ETH_ALEN)) {
-                       if (check_fwstate(pmlmepriv,
-                           WIFI_STATION_STATE) == false)
+                       if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE))
                                goto _Abort_Set_BSSID; /* driver is in
                                                * WIFI_ADHOC_MASTER_STATE */
                } else {
@@ -177,7 +176,7 @@ void r8712_set_802_11_ssid(struct _adapter *padapter,
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct wlan_network *pnetwork = &pmlmepriv->cur_network;
 
-       if (padapter->hw_init_completed == false)
+       if (!padapter->hw_init_completed)
                return;
        spin_lock_irqsave(&pmlmepriv->lock, irqL);
        if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) {
@@ -188,10 +187,9 @@ void r8712_set_802_11_ssid(struct _adapter *padapter,
                if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) &&
                    (!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid,
                    ssid->SsidLength))) {
-                       if ((check_fwstate(pmlmepriv,
-                            WIFI_STATION_STATE) == false)) {
-                               if (r8712_is_same_ibss(padapter,
-                                    pnetwork) == false) {
+                       if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
+                               if (!r8712_is_same_ibss(padapter,
+                                    pnetwork)) {
                                        /* if in WIFI_ADHOC_MASTER_STATE or
                                         *  WIFI_ADHOC_STATE, create bss or
                                         * rejoin again
@@ -227,7 +225,7 @@ void r8712_set_802_11_ssid(struct _adapter *padapter,
        }
        if (padapter->securitypriv.btkip_countermeasure == true)
                goto _Abort_Set_SSID;
-       if (validate_ssid(ssid) == false)
+       if (!validate_ssid(ssid))
                goto _Abort_Set_SSID;
        memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct ndis_802_11_ssid));
        pmlmepriv->assoc_by_bssid = false;
@@ -308,10 +306,10 @@ u8 r8712_set_802_11_bssid_list_scan(struct _adapter *padapter)
        unsigned long irqL;
        u8 ret = true;
 
-       if (padapter == NULL)
+       if (!padapter)
                return false;
        pmlmepriv = &padapter->mlmepriv;
-       if (padapter->hw_init_completed == false)
+       if (!padapter->hw_init_completed)
                return false;
        spin_lock_irqsave(&pmlmepriv->lock, irqL);
        if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) ||
@@ -345,13 +343,9 @@ u8 r8712_set_802_11_authentication_mode(struct _adapter *padapter,
 u8 r8712_set_802_11_add_wep(struct _adapter *padapter,
                            struct NDIS_802_11_WEP *wep)
 {
-       u8      bdefaultkey;
-       u8      btransmitkey;
        sint    keyid;
        struct security_priv *psecuritypriv = &padapter->securitypriv;
 
-       bdefaultkey = (wep->KeyIndex & 0x40000000) > 0 ? false : true;
-       btransmitkey = (wep->KeyIndex & 0x80000000) > 0 ? true : false;
        keyid = wep->KeyIndex & 0x3fffffff;
        if (keyid >= WEP_KEYS)
                return false;
index 00f2e0f..b7462e8 100644 (file)
@@ -923,7 +923,7 @@ void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf)
 ignore_joinbss_callback:
        spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
        if (sizeof(struct list_head) == 4 * sizeof(u32))
-               kfree((u8 *)pnetwork);
+               kfree(pnetwork);
 }
 
 void r8712_stassoc_event_callback(struct _adapter *adapter, u8 *pbuf)
@@ -1218,7 +1218,7 @@ sint r8712_set_auth(struct _adapter *adapter,
 
        psetauthparm = kzalloc(sizeof(*psetauthparm), GFP_ATOMIC);
        if (psetauthparm == NULL) {
-               kfree((unsigned char *)pcmd);
+               kfree(pcmd);
                return _FAIL;
        }
        psetauthparm->mode = (u8)psecuritypriv->AuthAlgrthm;
@@ -1372,7 +1372,7 @@ static int SecIsInPMKIDList(struct _adapter *Adapter, u8 *bssid)
 sint r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie,
                     u8 *out_ie, uint in_len)
 {
-       u8 authmode = 0, securitytype, match;
+       u8 authmode = 0, match;
        u8 sec_ie[255], uncst_oui[4], bkup_ie[255];
        u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01};
        uint ielength, cnt, remove_cnt;
@@ -1399,21 +1399,17 @@ sint r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie,
        switch (ndissecuritytype) {
        case Ndis802_11Encryption1Enabled:
        case Ndis802_11Encryption1KeyAbsent:
-               securitytype = _WEP40_;
                uncst_oui[3] = 0x1;
                break;
        case Ndis802_11Encryption2Enabled:
        case Ndis802_11Encryption2KeyAbsent:
-               securitytype = _TKIP_;
                uncst_oui[3] = 0x2;
                break;
        case Ndis802_11Encryption3Enabled:
        case Ndis802_11Encryption3KeyAbsent:
-               securitytype = _AES_;
                uncst_oui[3] = 0x4;
                break;
        default:
-               securitytype = _NO_PRIVACY_;
                break;
        }
        /*Search required WPA or WPA2 IE and copy to sec_ie[] */
@@ -1705,7 +1701,7 @@ unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie,
                                     u8 *out_ie, uint in_len, uint *pout_len)
 {
        u32 ielen, out_len;
-       unsigned char *p, *pframe;
+       unsigned char *p;
        struct ieee80211_ht_cap ht_capie;
        unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -1717,10 +1713,8 @@ unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie,
        if (p && (ielen > 0)) {
                if (pqospriv->qos_option == 0) {
                        out_len = *pout_len;
-                       pframe = r8712_set_ie(out_ie+out_len,
-                                             _VENDOR_SPECIFIC_IE_,
-                                             _WMM_IE_Length_,
-                                              WMM_IE, pout_len);
+                       r8712_set_ie(out_ie+out_len, _VENDOR_SPECIFIC_IE_,
+                                    _WMM_IE_Length_, WMM_IE, pout_len);
                        pqospriv->qos_option = 1;
                }
                out_len = *pout_len;
@@ -1733,9 +1727,9 @@ unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie,
                                    IEEE80211_HT_CAP_DSSSCCK40;
                ht_capie.ampdu_params_info = (IEEE80211_HT_CAP_AMPDU_FACTOR &
                                0x03) | (IEEE80211_HT_CAP_AMPDU_DENSITY & 0x00);
-               pframe = r8712_set_ie(out_ie+out_len, _HT_CAPABILITY_IE_,
-                               sizeof(struct ieee80211_ht_cap),
-                               (unsigned char *)&ht_capie, pout_len);
+               r8712_set_ie(out_ie+out_len, _HT_CAPABILITY_IE_,
+                            sizeof(struct ieee80211_ht_cap),
+                            (unsigned char *)&ht_capie, pout_len);
                phtpriv->ht_option = 1;
        }
        return phtpriv->ht_option;
@@ -1748,7 +1742,6 @@ static void update_ht_cap(struct _adapter *padapter, u8 *pie, uint ie_len)
        int i, len;
        struct sta_info *bmc_sta, *psta;
        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;
@@ -1801,8 +1794,6 @@ static void update_ht_cap(struct _adapter *padapter, u8 *pie, uint ie_len)
        p = r8712_get_ie(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);
 }
 
 void r8712_issue_addbareq_cmd(struct _adapter *padapter, int priority)
index 2ec660a..3d913b9 100644 (file)
@@ -56,7 +56,7 @@ static int init_mp_priv(struct mp_priv *pmp_priv)
        pmp_priv->pallocated_mp_xmitframe_buf = kmalloc(NR_MP_XMITFRAME *
                                sizeof(struct mp_xmit_frame) + 4,
                                GFP_ATOMIC);
-       if (pmp_priv->pallocated_mp_xmitframe_buf == NULL) {
+       if (!pmp_priv->pallocated_mp_xmitframe_buf) {
                res = _FAIL;
                goto _exit_init_mp_priv;
        }
@@ -173,7 +173,7 @@ u8 r8712_bb_reg_write(struct _adapter *pAdapter, u16 offset, u32 value)
                oldValue = r8712_bb_reg_read(pAdapter, iocmd.value);
                oldValue &= (0xFFFFFFFF >> ((4 - shift) * 8));
                value = oldValue | (newValue << (shift * 8));
-               if (fw_iocmd_write(pAdapter, iocmd, value) == false)
+               if (!fw_iocmd_write(pAdapter, iocmd, value))
                        return false;
                iocmd.value += 4;
                oldValue = r8712_bb_reg_read(pAdapter, iocmd.value);
index 9827ff8..a16f15e 100644 (file)
@@ -1431,11 +1431,8 @@ unsigned int mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv)
 /*-------------------------------------------------------------------------*/
 uint oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv)
 {
-       u8      bpwrup;
-
        if (poid_par_priv->type_of_oid != SET_OID)
                return RNDIS_STATUS_NOT_ACCEPTED;
-       bpwrup = *(u8 *)poid_par_priv->information_buf;
        /*CALL  the power_down function*/
        return RNDIS_STATUS_SUCCESS;
 }
index 51dcf55..ed2844d 100644 (file)
@@ -156,11 +156,9 @@ static void rpwm_workitem_callback(struct work_struct *work)
                                       struct pwrctrl_priv, rpwm_workitem);
        struct _adapter *padapter = container_of(pwrpriv,
                                    struct _adapter, pwrctrlpriv);
-       u8 cpwm = pwrpriv->cpwm;
-
        if (pwrpriv->cpwm != pwrpriv->rpwm) {
                _enter_pwrlock(&pwrpriv->lock);
-               cpwm = r8712_read8(padapter, SDIO_HCPWM);
+               r8712_read8(padapter, SDIO_HCPWM);
                pwrpriv->rpwm_retry = 1;
                r8712_set_rpwm(padapter, pwrpriv->rpwm);
                up(&pwrpriv->lock);
index 9b99a71..06f15f8 100644 (file)
@@ -601,7 +601,7 @@ sint r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe)
 {
        /*remove the wlanhdr and add the eth_hdr*/
        sint    rmv_len;
-       u16     eth_type, len;
+       u16     len;
        u8      bsnaphdr;
        u8      *psnap_type;
        struct ieee80211_snap_hdr *psnap;
@@ -635,7 +635,6 @@ sint r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe)
                ptr += rmv_len;
                *ptr = 0x87;
                *(ptr+1) = 0x12;
-               eth_type = 0x8712;
                /* append rx status for mp test packets */
                ptr = recvframe_pull(precvframe, (rmv_len -
                      sizeof(struct ethhdr) + 2) - 24);
@@ -658,27 +657,11 @@ s32 r8712_recv_entry(union recv_frame *precvframe)
 {
        struct _adapter *padapter;
        struct recv_priv *precvpriv;
-       struct  mlme_priv *pmlmepriv;
-       struct recv_stat *prxstat;
-       struct dvobj_priv *pdev;
-       u8 *phead, *pdata, *ptail, *pend;
 
-       struct  __queue *pfree_recv_queue, *ppending_recv_queue;
        s32 ret = _SUCCESS;
-       struct intf_hdl *pintfhdl;
 
        padapter = precvframe->u.hdr.adapter;
-       pintfhdl = &padapter->pio_queue->intf;
-       pmlmepriv = &padapter->mlmepriv;
        precvpriv = &(padapter->recvpriv);
-       pdev = &padapter->dvobjpriv;
-       pfree_recv_queue = &(precvpriv->free_recv_queue);
-       ppending_recv_queue = &(precvpriv->recv_pending_queue);
-       phead = precvframe->u.hdr.rx_head;
-       pdata = precvframe->u.hdr.rx_data;
-       ptail = precvframe->u.hdr.rx_tail;
-       pend = precvframe->u.hdr.rx_end;
-       prxstat = (struct recv_stat *)phead;
 
        padapter->ledpriv.LedControlHandler(padapter, LED_CTL_RX);
 
index 92ca899..77487bb 100644 (file)
@@ -170,11 +170,8 @@ static inline u8 *recvframe_put(union recv_frame *precvframe, sint sz)
        /* used for append sz bytes from ptr to rx_tail, update rx_tail and
         * return the updated rx_tail to the caller
         * after putting, rx_tail must be still larger than rx_end. */
-       unsigned char *prev_rx_tail;
-
        if (precvframe == NULL)
                return NULL;
-       prev_rx_tail = precvframe->u.hdr.rx_tail;
        precvframe->u.hdr.rx_tail += sz;
        if (precvframe->u.hdr.rx_tail > precvframe->u.hdr.rx_end) {
                precvframe->u.hdr.rx_tail -= sz;
index 8faf22b..c653ad6 100644 (file)
@@ -578,7 +578,7 @@ u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 *pxmitframe)
        u8 ttkey[16];
        u8 crc[4];
        struct arc4context mycontext;
-       u32 curfragnum, length, prwskeylen;
+       u32 curfragnum, length;
 
        u8 *pframe, *payload, *iv, *prwskey;
        union pn48 txpn;
@@ -600,7 +600,6 @@ u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 *pxmitframe)
                                  &pattrib->ra[0]);
                if (stainfo != NULL) {
                        prwskey = &stainfo->x_UncstKey.skey[0];
-                       prwskeylen = 16;
                        for (curfragnum = 0; curfragnum < pattrib->nr_frags;
                             curfragnum++) {
                                iv = pframe + pattrib->hdrlen;
@@ -655,7 +654,7 @@ u32 r8712_tkip_decrypt(struct _adapter *padapter, u8 *precvframe)
        u8 ttkey[16];
        u8 crc[4];
        struct arc4context mycontext;
-       u32 length, prwskeylen;
+       u32 length;
        u8 *pframe, *payload, *iv, *prwskey, idx = 0;
        union pn48 txpn;
        struct  sta_info *stainfo;
@@ -683,7 +682,6 @@ u32 r8712_tkip_decrypt(struct _adapter *padapter, u8 *precvframe)
                                        return _FAIL;
                        } else
                                prwskey = &stainfo->x_UncstKey.skey[0];
-                       prwskeylen = 16;
                        GET_TKIP_PN(iv, txpn);
                        pnl = (u16)(txpn.val);
                        pnh = (u32)(txpn.val >> 16);
@@ -1154,7 +1152,6 @@ u32 r8712_aes_encrypt(struct _adapter *padapter, u8 *pxmitframe)
 {      /* exclude ICV */
        /* Intermediate Buffers */
        sint    curfragnum, length;
-       u32     prwskeylen;
        u8      *pframe, *prwskey;
        struct  sta_info *stainfo;
        struct  pkt_attrib  *pattrib = &((struct xmit_frame *)
@@ -1174,7 +1171,6 @@ u32 r8712_aes_encrypt(struct _adapter *padapter, u8 *pxmitframe)
                                  &pattrib->ra[0]);
                if (stainfo != NULL) {
                        prwskey = &stainfo->x_UncstKey.skey[0];
-                       prwskeylen = 16;
                        for (curfragnum = 0; curfragnum < pattrib->nr_frags;
                             curfragnum++) {
                                if ((curfragnum + 1) == pattrib->nr_frags) {
@@ -1363,7 +1359,6 @@ u32 r8712_aes_decrypt(struct _adapter *padapter, u8 *precvframe)
 {      /* exclude ICV */
        /* Intermediate Buffers */
        sint            length;
-       u32     prwskeylen;
        u8      *pframe, *prwskey, *iv, idx;
        struct  sta_info *stainfo;
        struct  rx_pkt_attrib *prxattrib = &((union recv_frame *)
@@ -1387,7 +1382,6 @@ u32 r8712_aes_decrypt(struct _adapter *padapter, u8 *precvframe)
 
                        } else
                                prwskey = &stainfo->x_UncstKey.skey[0];
-                       prwskeylen = 16;
                        length = ((union recv_frame *)precvframe)->
                                 u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len;
                        aes_decipher(prwskey, prxattrib->hdrlen, pframe,
index e769bb5..4c9b98e 100644 (file)
@@ -79,13 +79,11 @@ static void mfree_all_stainfo(struct sta_priv *pstapriv)
 {
        unsigned long irqL;
        struct list_head *plist, *phead;
-       struct sta_info *psta = NULL;
 
        spin_lock_irqsave(&pstapriv->sta_hash_lock, irqL);
        phead = &pstapriv->free_sta_queue.queue;
        plist = phead->next;
        while ((end_of_queue_search(phead, plist)) == false) {
-               psta = LIST_CONTAINOR(plist, struct sta_info, list);
                plist = plist->next;
        }
 
@@ -109,7 +107,6 @@ u32 _r8712_free_sta_priv(struct sta_priv *pstapriv)
 
 struct sta_info *r8712_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
 {
-       uint tmp_aid;
        s32     index;
        struct list_head *phash_list;
        struct sta_info *psta;
@@ -127,7 +124,6 @@ struct sta_info *r8712_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
                psta = LIST_CONTAINOR(pfree_sta_queue->queue.next,
                                      struct sta_info, list);
                list_del_init(&(psta->list));
-               tmp_aid = psta->aid;
                _init_stainfo(psta);
                memcpy(psta->hwaddr, hwaddr, ETH_ALEN);
                index = wifi_mac_hash(hwaddr);
@@ -267,15 +263,10 @@ struct sta_info *r8712_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
 
 void r8712_init_bcmc_stainfo(struct _adapter *padapter)
 {
-       struct sta_info *psta;
-       struct tx_servq *ptxservq;
        unsigned char bcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
        struct  sta_priv *pstapriv = &padapter->stapriv;
 
-       psta = r8712_alloc_stainfo(pstapriv, bcast_addr);
-       if (psta == NULL)
-               return;
-       ptxservq = &(psta->sta_xmitpriv.be_q);
+       r8712_alloc_stainfo(pstapriv, bcast_addr);
 }
 
 struct sta_info *r8712_get_bcmc_stainfo(struct _adapter *padapter)
index f49acaf..62a377e 100644 (file)
@@ -184,7 +184,6 @@ void _free_xmit_priv(struct xmit_priv *pxmitpriv)
 sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt,
                   struct pkt_attrib *pattrib)
 {
-       uint i;
        struct pkt_file pktfile;
        struct sta_info *psta = NULL;
        struct ethhdr etherhdr;
@@ -199,7 +198,7 @@ sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt,
 
        _r8712_open_pktfile(pkt, &pktfile);
 
-       i = _r8712_pktfile_read(&pktfile, (unsigned char *)&etherhdr, ETH_HLEN);
+       _r8712_pktfile_read(&pktfile, (unsigned char *)&etherhdr, ETH_HLEN);
 
        pattrib->ether_type = ntohs(etherhdr.h_proto);
 
@@ -236,7 +235,7 @@ sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt,
                /* for mp storing the txcmd per packet,
                 * according to the info of txcmd to update pattrib */
                /*get MP_TXDESC_SIZE bytes txcmd per packet*/
-               i = _r8712_pktfile_read(&pktfile, (u8 *)&txdesc, TXDESC_SIZE);
+               _r8712_pktfile_read(&pktfile, (u8 *)&txdesc, TXDESC_SIZE);
                memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
                memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
                pattrib->pctrl = 1;
@@ -347,7 +346,7 @@ sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt,
 static sint xmitframe_addmic(struct _adapter *padapter,
                             struct xmit_frame *pxmitframe)
 {
-       u32     curfragnum, length, datalen;
+       u32     curfragnum, length;
        u8      *pframe, *payload, mic[8];
        struct  mic_data micdata;
        struct  sta_info *stainfo;
@@ -369,7 +368,6 @@ static sint xmitframe_addmic(struct _adapter *padapter,
                        u8 null_key[16] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
                                           0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
                                           0x0, 0x0};
-                       datalen = pattrib->pktlen - pattrib->hdrlen;
                        pframe = pxmitframe->buf_addr + TXDESC_OFFSET;
                        if (bmcst) {
                                if (!memcmp(psecuritypriv->XGrptxmickey
@@ -486,7 +484,7 @@ static sint make_wlanhdr(struct _adapter *padapter , u8 *hdr,
        memset(hdr, 0, WLANHDR_OFFSET);
        SetFrameSubType(fctrl, pattrib->subtype);
        if (pattrib->subtype & WIFI_DATA_TYPE) {
-               if ((check_fwstate(pmlmepriv,  WIFI_STATION_STATE) == true)) {
+               if (check_fwstate(pmlmepriv,  WIFI_STATION_STATE) == true) {
                        /* to_ds = 1, fr_ds = 0; */
                        SetToDs(fctrl);
                        memcpy(pwlanhdr->addr1, get_bssid(pmlmepriv),
@@ -825,16 +823,13 @@ void r8712_free_xmitframe(struct xmit_priv *pxmitpriv,
        unsigned long irqL;
        struct  __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue;
        struct _adapter *padapter = pxmitpriv->adapter;
-       struct sk_buff *pndis_pkt = NULL;
 
        if (pxmitframe == NULL)
                return;
        spin_lock_irqsave(&pfree_xmit_queue->lock, irqL);
        list_del_init(&pxmitframe->list);
-       if (pxmitframe->pkt) {
-               pndis_pkt = pxmitframe->pkt;
+       if (pxmitframe->pkt)
                pxmitframe->pkt = NULL;
-       }
        list_add_tail(&pxmitframe->list, &pfree_xmit_queue->queue);
        pxmitpriv->free_xmitframe_cnt++;
        spin_unlock_irqrestore(&pfree_xmit_queue->lock, irqL);
index a3d733b..7d0d171 100644 (file)
@@ -255,9 +255,6 @@ static struct drv_priv drvpriv = {
 static uint r8712_usb_dvobj_init(struct _adapter *padapter)
 {
        uint    status = _SUCCESS;
-       struct  usb_device_descriptor           *pdev_desc;
-       struct  usb_host_config                 *phost_conf;
-       struct  usb_config_descriptor           *pconf_desc;
        struct  usb_host_interface              *phost_iface;
        struct  usb_interface_descriptor        *piface_desc;
        struct dvobj_priv *pdvobjpriv = &padapter->dvobjpriv;
@@ -265,9 +262,6 @@ static uint r8712_usb_dvobj_init(struct _adapter *padapter)
 
        pdvobjpriv->padapter = padapter;
        padapter->EepromAddressSize = 6;
-       pdev_desc = &pusbd->descriptor;
-       phost_conf = pusbd->actconfig;
-       pconf_desc = &phost_conf->desc;
        phost_iface = &pintf->altsetting[0];
        piface_desc = &phost_iface->desc;
        pdvobjpriv->nr_endpoint = piface_desc->bNumEndpoints;
@@ -292,13 +286,13 @@ static void r8712_usb_dvobj_deinit(struct _adapter *padapter)
 void rtl871x_intf_stop(struct _adapter *padapter)
 {
        /*disable_hw_interrupt*/
-       if (padapter->bSurpriseRemoved == false) {
+       if (!padapter->bSurpriseRemoved) {
                /*device still exists, so driver can do i/o operation
                 * TODO: */
        }
 
        /* cancel in irp */
-       if (padapter->dvobjpriv.inirp_deinit != NULL)
+       if (padapter->dvobjpriv.inirp_deinit)
                padapter->dvobjpriv.inirp_deinit(padapter);
        /* cancel out irp */
        r8712_usb_write_port_cancel(padapter);
@@ -318,7 +312,7 @@ void r871x_dev_unload(struct _adapter *padapter)
                r8712_stop_drv_threads(padapter);
 
                /*s5.*/
-               if (padapter->bSurpriseRemoved == false) {
+               if (!padapter->bSurpriseRemoved) {
                        padapter->hw_init_completed = false;
                        rtl8712_hal_deinit(padapter);
                }
@@ -402,7 +396,7 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf,
        /* step 3.
         * initialize the dvobj_priv
         */
-       if (padapter->dvobj_init == NULL)
+       if (!padapter->dvobj_init)
                        goto error;
        else {
                status = padapter->dvobj_init(padapter);
@@ -568,7 +562,7 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf,
                    ((mac[0] == 0x00) && (mac[1] == 0x00) &&
                     (mac[2] == 0x00) && (mac[3] == 0x00) &&
                     (mac[4] == 0x00) && (mac[5] == 0x00)) ||
-                    (AutoloadFail == false)) {
+                    (!AutoloadFail)) {
                        mac[0] = 0x00;
                        mac[1] = 0xe0;
                        mac[2] = 0x4c;
index e89d2b0..c3a4e3f 100644 (file)
@@ -168,7 +168,6 @@ static void usb_write_mem_complete(struct urb *purb)
 void r8712_usb_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem)
 {
        unsigned int pipe;
-       int status;
        struct _adapter *padapter = (struct _adapter *)pintfhdl->adapter;
        struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
        struct io_queue *pio_queue = (struct io_queue *)padapter->pio_queue;
@@ -186,7 +185,7 @@ void r8712_usb_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem)
        usb_fill_bulk_urb(piorw_urb, pusbd, pipe,
                          wmem, cnt, usb_write_mem_complete,
                          pio_queue);
-       status = usb_submit_urb(piorw_urb, GFP_ATOMIC);
+       usb_submit_urb(piorw_urb, GFP_ATOMIC);
        _down_sema(&pintfpriv->io_retevt);
 }
 
@@ -267,7 +266,7 @@ u32 r8712_usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem)
        if (adapter->bDriverStopped || adapter->bSurpriseRemoved ||
            adapter->pwrctrlpriv.pnp_bstop_trx)
                return _FAIL;
-       if ((precvbuf->reuse == false) || (precvbuf->pskb == NULL)) {
+       if (!precvbuf->reuse == false || !precvbuf->pskb) {
                precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue);
                if (NULL != precvbuf->pskb)
                        precvbuf->reuse = true;
@@ -275,10 +274,10 @@ u32 r8712_usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem)
        if (precvbuf != NULL) {
                r8712_init_recvbuf(adapter, precvbuf);
                /* re-assign for linux based on skb */
-               if ((precvbuf->reuse == false) || (precvbuf->pskb == NULL)) {
+               if (!precvbuf->reuse || !precvbuf->pskb) {
                        precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev,
                                         MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ);
-                       if (precvbuf->pskb == NULL)
+                       if (!precvbuf->pskb)
                                return _FAIL;
                        tmpaddr = (addr_t)precvbuf->pskb->data;
                        alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1);
index 0ac9130..039b598 100644 (file)
@@ -79,7 +79,6 @@ sint r8712_endofpktfile(struct pkt_file *pfile)
 
 void r8712_set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib)
 {
-       int i;
        struct ethhdr etherhdr;
        struct iphdr ip_hdr;
        u16 UserPriority = 0;
@@ -89,8 +88,7 @@ void r8712_set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib)
 
        /* get UserPriority from IP hdr*/
        if (pattrib->ether_type == 0x0800) {
-               i = _r8712_pktfile_read(ppktfile, (u8 *)&ip_hdr,
-                                       sizeof(ip_hdr));
+               _r8712_pktfile_read(ppktfile, (u8 *)&ip_hdr, sizeof(ip_hdr));
                /*UserPriority = (ntohs(ip_hdr.tos) >> 5) & 0x3 ;*/
                UserPriority = ip_hdr.tos >> 5;
        } else {
index 6b4092f..e394d12 100644 (file)
@@ -231,12 +231,10 @@ void      expire_timeout_chk23a(struct rtw_adapter *padapter)
                        psta->expire_to--;
                }
 
-               if (psta->expire_to <= 0)
-               {
+               if (psta->expire_to <= 0) {
                        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 
-                       if (padapter->registrypriv.wifi_spec == 1)
-                       {
+                       if (padapter->registrypriv.wifi_spec == 1) {
                                psta->expire_to = pstapriv->expire_to;
                                continue;
                        }
@@ -308,15 +306,12 @@ void      expire_timeout_chk23a(struct rtw_adapter *padapter)
                        ret = issue_nulldata23a(padapter, psta->hwaddr, 0, 3, 50);
 
                psta->keep_alive_trycnt++;
-               if (ret == _SUCCESS)
-               {
+               if (ret == _SUCCESS) {
                        DBG_8723A("asoc check, sta(" MAC_FMT ") is alive\n", MAC_ARG(psta->hwaddr));
                        psta->expire_to = pstapriv->expire_to;
                        psta->keep_alive_trycnt = 0;
                        continue;
-               }
-               else if (psta->keep_alive_trycnt <= 3)
-               {
+               } else if (psta->keep_alive_trycnt <= 3) {
                        DBG_8723A("ack check for asoc expire, keep_alive_trycnt =%d\n", psta->keep_alive_trycnt);
                        psta->expire_to = 1;
                        continue;
@@ -363,8 +358,7 @@ void add_RATid23a(struct rtw_adapter *padapter, struct sta_info *psta, u8 rssi_l
                return;
 
        /* b/g mode ra_bitmap */
-       for (i = 0; i < sizeof(psta->bssrateset); i++)
-       {
+       for (i = 0; i < sizeof(psta->bssrateset); i++) {
                if (psta->bssrateset[i])
                        tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value23a(psta->bssrateset[i]&0x7f);
        }
@@ -406,8 +400,7 @@ void add_RATid23a(struct rtw_adapter *padapter, struct sta_info *psta, u8 rssi_l
        raid = networktype_to_raid23a(sta_band);
        init_rate = get_highest_rate_idx23a(tx_ra_bitmap&0x0fffffff)&0x3f;
 
-       if (psta->aid < NUM_STA)
-       {
+       if (psta->aid < NUM_STA) {
                u8 arg = 0;
 
                arg = psta->mac_id&0x1f;
@@ -436,11 +429,8 @@ void add_RATid23a(struct rtw_adapter *padapter, struct sta_info *psta, u8 rssi_l
                psta->raid = raid;
                psta->init_rate = init_rate;
 
-       }
-       else
-       {
+       } else
                DBG_8723A("station aid %d exceed the max number\n", psta->aid);
-       }
 }
 
 static void update_bmc_sta(struct rtw_adapter *padapter)
@@ -453,8 +443,7 @@ static void update_bmc_sta(struct rtw_adapter *padapter)
        struct wlan_bssid_ex *pcur_network = &pmlmepriv->cur_network.network;
        struct sta_info *psta = rtw_get_bcmc_stainfo23a(padapter);
 
-       if (psta)
-       {
+       if (psta) {
                psta->aid = 0;/* default set to 0 */
                psta->mac_id = psta->aid + 1;
 
@@ -474,8 +463,7 @@ static void update_bmc_sta(struct rtw_adapter *padapter)
                psta->bssratelen = supportRateNum;
 
                /* b/g mode ra_bitmap */
-               for (i = 0; i < supportRateNum; i++)
-               {
+               for (i = 0; i < supportRateNum; i++) {
                        if (psta->bssrateset[i])
                                tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value23a(psta->bssrateset[i]&0x7f);
                }
@@ -522,11 +510,8 @@ static void update_bmc_sta(struct rtw_adapter *padapter)
                psta->state = _FW_LINKED;
                spin_unlock_bh(&psta->lock);
 
-       }
-       else
-       {
+       } else
                DBG_8723A("add_RATid23a_bmc_sta error!\n");
-       }
 }
 
 /* notes: */
@@ -561,8 +546,7 @@ void update_sta_info23a_apmode23a(struct rtw_adapter *padapter, struct sta_info
        /* ERP */
        VCS_update23a(padapter, psta);
        /* HT related cap */
-       if (phtpriv_sta->ht_option)
-       {
+       if (phtpriv_sta->ht_option) {
                /* check if sta supports rx ampdu */
                phtpriv_sta->ampdu_enable = phtpriv_ap->ampdu_enable;
 
@@ -580,9 +564,7 @@ void update_sta_info23a_apmode23a(struct rtw_adapter *padapter, struct sta_info
 
                psta->qos_option = true;
 
-       }
-       else
-       {
+       } else {
                phtpriv_sta->ampdu_enable = false;
 
                phtpriv_sta->sgi = false;
@@ -654,7 +636,7 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf)
 
        bcn_interval = (u16)pnetwork->beacon_interval;
        cur_channel = pnetwork->DSConfig;
-       cur_bwmode = HT_CHANNEL_WIDTH_20;;
+       cur_bwmode = HT_CHANNEL_WIDTH_20;
        cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
 
        /* check if there is wps ie, */
@@ -1122,7 +1104,6 @@ int rtw_acl_remove_sta23a(struct rtw_adapter *padapter, u8 *addr)
        struct sta_priv *pstapriv = &padapter->stapriv;
        struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
        struct rtw_queue *pacl_node_q = &pacl_list->acl_node_q;
-       int ret = 0;
 
        DBG_8723A("%s(acl_num =%d) = %pM\n", __func__, pacl_list->num, addr);
 
@@ -1148,7 +1129,7 @@ int rtw_acl_remove_sta23a(struct rtw_adapter *padapter, u8 *addr)
 
        DBG_8723A("%s, acl_num =%d\n", __func__, pacl_list->num);
 
-       return ret;
+       return 0;
 }
 
 static void update_bcn_fixed_ie(struct rtw_adapter *padapter)
@@ -1217,8 +1198,6 @@ static void update_bcn_wmm_ie(struct rtw_adapter *padapter)
 static void update_bcn_wps_ie(struct rtw_adapter *padapter)
 {
        DBG_8723A("%s\n", __func__);
-
-       return;
 }
 
 static void update_bcn_p2p_ie(struct rtw_adapter *padapter)
@@ -1261,8 +1240,7 @@ void update_beacon23a(struct rtw_adapter *padapter, u8 ie_id, u8 *oui, u8 tx)
 
        spin_lock_bh(&pmlmepriv->bcn_update_lock);
 
-       switch (ie_id)
-       {
+       switch (ie_id) {
        case 0xFF:
                /* 8: TimeStamp, 2: Beacon Interval 2:Capability */
                update_bcn_fixed_ie(padapter);
@@ -1389,8 +1367,7 @@ static int rtw_ht_operation_update(struct rtw_adapter *padapter)
 void associated_clients_update23a(struct rtw_adapter *padapter, u8 updated)
 {
        /* update associated stations cap. */
-       if (updated == true)
-       {
+       if (updated == true) {
                struct list_head *phead, *plist, *ptmp;
                struct sta_info *psta;
                struct sta_priv *pstapriv = &padapter->stapriv;
@@ -1416,34 +1393,27 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 
-       if (!(psta->flags & WLAN_STA_SHORT_PREAMBLE))
-       {
-               if (!psta->no_short_preamble_set)
-               {
+       if (!(psta->flags & WLAN_STA_SHORT_PREAMBLE)) {
+               if (!psta->no_short_preamble_set) {
                        psta->no_short_preamble_set = 1;
 
                        pmlmepriv->num_sta_no_short_preamble++;
 
                        if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) &&
-                               (pmlmepriv->num_sta_no_short_preamble == 1))
-                       {
+                               (pmlmepriv->num_sta_no_short_preamble == 1)) {
                                beacon_updated = true;
                                update_beacon23a(padapter, 0xFF, NULL, true);
                        }
 
                }
-       }
-       else
-       {
-               if (psta->no_short_preamble_set)
-               {
+       } else {
+               if (psta->no_short_preamble_set) {
                        psta->no_short_preamble_set = 0;
 
                        pmlmepriv->num_sta_no_short_preamble--;
 
                        if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) &&
-                               (pmlmepriv->num_sta_no_short_preamble == 0))
-                       {
+                               (pmlmepriv->num_sta_no_short_preamble == 0)) {
                                beacon_updated = true;
                                update_beacon23a(padapter, 0xFF, NULL, true);
                        }
@@ -1451,32 +1421,25 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info
                }
        }
 
-       if (psta->flags & WLAN_STA_NONERP)
-       {
-               if (!psta->nonerp_set)
-               {
+       if (psta->flags & WLAN_STA_NONERP) {
+               if (!psta->nonerp_set) {
                        psta->nonerp_set = 1;
 
                        pmlmepriv->num_sta_non_erp++;
 
-                       if (pmlmepriv->num_sta_non_erp == 1)
-                       {
+                       if (pmlmepriv->num_sta_non_erp == 1) {
                                beacon_updated = true;
                                update_beacon23a(padapter, WLAN_EID_ERP_INFO, NULL, true);
                        }
                }
 
-       }
-       else
-       {
-               if (psta->nonerp_set)
-               {
+       } else {
+               if (psta->nonerp_set) {
                        psta->nonerp_set = 0;
 
                        pmlmepriv->num_sta_non_erp--;
 
-                       if (pmlmepriv->num_sta_non_erp == 0)
-                       {
+                       if (pmlmepriv->num_sta_non_erp == 0) {
                                beacon_updated = true;
                                update_beacon23a(padapter, WLAN_EID_ERP_INFO, NULL, true);
                        }
@@ -1484,42 +1447,34 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info
 
        }
 
-       if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT_TIME))
-       {
-               if (!psta->no_short_slot_time_set)
-               {
+       if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)) {
+               if (!psta->no_short_slot_time_set) {
                        psta->no_short_slot_time_set = 1;
 
                        pmlmepriv->num_sta_no_short_slot_time++;
 
                        if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) &&
-                                (pmlmepriv->num_sta_no_short_slot_time == 1))
-                       {
+                                (pmlmepriv->num_sta_no_short_slot_time == 1)) {
                                beacon_updated = true;
                                update_beacon23a(padapter, 0xFF, NULL, true);
                        }
 
                }
-       }
-       else
-       {
-               if (psta->no_short_slot_time_set)
-               {
+       } else {
+               if (psta->no_short_slot_time_set) {
                        psta->no_short_slot_time_set = 0;
 
                        pmlmepriv->num_sta_no_short_slot_time--;
 
                        if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) &&
-                                (pmlmepriv->num_sta_no_short_slot_time == 0))
-                       {
+                                (pmlmepriv->num_sta_no_short_slot_time == 0)) {
                                beacon_updated = true;
                                update_beacon23a(padapter, 0xFF, NULL, true);
                        }
                }
        }
 
-       if (psta->flags & WLAN_STA_HT)
-       {
+       if (psta->flags & WLAN_STA_HT) {
                u16 ht_capab = le16_to_cpu(psta->htpriv.ht_cap.cap_info);
 
                DBG_8723A("HT: STA " MAC_FMT " HT Capabilities "
@@ -1552,9 +1507,7 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info
                                   pmlmepriv->num_sta_ht_20mhz);
                }
 
-       }
-       else
-       {
+       } else {
                if (!psta->no_ht_set) {
                        psta->no_ht_set = 1;
                        pmlmepriv->num_sta_no_ht++;
@@ -1567,8 +1520,7 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info
                }
        }
 
-       if (rtw_ht_operation_update(padapter) > 0)
-       {
+       if (rtw_ht_operation_update(padapter) > 0) {
                update_beacon23a(padapter, WLAN_EID_HT_CAPABILITY, NULL, false);
                update_beacon23a(padapter, WLAN_EID_HT_OPERATION, NULL, true);
        }
@@ -1592,8 +1544,7 @@ u8 bss_cap_update_on_sta_leave23a(struct rtw_adapter *padapter, struct sta_info
                psta->no_short_preamble_set = 0;
                pmlmepriv->num_sta_no_short_preamble--;
                if (pmlmeext->cur_wireless_mode > WIRELESS_11B
-                   && pmlmepriv->num_sta_no_short_preamble == 0)
-               {
+                   && pmlmepriv->num_sta_no_short_preamble == 0) {
                        beacon_updated = true;
                        update_beacon23a(padapter, 0xFF, NULL, true);
                }
@@ -1602,8 +1553,7 @@ u8 bss_cap_update_on_sta_leave23a(struct rtw_adapter *padapter, struct sta_info
        if (psta->nonerp_set) {
                psta->nonerp_set = 0;
                pmlmepriv->num_sta_non_erp--;
-               if (pmlmepriv->num_sta_non_erp == 0)
-               {
+               if (pmlmepriv->num_sta_non_erp == 0) {
                        beacon_updated = true;
                        update_beacon23a(padapter, WLAN_EID_ERP_INFO,
                                         NULL, true);
@@ -1614,8 +1564,7 @@ u8 bss_cap_update_on_sta_leave23a(struct rtw_adapter *padapter, struct sta_info
                psta->no_short_slot_time_set = 0;
                pmlmepriv->num_sta_no_short_slot_time--;
                if (pmlmeext->cur_wireless_mode > WIRELESS_11B
-                   && pmlmepriv->num_sta_no_short_slot_time == 0)
-               {
+                   && pmlmepriv->num_sta_no_short_slot_time == 0) {
                        beacon_updated = true;
                        update_beacon23a(padapter, 0xFF, NULL, true);
                }
@@ -1636,8 +1585,7 @@ u8 bss_cap_update_on_sta_leave23a(struct rtw_adapter *padapter, struct sta_info
                pmlmepriv->num_sta_ht_20mhz--;
        }
 
-       if (rtw_ht_operation_update(padapter) > 0)
-       {
+       if (rtw_ht_operation_update(padapter) > 0) {
                update_beacon23a(padapter, WLAN_EID_HT_CAPABILITY, NULL, false);
                update_beacon23a(padapter, WLAN_EID_HT_OPERATION, NULL, true);
        }
@@ -1657,8 +1605,7 @@ u8 ap_free_sta23a(struct rtw_adapter *padapter, struct sta_info *psta, bool acti
        if (!psta)
                return beacon_updated;
 
-       if (active == true)
-       {
+       if (active) {
                /* tear down Rx AMPDU */
                send_delba23a(padapter, 0, psta->hwaddr);/*  recipient */
 
@@ -1698,7 +1645,6 @@ u8 ap_free_sta23a(struct rtw_adapter *padapter, struct sta_info *psta, bool acti
 int rtw_ap_inform_ch_switch23a (struct rtw_adapter *padapter, u8 new_ch, u8 ch_offset)
 {
        struct list_head *phead, *plist;
-       int ret = 0;
        struct sta_info *psta = NULL;
        struct sta_priv *pstapriv = &padapter->stapriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
@@ -1706,7 +1652,7 @@ int rtw_ap_inform_ch_switch23a (struct rtw_adapter *padapter, u8 new_ch, u8 ch_o
        u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 
        if ((pmlmeinfo->state&0x03) != MSR_AP)
-               return ret;
+               return 0;
 
        DBG_8723A("%s(%s): with ch:%u, offset:%u\n", __func__,
                  padapter->pnetdev->name, new_ch, ch_offset);
@@ -1724,13 +1670,12 @@ int rtw_ap_inform_ch_switch23a (struct rtw_adapter *padapter, u8 new_ch, u8 ch_o
 
        issue_action_spct_ch_switch23a (padapter, bc_addr, new_ch, ch_offset);
 
-       return ret;
+       return 0;
 }
 
 int rtw_sta_flush23a(struct rtw_adapter *padapter)
 {
        struct list_head *phead, *plist, *ptmp;
-       int ret = 0;
        struct sta_info *psta;
        struct sta_priv *pstapriv = &padapter->stapriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
@@ -1743,7 +1688,7 @@ int rtw_sta_flush23a(struct rtw_adapter *padapter)
        DBG_8723A("%s(%s)\n", __func__, padapter->pnetdev->name);
 
        if ((pmlmeinfo->state&0x03) != MSR_AP)
-               return ret;
+               return 0;
 
        spin_lock_bh(&pstapriv->asoc_list_lock);
        phead = &pstapriv->asoc_list;
@@ -1769,7 +1714,7 @@ int rtw_sta_flush23a(struct rtw_adapter *padapter)
 
        associated_clients_update23a(padapter, true);
 
-       return ret;
+       return 0;
 }
 
 /* called > TSR LEVEL for USB or SDIO Interface*/
@@ -1788,13 +1733,10 @@ void sta_info_update23a(struct rtw_adapter *padapter, struct sta_info *psta)
                psta->qos_option = 0;
 
        /* update 802.11n ht cap. */
-       if (WLAN_STA_HT&flags)
-       {
+       if (WLAN_STA_HT&flags) {
                psta->htpriv.ht_option = true;
                psta->qos_option = 1;
-       }
-       else
-       {
+       } else {
                psta->htpriv.ht_option = false;
        }
 
@@ -1807,8 +1749,7 @@ void sta_info_update23a(struct rtw_adapter *padapter, struct sta_info *psta)
 /* called >= TSR LEVEL for USB or SDIO Interface*/
 void ap_sta_info_defer_update23a(struct rtw_adapter *padapter, struct sta_info *psta)
 {
-       if (psta->state & _FW_LINKED)
-       {
+       if (psta->state & _FW_LINKED) {
                /* add ratid */
                add_RATid23a(padapter, psta, 0);/* DM_RATR_STA_INIT */
        }
@@ -1819,7 +1760,7 @@ void rtw_ap_restore_network(struct rtw_adapter *padapter)
 {
        struct mlme_priv *mlmepriv = &padapter->mlmepriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct sta_priv * pstapriv = &padapter->stapriv;
+       struct sta_priv *pstapriv = &padapter->stapriv;
        struct sta_info *psta;
        struct security_priv *psecuritypriv = &padapter->securitypriv;
        struct list_head *phead, *plist, *ptmp;
index 4eaa502..44eae8e 100644 (file)
@@ -36,25 +36,25 @@ static struct cmd_hdl wlancmds[] = {
        GEN_MLME_EXT_HANDLER(0, NULL)
        GEN_MLME_EXT_HANDLER(0, NULL)
        GEN_MLME_EXT_HANDLER(0, NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct wlan_bssid_ex), join_cmd_hdl23a) /*14*/
-       GEN_MLME_EXT_HANDLER(sizeof (struct disconnect_parm), disconnect_hdl23a)
-       GEN_MLME_EXT_HANDLER(sizeof (struct wlan_bssid_ex), createbss_hdl23a)
-       GEN_MLME_EXT_HANDLER(sizeof (struct setopmode_parm), setopmode_hdl23a)
-       GEN_MLME_EXT_HANDLER(sizeof (struct sitesurvey_parm), sitesurvey_cmd_hdl23a) /*18*/
-       GEN_MLME_EXT_HANDLER(sizeof (struct setauth_parm), setauth_hdl23a)
-       GEN_MLME_EXT_HANDLER(sizeof (struct setkey_parm), setkey_hdl23a) /*20*/
-       GEN_MLME_EXT_HANDLER(sizeof (struct set_stakey_parm), set_stakey_hdl23a)
-       GEN_MLME_EXT_HANDLER(sizeof (struct set_assocsta_parm), NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct del_assocsta_parm), NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct setstapwrstate_parm), NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct setbasicrate_parm), NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct getbasicrate_parm), NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct setdatarate_parm), NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct getdatarate_parm), NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct setphyinfo_parm), NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct getphyinfo_parm), NULL)  /*30*/
-       GEN_MLME_EXT_HANDLER(sizeof (struct setphy_parm), NULL)
-       GEN_MLME_EXT_HANDLER(sizeof (struct getphy_parm), NULL)
+       GEN_MLME_EXT_HANDLER(sizeof(struct wlan_bssid_ex), join_cmd_hdl23a) /*14*/
+       GEN_MLME_EXT_HANDLER(sizeof(struct disconnect_parm), disconnect_hdl23a)
+       GEN_MLME_EXT_HANDLER(sizeof(struct wlan_bssid_ex), createbss_hdl23a)
+       GEN_MLME_EXT_HANDLER(sizeof(struct setopmode_parm), setopmode_hdl23a)
+       GEN_MLME_EXT_HANDLER(sizeof(struct sitesurvey_parm), sitesurvey_cmd_hdl23a) /*18*/
+       GEN_MLME_EXT_HANDLER(sizeof(struct setauth_parm), setauth_hdl23a)
+       GEN_MLME_EXT_HANDLER(sizeof(struct setkey_parm), setkey_hdl23a) /*20*/
+       GEN_MLME_EXT_HANDLER(sizeof(struct set_stakey_parm), set_stakey_hdl23a)
+       GEN_MLME_EXT_HANDLER(sizeof(struct set_assocsta_parm), NULL)
+       GEN_MLME_EXT_HANDLER(sizeof(struct del_assocsta_parm), NULL)
+       GEN_MLME_EXT_HANDLER(sizeof(struct setstapwrstate_parm), NULL)
+       GEN_MLME_EXT_HANDLER(sizeof(struct setbasicrate_parm), NULL)
+       GEN_MLME_EXT_HANDLER(sizeof(struct getbasicrate_parm), NULL)
+       GEN_MLME_EXT_HANDLER(sizeof(struct setdatarate_parm), NULL)
+       GEN_MLME_EXT_HANDLER(sizeof(struct getdatarate_parm), NULL)
+       GEN_MLME_EXT_HANDLER(sizeof(struct setphyinfo_parm), NULL)
+       GEN_MLME_EXT_HANDLER(sizeof(struct getphyinfo_parm), NULL)  /*30*/
+       GEN_MLME_EXT_HANDLER(sizeof(struct setphy_parm), NULL)
+       GEN_MLME_EXT_HANDLER(sizeof(struct getphy_parm), NULL)
        GEN_MLME_EXT_HANDLER(0, NULL)
        GEN_MLME_EXT_HANDLER(0, NULL)
        GEN_MLME_EXT_HANDLER(0, NULL)
@@ -359,6 +359,7 @@ int rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter,
        /* prepare ssid list */
        if (ssid) {
                int i;
+
                for (i = 0; i < ssid_num && i < RTW_SSID_SCAN_AMOUNT; i++) {
                        if (ssid[i].ssid_len) {
                                memcpy(&psurveyPara->ssid[i], &ssid[i],
@@ -371,6 +372,7 @@ int rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter,
        /* prepare channel list */
        if (ch) {
                int i;
+
                for (i = 0; i < ch_num && i < RTW_CHANNEL_SCAN_AMOUNT; i++) {
                        if (ch[i].hw_value &&
                            !(ch[i].flags & IEEE80211_CHAN_DISABLED)) {
@@ -599,7 +601,7 @@ exit:
        return res;
 }
 
-int rtw_disassoc_cmd23a(struct rtw_adapter*padapter, u32 deauth_timeout_ms,
+int rtw_disassoc_cmd23a(struct rtw_adapter *padapter, u32 deauth_timeout_ms,
                        bool enqueue)
 {
        struct cmd_obj *cmdobj = NULL;
@@ -719,6 +721,7 @@ int rtw_setstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 unicast_key)
                memcpy(&psetstakey_para->key, &sta->dot118021x_UncstKey, 16);
        } else {
                int idx = psecuritypriv->dot118021XGrpKeyid;
+
                memcpy(&psetstakey_para->key,
                       &psecuritypriv->dot118021XGrpKey[idx].skey, 16);
        }
@@ -786,7 +789,7 @@ exit:
        return res;
 }
 
-int rtw_addbareq_cmd23a(struct rtw_adapter*padapter, u8 tid, u8 *addr)
+int rtw_addbareq_cmd23a(struct rtw_adapter *padapter, u8 tid, u8 *addr)
 {
        struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
        struct cmd_obj *ph2c;
@@ -822,7 +825,7 @@ exit:
        return res;
 }
 
-int rtw_dynamic_chk_wk_cmd23a(struct rtw_adapter*padapter)
+int rtw_dynamic_chk_wk_cmd23a(struct rtw_adapter *padapter)
 {
        struct cmd_obj *ph2c;
        struct drvextra_cmd_parm *pdrvextra_cmd_parm;
@@ -859,7 +862,7 @@ exit:
  * This is only ever called from on_action_spct23a_ch_switch () which isn't
  * called from anywhere itself
  */
-int rtw_set_ch_cmd23a(struct rtw_adapter*padapter, u8 ch, u8 bw, u8 ch_offset,
+int rtw_set_ch_cmd23a(struct rtw_adapter *padapter, u8 ch, u8 bw, u8 ch_offset,
                      u8 enqueue)
 {
        struct cmd_obj *pcmdobj;
@@ -1017,46 +1020,45 @@ static void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type)
            check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))
                return;
 
-       switch (lps_ctrl_type)
-       {
-               case LPS_CTRL_SCAN:
-                       rtl8723a_BT_wifiscan_notify(padapter, true);
-                       if (!rtl8723a_BT_using_antenna_1(padapter)) {
-                               if (check_fwstate(pmlmepriv, _FW_LINKED))
-                                       LPS_Leave23a(padapter);
+       switch (lps_ctrl_type) {
+       case LPS_CTRL_SCAN:
+               rtl8723a_BT_wifiscan_notify(padapter, true);
+               if (!rtl8723a_BT_using_antenna_1(padapter)) {
+                       if (check_fwstate(pmlmepriv, _FW_LINKED))
+                               LPS_Leave23a(padapter);
                        }
-                       break;
-               case LPS_CTRL_JOINBSS:
+               break;
+       case LPS_CTRL_JOINBSS:
+               LPS_Leave23a(padapter);
+               break;
+       case LPS_CTRL_CONNECT:
+               mstatus = 1;/* connect */
+               /*  Reset LPS Setting */
+               padapter->pwrctrlpriv.LpsIdleCount = 0;
+               rtl8723a_set_FwJoinBssReport_cmd(padapter, 1);
+               rtl8723a_BT_mediastatus_notify(padapter, mstatus);
+               break;
+       case LPS_CTRL_DISCONNECT:
+               mstatus = 0;/* disconnect */
+               rtl8723a_BT_mediastatus_notify(padapter, mstatus);
+               if (!rtl8723a_BT_using_antenna_1(padapter))
                        LPS_Leave23a(padapter);
-                       break;
-               case LPS_CTRL_CONNECT:
-                       mstatus = 1;/* connect */
-                       /*  Reset LPS Setting */
-                       padapter->pwrctrlpriv.LpsIdleCount = 0;
-                       rtl8723a_set_FwJoinBssReport_cmd(padapter, 1);
-                       rtl8723a_BT_mediastatus_notify(padapter, mstatus);
-                       break;
-               case LPS_CTRL_DISCONNECT:
-                       mstatus = 0;/* disconnect */
-                       rtl8723a_BT_mediastatus_notify(padapter, mstatus);
-                       if (!rtl8723a_BT_using_antenna_1(padapter))
-                               LPS_Leave23a(padapter);
-                       rtl8723a_set_FwJoinBssReport_cmd(padapter, 0);
-                       break;
-               case LPS_CTRL_SPECIAL_PACKET:
-                       pwrpriv->DelayLPSLastTimeStamp = jiffies;
-                       rtl8723a_BT_specialpacket_notify(padapter);
-                       if (!rtl8723a_BT_using_antenna_1(padapter))
-                               LPS_Leave23a(padapter);
-                       break;
-               case LPS_CTRL_LEAVE:
-                       rtl8723a_BT_lps_leave(padapter);
-                       if (!rtl8723a_BT_using_antenna_1(padapter))
-                               LPS_Leave23a(padapter);
-                       break;
+               rtl8723a_set_FwJoinBssReport_cmd(padapter, 0);
+               break;
+       case LPS_CTRL_SPECIAL_PACKET:
+               pwrpriv->DelayLPSLastTimeStamp = jiffies;
+               rtl8723a_BT_specialpacket_notify(padapter);
+               if (!rtl8723a_BT_using_antenna_1(padapter))
+                       LPS_Leave23a(padapter);
+               break;
+       case LPS_CTRL_LEAVE:
+               rtl8723a_BT_lps_leave(padapter);
+               if (!rtl8723a_BT_using_antenna_1(padapter))
+                       LPS_Leave23a(padapter);
+               break;
 
-               default:
-                       break;
+       default:
+               break;
        }
 }
 
@@ -1098,7 +1100,7 @@ exit:
        return res;
 }
 
-int rtw_ps_cmd23a(struct rtw_adapter*padapter)
+int rtw_ps_cmd23a(struct rtw_adapter *padapter)
 {
        struct cmd_obj *ppscmd;
        struct drvextra_cmd_parm *pdrvextra_cmd_parm;
@@ -1147,7 +1149,7 @@ static void rtw_chk_hi_queue_hdl(struct rtw_adapter *padapter)
 
                val = rtl8723a_chk_hi_queue_empty(padapter);
 
-               while (val == false) {
+               while (!val) {
                        msleep(100);
 
                        cnt++;
@@ -1168,7 +1170,7 @@ static void rtw_chk_hi_queue_hdl(struct rtw_adapter *padapter)
        }
 }
 
-int rtw_chk_hi_queue_cmd23a(struct rtw_adapter*padapter)
+int rtw_chk_hi_queue_cmd23a(struct rtw_adapter *padapter)
 {
        struct cmd_obj *ph2c;
        struct drvextra_cmd_parm *pdrvextra_cmd_parm;
@@ -1305,8 +1307,7 @@ int rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 
        pdrvextra_cmd = (struct drvextra_cmd_parm *)pbuf;
 
-       switch (pdrvextra_cmd->ec_id)
-       {
+       switch (pdrvextra_cmd->ec_id) {
        case DYNAMIC_CHK_WK_CID:
                dynamic_chk_wk_hdl(padapter, pdrvextra_cmd->pbuf,
                                   pdrvextra_cmd->type_size);
index 9f6ce7d..81960e7 100644 (file)
@@ -117,12 +117,7 @@ Efuse_GetCurrentSize23a(struct rtw_adapter *pAdapter, u8 efuseType)
 u8
 Efuse_CalculateWordCnts23a(u8 word_en)
 {
-       u8 word_cnts = 0;
-       if (!(word_en & BIT(0)))        word_cnts++; /*  0 : write enable */
-       if (!(word_en & BIT(1)))        word_cnts++;
-       if (!(word_en & BIT(2)))        word_cnts++;
-       if (!(word_en & BIT(3)))        word_cnts++;
-       return word_cnts;
+       return hweight8((~word_en) & 0xf);
 }
 
 /*  */
@@ -181,7 +176,7 @@ EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType,
 
        switch (type) {
        case TYPE_EFUSE_MAX_SECTION:
-               pMax_section = (u8 *) pOut;
+               pMax_section = pOut;
 
                if (efuseType == EFUSE_WIFI)
                        *pMax_section = EFUSE_MAX_SECTION_8723A;
@@ -190,7 +185,7 @@ EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType,
                break;
 
        case TYPE_EFUSE_REAL_CONTENT_LEN:
-               pu2Tmp = (u16 *) pOut;
+               pu2Tmp = pOut;
 
                if (efuseType == EFUSE_WIFI)
                        *pu2Tmp = EFUSE_REAL_CONTENT_LEN_8723A;
@@ -199,7 +194,7 @@ EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType,
                break;
 
        case TYPE_AVAILABLE_EFUSE_BYTES_BANK:
-               pu2Tmp = (u16 *) pOut;
+               pu2Tmp = pOut;
 
                if (efuseType == EFUSE_WIFI)
                        *pu2Tmp = (EFUSE_REAL_CONTENT_LEN_8723A -
@@ -210,7 +205,7 @@ EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType,
                break;
 
        case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL:
-               pu2Tmp = (u16 *) pOut;
+               pu2Tmp = pOut;
 
                if (efuseType == EFUSE_WIFI)
                        *pu2Tmp = (EFUSE_REAL_CONTENT_LEN_8723A -
@@ -221,7 +216,7 @@ EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType,
                break;
 
        case TYPE_EFUSE_MAP_LEN:
-               pu2Tmp = (u16 *) pOut;
+               pu2Tmp = pOut;
 
                if (efuseType == EFUSE_WIFI)
                        *pu2Tmp = EFUSE_MAP_LEN_8723A;
@@ -230,7 +225,7 @@ EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType,
                break;
 
        case TYPE_EFUSE_PROTECT_BYTES_BANK:
-               pu1Tmp = (u8 *) pOut;
+               pu1Tmp = pOut;
 
                if (efuseType == EFUSE_WIFI)
                        *pu1Tmp = EFUSE_OOB_PROTECT_BYTES;
@@ -239,7 +234,7 @@ EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType,
                break;
 
        case TYPE_EFUSE_CONTENT_LEN_BANK:
-               pu2Tmp = (u16 *) pOut;
+               pu2Tmp = pOut;
 
                if (efuseType == EFUSE_WIFI)
                        *pu2Tmp = EFUSE_REAL_CONTENT_LEN_8723A;
@@ -248,7 +243,7 @@ EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType,
                break;
 
        default:
-               pu1Tmp = (u8 *) pOut;
+               pu1Tmp = pOut;
                *pu1Tmp = 0;
                break;
        }
index 6274cb3..bbbcfc8 100644 (file)
@@ -69,6 +69,7 @@ int rtw_get_bit_value_from_ieee_value23a(u8 val)
                {2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 0};
 
        int i = 0;
+
        while (dot11_rate_table[i] != 0) {
                if (dot11_rate_table[i] == val)
                        return BIT(i);
@@ -301,8 +302,7 @@ void rtw_set_supported_rate23a(u8 *SupportedRates, uint mode)
 
        memset(SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX);
 
-       switch (mode)
-       {
+       switch (mode) {
        case WIRELESS_11B:
                memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN);
                break;
index 989cda2..92ab1f8 100644 (file)
@@ -44,6 +44,7 @@ static void BlinkTimerCallback(unsigned long data)
 void BlinkWorkItemCallback23a(struct work_struct *work)
 {
        struct led_8723a *pLed = container_of(work, struct led_8723a, BlinkWorkItem);
+
        BlinkHandler23a(pLed);
 }
 
@@ -51,7 +52,8 @@ void BlinkWorkItemCallback23a(struct work_struct *work)
 /*     Description: */
 /*             Reset status of led_8723a object. */
 /*  */
-void ResetLedStatus23a(struct led_8723a * pLed) {
+void ResetLedStatus23a(struct led_8723a *pLed)
+{
 
        pLed->CurrLedState = RTW_LED_OFF; /*  Current LED state. */
        pLed->bLedOn = false; /*  true if LED is ON, false if LED is OFF. */
@@ -422,29 +424,23 @@ static void SwLedBlink3(struct led_8723a *pLed)
        u8 bStopBlinking = false;
 
        /*  Change LED according to BlinkingLedState specified. */
-       if (pLed->BlinkingLedState == RTW_LED_ON)
-       {
+       if (pLed->BlinkingLedState == RTW_LED_ON) {
                SwLedOn23a(padapter, pLed);
                RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes));
-       }
-       else
-       {
+       } else {
                if (pLed->CurrLedState != LED_BLINK_WPS_STOP)
                        SwLedOff23a(padapter, pLed);
                RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes));
        }
 
-       switch (pLed->CurrLedState)
-       {
+       switch (pLed->CurrLedState) {
                case LED_BLINK_SCAN:
                        pLed->BlinkTimes--;
-                       if (pLed->BlinkTimes == 0)
-                       {
+                       if (pLed->BlinkTimes == 0) {
                                bStopBlinking = true;
                        }
 
-                       if (bStopBlinking)
-                       {
+                       if (bStopBlinking) {
                                if (padapter->pwrctrlpriv.rf_pwrstate != rf_on)
                                {
                                        SwLedOff23a(padapter, pLed);
@@ -465,15 +461,11 @@ static void SwLedBlink3(struct led_8723a *pLed)
                                        RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState));
                                }
                                pLed->bLedScanBlinkInProgress = false;
-                       }
-                       else
-                       {
+                       } else {
                                if (padapter->pwrctrlpriv.rf_pwrstate != rf_on)
                                {
                                        SwLedOff23a(padapter, pLed);
-                               }
-                               else
-                               {
+                               } else {
                                        if (pLed->bLedOn)
                                                pLed->BlinkingLedState = RTW_LED_OFF;
                                        else
@@ -486,12 +478,10 @@ static void SwLedBlink3(struct led_8723a *pLed)
 
                case LED_BLINK_TXRX:
                        pLed->BlinkTimes--;
-                       if (pLed->BlinkTimes == 0)
-                       {
+                       if (pLed->BlinkTimes == 0) {
                                bStopBlinking = true;
                        }
-                       if (bStopBlinking)
-                       {
+                       if (bStopBlinking) {
                                if (padapter->pwrctrlpriv.rf_pwrstate != rf_on)
                                {
                                        SwLedOff23a(padapter, pLed);
@@ -514,15 +504,11 @@ static void SwLedBlink3(struct led_8723a *pLed)
                                        RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState));
                                }
                                pLed->bLedBlinkInProgress = false;
-                       }
-                       else
-                       {
+                       } else {
                                if (padapter->pwrctrlpriv.rf_pwrstate != rf_on)
                                {
                                        SwLedOff23a(padapter, pLed);
-                               }
-                               else
-                               {
+                               } else {
                                        if (pLed->bLedOn)
                                                pLed->BlinkingLedState = RTW_LED_OFF;
                                        else
@@ -543,8 +529,7 @@ static void SwLedBlink3(struct led_8723a *pLed)
                        break;
 
                case LED_BLINK_WPS_STOP:        /* WPS success */
-                       if (pLed->BlinkingLedState == RTW_LED_ON)
-                       {
+                       if (pLed->BlinkingLedState == RTW_LED_ON) {
                                pLed->BlinkingLedState = RTW_LED_OFF;
                                mod_timer(&pLed->BlinkTimer, jiffies +
                                          msecs_to_jiffies(LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA));
@@ -553,8 +538,7 @@ static void SwLedBlink3(struct led_8723a *pLed)
                                bStopBlinking = true;
                        }
 
-                       if (bStopBlinking)
-                       {
+                       if (bStopBlinking) {
                                if (padapter->pwrctrlpriv.rf_pwrstate != rf_on)
                                {
                                        SwLedOff23a(padapter, pLed);
@@ -584,8 +568,7 @@ static void SwLedBlink4(struct led_8723a *pLed)
        unsigned long delay = 0;
 
        /*  Change LED according to BlinkingLedState specified. */
-       if (pLed->BlinkingLedState == RTW_LED_ON)
-       {
+       if (pLed->BlinkingLedState == RTW_LED_ON) {
                SwLedOn23a(padapter, pLed);
                RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes));
        } else {
@@ -600,8 +583,7 @@ static void SwLedBlink4(struct led_8723a *pLed)
                SwLedOff23a(padapter, pLed1);
        }
 
-       switch (pLed->CurrLedState)
-       {
+       switch (pLed->CurrLedState) {
                case LED_BLINK_SLOWLY:
                        if (pLed->bLedOn)
                                pLed->BlinkingLedState = RTW_LED_OFF;
@@ -750,8 +732,7 @@ static void SwLedBlink5(struct led_8723a *pLed)
                RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes));
        }
 
-       switch (pLed->CurrLedState)
-       {
+       switch (pLed->CurrLedState) {
                case LED_BLINK_SCAN:
                        pLed->BlinkTimes--;
                        if (pLed->BlinkTimes == 0) {
@@ -853,8 +834,7 @@ SwLedControlMode1(struct rtw_adapter *padapter, enum led_ctl_mode LedAction)
 
        long delay = -1;
 
-       switch (LedAction)
-       {
+       switch (LedAction) {
                case LED_CTL_POWER_ON:
                case LED_CTL_START_TO_LINK:
                case LED_CTL_NO_LINK:
@@ -1183,8 +1163,7 @@ SwLedControlMode2(struct rtw_adapter *padapter, enum led_ctl_mode LedAction)
                break;
        case LED_CTL_START_TO_LINK:
        case LED_CTL_NO_LINK:
-               if (!IS_LED_BLINKING(pLed))
-               {
+               if (!IS_LED_BLINKING(pLed)) {
                        pLed->CurrLedState = RTW_LED_OFF;
                        pLed->BlinkingLedState = RTW_LED_OFF;
                        delay = 0;
@@ -1228,8 +1207,7 @@ SwLedControlMode3(struct rtw_adapter *padapter, enum led_ctl_mode LedAction)
        struct led_8723a *pLed = &ledpriv->SwLed0;
        long delay = -1;
 
-       switch (LedAction)
-       {
+       switch (LedAction) {
                case LED_CTL_SITE_SURVEY:
                        if (pmlmepriv->LinkDetectInfo.bBusyTraffic)
                                ;
@@ -1343,8 +1321,7 @@ SwLedControlMode3(struct rtw_adapter *padapter, enum led_ctl_mode LedAction)
 
                case LED_CTL_START_TO_LINK:
                case LED_CTL_NO_LINK:
-                       if (!IS_LED_BLINKING(pLed))
-                       {
+                       if (!IS_LED_BLINKING(pLed)) {
                                pLed->CurrLedState = RTW_LED_OFF;
                                pLed->BlinkingLedState = RTW_LED_OFF;
                                delay = 0;
@@ -1390,8 +1367,7 @@ SwLedControlMode4(struct rtw_adapter *padapter, enum led_ctl_mode LedAction)
        struct led_8723a *pLed = &ledpriv->SwLed0;
        struct led_8723a *pLed1 = &ledpriv->SwLed1;
 
-       switch (LedAction)
-       {
+       switch (LedAction) {
                case LED_CTL_START_TO_LINK:
                        if (pLed1->bLedWPSBlinkInProgress) {
                                pLed1->bLedWPSBlinkInProgress = false;
@@ -1548,8 +1524,7 @@ SwLedControlMode4(struct rtw_adapter *padapter, enum led_ctl_mode LedAction)
                                }
                                pLed->bLedWPSBlinkInProgress = true;
                                pLed->CurrLedState = LED_BLINK_WPS;
-                               if (pLed->bLedOn)
-                               {
+                               if (pLed->bLedOn) {
                                        pLed->BlinkingLedState = RTW_LED_OFF;
                                        mod_timer(&pLed->BlinkTimer, jiffies +
                                                  msecs_to_jiffies(LED_BLINK_SLOWLY_INTERVAL));
@@ -1695,8 +1670,7 @@ SwLedControlMode5(struct rtw_adapter *padapter, enum led_ctl_mode LedAction)
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct led_8723a *pLed = &ledpriv->SwLed0;
 
-       switch (LedAction)
-       {
+       switch (LedAction) {
                case LED_CTL_POWER_ON:
                case LED_CTL_NO_LINK:
                case LED_CTL_LINK:      /* solid blue */
@@ -1710,10 +1684,8 @@ SwLedControlMode5(struct rtw_adapter *padapter, enum led_ctl_mode LedAction)
                        if (pmlmepriv->LinkDetectInfo.bBusyTraffic &&
                            check_fwstate(pmlmepriv, _FW_LINKED))
                                ;
-                       else if (pLed->bLedScanBlinkInProgress == false)
-                       {
-                               if (pLed->bLedBlinkInProgress == true)
-                               {
+                       else if (pLed->bLedScanBlinkInProgress == false) {
+                               if (pLed->bLedBlinkInProgress == true) {
                                        del_timer_sync(&pLed->BlinkTimer);
                                        pLed->bLedBlinkInProgress = false;
                                }
index 1f60064..85d1eca 100644 (file)
@@ -50,7 +50,6 @@ static void rtw_init_mlme_timer(struct rtw_adapter *padapter)
 int rtw_init_mlme_priv23a(struct rtw_adapter *padapter)
 {
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       int res = _SUCCESS;
 
        pmlmepriv->nic_hdl = padapter;
 
@@ -68,7 +67,7 @@ int rtw_init_mlme_priv23a(struct rtw_adapter *padapter)
        rtw_clear_scan_deny(padapter);
 
        rtw_init_mlme_timer(padapter);
-       return res;
+       return _SUCCESS;
 }
 
 #ifdef CONFIG_8723AU_AP_MODE
@@ -110,7 +109,6 @@ struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv, gfp_t gfp)
                pnetwork->network_type = 0;
                pnetwork->fixed = false;
                pnetwork->last_scanned = jiffies;
-               pnetwork->aid = 0;
                pnetwork->join_res = 0;
        }
 
@@ -218,8 +216,6 @@ void rtw_generate_random_ibss23a(u8 *pibss)
        pibss[3] = curtime & 0xff;/* p[0]; */
        pibss[4] = (curtime >> 8) & 0xff;/* p[1]; */
        pibss[5] = (curtime >> 16) & 0xff;/* p[2]; */
-
-       return;
 }
 
 void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming)
@@ -356,12 +352,12 @@ rtw_get_oldest_wlan_network23a(struct rtw_queue *scanned_queue)
 void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src,
                       struct rtw_adapter *padapter, bool update_ie)
 {
-       u8 ss_ori = dst->PhyInfo.SignalStrength;
-       u8 sq_ori = dst->PhyInfo.SignalQuality;
+       u8 ss_ori = dst->SignalStrength;
+       u8 sq_ori = dst->SignalQuality;
        long rssi_ori = dst->Rssi;
 
-       u8 ss_smp = src->PhyInfo.SignalStrength;
-       u8 sq_smp = src->PhyInfo.SignalQuality;
+       u8 ss_smp = src->SignalStrength;
+       u8 sq_smp = src->SignalQuality;
        long rssi_smp = src->Rssi;
 
        u8 ss_final;
@@ -389,16 +385,16 @@ void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src,
                        rssi_final = rssi_ori;
        } 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;
+                       ss_final = ((u32)src->SignalStrength +
+                                   (u32)dst->SignalStrength * 4) / 5;
+                       sq_final = ((u32)src->SignalQuality +
+                                   (u32)dst->SignalQuality * 4) / 5;
                        rssi_final = src->Rssi+dst->Rssi * 4 / 5;
                } else {
                        /* bss info not receiving from the right channel, use
                           the original RX signal infos */
-                       ss_final = dst->PhyInfo.SignalStrength;
-                       sq_final = dst->PhyInfo.SignalQuality;
+                       ss_final = dst->SignalStrength;
+                       sq_final = dst->SignalQuality;
                        rssi_final = dst->Rssi;
                }
 
@@ -407,14 +403,13 @@ void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src,
        if (update_ie)
                memcpy(dst, src, get_wlan_bssid_ex_sz(src));
 
-       dst->PhyInfo.SignalStrength = ss_final;
-       dst->PhyInfo.SignalQuality = sq_final;
+       dst->SignalStrength = ss_final;
+       dst->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,
-                 dst->PhyInfo.SignalStrength,
-                 dst->PhyInfo.SignalQuality, dst->Rssi);
+                 dst->SignalStrength, dst->SignalQuality, dst->Rssi);
 }
 
 static void update_current_network(struct rtw_adapter *adapter,
@@ -487,12 +482,11 @@ static void rtw_update_scanned_network(struct rtw_adapter *adapter,
                pnetwork->last_scanned = jiffies;
 
                pnetwork->network_type = 0;
-               pnetwork->aid = 0;
                pnetwork->join_res = 0;
 
                /* bss info not receiving from the right channel */
-               if (pnetwork->network.PhyInfo.SignalQuality == 101)
-                       pnetwork->network.PhyInfo.SignalQuality = 0;
+               if (pnetwork->network.SignalQuality == 101)
+                       pnetwork->network.SignalQuality = 0;
        } else {
                /*
                 * we have an entry and we are going to update it. But
@@ -579,8 +573,6 @@ void rtw_atimdone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf)
 {
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
                 ("receive atimdone_evet\n"));
-
-       return;
 }
 
 void rtw_survey_event_cb23a(struct rtw_adapter *adapter, const u8 *pbuf)
@@ -650,8 +642,6 @@ exit:
 
        kfree(survey->bss);
        survey->bss = NULL;
-
-       return;
 }
 
 void
@@ -1028,19 +1018,17 @@ rtw_joinbss_update_network23a(struct rtw_adapter *padapter,
        cur_network->network.beacon_interval =
                ptarget_wlan->network.beacon_interval;
        cur_network->network.tsf = ptarget_wlan->network.tsf;
-       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;
+               ptarget_wlan->network.SignalStrength;
+       padapter->recvpriv.signal_qual = ptarget_wlan->network.SignalQuality;
        /*
         * the ptarget_wlan->network.Rssi is raw data, we use
-        * ptarget_wlan->network.PhyInfo.SignalStrength instead (has scaled)
+        * ptarget_wlan->network.SignalStrength instead (has scaled)
         */
        padapter->recvpriv.rssi = translate_percentage_to_dbm(
-               ptarget_wlan->network.PhyInfo.SignalStrength);
+               ptarget_wlan->network.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);
@@ -1132,7 +1120,7 @@ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf)
                if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) {
                        /* s1. find ptarget_wlan */
                        if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-                               if (the_same_macaddr == true) {
+                               if (the_same_macaddr) {
                                        ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, cur_network->network.MacAddress);
                                } else {
                                        pcur_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, cur_network->network.MacAddress);
@@ -1515,18 +1503,21 @@ out:
 inline bool rtw_is_scan_deny(struct rtw_adapter *adapter)
 {
        struct mlme_priv *mlmepriv = &adapter->mlmepriv;
+
        return (atomic_read(&mlmepriv->set_scan_deny) != 0) ? true : false;
 }
 
 void rtw_clear_scan_deny(struct rtw_adapter *adapter)
 {
        struct mlme_priv *mlmepriv = &adapter->mlmepriv;
+
        atomic_set(&mlmepriv->set_scan_deny, 0);
 }
 
 void rtw_set_scan_deny_timer_hdl(unsigned long data)
 {
        struct rtw_adapter *adapter = (struct rtw_adapter *)data;
+
        rtw_clear_scan_deny(adapter);
 }
 
@@ -1540,7 +1531,8 @@ void rtw_set_scan_deny(struct rtw_adapter *adapter, u32 ms)
 }
 
 #if defined(IEEE80211_SCAN_RESULT_EXPIRE)
-#define RTW_SCAN_RESULT_EXPIRE IEEE80211_SCAN_RESULT_EXPIRE/HZ*1000 -1000 /* 3000 -1000 */
+#define RTW_SCAN_RESULT_EXPIRE  \
+       ((IEEE80211_SCAN_RESULT_EXPIRE / (HZ*1000)) - 1000) /* 3000 -1000 */
 #else
 #define RTW_SCAN_RESULT_EXPIRE 2000
 #endif
@@ -1766,7 +1758,7 @@ exit:
        return ret;
 }
 
-int rtw_set_auth23a(struct rtw_adapter * adapter,
+int rtw_set_auth23a(struct rtw_adapter *adapter,
                    struct security_priv *psecuritypriv)
 {
        struct cmd_obj *pcmd;
@@ -2151,6 +2143,7 @@ bool rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie,
 
        if (p && p[1] > 0) {
                u32 rx_packet_offset, max_recvbuf_sz;
+
                if (pmlmepriv->qos_option == 0) {
                        out_len = *pout_len;
                        pframe = rtw_set_ie23a(out_ie + out_len,
index 3eb77de..0e0f73c 100644 (file)
@@ -331,6 +331,7 @@ rtw_update_TSF(struct mlme_ext_priv *pmlmeext, struct ieee80211_mgmt *mgmt)
 int rtw_ch_set_search_ch23a(struct rt_channel_info *ch_set, const u32 ch)
 {
        int i;
+
        for (i = 0; ch_set[i]. ChannelNum != 0; i++) {
                if (ch == ch_set[i].ChannelNum)
                        break;
@@ -566,7 +567,6 @@ static u8 init_channel_set(struct rtw_adapter *padapter, u8 cplan,
 
 int init_mlme_ext_priv23a(struct rtw_adapter *padapter)
 {
-       int res = _SUCCESS;
        struct registry_priv *pregistrypriv = &padapter->registrypriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -593,7 +593,7 @@ int init_mlme_ext_priv23a(struct rtw_adapter *padapter)
        pmlmeext->mlmeext_init = true;
 
        pmlmeext->active_keep_alive_check = true;
-       return res;
+       return _SUCCESS;
 }
 
 void free_mlme_ext_priv23a (struct mlme_ext_priv *pmlmeext)
@@ -680,8 +680,7 @@ void mgt_dispatcher23a(struct rtw_adapter *padapter,
        }
 
 #ifdef CONFIG_8723AU_AP_MODE
-       switch (stype)
-       {
+       switch (stype) {
        case IEEE80211_STYPE_AUTH:
                if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
                        ptable->func = &OnAuth23a;
@@ -1572,6 +1571,7 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
        pstat->uapsd_bk = 0;
        if (pmlmepriv->qos_option) {
                const u8 *end = pos + left;
+
                p = pos;
 
                for (;;) {
@@ -2335,12 +2335,9 @@ static int update_hidden_ssid(u8 *ies, u32 ies_len, u8 hidden_ssid_mode)
           __func__, hidden_ssid_mode, ssid_ie, ssid_len_ori); */
 
        if (ssid_ie && ssid_len_ori > 0) {
-               switch (hidden_ssid_mode)
-               {
+               switch (hidden_ssid_mode) {
                case 1:
                        next_ie = ssid_ie + 2 + ssid_len_ori;
-                       remain_len = 0;
-
                        remain_len = ies_len -(next_ie-ies);
 
                        ssid_ie[1] = 0;
@@ -2599,7 +2596,9 @@ static void issue_probersp(struct rtw_adapter *padapter, unsigned char *da,
                if (ssid_ie && cur_network->Ssid.ssid_len) {
                        uint remainder_ielen;
                        u8 *remainder_ie;
+
                        remainder_ie = ssid_ie + 2;
+
                        remainder_ielen = pframe - remainder_ie;
 
                        DBG_8723A_LEVEL(_drv_warning_, "%s(%s): "
@@ -2862,6 +2861,7 @@ static void issue_auth(struct rtw_adapter *padapter, struct sta_info *psta,
        if (psta) { /*  for AP mode */
 #ifdef CONFIG_8723AU_AP_MODE
                unsigned short val16;
+
                ether_addr_copy(mgmt->da, psta->hwaddr);
                ether_addr_copy(mgmt->sa, myid(&padapter->eeprompriv));
                ether_addr_copy(mgmt->bssid, myid(&padapter->eeprompriv));
@@ -3306,6 +3306,7 @@ static void issue_assocreq(struct rtw_adapter *padapter)
                            !memcmp(p + 2, WMM_OUI23A, 4) ||
                            !memcmp(p + 2, WPS_OUI23A, 4)) {
                                u8 plen = p[1];
+
                                if (!padapter->registrypriv.wifi_spec) {
                                        /* Commented by Kurt 20110629 */
                                        /* In some older APs, WPS handshake */
@@ -3997,7 +3998,7 @@ int send_beacon23a(struct rtw_adapter *padapter)
                        yield();
                        bxmitok = rtl8723a_get_bcn_valid(padapter);
                        poll++;
-               } while ((poll % 10) != 0 && bxmitok == false &&
+               } while ((poll % 10) != 0 && !bxmitok &&
                         !padapter->bSurpriseRemoved &&
                         !padapter->bDriverStopped);
 
@@ -4070,6 +4071,7 @@ static void rtw_site_survey(struct rtw_adapter *padapter)
                if (ScanType == SCAN_ACTIVE) /* obey the channel plan setting... */
                {
                        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??? */
@@ -4197,9 +4199,9 @@ static struct wlan_bssid_ex *collect_bss_info(struct rtw_adapter *padapter,
        /* get the signal strength */
        /*  in dBM.raw data */
        bssid->Rssi = precv_frame->attrib.phy_info.RecvSignalPower;
-       bssid->PhyInfo.SignalQuality =
+       bssid->SignalQuality =
                precv_frame->attrib.phy_info.SignalQuality;/* in percentage */
-       bssid->PhyInfo.SignalStrength =
+       bssid->SignalStrength =
                precv_frame->attrib.phy_info.SignalStrength;/* in percentage */
 
        /*  checking SSID */
@@ -4293,6 +4295,7 @@ static struct wlan_bssid_ex *collect_bss_info(struct rtw_adapter *padapter,
                                     bssid->IELength);
                if (p && p[1] > 0) {
                        struct ieee80211_ht_cap *pHT_caps;
+
                        pHT_caps = (struct ieee80211_ht_cap *)(p + 2);
 
                        if (pHT_caps->cap_info &
@@ -4305,7 +4308,7 @@ static struct wlan_bssid_ex *collect_bss_info(struct rtw_adapter *padapter,
 
        /*  mark bss info receiving from nearby channel as SignalQuality 101 */
        if (bssid->DSConfig != rtw_get_oper_ch23a(padapter))
-               bssid->PhyInfo.SignalQuality = 101;
+               bssid->SignalQuality = 101;
 
        return bssid;
 fail:
@@ -4319,6 +4322,7 @@ static void start_create_ibss(struct rtw_adapter *padapter)
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network;
+
        pmlmeext->cur_channel = (u8)pnetwork->DSConfig;
        pmlmeinfo->bcn_interval = pnetwork->beacon_interval;
 
@@ -4354,9 +4358,7 @@ static void start_create_ibss(struct rtw_adapter *padapter)
                        report_join_res23a(padapter, 1);
                        pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS;
                }
-       }
-       else
-       {
+       } else {
                DBG_8723A("%s: invalid cap:%x\n", __func__, caps);
                return;
        }
@@ -4414,9 +4416,7 @@ static void start_clnt_join(struct rtw_adapter *padapter)
                pmlmeinfo->state = MSR_ADHOC;
 
                report_join_res23a(padapter, 1);
-       }
-       else
-       {
+       } else {
                /* DBG_8723A("marc: invalid cap:%x\n", caps); */
                return;
        }
@@ -4480,16 +4480,12 @@ int receive_disconnect23a(struct rtw_adapter *padapter,
 
        DBG_8723A("%s\n", __func__);
 
-       if ((pmlmeinfo->state&0x03) == MSR_INFRA)
-       {
-               if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)
-               {
+       if ((pmlmeinfo->state&0x03) == MSR_INFRA) {
+               if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) {
                        pmlmeinfo->state = MSR_NOLINK;
                        report_del_sta_event23a(padapter, MacAddr, reason);
 
-               }
-               else if (pmlmeinfo->state & WIFI_FW_LINKING_STATE)
-               {
+               } else if (pmlmeinfo->state & WIFI_FW_LINKING_STATE) {
                        pmlmeinfo->state = MSR_NOLINK;
                        report_join_res23a(padapter, -2);
                }
@@ -4866,7 +4862,7 @@ void report_join_res23a(struct rtw_adapter *padapter, int res)
        pjoinbss_evt = (struct joinbss_event*)(pevtcmd + sizeof(struct C2HEvent_Header));
        memcpy((unsigned char *)&pjoinbss_evt->network.network,
               &pmlmeinfo->network, sizeof(struct wlan_bssid_ex));
-       pjoinbss_evt->network.join_res  = pjoinbss_evt->network.aid = res;
+       pjoinbss_evt->network.join_res = res;
 
        DBG_8723A("report_join_res23a(%d)\n", res);
 
@@ -4995,8 +4991,7 @@ void update_sta_info23a(struct rtw_adapter *padapter, struct sta_info *psta)
        VCS_update23a(padapter, psta);
 
        /* HT */
-       if (pmlmepriv->htpriv.ht_option)
-       {
+       if (pmlmepriv->htpriv.ht_option) {
                psta->htpriv.ht_option = true;
 
                psta->htpriv.ampdu_enable = pmlmepriv->htpriv.ampdu_enable;
@@ -5006,9 +5001,7 @@ void update_sta_info23a(struct rtw_adapter *padapter, struct sta_info *psta)
 
                psta->qos_option = true;
 
-       }
-       else
-       {
+       } else {
                psta->htpriv.ht_option = false;
 
                psta->htpriv.ampdu_enable = false;
@@ -5050,12 +5043,10 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter,
                goto exit_mlmeext_joinbss_event_callback23a;
        }
 
-       if ((pmlmeinfo->state&0x03) == MSR_ADHOC)
-       {
+       if ((pmlmeinfo->state&0x03) == MSR_ADHOC) {
                /* for bc/mc */
                psta_bmc = rtw_get_bcmc_stainfo23a(padapter);
-               if (psta_bmc)
-               {
+               if (psta_bmc) {
                        pmlmeinfo->FW_sta_info[psta_bmc->mac_id].psta = psta_bmc;
                        update_bmc_sta_support_rate23a(padapter, psta_bmc->mac_id);
                        Update_RA_Entry23a(padapter, psta_bmc);
@@ -5086,8 +5077,7 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter,
        set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
 
        psta = rtw_get_stainfo23a(pstapriv, cur_network->MacAddress);
-       if (psta) /* only for infra. mode */
-       {
+       if (psta) { /* only for infra. mode */
                pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta;
 
                /* DBG_8723A("set_sta_rate23a\n"); */
@@ -5123,8 +5113,7 @@ void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter,
 
        if ((pmlmeinfo->state & 0x03) == MSR_ADHOC) {
        /* adhoc master or sta_count>1 */
-               if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)
-               {
+               if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) {
                        /* nothing to do */
                } else { /* adhoc client */
                        /*  correcting TSF */
index 1b2af73..e2d51af 100644 (file)
@@ -159,7 +159,7 @@ void rtw_ps_processor23a(struct rtw_adapter *padapter)
        if (pwrpriv->ips_mode_req == IPS_NONE)
                goto exit;
 
-       if (rtw_pwr_unassociated_idle(padapter) == false)
+       if (!rtw_pwr_unassociated_idle(padapter))
                goto exit;
 
        if (pwrpriv->rf_pwrstate == rf_on &&
@@ -172,12 +172,12 @@ void rtw_ps_processor23a(struct rtw_adapter *padapter)
 exit:
        rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv);
        pwrpriv->ps_processing = false;
-       return;
 }
 
 static void pwr_state_check_handler(unsigned long data)
 {
        struct rtw_adapter *padapter = (struct rtw_adapter *)data;
+
        rtw_ps_cmd23a(padapter);
 }
 
@@ -338,8 +338,7 @@ s32 LPS_RF_ON_check23a(struct rtw_adapter *padapter, u32 delay_ms)
        start_time = jiffies;
        end_time = start_time + msecs_to_jiffies(delay_ms);
 
-       while (1)
-       {
+       while (1) {
                bAwake = rtl8723a_get_fwlps_rf_on(padapter);
                if (bAwake == true)
                        break;
@@ -470,6 +469,7 @@ void rtw_free_pwrctrl_priv(struct rtw_adapter *adapter)
 inline void rtw_set_ips_deny23a(struct rtw_adapter *padapter, u32 ms)
 {
        struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
+
        pwrpriv->ips_deny_time = jiffies + msecs_to_jiffies(ms);
 }
 
index 5bc7734..de98da5 100644 (file)
@@ -215,6 +215,7 @@ u32 rtw_free_uc_swdec_pending_queue23a(struct rtw_adapter *adapter)
 {
        u32 cnt = 0;
        struct recv_frame *pending_frame;
+
        while ((pending_frame = rtw_alloc_recvframe23a(&adapter->recvpriv.uc_swdec_pending_queue))) {
                rtw_free_recvframe23a(pending_frame);
                DBG_8723A("%s: dequeue uc_swdec_pending_queue\n", __func__);
@@ -239,6 +240,7 @@ int rtw_enqueue_recvbuf23a_to_head(struct recv_buf *precvbuf, struct rtw_queue *
 int rtw_enqueue_recvbuf23a(struct recv_buf *precvbuf, struct rtw_queue *queue)
 {
        unsigned long irqL;
+
        spin_lock_irqsave(&queue->lock, irqL);
 
        list_del_init(&precvbuf->list);
@@ -364,6 +366,7 @@ int recvframe_chkmic(struct rtw_adapter *adapter,
 
                        if (bmic_err == true) {
                                int i;
+
                                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
                                         ("\n *(pframemic-8)-*(pframemic-1) ="
                                          "0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:"
@@ -483,6 +486,7 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter,
 
        if (prxattrib->encrypt > 0) {
                u8 *iv = precv_frame->pkt->data + prxattrib->hdrlen;
+
                prxattrib->key_index = (((iv[3]) >> 6) & 0x3);
 
                if (prxattrib->key_index > WEP_KEYS) {
@@ -1066,6 +1070,7 @@ int sta2ap_data_frame(struct rtw_adapter *adapter,
                }
        } else {
                u8 *myhwaddr = myid(&adapter->eeprompriv);
+
                if (!ether_addr_equal(pattrib->ra, myhwaddr)) {
                        ret = RTW_RX_HANDLED;
                        goto exit;
@@ -1405,8 +1410,7 @@ static int validate_recv_data_frame(struct rtw_adapter *adapter,
                RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
                         ("\n pattrib->encrypt =%d\n", pattrib->encrypt));
 
-               switch (pattrib->encrypt)
-               {
+               switch (pattrib->encrypt) {
                case WLAN_CIPHER_SUITE_WEP40:
                case WLAN_CIPHER_SUITE_WEP104:
                        pattrib->iv_len = IEEE80211_WEP_IV_LEN;
@@ -1505,8 +1509,7 @@ static int validate_recv_frame(struct rtw_adapter *adapter,
        if (unlikely(bDumpRxPkt == 1))
                dump_rx_pkt(skb, type, bDumpRxPkt);
 
-       switch (type)
-       {
+       switch (type) {
        case IEEE80211_FTYPE_MGMT:
                retval = validate_recv_mgnt_frame(adapter, precv_frame);
                if (retval == _FAIL) {
@@ -1551,8 +1554,6 @@ static int wlanhdr_to_ethhdr (struct recv_frame *precvframe)
        u16     eth_type, len, hdrlen;
        u8      bsnaphdr;
        u8      *psnap;
-
-       int ret = _SUCCESS;
        struct rtw_adapter *adapter = precvframe->adapter;
        struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
 
@@ -1613,7 +1614,7 @@ static int wlanhdr_to_ethhdr (struct recv_frame *precvframe)
        }
 
 
-       return ret;
+       return _SUCCESS;
 }
 
 /* perform defrag */
@@ -1691,7 +1692,7 @@ struct recv_frame *recvframe_defrag(struct rtw_adapter *adapter,
                skb_put(skb, pnfhdr->pkt->len);
 
                prframe->attrib.icv_len = pnfhdr->attrib.icv_len;
-       };
+       }
 
        /* free the defrag_q queue and return the prframe */
        rtw_free_recvframe23a_queue(defrag_q);
@@ -2177,8 +2178,7 @@ int process_recv_indicatepkts(struct rtw_adapter *padapter,
                                return retval;
                        }
                }
-       } else /* B/G mode */
-       {
+       } else { /* B/G mode */
                retval = wlanhdr_to_ethhdr(prframe);
                if (retval != _SUCCESS) {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
index 76371ae..715a474 100644 (file)
 
 #define CRC32_POLY 0x04c11db7
 
-struct arc4context
-{
+struct arc4context {
        u32 x;
        u32 y;
        u8 state[256];
 };
 
-static void arcfour_init(struct arc4context    *parc4ctx, u8 * key, u32        key_len)
+static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len)
 {
        u32     t, u;
        u32     keyindex;
        u32     stateindex;
-       u8 * state;
+       u8 *state;
        u32     counter;
 
        state = parc4ctx->state;
@@ -45,8 +44,7 @@ static void arcfour_init(struct arc4context   *parc4ctx, u8 * key, u32        key_len)
                state[counter] = (u8)counter;
        keyindex = 0;
        stateindex = 0;
-       for (counter = 0; counter < 256; counter++)
-       {
+       for (counter = 0; counter < 256; counter++) {
                t = state[counter];
                stateindex = (stateindex + key[keyindex] + t) & 0xff;
                u = state[stateindex];
@@ -62,7 +60,7 @@ static u32 arcfour_byte(      struct arc4context      *parc4ctx)
        u32 x;
        u32 y;
        u32 sx, sy;
-       u8 * state;
+       u8 *state;
 
        state = parc4ctx->state;
        x = (parc4ctx->x + 1) & 0xff;
@@ -78,8 +76,8 @@ static u32 arcfour_byte(      struct arc4context      *parc4ctx)
 }
 
 static void arcfour_encrypt(   struct arc4context      *parc4ctx,
-       u8 * dest,
-       u8 * src,
+       u8 *dest,
+       u8 *src,
        u32 len)
 {
        u32     i;
@@ -114,8 +112,7 @@ static void crc32_init(void)
 
                c = 0x12340000;
 
-               for (i = 0; i < 256; ++i)
-               {
+               for (i = 0; i < 256; ++i) {
                        k = crc32_reverseBit((u8)i);
                        for (c = ((u32)k) << 24, j = 8; j > 0; --j) {
                                c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1);
@@ -221,7 +218,7 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter,
        u8 keyindex;
        struct rx_pkt_attrib *prxattrib = &precvframe->attrib;
        struct security_priv *psecuritypriv = &padapter->securitypriv;
-       struct sk_buff * skb = precvframe->pkt;
+       struct sk_buff *skb = precvframe->pkt;
 
        pframe = skb->data;
 
@@ -260,33 +257,29 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter,
                          crc[1], payload[length - 3],
                          crc[0], payload[length - 4]));
        }
-
-       return;
 }
 
 /* 3           ===== TKIP related ===== */
 
-static u32 secmicgetuint32(u8 * p)
+static u32 secmicgetuint32(u8 *p)
 /*  Convert from Byte[] to u32 in a portable way */
 {
        s32 i;
        u32 res = 0;
 
-       for (i = 0; i<4; i++)
-       {
+       for (i = 0; i<4; i++) {
                res |= ((u32)(*p++)) << (8*i);
        }
 
        return res;
 }
 
-static void secmicputuint32(u8 * p, u32 val)
+static void secmicputuint32(u8 *p, u32 val)
 /*  Convert from long to Byte[] in a portable way */
 {
        long i;
 
-       for (i = 0; i<4; i++)
-       {
+       for (i = 0; i<4; i++) {
                *p++ = (u8) (val & 0xff);
                val >>= 8;
        }
@@ -304,7 +297,7 @@ static void secmicclear(struct mic_data *pmicdata)
 
 }
 
-void rtw_secmicsetkey23a(struct mic_data *pmicdata, u8 * key)
+void rtw_secmicsetkey23a(struct mic_data *pmicdata, u8 *key)
 {
        /*  Set the key */
 
@@ -322,8 +315,7 @@ void rtw_secmicappend23abyte23a(struct mic_data *pmicdata, u8 b)
        pmicdata->M |= ((unsigned long)b) << (8*pmicdata->nBytesInM);
        pmicdata->nBytesInM++;
        /*  Process the word if it is full. */
-       if (pmicdata->nBytesInM >= 4)
-       {
+       if (pmicdata->nBytesInM >= 4) {
                pmicdata->L ^= pmicdata->M;
                pmicdata->R ^= ROL32(pmicdata->L, 17);
                pmicdata->L += pmicdata->R;
@@ -340,19 +332,18 @@ void rtw_secmicappend23abyte23a(struct mic_data *pmicdata, u8 b)
 
 }
 
-void rtw_secmicappend23a(struct mic_data *pmicdata, u8 * src, u32 nbytes)
+void rtw_secmicappend23a(struct mic_data *pmicdata, u8 *src, u32 nbytes)
 {
 
        /*  This is simple */
-       while(nbytes > 0)
-       {
+       while(nbytes > 0) {
                rtw_secmicappend23abyte23a(pmicdata, *src++);
                nbytes--;
        }
 
 }
 
-void rtw_secgetmic23a(struct mic_data *pmicdata, u8 * dst)
+void rtw_secgetmic23a(struct mic_data *pmicdata, u8 *dst)
 {
 
        /*  Append the minimum padding */
@@ -362,8 +353,7 @@ void rtw_secgetmic23a(struct mic_data *pmicdata, u8 * dst)
        rtw_secmicappend23abyte23a(pmicdata, 0);
        rtw_secmicappend23abyte23a(pmicdata, 0);
        /*  and then zeroes until the length is a multiple of 4 */
-       while(pmicdata->nBytesInM != 0)
-       {
+       while(pmicdata->nBytesInM != 0) {
                rtw_secmicappend23abyte23a(pmicdata, 0);
        }
        /*  The appendByte function has already computed the result. */
@@ -374,7 +364,8 @@ void rtw_secgetmic23a(struct mic_data *pmicdata, u8 * dst)
 
 }
 
-void rtw_seccalctkipmic23a(u8 * key, u8 *header, u8 *data, u32 data_len, u8 *mic_code, u8 pri)
+void rtw_seccalctkipmic23a(u8 *key, u8 *header, u8 *data, u32 data_len,
+                          u8 *mic_code, u8 pri)
 {
 
        struct mic_data micdata;
@@ -531,8 +522,8 @@ static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32)
 
        /* Now compute an unbalanced Feistel cipher with 80-bit block */
        /* size on the 80-bit block P1K[], using the 128-bit key TK[] */
-       for (i = 0; i < PHASE1_LOOP_CNT ;i++)
-       {                 /* Each add operation here is mod 2**16 */
+       for (i = 0; i < PHASE1_LOOP_CNT ;i++) {
+               /* Each add operation here is mod 2**16 */
                p1k[0] += _S_(p1k[4] ^ TK16((i&1)+0));
                p1k[1] += _S_(p1k[0] ^ TK16((i&1)+2));
                p1k[2] += _S_(p1k[1] ^ TK16((i&1)+4));
@@ -602,8 +593,7 @@ static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16)
        rc4key[3] = Lo8((PPK[5] ^ TK16(0)) >> 1);
 
        /* Copy 96 bits of PPK[0..5] to RC4KEY[4..15]  (little-endian)       */
-       for (i = 0;i<6;i++)
-       {
+       for (i = 0;i<6;i++) {
                rc4key[4+2*i] = Lo8(PPK[i]);
                rc4key[5+2*i] = Hi8(PPK[i]);
        }
@@ -649,8 +639,7 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
 
                if (stainfo!= NULL) {
 
-                       if (!(stainfo->state &_FW_LINKED))
-                       {
+                       if (!(stainfo->state &_FW_LINKED)) {
                                DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, stainfo->state);
                                return _FAIL;
                        }
@@ -728,7 +717,7 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
        struct  sta_info                *stainfo;
        struct  rx_pkt_attrib *prxattrib = &precvframe->attrib;
        struct  security_priv *psecuritypriv = &padapter->securitypriv;
-       struct sk_buff * skb = precvframe->pkt;
+       struct sk_buff *skb = precvframe->pkt;
        int res = _SUCCESS;
 
        pframe = skb->data;
@@ -887,8 +876,7 @@ static void byte_sub(u8 *in, u8 *out)
 {
        int i;
 
-       for (i = 0; i< 16; i++)
-       {
+       for (i = 0; i< 16; i++) {
                out[i] = sbox(in[i]);
        }
 
@@ -928,8 +916,7 @@ static void mix_column(u8 *in, u8 *out)
        u8 temp[4];
        u8 tempb[4];
 
-       for (i = 0 ; i<4; i++)
-       {
+       for (i = 0 ; i<4; i++) {
                if ((in[i] & 0x80) == 0x80)
                    add1b[i] = 0x1b;
                else
@@ -951,11 +938,9 @@ static void mix_column(u8 *in, u8 *out)
        andf7[2] = in[2] & 0x7f;
        andf7[3] = in[3] & 0x7f;
 
-       for (i = 3; i>0; i--)    /* logical shift left 1 bit */
-       {
+       for (i = 3; i>0; i--) { /* logical shift left 1 bit */
                andf7[i] = andf7[i] << 1;
-               if ((andf7[i-1] & 0x80) == 0x80)
-               {
+               if ((andf7[i-1] & 0x80) == 0x80) {
                    andf7[i] = (andf7[i] | 0x01);
                }
        }
@@ -988,21 +973,15 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext)
 
        for (i = 0; i<16; i++) round_key[i] = key[i];
 
-       for (round = 0; round < 11; round++)
-       {
-               if (round == 0)
-               {
+       for (round = 0; round < 11; round++) {
+               if (round == 0) {
                    xor_128(round_key, data, ciphertext);
                    next_key(round_key, round);
-               }
-               else if (round == 10)
-               {
+               } else if (round == 10) {
                    byte_sub(ciphertext, intermediatea);
                    shift_row(intermediatea, intermediateb);
                    xor_128(intermediateb, round_key, ciphertext);
-               }
-               else    /* 1 - 9 */
-               {
+               } else { /* 1 - 9 */
                    byte_sub(ciphertext, intermediatea);
                    shift_row(intermediatea, intermediateb);
                    mix_column(&intermediateb[0], &intermediatea[0]);
@@ -1088,20 +1067,17 @@ static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists,
        mic_header2[6] = 0x00;
        mic_header2[7] = 0x00; /* mpdu[23]; */
 
-       if (!qc_exists && a4_exists)
-       {
+       if (!qc_exists && a4_exists) {
                for (i = 0;i<6;i++) mic_header2[8+i] = mpdu[24+i];   /* A4 */
 
        }
 
-       if (qc_exists && !a4_exists)
-       {
+       if (qc_exists && !a4_exists) {
                mic_header2[8] = mpdu[24] & 0x0f; /* mute bits 15 - 4 */
                mic_header2[9] = mpdu[25] & 0x00;
        }
 
-       if (qc_exists && a4_exists)
-       {
+       if (qc_exists && a4_exists) {
                for (i = 0;i<6;i++) mic_header2[8+i] = mpdu[24+i];   /* A4 */
 
                mic_header2[14] = mpdu[30] & 0x0f;
index 58ed980..29a29d9 100644 (file)
@@ -107,7 +107,7 @@ static void sreset_restore_network_station(struct rtw_adapter *padapter)
 
        mlmeext_joinbss_event_callback23a(padapter, 1);
        /* restore Sequence No. */
-       rtl8723au_write8(padapter, 0x4dc, padapter->xmitpriv.nqos_ssn);
+       rtl8723au_write8(padapter, REG_NQOS_SEQ, padapter->xmitpriv.nqos_ssn);
 
        sreset_restore_security_station(padapter);
 }
index 09c44a5..69d9e0f 100644 (file)
@@ -608,8 +608,6 @@ void WMMOnAssocRsp23a(struct rtw_adapter *padapter)
                DBG_8723A("wmm_para_seq(%d): %d\n", i,
                          pxmitpriv->wmm_para_seq[i]);
        }
-
-       return;
 }
 
 static void bwmode_update_check(struct rtw_adapter *padapter, const u8 *p)
@@ -750,7 +748,6 @@ void HT_caps_handler23a(struct rtw_adapter *padapter, const u8 *p)
                else
                        cap->mcs.rx_mask[i] &= MCS_rate_2R23A[i];
        }
-       return;
 }
 
 void HT_info_handler23a(struct rtw_adapter *padapter, const u8 *p)
@@ -771,7 +768,6 @@ void HT_info_handler23a(struct rtw_adapter *padapter, const u8 *p)
 
        pmlmeinfo->HT_info_enable = 1;
        memcpy(&pmlmeinfo->HT_info, p + 2, p[1]);
-       return;
 }
 
 void HTOnAssocRsp23a(struct rtw_adapter *padapter)
@@ -833,7 +829,7 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta)
                psta->cts2self = 0;
                break;
        case 1: /* on */
-               if (pregpriv->vcs_type == 1) { /* 1:RTS/CTS 2:CTS to self */
+               if (pregpriv->vcs_type == RTS_CTS) {
                        psta->rtsen = 1;
                        psta->cts2self = 0;
                } else {
@@ -844,7 +840,7 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta)
        case 2: /* auto */
        default:
                if (pmlmeinfo->ERP_enable && pmlmeinfo->ERP_IE & BIT(1)) {
-                       if (pregpriv->vcs_type == 1) {
+                       if (pregpriv->vcs_type == RTS_CTS) {
                                psta->rtsen = 1;
                                psta->cts2self = 0;
                        } else {
@@ -870,7 +866,7 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter,
        int pie_len, ssid_len, privacy;
        const u8 *p, *ssid;
 
-       if (is_client_associated_to_ap23a(Adapter) == false)
+       if (!is_client_associated_to_ap23a(Adapter))
                return _SUCCESS;
 
        if (unlikely(!ieee80211_is_beacon(mgmt->frame_control))) {
@@ -1080,7 +1076,7 @@ bool is_ap_in_tkip23a(struct rtw_adapter *padapter)
                return false;
 }
 
-bool should_forbid_n_rate23a(struct rtw_adapter * padapter)
+bool should_forbid_n_rate23a(struct rtw_adapter *padapter)
 {
        u32 i;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -1153,6 +1149,7 @@ bool is_ap_in_wep23a(struct rtw_adapter *padapter)
 static int wifirate2_ratetbl_inx23a(unsigned char rate)
 {
        int inx = 0;
+
        rate = rate & 0x7f;
 
        switch (rate) {
@@ -1311,6 +1308,7 @@ unsigned char check_assoc_AP23a(u8 *pframe, uint len)
        u8 epigram_vendor_flag;
        u8 ralink_vendor_flag;
        const u8 *p;
+
        epigram_vendor_flag = 0;
        ralink_vendor_flag = 0;
 
@@ -1324,7 +1322,6 @@ unsigned char check_assoc_AP23a(u8 *pframe, uint len)
                                DBG_8723A("link to Artheros AP\n");
                                return HT_IOT_PEER_ATHEROS;
                        } else if (!memcmp(p + 2, BROADCOM_OUI1, 3) ||
-                                  !memcmp(p + 2, BROADCOM_OUI2, 3) ||
                                   !memcmp(p + 2, BROADCOM_OUI2, 3)) {
                                DBG_8723A("link to Broadcom AP\n");
                                return HT_IOT_PEER_BROADCOM;
index 7a80381..4c2f0a1 100644 (file)
@@ -184,12 +184,6 @@ int _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv,
 
        sema_init(&pxmitpriv->tx_retevt, 0);
 
-       /* per AC pending irp */
-       pxmitpriv->beq_cnt = 0;
-       pxmitpriv->bkq_cnt = 0;
-       pxmitpriv->viq_cnt = 0;
-       pxmitpriv->voq_cnt = 0;
-
        pxmitpriv->ack_tx = false;
        mutex_init(&pxmitpriv->ack_tx_mutex);
        rtw_sctx_init23a(&pxmitpriv->ack_tx_ops, 0);
@@ -315,6 +309,7 @@ static void update_attrib_vcs_info(struct rtw_adapter *padapter, struct xmit_fra
                        /* check HT op mode */
                        if (pattrib->ht_en) {
                                u8 HTOpMode = pmlmeinfo->HT_protection;
+
                                if ((pmlmeext->cur_bwmode && (HTOpMode == 2 || HTOpMode == 3)) ||
                                    (!pmlmeext->cur_bwmode && HTOpMode == 3)) {
                                        pattrib->vcs_mode = RTS_CTS;
@@ -464,6 +459,7 @@ static int update_attrib(struct rtw_adapter *padapter,
                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) ||
@@ -1293,7 +1289,7 @@ void rtw_update_protection23a(struct rtw_adapter *padapter, u8 *ie, uint ie_len)
        uint protection;
        const u8 *p;
 
-       switch (pxmitpriv->vcs_setting) {
+       switch (pregistrypriv->vrtl_carrier_sense) {
        case DISABLE_VCS:
                pxmitpriv->vcs = NONE_VCS;
                break;
index 4b41bc4..179a1ba 100644 (file)
@@ -612,7 +612,7 @@ static void _PHY_PathADDAOn(struct rtw_adapter *pAdapter, u32 *ADDAReg, bool isP
        u32 i;
 
        pathOn = isPathAOn ? 0x04db25a4 : 0x0b1b25a4;
-       if (false == is2T) {
+       if (!is2T) {
                pathOn = 0x0bdb25a0;
                PHY_SetBBReg(pAdapter, ADDAReg[0], bMaskDWord, 0x0b1b25a0);
        } else {
index bf919f6..bf4cae2 100644 (file)
@@ -463,7 +463,7 @@ void rtl8723a_set_ampdu_factor(struct rtw_adapter *padapter, u8 FactorToSet)
                MaxAggNum = 0xF;
 
        if (FactorToSet <= 3) {
-               FactorToSet = (1 << (FactorToSet + 2));
+               FactorToSet = 1 << (FactorToSet + 2);
                if (FactorToSet > MaxAggNum)
                        FactorToSet = MaxAggNum;
 
@@ -727,7 +727,7 @@ void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter)
        rtl8723au_write8(padapter, REG_TXPAUSE, 0xff);
 
        /*  keep sn */
-       padapter->xmitpriv.nqos_ssn = rtl8723au_read16(padapter, REG_NQOS_SEQ);
+       padapter->xmitpriv.nqos_ssn = rtl8723au_read8(padapter, REG_NQOS_SEQ);
 
        if (pwrpriv->bkeepfwalive != true) {
                u32 v32;
index 9054a98..5de806e 100644 (file)
@@ -1766,9 +1766,7 @@ bthci_CmdSetEventFilter(
        struct packet_irp_hcicmd_data *pHciCmd
        )
 {
-       enum hci_status status = HCI_STATUS_SUCCESS;
-
-       return status;
+       return HCI_STATUS_SUCCESS;
 }
 
 /* 7.3.14 */
@@ -2984,8 +2982,7 @@ bthci_CmdReadLinkQuality(
 
 static enum hci_status bthci_CmdReadRSSI(struct rtw_adapter *padapter)
 {
-       enum hci_status status = HCI_STATUS_SUCCESS;
-       return status;
+       return HCI_STATUS_SUCCESS;
 }
 
 static enum hci_status
@@ -2994,7 +2991,6 @@ bthci_CmdCreateLogicalLink(
        struct packet_irp_hcicmd_data *pHciCmd
        )
 {
-       enum hci_status status = HCI_STATUS_SUCCESS;
        struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
        struct bt_dgb *pBtDbg = &pBTInfo->BtDbg;
 
@@ -3003,7 +2999,7 @@ bthci_CmdCreateLogicalLink(
        bthci_BuildLogicalLink(padapter, pHciCmd,
                HCI_CREATE_LOGICAL_LINK);
 
-       return status;
+       return HCI_STATUS_SUCCESS;
 }
 
 static enum hci_status
@@ -3012,7 +3008,6 @@ bthci_CmdAcceptLogicalLink(
        struct packet_irp_hcicmd_data *pHciCmd
        )
 {
-       enum hci_status status = HCI_STATUS_SUCCESS;
        struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
        struct bt_dgb *pBtDbg = &pBTInfo->BtDbg;
 
@@ -3021,7 +3016,7 @@ bthci_CmdAcceptLogicalLink(
        bthci_BuildLogicalLink(padapter, pHciCmd,
                HCI_ACCEPT_LOGICAL_LINK);
 
-       return status;
+       return HCI_STATUS_SUCCESS;
 }
 
 static enum hci_status
@@ -4141,9 +4136,7 @@ static enum hci_status
 bthci_CmdHostNumberOfCompletedPackets(struct rtw_adapter *padapter,
                                      struct packet_irp_hcicmd_data *pHciCmd)
 {
-       enum hci_status status = HCI_STATUS_SUCCESS;
-
-       return status;
+       return HCI_STATUS_SUCCESS;
 }
 
 static enum hci_status
index 271c33d..7b56411 100644 (file)
@@ -115,19 +115,16 @@ exit:
 
 int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u8 *param)
 {
-       int res = _SUCCESS;
-
        *((u32 *)param) = cpu_to_le32(*((u32 *)param));
 
        FillH2CCmd(padapter, RSSI_SETTING_EID, 3, param);
 
-       return res;
+       return _SUCCESS;
 }
 
 int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg)
 {
        u8 buf[5];
-       int res = _SUCCESS;
 
        memset(buf, 0, 5);
        mask = cpu_to_le32(mask);
@@ -136,7 +133,7 @@ int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg)
 
        FillH2CCmd(padapter, MACID_CONFIG_EID, 5, buf);
 
-       return res;
+       return _SUCCESS;
 }
 
 /* bitmap[0:27] = tx_rate_bitmap */
index 8523908..9a75eb6 100644 (file)
@@ -1522,10 +1522,8 @@ static void _DisableAnalog(struct rtw_adapter *padapter, bool bWithoutHWSM)
 /*  HW Auto state machine */
 int CardDisableHWSM(struct rtw_adapter *padapter, u8 resetMCU)
 {
-       int rtStatus = _SUCCESS;
-
        if (padapter->bSurpriseRemoved) {
-               return rtStatus;
+               return _SUCCESS;
        }
        /*  RF Off Sequence ==== */
        _DisableRFAFEAndResetBB(padapter);
@@ -1542,18 +1540,14 @@ int CardDisableHWSM(struct rtw_adapter *padapter, u8 resetMCU)
        RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
                 ("======> Card disable finished.\n"));
 
-       return rtStatus;
+       return _SUCCESS;
 }
 
 /*  without HW Auto state machine */
 int CardDisableWithoutHWSM(struct rtw_adapter *padapter)
 {
-       int rtStatus = _SUCCESS;
-
-       /* RT_TRACE(COMP_INIT, DBG_LOUD,
-          ("======> Card Disable Without HWSM .\n")); */
        if (padapter->bSurpriseRemoved) {
-               return rtStatus;
+               return _SUCCESS;
        }
 
        /*  RF Off Sequence ==== */
@@ -1573,7 +1567,7 @@ int CardDisableWithoutHWSM(struct rtw_adapter *padapter)
 
        /* RT_TRACE(COMP_INIT, DBG_LOUD,
           ("<====== Card Disable Without HWSM .\n")); */
-       return rtStatus;
+       return _SUCCESS;
 }
 
 void Hal_InitPGData(struct rtw_adapter *padapter, u8 *PROMContent)
@@ -1945,13 +1939,13 @@ Hal_EfuseParseThermalMeter_8723A(struct rtw_adapter *padapter,
        /*  */
        /*  ThermalMeter from EEPROM */
        /*  */
-       if (AutoloadFail == false)
+       if (!AutoloadFail)
                pHalData->EEPROMThermalMeter =
                    PROMContent[EEPROM_THERMAL_METER_8723A];
        else
                pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter;
 
-       if ((pHalData->EEPROMThermalMeter == 0xff) || (AutoloadFail == true)) {
+       if ((pHalData->EEPROMThermalMeter == 0xff) || AutoloadFail) {
                pHalData->bAPKThermalMeterIgnore = true;
                pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter;
        }
index 3d4d7ec..88e91cd 100644 (file)
@@ -418,7 +418,6 @@ PHY_SetRFReg(struct rtw_adapter *Adapter, enum RF_RADIO_PATH eRFPath,
  *---------------------------------------------------------------------------*/
 int PHY_MACConfig8723A(struct rtw_adapter *Adapter)
 {
-       int rtStatus = _SUCCESS;
        struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
        bool is92C = IS_92C_SERIAL(pHalData->VersionID);
 
@@ -433,7 +432,7 @@ int PHY_MACConfig8723A(struct rtw_adapter *Adapter)
        if (is92C && (BOARD_USB_DONGLE == pHalData->BoardType))
                rtl8723au_write8(Adapter, 0x40, 0x04);
 
-       return rtStatus;
+       return _SUCCESS;
 }
 
 /**
index a5de03d..adc2953 100644 (file)
@@ -480,7 +480,7 @@ static void _InitRFType(struct rtw_adapter *Adapter)
 
        pHalData->rf_chip = RF_6052;
 
-       if (is92CU == false) {
+       if (!is92CU) {
                pHalData->rf_type = RF_1T1R;
                DBG_8723A("Set RF Chip ID to RF_6052 and RF type to 1T1R.\n");
                return;
@@ -1485,7 +1485,6 @@ void rtl8723a_update_ramask(struct rtw_adapter *padapter,
        }
 
        /* mask &= 0x0fffffff; */
-       rate_bitmap = 0x0fffffff;
        rate_bitmap = ODM_Get_Rate_Bitmap23a(pHalData, mac_id, mask,
                                             rssi_level);
        DBG_8723A("%s => mac_id:%d, networkType:0x%02x, "
index bbeaab4..c834b3a 100644 (file)
@@ -19,7 +19,7 @@ extern u8 Rtl8723UFwUMCBCutImgArrayWithoutBT[Rtl8723UUMCBCutImgArrayWithoutBTLen
 extern const u8 Rtl8723SFwUMCBCutMPImgArray[Rtl8723SUMCBCutMPImgArrayLength];
 
 #define Rtl8723EBTImgArrayLength 15276
-extern u8 Rtl8723EFwBTImgArray[Rtl8723EBTImgArrayLength] ;
+extern u8 Rtl8723EFwBTImgArray[Rtl8723EBTImgArrayLength];
 
 #define Rtl8723UPHY_REG_Array_PGLength 336
 extern u32 Rtl8723UPHY_REG_Array_PG[Rtl8723UPHY_REG_Array_PGLength];
index 4d935a3..83be5ba 100644 (file)
@@ -91,8 +91,7 @@
 #define ODM_COMP_INIT                          BIT(31)
 
 /*------------------------Export Macro Definition---------------------------*/
-       #define DbgPrint        printk
-       #define RT_PRINTK(fmt, args...) DbgPrint("%s(): " fmt, __func__, ## args);
+       #define RT_PRINTK(fmt, args...) printk("%s(): " fmt, __func__, ## args);
 
 #ifndef ASSERT
        #define ASSERT(expr)
 #define ODM_RT_TRACE(pDM_Odm, comp, level, fmt)                                                        \
                if(((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel))       \
                {                                                                               \
-                       DbgPrint("[ODM-8723A] ");                                               \
-                       RT_PRINTK fmt;                                                          \
-               }
-
-#define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt)                                              \
-               if(((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel))       \
-               {                                                                               \
+                       printk("[ODM-8723A] ");                                         \
                        RT_PRINTK fmt;                                                          \
                }
 
 #define ODM_RT_ASSERT(pDM_Odm, expr, fmt)                                                      \
                if(!(expr)) {                                                                   \
-                       DbgPrint("Assertion failed! %s at ......\n", #expr);                    \
-                       DbgPrint("      ......%s,%s,line=%d\n", __FILE__, __func__, __LINE__);\
+                       printk("Assertion failed! %s at ......\n", #expr);                      \
+                       printk("      ......%s,%s,line=%d\n", __FILE__, __func__, __LINE__);\
                        RT_PRINTK fmt;                                                          \
                        ASSERT(false);                                                          \
                }
-#define ODM_dbg_enter() { DbgPrint("==> %s\n", __func__); }
-#define ODM_dbg_exit() { DbgPrint("<== %s\n", __func__); }
-#define ODM_dbg_trace(str) { DbgPrint("%s:%s\n", __func__, str); }
-
-#define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr)                                           \
-                       if(((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel){       \
-                               int __i;                        \
-                               u8 *    __ptr = (u8 *)ptr;      \
-                               DbgPrint("[ODM] ");             \
-                               DbgPrint(title_str);            \
-                               DbgPrint(" ");                  \
-                               for (__i=0; __i < 6; __i++)     \
-                                       DbgPrint("%02X%s", __ptr[__i], (__i == 5) ? "" : "-");          \
-                               DbgPrint("\n");                 \
-                       }
 
 void ODM_InitDebugSetting23a(struct dm_odm_t *pDM_Odm);
 
index 1811222..bf236e8 100644 (file)
@@ -37,8 +37,7 @@ enum{
 #define IQK_BB_REG_NUM                 9
 #define HP_THERMAL_NUM         8
 /*  duplicate code,will move to ODM ######### */
-struct dm_priv
-{
+struct dm_priv {
        u32     InitODMFlag;
 
        /*  Upper and Lower Signal threshold for Rate Adaptive*/
index 885d4d3..0109052 100644 (file)
@@ -35,8 +35,7 @@
 #define PHY_LINKQUALITY_SLID_WIN_MAX   20
 
 
-struct phy_stat
-{
+struct phy_stat {
        unsigned int phydw0;
        unsigned int phydw1;
        unsigned int phydw2;
index ef67068..8ffe5de 100644 (file)
@@ -450,8 +450,7 @@ struct getrfintfs_parm {
        u8      rfintfs;
 };
 
-struct Tx_Beacon_param
-{
+struct Tx_Beacon_param {
        struct wlan_bssid_ex network;
 };
 
index cfc947d..780eb89 100644 (file)
@@ -19,8 +19,7 @@
 #include "linux/ieee80211.h"
 #include "wifi.h"
 
-struct ht_priv
-{
+struct ht_priv {
        bool    ht_option;
        bool    ampdu_enable;/* for enable Tx A-MPDU */
        /* u8   baddbareq_issued[16]; */
index 2ff01eb..a6751f1 100644 (file)
@@ -270,7 +270,7 @@ static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, int state)
 static inline void clr_fwstate(struct mlme_priv *pmlmepriv, int state)
 {
        spin_lock_bh(&pmlmepriv->lock);
-       if (check_fwstate(pmlmepriv, state) == true)
+       if (check_fwstate(pmlmepriv, state))
                pmlmepriv->fw_state ^= state;
        spin_unlock_bh(&pmlmepriv->lock);
 }
index 97c3c44..51dba1f 100644 (file)
@@ -270,8 +270,7 @@ struct action_handler {
        int (*func)(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
 };
 
-struct ss_res
-{
+struct ss_res {
        int     state;
        int     bss_cnt;
        int     channel_idx;
@@ -318,8 +317,7 @@ struct FW_Sta_Info {
  * 5. ... and so on, till survey done.
  */
 
-struct mlme_ext_info
-{
+struct mlme_ext_info {
        u32     state;
        u32     reauth_count;
        u32     reassoc_count;
index 32a8441..abe4316 100644 (file)
@@ -295,10 +295,6 @@ struct     xmit_priv {
 
        struct rtw_adapter      *adapter;
 
-       u8   vcs_setting;
-       u8      vcs;
-       u8      vcs_type;
-
        u64     tx_bytes;
        u64     tx_pkts;
        u64     tx_drop;
@@ -307,6 +303,8 @@ struct      xmit_priv {
 
        struct hw_xmit *hwxmits;
        u8      hwxmit_entry;
+       u8      vcs;
+       u8      nqos_ssn;
 
        u8      wmm_para_seq[4];/* sequence for wmm ac parameter strength from
                                 * large to small. it's value is 0->vo, 1->vi,
@@ -317,11 +315,6 @@ struct     xmit_priv {
        u8              txirp_cnt;/*  */
 
        struct tasklet_struct xmit_tasklet;
-       /* per AC pending irp */
-       int beq_cnt;
-       int bkq_cnt;
-       int viq_cnt;
-       int voq_cnt;
 
        struct rtw_queue free_xmitbuf_queue;
        struct list_head xmitbuf_list;          /* track buffers for cleanup */
@@ -332,7 +325,6 @@ struct      xmit_priv {
        struct list_head xmitextbuf_list;       /* track buffers for cleanup */
        uint free_xmit_extbuf_cnt;
 
-       u16     nqos_ssn;
        int     ack_tx;
        struct mutex ack_tx_mutex;
        struct submit_ctx ack_tx_ops;
index 96e8074..95b32e1 100644 (file)
@@ -57,23 +57,6 @@ enum  {
        Ndis802_11Encryption3KeyAbsent,
 };
 
-/*  Key mapping keys require a BSSID */
-struct ndis_802_11_key {
-       u32 Length;             /*  Length of this structure */
-       u32 KeyIndex;
-       u32 KeyLength;          /*  length of key in bytes */
-       unsigned char BSSID[6];
-       unsigned long long KeyRSC;
-       u8 KeyMaterial[32]; /*  variable length depending on above field */
-};
-
-struct wlan_phy_info {
-       u8      SignalStrength;/* in percentage) */
-       u8      SignalQuality;/* in percentage) */
-       u8      Optimum_antenna;  /* for Antenna diversity */
-       u8      Reserved_0;
-};
-
 struct wlan_bcn_info {
        /* these infor get from rtw_get_encrypt_info when
         *       * translate scan to UI */
@@ -99,7 +82,8 @@ struct wlan_bssid_ex {
        u32 DSConfig;           /*  Frequency, units are kHz */
        enum nl80211_iftype ifmode;
        unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX];
-       struct wlan_phy_info    PhyInfo;
+       u8 SignalStrength;/* in percentage */
+       u8 SignalQuality;/* in percentage */
        u32  IELength;
        u8  IEs[MAX_IE_SZ]; /* timestamp, beacon interval, and capability info*/
 } __packed;
@@ -115,7 +99,6 @@ struct       wlan_network {
        /*  set to fixed when not to be removed as site-surveying */
        int     fixed;
        unsigned long   last_scanned; /* timestamp for the network */
-       int     aid;            /* will only be valid when a BSS is joined. */
        int     join_res;
        struct wlan_bssid_ex    network; /* must be the last item */
        struct wlan_bcn_info    BcnInfo;
index bd6953a..e154de9 100644 (file)
@@ -275,7 +275,8 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter,
                            &pnetwork->network)) {
                notify_signal = 100 * translate_percentage_to_dbm(padapter->recvpriv.signal_strength);  /* dbm */
        } else {
-               notify_signal = 100 * translate_percentage_to_dbm(pnetwork->network.PhyInfo.SignalStrength);    /* dbm */
+               notify_signal = 100 * translate_percentage_to_dbm(
+                       pnetwork->network.SignalStrength);      /* dbm */
        }
 
        bss = cfg80211_inform_bss(wiphy, notify_channel,
@@ -471,7 +472,6 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, u8 key_index,
                                          int set_tx, const u8 *sta_addr,
                                          struct key_params *keyparms)
 {
-       int ret = 0;
        int key_len;
        struct sta_info *psta = NULL, *pbcmc_sta = NULL;
        struct rtw_adapter *padapter = netdev_priv(dev);
@@ -708,7 +708,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, u8 key_index,
 
 exit:
 
-       return ret;
+       return 0;
 }
 #endif
 
@@ -850,7 +850,6 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, u8 key_index,
                                            dot11PrivacyAlgrthm;
                                }
                        }
-               } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {        /* adhoc mode */
                }
        }
 
@@ -2364,7 +2363,6 @@ void rtw_cfg80211_indicate_sta_assoc(struct rtw_adapter *padapter,
                        ie_offset = offsetof(struct ieee80211_mgmt,
                                             u.reassoc_req.variable);
 
-               sinfo.filled = 0;
                sinfo.filled = STATION_INFO_ASSOC_REQ_IES;
                sinfo.assoc_req_ies = pmgmt_frame + ie_offset;
                sinfo.assoc_req_ies_len = frame_len - ie_offset;
@@ -2432,20 +2430,16 @@ void rtw_cfg80211_indicate_sta_disassoc(struct rtw_adapter *padapter,
 
 static int rtw_cfg80211_monitor_if_open(struct net_device *ndev)
 {
-       int ret = 0;
-
        DBG_8723A("%s\n", __func__);
 
-       return ret;
+       return 0;
 }
 
 static int rtw_cfg80211_monitor_if_close(struct net_device *ndev)
 {
-       int ret = 0;
-
        DBG_8723A("%s\n", __func__);
 
-       return ret;
+       return 0;
 }
 
 static int rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb,
@@ -2574,11 +2568,9 @@ fail:
 static int
 rtw_cfg80211_monitor_if_set_mac_address(struct net_device *ndev, void *addr)
 {
-       int ret = 0;
-
        DBG_8723A("%s\n", __func__);
 
-       return ret;
+       return 0;
 }
 
 static const struct net_device_ops rtw_cfg80211_monitor_if_ops = {
index b34eaec..d001003 100644 (file)
@@ -175,7 +175,6 @@ static int netdev_close(struct net_device *pnetdev);
 static int loadparam(struct rtw_adapter *padapter,  struct net_device *pnetdev)
 {
        struct registry_priv  *registry_par = &padapter->registrypriv;
-       int status = _SUCCESS;
 
        GlobalDebugLevel23A = rtw_debug;
        registry_par->chip_version = (u8)rtw_chip_version;
@@ -234,7 +233,7 @@ static int loadparam(struct rtw_adapter *padapter,  struct net_device *pnetdev)
        snprintf(registry_par->if2name, 16, "%s", if2name);
        registry_par->notch_filter = (u8)rtw_notch_filter;
        registry_par->regulatory_tid = (u8)rtw_regulatory_id;
-       return status;
+       return _SUCCESS;
 }
 
 static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p)
@@ -384,12 +383,9 @@ static int rtw_init_default_value(struct rtw_adapter *padapter)
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct security_priv *psecuritypriv = &padapter->securitypriv;
-       int ret = _SUCCESS;
 
        /* xmit_priv */
-       pxmitpriv->vcs_setting = pregistrypriv->vrtl_carrier_sense;
        pxmitpriv->vcs = pregistrypriv->vcs_type;
-       pxmitpriv->vcs_type = pregistrypriv->vcs_type;
        /* pxmitpriv->rts_thresh = pregistrypriv->rts_thresh; */
        pxmitpriv->frag_len = pregistrypriv->frag_thresh;
 
@@ -425,7 +421,7 @@ static int rtw_init_default_value(struct rtw_adapter *padapter)
        /* misc. */
        padapter->bReadPortCancel = false;
        padapter->bWritePortCancel = false;
-       return ret;
+       return _SUCCESS;
 }
 
 int rtw_reset_drv_sw23a(struct rtw_adapter *padapter)
index 865743e..08424d4 100644 (file)
@@ -59,21 +59,6 @@ static struct usb_driver rtl8723a_usb_drv = {
 
 static struct usb_driver *usb_drv = &rtl8723a_usb_drv;
 
-static inline int RT_usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd)
-{
-       return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd);
-}
-
-static inline int RT_usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd)
-{
-       return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd);
-}
-
-static inline int RT_usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd)
-{
-       return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd);
-}
-
 static int rtw_init_intf_priv(struct dvobj_priv *dvobj)
 {
        mutex_init(&dvobj->usb_vendor_req_mutex);
@@ -143,21 +128,21 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf)
                                  le16_to_cpu(pendp_desc->wMaxPacketSize));
                        DBG_8723A("bInterval =%x\n", pendp_desc->bInterval);
 
-                       if (RT_usb_endpoint_is_bulk_in(pendp_desc)) {
-                               DBG_8723A("RT_usb_endpoint_is_bulk_in = %x\n",
+                       if (usb_endpoint_is_bulk_in(pendp_desc)) {
+                               DBG_8723A("usb_endpoint_is_bulk_in = %x\n",
                                          usb_endpoint_num(pendp_desc));
                                pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] =
                                        usb_endpoint_num(pendp_desc);
                                pdvobjpriv->RtNumInPipes++;
-                       } else if (RT_usb_endpoint_is_int_in(pendp_desc)) {
-                               DBG_8723A("RT_usb_endpoint_is_int_in = %x, Interval = %x\n",
+                       } else if (usb_endpoint_is_int_in(pendp_desc)) {
+                               DBG_8723A("usb_endpoint_is_int_in = %x, Interval = %x\n",
                                          usb_endpoint_num(pendp_desc),
                                          pendp_desc->bInterval);
                                pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] =
                                        usb_endpoint_num(pendp_desc);
                                pdvobjpriv->RtNumInPipes++;
-                       } else if (RT_usb_endpoint_is_bulk_out(pendp_desc)) {
-                               DBG_8723A("RT_usb_endpoint_is_bulk_out = %x\n",
+                       } else if (usb_endpoint_is_bulk_out(pendp_desc)) {
+                               DBG_8723A("usb_endpoint_is_bulk_out = %x\n",
                                          usb_endpoint_num(pendp_desc));
                                pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] =
                                        usb_endpoint_num(pendp_desc);
index a3349ac..3e19b3b 100644 (file)
 #include <usb_ops_linux.h>
 #include <rtw_sreset.h>
 
-struct zero_bulkout_context {
-       void *pbuf;
-       void *purb;
-       void *pirp;
-       void *padapter;
-};
-
 void rtl8723au_read_port_cancel(struct rtw_adapter *padapter)
 {
        struct recv_buf *precvbuf;
@@ -53,18 +46,6 @@ static void usb_write_port23a_complete(struct urb *purb)
        unsigned long irqL;
 
        switch (pxmitbuf->flags) {
-       case VO_QUEUE_INX:
-               pxmitpriv->voq_cnt--;
-               break;
-       case VI_QUEUE_INX:
-               pxmitpriv->viq_cnt--;
-               break;
-       case BE_QUEUE_INX:
-               pxmitpriv->beq_cnt--;
-               break;
-       case BK_QUEUE_INX:
-               pxmitpriv->bkq_cnt--;
-               break;
        case HIGH_QUEUE_INX:
 #ifdef CONFIG_8723AU_AP_MODE
                rtw_chk_hi_queue_cmd23a(padapter);
@@ -166,19 +147,15 @@ int rtl8723au_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt,
 
        switch (addr) {
        case VO_QUEUE_INX:
-               pxmitpriv->voq_cnt++;
                pxmitbuf->flags = VO_QUEUE_INX;
                break;
        case VI_QUEUE_INX:
-               pxmitpriv->viq_cnt++;
                pxmitbuf->flags = VI_QUEUE_INX;
                break;
        case BE_QUEUE_INX:
-               pxmitpriv->beq_cnt++;
                pxmitbuf->flags = BE_QUEUE_INX;
                break;
        case BK_QUEUE_INX:
-               pxmitpriv->bkq_cnt++;
                pxmitbuf->flags = BK_QUEUE_INX;
                break;
        case HIGH_QUEUE_INX:
index 228e483..b4612fb 100644 (file)
@@ -2599,9 +2599,9 @@ static int mspro_rw_multi_sector(struct scsi_cmnd *srb,
 
                        if (count > sector_cnt) {
                                if (mode_2k)
-                                       ms_card->seq_mode |= MODE_2K_SEQ;
+                                       ms_card->seq_mode = MODE_2K_SEQ;
                                else
-                                       ms_card->seq_mode |= MODE_512_SEQ;
+                                       ms_card->seq_mode = MODE_512_SEQ;
                        }
                } else {
                        count = sector_cnt;
index 2d2527c..c74f1b8 100644 (file)
@@ -418,7 +418,7 @@ static void rtsx_shutdown(struct pci_dev *pci)
 
 static int rtsx_control_thread(void *__dev)
 {
-       struct rtsx_dev *dev = (struct rtsx_dev *)__dev;
+       struct rtsx_dev *dev = __dev;
        struct rtsx_chip *chip = dev->chip;
        struct Scsi_Host *host = rtsx_to_host(dev);
 
@@ -527,7 +527,7 @@ SkipForAbort:
 
 static int rtsx_polling_thread(void *__dev)
 {
-       struct rtsx_dev *dev = (struct rtsx_dev *)__dev;
+       struct rtsx_dev *dev = __dev;
        struct rtsx_chip *chip = dev->chip;
        struct sd_info *sd_card = &(chip->sd_card);
        struct xd_info *xd_card = &(chip->xd_card);
index a7ade8b..9593d81 100644 (file)
@@ -126,10 +126,11 @@ static int rtsx_pre_handle_sdio_old(struct rtsx_chip *chip)
        if (chip->ignore_sd && CHK_SDIO_EXIST(chip)) {
                if (chip->asic_code) {
                        RTSX_WRITE_REG(chip, CARD_PULL_CTL5, 0xFF,
-                               MS_INS_PU | SD_WP_PU | SD_CD_PU | SD_CMD_PU);
+                                      MS_INS_PU | SD_WP_PU |
+                                      SD_CD_PU | SD_CMD_PU);
                } else {
                        RTSX_WRITE_REG(chip, FPGA_PULL_CTL, 0xFF,
-                               FPGA_SD_PULL_CTL_EN);
+                                      FPGA_SD_PULL_CTL_EN);
                }
                RTSX_WRITE_REG(chip, CARD_SHARE_MODE, 0xFF, CARD_SHARE_48_SD);
 
@@ -137,7 +138,7 @@ static int rtsx_pre_handle_sdio_old(struct rtsx_chip *chip)
                RTSX_WRITE_REG(chip, 0xFF2C, 0x01, 0x01);
 
                RTSX_WRITE_REG(chip, SDIO_CTRL, 0xFF,
-                       SDIO_BUS_CTRL | SDIO_CD_CTRL);
+                              SDIO_BUS_CTRL | SDIO_CD_CTRL);
 
                chip->sd_int = 1;
                chip->sd_io = 1;
@@ -201,7 +202,7 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip)
                                        TRACE_RET(chip, STATUS_FAIL);
                        } else {
                                RTSX_WRITE_REG(chip, FPGA_PULL_CTL,
-                                       FPGA_SD_PULL_CTL_BIT | 0x20, 0);
+                                              FPGA_SD_PULL_CTL_BIT | 0x20, 0);
                        }
                        retval = card_share_mode(chip, SD_CARD);
                        if (retval != STATUS_SUCCESS)
@@ -226,6 +227,87 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip)
 }
 #endif
 
+static int rtsx_reset_aspm(struct rtsx_chip *chip)
+{
+       int ret;
+
+       if (chip->dynamic_aspm) {
+               if (!CHK_SDIO_EXIST(chip) || !CHECK_PID(chip, 0x5288))
+                       return STATUS_SUCCESS;
+
+               ret = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFF,
+                                       chip->aspm_l0s_l1_en);
+               if (ret != STATUS_SUCCESS)
+                       TRACE_RET(chip, STATUS_FAIL);
+
+               return STATUS_SUCCESS;
+       }
+
+       if (CHECK_PID(chip, 0x5208))
+               RTSX_WRITE_REG(chip, ASPM_FORCE_CTL, 0xFF, 0x3F);
+       ret = rtsx_write_config_byte(chip, LCTLR, chip->aspm_l0s_l1_en);
+       if (ret != STATUS_SUCCESS)
+               TRACE_RET(chip, STATUS_FAIL);
+
+       chip->aspm_level[0] = chip->aspm_l0s_l1_en;
+       if (CHK_SDIO_EXIST(chip)) {
+               chip->aspm_level[1] = chip->aspm_l0s_l1_en;
+               ret = rtsx_write_cfg_dw(chip, CHECK_PID(chip, 0x5288) ? 2 : 1,
+                                       0xC0, 0xFF, chip->aspm_l0s_l1_en);
+               if (ret != STATUS_SUCCESS)
+                       TRACE_RET(chip, STATUS_FAIL);
+       }
+
+       chip->aspm_enabled = 1;
+
+       return STATUS_SUCCESS;
+}
+
+static int rtsx_enable_pcie_intr(struct rtsx_chip *chip)
+{
+       int ret;
+
+       if (!chip->asic_code || !CHECK_PID(chip, 0x5208)) {
+               rtsx_enable_bus_int(chip);
+               return STATUS_SUCCESS;
+       }
+
+       if (chip->phy_debug_mode) {
+               RTSX_WRITE_REG(chip, CDRESUMECTL, 0x77, 0);
+               rtsx_disable_bus_int(chip);
+       } else {
+               rtsx_enable_bus_int(chip);
+       }
+
+       if (chip->ic_version >= IC_VER_D) {
+               u16 reg;
+
+               ret = rtsx_read_phy_register(chip, 0x00, &reg);
+               if (ret != STATUS_SUCCESS)
+                       TRACE_RET(chip, STATUS_FAIL);
+
+               reg &= 0xFE7F;
+               reg |= 0x80;
+               ret = rtsx_write_phy_register(chip, 0x00, reg);
+               if (ret != STATUS_SUCCESS)
+                       TRACE_RET(chip, STATUS_FAIL);
+
+               ret = rtsx_read_phy_register(chip, 0x1C, &reg);
+               if (ret != STATUS_SUCCESS)
+                       TRACE_RET(chip, STATUS_FAIL);
+
+               reg &= 0xFFF7;
+               ret = rtsx_write_phy_register(chip, 0x1C, reg);
+               if (ret != STATUS_SUCCESS)
+                       TRACE_RET(chip, STATUS_FAIL);
+       }
+
+       if (chip->driver_first_load && (chip->ic_version < IC_VER_C))
+               rtsx_calibration(chip);
+
+       return STATUS_SUCCESS;
+}
+
 int rtsx_reset_chip(struct rtsx_chip *chip)
 {
        int retval;
@@ -268,7 +350,7 @@ int rtsx_reset_chip(struct rtsx_chip *chip)
 
 #ifdef LED_AUTO_BLINK
        RTSX_WRITE_REG(chip, CARD_AUTO_BLINK, 0xFF,
-                       LED_BLINK_SPEED | BLINK_EN | LED_GPIO0);
+                      LED_BLINK_SPEED | BLINK_EN | LED_GPIO0);
 #endif
 
        if (chip->asic_code) {
@@ -288,39 +370,9 @@ int rtsx_reset_chip(struct rtsx_chip *chip)
 
        /* Enable ASPM */
        if (chip->aspm_l0s_l1_en) {
-               if (chip->dynamic_aspm) {
-                       if (CHK_SDIO_EXIST(chip)) {
-                               if (CHECK_PID(chip, 0x5288)) {
-                                       retval = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFF, chip->aspm_l0s_l1_en);
-                                       if (retval != STATUS_SUCCESS)
-                                               TRACE_RET(chip, STATUS_FAIL);
-                               }
-                       }
-               } else {
-                       if (CHECK_PID(chip, 0x5208))
-                               RTSX_WRITE_REG(chip, ASPM_FORCE_CTL,
-                                       0xFF, 0x3F);
-
-                       retval = rtsx_write_config_byte(chip, LCTLR,
-                                                       chip->aspm_l0s_l1_en);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
-
-                       chip->aspm_level[0] = chip->aspm_l0s_l1_en;
-                       if (CHK_SDIO_EXIST(chip)) {
-                               chip->aspm_level[1] = chip->aspm_l0s_l1_en;
-                               if (CHECK_PID(chip, 0x5288))
-                                       retval = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFF, chip->aspm_l0s_l1_en);
-                               else
-                                       retval = rtsx_write_cfg_dw(chip, 1, 0xC0, 0xFF, chip->aspm_l0s_l1_en);
-
-                               if (retval != STATUS_SUCCESS)
-                                       TRACE_RET(chip, STATUS_FAIL);
-
-                       }
-
-                       chip->aspm_enabled = 1;
-               }
+               retval = rtsx_reset_aspm(chip);
+               if (retval != STATUS_SUCCESS)
+                       TRACE_RET(chip, STATUS_FAIL);
        } else {
                if (chip->asic_code && CHECK_PID(chip, 0x5208)) {
                        retval = rtsx_write_phy_register(chip, 0x07, 0x0129);
@@ -338,91 +390,38 @@ int rtsx_reset_chip(struct rtsx_chip *chip)
                TRACE_RET(chip, STATUS_FAIL);
 
        if (CHK_SDIO_EXIST(chip)) {
-               if (CHECK_PID(chip, 0x5288))
-                       retval = rtsx_write_cfg_dw(chip, 2, 0xC0,
-                                               0xFF00, 0x0100);
-               else
-                       retval = rtsx_write_cfg_dw(chip, 1, 0xC0,
-                                               0xFF00, 0x0100);
+               retval = rtsx_write_cfg_dw(chip,
+                                          CHECK_PID(chip, 0x5288) ? 2 : 1,
+                                          0xC0, 0xFF00, 0x0100);
 
                if (retval != STATUS_SUCCESS)
                        TRACE_RET(chip, STATUS_FAIL);
-
        }
 
-       if (CHECK_PID(chip, 0x5288)) {
-               if (!CHK_SDIO_EXIST(chip)) {
-                       retval = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFFFF,
-                                               0x0103);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
-
-                       retval = rtsx_write_cfg_dw(chip, 2, 0x84, 0xFF, 0x03);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+       if (CHECK_PID(chip, 0x5288) && !CHK_SDIO_EXIST(chip)) {
+               retval = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFFFF, 0x0103);
+               if (retval != STATUS_SUCCESS)
+                       TRACE_RET(chip, STATUS_FAIL);
 
-               }
+               retval = rtsx_write_cfg_dw(chip, 2, 0x84, 0xFF, 0x03);
+               if (retval != STATUS_SUCCESS)
+                       TRACE_RET(chip, STATUS_FAIL);
        }
 
        RTSX_WRITE_REG(chip, IRQSTAT0, LINK_RDY_INT, LINK_RDY_INT);
 
        RTSX_WRITE_REG(chip, PERST_GLITCH_WIDTH, 0xFF, 0x80);
 
-       /* Enable PCIE interrupt */
-       if (chip->asic_code) {
-               if (CHECK_PID(chip, 0x5208)) {
-                       if (chip->phy_debug_mode) {
-                               RTSX_WRITE_REG(chip, CDRESUMECTL, 0x77, 0);
-                               rtsx_disable_bus_int(chip);
-                       } else {
-                               rtsx_enable_bus_int(chip);
-                       }
-
-                       if (chip->ic_version >= IC_VER_D) {
-                               u16 reg;
-
-                               retval = rtsx_read_phy_register(chip, 0x00,
-                                                               &reg);
-                               if (retval != STATUS_SUCCESS)
-                                       TRACE_RET(chip, STATUS_FAIL);
-
-                               reg &= 0xFE7F;
-                               reg |= 0x80;
-                               retval = rtsx_write_phy_register(chip, 0x00,
-                                                               reg);
-                               if (retval != STATUS_SUCCESS)
-                                       TRACE_RET(chip, STATUS_FAIL);
-
-                               retval = rtsx_read_phy_register(chip, 0x1C,
-                                                               &reg);
-                               if (retval != STATUS_SUCCESS)
-                                       TRACE_RET(chip, STATUS_FAIL);
-
-                               reg &= 0xFFF7;
-                               retval = rtsx_write_phy_register(chip, 0x1C,
-                                                               reg);
-                               if (retval != STATUS_SUCCESS)
-                                       TRACE_RET(chip, STATUS_FAIL);
-
-                       }
-
-                       if (chip->driver_first_load &&
-                               (chip->ic_version < IC_VER_C))
-                               rtsx_calibration(chip);
-
-               } else {
-                       rtsx_enable_bus_int(chip);
-               }
-       } else {
-               rtsx_enable_bus_int(chip);
-       }
+       retval = rtsx_enable_pcie_intr(chip);
+       if (retval != STATUS_SUCCESS)
+               TRACE_RET(chip, STATUS_FAIL);
 
        chip->need_reset = 0;
 
        chip->int_reg = rtsx_readl(chip, RTSX_BIPR);
 
        if (chip->hw_bypass_sd)
-               goto NextCard;
+               goto nextcard;
        dev_dbg(rtsx_dev(chip), "In %s, chip->int_reg = 0x%x\n", __func__,
                chip->int_reg);
        if (chip->int_reg & SD_EXIST) {
@@ -443,10 +442,10 @@ int rtsx_reset_chip(struct rtsx_chip *chip)
        } else {
                chip->sd_io = 0;
                RTSX_WRITE_REG(chip, SDIO_CTRL, SDIO_BUS_CTRL | SDIO_CD_CTRL,
-                       0);
+                              0);
        }
 
-NextCard:
+nextcard:
        if (chip->int_reg & XD_EXIST)
                chip->need_reset |= XD_CARD;
        if (chip->int_reg & MS_EXIST)
@@ -484,10 +483,10 @@ NextCard:
 
        if (chip->ft2_fast_mode) {
                RTSX_WRITE_REG(chip, CARD_PWR_CTL, 0xFF,
-                       MS_PARTIAL_POWER_ON | SD_PARTIAL_POWER_ON);
+                              MS_PARTIAL_POWER_ON | SD_PARTIAL_POWER_ON);
                udelay(chip->pmos_pwr_on_interval);
                RTSX_WRITE_REG(chip, CARD_PWR_CTL, 0xFF,
-                       MS_POWER_ON | SD_POWER_ON);
+                              MS_POWER_ON | SD_POWER_ON);
 
                wait_timeout(200);
        }
@@ -540,10 +539,7 @@ static int rts5208_init(struct rtsx_chip *chip)
 
        RTSX_WRITE_REG(chip, CLK_SEL, 0x03, 0x03);
        RTSX_READ_REG(chip, CLK_SEL, &val);
-       if (val == 0)
-               chip->asic_code = 1;
-       else
-               chip->asic_code = 0;
+       chip->asic_code = val == 0 ? 1 : 0;
 
        if (chip->asic_code) {
                retval = rtsx_read_phy_register(chip, 0x1C, &reg);
@@ -553,10 +549,7 @@ static int rts5208_init(struct rtsx_chip *chip)
                dev_dbg(rtsx_dev(chip), "Value of phy register 0x1C is 0x%x\n",
                        reg);
                chip->ic_version = (reg >> 4) & 0x07;
-               if (reg & PHY_DEBUG_MODE)
-                       chip->phy_debug_mode = 1;
-               else
-                       chip->phy_debug_mode = 0;
+               chip->phy_debug_mode = reg & PHY_DEBUG_MODE ? 1 : 0;
 
        } else {
                RTSX_READ_REG(chip, 0xFE80, &val);
@@ -566,16 +559,10 @@ static int rts5208_init(struct rtsx_chip *chip)
 
        RTSX_READ_REG(chip, PDINFO, &val);
        dev_dbg(rtsx_dev(chip), "PDINFO: 0x%x\n", val);
-       if (val & AUX_PWR_DETECTED)
-               chip->aux_pwr_exist = 1;
-       else
-               chip->aux_pwr_exist = 0;
+       chip->aux_pwr_exist = val & AUX_PWR_DETECTED ? 1 : 0;
 
        RTSX_READ_REG(chip, 0xFE50, &val);
-       if (val & 0x01)
-               chip->hw_bypass_sd = 1;
-       else
-               chip->hw_bypass_sd = 0;
+       chip->hw_bypass_sd = val & 0x01 ? 1 : 0;
 
        rtsx_read_config_byte(chip, 0x0E, &val);
        if (val & 0x80)
@@ -585,10 +572,7 @@ static int rts5208_init(struct rtsx_chip *chip)
 
        if (chip->use_hw_setting) {
                RTSX_READ_REG(chip, CHANGE_LINK_STATE, &val);
-               if (val & 0x80)
-                       chip->auto_delink_en = 1;
-               else
-                       chip->auto_delink_en = 0;
+               chip->auto_delink_en = val & 0x80 ? 1 : 0;
        }
 
        return STATUS_SUCCESS;
@@ -602,33 +586,21 @@ static int rts5288_init(struct rtsx_chip *chip)
 
        RTSX_WRITE_REG(chip, CLK_SEL, 0x03, 0x03);
        RTSX_READ_REG(chip, CLK_SEL, &val);
-       if (val == 0)
-               chip->asic_code = 1;
-       else
-               chip->asic_code = 0;
+       chip->asic_code = val == 0 ? 1 : 0;
 
        chip->ic_version = 0;
        chip->phy_debug_mode = 0;
 
        RTSX_READ_REG(chip, PDINFO, &val);
        dev_dbg(rtsx_dev(chip), "PDINFO: 0x%x\n", val);
-       if (val & AUX_PWR_DETECTED)
-               chip->aux_pwr_exist = 1;
-       else
-               chip->aux_pwr_exist = 0;
+       chip->aux_pwr_exist = val & AUX_PWR_DETECTED ? 1 : 0;
 
        RTSX_READ_REG(chip, CARD_SHARE_MODE, &val);
        dev_dbg(rtsx_dev(chip), "CARD_SHARE_MODE: 0x%x\n", val);
-       if (val & 0x04)
-               chip->baro_pkg = QFN;
-       else
-               chip->baro_pkg = LQFP;
+       chip->baro_pkg = val & 0x04 ? QFN : LQFP;
 
        RTSX_READ_REG(chip, 0xFE5A, &val);
-       if (val & 0x10)
-               chip->hw_bypass_sd = 1;
-       else
-               chip->hw_bypass_sd = 0;
+       chip->hw_bypass_sd = val & 0x10 ? 1 : 0;
 
        retval = rtsx_read_cfg_dw(chip, 0, 0x718, &lval);
        if (retval != STATUS_SUCCESS)
@@ -643,16 +615,12 @@ static int rts5288_init(struct rtsx_chip *chip)
 
        if (chip->use_hw_setting) {
                RTSX_READ_REG(chip, CHANGE_LINK_STATE, &val);
-               if (val & 0x80)
-                       chip->auto_delink_en = 1;
-               else
-                       chip->auto_delink_en = 0;
+               chip->auto_delink_en = val & 0x80 ? 1 : 0;
 
                if (CHECK_BARO_PKG(chip, LQFP))
                        chip->lun_mode = SD_MS_1LUN;
                else
                        chip->lun_mode = DEFAULT_SINGLE;
-
        }
 
        return STATUS_SUCCESS;
@@ -660,9 +628,9 @@ static int rts5288_init(struct rtsx_chip *chip)
 
 int rtsx_init_chip(struct rtsx_chip *chip)
 {
-       struct sd_info *sd_card = &(chip->sd_card);
-       struct xd_info *xd_card = &(chip->xd_card);
-       struct ms_info *ms_card = &(chip->ms_card);
+       struct sd_info *sd_card = &chip->sd_card;
+       struct xd_info *xd_card = &chip->xd_card;
+       struct ms_info *ms_card = &chip->ms_card;
        int retval;
        unsigned int i;
 
@@ -740,7 +708,6 @@ int rtsx_init_chip(struct rtsx_chip *chip)
                retval = rts5288_init(chip);
                if (retval != STATUS_SUCCESS)
                        TRACE_RET(chip, STATUS_FAIL);
-
        }
 
        if (chip->ss_en == 2)
@@ -842,7 +809,6 @@ static void rtsx_monitor_aspm_config(struct rtsx_chip *chip)
        } else {
                if (reg0 & 0x03)
                        maybe_support_aspm = 1;
-
        }
 
        if (reg_changed) {
@@ -859,15 +825,15 @@ static void rtsx_monitor_aspm_config(struct rtsx_chip *chip)
                        chip->sdio_aspm = 0;
                }
                rtsx_write_register(chip, ASPM_FORCE_CTL, 0xFF,
-                               0x30 | chip->aspm_level[0] |
-                               (chip->aspm_level[1] << 2));
+                                   0x30 | chip->aspm_level[0] |
+                                   (chip->aspm_level[1] << 2));
        }
 }
 
 void rtsx_polling_func(struct rtsx_chip *chip)
 {
 #ifdef SUPPORT_SD_LOCK
-       struct sd_info *sd_card = &(chip->sd_card);
+       struct sd_info *sd_card = &chip->sd_card;
 #endif
        int ss_allowed;
 
@@ -875,7 +841,7 @@ void rtsx_polling_func(struct rtsx_chip *chip)
                return;
 
        if (rtsx_chk_stat(chip, RTSX_STAT_DELINK))
-               goto Delink_Stage;
+               goto delink_stage;
 
        if (chip->polling_config) {
                u8 val;
@@ -888,7 +854,7 @@ void rtsx_polling_func(struct rtsx_chip *chip)
 
 #ifdef SUPPORT_OCP
        if (chip->ocp_int) {
-               rtsx_read_register(chip, OCPSTAT, &(chip->ocp_stat));
+               rtsx_read_register(chip, OCPSTAT, &chip->ocp_stat);
 
                if (chip->card_exist & SD_CARD)
                        sd_power_off_card3v3(chip);
@@ -932,7 +898,6 @@ void rtsx_polling_func(struct rtsx_chip *chip)
                                rtsx_read_cfg_dw(chip, 1, 0x04, &val);
                                if (val & 0x07)
                                        ss_allowed = 0;
-
                        }
                }
        } else {
@@ -958,7 +923,7 @@ void rtsx_polling_func(struct rtsx_chip *chip)
 
 #ifdef SUPPORT_SDIO_ASPM
                if (CHK_SDIO_EXIST(chip) && !CHK_SDIO_IGNORED(chip) &&
-                               chip->aspm_l0s_l1_en && chip->dynamic_aspm) {
+                   chip->aspm_l0s_l1_en && chip->dynamic_aspm) {
                        if (chip->sd_io) {
                                dynamic_configure_sdio_aspm(chip);
                        } else {
@@ -966,7 +931,8 @@ void rtsx_polling_func(struct rtsx_chip *chip)
                                        dev_dbg(rtsx_dev(chip), "SDIO enter ASPM!\n");
                                        rtsx_write_register(chip,
                                                ASPM_FORCE_CTL, 0xFC,
-                                               0x30 | (chip->aspm_level[1] << 2));
+                                               0x30 |
+                                               (chip->aspm_level[1] << 2));
                                        chip->sdio_aspm = 1;
                                }
                        }
@@ -988,9 +954,10 @@ void rtsx_polling_func(struct rtsx_chip *chip)
 
                        turn_off_led(chip, LED_GPIO);
 
-                       if (chip->auto_power_down && !chip->card_ready && !chip->sd_io)
-                               rtsx_force_power_down(chip, SSC_PDCTL | OC_PDCTL);
-
+                       if (chip->auto_power_down && !chip->card_ready &&
+                           !chip->sd_io)
+                               rtsx_force_power_down(chip,
+                                                     SSC_PDCTL | OC_PDCTL);
                }
        }
 
@@ -1013,7 +980,6 @@ void rtsx_polling_func(struct rtsx_chip *chip)
                break;
        }
 
-
 #ifdef SUPPORT_OCP
        if (CHECK_LUN_MODE(chip, SD_MS_2LUN)) {
                if (chip->ocp_stat &
@@ -1024,7 +990,7 @@ void rtsx_polling_func(struct rtsx_chip *chip)
                if (chip->ocp_stat & (SD_OC_NOW | SD_OC_EVER)) {
                        if (chip->card_exist & SD_CARD) {
                                rtsx_write_register(chip, CARD_OE, SD_OUTPUT_EN,
-                                               0);
+                                                   0);
                                card_power_off(chip, SD_CARD);
                                chip->card_fail |= SD_CARD;
                        }
@@ -1032,7 +998,7 @@ void rtsx_polling_func(struct rtsx_chip *chip)
                if (chip->ocp_stat & (MS_OC_NOW | MS_OC_EVER)) {
                        if (chip->card_exist & MS_CARD) {
                                rtsx_write_register(chip, CARD_OE, MS_OUTPUT_EN,
-                                               0);
+                                                   0);
                                card_power_off(chip, MS_CARD);
                                chip->card_fail |= MS_CARD;
                        }
@@ -1043,15 +1009,15 @@ void rtsx_polling_func(struct rtsx_chip *chip)
                                chip->ocp_stat);
                        if (chip->card_exist & SD_CARD) {
                                rtsx_write_register(chip, CARD_OE, SD_OUTPUT_EN,
-                                               0);
+                                                   0);
                                chip->card_fail |= SD_CARD;
                        } else if (chip->card_exist & MS_CARD) {
                                rtsx_write_register(chip, CARD_OE, MS_OUTPUT_EN,
-                                               0);
+                                                   0);
                                chip->card_fail |= MS_CARD;
                        } else if (chip->card_exist & XD_CARD) {
                                rtsx_write_register(chip, CARD_OE, XD_OUTPUT_EN,
-                                               0);
+                                                   0);
                                chip->card_fail |= XD_CARD;
                        }
                        card_power_off(chip, SD_CARD);
@@ -1059,9 +1025,9 @@ void rtsx_polling_func(struct rtsx_chip *chip)
        }
 #endif
 
-Delink_Stage:
+delink_stage:
        if (chip->auto_delink_en && chip->auto_delink_allowed &&
-               !chip->card_ready && !chip->card_ejected && !chip->sd_io) {
+           !chip->card_ready && !chip->card_ejected && !chip->sd_io) {
                int enter_L1 = chip->auto_delink_in_L1 && (
                        chip->aspm_l0s_l1_en || chip->ss_en);
                int delink_stage1_cnt = chip->delink_stage1_step;
@@ -1081,27 +1047,33 @@ Delink_Stage:
                                        dev_dbg(rtsx_dev(chip), "False card inserted, do force delink\n");
 
                                        if (enter_L1)
-                                               rtsx_write_register(chip, HOST_SLEEP_STATE, 0x03, 1);
+                                               rtsx_write_register(chip,
+                                                             HOST_SLEEP_STATE,
+                                                             0x03, 1);
 
                                        rtsx_write_register(chip,
-                                                       CHANGE_LINK_STATE, 0x0A,
-                                                       0x0A);
+                                                           CHANGE_LINK_STATE,
+                                                           0x0A, 0x0A);
 
                                        if (enter_L1)
                                                rtsx_enter_L1(chip);
 
-                                       chip->auto_delink_cnt = delink_stage3_cnt + 1;
+                                       chip->auto_delink_cnt =
+                                               delink_stage3_cnt + 1;
                                } else {
                                        dev_dbg(rtsx_dev(chip), "No card inserted, do delink\n");
 
                                        if (enter_L1)
-                                               rtsx_write_register(chip, HOST_SLEEP_STATE, 0x03, 1);
+                                               rtsx_write_register(chip,
+                                                             HOST_SLEEP_STATE,
+                                                             0x03, 1);
 
-                                       rtsx_write_register(chip, CHANGE_LINK_STATE, 0x02, 0x02);
+                                       rtsx_write_register(chip,
+                                                           CHANGE_LINK_STATE,
+                                                           0x02, 0x02);
 
                                        if (enter_L1)
                                                rtsx_enter_L1(chip);
-
                                }
                        }
 
@@ -1115,7 +1087,7 @@ Delink_Stage:
                                        rtsx_set_phy_reg_bit(chip, 0x1C, 2);
 
                                rtsx_write_register(chip, CHANGE_LINK_STATE,
-                                               0x0A, 0x0A);
+                                                   0x0A, 0x0A);
                        }
 
                        chip->auto_delink_cnt++;
@@ -1219,7 +1191,7 @@ int rtsx_read_register(struct rtsx_chip *chip, u16 addr, u8 *data)
 }
 
 int rtsx_write_cfg_dw(struct rtsx_chip *chip, u8 func_no, u16 addr, u32 mask,
-               u32 val)
+                     u32 val)
 {
        u8 mode = 0, tmp;
        int i;
@@ -1279,7 +1251,7 @@ int rtsx_read_cfg_dw(struct rtsx_chip *chip, u8 func_no, u16 addr, u32 *val)
 }
 
 int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf,
-               int len)
+                      int len)
 {
        u32 *data, *mask;
        u16 offset = addr % 4;
@@ -1324,7 +1296,7 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf,
 
        for (i = 0; i < dw_len; i++) {
                retval = rtsx_write_cfg_dw(chip, func, aligned_addr + i * 4,
-                                       mask[i], data[i]);
+                                          mask[i], data[i]);
                if (retval != STATUS_SUCCESS) {
                        vfree(data);
                        vfree(mask);
@@ -1339,7 +1311,7 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf,
 }
 
 int rtsx_read_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf,
-               int len)
+                     int len)
 {
        u32 *data;
        u16 offset = addr % 4;
@@ -1360,7 +1332,7 @@ int rtsx_read_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf,
 
        for (i = 0; i < dw_len; i++) {
                retval = rtsx_read_cfg_dw(chip, func, aligned_addr + i * 4,
-                                       data + i);
+                                         data + i);
                if (retval != STATUS_SUCCESS) {
                        vfree(data);
                        TRACE_RET(chip, STATUS_FAIL);
@@ -1522,7 +1494,7 @@ int rtsx_set_phy_reg_bit(struct rtsx_chip *chip, u8 reg, u8 bit)
        if (retval != STATUS_SUCCESS)
                TRACE_RET(chip, STATUS_FAIL);
 
-       if (0 == (value & (1 << bit))) {
+       if ((value & (1 << bit)) == 0) {
                value |= (1 << bit);
                retval = rtsx_write_phy_register(chip, reg, value);
                if (retval != STATUS_SUCCESS)
@@ -1595,12 +1567,9 @@ void rtsx_enter_ss(struct rtsx_chip *chip)
                rtsx_force_power_down(chip, SSC_PDCTL | OC_PDCTL);
        }
 
-       if (CHK_SDIO_EXIST(chip)) {
-               if (CHECK_PID(chip, 0x5288))
-                       rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFF00, 0x0100);
-               else
-                       rtsx_write_cfg_dw(chip, 1, 0xC0, 0xFF00, 0x0100);
-       }
+       if (CHK_SDIO_EXIST(chip))
+               rtsx_write_cfg_dw(chip, CHECK_PID(chip, 0x5288) ? 2 : 1,
+                                 0xC0, 0xFF00, 0x0100);
 
        if (chip->auto_delink_en) {
                rtsx_write_register(chip, HOST_SLEEP_STATE, 0x01, 0x01);
@@ -1666,7 +1635,7 @@ int rtsx_pre_handle_interrupt(struct rtsx_chip *chip)
        chip->int_reg = rtsx_readl(chip, RTSX_BIPR);
 
        if (((chip->int_reg & int_enable) == 0) ||
-               (chip->int_reg == 0xFFFFFFFF))
+           (chip->int_reg == 0xFFFFFFFF))
                return STATUS_FAIL;
 
        status = chip->int_reg &= (int_enable | 0x7FFFFF);
@@ -1676,12 +1645,12 @@ int rtsx_pre_handle_interrupt(struct rtsx_chip *chip)
 
                if (status & SD_INT) {
                        if (status & SD_EXIST) {
-                               set_bit(SD_NR, &(chip->need_reset));
+                               set_bit(SD_NR, &chip->need_reset);
                        } else {
-                               set_bit(SD_NR, &(chip->need_release));
+                               set_bit(SD_NR, &chip->need_release);
                                chip->sd_reset_counter = 0;
                                chip->sd_show_cnt = 0;
-                               clear_bit(SD_NR, &(chip->need_reset));
+                               clear_bit(SD_NR, &chip->need_reset);
                        }
                } else {
                        /* If multi-luns, it's possible that
@@ -1691,35 +1660,35 @@ int rtsx_pre_handle_interrupt(struct rtsx_chip *chip)
                           all existed cards should be reset.
                        */
                        if (exit_ss && (status & SD_EXIST))
-                               set_bit(SD_NR, &(chip->need_reinit));
+                               set_bit(SD_NR, &chip->need_reinit);
                }
                if (!CHECK_PID(chip, 0x5288) || CHECK_BARO_PKG(chip, QFN)) {
                        if (status & XD_INT) {
                                if (status & XD_EXIST) {
-                                       set_bit(XD_NR, &(chip->need_reset));
+                                       set_bit(XD_NR, &chip->need_reset);
                                } else {
-                                       set_bit(XD_NR, &(chip->need_release));
+                                       set_bit(XD_NR, &chip->need_release);
                                        chip->xd_reset_counter = 0;
                                        chip->xd_show_cnt = 0;
-                                       clear_bit(XD_NR, &(chip->need_reset));
+                                       clear_bit(XD_NR, &chip->need_reset);
                                }
                        } else {
                                if (exit_ss && (status & XD_EXIST))
-                                       set_bit(XD_NR, &(chip->need_reinit));
+                                       set_bit(XD_NR, &chip->need_reinit);
                        }
                }
                if (status & MS_INT) {
                        if (status & MS_EXIST) {
-                               set_bit(MS_NR, &(chip->need_reset));
+                               set_bit(MS_NR, &chip->need_reset);
                        } else {
-                               set_bit(MS_NR, &(chip->need_release));
+                               set_bit(MS_NR, &chip->need_release);
                                chip->ms_reset_counter = 0;
                                chip->ms_show_cnt = 0;
-                               clear_bit(MS_NR, &(chip->need_reset));
+                               clear_bit(MS_NR, &chip->need_reset);
                        }
                } else {
                        if (exit_ss && (status & MS_EXIST))
-                               set_bit(MS_NR, &(chip->need_reinit));
+                               set_bit(MS_NR, &chip->need_reinit);
                }
        }
 
@@ -1727,10 +1696,8 @@ int rtsx_pre_handle_interrupt(struct rtsx_chip *chip)
        chip->ocp_int = ocp_int & status;
 #endif
 
-       if (chip->sd_io) {
-               if (chip->int_reg & DATA_DONE_INT)
-                       chip->int_reg &= ~(u32)DATA_DONE_INT;
-       }
+       if (chip->sd_io && (chip->int_reg & DATA_DONE_INT))
+               chip->int_reg &= ~(u32)DATA_DONE_INT;
 
        return STATUS_SUCCESS;
 }
@@ -1774,14 +1741,14 @@ void rtsx_do_before_power_down(struct rtsx_chip *chip, int pm_stat)
        if (pm_stat == PM_S1) {
                dev_dbg(rtsx_dev(chip), "Host enter S1\n");
                rtsx_write_register(chip, HOST_SLEEP_STATE, 0x03,
-                               HOST_ENTER_S1);
+                                   HOST_ENTER_S1);
        } else if (pm_stat == PM_S3) {
                if (chip->s3_pwr_off_delay > 0)
                        wait_timeout(chip->s3_pwr_off_delay);
 
                dev_dbg(rtsx_dev(chip), "Host enter S3\n");
                rtsx_write_register(chip, HOST_SLEEP_STATE, 0x03,
-                               HOST_ENTER_S3);
+                                   HOST_ENTER_S3);
        }
 
        if (chip->do_delink_before_power_down && chip->auto_delink_en)
@@ -1796,31 +1763,25 @@ void rtsx_do_before_power_down(struct rtsx_chip *chip, int pm_stat)
 
 void rtsx_enable_aspm(struct rtsx_chip *chip)
 {
-       if (chip->aspm_l0s_l1_en && chip->dynamic_aspm) {
-               if (!chip->aspm_enabled) {
-                       dev_dbg(rtsx_dev(chip), "Try to enable ASPM\n");
-                       chip->aspm_enabled = 1;
+       if (chip->aspm_l0s_l1_en && chip->dynamic_aspm && !chip->aspm_enabled) {
+               dev_dbg(rtsx_dev(chip), "Try to enable ASPM\n");
+               chip->aspm_enabled = 1;
 
-                       if (chip->asic_code && CHECK_PID(chip, 0x5208))
-                               rtsx_write_phy_register(chip, 0x07, 0);
-                       if (CHECK_PID(chip, 0x5208)) {
-                               rtsx_write_register(chip, ASPM_FORCE_CTL, 0xF3,
-                                       0x30 | chip->aspm_level[0]);
-                       } else {
-                               rtsx_write_config_byte(chip, LCTLR,
-                                               chip->aspm_l0s_l1_en);
-                       }
+               if (chip->asic_code && CHECK_PID(chip, 0x5208))
+                       rtsx_write_phy_register(chip, 0x07, 0);
+               if (CHECK_PID(chip, 0x5208)) {
+                       rtsx_write_register(chip, ASPM_FORCE_CTL, 0xF3,
+                                           0x30 | chip->aspm_level[0]);
+               } else {
+                       rtsx_write_config_byte(chip, LCTLR,
+                                              chip->aspm_l0s_l1_en);
+               }
 
-                       if (CHK_SDIO_EXIST(chip)) {
-                               u16 val = chip->aspm_l0s_l1_en | 0x0100;
+               if (CHK_SDIO_EXIST(chip)) {
+                       u16 val = chip->aspm_l0s_l1_en | 0x0100;
 
-                               if (CHECK_PID(chip, 0x5288))
-                                       rtsx_write_cfg_dw(chip, 2, 0xC0,
-                                                       0xFFFF, val);
-                               else
-                                       rtsx_write_cfg_dw(chip, 1, 0xC0,
-                                                       0xFFFF, val);
-                       }
+                       rtsx_write_cfg_dw(chip, CHECK_PID(chip, 0x5288) ? 2 : 1,
+                                         0xC0, 0xFFF, val);
                }
        }
 }
@@ -1830,21 +1791,19 @@ void rtsx_disable_aspm(struct rtsx_chip *chip)
        if (CHECK_PID(chip, 0x5208))
                rtsx_monitor_aspm_config(chip);
 
-       if (chip->aspm_l0s_l1_en && chip->dynamic_aspm) {
-               if (chip->aspm_enabled) {
-                       dev_dbg(rtsx_dev(chip), "Try to disable ASPM\n");
-                       chip->aspm_enabled = 0;
+       if (chip->aspm_l0s_l1_en && chip->dynamic_aspm && chip->aspm_enabled) {
+               dev_dbg(rtsx_dev(chip), "Try to disable ASPM\n");
+               chip->aspm_enabled = 0;
 
-                       if (chip->asic_code && CHECK_PID(chip, 0x5208))
-                               rtsx_write_phy_register(chip, 0x07, 0x0129);
-                       if (CHECK_PID(chip, 0x5208))
-                               rtsx_write_register(chip, ASPM_FORCE_CTL,
-                                               0xF3, 0x30);
-                       else
-                               rtsx_write_config_byte(chip, LCTLR, 0x00);
+               if (chip->asic_code && CHECK_PID(chip, 0x5208))
+                       rtsx_write_phy_register(chip, 0x07, 0x0129);
+               if (CHECK_PID(chip, 0x5208))
+                       rtsx_write_register(chip, ASPM_FORCE_CTL,
+                                           0xF3, 0x30);
+               else
+                       rtsx_write_config_byte(chip, LCTLR, 0x00);
 
-                       wait_timeout(1);
-               }
+               wait_timeout(1);
        }
 }
 
@@ -1907,7 +1866,7 @@ int rtsx_write_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len)
 
                for (j = 0; j < 256; j++) {
                        rtsx_add_cmd(chip, WRITE_REG_CMD, reg_addr++, 0xFF,
-                               *ptr);
+                                    *ptr);
                        ptr++;
                }
 
@@ -1921,7 +1880,7 @@ int rtsx_write_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len)
 
                for (j = 0; j < buf_len%256; j++) {
                        rtsx_add_cmd(chip, WRITE_REG_CMD, reg_addr++, 0xFF,
-                               *ptr);
+                                    *ptr);
                        ptr++;
                }
 
index bbbf796..1161082 100644 (file)
@@ -584,9 +584,8 @@ static int start_stop_unit(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        case MAKE_MEDIUM_READY:
        case LOAD_MEDIUM:
-               if (check_card_ready(chip, lun)) {
+               if (check_card_ready(chip, lun))
                        return TRANSPORT_GOOD;
-               }
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
                TRACE_RET(chip, TRANSPORT_FAILED);
 
index 0a67dca..756a968 100644 (file)
@@ -539,7 +539,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card,
                if (i == buf_cnt / (HOST_SG_TBL_BUF_LEN / 8))
                        sg_cnt = buf_cnt % (HOST_SG_TBL_BUF_LEN / 8);
                else
-                       sg_cnt = (HOST_SG_TBL_BUF_LEN / 8);
+                       sg_cnt = HOST_SG_TBL_BUF_LEN / 8;
 
                chip->sgi = 0;
                for (j = 0; j < sg_cnt; j++) {
@@ -728,15 +728,13 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card,
        if (rtsx_chk_stat(chip, RTSX_STAT_ABORT))
                return -EIO;
 
-       if (use_sg) {
+       if (use_sg)
                err = rtsx_transfer_sglist_adma_partial(chip, card,
                                (struct scatterlist *)buf, use_sg,
                                index, offset, (int)len, dma_dir, timeout);
-       } else {
+       else
                err = rtsx_transfer_buf(chip, card,
                                        buf, len, dma_dir, timeout);
-       }
-
        if (err < 0) {
                if (RTSX_TST_DELINK(chip)) {
                        RTSX_CLR_DELINK(chip);
index b4b1123..899bc20 100644 (file)
@@ -46,7 +46,7 @@ void rtsx_add_cmd(struct rtsx_chip *chip,
 void rtsx_send_cmd_no_wait(struct rtsx_chip *chip);
 int rtsx_send_cmd(struct rtsx_chip *chip, u8 card, int timeout);
 
-extern inline u8 *rtsx_get_cmd_data(struct rtsx_chip *chip)
+static inline u8 *rtsx_get_cmd_data(struct rtsx_chip *chip)
 {
 #ifdef CMD_USING_SG
        return (u8 *)(chip->host_sg_tbl_ptr);
index b9172bf..012a823 100644 (file)
@@ -1,8 +1,8 @@
 config CRYPTO_SKEIN
-       bool "Skein digest algorithm"
+       tristate "Skein digest algorithm"
        depends on (X86 || UML_X86) && 64BIT && CRYPTO
-       select CRYPTO_THREEFISH
        select CRYPTO_HASH
+       select CRYPTO_ALGAPI
        help
          Skein secure hash algorithm is one of 5 finalists from the NIST SHA3
          competition.
@@ -12,21 +12,5 @@ config CRYPTO_SKEIN
 
          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 && CRYPTO
-       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.
+         for more information. This module also contains the threefish block
+         cipher algorithm.
index a14aadd..b7f947f 100644 (file)
@@ -1,9 +1,10 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
-                               skein_api.o \
-                               skein_block.o
-
-obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
-                                 threefish_api.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein.o
+skein-y := skein_base.o \
+          skein_api.o \
+          skein_block.o \
+          threefish_block.o \
+          threefish_api.o \
+          skein_generic.o
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
deleted file mode 100644 (file)
index 8cc8358..0000000
+++ /dev/null
@@ -1,883 +0,0 @@
-/***********************************************************************
-**
-** Implementation of the Skein hash function.
-**
-** Source code author: Doug Whiting, 2008.
-**
-** This algorithm and source code is released to the public domain.
-**
-************************************************************************/
-
-#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 hash_bit_len)
-{
-       union {
-               u8 b[SKEIN_256_STATE_BYTES];
-               u64 w[SKEIN_256_STATE_WORDS];
-       } cfg;                              /* config block */
-
-       skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
-       ctx->h.hash_bit_len = hash_bit_len;         /* output hash bit count */
-
-       switch (hash_bit_len) { /* use pre-computed values, where available */
-       case  256:
-               memcpy(ctx->x, SKEIN_256_IV_256, sizeof(ctx->x));
-               break;
-       case  224:
-               memcpy(ctx->x, SKEIN_256_IV_224, sizeof(ctx->x));
-               break;
-       case  160:
-               memcpy(ctx->x, SKEIN_256_IV_160, sizeof(ctx->x));
-               break;
-       case  128:
-               memcpy(ctx->x, SKEIN_256_IV_128, sizeof(ctx->x));
-               break;
-       default:
-               /* here if there is no precomputed IV value available */
-               /*
-                * build/process the config block, type == CONFIG (could be
-                * precomputed)
-                */
-               /* set tweaks: T0=0; T1=CFG | FINAL */
-               skein_start_new_type(ctx, CFG_FINAL);
-
-               /* set the schema, version */
-               cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
-               /* hash result length in bits */
-               cfg.w[1] = skein_swap64(hash_bit_len);
-               cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
-               /* zero pad config block */
-               memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0]));
-
-               /* compute the initial chaining values from config block */
-               /* zero the chaining variables */
-               memset(ctx->x, 0, sizeof(ctx->x));
-               skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
-               break;
-       }
-       /* The chaining vars ctx->x are now initialized for hash_bit_len. */
-       /* Set up to process the data message portion of the hash (default) */
-       skein_start_new_type(ctx, MSG);              /* T0=0, T1= MSG type */
-
-       return SKEIN_SUCCESS;
-}
-
-/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
-/* init the context for a MAC and/or tree hash operation */
-/* [identical to skein_256_init() when key_bytes == 0 && \
- *     tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
-int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len,
-                      u64 tree_info, const u8 *key, size_t key_bytes)
-{
-       union {
-               u8  b[SKEIN_256_STATE_BYTES];
-               u64 w[SKEIN_256_STATE_WORDS];
-       } cfg; /* config block */
-
-       skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
-       skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL);
-
-       /* compute the initial chaining values ctx->x[], based on key */
-       if (key_bytes == 0) { /* is there a key? */
-               /* no key: use all zeroes as key for config block */
-               memset(ctx->x, 0, sizeof(ctx->x));
-       } else { /* here to pre-process a key */
-               skein_assert(sizeof(cfg.b) >= sizeof(ctx->x));
-               /* do a mini-Init right here */
-               /* set output hash bit count = state size */
-               ctx->h.hash_bit_len = 8*sizeof(ctx->x);
-               /* set tweaks: T0 = 0; T1 = KEY type */
-               skein_start_new_type(ctx, KEY);
-               /* zero the initial chaining variables */
-               memset(ctx->x, 0, sizeof(ctx->x));
-               /* hash the key */
-               skein_256_update(ctx, key, key_bytes);
-               /* put result into cfg.b[] */
-               skein_256_final_pad(ctx, cfg.b);
-               /* copy over into ctx->x[] */
-               memcpy(ctx->x, cfg.b, sizeof(cfg.b));
-       }
-       /*
-        * build/process the config block, type == CONFIG (could be
-        * precomputed for each key)
-        */
-       /* output hash bit count */
-       ctx->h.hash_bit_len = hash_bit_len;
-       skein_start_new_type(ctx, CFG_FINAL);
-
-       /* pre-pad cfg.w[] with zeroes */
-       memset(&cfg.w, 0, sizeof(cfg.w));
-       cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
-       /* hash result length in bits */
-       cfg.w[1] = skein_swap64(hash_bit_len);
-       /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
-       cfg.w[2] = skein_swap64(tree_info);
-
-       skein_show_key(256, &ctx->h, key, key_bytes);
-
-       /* compute the initial chaining values from config block */
-       skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
-
-       /* The chaining vars ctx->x are now initialized */
-       /* Set up to process the data message portion of the hash (default) */
-       skein_start_new_type(ctx, MSG);
-
-       return SKEIN_SUCCESS;
-}
-
-/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
-/* process the input bytes */
-int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg,
-                    size_t msg_byte_cnt)
-{
-       size_t n;
-
-       /* catch uninitialized context */
-       skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
-
-       /* process full blocks, if any */
-       if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_256_BLOCK_BYTES) {
-               /* finish up any buffered message data */
-               if (ctx->h.b_cnt) {
-                       /* # bytes free in buffer b[] */
-                       n = SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt;
-                       if (n) {
-                               /* check on our logic here */
-                               skein_assert(n < msg_byte_cnt);
-                               memcpy(&ctx->b[ctx->h.b_cnt], msg, n);
-                               msg_byte_cnt  -= n;
-                               msg         += n;
-                               ctx->h.b_cnt += n;
-                       }
-                       skein_assert(ctx->h.b_cnt == SKEIN_256_BLOCK_BYTES);
-                       skein_256_process_block(ctx, ctx->b, 1,
-                                               SKEIN_256_BLOCK_BYTES);
-                       ctx->h.b_cnt = 0;
-               }
-               /*
-                * now process any remaining full blocks, directly from input
-                * message data
-                */
-               if (msg_byte_cnt > SKEIN_256_BLOCK_BYTES) {
-                       /* number of full blocks to process */
-                       n = (msg_byte_cnt-1) / SKEIN_256_BLOCK_BYTES;
-                       skein_256_process_block(ctx, msg, n,
-                                               SKEIN_256_BLOCK_BYTES);
-                       msg_byte_cnt -= n * SKEIN_256_BLOCK_BYTES;
-                       msg        += n * SKEIN_256_BLOCK_BYTES;
-               }
-               skein_assert(ctx->h.b_cnt == 0);
-       }
-
-       /* copy any remaining source message data bytes into b[] */
-       if (msg_byte_cnt) {
-               skein_assert(msg_byte_cnt + ctx->h.b_cnt <=
-                            SKEIN_256_BLOCK_BYTES);
-               memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt);
-               ctx->h.b_cnt += msg_byte_cnt;
-       }
-
-       return SKEIN_SUCCESS;
-}
-
-/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
-/* finalize the hash computation and output the result */
-int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val)
-{
-       size_t i, n, byte_cnt;
-       u64 x[SKEIN_256_STATE_WORDS];
-       /* catch uninitialized context */
-       skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
-
-       /* tag as the final block */
-       ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL;
-       /* zero pad b[] if necessary */
-       if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES)
-               memset(&ctx->b[ctx->h.b_cnt], 0,
-                       SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt);
-
-       /* process the final block */
-       skein_256_process_block(ctx, ctx->b, 1, ctx->h.b_cnt);
-
-       /* now output the result */
-       /* total number of output bytes */
-       byte_cnt = (ctx->h.hash_bit_len + 7) >> 3;
-
-       /* run Threefish in "counter mode" to generate output */
-       /* zero out b[], so it can hold the counter */
-       memset(ctx->b, 0, sizeof(ctx->b));
-       /* keep a local copy of counter mode "key" */
-       memcpy(x, ctx->x, sizeof(x));
-       for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) {
-               /* build the counter block */
-               ((u64 *)ctx->b)[0] = skein_swap64((u64) i);
-               skein_start_new_type(ctx, OUT_FINAL);
-               /* run "counter mode" */
-               skein_256_process_block(ctx, ctx->b, 1, sizeof(u64));
-               /* number of output bytes left to go */
-               n = byte_cnt - i*SKEIN_256_BLOCK_BYTES;
-               if (n >= SKEIN_256_BLOCK_BYTES)
-                       n  = SKEIN_256_BLOCK_BYTES;
-               /* "output" the ctr mode bytes */
-               skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x,
-                                     n);
-               skein_show_final(256, &ctx->h, n,
-                                hash_val+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 hash_bit_len)
-{
-       union {
-               u8 b[SKEIN_512_STATE_BYTES];
-               u64 w[SKEIN_512_STATE_WORDS];
-       } cfg;                              /* config block */
-
-       skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
-       ctx->h.hash_bit_len = hash_bit_len;         /* output hash bit count */
-
-       switch (hash_bit_len) { /* use pre-computed values, where available */
-       case  512:
-               memcpy(ctx->x, SKEIN_512_IV_512, sizeof(ctx->x));
-               break;
-       case  384:
-               memcpy(ctx->x, SKEIN_512_IV_384, sizeof(ctx->x));
-               break;
-       case  256:
-               memcpy(ctx->x, SKEIN_512_IV_256, sizeof(ctx->x));
-               break;
-       case  224:
-               memcpy(ctx->x, SKEIN_512_IV_224, sizeof(ctx->x));
-               break;
-       default:
-               /* here if there is no precomputed IV value available */
-               /*
-                * build/process the config block, type == CONFIG (could be
-                * precomputed)
-                */
-               /* set tweaks: T0=0; T1=CFG | FINAL */
-               skein_start_new_type(ctx, CFG_FINAL);
-
-               /* set the schema, version */
-               cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
-               /* hash result length in bits */
-               cfg.w[1] = skein_swap64(hash_bit_len);
-               cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
-               /* zero pad config block */
-               memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0]));
-
-               /* compute the initial chaining values from config block */
-               /* zero the chaining variables */
-               memset(ctx->x, 0, sizeof(ctx->x));
-               skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
-               break;
-       }
-
-       /*
-        * The chaining vars ctx->x are now initialized for the given
-        * hash_bit_len.
-        */
-       /* Set up to process the data message portion of the hash (default) */
-       skein_start_new_type(ctx, MSG);              /* T0=0, T1= MSG type */
-
-       return SKEIN_SUCCESS;
-}
-
-/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
-/* init the context for a MAC and/or tree hash operation */
-/* [identical to skein_512_init() when key_bytes == 0 && \
- *     tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
-int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len,
-                      u64 tree_info, const u8 *key, size_t key_bytes)
-{
-       union {
-               u8 b[SKEIN_512_STATE_BYTES];
-               u64 w[SKEIN_512_STATE_WORDS];
-       } cfg;                              /* config block */
-
-       skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
-       skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL);
-
-       /* compute the initial chaining values ctx->x[], based on key */
-       if (key_bytes == 0) { /* is there a key? */
-               /* no key: use all zeroes as key for config block */
-               memset(ctx->x, 0, sizeof(ctx->x));
-       } else { /* here to pre-process a key */
-               skein_assert(sizeof(cfg.b) >= sizeof(ctx->x));
-               /* do a mini-Init right here */
-               /* set output hash bit count = state size */
-               ctx->h.hash_bit_len = 8*sizeof(ctx->x);
-               /* set tweaks: T0 = 0; T1 = KEY type */
-               skein_start_new_type(ctx, KEY);
-               /* zero the initial chaining variables */
-               memset(ctx->x, 0, sizeof(ctx->x));
-               /* hash the key */
-               skein_512_update(ctx, key, key_bytes);
-               /* put result into cfg.b[] */
-               skein_512_final_pad(ctx, cfg.b);
-               /* copy over into ctx->x[] */
-               memcpy(ctx->x, cfg.b, sizeof(cfg.b));
-       }
-       /*
-        * build/process the config block, type == CONFIG (could be
-        * precomputed for each key)
-        */
-       ctx->h.hash_bit_len = hash_bit_len;          /* output hash bit count */
-       skein_start_new_type(ctx, CFG_FINAL);
-
-       /* pre-pad cfg.w[] with zeroes */
-       memset(&cfg.w, 0, sizeof(cfg.w));
-       cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
-       /* hash result length in bits */
-       cfg.w[1] = skein_swap64(hash_bit_len);
-       /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
-       cfg.w[2] = skein_swap64(tree_info);
-
-       skein_show_key(512, &ctx->h, key, key_bytes);
-
-       /* compute the initial chaining values from config block */
-       skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
-
-       /* The chaining vars ctx->x are now initialized */
-       /* Set up to process the data message portion of the hash (default) */
-       skein_start_new_type(ctx, MSG);
-
-       return SKEIN_SUCCESS;
-}
-
-/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
-/* process the input bytes */
-int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg,
-                    size_t msg_byte_cnt)
-{
-       size_t n;
-
-       /* catch uninitialized context */
-       skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
-
-       /* process full blocks, if any */
-       if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_512_BLOCK_BYTES) {
-               /* finish up any buffered message data */
-               if (ctx->h.b_cnt) {
-                       /* # bytes free in buffer b[] */
-                       n = SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt;
-                       if (n) {
-                               /* check on our logic here */
-                               skein_assert(n < msg_byte_cnt);
-                               memcpy(&ctx->b[ctx->h.b_cnt], msg, n);
-                               msg_byte_cnt  -= n;
-                               msg         += n;
-                               ctx->h.b_cnt += n;
-                       }
-                       skein_assert(ctx->h.b_cnt == SKEIN_512_BLOCK_BYTES);
-                       skein_512_process_block(ctx, ctx->b, 1,
-                                               SKEIN_512_BLOCK_BYTES);
-                       ctx->h.b_cnt = 0;
-               }
-               /*
-                * now process any remaining full blocks, directly from input
-                * message data
-                */
-               if (msg_byte_cnt > SKEIN_512_BLOCK_BYTES) {
-                       /* number of full blocks to process */
-                       n = (msg_byte_cnt-1) / SKEIN_512_BLOCK_BYTES;
-                       skein_512_process_block(ctx, msg, n,
-                                               SKEIN_512_BLOCK_BYTES);
-                       msg_byte_cnt -= n * SKEIN_512_BLOCK_BYTES;
-                       msg        += n * SKEIN_512_BLOCK_BYTES;
-               }
-               skein_assert(ctx->h.b_cnt == 0);
-       }
-
-       /* copy any remaining source message data bytes into b[] */
-       if (msg_byte_cnt) {
-               skein_assert(msg_byte_cnt + ctx->h.b_cnt <=
-                            SKEIN_512_BLOCK_BYTES);
-               memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt);
-               ctx->h.b_cnt += msg_byte_cnt;
-       }
-
-       return SKEIN_SUCCESS;
-}
-
-/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
-/* finalize the hash computation and output the result */
-int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val)
-{
-       size_t i, n, byte_cnt;
-       u64 x[SKEIN_512_STATE_WORDS];
-       /* catch uninitialized context */
-       skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
-
-       /* tag as the final block */
-       ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL;
-       /* zero pad b[] if necessary */
-       if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES)
-               memset(&ctx->b[ctx->h.b_cnt], 0,
-                       SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt);
-
-       /* process the final block */
-       skein_512_process_block(ctx, ctx->b, 1, ctx->h.b_cnt);
-
-       /* now output the result */
-       /* total number of output bytes */
-       byte_cnt = (ctx->h.hash_bit_len + 7) >> 3;
-
-       /* run Threefish in "counter mode" to generate output */
-       /* zero out b[], so it can hold the counter */
-       memset(ctx->b, 0, sizeof(ctx->b));
-       /* keep a local copy of counter mode "key" */
-       memcpy(x, ctx->x, sizeof(x));
-       for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) {
-               /* build the counter block */
-               ((u64 *)ctx->b)[0] = skein_swap64((u64) i);
-               skein_start_new_type(ctx, OUT_FINAL);
-               /* run "counter mode" */
-               skein_512_process_block(ctx, ctx->b, 1, sizeof(u64));
-               /* number of output bytes left to go */
-               n = byte_cnt - i*SKEIN_512_BLOCK_BYTES;
-               if (n >= SKEIN_512_BLOCK_BYTES)
-                       n  = SKEIN_512_BLOCK_BYTES;
-               /* "output" the ctr mode bytes */
-               skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x,
-                                     n);
-               skein_show_final(512, &ctx->h, n,
-                                hash_val+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 skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len)
-{
-       union {
-               u8 b[SKEIN_1024_STATE_BYTES];
-               u64 w[SKEIN_1024_STATE_WORDS];
-       } cfg;                              /* config block */
-
-       skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
-       ctx->h.hash_bit_len = hash_bit_len;         /* output hash bit count */
-
-       switch (hash_bit_len) { /* use pre-computed values, where available */
-       case  512:
-               memcpy(ctx->x, SKEIN_1024_IV_512, sizeof(ctx->x));
-               break;
-       case  384:
-               memcpy(ctx->x, SKEIN_1024_IV_384, sizeof(ctx->x));
-               break;
-       case 1024:
-               memcpy(ctx->x, SKEIN_1024_IV_1024, sizeof(ctx->x));
-               break;
-       default:
-               /* here if there is no precomputed IV value available */
-               /*
-                * build/process the config block, type == CONFIG
-                * (could be precomputed)
-                */
-               /* set tweaks: T0=0; T1=CFG | FINAL */
-               skein_start_new_type(ctx, CFG_FINAL);
-
-               /* set the schema, version */
-               cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
-               /* hash result length in bits */
-               cfg.w[1] = skein_swap64(hash_bit_len);
-               cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
-               /* zero pad config block */
-               memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0]));
-
-               /* compute the initial chaining values from config block */
-               /* zero the chaining variables */
-               memset(ctx->x, 0, sizeof(ctx->x));
-               skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
-               break;
-       }
-
-       /* The chaining vars ctx->x are now initialized for the hash_bit_len. */
-       /* Set up to process the data message portion of the hash (default) */
-       skein_start_new_type(ctx, MSG);              /* T0=0, T1= MSG type */
-
-       return SKEIN_SUCCESS;
-}
-
-/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
-/* init the context for a MAC and/or tree hash operation */
-/* [identical to skein_1024_init() when key_bytes == 0 && \
- *     tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
-int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len,
-                       u64 tree_info, const u8 *key, size_t key_bytes)
-{
-       union {
-               u8 b[SKEIN_1024_STATE_BYTES];
-               u64 w[SKEIN_1024_STATE_WORDS];
-       } cfg;                              /* config block */
-
-       skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
-       skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL);
-
-       /* compute the initial chaining values ctx->x[], based on key */
-       if (key_bytes == 0) { /* is there a key? */
-               /* no key: use all zeroes as key for config block */
-               memset(ctx->x, 0, sizeof(ctx->x));
-       } else { /* here to pre-process a key */
-               skein_assert(sizeof(cfg.b) >= sizeof(ctx->x));
-               /* do a mini-Init right here */
-               /* set output hash bit count = state size */
-               ctx->h.hash_bit_len = 8*sizeof(ctx->x);
-               /* set tweaks: T0 = 0; T1 = KEY type */
-               skein_start_new_type(ctx, KEY);
-               /* zero the initial chaining variables */
-               memset(ctx->x, 0, sizeof(ctx->x));
-               /* hash the key */
-               skein_1024_update(ctx, key, key_bytes);
-               /* put result into cfg.b[] */
-               skein_1024_final_pad(ctx, cfg.b);
-               /* copy over into ctx->x[] */
-               memcpy(ctx->x, cfg.b, sizeof(cfg.b));
-       }
-       /*
-        * build/process the config block, type == CONFIG (could be
-        * precomputed for each key)
-        */
-       /* output hash bit count */
-       ctx->h.hash_bit_len = hash_bit_len;
-       skein_start_new_type(ctx, CFG_FINAL);
-
-       /* pre-pad cfg.w[] with zeroes */
-       memset(&cfg.w, 0, sizeof(cfg.w));
-       cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
-       /* hash result length in bits */
-       cfg.w[1] = skein_swap64(hash_bit_len);
-       /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
-       cfg.w[2] = skein_swap64(tree_info);
-
-       skein_show_key(1024, &ctx->h, key, key_bytes);
-
-       /* compute the initial chaining values from config block */
-       skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
-
-       /* The chaining vars ctx->x are now initialized */
-       /* Set up to process the data message portion of the hash (default) */
-       skein_start_new_type(ctx, MSG);
-
-       return SKEIN_SUCCESS;
-}
-
-/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
-/* process the input bytes */
-int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg,
-                     size_t msg_byte_cnt)
-{
-       size_t n;
-
-       /* catch uninitialized context */
-       skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL);
-
-       /* process full blocks, if any */
-       if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_1024_BLOCK_BYTES) {
-               /* finish up any buffered message data */
-               if (ctx->h.b_cnt) {
-                       /* # bytes free in buffer b[] */
-                       n = SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt;
-                       if (n) {
-                               /* check on our logic here */
-                               skein_assert(n < msg_byte_cnt);
-                               memcpy(&ctx->b[ctx->h.b_cnt], msg, n);
-                               msg_byte_cnt  -= n;
-                               msg         += n;
-                               ctx->h.b_cnt += n;
-                       }
-                       skein_assert(ctx->h.b_cnt == SKEIN_1024_BLOCK_BYTES);
-                       skein_1024_process_block(ctx, ctx->b, 1,
-                                                SKEIN_1024_BLOCK_BYTES);
-                       ctx->h.b_cnt = 0;
-               }
-               /*
-                * now process any remaining full blocks, directly from input
-                * message data
-                */
-               if (msg_byte_cnt > SKEIN_1024_BLOCK_BYTES) {
-                       /* number of full blocks to process */
-                       n = (msg_byte_cnt-1) / SKEIN_1024_BLOCK_BYTES;
-                       skein_1024_process_block(ctx, msg, n,
-                                                SKEIN_1024_BLOCK_BYTES);
-                       msg_byte_cnt -= n * SKEIN_1024_BLOCK_BYTES;
-                       msg        += n * SKEIN_1024_BLOCK_BYTES;
-               }
-               skein_assert(ctx->h.b_cnt == 0);
-       }
-
-       /* copy any remaining source message data bytes into b[] */
-       if (msg_byte_cnt) {
-               skein_assert(msg_byte_cnt + ctx->h.b_cnt <=
-                            SKEIN_1024_BLOCK_BYTES);
-               memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt);
-               ctx->h.b_cnt += msg_byte_cnt;
-       }
-
-       return SKEIN_SUCCESS;
-}
-
-/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
-/* finalize the hash computation and output the result */
-int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val)
-{
-       size_t i, n, byte_cnt;
-       u64 x[SKEIN_1024_STATE_WORDS];
-       /* catch uninitialized context */
-       skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL);
-
-       /* tag as the final block */
-       ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL;
-       /* zero pad b[] if necessary */
-       if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES)
-               memset(&ctx->b[ctx->h.b_cnt], 0,
-                       SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt);
-
-       /* process the final block */
-       skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt);
-
-       /* now output the result */
-       /* total number of output bytes */
-       byte_cnt = (ctx->h.hash_bit_len + 7) >> 3;
-
-       /* run Threefish in "counter mode" to generate output */
-       /* zero out b[], so it can hold the counter */
-       memset(ctx->b, 0, sizeof(ctx->b));
-       /* keep a local copy of counter mode "key" */
-       memcpy(x, ctx->x, sizeof(x));
-       for (i = 0; i*SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) {
-               /* build the counter block */
-               ((u64 *)ctx->b)[0] = skein_swap64((u64) i);
-               skein_start_new_type(ctx, OUT_FINAL);
-               /* run "counter mode" */
-               skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64));
-               /* number of output bytes left to go */
-               n = byte_cnt - i*SKEIN_1024_BLOCK_BYTES;
-               if (n >= SKEIN_1024_BLOCK_BYTES)
-                       n  = SKEIN_1024_BLOCK_BYTES;
-               /* "output" the ctr mode bytes */
-               skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x,
-                                     n);
-               skein_show_final(1024, &ctx->h, n,
-                                hash_val+i*SKEIN_1024_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 *hash_val)
-{
-       /* catch uninitialized context */
-       skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
-
-       /* tag as the final block */
-       ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL;
-       /* zero pad b[] if necessary */
-       if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES)
-               memset(&ctx->b[ctx->h.b_cnt], 0,
-                       SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt);
-       /* process the final block */
-       skein_256_process_block(ctx, ctx->b, 1, ctx->h.b_cnt);
-
-       /* "output" the state bytes */
-       skein_put64_lsb_first(hash_val, ctx->x, SKEIN_256_BLOCK_BYTES);
-
-       return SKEIN_SUCCESS;
-}
-
-/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
-/* finalize the hash computation and output the block, no OUTPUT stage */
-int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val)
-{
-       /* catch uninitialized context */
-       skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
-
-       /* tag as the final block */
-       ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL;
-       /* zero pad b[] if necessary */
-       if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES)
-               memset(&ctx->b[ctx->h.b_cnt], 0,
-                       SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt);
-       /* process the final block */
-       skein_512_process_block(ctx, ctx->b, 1, ctx->h.b_cnt);
-
-       /* "output" the state bytes */
-       skein_put64_lsb_first(hash_val, ctx->x, SKEIN_512_BLOCK_BYTES);
-
-       return SKEIN_SUCCESS;
-}
-
-/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
-/* finalize the hash computation and output the block, no OUTPUT stage */
-int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val)
-{
-       /* catch uninitialized context */
-       skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL);
-
-       /* tag as the final block */
-       ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL;
-       /* zero pad b[] if necessary */
-       if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES)
-               memset(&ctx->b[ctx->h.b_cnt], 0,
-                       SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt);
-       /* process the final block */
-       skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt);
-
-       /* "output" the state bytes */
-       skein_put64_lsb_first(hash_val, ctx->x, SKEIN_1024_BLOCK_BYTES);
-
-       return SKEIN_SUCCESS;
-}
-
-#if SKEIN_TREE_HASH
-/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
-/* just do the OUTPUT stage                                       */
-int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val)
-{
-       size_t i, n, byte_cnt;
-       u64 x[SKEIN_256_STATE_WORDS];
-       /* catch uninitialized context */
-       skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
-
-       /* now output the result */
-       /* total number of output bytes */
-       byte_cnt = (ctx->h.hash_bit_len + 7) >> 3;
-
-       /* run Threefish in "counter mode" to generate output */
-       /* zero out b[], so it can hold the counter */
-       memset(ctx->b, 0, sizeof(ctx->b));
-       /* keep a local copy of counter mode "key" */
-       memcpy(x, ctx->x, sizeof(x));
-       for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) {
-               /* build the counter block */
-               ((u64 *)ctx->b)[0] = skein_swap64((u64) i);
-               skein_start_new_type(ctx, OUT_FINAL);
-               /* run "counter mode" */
-               skein_256_process_block(ctx, ctx->b, 1, sizeof(u64));
-               /* number of output bytes left to go */
-               n = byte_cnt - i*SKEIN_256_BLOCK_BYTES;
-               if (n >= SKEIN_256_BLOCK_BYTES)
-                       n  = SKEIN_256_BLOCK_BYTES;
-               /* "output" the ctr mode bytes */
-               skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x,
-                                     n);
-               skein_show_final(256, &ctx->h, n,
-                                hash_val+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 *hash_val)
-{
-       size_t i, n, byte_cnt;
-       u64 x[SKEIN_512_STATE_WORDS];
-       /* catch uninitialized context */
-       skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
-
-       /* now output the result */
-       /* total number of output bytes */
-       byte_cnt = (ctx->h.hash_bit_len + 7) >> 3;
-
-       /* run Threefish in "counter mode" to generate output */
-       /* zero out b[], so it can hold the counter */
-       memset(ctx->b, 0, sizeof(ctx->b));
-       /* keep a local copy of counter mode "key" */
-       memcpy(x, ctx->x, sizeof(x));
-       for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) {
-               /* build the counter block */
-               ((u64 *)ctx->b)[0] = skein_swap64((u64) i);
-               skein_start_new_type(ctx, OUT_FINAL);
-               /* run "counter mode" */
-               skein_512_process_block(ctx, ctx->b, 1, sizeof(u64));
-               /* number of output bytes left to go */
-               n = byte_cnt - i*SKEIN_512_BLOCK_BYTES;
-               if (n >= SKEIN_512_BLOCK_BYTES)
-                       n  = SKEIN_512_BLOCK_BYTES;
-               /* "output" the ctr mode bytes */
-               skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x,
-                                     n);
-               skein_show_final(256, &ctx->h, n,
-                                hash_val+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 skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val)
-{
-       size_t i, n, byte_cnt;
-       u64 x[SKEIN_1024_STATE_WORDS];
-       /* catch uninitialized context */
-       skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL);
-
-       /* now output the result */
-       /* total number of output bytes */
-       byte_cnt = (ctx->h.hash_bit_len + 7) >> 3;
-
-       /* run Threefish in "counter mode" to generate output */
-       /* zero out b[], so it can hold the counter */
-       memset(ctx->b, 0, sizeof(ctx->b));
-       /* keep a local copy of counter mode "key" */
-       memcpy(x, ctx->x, sizeof(x));
-       for (i = 0; i*SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) {
-               /* build the counter block */
-               ((u64 *)ctx->b)[0] = skein_swap64((u64) i);
-               skein_start_new_type(ctx, OUT_FINAL);
-               /* run "counter mode" */
-               skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64));
-               /* number of output bytes left to go */
-               n = byte_cnt - i*SKEIN_1024_BLOCK_BYTES;
-               if (n >= SKEIN_1024_BLOCK_BYTES)
-                       n  = SKEIN_1024_BLOCK_BYTES;
-               /* "output" the ctr mode bytes */
-               skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x,
-                                     n);
-               skein_show_final(256, &ctx->h, n,
-                                hash_val+i*SKEIN_1024_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/skein.h b/drivers/staging/skein/skein.h
deleted file mode 100644 (file)
index e6669f1..0000000
+++ /dev/null
@@ -1,346 +0,0 @@
-#ifndef _SKEIN_H_
-#define _SKEIN_H_     1
-/**************************************************************************
-**
-** Interface declarations and internal definitions for Skein hashing.
-**
-** Source code author: Doug Whiting, 2008.
-**
-** This algorithm and source code is released to the public domain.
-**
-***************************************************************************
-**
-** The following compile-time switches may be defined to control some
-** tradeoffs between speed, code size, error checking, and security.
-**
-** The "default" note explains what happens when the switch is not defined.
-**
-**  SKEIN_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, b_cnt) memcpy(dst08, src64, b_cnt)
-#define skein_get64_lsb_first(dst64, src08, w_cnt) \
-               memcpy(dst64, src08, 8*(w_cnt))
-#define skein_swap64(w64)  (w64)
-
-enum {
-       SKEIN_SUCCESS         =      0, /* return codes from Skein calls */
-       SKEIN_FAIL            =      1,
-       SKEIN_BAD_HASHLEN     =      2
-};
-
-#define  SKEIN_MODIFIER_WORDS   (2) /* number of modifier (tweak) words */
-
-#define  SKEIN_256_STATE_WORDS  (4)
-#define  SKEIN_512_STATE_WORDS  (8)
-#define  SKEIN_1024_STATE_WORDS (16)
-#define  SKEIN_MAX_STATE_WORDS (16)
-
-#define  SKEIN_256_STATE_BYTES  (8*SKEIN_256_STATE_WORDS)
-#define  SKEIN_512_STATE_BYTES  (8*SKEIN_512_STATE_WORDS)
-#define  SKEIN_1024_STATE_BYTES  (8*SKEIN_1024_STATE_WORDS)
-
-#define  SKEIN_256_STATE_BITS  (64*SKEIN_256_STATE_WORDS)
-#define  SKEIN_512_STATE_BITS  (64*SKEIN_512_STATE_WORDS)
-#define  SKEIN_1024_STATE_BITS  (64*SKEIN_1024_STATE_WORDS)
-
-#define  SKEIN_256_BLOCK_BYTES  (8*SKEIN_256_STATE_WORDS)
-#define  SKEIN_512_BLOCK_BYTES  (8*SKEIN_512_STATE_WORDS)
-#define  SKEIN_1024_BLOCK_BYTES  (8*SKEIN_1024_STATE_WORDS)
-
-struct skein_ctx_hdr {
-       size_t hash_bit_len;            /* size of hash result, in bits */
-       size_t b_cnt;                   /* current byte count in buffer b[] */
-       u64 tweak[SKEIN_MODIFIER_WORDS]; /* tweak[0]=byte cnt, tweak[1]=flags */
-};
-
-struct skein_256_ctx { /* 256-bit Skein hash context structure */
-       struct skein_ctx_hdr h;         /* common header context variables */
-       u64 x[SKEIN_256_STATE_WORDS];   /* chaining variables */
-       u8 b[SKEIN_256_BLOCK_BYTES];    /* partial block buf (8-byte aligned) */
-};
-
-struct skein_512_ctx { /* 512-bit Skein hash context structure */
-       struct skein_ctx_hdr h;         /* common header context variables */
-       u64 x[SKEIN_512_STATE_WORDS];   /* chaining variables */
-       u8 b[SKEIN_512_BLOCK_BYTES];    /* partial block buf (8-byte aligned) */
-};
-
-struct skein_1024_ctx { /* 1024-bit Skein hash context structure */
-       struct skein_ctx_hdr h;         /* common header context variables */
-       u64 x[SKEIN_1024_STATE_WORDS];  /* chaining variables */
-       u8 b[SKEIN_1024_BLOCK_BYTES];   /* partial block buf (8-byte aligned) */
-};
-
-/* Skein APIs for (incremental) "straight hashing" */
-int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len);
-int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len);
-int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len);
-
-int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg,
-                    size_t msg_byte_cnt);
-int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg,
-                    size_t msg_byte_cnt);
-int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg,
-                     size_t msg_byte_cnt);
-
-int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val);
-int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val);
-int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val);
-
-/*
-**   Skein APIs for "extended" initialization: MAC keys, tree hashing.
-**   After an init_ext() call, just use update/final calls as with init().
-**
-**   Notes: Same parameters as _init() calls, plus tree_info/key/key_bytes.
-**          When key_bytes == 0 and tree_info == SKEIN_SEQUENTIAL,
-**              the results of init_ext() are identical to calling init().
-**          The function init() may be called once to "precompute" the IV for
-**              a given hash_bit_len value, then by saving a copy of the context
-**              the IV computation may be avoided in later calls.
-**          Similarly, the function init_ext() may be called once per MAC key
-**              to precompute the MAC IV, then a copy of the context saved and
-**              reused for each new MAC computation.
-**/
-int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len,
-                      u64 tree_info, const u8 *key, size_t key_bytes);
-int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len,
-                      u64 tree_info, const u8 *key, size_t key_bytes);
-int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len,
-                       u64 tree_info, const u8 *key, size_t key_bytes);
-
-/*
-**   Skein APIs for MAC and tree hash:
-**      final_pad:  pad, do final block, but no OUTPUT type
-**      output:     do just the output stage
-*/
-int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val);
-int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val);
-int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val);
-
-#ifndef SKEIN_TREE_HASH
-#define SKEIN_TREE_HASH (1)
-#endif
-#if  SKEIN_TREE_HASH
-int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val);
-int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val);
-int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val);
-#endif
-
-/*****************************************************************
-** "Internal" Skein definitions
-**    -- not needed for sequential hashing API, but will be
-**           helpful for other uses of Skein (e.g., tree hash mode).
-**    -- included here so that they can be shared between
-**           reference and optimized code.
-******************************************************************/
-
-/* tweak word tweak[1]: bit field starting positions */
-#define SKEIN_T1_BIT(BIT)       ((BIT) - 64)      /* second word  */
-
-#define SKEIN_T1_POS_TREE_LVL   SKEIN_T1_BIT(112) /* 112..118 hash tree level */
-#define SKEIN_T1_POS_BIT_PAD    SKEIN_T1_BIT(119) /* 119 part. final in byte */
-#define SKEIN_T1_POS_BLK_TYPE   SKEIN_T1_BIT(120) /* 120..125 type field `*/
-#define SKEIN_T1_POS_FIRST      SKEIN_T1_BIT(126) /* 126      first blk flag */
-#define SKEIN_T1_POS_FINAL      SKEIN_T1_BIT(127) /* 127      final blk flag */
-
-/* tweak word tweak[1]: flag bit definition(s) */
-#define SKEIN_T1_FLAG_FIRST     (((u64)  1) << SKEIN_T1_POS_FIRST)
-#define SKEIN_T1_FLAG_FINAL     (((u64)  1) << SKEIN_T1_POS_FINAL)
-#define SKEIN_T1_FLAG_BIT_PAD   (((u64)  1) << SKEIN_T1_POS_BIT_PAD)
-
-/* tweak word tweak[1]: tree level bit field mask */
-#define SKEIN_T1_TREE_LVL_MASK  (((u64)0x7F) << SKEIN_T1_POS_TREE_LVL)
-#define SKEIN_T1_TREE_LEVEL(n)  (((u64) (n)) << SKEIN_T1_POS_TREE_LVL)
-
-/* tweak word tweak[1]: block type field */
-#define SKEIN_BLK_TYPE_KEY       (0) /* key, for MAC and KDF */
-#define SKEIN_BLK_TYPE_CFG       (4) /* configuration block */
-#define SKEIN_BLK_TYPE_PERS      (8) /* personalization string */
-#define SKEIN_BLK_TYPE_PK       (12) /* pubkey (for digital sigs) */
-#define SKEIN_BLK_TYPE_KDF      (16) /* key identifier for KDF */
-#define SKEIN_BLK_TYPE_NONCE    (20) /* nonce for PRNG */
-#define SKEIN_BLK_TYPE_MSG      (48) /* message processing */
-#define SKEIN_BLK_TYPE_OUT      (63) /* output stage */
-#define SKEIN_BLK_TYPE_MASK     (63) /* bit field mask */
-
-#define SKEIN_T1_BLK_TYPE(T)   (((u64) (SKEIN_BLK_TYPE_##T)) << \
-                                       SKEIN_T1_POS_BLK_TYPE)
-#define SKEIN_T1_BLK_TYPE_KEY   SKEIN_T1_BLK_TYPE(KEY)  /* for MAC and KDF */
-#define SKEIN_T1_BLK_TYPE_CFG   SKEIN_T1_BLK_TYPE(CFG)  /* config block */
-#define SKEIN_T1_BLK_TYPE_PERS  SKEIN_T1_BLK_TYPE(PERS) /* personalization */
-#define SKEIN_T1_BLK_TYPE_PK    SKEIN_T1_BLK_TYPE(PK)   /* pubkey (for sigs) */
-#define SKEIN_T1_BLK_TYPE_KDF   SKEIN_T1_BLK_TYPE(KDF)  /* key ident for KDF */
-#define SKEIN_T1_BLK_TYPE_NONCE SKEIN_T1_BLK_TYPE(NONCE)/* nonce for PRNG */
-#define SKEIN_T1_BLK_TYPE_MSG   SKEIN_T1_BLK_TYPE(MSG)  /* message processing */
-#define SKEIN_T1_BLK_TYPE_OUT   SKEIN_T1_BLK_TYPE(OUT)  /* output stage */
-#define SKEIN_T1_BLK_TYPE_MASK  SKEIN_T1_BLK_TYPE(MASK) /* field bit mask */
-
-#define SKEIN_T1_BLK_TYPE_CFG_FINAL    (SKEIN_T1_BLK_TYPE_CFG | \
-                                       SKEIN_T1_FLAG_FINAL)
-#define SKEIN_T1_BLK_TYPE_OUT_FINAL    (SKEIN_T1_BLK_TYPE_OUT | \
-                                       SKEIN_T1_FLAG_FINAL)
-
-#define SKEIN_VERSION           (1)
-
-#ifndef SKEIN_ID_STRING_LE      /* allow compile-time personalization */
-#define SKEIN_ID_STRING_LE      (0x33414853) /* "SHA3" (little-endian)*/
-#endif
-
-#define SKEIN_MK_64(hi32, lo32)  ((lo32) + (((u64) (hi32)) << 32))
-#define SKEIN_SCHEMA_VER        SKEIN_MK_64(SKEIN_VERSION, SKEIN_ID_STRING_LE)
-#define SKEIN_KS_PARITY         SKEIN_MK_64(0x1BD11BDA, 0xA9FC1A22)
-
-#define SKEIN_CFG_STR_LEN       (4*8)
-
-/* bit field definitions in config block tree_info word */
-#define SKEIN_CFG_TREE_LEAF_SIZE_POS  (0)
-#define SKEIN_CFG_TREE_NODE_SIZE_POS  (8)
-#define SKEIN_CFG_TREE_MAX_LEVEL_POS  (16)
-
-#define SKEIN_CFG_TREE_LEAF_SIZE_MSK (((u64)0xFF) << \
-                                       SKEIN_CFG_TREE_LEAF_SIZE_POS)
-#define SKEIN_CFG_TREE_NODE_SIZE_MSK (((u64)0xFF) << \
-                                       SKEIN_CFG_TREE_NODE_SIZE_POS)
-#define SKEIN_CFG_TREE_MAX_LEVEL_MSK (((u64)0xFF) << \
-                                       SKEIN_CFG_TREE_MAX_LEVEL_POS)
-
-#define SKEIN_CFG_TREE_INFO(leaf, node, max_lvl)                   \
-       ((((u64)(leaf))   << SKEIN_CFG_TREE_LEAF_SIZE_POS) |    \
-        (((u64)(node))   << SKEIN_CFG_TREE_NODE_SIZE_POS) |    \
-        (((u64)(max_lvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS))
-
-/* use as tree_info in InitExt() call for sequential processing */
-#define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0, 0, 0)
-
-/*
-**   Skein macros for getting/setting tweak words, etc.
-**   These are useful for partial input bytes, hash tree init/update, etc.
-**/
-#define skein_get_tweak(ctx_ptr, TWK_NUM)          ((ctx_ptr)->h.tweak[TWK_NUM])
-#define skein_set_tweak(ctx_ptr, TWK_NUM, t_val) { \
-               (ctx_ptr)->h.tweak[TWK_NUM] = (t_val); \
-       }
-
-#define skein_get_T0(ctx_ptr)     skein_get_tweak(ctx_ptr, 0)
-#define skein_get_T1(ctx_ptr)     skein_get_tweak(ctx_ptr, 1)
-#define skein_set_T0(ctx_ptr, T0) skein_set_tweak(ctx_ptr, 0, T0)
-#define skein_set_T1(ctx_ptr, T1) skein_set_tweak(ctx_ptr, 1, T1)
-
-/* set both tweak words at once */
-#define skein_set_T0_T1(ctx_ptr, T0, T1)           \
-       {                                          \
-       skein_set_T0(ctx_ptr, (T0));               \
-       skein_set_T1(ctx_ptr, (T1));               \
-       }
-
-#define skein_set_type(ctx_ptr, BLK_TYPE)         \
-       skein_set_T1(ctx_ptr, SKEIN_T1_BLK_TYPE_##BLK_TYPE)
-
-/*
- * setup for starting with a new type:
- * h.tweak[0]=0; h.tweak[1] = NEW_TYPE; h.b_cnt=0;
- */
-#define skein_start_new_type(ctx_ptr, BLK_TYPE) { \
-               skein_set_T0_T1(ctx_ptr, 0, SKEIN_T1_FLAG_FIRST | \
-                               SKEIN_T1_BLK_TYPE_##BLK_TYPE); \
-               (ctx_ptr)->h.b_cnt = 0; \
-       }
-
-#define skein_clear_first_flag(hdr) { \
-               (hdr).tweak[1] &= ~SKEIN_T1_FLAG_FIRST; \
-       }
-#define skein_set_bit_pad_flag(hdr) { \
-               (hdr).tweak[1] |=  SKEIN_T1_FLAG_BIT_PAD; \
-       }
-
-#define skein_set_tree_level(hdr, height) { \
-               (hdr).tweak[1] |= SKEIN_T1_TREE_LEVEL(height); \
-       }
-
-/*****************************************************************
-** "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, blk_ptr, w_ptr, ks_event_ptr, ks_odd_ptr)
-#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, out_ptr)
-#define skein_show_key(bits, ctx, key, key_bytes)
-#endif
-
-/* ignore all asserts, for performance */
-#define skein_assert_ret(x, ret_code)
-#define skein_assert(x)
-
-/*****************************************************************
-** Skein block function constants (shared across Ref and Opt code)
-******************************************************************/
-enum {
-           /* SKEIN_256 round rotation constants */
-       R_256_0_0 = 14, R_256_0_1 = 16,
-       R_256_1_0 = 52, R_256_1_1 = 57,
-       R_256_2_0 = 23, R_256_2_1 = 40,
-       R_256_3_0 =  5, R_256_3_1 = 37,
-       R_256_4_0 = 25, R_256_4_1 = 33,
-       R_256_5_0 = 46, R_256_5_1 = 12,
-       R_256_6_0 = 58, R_256_6_1 = 22,
-       R_256_7_0 = 32, R_256_7_1 = 32,
-
-           /* SKEIN_512 round rotation constants */
-       R_512_0_0 = 46, R_512_0_1 = 36, R_512_0_2 = 19, R_512_0_3 = 37,
-       R_512_1_0 = 33, R_512_1_1 = 27, R_512_1_2 = 14, R_512_1_3 = 42,
-       R_512_2_0 = 17, R_512_2_1 = 49, R_512_2_2 = 36, R_512_2_3 = 39,
-       R_512_3_0 = 44, R_512_3_1 =  9, R_512_3_2 = 54, R_512_3_3 = 56,
-       R_512_4_0 = 39, R_512_4_1 = 30, R_512_4_2 = 34, R_512_4_3 = 24,
-       R_512_5_0 = 13, R_512_5_1 = 50, R_512_5_2 = 10, R_512_5_3 = 17,
-       R_512_6_0 = 25, R_512_6_1 = 29, R_512_6_2 = 39, R_512_6_3 = 43,
-       R_512_7_0 =  8, R_512_7_1 = 35, R_512_7_2 = 56, R_512_7_3 = 22,
-
-           /* SKEIN_1024 round rotation constants */
-       R1024_0_0 = 24, R1024_0_1 = 13, R1024_0_2 =  8, R1024_0_3 = 47,
-       R1024_0_4 =  8, R1024_0_5 = 17, R1024_0_6 = 22, R1024_0_7 = 37,
-       R1024_1_0 = 38, R1024_1_1 = 19, R1024_1_2 = 10, R1024_1_3 = 55,
-       R1024_1_4 = 49, R1024_1_5 = 18, R1024_1_6 = 23, R1024_1_7 = 52,
-       R1024_2_0 = 33, R1024_2_1 =  4, R1024_2_2 = 51, R1024_2_3 = 13,
-       R1024_2_4 = 34, R1024_2_5 = 41, R1024_2_6 = 59, R1024_2_7 = 17,
-       R1024_3_0 =  5, R1024_3_1 = 20, R1024_3_2 = 48, R1024_3_3 = 41,
-       R1024_3_4 = 47, R1024_3_5 = 28, R1024_3_6 = 16, R1024_3_7 = 25,
-       R1024_4_0 = 41, R1024_4_1 =  9, R1024_4_2 = 37, R1024_4_3 = 31,
-       R1024_4_4 = 12, R1024_4_5 = 47, R1024_4_6 = 44, R1024_4_7 = 30,
-       R1024_5_0 = 16, R1024_5_1 = 34, R1024_5_2 = 56, R1024_5_3 = 51,
-       R1024_5_4 =  4, R1024_5_5 = 53, R1024_5_6 = 42, R1024_5_7 = 41,
-       R1024_6_0 = 31, R1024_6_1 = 44, R1024_6_2 = 47, R1024_6_3 = 46,
-       R1024_6_4 = 19, R1024_6_5 = 42, R1024_6_6 = 44, R1024_6_7 = 25,
-       R1024_7_0 =  9, R1024_7_1 = 48, R1024_7_2 = 35, R1024_7_3 = 52,
-       R1024_7_4 = 23, R1024_7_5 = 31, R1024_7_6 = 37, R1024_7_7 = 20
-};
-
-#ifndef SKEIN_ROUNDS
-#define SKEIN_256_ROUNDS_TOTAL (72)    /* # rounds for diff block sizes */
-#define SKEIN_512_ROUNDS_TOTAL (72)
-#define SKEIN_1024_ROUNDS_TOTAL (80)
-#else                  /* allow command-line define in range 8*(5..14)   */
-#define SKEIN_256_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/100) + 5) % 10) + 5))
-#define SKEIN_512_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/10)  + 5) % 10) + 5))
-#define SKEIN_1024_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS)     + 5) % 10) + 5))
-#endif
-
-#endif  /* ifndef _SKEIN_H_ */
index 6e700ee..5bfce07 100644 (file)
@@ -31,7 +31,7 @@ int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size)
 {
        skein_assert_ret(ctx && size, SKEIN_FAIL);
 
-       memset(ctx , 0, sizeof(struct skein_ctx));
+       memset(ctx, 0, sizeof(struct skein_ctx));
        ctx->skein_size = size;
 
        return SKEIN_SUCCESS;
index e02fa19..171b875 100644 (file)
@@ -79,7 +79,7 @@ OTHER DEALINGS IN THE SOFTWARE.
  */
 
 #include <linux/types.h>
-#include "skein.h"
+#include "skein_base.h"
 
 /**
  * Which Skein size to use
diff --git a/drivers/staging/skein/skein_base.c b/drivers/staging/skein/skein_base.c
new file mode 100644 (file)
index 0000000..7e700a6
--- /dev/null
@@ -0,0 +1,864 @@
+/***********************************************************************
+**
+** Implementation of the Skein hash function.
+**
+** Source code author: Doug Whiting, 2008.
+**
+** This algorithm and source code is released to the public domain.
+**
+************************************************************************/
+
+#include <linux/string.h>       /* get the memcpy/memset functions */
+#include <linux/export.h>
+#include "skein_base.h" /* get the Skein API definitions   */
+#include "skein_iv.h"    /* get precomputed IVs */
+#include "skein_block.h"
+
+/*****************************************************************/
+/*     256-bit Skein                                             */
+/*****************************************************************/
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* init the context for a straight hashing operation  */
+int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len)
+{
+       union {
+               u8 b[SKEIN_256_STATE_BYTES];
+               u64 w[SKEIN_256_STATE_WORDS];
+       } cfg;                              /* config block */
+
+       skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
+       ctx->h.hash_bit_len = hash_bit_len;         /* output hash bit count */
+
+       switch (hash_bit_len) { /* use pre-computed values, where available */
+       case  256:
+               memcpy(ctx->x, SKEIN_256_IV_256, sizeof(ctx->x));
+               break;
+       case  224:
+               memcpy(ctx->x, SKEIN_256_IV_224, sizeof(ctx->x));
+               break;
+       case  160:
+               memcpy(ctx->x, SKEIN_256_IV_160, sizeof(ctx->x));
+               break;
+       case  128:
+               memcpy(ctx->x, SKEIN_256_IV_128, sizeof(ctx->x));
+               break;
+       default:
+               /* here if there is no precomputed IV value available */
+               /*
+                * build/process the config block, type == CONFIG (could be
+                * precomputed)
+                */
+               /* set tweaks: T0=0; T1=CFG | FINAL */
+               skein_start_new_type(ctx, CFG_FINAL);
+
+               /* set the schema, version */
+               cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
+               /* hash result length in bits */
+               cfg.w[1] = skein_swap64(hash_bit_len);
+               cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
+               /* zero pad config block */
+               memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0]));
+
+               /* compute the initial chaining values from config block */
+               /* zero the chaining variables */
+               memset(ctx->x, 0, sizeof(ctx->x));
+               skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
+               break;
+       }
+       /* The chaining vars ctx->x are now initialized for hash_bit_len. */
+       /* Set up to process the data message portion of the hash (default) */
+       skein_start_new_type(ctx, MSG);              /* T0=0, T1= MSG type */
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* init the context for a MAC and/or tree hash operation */
+/* [identical to skein_256_init() when key_bytes == 0 && \
+ *     tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
+int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len,
+                      u64 tree_info, const u8 *key, size_t key_bytes)
+{
+       union {
+               u8  b[SKEIN_256_STATE_BYTES];
+               u64 w[SKEIN_256_STATE_WORDS];
+       } cfg; /* config block */
+
+       skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
+       skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL);
+
+       /* compute the initial chaining values ctx->x[], based on key */
+       if (key_bytes == 0) { /* is there a key? */
+               /* no key: use all zeroes as key for config block */
+               memset(ctx->x, 0, sizeof(ctx->x));
+       } else { /* here to pre-process a key */
+               skein_assert(sizeof(cfg.b) >= sizeof(ctx->x));
+               /* do a mini-Init right here */
+               /* set output hash bit count = state size */
+               ctx->h.hash_bit_len = 8*sizeof(ctx->x);
+               /* set tweaks: T0 = 0; T1 = KEY type */
+               skein_start_new_type(ctx, KEY);
+               /* zero the initial chaining variables */
+               memset(ctx->x, 0, sizeof(ctx->x));
+               /* hash the key */
+               skein_256_update(ctx, key, key_bytes);
+               /* put result into cfg.b[] */
+               skein_256_final_pad(ctx, cfg.b);
+               /* copy over into ctx->x[] */
+               memcpy(ctx->x, cfg.b, sizeof(cfg.b));
+       }
+       /*
+        * build/process the config block, type == CONFIG (could be
+        * precomputed for each key)
+        */
+       /* output hash bit count */
+       ctx->h.hash_bit_len = hash_bit_len;
+       skein_start_new_type(ctx, CFG_FINAL);
+
+       /* pre-pad cfg.w[] with zeroes */
+       memset(&cfg.w, 0, sizeof(cfg.w));
+       cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
+       /* hash result length in bits */
+       cfg.w[1] = skein_swap64(hash_bit_len);
+       /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
+       cfg.w[2] = skein_swap64(tree_info);
+
+       /* compute the initial chaining values from config block */
+       skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
+
+       /* The chaining vars ctx->x are now initialized */
+       /* Set up to process the data message portion of the hash (default) */
+       skein_start_new_type(ctx, MSG);
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* process the input bytes */
+int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg,
+                    size_t msg_byte_cnt)
+{
+       size_t n;
+
+       /* catch uninitialized context */
+       skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* process full blocks, if any */
+       if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_256_BLOCK_BYTES) {
+               /* finish up any buffered message data */
+               if (ctx->h.b_cnt) {
+                       /* # bytes free in buffer b[] */
+                       n = SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt;
+                       if (n) {
+                               /* check on our logic here */
+                               skein_assert(n < msg_byte_cnt);
+                               memcpy(&ctx->b[ctx->h.b_cnt], msg, n);
+                               msg_byte_cnt  -= n;
+                               msg         += n;
+                               ctx->h.b_cnt += n;
+                       }
+                       skein_assert(ctx->h.b_cnt == SKEIN_256_BLOCK_BYTES);
+                       skein_256_process_block(ctx, ctx->b, 1,
+                                               SKEIN_256_BLOCK_BYTES);
+                       ctx->h.b_cnt = 0;
+               }
+               /*
+                * now process any remaining full blocks, directly from input
+                * message data
+                */
+               if (msg_byte_cnt > SKEIN_256_BLOCK_BYTES) {
+                       /* number of full blocks to process */
+                       n = (msg_byte_cnt-1) / SKEIN_256_BLOCK_BYTES;
+                       skein_256_process_block(ctx, msg, n,
+                                               SKEIN_256_BLOCK_BYTES);
+                       msg_byte_cnt -= n * SKEIN_256_BLOCK_BYTES;
+                       msg        += n * SKEIN_256_BLOCK_BYTES;
+               }
+               skein_assert(ctx->h.b_cnt == 0);
+       }
+
+       /* copy any remaining source message data bytes into b[] */
+       if (msg_byte_cnt) {
+               skein_assert(msg_byte_cnt + ctx->h.b_cnt <=
+                            SKEIN_256_BLOCK_BYTES);
+               memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt);
+               ctx->h.b_cnt += msg_byte_cnt;
+       }
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* finalize the hash computation and output the result */
+int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val)
+{
+       size_t i, n, byte_cnt;
+       u64 x[SKEIN_256_STATE_WORDS];
+       /* catch uninitialized context */
+       skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* tag as the final block */
+       ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL;
+       /* zero pad b[] if necessary */
+       if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES)
+               memset(&ctx->b[ctx->h.b_cnt], 0,
+                       SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt);
+
+       /* process the final block */
+       skein_256_process_block(ctx, ctx->b, 1, ctx->h.b_cnt);
+
+       /* now output the result */
+       /* total number of output bytes */
+       byte_cnt = (ctx->h.hash_bit_len + 7) >> 3;
+
+       /* run Threefish in "counter mode" to generate output */
+       /* zero out b[], so it can hold the counter */
+       memset(ctx->b, 0, sizeof(ctx->b));
+       /* keep a local copy of counter mode "key" */
+       memcpy(x, ctx->x, sizeof(x));
+       for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) {
+               /* build the counter block */
+               ((u64 *)ctx->b)[0] = skein_swap64((u64) i);
+               skein_start_new_type(ctx, OUT_FINAL);
+               /* run "counter mode" */
+               skein_256_process_block(ctx, ctx->b, 1, sizeof(u64));
+               /* number of output bytes left to go */
+               n = byte_cnt - i*SKEIN_256_BLOCK_BYTES;
+               if (n >= SKEIN_256_BLOCK_BYTES)
+                       n  = SKEIN_256_BLOCK_BYTES;
+               /* "output" the ctr mode bytes */
+               skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x,
+                                     n);
+               /* restore the counter mode key for next time */
+               memcpy(ctx->x, x, sizeof(x));
+       }
+       return SKEIN_SUCCESS;
+}
+
+/*****************************************************************/
+/*     512-bit Skein                                             */
+/*****************************************************************/
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* init the context for a straight hashing operation  */
+int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len)
+{
+       union {
+               u8 b[SKEIN_512_STATE_BYTES];
+               u64 w[SKEIN_512_STATE_WORDS];
+       } cfg;                              /* config block */
+
+       skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
+       ctx->h.hash_bit_len = hash_bit_len;         /* output hash bit count */
+
+       switch (hash_bit_len) { /* use pre-computed values, where available */
+       case  512:
+               memcpy(ctx->x, SKEIN_512_IV_512, sizeof(ctx->x));
+               break;
+       case  384:
+               memcpy(ctx->x, SKEIN_512_IV_384, sizeof(ctx->x));
+               break;
+       case  256:
+               memcpy(ctx->x, SKEIN_512_IV_256, sizeof(ctx->x));
+               break;
+       case  224:
+               memcpy(ctx->x, SKEIN_512_IV_224, sizeof(ctx->x));
+               break;
+       default:
+               /* here if there is no precomputed IV value available */
+               /*
+                * build/process the config block, type == CONFIG (could be
+                * precomputed)
+                */
+               /* set tweaks: T0=0; T1=CFG | FINAL */
+               skein_start_new_type(ctx, CFG_FINAL);
+
+               /* set the schema, version */
+               cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
+               /* hash result length in bits */
+               cfg.w[1] = skein_swap64(hash_bit_len);
+               cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
+               /* zero pad config block */
+               memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0]));
+
+               /* compute the initial chaining values from config block */
+               /* zero the chaining variables */
+               memset(ctx->x, 0, sizeof(ctx->x));
+               skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
+               break;
+       }
+
+       /*
+        * The chaining vars ctx->x are now initialized for the given
+        * hash_bit_len.
+        */
+       /* Set up to process the data message portion of the hash (default) */
+       skein_start_new_type(ctx, MSG);              /* T0=0, T1= MSG type */
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* init the context for a MAC and/or tree hash operation */
+/* [identical to skein_512_init() when key_bytes == 0 && \
+ *     tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
+int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len,
+                      u64 tree_info, const u8 *key, size_t key_bytes)
+{
+       union {
+               u8 b[SKEIN_512_STATE_BYTES];
+               u64 w[SKEIN_512_STATE_WORDS];
+       } cfg;                              /* config block */
+
+       skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
+       skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL);
+
+       /* compute the initial chaining values ctx->x[], based on key */
+       if (key_bytes == 0) { /* is there a key? */
+               /* no key: use all zeroes as key for config block */
+               memset(ctx->x, 0, sizeof(ctx->x));
+       } else { /* here to pre-process a key */
+               skein_assert(sizeof(cfg.b) >= sizeof(ctx->x));
+               /* do a mini-Init right here */
+               /* set output hash bit count = state size */
+               ctx->h.hash_bit_len = 8*sizeof(ctx->x);
+               /* set tweaks: T0 = 0; T1 = KEY type */
+               skein_start_new_type(ctx, KEY);
+               /* zero the initial chaining variables */
+               memset(ctx->x, 0, sizeof(ctx->x));
+               /* hash the key */
+               skein_512_update(ctx, key, key_bytes);
+               /* put result into cfg.b[] */
+               skein_512_final_pad(ctx, cfg.b);
+               /* copy over into ctx->x[] */
+               memcpy(ctx->x, cfg.b, sizeof(cfg.b));
+       }
+       /*
+        * build/process the config block, type == CONFIG (could be
+        * precomputed for each key)
+        */
+       ctx->h.hash_bit_len = hash_bit_len;          /* output hash bit count */
+       skein_start_new_type(ctx, CFG_FINAL);
+
+       /* pre-pad cfg.w[] with zeroes */
+       memset(&cfg.w, 0, sizeof(cfg.w));
+       cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
+       /* hash result length in bits */
+       cfg.w[1] = skein_swap64(hash_bit_len);
+       /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
+       cfg.w[2] = skein_swap64(tree_info);
+
+       /* compute the initial chaining values from config block */
+       skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
+
+       /* The chaining vars ctx->x are now initialized */
+       /* Set up to process the data message portion of the hash (default) */
+       skein_start_new_type(ctx, MSG);
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* process the input bytes */
+int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg,
+                    size_t msg_byte_cnt)
+{
+       size_t n;
+
+       /* catch uninitialized context */
+       skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* process full blocks, if any */
+       if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_512_BLOCK_BYTES) {
+               /* finish up any buffered message data */
+               if (ctx->h.b_cnt) {
+                       /* # bytes free in buffer b[] */
+                       n = SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt;
+                       if (n) {
+                               /* check on our logic here */
+                               skein_assert(n < msg_byte_cnt);
+                               memcpy(&ctx->b[ctx->h.b_cnt], msg, n);
+                               msg_byte_cnt  -= n;
+                               msg         += n;
+                               ctx->h.b_cnt += n;
+                       }
+                       skein_assert(ctx->h.b_cnt == SKEIN_512_BLOCK_BYTES);
+                       skein_512_process_block(ctx, ctx->b, 1,
+                                               SKEIN_512_BLOCK_BYTES);
+                       ctx->h.b_cnt = 0;
+               }
+               /*
+                * now process any remaining full blocks, directly from input
+                * message data
+                */
+               if (msg_byte_cnt > SKEIN_512_BLOCK_BYTES) {
+                       /* number of full blocks to process */
+                       n = (msg_byte_cnt-1) / SKEIN_512_BLOCK_BYTES;
+                       skein_512_process_block(ctx, msg, n,
+                                               SKEIN_512_BLOCK_BYTES);
+                       msg_byte_cnt -= n * SKEIN_512_BLOCK_BYTES;
+                       msg        += n * SKEIN_512_BLOCK_BYTES;
+               }
+               skein_assert(ctx->h.b_cnt == 0);
+       }
+
+       /* copy any remaining source message data bytes into b[] */
+       if (msg_byte_cnt) {
+               skein_assert(msg_byte_cnt + ctx->h.b_cnt <=
+                            SKEIN_512_BLOCK_BYTES);
+               memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt);
+               ctx->h.b_cnt += msg_byte_cnt;
+       }
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* finalize the hash computation and output the result */
+int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val)
+{
+       size_t i, n, byte_cnt;
+       u64 x[SKEIN_512_STATE_WORDS];
+       /* catch uninitialized context */
+       skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* tag as the final block */
+       ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL;
+       /* zero pad b[] if necessary */
+       if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES)
+               memset(&ctx->b[ctx->h.b_cnt], 0,
+                       SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt);
+
+       /* process the final block */
+       skein_512_process_block(ctx, ctx->b, 1, ctx->h.b_cnt);
+
+       /* now output the result */
+       /* total number of output bytes */
+       byte_cnt = (ctx->h.hash_bit_len + 7) >> 3;
+
+       /* run Threefish in "counter mode" to generate output */
+       /* zero out b[], so it can hold the counter */
+       memset(ctx->b, 0, sizeof(ctx->b));
+       /* keep a local copy of counter mode "key" */
+       memcpy(x, ctx->x, sizeof(x));
+       for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) {
+               /* build the counter block */
+               ((u64 *)ctx->b)[0] = skein_swap64((u64) i);
+               skein_start_new_type(ctx, OUT_FINAL);
+               /* run "counter mode" */
+               skein_512_process_block(ctx, ctx->b, 1, sizeof(u64));
+               /* number of output bytes left to go */
+               n = byte_cnt - i*SKEIN_512_BLOCK_BYTES;
+               if (n >= SKEIN_512_BLOCK_BYTES)
+                       n  = SKEIN_512_BLOCK_BYTES;
+               /* "output" the ctr mode bytes */
+               skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x,
+                                     n);
+               /* restore the counter mode key for next time */
+               memcpy(ctx->x, x, sizeof(x));
+       }
+       return SKEIN_SUCCESS;
+}
+
+/*****************************************************************/
+/*    1024-bit Skein                                             */
+/*****************************************************************/
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* init the context for a straight hashing operation  */
+int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len)
+{
+       union {
+               u8 b[SKEIN_1024_STATE_BYTES];
+               u64 w[SKEIN_1024_STATE_WORDS];
+       } cfg;                              /* config block */
+
+       skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
+       ctx->h.hash_bit_len = hash_bit_len;         /* output hash bit count */
+
+       switch (hash_bit_len) { /* use pre-computed values, where available */
+       case  512:
+               memcpy(ctx->x, SKEIN_1024_IV_512, sizeof(ctx->x));
+               break;
+       case  384:
+               memcpy(ctx->x, SKEIN_1024_IV_384, sizeof(ctx->x));
+               break;
+       case 1024:
+               memcpy(ctx->x, SKEIN_1024_IV_1024, sizeof(ctx->x));
+               break;
+       default:
+               /* here if there is no precomputed IV value available */
+               /*
+                * build/process the config block, type == CONFIG
+                * (could be precomputed)
+                */
+               /* set tweaks: T0=0; T1=CFG | FINAL */
+               skein_start_new_type(ctx, CFG_FINAL);
+
+               /* set the schema, version */
+               cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
+               /* hash result length in bits */
+               cfg.w[1] = skein_swap64(hash_bit_len);
+               cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
+               /* zero pad config block */
+               memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0]));
+
+               /* compute the initial chaining values from config block */
+               /* zero the chaining variables */
+               memset(ctx->x, 0, sizeof(ctx->x));
+               skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
+               break;
+       }
+
+       /* The chaining vars ctx->x are now initialized for the hash_bit_len. */
+       /* Set up to process the data message portion of the hash (default) */
+       skein_start_new_type(ctx, MSG);              /* T0=0, T1= MSG type */
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* init the context for a MAC and/or tree hash operation */
+/* [identical to skein_1024_init() when key_bytes == 0 && \
+ *     tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
+int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len,
+                       u64 tree_info, const u8 *key, size_t key_bytes)
+{
+       union {
+               u8 b[SKEIN_1024_STATE_BYTES];
+               u64 w[SKEIN_1024_STATE_WORDS];
+       } cfg;                              /* config block */
+
+       skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
+       skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL);
+
+       /* compute the initial chaining values ctx->x[], based on key */
+       if (key_bytes == 0) { /* is there a key? */
+               /* no key: use all zeroes as key for config block */
+               memset(ctx->x, 0, sizeof(ctx->x));
+       } else { /* here to pre-process a key */
+               skein_assert(sizeof(cfg.b) >= sizeof(ctx->x));
+               /* do a mini-Init right here */
+               /* set output hash bit count = state size */
+               ctx->h.hash_bit_len = 8*sizeof(ctx->x);
+               /* set tweaks: T0 = 0; T1 = KEY type */
+               skein_start_new_type(ctx, KEY);
+               /* zero the initial chaining variables */
+               memset(ctx->x, 0, sizeof(ctx->x));
+               /* hash the key */
+               skein_1024_update(ctx, key, key_bytes);
+               /* put result into cfg.b[] */
+               skein_1024_final_pad(ctx, cfg.b);
+               /* copy over into ctx->x[] */
+               memcpy(ctx->x, cfg.b, sizeof(cfg.b));
+       }
+       /*
+        * build/process the config block, type == CONFIG (could be
+        * precomputed for each key)
+        */
+       /* output hash bit count */
+       ctx->h.hash_bit_len = hash_bit_len;
+       skein_start_new_type(ctx, CFG_FINAL);
+
+       /* pre-pad cfg.w[] with zeroes */
+       memset(&cfg.w, 0, sizeof(cfg.w));
+       cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
+       /* hash result length in bits */
+       cfg.w[1] = skein_swap64(hash_bit_len);
+       /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
+       cfg.w[2] = skein_swap64(tree_info);
+
+       /* compute the initial chaining values from config block */
+       skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
+
+       /* The chaining vars ctx->x are now initialized */
+       /* Set up to process the data message portion of the hash (default) */
+       skein_start_new_type(ctx, MSG);
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* process the input bytes */
+int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg,
+                     size_t msg_byte_cnt)
+{
+       size_t n;
+
+       /* catch uninitialized context */
+       skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* process full blocks, if any */
+       if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_1024_BLOCK_BYTES) {
+               /* finish up any buffered message data */
+               if (ctx->h.b_cnt) {
+                       /* # bytes free in buffer b[] */
+                       n = SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt;
+                       if (n) {
+                               /* check on our logic here */
+                               skein_assert(n < msg_byte_cnt);
+                               memcpy(&ctx->b[ctx->h.b_cnt], msg, n);
+                               msg_byte_cnt  -= n;
+                               msg         += n;
+                               ctx->h.b_cnt += n;
+                       }
+                       skein_assert(ctx->h.b_cnt == SKEIN_1024_BLOCK_BYTES);
+                       skein_1024_process_block(ctx, ctx->b, 1,
+                                                SKEIN_1024_BLOCK_BYTES);
+                       ctx->h.b_cnt = 0;
+               }
+               /*
+                * now process any remaining full blocks, directly from input
+                * message data
+                */
+               if (msg_byte_cnt > SKEIN_1024_BLOCK_BYTES) {
+                       /* number of full blocks to process */
+                       n = (msg_byte_cnt-1) / SKEIN_1024_BLOCK_BYTES;
+                       skein_1024_process_block(ctx, msg, n,
+                                                SKEIN_1024_BLOCK_BYTES);
+                       msg_byte_cnt -= n * SKEIN_1024_BLOCK_BYTES;
+                       msg        += n * SKEIN_1024_BLOCK_BYTES;
+               }
+               skein_assert(ctx->h.b_cnt == 0);
+       }
+
+       /* copy any remaining source message data bytes into b[] */
+       if (msg_byte_cnt) {
+               skein_assert(msg_byte_cnt + ctx->h.b_cnt <=
+                            SKEIN_1024_BLOCK_BYTES);
+               memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt);
+               ctx->h.b_cnt += msg_byte_cnt;
+       }
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* finalize the hash computation and output the result */
+int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val)
+{
+       size_t i, n, byte_cnt;
+       u64 x[SKEIN_1024_STATE_WORDS];
+       /* catch uninitialized context */
+       skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* tag as the final block */
+       ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL;
+       /* zero pad b[] if necessary */
+       if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES)
+               memset(&ctx->b[ctx->h.b_cnt], 0,
+                       SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt);
+
+       /* process the final block */
+       skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt);
+
+       /* now output the result */
+       /* total number of output bytes */
+       byte_cnt = (ctx->h.hash_bit_len + 7) >> 3;
+
+       /* run Threefish in "counter mode" to generate output */
+       /* zero out b[], so it can hold the counter */
+       memset(ctx->b, 0, sizeof(ctx->b));
+       /* keep a local copy of counter mode "key" */
+       memcpy(x, ctx->x, sizeof(x));
+       for (i = 0; i*SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) {
+               /* build the counter block */
+               ((u64 *)ctx->b)[0] = skein_swap64((u64) i);
+               skein_start_new_type(ctx, OUT_FINAL);
+               /* run "counter mode" */
+               skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64));
+               /* number of output bytes left to go */
+               n = byte_cnt - i*SKEIN_1024_BLOCK_BYTES;
+               if (n >= SKEIN_1024_BLOCK_BYTES)
+                       n  = SKEIN_1024_BLOCK_BYTES;
+               /* "output" the ctr mode bytes */
+               skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x,
+                                     n);
+               /* restore the counter mode key for next time */
+               memcpy(ctx->x, x, sizeof(x));
+       }
+       return SKEIN_SUCCESS;
+}
+
+/**************** Functions to support MAC/tree hashing ***************/
+/*   (this code is identical for Optimized and Reference versions)    */
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* finalize the hash computation and output the block, no OUTPUT stage */
+int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val)
+{
+       /* catch uninitialized context */
+       skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* tag as the final block */
+       ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL;
+       /* zero pad b[] if necessary */
+       if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES)
+               memset(&ctx->b[ctx->h.b_cnt], 0,
+                       SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt);
+       /* process the final block */
+       skein_256_process_block(ctx, ctx->b, 1, ctx->h.b_cnt);
+
+       /* "output" the state bytes */
+       skein_put64_lsb_first(hash_val, ctx->x, SKEIN_256_BLOCK_BYTES);
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* finalize the hash computation and output the block, no OUTPUT stage */
+int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val)
+{
+       /* catch uninitialized context */
+       skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* tag as the final block */
+       ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL;
+       /* zero pad b[] if necessary */
+       if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES)
+               memset(&ctx->b[ctx->h.b_cnt], 0,
+                       SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt);
+       /* process the final block */
+       skein_512_process_block(ctx, ctx->b, 1, ctx->h.b_cnt);
+
+       /* "output" the state bytes */
+       skein_put64_lsb_first(hash_val, ctx->x, SKEIN_512_BLOCK_BYTES);
+
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* finalize the hash computation and output the block, no OUTPUT stage */
+int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val)
+{
+       /* catch uninitialized context */
+       skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* tag as the final block */
+       ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL;
+       /* zero pad b[] if necessary */
+       if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES)
+               memset(&ctx->b[ctx->h.b_cnt], 0,
+                       SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt);
+       /* process the final block */
+       skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt);
+
+       /* "output" the state bytes */
+       skein_put64_lsb_first(hash_val, ctx->x, SKEIN_1024_BLOCK_BYTES);
+
+       return SKEIN_SUCCESS;
+}
+
+#if SKEIN_TREE_HASH
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* just do the OUTPUT stage                                       */
+int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val)
+{
+       size_t i, n, byte_cnt;
+       u64 x[SKEIN_256_STATE_WORDS];
+       /* catch uninitialized context */
+       skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* now output the result */
+       /* total number of output bytes */
+       byte_cnt = (ctx->h.hash_bit_len + 7) >> 3;
+
+       /* run Threefish in "counter mode" to generate output */
+       /* zero out b[], so it can hold the counter */
+       memset(ctx->b, 0, sizeof(ctx->b));
+       /* keep a local copy of counter mode "key" */
+       memcpy(x, ctx->x, sizeof(x));
+       for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) {
+               /* build the counter block */
+               ((u64 *)ctx->b)[0] = skein_swap64((u64) i);
+               skein_start_new_type(ctx, OUT_FINAL);
+               /* run "counter mode" */
+               skein_256_process_block(ctx, ctx->b, 1, sizeof(u64));
+               /* number of output bytes left to go */
+               n = byte_cnt - i*SKEIN_256_BLOCK_BYTES;
+               if (n >= SKEIN_256_BLOCK_BYTES)
+                       n  = SKEIN_256_BLOCK_BYTES;
+               /* "output" the ctr mode bytes */
+               skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x,
+                                     n);
+               /* restore the counter mode key for next time */
+               memcpy(ctx->x, x, sizeof(x));
+       }
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* just do the OUTPUT stage                                       */
+int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val)
+{
+       size_t i, n, byte_cnt;
+       u64 x[SKEIN_512_STATE_WORDS];
+       /* catch uninitialized context */
+       skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* now output the result */
+       /* total number of output bytes */
+       byte_cnt = (ctx->h.hash_bit_len + 7) >> 3;
+
+       /* run Threefish in "counter mode" to generate output */
+       /* zero out b[], so it can hold the counter */
+       memset(ctx->b, 0, sizeof(ctx->b));
+       /* keep a local copy of counter mode "key" */
+       memcpy(x, ctx->x, sizeof(x));
+       for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) {
+               /* build the counter block */
+               ((u64 *)ctx->b)[0] = skein_swap64((u64) i);
+               skein_start_new_type(ctx, OUT_FINAL);
+               /* run "counter mode" */
+               skein_512_process_block(ctx, ctx->b, 1, sizeof(u64));
+               /* number of output bytes left to go */
+               n = byte_cnt - i*SKEIN_512_BLOCK_BYTES;
+               if (n >= SKEIN_512_BLOCK_BYTES)
+                       n  = SKEIN_512_BLOCK_BYTES;
+               /* "output" the ctr mode bytes */
+               skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x,
+                                     n);
+               /* restore the counter mode key for next time */
+               memcpy(ctx->x, x, sizeof(x));
+       }
+       return SKEIN_SUCCESS;
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+/* just do the OUTPUT stage                                       */
+int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val)
+{
+       size_t i, n, byte_cnt;
+       u64 x[SKEIN_1024_STATE_WORDS];
+       /* catch uninitialized context */
+       skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL);
+
+       /* now output the result */
+       /* total number of output bytes */
+       byte_cnt = (ctx->h.hash_bit_len + 7) >> 3;
+
+       /* run Threefish in "counter mode" to generate output */
+       /* zero out b[], so it can hold the counter */
+       memset(ctx->b, 0, sizeof(ctx->b));
+       /* keep a local copy of counter mode "key" */
+       memcpy(x, ctx->x, sizeof(x));
+       for (i = 0; i*SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) {
+               /* build the counter block */
+               ((u64 *)ctx->b)[0] = skein_swap64((u64) i);
+               skein_start_new_type(ctx, OUT_FINAL);
+               /* run "counter mode" */
+               skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64));
+               /* number of output bytes left to go */
+               n = byte_cnt - i*SKEIN_1024_BLOCK_BYTES;
+               if (n >= SKEIN_1024_BLOCK_BYTES)
+                       n  = SKEIN_1024_BLOCK_BYTES;
+               /* "output" the ctr mode bytes */
+               skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x,
+                                     n);
+               /* restore the counter mode key for next time */
+               memcpy(ctx->x, x, sizeof(x));
+       }
+       return SKEIN_SUCCESS;
+}
+#endif
diff --git a/drivers/staging/skein/skein_base.h b/drivers/staging/skein/skein_base.h
new file mode 100644 (file)
index 0000000..993b951
--- /dev/null
@@ -0,0 +1,335 @@
+#ifndef _SKEIN_H_
+#define _SKEIN_H_     1
+/**************************************************************************
+**
+** Interface declarations and internal definitions for Skein hashing.
+**
+** Source code author: Doug Whiting, 2008.
+**
+** This algorithm and source code is released to the public domain.
+**
+***************************************************************************
+**
+** The following compile-time switches may be defined to control some
+** tradeoffs between speed, code size, error checking, and security.
+**
+** The "default" note explains what happens when the switch is not defined.
+**
+**  SKEIN_ERR_CHECK        -- how error checking is handled inside Skein
+**                            code. If not defined, most error checking
+**                            is disabled (for performance). Otherwise,
+**                            the switch value is interpreted as:
+**                                0: use assert()      to flag errors
+**                                1: return SKEIN_FAIL to flag errors
+**
+***************************************************************************/
+
+/*Skein digest sizes for crypto api*/
+#define SKEIN256_DIGEST_BIT_SIZE 256
+#define SKEIN512_DIGEST_BIT_SIZE 512
+#define SKEIN1024_DIGEST_BIT_SIZE 1024
+
+/* below two prototype assume we are handed aligned data */
+#define skein_put64_lsb_first(dst08, src64, b_cnt) memcpy(dst08, src64, b_cnt)
+#define skein_get64_lsb_first(dst64, src08, w_cnt) \
+               memcpy(dst64, src08, 8*(w_cnt))
+#define skein_swap64(w64)  (w64)
+
+enum {
+       SKEIN_SUCCESS         =      0, /* return codes from Skein calls */
+       SKEIN_FAIL            =      1,
+       SKEIN_BAD_HASHLEN     =      2
+};
+
+#define  SKEIN_MODIFIER_WORDS   2 /* number of modifier (tweak) words */
+
+#define  SKEIN_256_STATE_WORDS  4
+#define  SKEIN_512_STATE_WORDS  8
+#define  SKEIN_1024_STATE_WORDS 16
+#define  SKEIN_MAX_STATE_WORDS 16
+
+#define  SKEIN_256_STATE_BYTES  (8*SKEIN_256_STATE_WORDS)
+#define  SKEIN_512_STATE_BYTES  (8*SKEIN_512_STATE_WORDS)
+#define  SKEIN_1024_STATE_BYTES  (8*SKEIN_1024_STATE_WORDS)
+
+#define  SKEIN_256_STATE_BITS  (64*SKEIN_256_STATE_WORDS)
+#define  SKEIN_512_STATE_BITS  (64*SKEIN_512_STATE_WORDS)
+#define  SKEIN_1024_STATE_BITS  (64*SKEIN_1024_STATE_WORDS)
+
+#define  SKEIN_256_BLOCK_BYTES  (8*SKEIN_256_STATE_WORDS)
+#define  SKEIN_512_BLOCK_BYTES  (8*SKEIN_512_STATE_WORDS)
+#define  SKEIN_1024_BLOCK_BYTES  (8*SKEIN_1024_STATE_WORDS)
+
+struct skein_ctx_hdr {
+       size_t hash_bit_len;            /* size of hash result, in bits */
+       size_t b_cnt;                   /* current byte count in buffer b[] */
+       u64 tweak[SKEIN_MODIFIER_WORDS]; /* tweak[0]=byte cnt, tweak[1]=flags */
+};
+
+struct skein_256_ctx { /* 256-bit Skein hash context structure */
+       struct skein_ctx_hdr h;         /* common header context variables */
+       u64 x[SKEIN_256_STATE_WORDS];   /* chaining variables */
+       u8 b[SKEIN_256_BLOCK_BYTES];    /* partial block buf (8-byte aligned) */
+};
+
+struct skein_512_ctx { /* 512-bit Skein hash context structure */
+       struct skein_ctx_hdr h;         /* common header context variables */
+       u64 x[SKEIN_512_STATE_WORDS];   /* chaining variables */
+       u8 b[SKEIN_512_BLOCK_BYTES];    /* partial block buf (8-byte aligned) */
+};
+
+struct skein_1024_ctx { /* 1024-bit Skein hash context structure */
+       struct skein_ctx_hdr h;         /* common header context variables */
+       u64 x[SKEIN_1024_STATE_WORDS];  /* chaining variables */
+       u8 b[SKEIN_1024_BLOCK_BYTES];   /* partial block buf (8-byte aligned) */
+};
+
+static inline int rotl_64(int x, int N)
+{
+       return (x << N) | (x >> (64 - N));
+}
+
+/* Skein APIs for (incremental) "straight hashing" */
+int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len);
+int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len);
+int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len);
+
+int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg,
+                    size_t msg_byte_cnt);
+int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg,
+                    size_t msg_byte_cnt);
+int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg,
+                     size_t msg_byte_cnt);
+
+int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val);
+int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val);
+int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val);
+
+/*
+**   Skein APIs for "extended" initialization: MAC keys, tree hashing.
+**   After an init_ext() call, just use update/final calls as with init().
+**
+**   Notes: Same parameters as _init() calls, plus tree_info/key/key_bytes.
+**          When key_bytes == 0 and tree_info == SKEIN_SEQUENTIAL,
+**              the results of init_ext() are identical to calling init().
+**          The function init() may be called once to "precompute" the IV for
+**              a given hash_bit_len value, then by saving a copy of the context
+**              the IV computation may be avoided in later calls.
+**          Similarly, the function init_ext() may be called once per MAC key
+**              to precompute the MAC IV, then a copy of the context saved and
+**              reused for each new MAC computation.
+**/
+int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len,
+                      u64 tree_info, const u8 *key, size_t key_bytes);
+int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len,
+                      u64 tree_info, const u8 *key, size_t key_bytes);
+int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len,
+                       u64 tree_info, const u8 *key, size_t key_bytes);
+
+/*
+**   Skein APIs for MAC and tree hash:
+**      final_pad:  pad, do final block, but no OUTPUT type
+**      output:     do just the output stage
+*/
+int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val);
+int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val);
+int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val);
+
+#ifndef SKEIN_TREE_HASH
+#define SKEIN_TREE_HASH (1)
+#endif
+#if  SKEIN_TREE_HASH
+int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val);
+int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val);
+int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val);
+#endif
+
+/*****************************************************************
+** "Internal" Skein definitions
+**    -- not needed for sequential hashing API, but will be
+**           helpful for other uses of Skein (e.g., tree hash mode).
+**    -- included here so that they can be shared between
+**           reference and optimized code.
+******************************************************************/
+
+/* tweak word tweak[1]: bit field starting positions */
+#define SKEIN_T1_BIT(BIT)       ((BIT) - 64)      /* second word  */
+
+#define SKEIN_T1_POS_TREE_LVL   SKEIN_T1_BIT(112) /* 112..118 hash tree level */
+#define SKEIN_T1_POS_BIT_PAD    SKEIN_T1_BIT(119) /* 119 part. final in byte */
+#define SKEIN_T1_POS_BLK_TYPE   SKEIN_T1_BIT(120) /* 120..125 type field `*/
+#define SKEIN_T1_POS_FIRST      SKEIN_T1_BIT(126) /* 126      first blk flag */
+#define SKEIN_T1_POS_FINAL      SKEIN_T1_BIT(127) /* 127      final blk flag */
+
+/* tweak word tweak[1]: flag bit definition(s) */
+#define SKEIN_T1_FLAG_FIRST     (((u64)  1) << SKEIN_T1_POS_FIRST)
+#define SKEIN_T1_FLAG_FINAL     (((u64)  1) << SKEIN_T1_POS_FINAL)
+#define SKEIN_T1_FLAG_BIT_PAD   (((u64)  1) << SKEIN_T1_POS_BIT_PAD)
+
+/* tweak word tweak[1]: tree level bit field mask */
+#define SKEIN_T1_TREE_LVL_MASK  (((u64)0x7F) << SKEIN_T1_POS_TREE_LVL)
+#define SKEIN_T1_TREE_LEVEL(n)  (((u64) (n)) << SKEIN_T1_POS_TREE_LVL)
+
+/* tweak word tweak[1]: block type field */
+#define SKEIN_BLK_TYPE_KEY       (0) /* key, for MAC and KDF */
+#define SKEIN_BLK_TYPE_CFG       (4) /* configuration block */
+#define SKEIN_BLK_TYPE_PERS      (8) /* personalization string */
+#define SKEIN_BLK_TYPE_PK       (12) /* pubkey (for digital sigs) */
+#define SKEIN_BLK_TYPE_KDF      (16) /* key identifier for KDF */
+#define SKEIN_BLK_TYPE_NONCE    (20) /* nonce for PRNG */
+#define SKEIN_BLK_TYPE_MSG      (48) /* message processing */
+#define SKEIN_BLK_TYPE_OUT      (63) /* output stage */
+#define SKEIN_BLK_TYPE_MASK     (63) /* bit field mask */
+
+#define SKEIN_T1_BLK_TYPE(T)   (((u64) (SKEIN_BLK_TYPE_##T)) << \
+                                       SKEIN_T1_POS_BLK_TYPE)
+#define SKEIN_T1_BLK_TYPE_KEY   SKEIN_T1_BLK_TYPE(KEY)  /* for MAC and KDF */
+#define SKEIN_T1_BLK_TYPE_CFG   SKEIN_T1_BLK_TYPE(CFG)  /* config block */
+#define SKEIN_T1_BLK_TYPE_PERS  SKEIN_T1_BLK_TYPE(PERS) /* personalization */
+#define SKEIN_T1_BLK_TYPE_PK    SKEIN_T1_BLK_TYPE(PK)   /* pubkey (for sigs) */
+#define SKEIN_T1_BLK_TYPE_KDF   SKEIN_T1_BLK_TYPE(KDF)  /* key ident for KDF */
+#define SKEIN_T1_BLK_TYPE_NONCE SKEIN_T1_BLK_TYPE(NONCE)/* nonce for PRNG */
+#define SKEIN_T1_BLK_TYPE_MSG   SKEIN_T1_BLK_TYPE(MSG)  /* message processing */
+#define SKEIN_T1_BLK_TYPE_OUT   SKEIN_T1_BLK_TYPE(OUT)  /* output stage */
+#define SKEIN_T1_BLK_TYPE_MASK  SKEIN_T1_BLK_TYPE(MASK) /* field bit mask */
+
+#define SKEIN_T1_BLK_TYPE_CFG_FINAL    (SKEIN_T1_BLK_TYPE_CFG | \
+                                       SKEIN_T1_FLAG_FINAL)
+#define SKEIN_T1_BLK_TYPE_OUT_FINAL    (SKEIN_T1_BLK_TYPE_OUT | \
+                                       SKEIN_T1_FLAG_FINAL)
+
+#define SKEIN_VERSION           (1)
+
+#ifndef SKEIN_ID_STRING_LE      /* allow compile-time personalization */
+#define SKEIN_ID_STRING_LE      (0x33414853) /* "SHA3" (little-endian)*/
+#endif
+
+#define SKEIN_MK_64(hi32, lo32)  ((lo32) + (((u64) (hi32)) << 32))
+#define SKEIN_SCHEMA_VER        SKEIN_MK_64(SKEIN_VERSION, SKEIN_ID_STRING_LE)
+#define SKEIN_KS_PARITY         SKEIN_MK_64(0x1BD11BDA, 0xA9FC1A22)
+
+#define SKEIN_CFG_STR_LEN       (4*8)
+
+/* bit field definitions in config block tree_info word */
+#define SKEIN_CFG_TREE_LEAF_SIZE_POS  (0)
+#define SKEIN_CFG_TREE_NODE_SIZE_POS  (8)
+#define SKEIN_CFG_TREE_MAX_LEVEL_POS  (16)
+
+#define SKEIN_CFG_TREE_LEAF_SIZE_MSK (((u64)0xFF) << \
+                                       SKEIN_CFG_TREE_LEAF_SIZE_POS)
+#define SKEIN_CFG_TREE_NODE_SIZE_MSK (((u64)0xFF) << \
+                                       SKEIN_CFG_TREE_NODE_SIZE_POS)
+#define SKEIN_CFG_TREE_MAX_LEVEL_MSK (((u64)0xFF) << \
+                                       SKEIN_CFG_TREE_MAX_LEVEL_POS)
+
+#define SKEIN_CFG_TREE_INFO(leaf, node, max_lvl)                   \
+       ((((u64)(leaf))   << SKEIN_CFG_TREE_LEAF_SIZE_POS) |    \
+        (((u64)(node))   << SKEIN_CFG_TREE_NODE_SIZE_POS) |    \
+        (((u64)(max_lvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS))
+
+/* use as tree_info in InitExt() call for sequential processing */
+#define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0, 0, 0)
+
+/*
+**   Skein macros for getting/setting tweak words, etc.
+**   These are useful for partial input bytes, hash tree init/update, etc.
+**/
+#define skein_get_tweak(ctx_ptr, TWK_NUM)          ((ctx_ptr)->h.tweak[TWK_NUM])
+#define skein_set_tweak(ctx_ptr, TWK_NUM, t_val) { \
+               (ctx_ptr)->h.tweak[TWK_NUM] = (t_val); \
+       }
+
+#define skein_get_T0(ctx_ptr)     skein_get_tweak(ctx_ptr, 0)
+#define skein_get_T1(ctx_ptr)     skein_get_tweak(ctx_ptr, 1)
+#define skein_set_T0(ctx_ptr, T0) skein_set_tweak(ctx_ptr, 0, T0)
+#define skein_set_T1(ctx_ptr, T1) skein_set_tweak(ctx_ptr, 1, T1)
+
+/* set both tweak words at once */
+#define skein_set_T0_T1(ctx_ptr, T0, T1)           \
+       {                                          \
+       skein_set_T0(ctx_ptr, (T0));               \
+       skein_set_T1(ctx_ptr, (T1));               \
+       }
+
+#define skein_set_type(ctx_ptr, BLK_TYPE)         \
+       skein_set_T1(ctx_ptr, SKEIN_T1_BLK_TYPE_##BLK_TYPE)
+
+/*
+ * setup for starting with a new type:
+ * h.tweak[0]=0; h.tweak[1] = NEW_TYPE; h.b_cnt=0;
+ */
+#define skein_start_new_type(ctx_ptr, BLK_TYPE) { \
+               skein_set_T0_T1(ctx_ptr, 0, SKEIN_T1_FLAG_FIRST | \
+                               SKEIN_T1_BLK_TYPE_##BLK_TYPE); \
+               (ctx_ptr)->h.b_cnt = 0; \
+       }
+
+#define skein_clear_first_flag(hdr) { \
+               (hdr).tweak[1] &= ~SKEIN_T1_FLAG_FIRST; \
+       }
+#define skein_set_bit_pad_flag(hdr) { \
+               (hdr).tweak[1] |=  SKEIN_T1_FLAG_BIT_PAD; \
+       }
+
+#define skein_set_tree_level(hdr, height) { \
+               (hdr).tweak[1] |= SKEIN_T1_TREE_LEVEL(height); \
+       }
+
+/* ignore all asserts, for performance */
+#define skein_assert_ret(x, ret_code)
+#define skein_assert(x)
+
+/*****************************************************************
+** Skein block function constants (shared across Ref and Opt code)
+******************************************************************/
+enum {
+           /* SKEIN_256 round rotation constants */
+       R_256_0_0 = 14, R_256_0_1 = 16,
+       R_256_1_0 = 52, R_256_1_1 = 57,
+       R_256_2_0 = 23, R_256_2_1 = 40,
+       R_256_3_0 =  5, R_256_3_1 = 37,
+       R_256_4_0 = 25, R_256_4_1 = 33,
+       R_256_5_0 = 46, R_256_5_1 = 12,
+       R_256_6_0 = 58, R_256_6_1 = 22,
+       R_256_7_0 = 32, R_256_7_1 = 32,
+
+           /* SKEIN_512 round rotation constants */
+       R_512_0_0 = 46, R_512_0_1 = 36, R_512_0_2 = 19, R_512_0_3 = 37,
+       R_512_1_0 = 33, R_512_1_1 = 27, R_512_1_2 = 14, R_512_1_3 = 42,
+       R_512_2_0 = 17, R_512_2_1 = 49, R_512_2_2 = 36, R_512_2_3 = 39,
+       R_512_3_0 = 44, R_512_3_1 =  9, R_512_3_2 = 54, R_512_3_3 = 56,
+       R_512_4_0 = 39, R_512_4_1 = 30, R_512_4_2 = 34, R_512_4_3 = 24,
+       R_512_5_0 = 13, R_512_5_1 = 50, R_512_5_2 = 10, R_512_5_3 = 17,
+       R_512_6_0 = 25, R_512_6_1 = 29, R_512_6_2 = 39, R_512_6_3 = 43,
+       R_512_7_0 =  8, R_512_7_1 = 35, R_512_7_2 = 56, R_512_7_3 = 22,
+
+           /* SKEIN_1024 round rotation constants */
+       R1024_0_0 = 24, R1024_0_1 = 13, R1024_0_2 =  8, R1024_0_3 = 47,
+       R1024_0_4 =  8, R1024_0_5 = 17, R1024_0_6 = 22, R1024_0_7 = 37,
+       R1024_1_0 = 38, R1024_1_1 = 19, R1024_1_2 = 10, R1024_1_3 = 55,
+       R1024_1_4 = 49, R1024_1_5 = 18, R1024_1_6 = 23, R1024_1_7 = 52,
+       R1024_2_0 = 33, R1024_2_1 =  4, R1024_2_2 = 51, R1024_2_3 = 13,
+       R1024_2_4 = 34, R1024_2_5 = 41, R1024_2_6 = 59, R1024_2_7 = 17,
+       R1024_3_0 =  5, R1024_3_1 = 20, R1024_3_2 = 48, R1024_3_3 = 41,
+       R1024_3_4 = 47, R1024_3_5 = 28, R1024_3_6 = 16, R1024_3_7 = 25,
+       R1024_4_0 = 41, R1024_4_1 =  9, R1024_4_2 = 37, R1024_4_3 = 31,
+       R1024_4_4 = 12, R1024_4_5 = 47, R1024_4_6 = 44, R1024_4_7 = 30,
+       R1024_5_0 = 16, R1024_5_1 = 34, R1024_5_2 = 56, R1024_5_3 = 51,
+       R1024_5_4 =  4, R1024_5_5 = 53, R1024_5_6 = 42, R1024_5_7 = 41,
+       R1024_6_0 = 31, R1024_6_1 = 44, R1024_6_2 = 47, R1024_6_3 = 46,
+       R1024_6_4 = 19, R1024_6_5 = 42, R1024_6_6 = 44, R1024_6_7 = 25,
+       R1024_7_0 =  9, R1024_7_1 = 48, R1024_7_2 = 35, R1024_7_3 = 52,
+       R1024_7_4 = 23, R1024_7_5 = 31, R1024_7_6 = 37, R1024_7_7 = 20
+};
+
+#ifndef SKEIN_ROUNDS
+#define SKEIN_256_ROUNDS_TOTAL (72)    /* # rounds for diff block sizes */
+#define SKEIN_512_ROUNDS_TOTAL (72)
+#define SKEIN_1024_ROUNDS_TOTAL (80)
+#else                  /* allow command-line define in range 8*(5..14)   */
+#define SKEIN_256_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/100) + 5) % 10) + 5))
+#define SKEIN_512_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/10)  + 5) % 10) + 5))
+#define SKEIN_1024_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS)     + 5) % 10) + 5))
+#endif
+
+#endif  /* ifndef _SKEIN_H_ */
index 616364f..66261ab 100644 (file)
@@ -15,7 +15,7 @@
 ************************************************************************/
 
 #include <linux/string.h>
-#include "skein.h"
+#include "skein_base.h"
 #include "skein_block.h"
 
 #ifndef SKEIN_USE_ASM
 #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 BLK_BITS        (WCNT * 64) /* some useful definitions for code here */
 #define KW_TWK_BASE     (0)
 #define KW_KEY_BASE     (3)
 #define ks              (kw + KW_KEY_BASE)
 #define ts              (kw + KW_TWK_BASE)
 
 #ifdef SKEIN_DEBUG
-#define debug_save_tweak(ctx) { \
-                       ctx->h.tweak[0] = ts[0]; ctx->h.tweak[1] = ts[1]; }
+#define debug_save_tweak(ctx)       \
+{                                   \
+       ctx->h.tweak[0] = ts[0];    \
+       ctx->h.tweak[1] = ts[1];    \
+}
 #else
 #define debug_save_tweak(ctx)
 #endif
 
-/*****************************  SKEIN_256 ******************************/
 #if !(SKEIN_USE_ASM & 256)
-void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr,
-                            size_t blk_cnt, size_t byte_cnt_add)
-       { /* do it in C */
-       enum {
-               WCNT = SKEIN_256_STATE_WORDS
-       };
 #undef  RCNT
-#define RCNT  (SKEIN_256_ROUNDS_TOTAL/8)
-
+#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)
+#define SKEIN_UNROLL_256 (((SKEIN_LOOP) / 100) % 10)
 #else
 #define SKEIN_UNROLL_256 (0)
 #endif
@@ -60,17 +55,329 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr,
 #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"*/
+#endif
+#define ROUND256(p0, p1, p2, p3, ROT, r_num) \
+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, r_num) /* fully unrolled */ \
+do {                                                          \
+       ROUND256(p0, p1, p2, p3, ROT, r_num);                 \
+} 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;                              \
+} while (0)
 #else
-       u64  kw[WCNT+4]; /* key schedule words : chaining vars + tweak */
+/* looping version */
+#define R256(p0, p1, p2, p3, ROT, r_num) \
+do { \
+       ROUND256(p0, p1, p2, p3, ROT, r_num); \
+} 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];                                \
+} while (0)
+#endif
+#define R256_8_ROUNDS(R)                                 \
+do {                                                     \
+               R256(0, 1, 2, 3, R_256_0, 8 * (R) + 1);  \
+               R256(0, 3, 2, 1, R_256_1, 8 * (R) + 2);  \
+               R256(0, 1, 2, 3, R_256_2, 8 * (R) + 3);  \
+               R256(0, 3, 2, 1, R_256_3, 8 * (R) + 4);  \
+               I256(2 * (R));                           \
+               R256(0, 1, 2, 3, R_256_4, 8 * (R) + 5);  \
+               R256(0, 3, 2, 1, R_256_5, 8 * (R) + 6);  \
+               R256(0, 1, 2, 3, R_256_6, 8 * (R) + 7);  \
+               R256(0, 3, 2, 1, R_256_7, 8 * (R) + 8);  \
+               I256(2 * (R) + 1);                       \
+} while (0)
+
+#define R256_UNROLL_R(NN)                     \
+       ((SKEIN_UNROLL_256 == 0 &&            \
+       SKEIN_256_ROUNDS_TOTAL / 8 > (NN)) || \
+       (SKEIN_UNROLL_256 > (NN)))
+
+#if  (SKEIN_UNROLL_256 > 14)
+#error  "need more unrolling in skein_256_process_block"
+#endif
+#endif
+
+#if !(SKEIN_USE_ASM & 512)
+#undef  RCNT
+#define RCNT  (SKEIN_512_ROUNDS_TOTAL/8)
+
+#ifdef SKEIN_LOOP /* configure how much to unroll the loop */
+#define SKEIN_UNROLL_512 (((SKEIN_LOOP)/10)%10)
+#else
+#define SKEIN_UNROLL_512 (0)
+#endif
+
+#if SKEIN_UNROLL_512
+#if (RCNT % SKEIN_UNROLL_512)
+#error "Invalid SKEIN_UNROLL_512" /* sanity check on unroll count */
+#endif
+#endif
+#define ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \
+do {                                                         \
+       X##p0 += X##p1;                                      \
+       X##p1 = 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, r_num) /* unrolled */ \
+do {                                                                    \
+       ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num);           \
+} 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;                              \
+} while (0)
+
+#else /* looping version */
+#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num)                 \
+do {                                                                     \
+       ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num);            \
+} 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];                                \
+} while (0)
+#endif /* end of looped code definitions */
+#define R512_8_ROUNDS(R)  /* do 8 full rounds */                      \
+do {                                                                  \
+               R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_0, 8 * (R) + 1);   \
+               R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_1, 8 * (R) + 2);   \
+               R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_2, 8 * (R) + 3);   \
+               R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_3, 8 * (R) + 4);   \
+               I512(2 * (R));                              \
+               R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_4, 8 * (R) + 5);   \
+               R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_5, 8 * (R) + 6);   \
+               R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_6, 8 * (R) + 7);   \
+               R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_7, 8 * (R) + 8);   \
+               I512(2 * (R) + 1);        /* and key injection */     \
+} while (0)
+#define R512_UNROLL_R(NN)                             \
+               ((SKEIN_UNROLL_512 == 0 &&            \
+               SKEIN_512_ROUNDS_TOTAL/8 > (NN)) ||   \
+               (SKEIN_UNROLL_512 > (NN)))
+
+#if  (SKEIN_UNROLL_512 > 14)
+#error  "need more unrolling in skein_512_process_block"
+#endif
+#endif
+
+#if !(SKEIN_USE_ASM & 1024)
+#undef  RCNT
+#define RCNT  (SKEIN_1024_ROUNDS_TOTAL/8)
+#ifdef SKEIN_LOOP /* configure how much to unroll the loop */
+#define SKEIN_UNROLL_1024 ((SKEIN_LOOP)%10)
+#else
+#define SKEIN_UNROLL_1024 (0)
+#endif
+
+#if (SKEIN_UNROLL_1024 != 0)
+#if (RCNT % SKEIN_UNROLL_1024)
+#error "Invalid SKEIN_UNROLL_1024" /* sanity check on unroll count */
+#endif
+#endif
+#define ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \
+                 pF, ROT, r_num)                                             \
+do {                                                                          \
+       X##p0 += X##p1;                                                       \
+       X##p1 = 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);                                               \
+} 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;                             \
+} 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);                                               \
+} 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];                                 \
+} while (0)
+
+#endif
+#define R1024_8_ROUNDS(R)                                                     \
+do {                                                                          \
+       R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, \
+             R1024_0, 8*(R) + 1);                                            \
+       R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, \
+             R1024_1, 8*(R) + 2);                                            \
+       R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, \
+             R1024_2, 8*(R) + 3);                                            \
+       R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, \
+             R1024_3, 8*(R) + 4);                                            \
+       I1024(2*(R));                                                         \
+       R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, \
+             R1024_4, 8*(R) + 5);                                            \
+       R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, \
+             R1024_5, 8*(R) + 6);                                            \
+       R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, \
+             R1024_6, 8*(R) + 7);                                            \
+       R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, \
+             R1024_7, 8*(R) + 8);                                            \
+       I1024(2*(R)+1);                                                       \
+} while (0)
+
+#define R1024_UNROLL_R(NN)                              \
+               ((SKEIN_UNROLL_1024 == 0 &&             \
+               SKEIN_1024_ROUNDS_TOTAL/8 > (NN)) ||  \
+               (SKEIN_UNROLL_1024 > (NN)))
+
+#if  (SKEIN_UNROLL_1024 > 14)
+#error  "need more unrolling in Skein_1024_Process_Block"
+#endif
+#endif
+
+/*****************************  SKEIN_256 ******************************/
+#if !(SKEIN_USE_ASM & 256)
+void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr,
+                            size_t blk_cnt, size_t byte_cnt_add)
+{ /* do it in C */
+       enum {
+               WCNT = SKEIN_256_STATE_WORDS
+       };
+       size_t r;
+#if SKEIN_UNROLL_256
+       /* key schedule: chaining vars + tweak + "rot"*/
+       u64  kw[WCNT+4+RCNT*2];
+#else
+       /* key schedule words : chaining vars + tweak */
+       u64  kw[WCNT+4];
 #endif
        u64  X0, X1, X2, X3; /* local copy of context vars, for speed */
        u64  w[WCNT]; /* local copy of input block */
 #ifdef SKEIN_DEBUG
        const u64 *X_ptr[4]; /* use for debugging (help cc put Xn in regs) */
 
-       X_ptr[0] = &X0;  X_ptr[1] = &X1;  X_ptr[2] = &X2;  X_ptr[3] = &X3;
+       X_ptr[0] = &X0;
+       X_ptr[1] = &X1;
+       X_ptr[2] = &X2;
+       X_ptr[3] = &X3;
 #endif
        skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */
        ts[0] = ctx->h.tweak[0];
@@ -94,132 +401,62 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr,
                /* get input block in little-endian format */
                skein_get64_lsb_first(w, blk_ptr, WCNT);
                debug_save_tweak(ctx);
-               skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts);
 
-               X0 = w[0] + ks[0]; /* do the first full key injection */
+               /* do the first full key injection */
+               X0 = w[0] + ks[0];
                X1 = w[1] + ks[1] + ts[0];
                X2 = w[2] + ks[2] + ts[1];
                X3 = w[3] + ks[3];
 
-               /* show starting state values */
-               skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL,
-                                x_ptr);
-
                blk_ptr += SKEIN_256_BLOCK_BYTES;
 
                /* run the rounds */
-
-#define ROUND256(p0, p1, p2, p3, ROT, r_num)                              \
-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, r_num) /* fully unrolled */ \
-do { \
-       ROUND256(p0, p1, p2, p3, ROT, r_num); \
-       skein_show_r_ptr(BLK_BITS, &ctx->h, r_num, X_ptr); \
-} 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, X_ptr); \
-} while (0)
-#else /* looping version */
-#define R256(p0, p1, p2, p3, ROT, r_num) \
-do { \
-       ROUND256(p0, p1, p2, p3, ROT, r_num); \
-       skein_show_r_ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + r_num, X_ptr); \
-} 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, X_ptr); \
-} while (0)
-
-       for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_256)
+               for (r = 1;
+                       r < (SKEIN_UNROLL_256 ? 2 * RCNT : 2);
+                       r += (SKEIN_UNROLL_256 ? 2 * SKEIN_UNROLL_256 : 1)) {
+                       R256_8_ROUNDS(0);
+#if   R256_UNROLL_R(1)
+                       R256_8_ROUNDS(1);
+#endif
+#if   R256_UNROLL_R(2)
+                       R256_8_ROUNDS(2);
+#endif
+#if   R256_UNROLL_R(3)
+                       R256_8_ROUNDS(3);
+#endif
+#if   R256_UNROLL_R(4)
+                       R256_8_ROUNDS(4);
+#endif
+#if   R256_UNROLL_R(5)
+                       R256_8_ROUNDS(5);
+#endif
+#if   R256_UNROLL_R(6)
+                       R256_8_ROUNDS(6);
+#endif
+#if   R256_UNROLL_R(7)
+                       R256_8_ROUNDS(7);
+#endif
+#if   R256_UNROLL_R(8)
+                       R256_8_ROUNDS(8);
+#endif
+#if   R256_UNROLL_R(9)
+                       R256_8_ROUNDS(9);
+#endif
+#if   R256_UNROLL_R(10)
+                       R256_8_ROUNDS(10);
+#endif
+#if   R256_UNROLL_R(11)
+                       R256_8_ROUNDS(11);
+#endif
+#if   R256_UNROLL_R(12)
+                       R256_8_ROUNDS(12);
+#endif
+#if   R256_UNROLL_R(13)
+                       R256_8_ROUNDS(13);
+#endif
+#if   R256_UNROLL_R(14)
+                       R256_8_ROUNDS(14);
 #endif
-               {
-#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];
@@ -227,8 +464,6 @@ do { \
                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 (--blk_cnt);
        ctx->h.tweak[0] = ts[0];
@@ -256,20 +491,8 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr,
        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;
+#if SKEIN_UNROLL_512
        u64  kw[WCNT+4+RCNT*2]; /* key sched: chaining vars + tweak + "rot"*/
 #else
        u64  kw[WCNT+4]; /* key schedule words : chaining vars + tweak */
@@ -279,8 +502,14 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr,
 #ifdef SKEIN_DEBUG
        const u64 *X_ptr[8]; /* use for debugging (help cc put Xn in regs) */
 
-       X_ptr[0] = &X0;  X_ptr[1] = &X1;  X_ptr[2] = &X2;  X_ptr[3] = &X3;
-       X_ptr[4] = &X4;  X_ptr[5] = &X5;  X_ptr[6] = &X6;  X_ptr[7] = &X7;
+       X_ptr[0] = &X0;
+       X_ptr[1] = &X1;
+       X_ptr[2] = &X2;
+       X_ptr[3] = &X3;
+       X_ptr[4] = &X4;
+       X_ptr[5] = &X5;
+       X_ptr[6] = &X6;
+       X_ptr[7] = &X7;
 #endif
 
        skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */
@@ -310,143 +539,68 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr,
                /* get input block in little-endian format */
                skein_get64_lsb_first(w, blk_ptr, WCNT);
                debug_save_tweak(ctx);
-               skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, 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];
+               /* do the first full key injection */
+               X0 = w[0] + ks[0];
+               X1 = w[1] + ks[1];
+               X2 = w[2] + ks[2];
+               X3 = w[3] + ks[3];
+               X4 = w[4] + ks[4];
+               X5 = w[5] + ks[5] + ts[0];
+               X6 = w[6] + ks[6] + ts[1];
+               X7 = w[7] + ks[7];
 
                blk_ptr += SKEIN_512_BLOCK_BYTES;
 
-               skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL,
-                                X_ptr);
                /* run the rounds */
-#define ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \
-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, r_num) /* unrolled */ \
-do { \
-       ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \
-       skein_show_r_ptr(BLK_BITS, &ctx->h, r_num, X_ptr); \
-} 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, X_ptr); \
-} while (0)
-#else /* looping version */
-#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \
-do { \
-       ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num); \
-       skein_show_r_ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + r_num, X_ptr); \
-} 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, X_ptr); \
-} 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)
+               for (r = 1;
+                       r < (SKEIN_UNROLL_512 ? 2 * RCNT : 2);
+                       r += (SKEIN_UNROLL_512 ? 2 * SKEIN_UNROLL_512 : 1)) {
 
                        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)
+#if   R512_UNROLL_R(1)
                        R512_8_ROUNDS(1);
-       #endif
-       #if   R512_UNROLL_R(2)
+#endif
+#if   R512_UNROLL_R(2)
                        R512_8_ROUNDS(2);
-       #endif
-       #if   R512_UNROLL_R(3)
+#endif
+#if   R512_UNROLL_R(3)
                        R512_8_ROUNDS(3);
-       #endif
-       #if   R512_UNROLL_R(4)
+#endif
+#if   R512_UNROLL_R(4)
                        R512_8_ROUNDS(4);
-       #endif
-       #if   R512_UNROLL_R(5)
+#endif
+#if   R512_UNROLL_R(5)
                        R512_8_ROUNDS(5);
-       #endif
-       #if   R512_UNROLL_R(6)
+#endif
+#if   R512_UNROLL_R(6)
                        R512_8_ROUNDS(6);
-       #endif
-       #if   R512_UNROLL_R(7)
+#endif
+#if   R512_UNROLL_R(7)
                        R512_8_ROUNDS(7);
-       #endif
-       #if   R512_UNROLL_R(8)
+#endif
+#if   R512_UNROLL_R(8)
                        R512_8_ROUNDS(8);
-       #endif
-       #if   R512_UNROLL_R(9)
+#endif
+#if   R512_UNROLL_R(9)
                        R512_8_ROUNDS(9);
-       #endif
-       #if   R512_UNROLL_R(10)
+#endif
+#if   R512_UNROLL_R(10)
                        R512_8_ROUNDS(10);
-       #endif
-       #if   R512_UNROLL_R(11)
+#endif
+#if   R512_UNROLL_R(11)
                        R512_8_ROUNDS(11);
-       #endif
-       #if   R512_UNROLL_R(12)
+#endif
+#if   R512_UNROLL_R(12)
                        R512_8_ROUNDS(12);
-       #endif
-       #if   R512_UNROLL_R(13)
+#endif
+#if   R512_UNROLL_R(13)
                        R512_8_ROUNDS(13);
-       #endif
-       #if   R512_UNROLL_R(14)
+#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
+#endif
                }
 
                /* do the final "feedforward" xor, update context chaining */
@@ -458,7 +612,6 @@ do { \
                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 (--blk_cnt);
@@ -487,20 +640,8 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr,
        enum {
                WCNT = SKEIN_1024_STATE_WORDS
        };
-#undef  RCNT
-#define RCNT  (SKEIN_1024_ROUNDS_TOTAL/8)
-
-#ifdef SKEIN_LOOP /* configure how much to unroll the loop */
-#define SKEIN_UNROLL_1024 ((SKEIN_LOOP)%10)
-#else
-#define SKEIN_UNROLL_1024 (0)
-#endif
-
-#if (SKEIN_UNROLL_1024 != 0)
-#if (RCNT % SKEIN_UNROLL_1024)
-#error "Invalid SKEIN_UNROLL_1024" /* sanity check on unroll count */
-#endif
        size_t  r;
+#if (SKEIN_UNROLL_1024 != 0)
        u64  kw[WCNT+4+RCNT*2]; /* key sched: chaining vars + tweak + "rot" */
 #else
        u64  kw[WCNT+4]; /* key schedule words : chaining vars + tweak */
@@ -510,16 +651,6 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr,
        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 *X_ptr[16]; /* use for debugging (help cc put Xn in regs) */
-
-       X_ptr[0]  = &X00;  X_ptr[1]  = &X01;  X_ptr[2]  = &X02;
-       X_ptr[3]  = &X03;  X_ptr[4]  = &X04;  X_ptr[5]  = &X05;
-       X_ptr[6]  = &X06;  X_ptr[7]  = &X07;  X_ptr[8]  = &X08;
-       X_ptr[9]  = &X09;  X_ptr[10] = &X10;  X_ptr[11] = &X11;
-       X_ptr[12] = &X12;  X_ptr[13] = &X13;  X_ptr[14] = &X14;
-       X_ptr[15] = &X15;
-#endif
 
        skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */
        ts[0] = ctx->h.tweak[0];
@@ -548,192 +679,81 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr,
                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[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];
+               ts[2] = ts[0] ^ ts[1];
 
                /* get input block in little-endian format */
                skein_get64_lsb_first(w, blk_ptr, WCNT);
                debug_save_tweak(ctx);
-               skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, 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,
-                                X_ptr);
-
-#define ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \
-                       pF, ROT, r_num) \
-do { \
-       X##p0 += X##p1; X##p1 = 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, X_ptr); \
-} 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, X_ptr); \
-} 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, X_ptr); \
-} 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, X_ptr); \
-} 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)
 
+               /* do the first full key injection */
+               X00 = w[0] + ks[0];
+               X01 = w[1] + ks[1];
+               X02 = w[2] + ks[2];
+               X03 = w[3] + ks[3];
+               X04 = w[4] + ks[4];
+               X05 = w[5] + ks[5];
+               X06 = w[6] + ks[6];
+               X07 = w[7] + ks[7];
+               X08 = w[8] + ks[8];
+               X09 = w[9] + ks[9];
+               X10 = w[10] + ks[10];
+               X11 = w[11] + ks[11];
+               X12 = w[12] + ks[12];
+               X13 = w[13] + ks[13] + ts[0];
+               X14 = w[14] + ks[14] + ts[1];
+               X15 = w[15] + ks[15];
+
+               for (r = 1;
+                       r < (SKEIN_UNROLL_1024 ? 2 * RCNT : 2);
+                       r += (SKEIN_UNROLL_1024 ? 2 * SKEIN_UNROLL_1024 : 1)) {
                        R1024_8_ROUNDS(0);
-
-#define R1024_UNROLL_R(NN) \
-               ((SKEIN_UNROLL_1024 == 0 && \
-                 SKEIN_1024_ROUNDS_TOTAL/8 > (NN)) || \
-                (SKEIN_UNROLL_1024 > (NN)))
-
-       #if   R1024_UNROLL_R(1)
+#if   R1024_UNROLL_R(1)
                        R1024_8_ROUNDS(1);
-       #endif
-       #if   R1024_UNROLL_R(2)
+#endif
+#if   R1024_UNROLL_R(2)
                        R1024_8_ROUNDS(2);
-       #endif
-       #if   R1024_UNROLL_R(3)
+#endif
+#if   R1024_UNROLL_R(3)
                        R1024_8_ROUNDS(3);
-       #endif
-       #if   R1024_UNROLL_R(4)
+#endif
+#if   R1024_UNROLL_R(4)
                        R1024_8_ROUNDS(4);
-       #endif
-       #if   R1024_UNROLL_R(5)
+#endif
+#if   R1024_UNROLL_R(5)
                        R1024_8_ROUNDS(5);
-       #endif
-       #if   R1024_UNROLL_R(6)
+#endif
+#if   R1024_UNROLL_R(6)
                        R1024_8_ROUNDS(6);
-       #endif
-       #if   R1024_UNROLL_R(7)
+#endif
+#if   R1024_UNROLL_R(7)
                        R1024_8_ROUNDS(7);
-       #endif
-       #if   R1024_UNROLL_R(8)
+#endif
+#if   R1024_UNROLL_R(8)
                        R1024_8_ROUNDS(8);
-       #endif
-       #if   R1024_UNROLL_R(9)
+#endif
+#if   R1024_UNROLL_R(9)
                        R1024_8_ROUNDS(9);
-       #endif
-       #if   R1024_UNROLL_R(10)
+#endif
+#if   R1024_UNROLL_R(10)
                        R1024_8_ROUNDS(10);
-       #endif
-       #if   R1024_UNROLL_R(11)
+#endif
+#if   R1024_UNROLL_R(11)
                        R1024_8_ROUNDS(11);
-       #endif
-       #if   R1024_UNROLL_R(12)
+#endif
+#if   R1024_UNROLL_R(12)
                        R1024_8_ROUNDS(12);
-       #endif
-       #if   R1024_UNROLL_R(13)
+#endif
+#if   R1024_UNROLL_R(13)
                        R1024_8_ROUNDS(13);
-       #endif
-       #if   R1024_UNROLL_R(14)
+#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
+#endif
                }
                /* do the final "feedforward" xor, update context chaining */
 
@@ -754,8 +774,6 @@ do { \
                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;
                blk_ptr += SKEIN_1024_BLOCK_BYTES;
        } while (--blk_cnt);
index bd7bdc3..9d40f4a 100644 (file)
@@ -10,7 +10,7 @@
 #ifndef _SKEIN_BLOCK_H_
 #define _SKEIN_BLOCK_H_
 
-#include "skein.h" /* get the Skein API definitions   */
+#include "skein_base.h" /* get the Skein API definitions   */
 
 void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr,
                             size_t blk_cnt, size_t byte_cnt_add);
diff --git a/drivers/staging/skein/skein_generic.c b/drivers/staging/skein/skein_generic.c
new file mode 100644 (file)
index 0000000..60d16b6
--- /dev/null
@@ -0,0 +1,216 @@
+/*
+ * Cryptographic API.
+ *
+ * Skein256 Hash Algorithm.
+ *
+ * Derived from cryptoapi implementation, adapted for in-place
+ * scatterlist interface.
+ *
+ * Copyright (c) Eric Rost <eric.rost@mybabylon.net>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <crypto/internal/hash.h>
+#include "skein_base.h"
+
+
+static int skein256_init(struct shash_desc *desc)
+{
+       return skein_256_init((struct skein_256_ctx *) shash_desc_ctx(desc),
+                       SKEIN256_DIGEST_BIT_SIZE);
+}
+
+int skein256_update(struct shash_desc *desc, const u8 *data,
+                       unsigned int len)
+{
+       return skein_256_update((struct skein_256_ctx *)shash_desc_ctx(desc),
+                               data, len);
+}
+
+static int skein256_final(struct shash_desc *desc, u8 *out)
+{
+       return skein_256_final((struct skein_256_ctx *)shash_desc_ctx(desc),
+                               out);
+}
+
+static int skein256_export(struct shash_desc *desc, void *out)
+{
+       struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+       memcpy(out, sctx, sizeof(*sctx));
+       return 0;
+}
+
+static int skein256_import(struct shash_desc *desc, const void *in)
+{
+       struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+       memcpy(sctx, in, sizeof(*sctx));
+       return 0;
+}
+
+static int skein512_init(struct shash_desc *desc)
+{
+       return skein_512_init((struct skein_512_ctx *)shash_desc_ctx(desc),
+                               SKEIN512_DIGEST_BIT_SIZE);
+}
+
+int skein512_update(struct shash_desc *desc, const u8 *data,
+                       unsigned int len)
+{
+       return skein_512_update((struct skein_512_ctx *)shash_desc_ctx(desc),
+                               data, len);
+}
+
+static int skein512_final(struct shash_desc *desc, u8 *out)
+{
+       return skein_512_final((struct skein_512_ctx *)shash_desc_ctx(desc),
+                               out);
+}
+
+static int skein512_export(struct shash_desc *desc, void *out)
+{
+       struct skein_512_ctx *sctx = shash_desc_ctx(desc);
+
+       memcpy(out, sctx, sizeof(*sctx));
+       return 0;
+}
+
+static int skein512_import(struct shash_desc *desc, const void *in)
+{
+       struct skein_512_ctx *sctx = shash_desc_ctx(desc);
+
+       memcpy(sctx, in, sizeof(*sctx));
+       return 0;
+}
+
+static int skein1024_init(struct shash_desc *desc)
+{
+       return skein_1024_init((struct skein_1024_ctx *)shash_desc_ctx(desc),
+                               SKEIN1024_DIGEST_BIT_SIZE);
+}
+
+int skein1024_update(struct shash_desc *desc, const u8 *data,
+                       unsigned int len)
+{
+       return skein_1024_update((struct skein_1024_ctx *)shash_desc_ctx(desc),
+                               data, len);
+}
+
+static int skein1024_final(struct shash_desc *desc, u8 *out)
+{
+       return skein_1024_final((struct skein_1024_ctx *)shash_desc_ctx(desc),
+                       out);
+}
+
+static int skein1024_export(struct shash_desc *desc, void *out)
+{
+       struct skein_1024_ctx *sctx = shash_desc_ctx(desc);
+
+       memcpy(out, sctx, sizeof(*sctx));
+       return 0;
+}
+
+static int skein1024_import(struct shash_desc *desc, const void *in)
+{
+       struct skein_1024_ctx *sctx = shash_desc_ctx(desc);
+
+       memcpy(sctx, in, sizeof(*sctx));
+       return 0;
+}
+
+static struct shash_alg alg256 = {
+       .digestsize     =       (SKEIN256_DIGEST_BIT_SIZE / 8),
+       .init           =       skein256_init,
+       .update         =       skein256_update,
+       .final          =       skein256_final,
+       .export         =       skein256_export,
+       .import         =       skein256_import,
+       .descsize       =       sizeof(struct skein_256_ctx),
+       .statesize      =       sizeof(struct skein_256_ctx),
+       .base           =       {
+               .cra_name               =       "skein256",
+               .cra_driver_name        =       "skein",
+               .cra_flags              =       CRYPTO_ALG_TYPE_SHASH,
+               .cra_blocksize          =       SKEIN_256_BLOCK_BYTES,
+               .cra_module             =       THIS_MODULE,
+       }
+};
+
+static struct shash_alg alg512 = {
+       .digestsize     =       (SKEIN512_DIGEST_BIT_SIZE / 8),
+       .init           =       skein512_init,
+       .update         =       skein512_update,
+       .final          =       skein512_final,
+       .export         =       skein512_export,
+       .import         =       skein512_import,
+       .descsize       =       sizeof(struct skein_512_ctx),
+       .statesize      =       sizeof(struct skein_512_ctx),
+       .base           =       {
+               .cra_name               =       "skein512",
+               .cra_driver_name        =       "skein",
+               .cra_flags              =       CRYPTO_ALG_TYPE_SHASH,
+               .cra_blocksize          =       SKEIN_512_BLOCK_BYTES,
+               .cra_module             =       THIS_MODULE,
+       }
+};
+
+static struct shash_alg alg1024 = {
+       .digestsize     =       (SKEIN1024_DIGEST_BIT_SIZE / 8),
+       .init           =       skein1024_init,
+       .update         =       skein1024_update,
+       .final          =       skein1024_final,
+       .export         =       skein1024_export,
+       .import         =       skein1024_import,
+       .descsize       =       sizeof(struct skein_1024_ctx),
+       .statesize      =       sizeof(struct skein_1024_ctx),
+       .base           =       {
+               .cra_name               =       "skein1024",
+               .cra_driver_name        =       "skein",
+               .cra_flags              =       CRYPTO_ALG_TYPE_SHASH,
+               .cra_blocksize          =       SKEIN_1024_BLOCK_BYTES,
+               .cra_module             =       THIS_MODULE,
+       }
+};
+
+static int __init skein_generic_init(void)
+{
+       if (crypto_register_shash(&alg256))
+               goto out;
+       if (crypto_register_shash(&alg512))
+               goto unreg256;
+       if (crypto_register_shash(&alg1024))
+               goto unreg512;
+
+       return 0;
+
+               
+unreg512:
+       crypto_unregister_shash(&alg512);
+unreg256:
+       crypto_unregister_shash(&alg256);
+out:
+       return -1;
+}
+
+static void __exit skein_generic_fini(void)
+{
+       crypto_unregister_shash(&alg256);
+       crypto_unregister_shash(&alg512);
+       crypto_unregister_shash(&alg1024);
+}
+
+module_init(skein_generic_init);
+module_exit(skein_generic_fini);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Skein Hash Algorithm");
+
+MODULE_ALIAS("skein");
index d9dc1d5..8a06314 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef _SKEIN_IV_H_
 #define _SKEIN_IV_H_
 
-#include "skein.h"    /* get Skein macros and types */
+#include "skein_base.h"    /* get Skein macros and types */
 
 /*
 ***************** Pre-computed Skein IVs *******************
index 8d5ddf8..8e0a0b7 100644 (file)
@@ -29,7 +29,7 @@
  */
 
 #include <linux/types.h>
-#include "skein.h"
+#include "skein_base.h"
 
 #define KEY_SCHEDULE_CONST 0x1BD11BDAA9FC1A22L
 
index 56ca3b6..cff7cbe 100644 (file)
@@ -596,8 +596,7 @@ static void slic_mac_address_config(struct adapter *adapter)
        u32 value2;
        __iomem struct slic_regs *slic_regs = adapter->slic_regs;
 
-       value = *(u32 *) &adapter->currmacaddr[2];
-       value = ntohl(value);
+       value = ntohl(*(__be32 *) &adapter->currmacaddr[2]);
        slic_reg32_write(&slic_regs->slic_wraddral, value, FLUSH);
        slic_reg32_write(&slic_regs->slic_wraddrbl, value, FLUSH);
 
@@ -1612,7 +1611,7 @@ static int slic_rcvqueue_init(struct adapter *adapter)
        rcvq->size = SLIC_RCVQ_ENTRIES;
        rcvq->errors = 0;
        rcvq->count = 0;
-       i = (SLIC_RCVQ_ENTRIES / SLIC_RCVQ_FILLENTRIES);
+       i = SLIC_RCVQ_ENTRIES / SLIC_RCVQ_FILLENTRIES;
        count = 0;
        while (i) {
                count += slic_rcvqueue_fill(adapter);
@@ -1788,7 +1787,7 @@ static int slic_mcast_add_list(struct adapter *adapter, char *address)
        if (mcaddr == NULL)
                return 1;
 
-       memcpy(mcaddr->address, address, ETH_ALEN);
+       ether_addr_copy(mcaddr->address, address);
 
        mcaddr->next = adapter->mcastaddrs;
        adapter->mcastaddrs = mcaddr;
index bcc7f62..b12c76d 100644 (file)
@@ -81,7 +81,7 @@ static ssize_t chars_chartab_show(struct kobject *kobj,
 static void report_char_chartab_status(int reset, int received, int used,
        int rejected, int do_characters)
 {
-       char *object_type[] = {
+       static char const *object_type[] = {
                "character class entries",
                "character descriptions",
        };
@@ -809,10 +809,10 @@ static ssize_t message_store_helper(const char *buf, size_t count,
                        if (msg_stored == -ENOMEM)
                                reset = 1;
                        break;
-               } else {
-                       used++;
                }
 
+               used++;
+
                cp = linefeed + 1;
        }
 
index 3f30a1b..e9f0c15 100644 (file)
@@ -695,7 +695,7 @@ static void say_next_word(struct vc_data *vc)
 
 static void spell_word(struct vc_data *vc)
 {
-       static char *delay_str[] = { "", ",", ".", ". .", ". . ." };
+       static char const *delay_str[] = { "", ",", ".", ". .", ". . ." };
        char *cp = buf, *str_cap = spk_str_caps_stop;
        char *cp1, *last_cap = spk_str_caps_stop;
        u_char ch;
index d7d5152..4e059ea 100644 (file)
@@ -231,7 +231,7 @@ static void do_catch_up(struct spk_synth *synth)
                if (ch == '\n')
                        ch = PROCSPEECH;
                spk_out(ch);
-               if ((jiffies >= jiff_max) && (ch == SPACE)) {
+               if (time_after_eq(jiffies, jiff_max) && (ch == SPACE)) {
                        spk_out(PROCSPEECH);
                        spin_lock_irqsave(&speakup_info.spinlock, flags);
                        delay_time_val = delay_time->u.n.value;
index 4ed3889..cef20fd 100644 (file)
@@ -229,7 +229,7 @@ spin_lock_irqsave(&speakup_info.spinlock, flags);
                        ch = PROCSPEECH;
                outb_p(ch, synth_port);
                SWAIT;
-               if ((jiffies >= jiff_max) && (ch == SPACE)) {
+               if (time_after_eq(jiffies, jiff_max) && (ch == SPACE)) {
                        timeout = 1000;
                        while (synth_writable())
                                if (--timeout <= 0)
index b4bdee4..2fc61a7 100644 (file)
  * Return value:
  * 1 if the insertion succeeds, 0 if the queue was full.
  */
-unsigned char
-visor_signal_insert(CHANNEL_HEADER __iomem *pChannel, u32 Queue, void *pSignal)
+unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue,
+                                void *sig)
 {
        void __iomem *psignal;
        unsigned int head, tail, nof;
 
-       SIGNAL_QUEUE_HEADER __iomem *pqhdr =
-           (SIGNAL_QUEUE_HEADER __iomem *)
-               ((char __iomem *) pChannel + readq(&pChannel->oChannelSpace))
-               + Queue;
+       struct signal_queue_header __iomem *pqhdr =
+           (struct signal_queue_header __iomem *)
+               ((char __iomem *) ch + readq(&ch->ch_space_offset))
+               + queue;
 
        /* capture current head and tail */
-       head = readl(&pqhdr->Head);
-       tail = readl(&pqhdr->Tail);
+       head = readl(&pqhdr->head);
+       tail = readl(&pqhdr->tail);
 
        /* queue is full if (head + 1) % n equals tail */
-       if (((head + 1) % readl(&pqhdr->MaxSignalSlots)) == tail) {
-               nof = readq(&pqhdr->NumOverflows) + 1;
-               writeq(nof, &pqhdr->NumOverflows);
+       if (((head + 1) % readl(&pqhdr->max_slots)) == tail) {
+               nof = readq(&pqhdr->num_overflows) + 1;
+               writeq(nof, &pqhdr->num_overflows);
                return 0;
        }
 
        /* increment the head index */
-       head = (head + 1) % readl(&pqhdr->MaxSignalSlots);
+       head = (head + 1) % readl(&pqhdr->max_slots);
 
        /* copy signal to the head location from the area pointed to
         * by pSignal
         */
-       psignal = (char __iomem *)pqhdr + readq(&pqhdr->oSignalBase) +
-               (head * readl(&pqhdr->SignalSize));
-       memcpy_toio(psignal, pSignal, readl(&pqhdr->SignalSize));
+       psignal = (char __iomem *)pqhdr + readq(&pqhdr->sig_base_offset) +
+               (head * readl(&pqhdr->signal_size));
+       memcpy_toio(psignal, sig, readl(&pqhdr->signal_size));
 
        mb(); /* channel synch */
-       writel(head, &pqhdr->Head);
+       writel(head, &pqhdr->head);
 
-       writeq(readq(&pqhdr->NumSignalsSent) + 1, &pqhdr->NumSignalsSent);
+       writeq(readq(&pqhdr->num_sent) + 1, &pqhdr->num_sent);
        return 1;
 }
-EXPORT_SYMBOL_GPL(visor_signal_insert);
+EXPORT_SYMBOL_GPL(spar_signal_insert);
 
 /*
  * Routine Description:
@@ -102,40 +102,40 @@ EXPORT_SYMBOL_GPL(visor_signal_insert);
  * 1 if the removal succeeds, 0 if the queue was empty.
  */
 unsigned char
-visor_signal_remove(CHANNEL_HEADER __iomem *pChannel, u32 Queue, void *pSignal)
+spar_signal_remove(struct channel_header __iomem *ch, u32 queue, void *sig)
 {
        void __iomem *psource;
        unsigned int head, tail;
-       SIGNAL_QUEUE_HEADER __iomem *pqhdr =
-           (SIGNAL_QUEUE_HEADER __iomem *) ((char __iomem *) pChannel +
-                                   readq(&pChannel->oChannelSpace)) + Queue;
+       struct signal_queue_header __iomem *pqhdr =
+           (struct signal_queue_header __iomem *) ((char __iomem *) ch +
+                                   readq(&ch->ch_space_offset)) + queue;
 
        /* capture current head and tail */
-       head = readl(&pqhdr->Head);
-       tail = readl(&pqhdr->Tail);
+       head = readl(&pqhdr->head);
+       tail = readl(&pqhdr->tail);
 
        /* queue is empty if the head index equals the tail index */
        if (head == tail) {
-               writeq(readq(&pqhdr->NumEmptyCnt) + 1, &pqhdr->NumEmptyCnt);
+               writeq(readq(&pqhdr->num_empty) + 1, &pqhdr->num_empty);
                return 0;
        }
 
        /* advance past the 'empty' front slot */
-       tail = (tail + 1) % readl(&pqhdr->MaxSignalSlots);
+       tail = (tail + 1) % readl(&pqhdr->max_slots);
 
        /* copy signal from tail location to the area pointed to by pSignal */
-       psource = (char __iomem *) pqhdr + readq(&pqhdr->oSignalBase) +
-               (tail * readl(&pqhdr->SignalSize));
-       memcpy_fromio(pSignal, psource, readl(&pqhdr->SignalSize));
+       psource = (char __iomem *) pqhdr + readq(&pqhdr->sig_base_offset) +
+               (tail * readl(&pqhdr->signal_size));
+       memcpy_fromio(sig, psource, readl(&pqhdr->signal_size));
 
        mb(); /* channel synch */
-       writel(tail, &pqhdr->Tail);
+       writel(tail, &pqhdr->tail);
 
-       writeq(readq(&pqhdr->NumSignalsReceived) + 1,
-              &pqhdr->NumSignalsReceived);
+       writeq(readq(&pqhdr->num_received) + 1,
+              &pqhdr->num_received);
        return 1;
 }
-EXPORT_SYMBOL_GPL(visor_signal_remove);
+EXPORT_SYMBOL_GPL(spar_signal_remove);
 
 /*
  * Routine Description:
@@ -156,18 +156,18 @@ EXPORT_SYMBOL_GPL(visor_signal_remove);
  * Return value:
  * # of signals copied.
  */
-unsigned int
-SignalRemoveAll(pCHANNEL_HEADER pChannel, u32 Queue, void *pSignal)
+unsigned int spar_signal_remove_all(struct channel_header *ch, u32 queue,
+                                   void *sig)
 {
        void *psource;
-       unsigned int head, tail, signalCount = 0;
-       pSIGNAL_QUEUE_HEADER pqhdr =
-           (pSIGNAL_QUEUE_HEADER) ((char *) pChannel +
-                                   pChannel->oChannelSpace) + Queue;
+       unsigned int head, tail, count = 0;
+       struct signal_queue_header *pqhdr =
+           (struct signal_queue_header *) ((char *) ch +
+                                   ch->ch_space_offset) + queue;
 
        /* capture current head and tail */
-       head = pqhdr->Head;
-       tail = pqhdr->Tail;
+       head = pqhdr->head;
+       tail = pqhdr->tail;
 
        /* queue is empty if the head index equals the tail index */
        if (head == tail)
@@ -175,25 +175,25 @@ SignalRemoveAll(pCHANNEL_HEADER pChannel, u32 Queue, void *pSignal)
 
        while (head != tail) {
                /* advance past the 'empty' front slot */
-               tail = (tail + 1) % pqhdr->MaxSignalSlots;
+               tail = (tail + 1) % pqhdr->max_slots;
 
                /* copy signal from tail location to the area pointed
                 * to by pSignal
                 */
                psource =
-                   (char *) pqhdr + pqhdr->oSignalBase +
-                   (tail * pqhdr->SignalSize);
-               memcpy((char *) pSignal + (pqhdr->SignalSize * signalCount),
-                      psource, pqhdr->SignalSize);
+                   (char *) pqhdr + pqhdr->sig_base_offset +
+                   (tail * pqhdr->signal_size);
+               memcpy((char *) sig + (pqhdr->signal_size * count),
+                      psource, pqhdr->signal_size);
 
                mb(); /* channel synch */
-               pqhdr->Tail = tail;
+               pqhdr->tail = tail;
 
-               signalCount++;
-               pqhdr->NumSignalsReceived++;
+               count++;
+               pqhdr->num_received++;
        }
 
-       return signalCount;
+       return count;
 }
 
 /*
@@ -207,13 +207,13 @@ SignalRemoveAll(pCHANNEL_HEADER pChannel, u32 Queue, void *pSignal)
  * Return value:
  * 1 if the signal queue is empty, 0 otherwise.
  */
-unsigned char
-visor_signalqueue_empty(CHANNEL_HEADER __iomem *pChannel, u32 Queue)
+unsigned char spar_signalqueue_empty(struct channel_header __iomem *ch,
+                                    u32 queue)
 {
-       SIGNAL_QUEUE_HEADER __iomem *pqhdr =
-           (SIGNAL_QUEUE_HEADER __iomem *) ((char __iomem *) pChannel +
-                                   readq(&pChannel->oChannelSpace)) + Queue;
-       return readl(&pqhdr->Head) == readl(&pqhdr->Tail);
+       struct signal_queue_header __iomem *pqhdr =
+           (struct signal_queue_header __iomem *) ((char __iomem *) ch +
+                                   readq(&ch->ch_space_offset)) + queue;
+       return readl(&pqhdr->head) == readl(&pqhdr->tail);
 }
-EXPORT_SYMBOL_GPL(visor_signalqueue_empty);
+EXPORT_SYMBOL_GPL(spar_signalqueue_empty);
 
index d54c5d6..b6fd126 100644 (file)
@@ -42,26 +42,26 @@ channel_mod_exit(void)
 }
 
 unsigned char
-SignalInsert_withLock(CHANNEL_HEADER __iomem *pChannel, u32 Queue,
+SignalInsert_withLock(struct channel_header __iomem *pChannel, u32 Queue,
                      void *pSignal, spinlock_t *lock)
 {
        unsigned char result;
        unsigned long flags;
 
        spin_lock_irqsave(lock, flags);
-       result = visor_signal_insert(pChannel, Queue, pSignal);
+       result = spar_signal_insert(pChannel, Queue, pSignal);
        spin_unlock_irqrestore(lock, flags);
        return result;
 }
 
 unsigned char
-SignalRemove_withLock(CHANNEL_HEADER __iomem *pChannel, u32 Queue,
+SignalRemove_withLock(struct channel_header __iomem *pChannel, u32 Queue,
                      void *pSignal, spinlock_t *lock)
 {
        unsigned char result;
 
        spin_lock(lock);
-       result = visor_signal_remove(pChannel, Queue, pSignal);
+       result = spar_signal_remove(pChannel, Queue, pSignal);
        spin_unlock(lock);
        return result;
 }
index d08e2c6..1531759 100644 (file)
@@ -15,9 +15,9 @@
 
 #ifndef __CHANSTUB_H__
 #define __CHANSTUB_H__
-unsigned char SignalInsert_withLock(CHANNEL_HEADER __iomem *pChannel, u32 Queue,
-                                    void *pSignal, spinlock_t *lock);
-unsigned char SignalRemove_withLock(CHANNEL_HEADER __iomem *pChannel, u32 Queue,
-                                    void *pSignal, spinlock_t *lock);
+unsigned char SignalInsert_withLock(struct channel_header __iomem *pChannel,
+                                   u32 Queue, void *pSignal, spinlock_t *lock);
+unsigned char SignalRemove_withLock(struct channel_header __iomem *pChannel,
+                                   u32 Queue, void *pSignal, spinlock_t *lock);
 
 #endif
index c25dfbf..6fb6e5b 100644 (file)
 
 #define ULTRA_CHANNEL_PROTOCOL_SIGNATURE  SIGNATURE_32('E', 'C', 'N', 'L')
 
-#define CHANNEL_GUID_MISMATCH(chType, chName, field, expected, actual, fil, \
-                             lin, logCtx)                              \
-       do {                                                            \
-               pr_err("Channel mismatch on channel=%s(%pUL) field=%s expected=%pUL actual=%pUL @%s:%d\n", \
-                      chName, &chType, field,  \
-                      &expected, &actual, \
-                      fil, lin);                                       \
-       } while (0)
-#define CHANNEL_U32_MISMATCH(chType, chName, field, expected, actual, fil, \
-                            lin, logCtx)                               \
-       do {                                                            \
-               pr_err("Channel mismatch on channel=%s(%pUL) field=%s expected=0x%-8.8lx actual=0x%-8.8lx @%s:%d\n", \
-                      chName, &chType, field,  \
-                      (unsigned long)expected, (unsigned long)actual,  \
-                      fil, lin);                                       \
-       } while (0)
-
-#define CHANNEL_U64_MISMATCH(chType, chName, field, expected, actual, fil, \
-                            lin, logCtx)                               \
-       do {                                                            \
-               pr_err("Channel mismatch on channel=%s(%pUL) field=%s expected=0x%-8.8Lx actual=0x%-8.8Lx @%s:%d\n", \
-                      chName, &chType, field,  \
-                      (unsigned long long)expected,                    \
-                      (unsigned long long)actual,                      \
-                      fil, lin);                                       \
-       } while (0)
-
-#define UltraLogEvent(logCtx, EventId, Severity, SubsystemMask, pFunctionName, \
-                     LineNumber, Str, args...)                         \
-       pr_info(Str, ## args)
-
-typedef enum {
+enum channel_serverstate {
        CHANNELSRV_UNINITIALIZED = 0,   /* channel is in an undefined state */
        CHANNELSRV_READY = 1    /* channel has been initialized by server */
-} CHANNEL_SERVERSTATE;
+};
 
-typedef enum {
+enum channel_clientstate {
        CHANNELCLI_DETACHED = 0,
        CHANNELCLI_DISABLED = 1,        /* client can see channel but is NOT
                                         * allowed to use it unless given TBD
@@ -100,32 +69,32 @@ typedef enum {
                                 * using channel */
        CHANNELCLI_OWNED = 5    /* "no worries" state - client can
                                 * access channel anytime */
-} CHANNEL_CLIENTSTATE;
+};
+
 static inline const u8 *
 ULTRA_CHANNELCLI_STRING(u32 v)
 {
        switch (v) {
        case CHANNELCLI_DETACHED:
-               return (const u8 *) ("DETACHED");
+               return (const u8 *)("DETACHED");
        case CHANNELCLI_DISABLED:
-               return (const u8 *) ("DISABLED");
+               return (const u8 *)("DISABLED");
        case CHANNELCLI_ATTACHING:
-               return (const u8 *) ("ATTACHING");
+               return (const u8 *)("ATTACHING");
        case CHANNELCLI_ATTACHED:
-               return (const u8 *) ("ATTACHED");
+               return (const u8 *)("ATTACHED");
        case CHANNELCLI_BUSY:
-               return (const u8 *) ("BUSY");
+               return (const u8 *)("BUSY");
        case CHANNELCLI_OWNED:
-               return (const u8 *) ("OWNED");
+               return (const u8 *)("OWNED");
        default:
                break;
        }
-       return (const u8 *) ("?");
+       return (const u8 *)("?");
 }
 
-#define ULTRA_CHANNELSRV_IS_READY(x)     ((x) == CHANNELSRV_READY)
-#define ULTRA_CHANNEL_SERVER_READY(pChannel) \
-       (ULTRA_CHANNELSRV_IS_READY(readl(&(pChannel)->SrvState)))
+#define SPAR_CHANNEL_SERVER_READY(ch) \
+       (readl(&(ch)->srv_state) == CHANNELSRV_READY)
 
 #define ULTRA_VALID_CHANNELCLI_TRANSITION(o, n)                                \
        (((((o) == CHANNELCLI_DETACHED) && ((n) == CHANNELCLI_DISABLED)) || \
@@ -145,60 +114,41 @@ ULTRA_CHANNELCLI_STRING(u32 v)
          (((o) == CHANNELCLI_BUSY) && ((n) == CHANNELCLI_OWNED)) || (0)) \
         ? (1) : (0))
 
-#define ULTRA_CHANNEL_CLIENT_CHK_TRANSITION(old, new, chanId, logCtx,  \
+#define SPAR_CHANNEL_CLIENT_CHK_TRANSITION(old, new, id, log,  \
                                            file, line)                 \
        do {                                                            \
                if (!ULTRA_VALID_CHANNELCLI_TRANSITION(old, new))       \
-                       UltraLogEvent(logCtx,                           \
-                                     CHANNELSTATE_DIAG_EVENTID_TRANSITERR, \
-                                     CHANNELSTATE_DIAG_SEVERITY, \
-                                     CHANNELSTATE_DIAG_SUBSYS,         \
-                                     __func__, __LINE__,               \
-                                     "%s Channel StateTransition INVALID! (%s) %s(%d)-->%s(%d) @%s:%d\n", \
-                                     chanId, "CliState<x>",            \
-                                     ULTRA_CHANNELCLI_STRING(old),     \
-                                     old,                              \
-                                     ULTRA_CHANNELCLI_STRING(new),     \
-                                     new,                              \
-                                     PathName_Last_N_Nodes((u8 *)file, 4), \
-                                     line);                            \
+                       pr_info("%s Channel StateTransition INVALID! (%s) %s(%d)-->%s(%d) @%s:%d\n", \
+                               id, "CliState<x>",              \
+                               ULTRA_CHANNELCLI_STRING(old),   \
+                               old,                            \
+                               ULTRA_CHANNELCLI_STRING(new),   \
+                               new,                            \
+                               pathname_last_n_nodes((u8 *)file, 4), \
+                               line);                          \
        } while (0)
 
-#define ULTRA_CHANNEL_CLIENT_TRANSITION(pChan, chanId,                 \
-                                       newstate, logCtx)               \
+#define SPAR_CHANNEL_CLIENT_TRANSITION(ch, id, newstate, log)          \
        do {                                                            \
-               ULTRA_CHANNEL_CLIENT_CHK_TRANSITION(                    \
-                       readl(&(((CHANNEL_HEADER __iomem *) \
-                                (pChan))->CliStateOS)),                \
-                       newstate,                                       \
-                       chanId, logCtx, __FILE__, __LINE__);            \
-               UltraLogEvent(logCtx, CHANNELSTATE_DIAG_EVENTID_TRANSITOK, \
-                       CHANNELSTATE_DIAG_SEVERITY, \
-                             CHANNELSTATE_DIAG_SUBSYS,                 \
-                             __func__, __LINE__,                       \
-                             "%s Channel StateTransition (%s) %s(%d)-->%s(%d) @%s:%d\n", \
-                             chanId, "CliStateOS",                     \
-                             ULTRA_CHANNELCLI_STRING( \
-                                     readl(&((CHANNEL_HEADER __iomem *) \
-                                             (pChan))->CliStateOS)),   \
-                             readl(&((CHANNEL_HEADER __iomem *) \
-                                     (pChan))->CliStateOS),            \
-                             ULTRA_CHANNELCLI_STRING(newstate),        \
-                             newstate,                                 \
-                             PathName_Last_N_Nodes(__FILE__, 4), __LINE__); \
-               writel(newstate, &((CHANNEL_HEADER __iomem *) \
-                                  (pChan))->CliStateOS);               \
+               SPAR_CHANNEL_CLIENT_CHK_TRANSITION(                     \
+                       readl(&(((struct channel_header __iomem *)\
+                                (ch))->cli_state_os)),         \
+                       newstate, id, log, __FILE__, __LINE__);         \
+                       pr_info("%s Channel StateTransition (%s) %s(%d)-->%s(%d) @%s:%d\n", \
+                               id, "CliStateOS",                       \
+                               ULTRA_CHANNELCLI_STRING( \
+                                     readl(&((struct channel_header __iomem *)\
+                                             (ch))->cli_state_os)),    \
+                               readl(&((struct channel_header __iomem *)\
+                                     (ch))->cli_state_os),             \
+                               ULTRA_CHANNELCLI_STRING(newstate),      \
+                               newstate,                               \
+                               pathname_last_n_nodes(__FILE__, 4), __LINE__); \
+               writel(newstate, &((struct channel_header __iomem *)\
+                                  (ch))->cli_state_os);                \
                mb(); /* required for channel synch */                  \
        } while (0)
 
-#define ULTRA_CHANNEL_CLIENT_ACQUIRE_OS(pChan, chanId, logCtx) \
-       ULTRA_channel_client_acquire_os(pChan, chanId, logCtx,          \
-                                       (char *)__FILE__, __LINE__,     \
-                                       (char *)__func__)
-#define ULTRA_CHANNEL_CLIENT_RELEASE_OS(pChan, chanId, logCtx) \
-       ULTRA_channel_client_release_os(pChan, chanId, logCtx,  \
-               (char *)__FILE__, __LINE__, (char *)__func__)
-
 /* Values for ULTRA_CHANNEL_PROTOCOL.CliErrorBoot: */
 /* throttling invalid boot channel statetransition error due to client
  * disabled */
@@ -239,98 +189,98 @@ ULTRA_CHANNELCLI_STRING(u32 v)
 
 #pragma pack(push, 1)          /* both GCC and VC now allow this pragma */
 /* Common Channel Header */
-typedef struct _CHANNEL_HEADER {
-       u64 Signature;          /* Signature */
-       u32 LegacyState;        /* DEPRECATED - being replaced by */
+struct channel_header {
+       u64 signature;          /* Signature */
+       u32 legacy_state;       /* DEPRECATED - being replaced by */
        /* /              SrvState, CliStateBoot, and CliStateOS below */
-       u32 HeaderSize;         /* sizeof(CHANNEL_HEADER) */
-       u64 Size;               /* Total size of this channel in bytes */
-       u64 Features;           /* Flags to modify behavior */
-       uuid_le Type;           /* Channel type: data, bus, control, etc. */
-       u64 PartitionHandle;    /* ID of guest partition */
-       u64 Handle;             /* Device number of this channel in client */
-       u64 oChannelSpace;      /* Offset in bytes to channel specific area */
-       u32 VersionId;          /* CHANNEL_HEADER Version ID */
-       u32 PartitionIndex;     /* Index of guest partition */
-       uuid_le ZoneGuid;               /* Guid of Channel's zone */
-       u32 oClientString;      /* offset from channel header to
+       u32 header_size;        /* sizeof(struct channel_header) */
+       u64 size;               /* Total size of this channel in bytes */
+       u64 features;           /* Flags to modify behavior */
+       uuid_le chtype;         /* Channel type: data, bus, control, etc. */
+       u64 partition_handle;   /* ID of guest partition */
+       u64 handle;             /* Device number of this channel in client */
+       u64 ch_space_offset;    /* Offset in bytes to channel specific area */
+       u32 version_id;         /* struct channel_header Version ID */
+       u32 partition_index;    /* Index of guest partition */
+       uuid_le zone_uuid;      /* Guid of Channel's zone */
+       u32 cli_str_offset;     /* offset from channel header to
                                 * nul-terminated ClientString (0 if
                                 * ClientString not present) */
-       u32 CliStateBoot;       /* CHANNEL_CLIENTSTATE of pre-boot
+       u32 cli_state_boot;     /* CHANNEL_CLIENTSTATE of pre-boot
                                 * EFI client of this channel */
-       u32 CmdStateCli;        /* CHANNEL_COMMANDSTATE (overloaded in
+       u32 cmd_state_cli;      /* CHANNEL_COMMANDSTATE (overloaded in
                                 * Windows drivers, see ServerStateUp,
                                 * ServerStateDown, etc) */
-       u32 CliStateOS;         /* CHANNEL_CLIENTSTATE of Guest OS
+       u32 cli_state_os;       /* CHANNEL_CLIENTSTATE of Guest OS
                                 * client of this channel */
-       u32 ChannelCharacteristics;     /* CHANNEL_CHARACTERISTIC_<xxx> */
-       u32 CmdStateSrv;        /* CHANNEL_COMMANDSTATE (overloaded in
+       u32 ch_characteristic;  /* CHANNEL_CHARACTERISTIC_<xxx> */
+       u32 cmd_state_srv;      /* CHANNEL_COMMANDSTATE (overloaded in
                                 * Windows drivers, see ServerStateUp,
                                 * ServerStateDown, etc) */
-       u32 SrvState;           /* CHANNEL_SERVERSTATE */
-       u8 CliErrorBoot;        /* bits to indicate err states for
+       u32 srv_state;          /* CHANNEL_SERVERSTATE */
+       u8 cli_error_boot;      /* bits to indicate err states for
                                 * boot clients, so err messages can
                                 * be throttled */
-       u8 CliErrorOS;          /* bits to indicate err states for OS
+       u8 cli_error_os;        /* bits to indicate err states for OS
                                 * clients, so err messages can be
                                 * throttled */
-       u8 Filler[1];           /* Pad out to 128 byte cacheline */
+       u8 filler[1];           /* Pad out to 128 byte cacheline */
        /* Please add all new single-byte values below here */
-       u8 RecoverChannel;
-} CHANNEL_HEADER, *pCHANNEL_HEADER, ULTRA_CHANNEL_PROTOCOL;
+       u8 recover_channel;
+};
 
 #define ULTRA_CHANNEL_ENABLE_INTS (0x1ULL << 0)
 
 /* Subheader for the Signal Type variation of the Common Channel */
-typedef struct _SIGNAL_QUEUE_HEADER {
+struct signal_queue_header {
        /* 1st cache line */
-       u32 VersionId;          /* SIGNAL_QUEUE_HEADER Version ID */
-       u32 Type;               /* Queue type: storage, network */
-       u64 Size;               /* Total size of this queue in bytes */
-       u64 oSignalBase;        /* Offset to signal queue area */
-       u64 FeatureFlags;       /* Flags to modify behavior */
-       u64 NumSignalsSent;     /* Total # of signals placed in this queue */
-       u64 NumOverflows;       /* Total # of inserts failed due to
+       u32 version;            /* SIGNAL_QUEUE_HEADER Version ID */
+       u32 chtype;             /* Queue type: storage, network */
+       u64 size;               /* Total size of this queue in bytes */
+       u64 sig_base_offset;    /* Offset to signal queue area */
+       u64 features;           /* Flags to modify behavior */
+       u64 num_sent;           /* Total # of signals placed in this queue */
+       u64 num_overflows;      /* Total # of inserts failed due to
                                 * full queue */
-       u32 SignalSize;         /* Total size of a signal for this queue */
-       u32 MaxSignalSlots;     /* Max # of slots in queue, 1 slot is
+       u32 signal_size;        /* Total size of a signal for this queue */
+       u32 max_slots;          /* Max # of slots in queue, 1 slot is
                                 * always empty */
-       u32 MaxSignals;         /* Max # of signals in queue
+       u32 max_signals;        /* Max # of signals in queue
                                 * (MaxSignalSlots-1) */
-       u32 Head;               /* Queue head signal # */
+       u32 head;               /* Queue head signal # */
        /* 2nd cache line */
-       u64 NumSignalsReceived; /* Total # of signals removed from this queue */
-       u32 Tail;               /* Queue tail signal # (on separate
+       u64 num_received;       /* Total # of signals removed from this queue */
+       u32 tail;               /* Queue tail signal # (on separate
                                 * cache line) */
-       u32 Reserved1;          /* Reserved field */
-       u64 Reserved2;          /* Resrved field */
-       u64 ClientQueue;
-       u64 NumInterruptsReceived;      /* Total # of Interrupts received.  This
+       u32 reserved1;          /* Reserved field */
+       u64 reserved2;          /* Reserved field */
+       u64 client_queue;
+       u64 num_irq_received;   /* Total # of Interrupts received.  This
                                         * is incremented by the ISR in the
                                         * guest windows driver */
-       u64 NumEmptyCnt;        /* Number of times that visor_signal_remove
+       u64 num_empty;          /* Number of times that visor_signal_remove
                                 * is called and returned Empty
                                 * Status. */
-       u32 ErrorFlags;         /* Error bits set during SignalReinit
+       u32 errorflags;         /* Error bits set during SignalReinit
                                 * to denote trouble with client's
                                 * fields */
-       u8 Filler[12];          /* Pad out to 64 byte cacheline */
-} SIGNAL_QUEUE_HEADER, *pSIGNAL_QUEUE_HEADER;
+       u8 filler[12];          /* Pad out to 64 byte cacheline */
+};
 
 #pragma pack(pop)
 
-#define SignalInit(chan, QHDRFLD, QDATAFLD, QDATATYPE, ver, typ)       \
+#define spar_signal_init(chan, QHDRFLD, QDATAFLD, QDATATYPE, ver, typ) \
        do {                                                            \
                memset(&chan->QHDRFLD, 0, sizeof(chan->QHDRFLD));       \
-               chan->QHDRFLD.VersionId = ver;                          \
-               chan->QHDRFLD.Type = typ;                               \
-               chan->QHDRFLD.Size = sizeof(chan->QDATAFLD);            \
-               chan->QHDRFLD.SignalSize = sizeof(QDATATYPE);           \
-               chan->QHDRFLD.oSignalBase = (u64)(chan->QDATAFLD)-      \
+               chan->QHDRFLD.version = ver;                            \
+               chan->QHDRFLD.chtype = typ;                             \
+               chan->QHDRFLD.size = sizeof(chan->QDATAFLD);            \
+               chan->QHDRFLD.signal_size = sizeof(QDATATYPE);          \
+               chan->QHDRFLD.sig_base_offset = (u64)(chan->QDATAFLD)-  \
                        (u64)(&chan->QHDRFLD);                          \
-               chan->QHDRFLD.MaxSignalSlots =                          \
+               chan->QHDRFLD.max_slots =                               \
                        sizeof(chan->QDATAFLD)/sizeof(QDATATYPE);       \
-               chan->QHDRFLD.MaxSignals = chan->QHDRFLD.MaxSignalSlots-1; \
+               chan->QHDRFLD.max_signals = chan->QHDRFLD.max_slots-1;  \
        } while (0)
 
 /* Generic function useful for validating any type of channel when it is
@@ -339,64 +289,62 @@ typedef struct _SIGNAL_QUEUE_HEADER {
  * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
  */
 static inline int
-ULTRA_check_channel_client(void __iomem *pChannel,
-                          uuid_le expectedTypeGuid,
-                          char *channelName,
-                          u64 expectedMinBytes,
-                          u32 expectedVersionId,
-                          u64 expectedSignature,
-                          char *fileName, int lineNumber, void *logCtx)
+spar_check_channel_client(void __iomem *ch,
+                         uuid_le expected_uuid,
+                         char *chname,
+                         u64 expected_min_bytes,
+                         u32 expected_version,
+                         u64 expected_signature)
 {
-       if (uuid_le_cmp(expectedTypeGuid, NULL_UUID_LE) != 0) {
+       if (uuid_le_cmp(expected_uuid, NULL_UUID_LE) != 0) {
                uuid_le guid;
 
                memcpy_fromio(&guid,
-                             &((CHANNEL_HEADER __iomem *)(pChannel))->Type,
+                             &((struct channel_header __iomem *)(ch))->chtype,
                              sizeof(guid));
                /* caller wants us to verify type GUID */
-               if (uuid_le_cmp(guid, expectedTypeGuid) != 0) {
-                       CHANNEL_GUID_MISMATCH(expectedTypeGuid, channelName,
-                                             "type", expectedTypeGuid,
-                                             guid, fileName,
-                                             lineNumber, logCtx);
+               if (uuid_le_cmp(guid, expected_uuid) != 0) {
+                       pr_err("Channel mismatch on channel=%s(%pUL) field=type expected=%pUL actual=%pUL\n",
+                              chname, &expected_uuid,
+                              &expected_uuid, &guid);
                        return 0;
                }
        }
-       if (expectedMinBytes > 0)       /* caller wants us to verify
+       if (expected_min_bytes > 0) {   /* caller wants us to verify
                                         * channel size */
-               if (readq(&((CHANNEL_HEADER __iomem *)
-                          (pChannel))->Size) < expectedMinBytes) {
-                       CHANNEL_U64_MISMATCH(expectedTypeGuid, channelName,
-                                            "size", expectedMinBytes,
-                                            readq(&((CHANNEL_HEADER __iomem *)
-                                                    (pChannel))->Size),
-                                            fileName,
-                                            lineNumber, logCtx);
+               unsigned long long bytes =
+                               readq(&((struct channel_header __iomem *)
+                                       (ch))->size);
+               if (bytes < expected_min_bytes) {
+                       pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8Lx actual=0x%-8.8Lx\n",
+                              chname, &expected_uuid,
+                              (unsigned long long)expected_min_bytes, bytes);
                        return 0;
                }
-       if (expectedVersionId > 0)      /* caller wants us to verify
+       }
+       if (expected_version > 0) {     /* caller wants us to verify
                                         * channel version */
-               if (readl(&((CHANNEL_HEADER __iomem *) (pChannel))->VersionId)
-                   != expectedVersionId) {
-                       CHANNEL_U32_MISMATCH(expectedTypeGuid, channelName,
-                                            "version", expectedVersionId,
-                                            readl(&((CHANNEL_HEADER __iomem *)
-                                                    (pChannel))->VersionId),
-                                            fileName, lineNumber, logCtx);
+               unsigned long ver = readl(&((struct channel_header __iomem *)
+                                   (ch))->version_id);
+               if (ver != expected_version) {
+                       pr_err("Channel mismatch on channel=%s(%pUL) field=version expected=0x%-8.8lx actual=0x%-8.8lx\n",
+                              chname, &expected_uuid,
+                              (unsigned long)expected_version, ver);
                        return 0;
                }
-       if (expectedSignature > 0)      /* caller wants us to verify
+       }
+       if (expected_signature > 0) {   /* caller wants us to verify
                                         * channel signature */
-               if (readq(&((CHANNEL_HEADER __iomem *) (pChannel))->Signature)
-                   != expectedSignature) {
-                       CHANNEL_U64_MISMATCH(expectedTypeGuid, channelName,
-                                            "signature", expectedSignature,
-                                            readq(&((CHANNEL_HEADER __iomem *)
-                                                    (pChannel))->Signature),
-                                            fileName,
-                                            lineNumber, logCtx);
+               unsigned long long sig =
+                               readq(&((struct channel_header __iomem *)
+                                       (ch))->signature);
+               if (sig != expected_signature) {
+                       pr_err("Channel mismatch on channel=%s(%pUL) field=signature expected=0x%-8.8llx actual=0x%-8.8llx\n",
+                              chname, &expected_uuid,
+                              expected_signature, sig);
                        return 0;
                }
+       }
        return 1;
 }
 
@@ -405,19 +353,16 @@ ULTRA_check_channel_client(void __iomem *pChannel,
  * Note that <logCtx> is only needed for callers in the EFI environment, and
  * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
  */
-static inline int
-ULTRA_check_channel_server(uuid_le typeGuid,
-                          char *channelName,
-                          u64 expectedMinBytes,
-                          u64 actualBytes,
-                          char *fileName, int lineNumber, void *logCtx)
+static inline int spar_check_channel_server(uuid_le typeuuid, char *name,
+                                           u64 expected_min_bytes,
+                                           u64 actual_bytes)
 {
-       if (expectedMinBytes > 0)       /* caller wants us to verify
+       if (expected_min_bytes > 0)     /* caller wants us to verify
                                         * channel size */
-               if (actualBytes < expectedMinBytes) {
-                       CHANNEL_U64_MISMATCH(typeGuid, channelName, "size",
-                                            expectedMinBytes, actualBytes,
-                                            fileName, lineNumber, logCtx);
+               if (actual_bytes < expected_min_bytes) {
+                       pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8llx actual=0x%-8.8llx\n",
+                              name, &typeuuid, expected_min_bytes,
+                              actual_bytes);
                        return 0;
                }
        return 1;
@@ -430,7 +375,7 @@ ULTRA_check_channel_server(uuid_le typeGuid,
  * in it, the return pointer will be to the beginning of the string.
  */
 static inline u8 *
-PathName_Last_N_Nodes(u8 *s, unsigned int n)
+pathname_last_n_nodes(u8 *s, unsigned int n)
 {
        u8 *p = s;
        unsigned int node_count = 0;
@@ -455,59 +400,43 @@ PathName_Last_N_Nodes(u8 *s, unsigned int n)
 }
 
 static inline int
-ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId,
-                               void *logCtx, char *file, int line, char *func)
+spar_channel_client_acquire_os(void __iomem *ch, u8 *id)
 {
-       CHANNEL_HEADER __iomem *pChan = pChannel;
+       struct channel_header __iomem *hdr = ch;
 
-       if (readl(&pChan->CliStateOS) == CHANNELCLI_DISABLED) {
-               if ((readb(&pChan->CliErrorOS)
+       if (readl(&hdr->cli_state_os) == CHANNELCLI_DISABLED) {
+               if ((readb(&hdr->cli_error_os)
                     & ULTRA_CLIERROROS_THROTTLEMSG_DISABLED) == 0) {
                        /* we are NOT throttling this message */
-                       writeb(readb(&pChan->CliErrorOS) |
+                       writeb(readb(&hdr->cli_error_os) |
                               ULTRA_CLIERROROS_THROTTLEMSG_DISABLED,
-                              &pChan->CliErrorOS);
+                              &hdr->cli_error_os);
                        /* throttle until acquire successful */
 
-                       UltraLogEvent(logCtx,
-                                     CHANNELSTATE_DIAG_EVENTID_TRANSITERR,
-                                     CHANNELSTATE_DIAG_SEVERITY,
-                                     CHANNELSTATE_DIAG_SUBSYS, func, line,
-                                     "%s Channel StateTransition INVALID! - acquire failed because OS client DISABLED @%s:%d\n",
-                                     chanId, PathName_Last_N_Nodes(
-                                             (u8 *) file, 4), line);
+                       pr_info("%s Channel StateTransition INVALID! - acquire failed because OS client DISABLED\n",
+                               id);
                }
                return 0;
        }
-       if ((readl(&pChan->CliStateOS) != CHANNELCLI_OWNED)
-           && (readl(&pChan->CliStateBoot) == CHANNELCLI_DISABLED)) {
+       if ((readl(&hdr->cli_state_os) != CHANNELCLI_OWNED) &&
+           (readl(&hdr->cli_state_boot) == CHANNELCLI_DISABLED)) {
                /* Our competitor is DISABLED, so we can transition to OWNED */
-               UltraLogEvent(logCtx, CHANNELSTATE_DIAG_EVENTID_TRANSITOK,
-                             CHANNELSTATE_DIAG_SEVERITY,
-                             CHANNELSTATE_DIAG_SUBSYS, func, line,
-                             "%s Channel StateTransition (%s) %s(%d)-->%s(%d) @%s:%d\n",
-                             chanId, "CliStateOS",
-                             ULTRA_CHANNELCLI_STRING(
-                                     readl(&pChan->CliStateOS)),
-                             readl(&pChan->CliStateOS),
-                             ULTRA_CHANNELCLI_STRING(CHANNELCLI_OWNED),
-                             CHANNELCLI_OWNED,
-                             PathName_Last_N_Nodes((u8 *) file, 4), line);
-               writel(CHANNELCLI_OWNED, &pChan->CliStateOS);
+               pr_info("%s Channel StateTransition (%s) %s(%d)-->%s(%d)\n",
+                       id, "cli_state_os",
+                       ULTRA_CHANNELCLI_STRING(readl(&hdr->cli_state_os)),
+                       readl(&hdr->cli_state_os),
+                       ULTRA_CHANNELCLI_STRING(CHANNELCLI_OWNED),
+                       CHANNELCLI_OWNED);
+               writel(CHANNELCLI_OWNED, &hdr->cli_state_os);
                mb(); /* required for channel synch */
        }
-       if (readl(&pChan->CliStateOS) == CHANNELCLI_OWNED) {
-               if (readb(&pChan->CliErrorOS) != 0) {
+       if (readl(&hdr->cli_state_os) == CHANNELCLI_OWNED) {
+               if (readb(&hdr->cli_error_os) != 0) {
                        /* we are in an error msg throttling state;
                         * come out of it */
-                       UltraLogEvent(logCtx,
-                                     CHANNELSTATE_DIAG_EVENTID_TRANSITOK,
-                                     CHANNELSTATE_DIAG_SEVERITY,
-                                     CHANNELSTATE_DIAG_SUBSYS, func, line,
-                                     "%s Channel OS client acquire now successful @%s:%d\n",
-                                     chanId, PathName_Last_N_Nodes((u8 *) file,
-                                                                   4), line);
-                       writeb(0, &pChan->CliErrorOS);
+                       pr_info("%s Channel OS client acquire now successful\n",
+                               id);
+                       writeb(0, &hdr->cli_error_os);
                }
                return 1;
        }
@@ -515,95 +444,67 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId,
        /* We have to do it the "hard way".  We transition to BUSY,
        * and can use the channel iff our competitor has not also
        * transitioned to BUSY. */
-       if (readl(&pChan->CliStateOS) != CHANNELCLI_ATTACHED) {
-               if ((readb(&pChan->CliErrorOS)
+       if (readl(&hdr->cli_state_os) != CHANNELCLI_ATTACHED) {
+               if ((readb(&hdr->cli_error_os)
                     & ULTRA_CLIERROROS_THROTTLEMSG_NOTATTACHED) == 0) {
                        /* we are NOT throttling this message */
-                       writeb(readb(&pChan->CliErrorOS) |
+                       writeb(readb(&hdr->cli_error_os) |
                               ULTRA_CLIERROROS_THROTTLEMSG_NOTATTACHED,
-                              &pChan->CliErrorOS);
+                              &hdr->cli_error_os);
                        /* throttle until acquire successful */
-                       UltraLogEvent(logCtx,
-                                     CHANNELSTATE_DIAG_EVENTID_TRANSITERR,
-                                     CHANNELSTATE_DIAG_SEVERITY,
-                                     CHANNELSTATE_DIAG_SUBSYS, func, line,
-                                     "%s Channel StateTransition INVALID! - acquire failed because OS client NOT ATTACHED (state=%s(%d)) @%s:%d\n",
-                                     chanId,
-                                     ULTRA_CHANNELCLI_STRING(
-                                             readl(&pChan->CliStateOS)),
-                                     readl(&pChan->CliStateOS),
-                                     PathName_Last_N_Nodes((u8 *) file, 4),
-                                     line);
+                       pr_info("%s Channel StateTransition INVALID! - acquire failed because OS client NOT ATTACHED (state=%s(%d))\n",
+                               id, ULTRA_CHANNELCLI_STRING(
+                                               readl(&hdr->cli_state_os)),
+                               readl(&hdr->cli_state_os));
                }
                return 0;
        }
-       writel(CHANNELCLI_BUSY, &pChan->CliStateOS);
+       writel(CHANNELCLI_BUSY, &hdr->cli_state_os);
        mb(); /* required for channel synch */
-       if (readl(&pChan->CliStateBoot) == CHANNELCLI_BUSY) {
-               if ((readb(&pChan->CliErrorOS)
+       if (readl(&hdr->cli_state_boot) == CHANNELCLI_BUSY) {
+               if ((readb(&hdr->cli_error_os)
                     & ULTRA_CLIERROROS_THROTTLEMSG_BUSY) == 0) {
                        /* we are NOT throttling this message */
-                       writeb(readb(&pChan->CliErrorOS) |
+                       writeb(readb(&hdr->cli_error_os) |
                               ULTRA_CLIERROROS_THROTTLEMSG_BUSY,
-                              &pChan->CliErrorOS);
+                              &hdr->cli_error_os);
                        /* throttle until acquire successful */
-                       UltraLogEvent(logCtx,
-                                     CHANNELSTATE_DIAG_EVENTID_TRANSITBUSY,
-                                     CHANNELSTATE_DIAG_SEVERITY,
-                                     CHANNELSTATE_DIAG_SUBSYS, func, line,
-                                     "%s Channel StateTransition failed - host OS acquire failed because boot BUSY @%s:%d\n",
-                                     chanId, PathName_Last_N_Nodes((u8 *) file,
-                                                                   4), line);
+                       pr_info("%s Channel StateTransition failed - host OS acquire failed because boot BUSY\n",
+                               id);
                }
                /* reset busy */
-               writel(CHANNELCLI_ATTACHED, &pChan->CliStateOS);
+               writel(CHANNELCLI_ATTACHED, &hdr->cli_state_os);
                mb(); /* required for channel synch */
                return 0;
        }
-       if (readb(&pChan->CliErrorOS) != 0) {
+       if (readb(&hdr->cli_error_os) != 0) {
                /* we are in an error msg throttling state; come out of it */
-               UltraLogEvent(logCtx, CHANNELSTATE_DIAG_EVENTID_TRANSITOK,
-                             CHANNELSTATE_DIAG_SEVERITY,
-                             CHANNELSTATE_DIAG_SUBSYS, func, line,
-                             "%s Channel OS client acquire now successful @%s:%d\n",
-                             chanId, PathName_Last_N_Nodes((u8 *) file, 4),
-                             line);
-               writeb(0, &pChan->CliErrorOS);
+               pr_info("%s Channel OS client acquire now successful\n", id);
+               writeb(0, &hdr->cli_error_os);
        }
        return 1;
 }
 
 static inline void
-ULTRA_channel_client_release_os(void __iomem *pChannel, u8 *chanId,
-                               void *logCtx, char *file, int line, char *func)
+spar_channel_client_release_os(void __iomem *ch, u8 *id)
 {
-       CHANNEL_HEADER __iomem *pChan = pChannel;
+       struct channel_header __iomem *hdr = ch;
 
-       if (readb(&pChan->CliErrorOS) != 0) {
+       if (readb(&hdr->cli_error_os) != 0) {
                /* we are in an error msg throttling state; come out of it */
-               UltraLogEvent(logCtx, CHANNELSTATE_DIAG_EVENTID_TRANSITOK,
-                             CHANNELSTATE_DIAG_SEVERITY,
-                             CHANNELSTATE_DIAG_SUBSYS, func, line,
-                             "%s Channel OS client error state cleared @%s:%d\n",
-                             chanId, PathName_Last_N_Nodes((u8 *) file, 4),
-                             line);
-               writeb(0, &pChan->CliErrorOS);
+               pr_info("%s Channel OS client error state cleared\n", id);
+               writeb(0, &hdr->cli_error_os);
        }
-       if (readl(&pChan->CliStateOS) == CHANNELCLI_OWNED)
+       if (readl(&hdr->cli_state_os) == CHANNELCLI_OWNED)
                return;
-       if (readl(&pChan->CliStateOS) != CHANNELCLI_BUSY) {
-               UltraLogEvent(logCtx, CHANNELSTATE_DIAG_EVENTID_TRANSITERR,
-                             CHANNELSTATE_DIAG_SEVERITY,
-                             CHANNELSTATE_DIAG_SUBSYS, func, line,
-                             "%s Channel StateTransition INVALID! - release failed because OS client NOT BUSY (state=%s(%d)) @%s:%d\n",
-                             chanId,
-                             ULTRA_CHANNELCLI_STRING(
-                                     readl(&pChan->CliStateOS)),
-                             readl(&pChan->CliStateOS),
-                             PathName_Last_N_Nodes((u8 *) file, 4), line);
+       if (readl(&hdr->cli_state_os) != CHANNELCLI_BUSY) {
+               pr_info("%s Channel StateTransition INVALID! - release failed because OS client NOT BUSY (state=%s(%d))\n",
+                       id, ULTRA_CHANNELCLI_STRING(
+                                       readl(&hdr->cli_state_os)),
+                       readl(&hdr->cli_state_os));
                /* return; */
        }
-       writel(CHANNELCLI_ATTACHED, &pChan->CliStateOS); /* release busy */
+       writel(CHANNELCLI_ATTACHED, &hdr->cli_state_os); /* release busy */
 }
 
 /*
@@ -625,8 +526,8 @@ ULTRA_channel_client_release_os(void __iomem *pChannel, u8 *chanId,
 * full.
 */
 
-unsigned char visor_signal_insert(CHANNEL_HEADER __iomem *pChannel, u32 Queue,
-                                 void *pSignal);
+unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue,
+                                void *sig);
 
 /*
 * Routine Description:
@@ -647,8 +548,8 @@ unsigned char visor_signal_insert(CHANNEL_HEADER __iomem *pChannel, u32 Queue,
 * empty.
 */
 
-unsigned char visor_signal_remove(CHANNEL_HEADER __iomem *pChannel, u32 Queue,
-                                 void *pSignal);
+unsigned char spar_signal_remove(struct channel_header __iomem *ch, u32 queue,
+                                void *sig);
 
 /*
 * Routine Description:
@@ -669,8 +570,8 @@ unsigned char visor_signal_remove(CHANNEL_HEADER __iomem *pChannel, u32 Queue,
 * Return value:
 * # of signals copied.
 */
-unsigned int SignalRemoveAll(pCHANNEL_HEADER pChannel, u32 Queue,
-                            void *pSignal);
+unsigned int spar_signal_remove_all(struct channel_header *ch, u32 queue,
+                                   void *sig);
 
 /*
 * Routine Description:
@@ -683,7 +584,7 @@ unsigned int SignalRemoveAll(pCHANNEL_HEADER pChannel, u32 Queue,
 * Return value:
 * 1 if the signal queue is empty, 0 otherwise.
 */
-unsigned char visor_signalqueue_empty(CHANNEL_HEADER __iomem *pChannel,
-                                     u32 Queue);
+unsigned char spar_signalqueue_empty(struct channel_header __iomem *ch,
+                                    u32 queue);
 
 #endif
index 63c67ca..706363f 100644 (file)
 /* Used in IOChannel
  * {414815ed-c58c-11da-95a9-00e08161165f}
  */
-#define ULTRA_VHBA_CHANNEL_PROTOCOL_GUID \
+#define SPAR_VHBA_CHANNEL_PROTOCOL_UUID \
                UUID_LE(0x414815ed, 0xc58c, 0x11da, \
                                0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f)
-static const uuid_le UltraVhbaChannelProtocolGuid =
-       ULTRA_VHBA_CHANNEL_PROTOCOL_GUID;
+static const uuid_le spar_vhba_channel_protocol_uuid =
+       SPAR_VHBA_CHANNEL_PROTOCOL_UUID;
 
 /* Used in IOChannel
  * {8cd5994d-c58e-11da-95a9-00e08161165f}
  */
-#define ULTRA_VNIC_CHANNEL_PROTOCOL_GUID \
+#define SPAR_VNIC_CHANNEL_PROTOCOL_UUID \
                UUID_LE(0x8cd5994d, 0xc58e, 0x11da, \
                                0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f)
-static const uuid_le UltraVnicChannelProtocolGuid =
-       ULTRA_VNIC_CHANNEL_PROTOCOL_GUID;
+static const uuid_le spar_vnic_channel_protocol_uuid =
+       SPAR_VNIC_CHANNEL_PROTOCOL_UUID;
 
 /* Used in IOChannel
  * {72120008-4AAB-11DC-8530-444553544200}
  */
-#define ULTRA_SIOVM_GUID \
+#define SPAR_SIOVM_UUID \
                UUID_LE(0x72120008, 0x4AAB, 0x11DC, \
                                0x85, 0x30, 0x44, 0x45, 0x53, 0x54, 0x42, 0x00)
-static const uuid_le UltraSIOVMGuid = ULTRA_SIOVM_GUID;
-
+static const uuid_le spar_siovm_uuid = SPAR_SIOVM_UUID;
 
 /* Used in visornoop/visornoop_main.c
  * {5b52c5ac-e5f5-4d42-8dff-429eaecd221f}
  */
-#define ULTRA_CONTROLDIRECTOR_CHANNEL_PROTOCOL_GUID  \
+#define SPAR_CONTROLDIRECTOR_CHANNEL_PROTOCOL_UUID  \
                UUID_LE(0x5b52c5ac, 0xe5f5, 0x4d42, \
                                0x8d, 0xff, 0x42, 0x9e, 0xae, 0xcd, 0x22, 0x1f)
 
-static const uuid_le UltraControlDirectorChannelProtocolGuid =
-       ULTRA_CONTROLDIRECTOR_CHANNEL_PROTOCOL_GUID;
+static const uuid_le spar_controldirector_channel_protocol_uuid =
+       SPAR_CONTROLDIRECTOR_CHANNEL_PROTOCOL_UUID;
 
 /* Used in visorchipset/visorchipset_main.c
  * {B4E79625-AEDE-4EAA-9E11-D3EDDCD4504C}
  */
-#define ULTRA_DIAG_POOL_CHANNEL_PROTOCOL_GUID                          \
+#define SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID                           \
                UUID_LE(0xb4e79625, 0xaede, 0x4eaa, \
                                0x9e, 0x11, 0xd3, 0xed, 0xdc, 0xd4, 0x50, 0x4c)
-
-
index fd4726e..7f1adf6 100644 (file)
 #include <linux/types.h>
 #include "channel.h"
 
-#define ULTRA_MEMORY_COUNT_Ki 1024
+#define ULTRA_MEMORY_COUNT_KI 1024
 
 /* Scale order 0 is one 32-bit (4-byte) word (in 64 or 128-bit
  * architecture potentially 64 or 128-bit word) */
 #define ULTRA_MEMORY_PAGE_WORD 4
 
 /* Define Ki scale page to be traditional 4KB page */
-#define ULTRA_MEMORY_PAGE_Ki (ULTRA_MEMORY_PAGE_WORD * ULTRA_MEMORY_COUNT_Ki)
-typedef struct _ULTRA_SEGMENT_STATE  {
-       u16 Enabled:1;          /* Bit 0: May enter other states */
-       u16 Active:1;           /* Bit 1: Assigned to active partition */
-       u16 Alive:1;            /* Bit 2: Configure message sent to
+#define ULTRA_MEMORY_PAGE_KI (ULTRA_MEMORY_PAGE_WORD * ULTRA_MEMORY_COUNT_KI)
+struct spar_segment_state  {
+       u16 enabled:1;          /* Bit 0: May enter other states */
+       u16 active:1;           /* Bit 1: Assigned to active partition */
+       u16 alive:1;            /* Bit 2: Configure message sent to
                                 * service/server */
-       u16 Revoked:1;          /* Bit 3: similar to partition state
+       u16 revoked:1;          /* Bit 3: similar to partition state
                                 * ShuttingDown */
-       u16 Allocated:1;        /* Bit 4: memory (device/port number)
+       u16 allocated:1;        /* Bit 4: memory (device/port number)
                                 * has been selected by Command */
-       u16 Known:1;            /* Bit 5: has been introduced to the
+       u16 known:1;            /* Bit 5: has been introduced to the
                                 * service/guest partition */
-       u16 Ready:1;            /* Bit 6: service/Guest partition has
+       u16 ready:1;            /* Bit 6: service/Guest partition has
                                 * responded to introduction */
-       u16 Operating:1;        /* Bit 7: resource is configured and
+       u16 operating:1;        /* Bit 7: resource is configured and
                                 * operating */
        /* Note: don't use high bit unless we need to switch to ushort
         * which is non-compliant */
-} ULTRA_SEGMENT_STATE;
-static const ULTRA_SEGMENT_STATE SegmentStateRunning = {
+};
+
+static const struct spar_segment_state segment_state_running = {
        1, 1, 1, 0, 1, 1, 1, 1
 };
-static const ULTRA_SEGMENT_STATE SegmentStatePaused = {
+
+static const struct spar_segment_state segment_state_paused = {
        1, 1, 1, 0, 1, 1, 1, 0
 };
-static const ULTRA_SEGMENT_STATE SegmentStateStandby = {
+
+static const struct spar_segment_state segment_state_standby = {
        1, 1, 0, 0, 1, 1, 1, 0
 };
-typedef union {
-       u64 Full;
-       struct {
-               u8 Major;       /* will be 1 for the first release and
-                                * increment thereafter  */
-               u8 Minor;
-               u16 Maintenance;
-               u32 Revision;   /* Subversion revision */
-       } Part;
-} ULTRA_COMPONENT_VERSION;
 
 #endif                         /* _CONTROL_FRAMEWORK_H_ not defined */
index d08c198..a66db79 100644 (file)
@@ -27,12 +27,12 @@ enum { INVALID_GUEST_FIRMWARE, SAMPLE_GUEST_FIRMWARE,
 };
 
 /* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */
-#define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_GUID  \
+#define SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID   \
                UUID_LE(0x2b3c2d10, 0x7ef5, 0x4ad8, \
                                0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d)
 
-static const uuid_le UltraControlvmChannelProtocolGuid =
-       ULTRA_CONTROLVM_CHANNEL_PROTOCOL_GUID;
+static const uuid_le spar_controlvm_channel_protocol_uuid =
+       SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID;
 
 #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE \
        ULTRA_CHANNEL_PROTOCOL_SIGNATURE
@@ -45,19 +45,13 @@ static const uuid_le UltraControlvmChannelProtocolGuid =
 * channel struct withOUT needing to increment this. */
 #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID  1
 
-#define ULTRA_CONTROLVM_CHANNEL_OK_CLIENT(pChannel, logCtx)           \
-       (ULTRA_check_channel_client(pChannel, \
-               UltraControlvmChannelProtocolGuid, \
+#define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(ch)           \
+       spar_check_channel_client(ch, \
+               spar_controlvm_channel_protocol_uuid, \
                "controlvm", \
-               sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \
+               sizeof(struct spar_controlvm_channel_protocol), \
                ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
-               ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE, \
-               __FILE__, __LINE__, logCtx))
-#define ULTRA_CONTROLVM_CHANNEL_OK_SERVER(actualBytes, logCtx)        \
-       (ULTRA_check_channel_server(UltraControlvmChannelProtocolGuid,  \
-                                   "controlvm",                        \
-                                   sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \
-                                   actualBytes, __FILE__, __LINE__, logCtx))
+               ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE)
 
 #define MY_DEVICE_INDEX 0
 #define MAX_MACDATA_LEN 8 /* number of bytes for MAC address in config packet */
@@ -88,7 +82,7 @@ static const uuid_le UltraControlvmChannelProtocolGuid =
  *  - issued on the EventQueue queue (q #2) in the ControlVm channel
  *  - responded to on the EventAckQueue queue (q #3) in the ControlVm channel
  */
-typedef enum  {
+enum controlvm_id {
        CONTROLVM_INVALID = 0,
        /* SWITCH commands required Parameter: SwitchNumber  */
        /* BUS commands required Parameter: BusNumber  */
@@ -117,9 +111,9 @@ typedef enum  {
        CONTROLVM_CHIPSET_READY = 0x304,        /* CP --> SP */
        CONTROLVM_CHIPSET_SELFTEST = 0x305,     /* CP --> SP */
 
-} CONTROLVM_ID;
+};
 
-struct InterruptInfo {
+struct irq_info {
         /**< specifies interrupt info. It is used to send interrupts
          *   for this channel. The peer at the end of this channel
          *   who has registered an interrupt (using recv fields
@@ -128,495 +122,390 @@ struct InterruptInfo {
          *   interrupt.  Currently this is used by IOPart-SP to wake
          *   up GP when Data Channel transitions from empty to
          *   non-empty.*/
-       u64 sendInterruptHandle;
+       u64 send_irq_handle;
 
         /**< specifies interrupt handle. It is used to retrieve the
          *   corresponding interrupt pin from Monitor; and the
          *   interrupt pin is used to connect to the corresponding
-         *   intrrupt.  Used by IOPart-GP only. */
-       u64 recvInterruptHandle;
+         *   interrupt.  Used by IOPart-GP only. */
+       u64 recv_irq_handle;
 
         /**< specifies interrupt vector. It, interrupt pin, and shared are
          *   used to connect to the corresponding interrupt.  Used by
          *   IOPart-GP only. */
-       u32 recvInterruptVector;
+       u32 recv_irq_vector;
 
     /**< specifies if the recvInterrupt is shared.  It, interrupt pin
      *   and vector are used to connect to 0 = not shared; 1 = shared.
      *   the corresponding interrupt.  Used by IOPart-GP only. */
-       u8 recvInterruptShared;
+       u8 recv_irq_shared;
        u8 reserved[3]; /* Natural alignment purposes */
 };
 
-struct PciId {
-       u16 Domain;
-       u8 Bus;
-       u8 Slot;
-       u8 Func;
-       u8 Reserved[3]; /* Natural alignment purposes */
-};
-
-struct PciConfigHdr {
-       u16 VendorId;
-       u16 SubSysVendor;
-       u16 DeviceId;
-       u16 SubSysDevice;
-       u32 ClassCode;
-       u32 Reserved;           /* Natural alignment purposes */
-};
-
-struct ScsiId {
-       u32 Bus;
-       u32 Target;
-       u32 Lun;
-       u32 Host; /* Command should ignore this for *
-                  * DiskArrival/RemovalEvents */
-};
-
-struct WWID {
-       u32 wwid1;
-       u32 wwid2;
-};
-
-struct virtDiskInfo  {
-       u32 switchNo;           /* defined by SWITCH_CREATE */
-       u32 externalPortNo;     /* 0 for SAS RAID provided (external)
-                                * virtual disks, 1 for virtual disk
-                                * images, 2 for gold disk images */
-       u16 VirtualDiskIndex;   /* Index of disk descriptor in the
-                                * VirtualDisk segment associated with
-                                * externalPortNo */
-       u16 Reserved1;
-       u32 Reserved2;
+struct pci_id {
+       u16 domain;
+       u8 bus;
+       u8 slot;
+       u8 func;
+       u8 reserved[3]; /* Natural alignment purposes */
 };
 
-typedef enum {
-       CONTROLVM_ACTION_NONE = 0,
-       CONTROLVM_ACTION_SET_RESTORE = 0x05E7,
-       CONTROLVM_ACTION_CLEAR_RESTORE = 0x0C18,
-       CONTROLVM_ACTION_RESTORING = 0x08E5,
-       CONTROLVM_ACTION_RESTORE_BUSY = 0x0999,
-       CONTROLVM_ACTION_CLEAR_NVRAM = 0xB01
-} CONTROLVM_ACTION;
-
-typedef enum _ULTRA_TOOL_ACTIONS {
-           /* enumeration that defines intended action  */
-           ULTRA_TOOL_ACTION_NONE = 0, /* normal boot of boot disk */
-       ULTRA_TOOL_ACTION_INSTALL = 1,  /* install source disk(s) to boot
-                                        * disk */
-       ULTRA_TOOL_ACTION_CAPTURE = 2,  /* capture boot disk to target disk(s)
-                                        * as 'gold image' */
-       ULTRA_TOOL_ACTION_REPAIR = 3,   /* use source disk(s) to repair
-                                        * installation on boot disk */
-       ULTRA_TOOL_ACTION_CLEAN = 4,    /* 'scrub' virtual disk before
-                                        * releasing back to storage pool */
-       ULTRA_TOOL_ACTION_UPGRADE = 5,  /* upgrade to use content of images
-                                        * referenced from newer blueprint */
-       ULTRA_TOOL_ACTION_DIAG = 6,     /* use tool to invoke diagnostic script
-                                        * provided by blueprint */
-       ULTRA_TOOL_ACTION_FAILED = 7,   /* used when tool fails installation
-                                          and cannot continue */
-       ULTRA_TOOL_ACTION_COUNT = 8
-} ULTRA_TOOL_ACTIONS;
-
-typedef struct _ULTRA_EFI_SPAR_INDICATION  {
-       u64 BootToFirmwareUI:1; /* Bit 0: Stop in uefi ui */
-       u64 ClearNvram:1;       /* Bit 1: Clear NVRAM */
-       u64 ClearCmos:1;        /* Bit 2: Clear CMOS */
-       u64 BootToTool:1;       /* Bit 3: Run install tool */
+struct efi_spar_indication  {
+       u64 boot_to_fw_ui:1;    /* Bit 0: Stop in uefi ui */
+       u64 clear_nvram:1;      /* Bit 1: Clear NVRAM */
+       u64 clear_cmos:1;       /* Bit 2: Clear CMOS */
+       u64 boot_to_tool:1;     /* Bit 3: Run install tool */
        /* remaining bits are available */
-} ULTRA_EFI_SPAR_INDICATION;
+};
 
-typedef enum {
+enum ultra_chipset_feature {
        ULTRA_CHIPSET_FEATURE_REPLY = 0x00000001,
        ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG = 0x00000002,
        ULTRA_CHIPSET_FEATURE_PCIVBUS = 0x00000004
-} ULTRA_CHIPSET_FEATURE;
+};
 
 /** This is the common structure that is at the beginning of every
  *  ControlVm message (both commands and responses) in any ControlVm
  *  queue.  Commands are easily distinguished from responses by
  *  looking at the flags.response field.
  */
-typedef struct _CONTROLVM_MESSAGE_HEADER  {
-       u32 Id;         /* See CONTROLVM_ID. */
+struct controlvm_message_header  {
+       u32 id;         /* See CONTROLVM_ID. */
        /* For requests, indicates the message type. */
        /* For responses, indicates the type of message we are responding to. */
 
-       u32 MessageSize;        /* Includes size of this struct + size
+       u32 message_size;       /* Includes size of this struct + size
                                 * of message */
-       u32 SegmentIndex;       /* Index of segment containing Vm
+       u32 segment_index;      /* Index of segment containing Vm
                                 * message/information */
-       u32 CompletionStatus;   /* Error status code or result of
+       u32 completion_status;  /* Error status code or result of
                                 * message completion */
        struct  {
                u32 failed:1;              /**< =1 in a response to * signify
                                            * failure */
-               u32 responseExpected:1;   /**< =1 in all messages that expect a
+               u32 response_expected:1;   /**< =1 in all messages that expect a
                                           * response (Control ignores this
                                           * bit) */
                u32 server:1;              /**< =1 in all bus & device-related
                                            * messages where the message
                                            * receiver is to act as the bus or
                                            * device server */
-               u32 testMessage:1;         /**< =1 for testing use only
+               u32 test_message:1;        /**< =1 for testing use only
                                            * (Control and Command ignore this
                                            * bit) */
-               u32 partialCompletion:1;  /**< =1 if there are forthcoming
+               u32 partial_completion:1;  /**< =1 if there are forthcoming
                                           * responses/acks associated
                                           * with this message */
                u32 preserve:1;        /**< =1 this is to let us know to
                                        * preserve channel contents
                                        * (for running guests)*/
-               u32 writerInDiag:1;     /**< =1 the DiagWriter is active in the
+               u32 writer_in_diag:1;   /**< =1 the DiagWriter is active in the
                                         * Diagnostic Partition*/
-
-                   /* remaining bits in this 32-bit word are available */
-       } Flags;
-       u32 Reserved;           /* Natural alignment */
-       u64 MessageHandle;      /* Identifies the particular message instance,
+       } flags;
+       u32 reserved;           /* Natural alignment */
+       u64 message_handle;     /* Identifies the particular message instance,
                                 * and is used to match particular */
        /* request instances with the corresponding response instance. */
-       u64 PayloadVmOffset;    /* Offset of payload area from start of this
+       u64 payload_vm_offset;  /* Offset of payload area from start of this
                                 * instance of ControlVm segment */
-       u32 PayloadMaxBytes;    /* Maximum bytes allocated in payload
+       u32 payload_max_bytes;  /* Maximum bytes allocated in payload
                                 * area of ControlVm segment */
-       u32 PayloadBytes;       /* Actual number of bytes of payload
+       u32 payload_bytes;      /* Actual number of bytes of payload
                                 * area to copy between IO/Command; */
        /* if non-zero, there is a payload to copy. */
-} CONTROLVM_MESSAGE_HEADER;
-
-typedef struct _CONTROLVM_PACKET_DEVICE_CREATE  {
-       u32 busNo;         /**< bus # (0..n-1) from the msg receiver's
-                           * perspective */
+};
 
-           /* Control uses header SegmentIndex field to access bus number... */
-       u32 devNo;         /**< bus-relative (0..n-1) device number */
-       u64 channelAddr;  /**< Guest physical address of the channel, which
-                       *   can be dereferenced by the receiver
-                       *   of this ControlVm command */
-       u64 channelBytes; /**< specifies size of the channel in bytes */
-       uuid_le dataTypeGuid;/**< specifies format of data in channel */
-       uuid_le devInstGuid; /**< instance guid for the device */
-       struct InterruptInfo intr; /**< specifies interrupt information */
-} CONTROLVM_PACKET_DEVICE_CREATE;      /* for CONTROLVM_DEVICE_CREATE */
-
-typedef struct _CONTROLVM_PACKET_DEVICE_CONFIGURE  {
-       u32 busNo;            /**< bus # (0..n-1) from the msg
+struct controlvm_packet_device_create  {
+       u32 bus_no;     /* bus # (0..n-1) from the msg receiver's end */
+       u32 dev_no;     /* bus-relative (0..n-1) device number */
+       u64 channel_addr;       /* Guest physical address of the channel, which
+                                * can be dereferenced by the receiver of this
+                                * ControlVm command */
+       u64 channel_bytes;      /* specifies size of the channel in bytes */
+       uuid_le data_type_uuid; /* specifies format of data in channel */
+       uuid_le dev_inst_uuid;  /* instance guid for the device */
+       struct irq_info intr;   /* specifies interrupt information */
+};     /* for CONTROLVM_DEVICE_CREATE */
+
+struct controlvm_packet_device_configure  {
+       u32 bus_no;           /**< bus # (0..n-1) from the msg
                               * receiver's perspective */
 
            /* Control uses header SegmentIndex field to access bus number... */
-       u32 devNo;            /**< bus-relative (0..n-1) device number */
-} CONTROLVM_PACKET_DEVICE_CONFIGURE;   /* for CONTROLVM_DEVICE_CONFIGURE */
+       u32 dev_no;           /**< bus-relative (0..n-1) device number */
+}    /* for CONTROLVM_DEVICE_CONFIGURE */
 
-typedef struct _CONTROLVM_MESSAGE_DEVICE_CREATE  {
-       CONTROLVM_MESSAGE_HEADER Header;
-       CONTROLVM_PACKET_DEVICE_CREATE Packet;
-} CONTROLVM_MESSAGE_DEVICE_CREATE;     /* total 128 bytes */
+struct controlvm_message_device_create {
+       struct controlvm_message_header header;
+       struct controlvm_packet_device_create packet;
+};     /* total 128 bytes */
 
-typedef struct _CONTROLVM_MESSAGE_DEVICE_CONFIGURE  {
-       CONTROLVM_MESSAGE_HEADER Header;
-       CONTROLVM_PACKET_DEVICE_CONFIGURE Packet;
-} CONTROLVM_MESSAGE_DEVICE_CONFIGURE;  /* total 56 bytes */
+struct controlvm_message_device_configure  {
+       struct controlvm_message_header header;
+       struct controlvm_packet_device_configure packet;
+};     /* total 56 bytes */
 
 /* This is the format for a message in any ControlVm queue. */
-typedef struct _CONTROLVM_MESSAGE_PACKET  {
+struct controlvm_message_packet  {
        union  {
-
-               /* BEGIN Request messages */
                struct  {
-                       u32 busNo;            /*< bus # (0..n-1) from the msg
-                                              * receiver's perspective */
-
-           /* Control uses header SegmentIndex field to access bus number... */
-                       u32 deviceCount;      /*< indicates the max number of
-                                              * devices on this bus */
-                       u64 channelAddr;     /*< Guest physical address of the
-                                             *   channel, which can be
-                                             *   dereferenced by the receiver
-                                             *   of this ControlVm command */
-                       u64 channelBytes;    /*< size of the channel in bytes */
-                       uuid_le busDataTypeGuid;/*< indicates format of data in
-                                                   bus channel */
-                       uuid_le busInstGuid;    /*< instance guid for the bus */
-               } createBus;    /* for CONTROLVM_BUS_CREATE */
+                       u32 bus_no;     /* bus # (0..n-1) from the msg
+                                        * receiver's perspective */
+                       u32 dev_count;  /* indicates the max number of
+                                        * devices on this bus */
+                       u64 channel_addr;       /* Guest physical address of
+                                                * the channel, which can be
+                                                * dereferenced by the receiver
+                                                * of this ControlVm command */
+                       u64 channel_bytes;      /* size of the channel */
+                       uuid_le bus_data_type_uuid;     /* indicates format of
+                                                        * data in bus channel*/
+                       uuid_le bus_inst_uuid;  /* instance uuid for the bus */
+               } create_bus;   /* for CONTROLVM_BUS_CREATE */
                struct  {
-                       u32 busNo;            /*< bus # (0..n-1) from the msg
-                                              * receiver's perspective */
-
-           /* Control uses header SegmentIndex field to access bus number... */
+                       u32 bus_no;     /* bus # (0..n-1) from the msg
+                                        * receiver's perspective */
                        u32 reserved;   /* Natural alignment purposes */
-               } destroyBus;   /* for CONTROLVM_BUS_DESTROY */
+               } destroy_bus;  /* for CONTROLVM_BUS_DESTROY */
                struct  {
-                       u32 busNo;                  /*< bus # (0..n-1) from the
-                                                    * msg receiver's
-                                                    * perspective */
-
-           /* Control uses header SegmentIndex field to access bus number... */
-                       u32 reserved1;              /* for alignment purposes */
-                       u64 guestHandle;            /* This is used to convert
-                                        *  guest physical address to real
-                                        *  physical address for DMA, for ex. */
-                       u64 recvBusInterruptHandle;/*< specifies interrupt
-                                        *   info. It is used by SP to register
-                                        *   to receive interrupts from the CP.
-                                        *   This interrupt is used for bus
-                                        *   level notifications.  The
-                                        *   corresponding
-                                        *   sendBusInterruptHandle is kept in
-                                        *   CP. */
-               } configureBus; /* for CONTROLVM_BUS_CONFIGURE */
-
+                       u32 bus_no;     /* bus # (0..n-1) from the receiver's
+                                        * perspective */
+                       u32 reserved1;  /* for alignment purposes */
+                       u64 guest_handle;       /* This is used to convert
+                                                * guest physical address to
+                                                * physical address */
+                       u64 recv_bus_irq_handle;
+                               /* specifies interrupt info. It is used by SP
+                                * to register to receive interrupts from the
+                                * CP. This interrupt is used for bus level
+                                * notifications.  The corresponding
+                                * sendBusInterruptHandle is kept in CP. */
+               } configure_bus;        /* for CONTROLVM_BUS_CONFIGURE */
                /* for CONTROLVM_DEVICE_CREATE */
-               CONTROLVM_PACKET_DEVICE_CREATE createDevice;
+               struct controlvm_packet_device_create create_device;
                struct  {
-                       u32 busNo;            /*< bus # (0..n-1) from the msg
-                                              * receiver's perspective */
-
-           /* Control uses header SegmentIndex field to access bus number... */
-                       u32 devNo;            /*< bus-relative (0..n-1) device
-                                              * number */
-               } destroyDevice;        /* for CONTROLVM_DEVICE_DESTROY */
-
+                       u32 bus_no;     /* bus # (0..n-1) from the msg
+                                        * receiver's perspective */
+                       u32 dev_no;     /* bus-relative (0..n-1) device # */
+               } destroy_device;       /* for CONTROLVM_DEVICE_DESTROY */
                /* for CONTROLVM_DEVICE_CONFIGURE */
-               CONTROLVM_PACKET_DEVICE_CONFIGURE configureDevice;
+               struct controlvm_packet_device_configure configure_device;
                struct  {
-                       u32 busNo;            /*< bus # (0..n-1) from the msg
-                                              * receiver's perspective */
-
-           /* Control uses header SegmentIndex field to access bus number... */
-                       u32 devNo;            /*< bus-relative (0..n-1) device
-                                              * number */
-               } reconfigureDevice;    /* for CONTROLVM_DEVICE_RECONFIGURE */
+                       u32 bus_no;     /* bus # (0..n-1) from the msg
+                                        * receiver's perspective */
+                       u32 dev_no;     /* bus-relative (0..n-1) device # */
+               } reconfigure_device;   /* for CONTROLVM_DEVICE_RECONFIGURE */
                struct  {
-                       u32 busNo;
-                       ULTRA_SEGMENT_STATE state;
+                       u32 bus_no;
+                       struct spar_segment_state state;
                        u8 reserved[2]; /* Natural alignment purposes */
-               } busChangeState;       /* for CONTROLVM_BUS_CHANGESTATE */
+               } bus_change_state;     /* for CONTROLVM_BUS_CHANGESTATE */
                struct  {
-                       u32 busNo;
-                       u32 devNo;
-                       ULTRA_SEGMENT_STATE state;
+                       u32 bus_no;
+                       u32 dev_no;
+                       struct spar_segment_state state;
                        struct  {
-                               u32 physicalDevice:1;   /* =1 if message is for
+                               u32 phys_device:1;      /* =1 if message is for
                                                         * a physical device */
-                       /* remaining bits in this 32-bit word are available */
                        } flags;
                        u8 reserved[2]; /* Natural alignment purposes */
-               } deviceChangeState;    /* for CONTROLVM_DEVICE_CHANGESTATE */
+               } device_change_state;  /* for CONTROLVM_DEVICE_CHANGESTATE */
                struct  {
-                       u32 busNo;
-                       u32 devNo;
-                       ULTRA_SEGMENT_STATE state;
+                       u32 bus_no;
+                       u32 dev_no;
+                       struct spar_segment_state state;
                        u8 reserved[6]; /* Natural alignment purposes */
-               } deviceChangeStateEvent; /* for CONTROLVM_DEVICE_CHANGESTATE_EVENT */
+               } device_change_state_event;
+                       /* for CONTROLVM_DEVICE_CHANGESTATE_EVENT */
                struct  {
-                       u32 busCount; /*< indicates the max number of busses */
-                       u32 switchCount; /*< indicates the max number of
-                                         *   switches (applicable for service
-                                         *   partition only) */
-                       ULTRA_CHIPSET_FEATURE features;
-                       u32 platformNumber;     /* Platform Number */
-               } initChipset;  /* for CONTROLVM_CHIPSET_INIT */
+                       u32 bus_count;  /* indicates the max number of busses */
+                       u32 switch_count; /* indicates the max number of
+                                          * switches if a service partition */
+                       enum ultra_chipset_feature features;
+                       u32 platform_number;    /* Platform Number */
+               } init_chipset; /* for CONTROLVM_CHIPSET_INIT */
                struct  {
-                       u32 Options; /*< reserved */
-                       u32 Test;    /*< bit 0 set to run embedded selftest */
-               } chipsetSelftest;      /* for CONTROLVM_CHIPSET_SELFTEST */
-
-                   /* END Request messages */
-
-                   /* BEGIN Response messages */
-
-                   /* END Response messages */
-
-                   /* BEGIN Event messages */
+                       u32 options;    /* reserved */
+                       u32 test;       /* bit 0 set to run embedded selftest */
+               } chipset_selftest;     /* for CONTROLVM_CHIPSET_SELFTEST */
+               u64 addr;       /* a physical address of something, that can be
+                                * dereferenced by the receiver of this
+                                * ControlVm command (depends on command id) */
+               u64 handle;     /* a handle of something (depends on command
+                                * id) */
+       };
+};
 
-                   /* END Event messages */
+/* All messages in any ControlVm queue have this layout. */
+struct controlvm_message {
+       struct controlvm_message_header hdr;
+       struct controlvm_message_packet cmd;
+};
 
-                   /* BEGIN Ack messages */
+struct device_map {
+       GUEST_PHYSICAL_ADDRESS device_channel_address;
+       u64 device_channel_size;
+       u32 ca_index;
+       u32 reserved;           /* natural alignment */
+       u64 reserved2;          /* Align structure on 32-byte boundary */
+};
 
-                   /* END Ack messages */
-               u64 addr;           /*< a physical address of something, that
-                                    *   can be dereferenced by the receiver of
-                                    *   this ControlVm command (depends on
-                                    *   command id) */
-               u64 handle;         /*< a handle of something (depends on
-                                    * command id) */
-       };
-} CONTROLVM_MESSAGE_PACKET;
+struct guest_devices  {
+       struct device_map video_channel;
+       struct device_map keyboard_channel;
+       struct device_map network_channel;
+       struct device_map storage_channel;
+       struct device_map console_channel;
+       u32 partition_index;
+       u32 pad;
+};
 
-/* All messages in any ControlVm queue have this layout. */
-typedef struct _CONTROLVM_MESSAGE  {
-       CONTROLVM_MESSAGE_HEADER hdr;
-       CONTROLVM_MESSAGE_PACKET cmd;
-} CONTROLVM_MESSAGE;
-
-typedef struct _DEVICE_MAP  {
-       GUEST_PHYSICAL_ADDRESS DeviceChannelAddress;
-       u64 DeviceChannelSize;
-       u32 CA_Index;
-       u32 Reserved;           /* natural alignment */
-       u64 Reserved2;          /* Align structure on 32-byte boundary */
-} DEVICE_MAP;
-
-typedef struct _GUEST_DEVICES  {
-       DEVICE_MAP VideoChannel;
-       DEVICE_MAP KeyboardChannel;
-       DEVICE_MAP NetworkChannel;
-       DEVICE_MAP StorageChannel;
-       DEVICE_MAP ConsoleChannel;
-       u32 PartitionIndex;
-       u32 Pad;
-} GUEST_DEVICES;
-
-typedef struct _ULTRA_CONTROLVM_CHANNEL_PROTOCOL  {
-        CHANNEL_HEADER Header;
-        GUEST_PHYSICAL_ADDRESS gpControlVm;    /* guest physical address of
+struct spar_controlvm_channel_protocol {
+        struct channel_header header;
+        GUEST_PHYSICAL_ADDRESS gp_controlvm;   /* guest physical address of
                                                 * this channel */
-        GUEST_PHYSICAL_ADDRESS gpPartitionTables; /* guest physical address of
-                                                   * partition tables */
-        GUEST_PHYSICAL_ADDRESS gpDiagGuest;    /* guest physical address of
+        GUEST_PHYSICAL_ADDRESS gp_partition_tables;/* guest physical address of
+                                                    * partition tables */
+        GUEST_PHYSICAL_ADDRESS gp_diag_guest;  /* guest physical address of
                                                 * diagnostic channel */
-        GUEST_PHYSICAL_ADDRESS gpBootRomDisk;  /* guest phys addr of (read
+        GUEST_PHYSICAL_ADDRESS gp_boot_romdisk;/* guest phys addr of (read
                                                 * only) Boot ROM disk */
-        GUEST_PHYSICAL_ADDRESS gpBootRamDisk;  /* guest phys addr of writable
+        GUEST_PHYSICAL_ADDRESS gp_boot_ramdisk;/* guest phys addr of writable
                                                 * Boot RAM disk */
-        GUEST_PHYSICAL_ADDRESS gpAcpiTable;    /* guest phys addr of acpi
+        GUEST_PHYSICAL_ADDRESS gp_acpi_table;  /* guest phys addr of acpi
                                                 * table */
-        GUEST_PHYSICAL_ADDRESS gpControlChannel; /* guest phys addr of control
-                                                  * channel */
-        GUEST_PHYSICAL_ADDRESS gpDiagRomDisk;  /* guest phys addr of diagnostic
+        GUEST_PHYSICAL_ADDRESS gp_control_channel;/* guest phys addr of control
+                                                   * channel */
+        GUEST_PHYSICAL_ADDRESS gp_diag_romdisk;/* guest phys addr of diagnostic
                                                 * ROM disk */
-        GUEST_PHYSICAL_ADDRESS gpNvram;        /* guest phys addr of NVRAM
+        GUEST_PHYSICAL_ADDRESS gp_nvram;       /* guest phys addr of NVRAM
                                                 * channel */
-        u64 RequestPayloadOffset;      /* Offset to request payload area */
-        u64 EventPayloadOffset;        /* Offset to event payload area */
-        u32 RequestPayloadBytes;       /* Bytes available in request payload
+        u64 request_payload_offset;    /* Offset to request payload area */
+        u64 event_payload_offset;      /* Offset to event payload area */
+        u32 request_payload_bytes;     /* Bytes available in request payload
                                         * area */
-        u32 EventPayloadBytes; /* Bytes available in event payload area */
-        u32 ControlChannelBytes;
-        u32 NvramChannelBytes; /* Bytes in PartitionNvram segment */
-        u32 MessageBytes;      /* sizeof(CONTROLVM_MESSAGE) */
-        u32 MessageCount;      /* CONTROLVM_MESSAGE_MAX */
-        GUEST_PHYSICAL_ADDRESS gpSmbiosTable;  /* guest phys addr of SMBIOS
+        u32 event_payload_bytes;/* Bytes available in event payload area */
+        u32 control_channel_bytes;
+        u32 nvram_channel_bytes;       /* Bytes in PartitionNvram segment */
+        u32 message_bytes;     /* sizeof(CONTROLVM_MESSAGE) */
+        u32 message_count;     /* CONTROLVM_MESSAGE_MAX */
+        GUEST_PHYSICAL_ADDRESS gp_smbios_table;/* guest phys addr of SMBIOS
                                                 * tables */
-        GUEST_PHYSICAL_ADDRESS gpPhysicalSmbiosTable;  /* guest phys addr of
-                                                        * SMBIOS table  */
+        GUEST_PHYSICAL_ADDRESS gp_physical_smbios_table;/* guest phys addr of
+                                                         * SMBIOS table  */
         /* ULTRA_MAX_GUESTS_PER_SERVICE */
-        GUEST_DEVICES gpObsoleteGuestDevices[16];
+        struct guest_devices gp_obsolete_guest_devices[16];
 
         /* guest physical address of EFI firmware image base  */
-        GUEST_PHYSICAL_ADDRESS VirtualGuestFirmwareImageBase;
+        GUEST_PHYSICAL_ADDRESS virtual_guest_firmware_image_base;
 
         /* guest physical address of EFI firmware entry point  */
-        GUEST_PHYSICAL_ADDRESS VirtualGuestFirmwareEntryPoint;
+        GUEST_PHYSICAL_ADDRESS virtual_guest_firmware_entry_point;
 
         /* guest EFI firmware image size  */
-        u64 VirtualGuestFirmwareImageSize;
+        u64 virtual_guest_firmware_image_size;
 
         /* GPA = 1MB where EFI firmware image is copied to  */
-        GUEST_PHYSICAL_ADDRESS VirtualGuestFirmwareBootBase;
-        GUEST_PHYSICAL_ADDRESS VirtualGuestImageBase;
-        GUEST_PHYSICAL_ADDRESS VirtualGuestImageSize;
-        u64 PrototypeControlChannelOffset;
-        GUEST_PHYSICAL_ADDRESS VirtualGuestPartitionHandle;
+        GUEST_PHYSICAL_ADDRESS virtual_guest_firmware_boot_base;
+        GUEST_PHYSICAL_ADDRESS virtual_guest_image_base;
+        GUEST_PHYSICAL_ADDRESS virtual_guest_image_size;
+        u64 prototype_control_channel_offset;
+        GUEST_PHYSICAL_ADDRESS virtual_guest_partition_handle;
 
-        u16 RestoreAction;     /* Restore Action field to restore the guest
+        u16 restore_action;    /* Restore Action field to restore the guest
                                 * partition */
-       u16 DumpAction;         /* For Windows guests it shows if the visordisk
+       u16 dump_action;        /* For Windows guests it shows if the visordisk
                                 * is running in dump mode */
-       u16 NvramFailCount;
-       u16 SavedCrashMsgCount; /* = CONTROLVM_CRASHMSG_MAX */
-       u32 SavedCrashMsgOffset;        /* Offset to request payload area needed
+       u16 nvram_fail_count;
+       u16 saved_crash_message_count;  /* = CONTROLVM_CRASHMSG_MAX */
+       u32 saved_crash_message_offset; /* Offset to request payload area needed
                                         * for crash dump */
-       u32 InstallationError;  /* Type of error encountered during
+       u32 installation_error; /* Type of error encountered during
                                 * installation */
-       u32 InstallationTextId; /* Id of string to display */
-       u16 InstallationRemainingSteps; /* Number of remaining installation
-                                        * steps (for progress bars) */
-       u8 ToolAction;          /* ULTRA_TOOL_ACTIONS Installation Action
+       u32 installation_text_id;       /* Id of string to display */
+       u16 installation_remaining_steps;/* Number of remaining installation
+                                         * steps (for progress bars) */
+       u8 tool_action;         /* ULTRA_TOOL_ACTIONS Installation Action
                                 * field */
-       u8 Reserved;            /* alignment */
-       ULTRA_EFI_SPAR_INDICATION EfiSparIndication;
-       ULTRA_EFI_SPAR_INDICATION EfiSparIndicationSupported;
-       u32 SPReserved;
-       u8 Reserved2[28];       /* Force signals to begin on 128-byte cache
+       u8 reserved;            /* alignment */
+       struct efi_spar_indication efi_spar_ind;
+       struct efi_spar_indication efi_spar_ind_supported;
+       u32 sp_reserved;
+       u8 reserved2[28];       /* Force signals to begin on 128-byte cache
                                 * line */
-       SIGNAL_QUEUE_HEADER RequestQueue;       /* Service or guest partition
-                                                * uses this queue to send
-                                                * requests to Control */
-       SIGNAL_QUEUE_HEADER ResponseQueue;      /* Control uses this queue to
-                                                * respond to service or guest
-                                                * partition requests */
-       SIGNAL_QUEUE_HEADER EventQueue;         /* Control uses this queue to
+       struct signal_queue_header request_queue;/* Service or guest partition
+                                                 * uses this queue to send
+                                                 * requests to Control */
+       struct signal_queue_header response_queue;/* Control uses this queue to
+                                                  * respond to service or guest
+                                                  * partition requests */
+       struct signal_queue_header event_queue; /* Control uses this queue to
                                                 * send events to service or
                                                 * guest partition */
-       SIGNAL_QUEUE_HEADER EventAckQueue;      /* Service or guest partition
-                                                * uses this queue to ack
-                                                * Control events */
+       struct signal_queue_header event_ack_queue;/* Service or guest partition
+                                                   * uses this queue to ack
+                                                   * Control events */
 
         /* Request fixed-size message pool - does not include payload */
-        CONTROLVM_MESSAGE RequestMsg[CONTROLVM_MESSAGE_MAX];
+        struct controlvm_message request_msg[CONTROLVM_MESSAGE_MAX];
 
         /* Response fixed-size message pool - does not include payload */
-        CONTROLVM_MESSAGE ResponseMsg[CONTROLVM_MESSAGE_MAX];
+        struct controlvm_message response_msg[CONTROLVM_MESSAGE_MAX];
 
         /* Event fixed-size message pool - does not include payload */
-        CONTROLVM_MESSAGE EventMsg[CONTROLVM_MESSAGE_MAX];
+        struct controlvm_message event_msg[CONTROLVM_MESSAGE_MAX];
 
         /* Ack fixed-size message pool - does not include payload */
-        CONTROLVM_MESSAGE EventAckMsg[CONTROLVM_MESSAGE_MAX];
+        struct controlvm_message event_ack_msg[CONTROLVM_MESSAGE_MAX];
 
         /* Message stored during IOVM creation to be reused after crash */
-        CONTROLVM_MESSAGE SavedCrashMsg[CONTROLVM_CRASHMSG_MAX];
-} ULTRA_CONTROLVM_CHANNEL_PROTOCOL;
+        struct controlvm_message saved_crash_msg[CONTROLVM_CRASHMSG_MAX];
+};
 
 /* Offsets for VM channel attributes... */
 #define VM_CH_REQ_QUEUE_OFFSET \
-       offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, RequestQueue)
+       offsetof(struct spar_controlvm_channel_protocol, request_queue)
 #define VM_CH_RESP_QUEUE_OFFSET \
-       offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, ResponseQueue)
+       offsetof(struct spar_controlvm_channel_protocol, response_queue)
 #define VM_CH_EVENT_QUEUE_OFFSET \
-       offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, EventQueue)
+       offsetof(struct spar_controlvm_channel_protocol, event_queue)
 #define VM_CH_ACK_QUEUE_OFFSET \
-       offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, EventAckQueue)
+       offsetof(struct spar_controlvm_channel_protocol, event_ack_queue)
 #define VM_CH_REQ_MSG_OFFSET \
-       offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, RequestMsg)
+       offsetof(struct spar_controlvm_channel_protocol, request_msg)
 #define VM_CH_RESP_MSG_OFFSET \
-       offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, ResponseMsg)
+       offsetof(struct spar_controlvm_channel_protocol, response_msg)
 #define VM_CH_EVENT_MSG_OFFSET \
-       offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, EventMsg)
+       offsetof(struct spar_controlvm_channel_protocol, event_msg)
 #define VM_CH_ACK_MSG_OFFSET \
-       offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, EventAckMsg)
+       offsetof(struct spar_controlvm_channel_protocol, event_ack_msg)
 #define VM_CH_CRASH_MSG_OFFSET \
-       offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, SavedCrashMsg)
+       offsetof(struct spar_controlvm_channel_protocol, saved_crash_msg)
 
 /* The following header will be located at the beginning of PayloadVmOffset for
- *  various ControlVm commands. The receiver of a ControlVm command with a
- *  PayloadVmOffset will dereference this address and then use ConnectionOffset,
- *  InitiatorOffset, and TargetOffset to get the location of UTF-8 formatted
- *  strings that can be parsed to obtain command-specific information. The value
- *  of TotalLength should equal PayloadBytes.  The format of the strings at
- *  PayloadVmOffset will take different forms depending on the message.  See the
- *  following Wiki page for more information:
- *  https://ustr-linux-1.na.uis.unisys.com/spar/index.php/ControlVm_Parameters_Area
+ * various ControlVm commands. The receiver of a ControlVm command with a
+ * PayloadVmOffset will dereference this address and then use connection_offset,
+ * initiator_offset, and target_offset to get the location of UTF-8 formatted
+ * strings that can be parsed to obtain command-specific information. The value
+ * of total_length should equal PayloadBytes. The format of the strings at
+ * PayloadVmOffset will take different forms depending on the message.
  */
-typedef struct _ULTRA_CONTROLVM_PARAMETERS_HEADER  {
-       u32 TotalLength;
-       u32 HeaderLength;
-       u32 ConnectionOffset;
-       u32 ConnectionLength;
-       u32 InitiatorOffset;
-       u32 InitiatorLength;
-       u32 TargetOffset;
-       u32 TargetLength;
-       u32 ClientOffset;
-       u32 ClientLength;
-       u32 NameOffset;
-       u32 NameLength;
-       uuid_le Id;
-       u32 Revision;
-       u32 Reserved;           /* Natural alignment */
-} ULTRA_CONTROLVM_PARAMETERS_HEADER;
+struct spar_controlvm_parameters_header {
+       u32 total_length;
+       u32 header_length;
+       u32 connection_offset;
+       u32 connection_length;
+       u32 initiator_offset;
+       u32 initiator_length;
+       u32 target_offset;
+       u32 target_length;
+       u32 client_offset;
+       u32 client_length;
+       u32 name_offset;
+       u32 name_length;
+       uuid_le id;
+       u32 revision;
+       u32 reserved;           /* Natural alignment */
+};
 
 #endif                         /* __CONTROLVMCHANNEL_H__ */
index 9912e51..e8fb867 100644 (file)
 #include "channel.h"
 
 /* {EEA7A573-DB82-447c-8716-EFBEAAAE4858} */
-#define ULTRA_DIAG_CHANNEL_PROTOCOL_GUID \
+#define SPAR_DIAG_CHANNEL_PROTOCOL_UUID \
                UUID_LE(0xeea7a573, 0xdb82, 0x447c, \
                                0x87, 0x16, 0xef, 0xbe, 0xaa, 0xae, 0x48, 0x58)
 
-static const uuid_le UltraDiagChannelProtocolGuid =
-       ULTRA_DIAG_CHANNEL_PROTOCOL_GUID;
+static const uuid_le spar_diag_channel_protocol_uuid =
+       SPAR_DIAG_CHANNEL_PROTOCOL_UUID;
 
 /* {E850F968-3263-4484-8CA5-2A35D087A5A8} */
 #define ULTRA_DIAG_ROOT_CHANNEL_PROTOCOL_GUID \
@@ -58,19 +58,20 @@ static const uuid_le UltraDiagChannelProtocolGuid =
 * increment this. */
 #define ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID 2
 
-#define ULTRA_DIAG_CHANNEL_OK_CLIENT(pChannel, logCtx)                 \
-       (ULTRA_check_channel_client(pChannel,                           \
-                                   UltraDiagChannelProtocolGuid,       \
-                                   "diag",                             \
-                                   sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \
-                                   ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID, \
-                                   ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE, \
-                                   __FILE__, __LINE__, logCtx))
-#define ULTRA_DIAG_CHANNEL_OK_SERVER(actualBytes, logCtx)              \
-       (ULTRA_check_channel_server(UltraDiagChannelProtocolGuid,       \
-                                   "diag",                             \
-                                   sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \
-                                   actualBytes, __FILE__, __LINE__, logCtx))
+#define SPAR_DIAG_CHANNEL_OK_CLIENT(ch)\
+       (spar_check_channel_client(ch,\
+                                  spar_diag_channel_protocol_uuid,\
+                                  "diag",\
+                                  sizeof(struct spar_diag_channel_protocol),\
+                                  ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID,\
+                                  ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE))
+
+#define SPAR_DIAG_CHANNEL_OK_SERVER(bytes)\
+       (spar_check_channel_server(spar_diag_channel_protocol_uuid,\
+                                  "diag",\
+                                  sizeof(struct spar_diag_channel_protocol),\
+                                  bytes))
+
 #define MAX_MODULE_NAME_SIZE 128       /* Maximum length of module name... */
 #define MAX_ADDITIONAL_INFO_SIZE 256   /* Maximum length of any additional info
                                         * accompanying event... */
@@ -105,21 +106,21 @@ static const uuid_le UltraDiagChannelProtocolGuid =
 /* Copied from EFI's EFI_TIME struct in efidef.h.  EFI headers are not allowed
 * in some of the Supervisor areas, such as Monitor, so it has been "ported" here
 * for use in diagnostic event timestamps... */
-typedef struct _DIAG_EFI_TIME  {
-       u16 Year;               /* 1998 - 20XX */
-       u8 Month;               /* 1 - 12 */
-       u8 Day;                 /* 1 - 31 */
-       u8 Hour;                /* 0 - 23 */
-       u8 Minute;              /* 0 - 59 */
-       u8 Second;              /* 0 - 59 */
-       u8 Pad1;
-       u32 Nanosecond; /* 0 - 999, 999, 999 */
-       s16 TimeZone;           /* -1440 to 1440 or 2047 */
-       u8 Daylight;
-       u8 Pad2;
-} DIAG_EFI_TIME;
-
-typedef enum  {
+struct diag_efi_time  {
+       u16 year;               /* 1998 - 20XX */
+       u8 month;               /* 1 - 12 */
+       u8 day;                 /* 1 - 31 */
+       u8 hour;                /* 0 - 23 */
+       u8 minute;              /* 0 - 59 */
+       u8 second;              /* 0 - 59 */
+       u8 pad1;
+       u32 nanosecond; /* 0 - 999, 999, 999 */
+       s16 timezone;           /* -1440 to 1440 or 2047 */
+       u8 daylight;
+       u8 pad2;
+};
+
+enum spar_component_types  {
         ULTRA_COMPONENT_GUEST = 0,
         ULTRA_COMPONENT_MONITOR = 0x01,
         ULTRA_COMPONENT_CCM = 0x02,    /* Common Control module */
@@ -144,9 +145,9 @@ typedef enum  {
         ULTRA_COMPONENT_PSERVICES = 0x17,
         ULTRA_COMPONENT_PDIAG = 0x18
         /* RESERVED 0x18 - 0x1F */
-} ULTRA_COMPONENT_TYPES;
+};
 
-/* Structure: DIAG_CHANNEL_EVENT Purpose: Contains attributes that make up an
+/* Structure: diag_channel_event Purpose: Contains attributes that make up an
  * event to be written to the DIAG_CHANNEL memory.  Attributes: EventId: Id of
  * the diagnostic event to write to memory.  Severity: Severity of the event
  * (Error, Info, etc).  ModuleName: Module/file name where event originated.
@@ -155,40 +156,40 @@ typedef enum  {
  * Reserved: Padding to align structure on a 64-byte cache line boundary.
  * AdditionalInfo: Array of characters for additional event info (may be
  * empty).  */
-typedef struct _DIAG_CHANNEL_EVENT  {
-       u32 EventId;
-       u32 Severity;
-       u8 ModuleName[MAX_MODULE_NAME_SIZE];
-       u32 LineNumber;
-       DIAG_EFI_TIME Timestamp;        /* Size = 16 bytes */
-       u32 PartitionNumber;    /* Filled in by Diag Switch as pool blocks are
+struct diag_channel_event {
+       u32 event_id;
+       u32 severity;
+       u8 module_name[MAX_MODULE_NAME_SIZE];
+       u32 line_number;
+       struct diag_efi_time timestamp; /* Size = 16 bytes */
+       u32 partition_number;   /* Filled in by Diag Switch as pool blocks are
                                 * filled */
-       u16 VirtualProcessorNumber;
-       u16 LogicalProcessorNumber;
-       u8 ComponentType;       /* ULTRA_COMPONENT_TYPES */
-       u8 Subsystem;
-       u16 Reserved0;          /* pad to u64 alignment */
-       u32 BlockNumber;        /* filled in by DiagSwitch as pool blocks are
+       u16 vcpu_number;
+       u16 lcpu_number;
+       u8 component_type;      /* ULTRA_COMPONENT_TYPES */
+       u8 subsystem;
+       u16 reserved0;          /* pad to u64 alignment */
+       u32 block_no;           /* filled in by DiagSwitch as pool blocks are
                                 * filled */
-       u32 BlockNumberHigh;
-       u32 EventNumber;        /* filled in by DiagSwitch as pool blocks are
+       u32 block_no_high;
+       u32 event_no;           /* filled in by DiagSwitch as pool blocks are
                                 * filled */
-       u32 EventNumberHigh;
+       u32 event_no_high;
 
-       /* The BlockNumber and EventNumber fields are set only by DiagSwitch
+       /* The block_no and event_no fields are set only by DiagSwitch
         * and referenced only by WinDiagDisplay formatting tool as
         * additional diagnostic information.  Other tools including
         * WinDiagDisplay currently ignore these 'Reserved' bytes. */
-       u8 Reserved[8];
-       u8 AdditionalInfo[MAX_ADDITIONAL_INFO_SIZE];
+       u8 reserved[8];
+       u8 additional_info[MAX_ADDITIONAL_INFO_SIZE];
 
-       /* NOTE: Changesto DIAG_CHANNEL_EVENT generally need to be reflected in
+       /* NOTE: Changes to diag_channel_event generally need to be reflected in
         * existing copies *
         * - for AppOS at
         * GuestLinux/visordiag_early/supervisor_diagchannel.h *
         * - for WinDiagDisplay at
         * EFI/Ultra/Tools/WinDiagDisplay/WinDiagDisplay/diagstruct.h */
-} DIAG_CHANNEL_EVENT;
+};
 
 /* Levels of severity for diagnostic events, in order from lowest severity to
 * highest (i.e. fatal errors are the most severe, and should always be logged,
@@ -201,7 +202,8 @@ typedef struct _DIAG_CHANNEL_EVENT  {
 * they are valid for controlling the amount of event data.  This enum is also
 * defined in DotNet\sParFramework\ControlFramework\ControlFramework.cs.  If a
 * change is made to this enum, they should also be reflected in that file.  */
-typedef enum  { DIAG_SEVERITY_ENUM_BEGIN = 0,
+enum diag_severity {
+               DIAG_SEVERITY_ENUM_BEGIN = 0,
                DIAG_SEVERITY_OVERRIDE = DIAG_SEVERITY_ENUM_BEGIN,
                DIAG_SEVERITY_VERBOSE = DIAG_SEVERITY_OVERRIDE, /* 0 */
                DIAG_SEVERITY_INFO = DIAG_SEVERITY_VERBOSE + 1, /* 1 */
@@ -212,7 +214,7 @@ typedef enum  { DIAG_SEVERITY_ENUM_BEGIN = 0,
                DIAG_SEVERITY_ENUM_END = DIAG_SEVERITY_SHUTOFF, /* 5 */
                DIAG_SEVERITY_NONFATAL_ERR = DIAG_SEVERITY_ERR,
                DIAG_SEVERITY_FATAL_ERR = DIAG_SEVERITY_PRINT
-} DIAG_SEVERITY;
+};
 
 /* Event Cause enums
 *
@@ -233,26 +235,24 @@ typedef enum  { DIAG_SEVERITY_ENUM_BEGIN = 0,
 * If a change is made to this enum, they should also be reflected in that
 * file.  */
 
-
-
 /* A cause value "DIAG_CAUSE_FILE_XFER" together with a severity value of
 * "DIAG_SEVERITY_PRINT" (=4), is used for transferring text or binary file to
 * the Diag partition. This cause-severity combination will be used by Logger
 * DiagSwitch to segregate events into block types. The files are transferred in
-* 256 byte chunks maximum, in the AdditionalInfo field of the DIAG_CHANNEL_EVENT
+* 256 byte chunks maximum, in the AdditionalInfo field of the diag_channel_event
 * structure. In the file transfer mode, some event fields will have different
 * meaning: EventId specifies the file offset, severity specifies the block type,
 * ModuleName specifies the filename, LineNumber specifies the number of valid
 * data bytes in an event and AdditionalInfo contains up to 256 bytes of data. */
 
 /* The Diag DiagWriter appends event blocks to events.raw as today, and for data
- * blocks uses DIAG_CHANNEL_EVENT
+ * blocks uses diag_channel_event
  * PartitionNumber to extract and append 'AdditionalInfo' to filename (specified
  * by ModuleName). */
 
 /* The Dell PDiag uses this new mechanism to stash DSET .zip onto the
  * 'diagnostic' virtual disk.  */
-typedef enum  {
+enum diag_cause {
        DIAG_CAUSE_UNKNOWN = 0,
        DIAG_CAUSE_UNKNOWN_DEBUG = DIAG_CAUSE_UNKNOWN + 1,      /* 1 */
        DIAG_CAUSE_DEBUG = DIAG_CAUSE_UNKNOWN_DEBUG + 1,        /* 2 */
@@ -264,7 +264,7 @@ typedef enum  {
        DIAG_CAUSE_INTERNAL_ERROR = DIAG_CAUSE_INVALID_REQUEST + 1, /* 8 */
        DIAG_CAUSE_FILE_XFER = DIAG_CAUSE_INTERNAL_ERROR + 1,   /* 9 */
        DIAG_CAUSE_ENUM_END = DIAG_CAUSE_FILE_XFER      /* 9 */
-} DIAG_CAUSE;
+};
 
 /* Event Cause category defined into the byte 2 of Severity */
 #define CAUSE_DEBUG (DIAG_CAUSE_DEBUG << CAUSE_SHIFT_AMT)
@@ -344,7 +344,7 @@ typedef enum  {
 #define CAUSE_FILE_XFER_SEVERITY_PRINT \
        (CAUSE_FILE_XFER | DIAG_SEVERITY_PRINT)
 
-/* Structure: DIAG_CHANNEL_PROTOCOL_HEADER
+/* Structure: diag_channel_protocol_header
  *
  * Purpose: Contains attributes that make up the header specific to the
  * DIAG_CHANNEL area.
@@ -362,12 +362,12 @@ typedef enum  {
  *                     whether events are logged.  Any event's severity for a
  *                     particular subsystem below this level will be discarded.
  */
-typedef struct _DIAG_CHANNEL_PROTOCOL_HEADER  {
-       volatile u32 DiagLock;
-       u8 IsChannelInitialized;
-       u8 Reserved[3];
-       u8 SubsystemSeverityFilter[64];
-} DIAG_CHANNEL_PROTOCOL_HEADER;
+struct diag_channel_protocol_header {
+       u32 diag_lock;
+       u8 channel_initialized;
+       u8 reserved[3];
+       u8 subsystem_severity_filter[64];
+};
 
 /* The Diagram for the Diagnostic Channel: */
 /* ----------------------- */
@@ -375,19 +375,20 @@ typedef struct _DIAG_CHANNEL_PROTOCOL_HEADER  {
 /* ----------------------- */
 /* | Signal Queue Header   |   Defined by SIGNAL_QUEUE_HEADER */
 /* ----------------------- */
-/* | DiagChannel Header    |   Defined by DIAG_CHANNEL_PROTOCOL_HEADER */
+/* | DiagChannel Header    |   Defined by diag_channel_protocol_header */
 /* ----------------------- */
-/* | Channel Event Info    |   Defined by (DIAG_CHANNEL_EVENT * MAX_EVENTS) */
+/* | Channel Event Info    |   Defined by diag_channel_event*MAX_EVENTS */
 /* ----------------------- */
 /* | Reserved              |   Reserved (pad out to 4MB) */
 /* ----------------------- */
 
 /* Offsets/sizes for diagnostic channel attributes... */
-#define DIAG_CH_QUEUE_HEADER_OFFSET (sizeof(ULTRA_CHANNEL_PROTOCOL))
-#define DIAG_CH_QUEUE_HEADER_SIZE (sizeof(SIGNAL_QUEUE_HEADER))
+#define DIAG_CH_QUEUE_HEADER_OFFSET (sizeof(struct channel_header))
+#define DIAG_CH_QUEUE_HEADER_SIZE (sizeof(struct signal_queue_header))
 #define DIAG_CH_PROTOCOL_HEADER_OFFSET \
        (DIAG_CH_QUEUE_HEADER_OFFSET + DIAG_CH_QUEUE_HEADER_SIZE)
-#define DIAG_CH_PROTOCOL_HEADER_SIZE (sizeof(DIAG_CHANNEL_PROTOCOL_HEADER))
+#define DIAG_CH_PROTOCOL_HEADER_SIZE \
+       (sizeof(struct diag_channel_protocol_header))
 #define DIAG_CH_EVENT_OFFSET \
        (DIAG_CH_PROTOCOL_HEADER_OFFSET + DIAG_CH_PROTOCOL_HEADER_SIZE)
 #define DIAG_CH_SIZE (4096 * 1024)
@@ -397,7 +398,7 @@ typedef struct _DIAG_CHANNEL_PROTOCOL_HEADER  {
 #define DIAG_CH_LRG_SIZE (2 * DIAG_CH_SIZE)    /* 8 MB */
 
 /*
- * Structure: ULTRA_DIAG_CHANNEL_PROTOCOL
+ * Structure: spar_diag_channel_protocol
  *
  * Purpose: Contains attributes that make up the DIAG_CHANNEL memory.
  *
@@ -409,19 +410,18 @@ typedef struct _DIAG_CHANNEL_PROTOCOL_HEADER  {
  * store event.
  *
  * DiagChannelHeader: Diagnostic channel header info (see
- * DIAG_CHANNEL_PROTOCOL_HEADER comments).
+ * diag_channel_protocol_header comments).
  *
  * Events: Area where diagnostic events (up to MAX_EVENTS) are written.
  *
  *Reserved: Reserved area to allow for correct channel size padding.
 */
-typedef struct _ULTRA_DIAG_CHANNEL_PROTOCOL  {
-       ULTRA_CHANNEL_PROTOCOL CommonChannelHeader;
-       SIGNAL_QUEUE_HEADER QueueHeader;
-       DIAG_CHANNEL_PROTOCOL_HEADER DiagChannelHeader;
-       DIAG_CHANNEL_EVENT Events[(DIAG_CH_SIZE - DIAG_CH_EVENT_OFFSET) /
-                                  sizeof(DIAG_CHANNEL_EVENT)];
-}
-ULTRA_DIAG_CHANNEL_PROTOCOL;
+struct spar_diag_channel_protocol  {
+       struct channel_header common_channel_header;
+       struct signal_queue_header queue_header;
+       struct diag_channel_protocol_header diag_channel_header;
+       struct diag_channel_event events[(DIAG_CH_SIZE - DIAG_CH_EVENT_OFFSET) /
+                                  sizeof(struct diag_channel_event)];
+};
 
 #endif
index b1dd73d..eb7efe4 100644 (file)
@@ -8,7 +8,6 @@
 * this file.  Note: Everything is OS-independent because this file is
 * used by Windows, Linux and possible EFI drivers.  */
 
-
 /*
 * Communication flow between the IOPart and GuestPart uses the channel headers
 * channel state.  The following states are currently being used:
 #define ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID 2
 #define ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID 1
 
-#define ULTRA_VHBA_CHANNEL_OK_CLIENT(pChannel, logCtx)                 \
-       (ULTRA_check_channel_client(pChannel, UltraVhbaChannelProtocolGuid, \
-                                   "vhba", MIN_IO_CHANNEL_SIZE,        \
-                                   ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \
-                                   ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE, \
-                                   __FILE__, __LINE__, logCtx))
-#define ULTRA_VHBA_CHANNEL_OK_SERVER(actualBytes, logCtx)              \
-       (ULTRA_check_channel_server(UltraVhbaChannelProtocolGuid,       \
-                                   "vhba", MIN_IO_CHANNEL_SIZE, actualBytes, \
-                                   __FILE__, __LINE__, logCtx))
-#define ULTRA_VNIC_CHANNEL_OK_CLIENT(pChannel, logCtx)                 \
-       (ULTRA_check_channel_client(pChannel, UltraVnicChannelProtocolGuid, \
-                                   "vnic", MIN_IO_CHANNEL_SIZE,        \
-                                   ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \
-                                   ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE, \
-                                   __FILE__, __LINE__, logCtx))
-#define ULTRA_VNIC_CHANNEL_OK_SERVER(actualBytes, logCtx)              \
-       (ULTRA_check_channel_server(UltraVnicChannelProtocolGuid,       \
-                                   "vnic", MIN_IO_CHANNEL_SIZE, actualBytes, \
-                                   __FILE__, __LINE__, logCtx))
-#define ULTRA_VSWITCH_CHANNEL_OK_CLIENT(pChannel, logCtx)              \
-       (ULTRA_check_channel_client(pChannel, UltraVswitchChannelProtocolGuid, \
-                                   "vswitch", MIN_IO_CHANNEL_SIZE,     \
-                                   ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID, \
-                                   ULTRA_VSWITCH_CHANNEL_PROTOCOL_SIGNATURE, \
-                                   __FILE__, __LINE__, logCtx))
-#define ULTRA_VSWITCH_CHANNEL_OK_SERVER(actualBytes, logCtx)          \
-       (ULTRA_check_channel_server(UltraVswitchChannelProtocolGuid,    \
-                                   "vswitch", MIN_IO_CHANNEL_SIZE,     \
-                                   actualBytes,                    \
-                                   __FILE__, __LINE__, logCtx))
+#define SPAR_VHBA_CHANNEL_OK_CLIENT(ch)                        \
+       (spar_check_channel_client(ch, spar_vhba_channel_protocol_uuid, \
+                                  "vhba", MIN_IO_CHANNEL_SIZE, \
+                                  ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \
+                                  ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE))
+
+#define SPAR_VNIC_CHANNEL_OK_CLIENT(ch)                        \
+       (spar_check_channel_client(ch, spar_vnic_channel_protocol_uuid, \
+                                  "vnic", MIN_IO_CHANNEL_SIZE, \
+                                  ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \
+                                  ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE))
+
 /*
 * Everything necessary to handle SCSI & NIC traffic between Guest Partition and
 * IO Partition is defined below.  */
 
-
 /*
 * Defines and enums.
 */
                                                 * SCSI Host value */
 
 /* various types of network packets that can be sent in cmdrsp */
-typedef enum { NET_RCV_POST = 0,       /* submit buffer to hold receiving
-                                        * incoming packet */
+enum net_types {
+       NET_RCV_POST = 0,       /* submit buffer to hold receiving
+                                * incoming packet */
        /* virtnic -> uisnic */
        NET_RCV,                /* incoming packet received */
        /* uisnic -> virtpci */
@@ -195,7 +175,7 @@ typedef enum { NET_RCV_POST = 0,    /* submit buffer to hold receiving
                                 * its MAC addr */
        NET_MACADDR_ACK,        /* MAC address  */
 
-} NET_TYPES;
+};
 
 #define                ETH_HEADER_SIZE 14      /* size of ethernet header */
 
@@ -211,19 +191,23 @@ typedef enum { NET_RCV_POST = 0,  /* submit buffer to hold receiving
 #define MAX_MACADDR_LEN 6      /* number of bytes in MAC address */
 #endif                         /* MAX_MACADDR_LEN */
 
-#define ETH_IS_LOCALLY_ADMINISTERED(Address) \
-       (((u8 *) (Address))[0] & ((u8) 0x02))
+#define ETH_IS_LOCALLY_ADMINISTERED(address) \
+       (((u8 *)(address))[0] & ((u8)0x02))
 #define NIC_VENDOR_ID 0x0008000B
 
 /* various types of scsi task mgmt commands  */
-typedef enum { TASK_MGMT_ABORT_TASK =
-           1, TASK_MGMT_BUS_RESET, TASK_MGMT_LUN_RESET,
-           TASK_MGMT_TARGET_RESET,
-} TASK_MGMT_TYPES;
+enum task_mgmt_types {
+       TASK_MGMT_ABORT_TASK = 1,
+       TASK_MGMT_BUS_RESET,
+       TASK_MGMT_LUN_RESET,
+       TASK_MGMT_TARGET_RESET,
+};
 
 /* various types of vdisk mgmt commands  */
-typedef enum { VDISK_MGMT_ACQUIRE = 1, VDISK_MGMT_RELEASE,
-} VDISK_MGMT_TYPES;
+enum vdisk_mgmt_types {
+       VDISK_MGMT_ACQUIRE = 1,
+       VDISK_MGMT_RELEASE,
+};
 
 /* this is used in the vdest field  */
 #define VDEST_ALL 0xFFFF
@@ -242,7 +226,6 @@ typedef enum { VDISK_MGMT_ACQUIRE = 1, VDISK_MGMT_RELEASE,
 /*
  * structs with pragma pack  */
 
-
 /* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */
 /* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */
 
@@ -377,16 +360,16 @@ struct uiscmdrsp_scsi {
        do {                                                            \
                memset(buf, 0,                                          \
                       MINNUM(len,                                      \
-                             (unsigned int) NO_DISK_INQUIRY_RESULT_LEN)); \
-               buf[2] = (u8) SCSI_SPC2_VER;                            \
+                             (unsigned int)NO_DISK_INQUIRY_RESULT_LEN)); \
+               buf[2] = (u8)SCSI_SPC2_VER;                             \
                if (lun == 0) {                                         \
-                       buf[0] = (u8) lun0notpresent;                   \
-                       buf[3] = (u8) DEV_HISUPPORT;                    \
+                       buf[0] = (u8)lun0notpresent;                    \
+                       buf[3] = (u8)DEV_HISUPPORT;                     \
                } else                                                  \
-                       buf[0] = (u8) notpresent;                       \
-               buf[4] = (u8) (                                         \
+                       buf[0] = (u8)notpresent;                        \
+               buf[4] = (u8)                                         \
                        MINNUM(len,                                     \
-                              (unsigned int) NO_DISK_INQUIRY_RESULT_LEN) - 5); \
+                              (unsigned int)NO_DISK_INQUIRY_RESULT_LEN) - 5);\
                if (len >= NO_DISK_INQUIRY_RESULT_LEN) {                \
                        buf[8] = 'D';                                   \
                        buf[9] = 'E';                                   \
@@ -410,12 +393,10 @@ struct uiscmdrsp_scsi {
                }                                                       \
        } while (0)
 
-
 /*
 * Struct & Defines to support sense information.
 */
 
-
 /* The following struct is returned in sensebuf field in uiscmdrsp_scsi.  It is
 * initialized in exactly the manner that is recommended in Windows (hence the
 * odd values).
@@ -429,21 +410,21 @@ struct uiscmdrsp_scsi {
 * AdditionalSenseLength                contains will be sizeof(sense_data)-8=10.
 */
 struct sense_data {
-       u8 ErrorCode:7;
-       u8 Valid:1;
-       u8 SegmentNumber;
-       u8 SenseKey:4;
-       u8 Reserved:1;
-       u8 IncorrectLength:1;
-       u8 EndOfMedia:1;
-       u8 FileMark:1;
-       u8 Information[4];
-       u8 AdditionalSenseLength;
-       u8 CommandSpecificInformation[4];
-       u8 AdditionalSenseCode;
-       u8 AdditionalSenseCodeQualifier;
-       u8 FieldReplaceableUnitCode;
-       u8 SenseKeySpecific[3];
+       u8 errorcode:7;
+       u8 valid:1;
+       u8 segment_number;
+       u8 sense_key:4;
+       u8 reserved:1;
+       u8 incorrect_length:1;
+       u8 end_of_media:1;
+       u8 file_mark:1;
+       u8 information[4];
+       u8 additional_sense_length;
+       u8 command_specific_information[4];
+       u8 additional_sense_code;
+       u8 additional_sense_code_qualifier;
+       u8 fru_code;
+       u8 sense_key_specific[3];
 };
 
 /* some SCSI ADSENSE codes */
@@ -484,7 +465,6 @@ struct net_pkt_xmt {
                                                 * each fragment */
        char ethhdr[ETH_HEADER_SIZE];   /* the ethernet header  */
        struct {
-
                    /* these are needed for csum at uisnic end */
                u8 valid;       /* 1 = rest of this struct is valid - else
                                 * ignore */
@@ -528,13 +508,12 @@ struct net_pkt_rcvpost {
            * to be describable */
            struct phys_info frag;      /* physical page information for the
                                         * single fragment 2K rcv buf */
-           u64 UniqueNum;              /* This is used to make sure that
+           u64 unique_num;             /* This is used to make sure that
                                         * receive posts are returned to  */
            /* the Adapter which sent them origonally. */
 };
 
 struct net_pkt_rcv {
-
        /* the number of receive buffers that can be chained  */
        /* is based on max mtu and size of each rcv buf */
        u32 rcv_done_len;       /* length of received data */
@@ -544,8 +523,8 @@ struct net_pkt_rcv {
                                                 * that must be chained; */
        /* each entry is a receive buffer provided by NET_RCV_POST. */
        /* NOTE: first rcvbuf in the chain will also be provided in net.buf. */
-       u64 UniqueNum;
-       u32 RcvsDroppedDelta;
+       u64 unique_num;
+       u32 rcvs_dropped_delta;
 };
 
 struct net_pkt_enbdis {
@@ -560,7 +539,7 @@ struct net_pkt_macaddr {
 
 /* cmd rsp packet used for VNIC network traffic  */
 struct uiscmdrsp_net {
-       NET_TYPES type;
+       enum net_types type;
        void *buf;
        union {
                struct net_pkt_xmt xmt; /* used for NET_XMIT */
@@ -576,7 +555,7 @@ struct uiscmdrsp_net {
 };
 
 struct uiscmdrsp_scsitaskmgmt {
-       TASK_MGMT_TYPES tasktype;
+       enum task_mgmt_types tasktype;
 
            /* the type of task */
        struct uisscsi_dest vdest;
@@ -594,7 +573,7 @@ struct uiscmdrsp_scsitaskmgmt {
            * For windows guests, this is a pointer to a location that a waiting
            * thread is testing to see if the taskmgmt command has completed.
            * When the rsp is received by guest, the thread receiving the
-           * response uses this to notify the the thread waiting for taskmgmt
+           * response uses this to notify the thread waiting for taskmgmt
            * command completion.  Its value is preserved by iopart & returned
            * as is in the task mgmt rsp. */
        void *notifyresult;
@@ -615,7 +594,7 @@ struct uiscmdrsp_scsitaskmgmt {
 /* Note that the vHba pointer is not used by the Client/Guest side. */
 struct uiscmdrsp_disknotify {
        u8 add;         /* 0-remove, 1-add */
-       void *vHba;             /* Pointer to vhba_info for channel info to
+       void *v_hba;            /* Pointer to vhba_info for channel info to
                                 * route msg */
        u32 channel, id, lun;   /* SCSI Path of Disk to added or removed */
 };
@@ -623,7 +602,7 @@ struct uiscmdrsp_disknotify {
 /* The following is used by virthba/vSCSI to send the Acquire/Release commands
 * to the IOVM.  */
 struct uiscmdrsp_vdiskmgmt {
-       VDISK_MGMT_TYPES vdisktype;
+       enum vdisk_mgmt_types vdisktype;
 
            /* the type of task */
        struct uisscsi_dest vdest;
@@ -641,7 +620,7 @@ struct uiscmdrsp_vdiskmgmt {
            * For windows guests, this is a pointer to a location that a waiting
            * thread is testing to see if the taskmgmt command has completed.
            * When the rsp is received by guest, the thread receiving the
-           * response uses this to notify the the thread waiting for taskmgmt
+           * response uses this to notify the thread waiting for taskmgmt
            * command completion.  Its value is preserved by iopart & returned
            * as is in the task mgmt rsp. */
        void *notifyresult;
@@ -683,11 +662,11 @@ struct uiscmdrsp {
 
 /* This is just the header of the IO channel.  It is assumed that directly after
 * this header there is a large region of memory which contains the command and
-* response queues as specified in cmdQ and rspQ SIGNAL_QUEUE_HEADERS. */
-typedef struct _ULTRA_IO_CHANNEL_PROTOCOL {
-       CHANNEL_HEADER ChannelHeader;
-       SIGNAL_QUEUE_HEADER cmdQ;
-       SIGNAL_QUEUE_HEADER rspQ;
+* response queues as specified in cmd_q and rsp_q SIGNAL_QUEUE_HEADERS. */
+struct spar_io_channel_protocol {
+       struct channel_header channel_header;
+       struct signal_queue_header cmd_q;
+       struct signal_queue_header rsp_q;
        union {
                struct {
                        struct vhba_wwnn wwnn;  /* 8 bytes */
@@ -697,14 +676,14 @@ typedef struct _ULTRA_IO_CHANNEL_PROTOCOL {
                        u8 macaddr[MAX_MACADDR_LEN];    /* 6 bytes */
                        u32 num_rcv_bufs;       /* 4 */
                        u32 mtu;        /* 4 */
-                       uuid_le zoneGuid;       /* 16 */
+                       uuid_le zone_uuid;      /* 16 */
                } vnic;         /* total     30 */
        };
 
 #define MAX_CLIENTSTRING_LEN 1024
-        u8 clientString[MAX_CLIENTSTRING_LEN]; /* NULL terminated - so holds
+        u8 client_string[MAX_CLIENTSTRING_LEN];/* NULL terminated - so holds
                                                 * max - 1 bytes */
-} ULTRA_IO_CHANNEL_PROTOCOL;
+};
 
 #pragma pack(pop)
 /* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */
@@ -733,144 +712,17 @@ typedef struct _ULTRA_IO_CHANNEL_PROTOCOL {
 * INLINE functions for initializing and accessing I/O data channels
 */
 
-
-#define NUMSIGNALS(x, q) (((ULTRA_IO_CHANNEL_PROTOCOL *)(x))->q.MaxSignalSlots)
-#define SIZEOF_PROTOCOL (COVER(sizeof(ULTRA_IO_CHANNEL_PROTOCOL), 64))
+#define SIZEOF_PROTOCOL (COVER(sizeof(struct spar_io_channel_protocol), 64))
 #define SIZEOF_CMDRSP (COVER(sizeof(struct uiscmdrsp), 64))
 
-#define IO_CHANNEL_SIZE(x) COVER(SIZEOF_PROTOCOL + \
-                                (NUMSIGNALS(x, cmdQ) + \
-                                 NUMSIGNALS(x, rspQ)) * SIZEOF_CMDRSP, 4096)
 #define MIN_IO_CHANNEL_SIZE COVER(SIZEOF_PROTOCOL + \
                                  2 * MIN_NUMSIGNALS * SIZEOF_CMDRSP, 4096)
-#ifdef __GNUC__
-/* These defines should only ever be used in service partitons */
-/* because they rely on the size of uiscmdrsp */
-#define QSLOTSFROMBYTES(bytes) (((bytes-SIZEOF_PROTOCOL)/2)/SIZEOF_CMDRSP)
-#define QSIZEFROMBYTES(bytes) (QSLOTSFROMBYTES(bytes)*SIZEOF_CMDRSP)
-#define SignalQInit(x)                                         \
-       do {                                                    \
-               x->cmdQ.Size = QSIZEFROMBYTES(x->ChannelHeader.Size);   \
-               x->cmdQ.oSignalBase = SIZEOF_PROTOCOL -                 \
-                       offsetof(ULTRA_IO_CHANNEL_PROTOCOL, cmdQ);      \
-               x->cmdQ.SignalSize = SIZEOF_CMDRSP;                     \
-               x->cmdQ.MaxSignalSlots =                                \
-                       QSLOTSFROMBYTES(x->ChannelHeader.Size);         \
-               x->cmdQ.MaxSignals = x->cmdQ.MaxSignalSlots - 1;        \
-               x->rspQ.Size = QSIZEFROMBYTES(x->ChannelHeader.Size);   \
-               x->rspQ.oSignalBase =                                   \
-                       (SIZEOF_PROTOCOL + x->cmdQ.Size) -              \
-                       offsetof(ULTRA_IO_CHANNEL_PROTOCOL, rspQ);      \
-               x->rspQ.SignalSize = SIZEOF_CMDRSP;                     \
-               x->rspQ.MaxSignalSlots =                                \
-                       QSLOTSFROMBYTES(x->ChannelHeader.Size);         \
-               x->rspQ.MaxSignals = x->rspQ.MaxSignalSlots - 1;        \
-               x->ChannelHeader.oChannelSpace =                        \
-                       offsetof(ULTRA_IO_CHANNEL_PROTOCOL, cmdQ);      \
-       } while (0)
-
-#define INIT_CLIENTSTRING(chan, type, clientStr, clientStrLen) \
-       do {                                                            \
-               if (clientStr) {                                        \
-                       chan->ChannelHeader.oClientString =             \
-                               offsetof(type, clientString);           \
-                       memcpy(chan->clientString, clientStr,           \
-                              MINNUM(clientStrLen,                     \
-                                     (u32) (MAX_CLIENTSTRING_LEN - 1))); \
-                       chan->clientString[MINNUM(clientStrLen,         \
-                                                 (u32) (MAX_CLIENTSTRING_LEN \
-                                                        - 1))]         \
-                               = '\0';                                 \
-               }                                                       \
-               else                                                    \
-                       if (clientStrLen > 0)                           \
-                               return 0;                               \
-       } while (0)
-
-
-#define ULTRA_IO_CHANNEL_SERVER_READY(x, chanId, logCtx) \
-       ULTRA_CHANNEL_SERVER_TRANSITION(x, chanId, SrvState, CHANNELSRV_READY, \
-                                       logCtx)
-
-#define ULTRA_IO_CHANNEL_SERVER_NOTREADY(x, chanId, logCtx)    \
-       ULTRA_CHANNEL_SERVER_TRANSITION(x, chanId, SrvState, \
-                                       CHANNELSRV_UNINITIALIZED, logCtx)
-
-static inline int ULTRA_VHBA_init_channel(ULTRA_IO_CHANNEL_PROTOCOL *x,
-                                             struct vhba_wwnn *wwnn,
-                                             struct vhba_config_max *max,
-                                             unsigned char *clientStr,
-                                             u32 clientStrLen, u64 bytes)  {
-       memset(x, 0, sizeof(ULTRA_IO_CHANNEL_PROTOCOL));
-       x->ChannelHeader.VersionId = ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID;
-       x->ChannelHeader.Signature = ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE;
-       x->ChannelHeader.SrvState = CHANNELSRV_UNINITIALIZED;
-       x->ChannelHeader.HeaderSize = sizeof(x->ChannelHeader);
-       x->ChannelHeader.Size = COVER(bytes, 4096);
-       x->ChannelHeader.Type = UltraVhbaChannelProtocolGuid;
-       x->ChannelHeader.ZoneGuid = NULL_UUID_LE;
-       x->vhba.wwnn = *wwnn;
-       x->vhba.max = *max;
-       INIT_CLIENTSTRING(x, ULTRA_IO_CHANNEL_PROTOCOL, clientStr,
-                         clientStrLen);
-       SignalQInit(x);
-       if ((x->cmdQ.MaxSignalSlots > MAX_NUMSIGNALS) ||
-            (x->rspQ.MaxSignalSlots > MAX_NUMSIGNALS)) {
-               return 0;
-       }
-       if ((x->cmdQ.MaxSignalSlots < MIN_NUMSIGNALS) ||
-            (x->rspQ.MaxSignalSlots < MIN_NUMSIGNALS)) {
-               return 0;
-       }
-       return 1;
-}
-
-static inline void ULTRA_VHBA_set_max(ULTRA_IO_CHANNEL_PROTOCOL *x,
-                                     struct vhba_config_max *max)  {
-       x->vhba.max = *max;
-}
-
-static inline int ULTRA_VNIC_init_channel(ULTRA_IO_CHANNEL_PROTOCOL *x,
-                                                unsigned char *macaddr,
-                                                u32 num_rcv_bufs, u32 mtu,
-                                                uuid_le zoneGuid,
-                                                unsigned char *clientStr,
-                                                u32 clientStrLen,
-                                                u64 bytes)  {
-       memset(x, 0, sizeof(ULTRA_IO_CHANNEL_PROTOCOL));
-       x->ChannelHeader.VersionId = ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID;
-       x->ChannelHeader.Signature = ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE;
-       x->ChannelHeader.SrvState = CHANNELSRV_UNINITIALIZED;
-       x->ChannelHeader.HeaderSize = sizeof(x->ChannelHeader);
-       x->ChannelHeader.Size = COVER(bytes, 4096);
-       x->ChannelHeader.Type = UltraVnicChannelProtocolGuid;
-       x->ChannelHeader.ZoneGuid = NULL_UUID_LE;
-       memcpy(x->vnic.macaddr, macaddr, MAX_MACADDR_LEN);
-       x->vnic.num_rcv_bufs = num_rcv_bufs;
-       x->vnic.mtu = mtu;
-       x->vnic.zoneGuid = zoneGuid;
-       INIT_CLIENTSTRING(x, ULTRA_IO_CHANNEL_PROTOCOL, clientStr,
-                          clientStrLen);
-       SignalQInit(x);
-       if ((x->cmdQ.MaxSignalSlots > MAX_NUMSIGNALS) ||
-            (x->rspQ.MaxSignalSlots > MAX_NUMSIGNALS)) {
-               return 0;
-       }
-       if ((x->cmdQ.MaxSignalSlots < MIN_NUMSIGNALS) ||
-            (x->rspQ.MaxSignalSlots < MIN_NUMSIGNALS)) {
-               return 0;
-       }
-       return 1;
-}
-
-#endif /* __GNUC__ */
 
 /*
 * INLINE function for expanding a guest's pfn-off-size into multiple 4K page
 * pfn-off-size entires.
 */
 
-
 /* we deal with 4K page sizes when we it comes to passing page information
  * between */
 /* Guest and IOPartition. */
@@ -900,13 +752,12 @@ add_physinfo_entries(u32 inp_pfn, /* input - specifies the pfn to be used
 
        firstlen = PI_PAGE_SIZE - inp_off;
        if (inp_len <= firstlen) {
-
                /* the input entry spans only one page - add as is */
                if (index >= max_pi_arr_entries)
                        return 0;
                pi_arr[index].pi_pfn = inp_pfn;
-               pi_arr[index].pi_off = (u16) inp_off;
-               pi_arr[index].pi_len = (u16) inp_len;
+               pi_arr[index].pi_off = (u16)inp_off;
+               pi_arr[index].pi_len = (u16)inp_len;
                    return index + 1;
        }
 
@@ -924,9 +775,8 @@ add_physinfo_entries(u32 inp_pfn,   /* input - specifies the pfn to be used
                else {
                        pi_arr[index + i].pi_off = 0;
                        pi_arr[index + i].pi_len =
-                           (u16) MINNUM(len, (u32) PI_PAGE_SIZE);
+                           (u16)MINNUM(len, (u32)PI_PAGE_SIZE);
                }
-
        }
        return index + i;
 }
index 1231c45..2c42ce1 100644 (file)
 #include "channel.h"
 
 /* {193b331b-c58f-11da-95a9-00e08161165f} */
-#define ULTRA_VBUS_CHANNEL_PROTOCOL_GUID \
+#define SPAR_VBUS_CHANNEL_PROTOCOL_UUID \
                UUID_LE(0x193b331b, 0xc58f, 0x11da, \
                                0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f)
-static const uuid_le UltraVbusChannelProtocolGuid =
-       ULTRA_VBUS_CHANNEL_PROTOCOL_GUID;
+static const uuid_le spar_vbus_channel_protocol_uuid =
+       SPAR_VBUS_CHANNEL_PROTOCOL_UUID;
 
-#define ULTRA_VBUS_CHANNEL_PROTOCOL_SIGNATURE ULTRA_CHANNEL_PROTOCOL_SIGNATURE
+#define SPAR_VBUS_CHANNEL_PROTOCOL_SIGNATURE ULTRA_CHANNEL_PROTOCOL_SIGNATURE
 
 /* Must increment this whenever you insert or delete fields within this channel
 * struct.  Also increment whenever you change the meaning of fields within this
 * channel struct so as to break pre-existing software.  Note that you can
 * usually add fields to the END of the channel struct withOUT needing to
 * increment this. */
-#define ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID 1
+#define SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID 1
 
-#define ULTRA_VBUS_CHANNEL_OK_CLIENT(pChannel, logCtx)       \
-       (ULTRA_check_channel_client(pChannel,                           \
-                                   UltraVbusChannelProtocolGuid,       \
-                                   "vbus",                             \
-                                   sizeof(ULTRA_VBUS_CHANNEL_PROTOCOL), \
-                                   ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID, \
-                                   ULTRA_VBUS_CHANNEL_PROTOCOL_SIGNATURE, \
-                                   __FILE__, __LINE__, logCtx))
-
-#define ULTRA_VBUS_CHANNEL_OK_SERVER(actualBytes, logCtx)    \
-       (ULTRA_check_channel_server(UltraVbusChannelProtocolGuid,       \
-                                   "vbus",                             \
-                                   sizeof(ULTRA_VBUS_CHANNEL_PROTOCOL), \
-                                   actualBytes,                        \
-                                   __FILE__, __LINE__, logCtx))
+#define SPAR_VBUS_CHANNEL_OK_CLIENT(ch)       \
+       spar_check_channel_client(ch,                           \
+                                  spar_vbus_channel_protocol_uuid,     \
+                                  "vbus",                              \
+                                  sizeof(struct spar_vbus_channel_protocol),\
+                                  SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID, \
+                                  SPAR_VBUS_CHANNEL_PROTOCOL_SIGNATURE)
 
+#define SPAR_VBUS_CHANNEL_OK_SERVER(actual_bytes)    \
+       (spar_check_channel_server(spar_vbus_channel_protocol_uuid,     \
+                                  "vbus",                              \
+                                  sizeof(struct ultra_vbus_channel_protocol),\
+                                  actual_bytes))
 
 #pragma pack(push, 1)          /* both GCC and VC now allow this pragma */
-typedef struct _ULTRA_VBUS_HEADERINFO {
-       u32 structBytes;        /* size of this struct in bytes */
-       u32 deviceInfoStructBytes;      /* sizeof(ULTRA_VBUS_DEVICEINFO) */
-       u32 devInfoCount;       /* num of items in DevInfo member */
+struct spar_vbus_headerinfo {
+       u32 struct_bytes;       /* size of this struct in bytes */
+       u32 device_info_struct_bytes;   /* sizeof(ULTRA_VBUS_DEVICEINFO) */
+       u32 dev_info_count;     /* num of items in DevInfo member */
        /* (this is the allocated size) */
-       u32 chpInfoByteOffset;  /* byte offset from beginning of this struct */
-       /* to the the ChpInfo struct (below) */
-       u32 busInfoByteOffset;  /* byte offset from beginning of this struct */
-       /* to the the BusInfo struct (below) */
-       u32 devInfoByteOffset;  /* byte offset from beginning of this struct */
-       /* to the the DevInfo array (below) */
+       u32 chp_info_offset;    /* byte offset from beginning of this struct */
+       /* to the ChpInfo struct (below) */
+       u32 bus_info_offset;    /* byte offset from beginning of this struct */
+       /* to the BusInfo struct (below) */
+       u32 dev_info_offset;    /* byte offset from beginning of this struct */
+       /* to the DevInfo array (below) */
        u8 reserved[104];
-} ULTRA_VBUS_HEADERINFO;
+};
 
-typedef struct _ULTRA_VBUS_CHANNEL_PROTOCOL {
-       ULTRA_CHANNEL_PROTOCOL ChannelHeader;   /* initialized by server */
-       ULTRA_VBUS_HEADERINFO HdrInfo;  /* initialized by server */
+struct spar_vbus_channel_protocol {
+       struct channel_header channel_header;   /* initialized by server */
+       struct spar_vbus_headerinfo hdr_info;   /* initialized by server */
        /* the remainder of this channel is filled in by the client */
-       ULTRA_VBUS_DEVICEINFO ChpInfo;  /* describes client chipset device and
-                                        * driver */
-       ULTRA_VBUS_DEVICEINFO BusInfo;  /* describes client bus device and
-                                        * driver */
-       ULTRA_VBUS_DEVICEINFO DevInfo[0];       /* describes client device and
-                                                * driver for */
-       /* each device on the bus */
-} ULTRA_VBUS_CHANNEL_PROTOCOL;
+       struct ultra_vbus_deviceinfo chp_info;
+       /* describes client chipset device and driver */
+       struct ultra_vbus_deviceinfo bus_info;
+       /* describes client bus device and driver */
+       struct ultra_vbus_deviceinfo dev_info[0];
+       /* describes client device and driver for each device on the bus */
+};
 
 #define VBUS_CH_SIZE_EXACT(MAXDEVICES) \
        (sizeof(ULTRA_VBUS_CHANNEL_PROTOCOL) + ((MAXDEVICES) * \
index 3bbdc2b..9b6d3e6 100644 (file)
  * It is filled in by the client side to provide info about the device
  * and driver from the client's perspective.
  */
-typedef struct _ULTRA_VBUS_DEVICEINFO {
-       u8 devType[16];         /* short string identifying the device type */
-       u8 drvName[16];         /* driver .sys file name */
-       u8 infoStrings[96];     /* sequence of tab-delimited id strings: */
+struct ultra_vbus_deviceinfo {
+       u8 devtype[16];         /* short string identifying the device type */
+       u8 drvname[16];         /* driver .sys file name */
+       u8 infostrs[96];        /* sequence of tab-delimited id strings: */
        /* <DRIVER_REV> <DRIVER_VERTAG> <DRIVER_COMPILETIME> */
        u8 reserved[128];       /* pad size to 256 bytes */
-} ULTRA_VBUS_DEVICEINFO;
+};
 
 #pragma pack(pop)
 
@@ -63,8 +63,9 @@ vbuschannel_sanitize_buffer(char *p, int remain, char *src, int srcmax)
                                        p++;
                                        remain--;
                                        chars++;
-                               } else if (p == NULL)
+                               } else if (p == NULL) {
                                        chars++;
+                               }
                                nonprintable_streak = 0;
                        }
                        if (remain > 0) {
@@ -72,10 +73,12 @@ vbuschannel_sanitize_buffer(char *p, int remain, char *src, int srcmax)
                                p++;
                                remain--;
                                chars++;
-                       } else if (p == NULL)
+                       } else if (p == NULL) {
                                chars++;
-               } else
+                       }
+               } else {
                        nonprintable_streak = 1;
+               }
                src++;
                srcmax--;
        }
@@ -115,7 +118,7 @@ vbuschannel_itoa(char *p, int remain, int num)
        }
        /* form a backwards decimal ascii string in <s> */
        while (num > 0) {
-               if (digits >= (int) sizeof(s))
+               if (digits >= (int)sizeof(s))
                        return 0;
                s[digits++] = (num % 10) + '0';
                num = num / 10;
@@ -147,15 +150,15 @@ vbuschannel_itoa(char *p, int remain, int num)
  * Returns the number of bytes written to <p>.
  */
 static inline int
-vbuschannel_devinfo_to_string(ULTRA_VBUS_DEVICEINFO *devinfo,
-                                 char *p, int remain, int devix)
+vbuschannel_devinfo_to_string(struct ultra_vbus_deviceinfo *devinfo,
+                             char *p, int remain, int devix)
 {
        char *psrc;
        int nsrc, x, i, pad;
        int chars = 0;
 
-       psrc = &(devinfo->devType[0]);
-       nsrc = sizeof(devinfo->devType);
+       psrc = &devinfo->devtype[0];
+       nsrc = sizeof(devinfo->devtype);
        if (vbuschannel_sanitize_buffer(NULL, 0, psrc, nsrc) <= 0)
                return 0;
 
@@ -184,8 +187,8 @@ vbuschannel_devinfo_to_string(ULTRA_VBUS_DEVICEINFO *devinfo,
        VBUSCHANNEL_ADDACHAR(' ', p, remain, chars);
 
        /* emit driver name */
-       psrc = &(devinfo->drvName[0]);
-       nsrc = sizeof(devinfo->drvName);
+       psrc = &devinfo->drvname[0];
+       nsrc = sizeof(devinfo->drvname);
        x = vbuschannel_sanitize_buffer(p, remain, psrc, nsrc);
        p += x;
        remain -= x;
@@ -196,8 +199,8 @@ vbuschannel_devinfo_to_string(ULTRA_VBUS_DEVICEINFO *devinfo,
        VBUSCHANNEL_ADDACHAR(' ', p, remain, chars);
 
        /* emit strings */
-       psrc = &(devinfo->infoStrings[0]);
-       nsrc = sizeof(devinfo->infoStrings);
+       psrc = &devinfo->infostrs[0];
+       nsrc = sizeof(devinfo->infostrs);
        x = vbuschannel_sanitize_buffer(p, remain, psrc, nsrc);
        p += x;
        remain -= x;
index 0b5b562..7833371 100644 (file)
@@ -33,7 +33,7 @@
 
 /* define subsystem number for AppOS, used in uislib driver  */
 #define MDS_APPOS 0x4000000000000000L  /* subsystem = 62 - AppOS */
-typedef enum {         /* VMCALL identification tuples  */
+enum vmcall_monitor_interface_method_tuple { /* VMCALL identification tuples  */
            /* Note: when a new VMCALL is added:
             * - the 1st 2 hex digits correspond to one of the
             *   VMCALL_MONITOR_INTERFACE types and
@@ -66,7 +66,7 @@ typedef enum {                /* VMCALL identification tuples  */
                                                 * ULTRA_SERVICE_CAPABILITY_TIME
                                                 * capable guest to make
                                                 * VMCALL */
-} VMCALL_MONITOR_INTERFACE_METHOD_TUPLE;
+};
 
 #define VMCALL_SUCCESS 0
 #define VMCALL_SUCCESSFUL(result)      (result == 0)
@@ -76,12 +76,12 @@ typedef enum {              /* VMCALL identification tuples  */
        __unisys_vmcall_gnuc(tuple, reg_ebx, reg_ecx)
 #define unisys_extended_vmcall(tuple, reg_ebx, reg_ecx, reg_edx) \
        __unisys_extended_vmcall_gnuc(tuple, reg_ebx, reg_ecx, reg_edx)
-#define ISSUE_IO_VMCALL(InterfaceMethod, param, result) \
-       (result = unisys_vmcall(InterfaceMethod, (param) & 0xFFFFFFFF,  \
+#define ISSUE_IO_VMCALL(method, param, result) \
+       (result = unisys_vmcall(method, (param) & 0xFFFFFFFF,   \
                                (param) >> 32))
-#define ISSUE_IO_EXTENDED_VMCALL(InterfaceMethod, param1, param2,      \
+#define ISSUE_IO_EXTENDED_VMCALL(method, param1, param2,       \
                                 param3, result)                        \
-       (result = unisys_extended_vmcall(InterfaceMethod, param1,       \
+       (result = unisys_extended_vmcall(method, param1,        \
                                         param2, param3))
 
     /* The following uses VMCALL_POST_CODE_LOGEVENT interface but is currently
@@ -107,21 +107,20 @@ struct phys_info {
 
 #pragma pack(pop)
 /* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */
-typedef struct phys_info IO_DATA_STRUCTURE;
 
 /* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */
 /* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */
 #pragma pack(push, 1)
 /* Parameters to VMCALL_IO_CONTROLVM_ADDR interface */
-typedef struct _VMCALL_IO_CONTROLVM_ADDR_PARAMS {
+struct vmcall_io_controlvm_addr_params {
            /* The Guest-relative physical address of the ControlVm channel.
            * This VMCall fills this in with the appropriate address. */
-       u64 ChannelAddress;     /* contents provided by this VMCALL (OUT) */
+       u64 address;    /* contents provided by this VMCALL (OUT) */
            /* the size of the ControlVm channel in bytes This VMCall fills this
            * in with the appropriate address. */
-       u32 ChannelBytes;       /* contents provided by this VMCALL (OUT) */
-       u8 Unused[4];           /* Unused Bytes in the 64-Bit Aligned Struct */
-} VMCALL_IO_CONTROLVM_ADDR_PARAMS;
+       u32 channel_bytes;      /* contents provided by this VMCALL (OUT) */
+       u8 unused[4];           /* Unused Bytes in the 64-Bit Aligned Struct */
+};
 
 #pragma pack(pop)
 /* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */
@@ -130,11 +129,11 @@ typedef struct _VMCALL_IO_CONTROLVM_ADDR_PARAMS {
 /* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */
 #pragma pack(push, 1)
 /* Parameters to VMCALL_IO_DIAG_ADDR interface */
-typedef struct _VMCALL_IO_DIAG_ADDR_PARAMS {
+struct vmcall_io_diag_addr_params {
            /* The Guest-relative physical address of the diagnostic channel.
            * This VMCall fills this in with the appropriate address. */
-       u64 ChannelAddress;     /* contents provided by this VMCALL (OUT) */
-} VMCALL_IO_DIAG_ADDR_PARAMS;
+       u64 address;    /* contents provided by this VMCALL (OUT) */
+};
 
 #pragma pack(pop)
 /* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */
@@ -143,25 +142,25 @@ typedef struct _VMCALL_IO_DIAG_ADDR_PARAMS {
 /* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */
 #pragma pack(push, 1)
 /* Parameters to VMCALL_IO_VISORSERIAL_ADDR interface */
-typedef struct _VMCALL_IO_VISORSERIAL_ADDR_PARAMS {
+struct vmcall_io_visorserial_addr_params {
            /* The Guest-relative physical address of the serial console
            * channel.  This VMCall fills this in with the appropriate
            * address. */
-       u64 ChannelAddress;     /* contents provided by this VMCALL (OUT) */
-} VMCALL_IO_VISORSERIAL_ADDR_PARAMS;
+       u64 address;    /* contents provided by this VMCALL (OUT) */
+};
 
 #pragma pack(pop)
 /* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */
 
 /* Parameters to VMCALL_CHANNEL_MISMATCH interface */
-typedef struct _VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS {
-       u8 ChannelName[32];     /* Null terminated string giving name of channel
+struct vmcall_channel_version_mismatch_params {
+       u8 chname[32];  /* Null terminated string giving name of channel
                                 * (IN) */
-       u8 ItemName[32];        /* Null terminated string giving name of
+       u8 item_name[32];       /* Null terminated string giving name of
                                 * mismatched item (IN) */
-       u32 SourceLineNumber;   /* line# where invoked. (IN) */
-       u8 SourceFileName[36];  /* source code where invoked - Null terminated
+       u32 line_no;            /* line# where invoked. (IN) */
+       u8 file_name[36];       /* source code where invoked - Null terminated
                                 * string (IN) */
-} VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS;
+};
 
 #endif /* __IOMONINTF_H__ */
index b14494f..de11f44 100644 (file)
@@ -71,7 +71,6 @@
 
 /** Try to evaulate the provided expression, and do a RETINT(x) iff
  *  the expression evaluates to < 0.
- *  @param x the expression to try
  */
 #define ASSERT(cond)                                           \
        do { if (!(cond))                                      \
                (void *)(p2) = SWAPPOINTERS_TEMP;       \
        } while (0)
 
-/**
- *  @addtogroup driverlogging
- *  @{
- */
-
 #define PRINTKDRV(fmt, args...) LOGINF(fmt, ## args)
 #define TBDDRV(fmt, args...)    LOGERR(fmt, ## args)
 #define HUHDRV(fmt, args...)    LOGERR(fmt, ## args)
 #define INFODEVX(devno, fmt, args...)     LOGINFDEVX(devno, fmt, ## args)
 #define DEBUGDEV(devname, fmt, args...)   DBGINFDEV(devname, fmt, ## args)
 
-/* @} */
-
 /** Verifies the consistency of your PRIVATEDEVICEDATA structure using
  *  conventional "signature" fields:
  *  <p>
         ((fd)->sig2 == fd))
 
 /** Sleep for an indicated number of seconds (for use in kernel mode).
- *  @param x the number of seconds to sleep.
+ *  x - the number of seconds to sleep.
  */
 #define SLEEP(x)                                            \
        do { current->state = TASK_INTERRUPTIBLE;            \
        } while (0)
 
 /** Sleep for an indicated number of jiffies (for use in kernel mode).
- *  @param x the number of jiffies to sleep.
+ *  x - the number of jiffies to sleep.
  */
 #define SLEEPJIFFIES(x)                                                    \
        do { current->state = TASK_INTERRUPTIBLE;                   \
                schedule_timeout(x);                                \
        } while (0)
 
-#ifndef max
-#define max(a, b) (((a) > (b)) ? (a) : (b))
-#endif
-
 static inline struct cdev *cdev_alloc_init(struct module *owner,
                                           const struct file_operations *fops)
 {
index 5178270..25b6181 100644 (file)
@@ -34,8 +34,7 @@
 #include "controlvmcompletionstatus.h"
 
 struct uisqueue_info {
-
-       CHANNEL_HEADER __iomem *chan;
+       struct channel_header __iomem *chan;
        /* channel containing queues in which scsi commands &
         * responses are queued
         */
@@ -48,8 +47,8 @@ struct uisqueue_info {
        u64 non_empty_wakeup_cnt;
 
        struct {
-               SIGNAL_QUEUE_HEADER reserved1;  /*  */
-               SIGNAL_QUEUE_HEADER reserved2;  /*  */
+               struct signal_queue_header reserved1;   /*  */
+               struct signal_queue_header reserved2;   /*  */
        } safe_uis_queue;
        unsigned int (*send_int_if_needed)(struct uisqueue_info *info,
                                           unsigned int whichcqueue,
@@ -119,7 +118,7 @@ struct extport_info {
        */
 
        struct switch_info *swtch;
-       struct PciId pci_id;
+       struct pci_id pci_id;
        char name[MAX_NAME_SIZE_UISQUEUE];
        union {
                struct vhba_wwnn wwnn;
@@ -133,7 +132,7 @@ struct device_info {
        u64 channel_bytes;
        uuid_le channel_uuid;
        uuid_le instance_uuid;
-       struct InterruptInfo intr;
+       struct irq_info intr;
        struct switch_info *swtch;
        char devid[30];         /* "vbus<busno>:dev<devno>" */
        u16 polling;
@@ -149,30 +148,27 @@ struct device_info {
        unsigned long long last_on_list_cnt;
 };
 
-typedef enum {
+enum switch_type {
        RECOVERY_LAN = 1,
        IB_LAN = 2
-} SWITCH_TYPE;
+};
 
 struct bus_info {
-       u32 busNo, deviceCount;
+       u32 bus_no, device_count;
        struct device_info **device;
-       u64 guestHandle, recvBusInterruptHandle;
-       uuid_le busInstGuid;
-       ULTRA_VBUS_CHANNEL_PROTOCOL __iomem *pBusChannel;
-       int busChannelBytes;
+       u64 guest_handle, recv_bus_irq_handle;
+       uuid_le bus_inst_uuid;
+       struct ultra_vbus_channel_protocol __iomem *bus_channel;
+       int bus_channel_bytes;
        struct proc_dir_entry *proc_dir;        /* proc/uislib/vbus/<x> */
        struct proc_dir_entry *proc_info;       /* proc/uislib/vbus/<x>/info */
        char name[25];
-       char partitionName[99];
+       char partition_name[99];
        struct bus_info *next;
-       u8 localVnic;           /* 1 if local vnic created internally
+       u8 local_vnic;          /* 1 if local vnic created internally
                                 * by IOVM; 0 otherwise... */
 };
 
-#define DEDICATED_SWITCH(s) ((s->extPortCount == 1) && \
-                            (s->intPortCount == 1))
-
 struct sn_list_entry {
        struct uisscsi_dest pdest;      /* scsi bus, target, lun for
                                         * phys disk */
@@ -183,23 +179,12 @@ struct sn_list_entry {
        struct sn_list_entry *next;
 };
 
-struct network_policy {
-       u32 promiscuous:1;
-       u32 macassign:1;
-       u32 peerforwarding:1;
-       u32 nonotify:1;
-       u32 standby:1;
-       u32 callhome:2;
-       char ip_addr[30];
-};
-
 /*
  * IO messages sent to UisnicControlChanFunc & UissdControlChanFunc by
  * code that processes the ControlVm channel messages.
  */
 
-
-typedef enum {
+enum iopart_msg_type {
        IOPART_ADD_VNIC,
        IOPART_DEL_VNIC,
        IOPART_DEL_ALL_VNICS,
@@ -219,7 +204,7 @@ typedef enum {
        IOPART_RESUME_VDISK,
        IOPART_ADD_DEVICE,      /* add generic device */
        IOPART_DEL_DEVICE,      /* del generic device */
-} IOPART_MSG_TYPE;
+};
 
 struct add_virt_iopart {
        void *chanptr;          /* pointer to data channel */
@@ -228,7 +213,7 @@ struct add_virt_iopart {
                                 * for DMA, for ex. */
        u64 recv_bus_irq_handle;        /* used to register to receive
                                         * bus level interrupts. */
-       struct InterruptInfo intr;      /* contains recv & send
+       struct irq_info intr;   /* contains recv & send
                                         * interrupt info */
        /* recvInterruptHandle is used to register to receive
        * interrupts on the data channel. Used by GuestLinux/Windows
@@ -259,21 +244,15 @@ struct add_vdisk_iopart {
        struct uisscsi_dest pdest;    /* scsi bus, target, lun for phys disk */
        u8 sernum[MAX_SERIAL_NUM];    /* serial num of physical disk */
        u32 serlen;                   /* length of serial num */
-       u32 bus_no;
-       u32 dev_no;
 };
 
 struct del_vdisk_iopart {
        void *chanptr;               /* pointer to data channel */
        struct uisscsi_dest vdest;   /* scsi bus, target, lun for virt disk */
-       u32 bus_no;
-       u32 dev_no;
 };
 
 struct del_virt_iopart {
        void *chanptr;               /* pointer to data channel */
-       u32 bus_no;
-       u32 dev_no;
 };
 
 struct det_virt_iopart {            /* detach internal port */
@@ -297,8 +276,7 @@ struct del_switch_iopart {       /* destroy switch */
 };
 
 struct io_msgs {
-
-       IOPART_MSG_TYPE msgtype;
+       enum iopart_msg_type msgtype;
 
        /* additional params needed by some messages */
        union {
@@ -329,7 +307,7 @@ struct io_msgs {
 * the ControlVm channel messages.
 */
 
-typedef enum {
+enum guestpart_msg_type {
        GUEST_ADD_VBUS,
        GUEST_ADD_VHBA,
        GUEST_ADD_VNIC,
@@ -344,15 +322,15 @@ typedef enum {
        GUEST_PAUSE_VNIC,
        GUEST_RESUME_VHBA,
        GUEST_RESUME_VNIC
-} GUESTPART_MSG_TYPE;
+};
 
 struct add_vbus_guestpart {
        void __iomem *chanptr;          /* pointer to data channel for bus -
                                         * NOT YET USED */
-       u32 busNo;              /* bus number to be created/deleted */
-       u32 deviceCount;        /* max num of devices on bus */
-       uuid_le busTypeGuid;    /* indicates type of bus */
-       uuid_le busInstGuid;    /* instance guid for device */
+       u32 bus_no;             /* bus number to be created/deleted */
+       u32 dev_count;  /* max num of devices on bus */
+       uuid_le bus_uuid;       /* indicates type of bus */
+       uuid_le instance_uuid;  /* instance guid for device */
 };
 
 struct del_vbus_guestpart {
@@ -367,7 +345,7 @@ struct add_virt_guestpart {
        u32 bus_no;             /* bus number for the operation */
        u32 device_no;          /* number of device on the bus */
        uuid_le instance_uuid;  /* instance guid for device */
-       struct InterruptInfo intr;      /* recv/send interrupt info */
+       struct irq_info intr;   /* recv/send interrupt info */
        /* recvInterruptHandle contains info needed in order to
         * register to receive interrupts on the data channel.
         * sendInterruptHandle contains handle which is provided to
@@ -394,8 +372,7 @@ struct init_chipset_guestpart {
 };
 
 struct guest_msgs {
-
-       GUESTPART_MSG_TYPE msgtype;
+       enum guestpart_msg_type msgtype;
 
        /* additional params needed by messages */
        union {
index 74e7cf6..7414220 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/sched.h>
 #include <linux/gfp.h>
 #include <linux/uuid.h>
+#include <linux/if_ether.h>
 
 #include "vmcallinterface.h"
 #include "channel.h"
 /* global function pointers that act as callback functions into
  * uisnicmod, uissdmod, and virtpcimod
  */
-extern int (*UisnicControlChanFunc)(struct io_msgs *);
-extern int (*UissdControlChanFunc)(struct io_msgs *);
-extern int (*VirtControlChanFunc)(struct guest_msgs *);
+extern int (*uisnic_control_chan_func)(struct io_msgs *);
+extern int (*uissd_control_chan_func)(struct io_msgs *);
+extern int (*virt_control_chan_func)(struct guest_msgs *);
 
 /* Return values of above callback functions: */
 #define CCF_ERROR        0     /* completed and failed */
 #define CCF_OK           1     /* completed successfully */
 #define CCF_PENDING      2     /* operation still pending */
-extern atomic_t UisUtils_Registered_Services;
+extern atomic_t uisutils_registered_services;
 
-typedef unsigned int MACARRAY[MAX_MACADDR_LEN];
-typedef struct ReqHandlerInfo_struct {
-       uuid_le switchTypeGuid;
+struct req_handler_info {
+       uuid_le switch_uuid;
        int (*controlfunc)(struct io_msgs *);
        unsigned long min_channel_bytes;
-       int (*Server_Channel_Ok)(unsigned long channelBytes);
-       int (*Server_Channel_Init)
-        (void *x, unsigned char *clientStr, u32 clientStrLen, u64 bytes);
+       int (*server_channel_ok)(unsigned long channel_bytes);
+       int (*server_channel_init)(void *x, unsigned char *client_str,
+                                  u32 client_str_len, u64 bytes);
        char switch_type_name[99];
        struct list_head list_link;     /* links into ReqHandlerInfo_list */
-} ReqHandlerInfo_t;
+};
 
-ReqHandlerInfo_t *ReqHandlerAdd(uuid_le switchTypeGuid,
+struct req_handler_info *req_handler_add(uuid_le switch_uuid,
                                const char *switch_type_name,
                                int (*controlfunc)(struct io_msgs *),
                                unsigned long min_channel_bytes,
-                               int (*Server_Channel_Ok)(unsigned long
-                                                        channelBytes),
-                               int (*Server_Channel_Init)
-                                (void *x, unsigned char *clientStr,
-                                 u32 clientStrLen, u64 bytes));
-ReqHandlerInfo_t *ReqHandlerFind(uuid_le switchTypeGuid);
-int ReqHandlerDel(uuid_le switchTypeGuid);
+                               int (*svr_channel_ok)(unsigned long
+                                                        channel_bytes),
+                               int (*svr_channel_init)(void *x,
+                                               unsigned char *client_str,
+                                               u32 client_str_len, u64 bytes));
+struct req_handler_info *req_handler_find(uuid_le switch_uuid);
+int req_handler_del(uuid_le switch_uuid);
 
 #define uislib_ioremap_cache(addr, size) \
        dbg_ioremap_cache(addr, size, __FILE__, __LINE__)
@@ -114,52 +114,49 @@ int uisutil_add_proc_line_ex(int *total, char **buffer, int *buffer_remaining,
                             char *format, ...);
 
 int uisctrl_register_req_handler(int type, void *fptr,
-                                ULTRA_VBUS_DEVICEINFO *chipset_driver_info);
-int uisctrl_register_req_handler_ex(uuid_le switchTypeGuid,
-                                   const char *switch_type_name,
-                                   int (*fptr)(struct io_msgs *),
-                                   unsigned long min_channel_bytes,
-                                   int (*Server_Channel_Ok)(unsigned long
-                                                            channelBytes),
-                                   int (*Server_Channel_Init)
-                                   (void *x, unsigned char *clientStr,
-                                    u32 clientStrLen, u64 bytes),
-                                   ULTRA_VBUS_DEVICEINFO *chipset_DriverInfo);
-
-int uisctrl_unregister_req_handler_ex(uuid_le switchTypeGuid);
+                       struct ultra_vbus_deviceinfo *chipset_driver_info);
+int uisctrl_register_req_handler_ex(uuid_le switch_guid,
+                       const char *switch_type_name,
+                       int (*fptr)(struct io_msgs *),
+                       unsigned long min_channel_bytes,
+                       int (*svr_channel_ok)(unsigned long
+                                             channel_bytes),
+                       int (*svr_channel_init)(void *x,
+                                               unsigned char *client_str,
+                                               u32 client_str_len,
+                                               u64 bytes),
+                       struct ultra_vbus_deviceinfo *chipset_driver_info);
+
+int uisctrl_unregister_req_handler_ex(uuid_le switch_uuid);
 unsigned char *util_map_virt(struct phys_info *sg);
 void util_unmap_virt(struct phys_info *sg);
 unsigned char *util_map_virt_atomic(struct phys_info *sg);
 void util_unmap_virt_atomic(void *buf);
-int uislib_server_inject_add_vnic(u32 switchNo, u32 BusNo, u32 numIntPorts,
-                                 u32 numExtPorts, MACARRAY pmac[],
-                                 pCHANNEL_HEADER **chan);
-void uislib_server_inject_del_vnic(u32 switchNo, u32 busNo, u32 numIntPorts,
-                                  u32 numExtPorts);
-int uislib_client_inject_add_bus(u32 busNo, uuid_le instGuid,
-                                u64 channelAddr, ulong nChannelBytes);
-int  uislib_client_inject_del_bus(u32 busNo);
-
-int uislib_client_inject_add_vhba(u32 busNo, u32 devNo,
+int uislib_client_inject_add_bus(u32 bus_no, uuid_le inst_uuid,
+                                u64 channel_addr, ulong n_channel_bytes);
+int  uislib_client_inject_del_bus(u32 bus_no);
+
+int uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no,
                                  u64 phys_chan_addr, u32 chan_bytes,
-                                 int is_test_addr, uuid_le instGuid,
-                                 struct InterruptInfo *intr);
-int  uislib_client_inject_pause_vhba(u32 busNo, u32 devNo);
-int  uislib_client_inject_resume_vhba(u32 busNo, u32 devNo);
-int uislib_client_inject_del_vhba(u32 busNo, u32 devNo);
-int uislib_client_inject_add_vnic(u32 busNo, u32 devNo,
+                                 int is_test_addr, uuid_le inst_uuid,
+                                 struct irq_info *intr);
+int  uislib_client_inject_pause_vhba(u32 bus_no, u32 dev_no);
+int  uislib_client_inject_resume_vhba(u32 bus_no, u32 dev_no);
+int uislib_client_inject_del_vhba(u32 bus_no, u32 dev_no);
+int uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no,
                                  u64 phys_chan_addr, u32 chan_bytes,
-                                 int is_test_addr, uuid_le instGuid,
-                                 struct InterruptInfo *intr);
-int uislib_client_inject_pause_vnic(u32 busNo, u32 devNo);
-int uislib_client_inject_resume_vnic(u32 busNo, u32 devNo);
-int uislib_client_inject_del_vnic(u32 busNo, u32 devNo);
+                                 int is_test_addr, uuid_le inst_uuid,
+                                 struct irq_info *intr);
+int uislib_client_inject_pause_vnic(u32 bus_no, u32 dev_no);
+int uislib_client_inject_resume_vnic(u32 bus_no, u32 dev_no);
+int uislib_client_inject_del_vnic(u32 bus_no, u32 dev_no);
 #ifdef STORAGE_CHANNEL
 u64 uislib_storage_channel(int client_id);
 #endif
 int uislib_get_owned_pdest(struct uisscsi_dest *pdest);
 
-int uislib_send_event(CONTROLVM_ID id, CONTROLVM_MESSAGE_PACKET *event);
+int uislib_send_event(enum controlvm_id id,
+                     struct controlvm_message_packet *event);
 
 /* structure used by vhba & vnic to keep track of queue & thread info */
 struct chaninfo {
@@ -182,11 +179,14 @@ struct chaninfo {
        set_current_state(TASK_INTERRUPTIBLE); \
        schedule_timeout(msecs_to_jiffies(x)); \
 }
+
 #define UIS_THREAD_WAIT_USEC(x) { \
        set_current_state(TASK_INTERRUPTIBLE); \
        schedule_timeout(usecs_to_jiffies(x)); \
 }
+
 #define UIS_THREAD_WAIT UIS_THREAD_WAIT_MSEC(5)
+
 #define UIS_THREAD_WAIT_SEC(x) { \
        set_current_state(TASK_INTERRUPTIBLE); \
        schedule_timeout((x)*HZ); \
@@ -224,42 +224,42 @@ unsigned int uisutil_copy_fragsinfo_from_skb(unsigned char *calling_ctx,
 static inline unsigned int
 issue_vmcall_io_controlvm_addr(u64 *control_addr, u32 *control_bytes)
 {
-       VMCALL_IO_CONTROLVM_ADDR_PARAMS params;
+       struct vmcall_io_controlvm_addr_params params;
        int result = VMCALL_SUCCESS;
        u64 physaddr;
 
        physaddr = virt_to_phys(&params);
        ISSUE_IO_VMCALL(VMCALL_IO_CONTROLVM_ADDR, physaddr, result);
        if (VMCALL_SUCCESSFUL(result)) {
-               *control_addr = params.ChannelAddress;
-               *control_bytes = params.ChannelBytes;
+               *control_addr = params.address;
+               *control_bytes = params.channel_bytes;
        }
        return result;
 }
 
 static inline unsigned int issue_vmcall_io_diag_addr(u64 *diag_channel_addr)
 {
-       VMCALL_IO_DIAG_ADDR_PARAMS params;
+       struct vmcall_io_diag_addr_params params;
        int result = VMCALL_SUCCESS;
        u64 physaddr;
 
        physaddr = virt_to_phys(&params);
        ISSUE_IO_VMCALL(VMCALL_IO_DIAG_ADDR, physaddr, result);
        if (VMCALL_SUCCESSFUL(result))
-               *diag_channel_addr = params.ChannelAddress;
+               *diag_channel_addr = params.address;
        return result;
 }
 
 static inline unsigned int issue_vmcall_io_visorserial_addr(u64 *channel_addr)
 {
-       VMCALL_IO_VISORSERIAL_ADDR_PARAMS params;
+       struct vmcall_io_visorserial_addr_params params;
        int result = VMCALL_SUCCESS;
        u64 physaddr;
 
        physaddr = virt_to_phys(&params);
        ISSUE_IO_VMCALL(VMCALL_IO_VISORSERIAL_ADDR, physaddr, result);
        if (VMCALL_SUCCESSFUL(result))
-               *channel_addr = params.ChannelAddress;
+               *channel_addr = params.address;
        return result;
 }
 
@@ -273,17 +273,8 @@ static inline s64 issue_vmcall_query_guest_virtual_time_offset(void)
        return result;
 }
 
-static inline s64 issue_vmcall_measurement_do_nothing(void)
-{
-       u64 result = VMCALL_SUCCESS;
-       u64 physaddr = 0;
-
-       ISSUE_IO_VMCALL(VMCALL_MEASUREMENT_DO_NOTHING, physaddr, result);
-       return result;
-}
-
 struct log_info_t {
-       volatile unsigned long long last_cycles;
+       unsigned long long last_cycles;
        unsigned long long delta_sum[64];
        unsigned long long delta_cnt[64];
        unsigned long long max_delta[64];
@@ -302,44 +293,29 @@ static inline unsigned int issue_vmcall_channel_mismatch(const char *chname,
                              const char *item_name, u32 line_no,
                              const char *path_n_fn)
 {
-       VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS params;
+       struct vmcall_channel_version_mismatch_params params;
        int result = VMCALL_SUCCESS;
        u64 physaddr;
        char *last_slash = NULL;
 
-       strlcpy(params.ChannelName, chname,
-               lengthof(VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS, ChannelName));
-       strlcpy(params.ItemName, item_name,
-               lengthof(VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS, ItemName));
-       params.SourceLineNumber = line_no;
+       strlcpy(params.chname, chname, sizeof(params.chname));
+       strlcpy(params.item_name, item_name, sizeof(params.item_name));
+       params.line_no = line_no;
 
        last_slash = strrchr(path_n_fn, '/');
        if (last_slash != NULL) {
                last_slash++;
-               strlcpy(params.SourceFileName, last_slash,
-                       lengthof(VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS,
-                                SourceFileName));
+               strlcpy(params.file_name, last_slash, sizeof(params.file_name));
        } else
-               strlcpy(params.SourceFileName,
+               strlcpy(params.file_name,
                        "Cannot determine source filename",
-                       lengthof(VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS,
-                                SourceFileName));
+                       sizeof(params.file_name));
 
        physaddr = virt_to_phys(&params);
        ISSUE_IO_VMCALL(VMCALL_CHANNEL_VERSION_MISMATCH, physaddr, result);
        return result;
 }
 
-static inline unsigned int issue_vmcall_fatal(void)
-{
-       int result = VMCALL_SUCCESS;
-       u64 physaddr = 0;
-
-       ISSUE_IO_VMCALL(VMCALL_GENERIC_SURRENDER_QUANTUM_FOREVER, physaddr,
-                       result);
-       return result;
-}
-
 #define UIS_DAEMONIZE(nam)
 void *uislib_cache_alloc(struct kmem_cache *cur_pool, char *fn, int ln);
 #define UISCACHEALLOC(cur_pool) uislib_cache_alloc(cur_pool, __FILE__, __LINE__)
index 1bde549..84abe5f 100644 (file)
 #define TARGET_HOSTNAME "linuxguest"
 
 static inline void bus_device_info_init(
-               ULTRA_VBUS_DEVICEINFO * bus_device_info_ptr,
+               struct ultra_vbus_deviceinfo *bus_device_info_ptr,
                const char *dev_type, const char *drv_name,
                const char *ver, const char *ver_tag)
 {
-       memset(bus_device_info_ptr, 0, sizeof(ULTRA_VBUS_DEVICEINFO));
-       snprintf(bus_device_info_ptr->devType,
-                sizeof(bus_device_info_ptr->devType),
+       memset(bus_device_info_ptr, 0, sizeof(struct ultra_vbus_deviceinfo));
+       snprintf(bus_device_info_ptr->devtype,
+                sizeof(bus_device_info_ptr->devtype),
                 "%s", (dev_type) ? dev_type : "unknownType");
-       snprintf(bus_device_info_ptr->drvName,
-                sizeof(bus_device_info_ptr->drvName),
+       snprintf(bus_device_info_ptr->drvname,
+                sizeof(bus_device_info_ptr->drvname),
                 "%s", (drv_name) ? drv_name : "unknownDriver");
-       snprintf(bus_device_info_ptr->infoStrings,
-                sizeof(bus_device_info_ptr->infoStrings), "%s\t%s\t%s",
+       snprintf(bus_device_info_ptr->infostrs,
+                sizeof(bus_device_info_ptr->infostrs), "%s\t%s\t%s",
                 (ver) ? ver : "unknownVer",
                 (ver_tag) ? ver_tag : "unknownVerTag",
                 TARGET_HOSTNAME);
index 706f1c0..354b682 100644 (file)
@@ -57,7 +57,7 @@
 #define __MYFILE__ "uislib.c"
 
 /* global function pointers that act as callback functions into virtpcimod */
-int (*VirtControlChanFunc)(struct guest_msgs *);
+int (*virt_control_chan_func)(struct guest_msgs *);
 
 static int ProcReadBufferValid;
 static char *ProcReadBuffer;   /* Note this MUST be global,
@@ -121,12 +121,12 @@ static const struct file_operations debugfs_info_fops = {
 };
 
 static void
-init_msg_header(CONTROLVM_MESSAGE *msg, u32 id, uint rsp, uint svr)
+init_msg_header(struct controlvm_message *msg, u32 id, uint rsp, uint svr)
 {
-       memset(msg, 0, sizeof(CONTROLVM_MESSAGE));
-       msg->hdr.Id = id;
-       msg->hdr.Flags.responseExpected = rsp;
-       msg->hdr.Flags.server = svr;
+       memset(msg, 0, sizeof(struct controlvm_message));
+       msg->hdr.id = id;
+       msg->hdr.flags.response_expected = rsp;
+       msg->hdr.flags.server = svr;
 }
 
 static __iomem void *
@@ -142,7 +142,7 @@ init_vbus_channel(u64 channelAddr, u32 channelBytes)
                rc = NULL;
                goto Away;
        }
-       if (!ULTRA_VBUS_CHANNEL_OK_CLIENT(pChan, NULL)) {
+       if (!SPAR_VBUS_CHANNEL_OK_CLIENT(pChan)) {
                ERRDRV("%s channel cannot be used", __func__);
                uislib_iounmap(pChan);
                rc = NULL;
@@ -154,7 +154,7 @@ Away:
 }
 
 static int
-create_bus(CONTROLVM_MESSAGE *msg, char *buf)
+create_bus(struct controlvm_message *msg, char *buf)
 {
        u32 busNo, deviceCount;
        struct bus_info *tmp, *bus;
@@ -168,8 +168,8 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf)
                return CONTROLVM_RESP_ERROR_MAX_BUSES;
        }
 
-       busNo = msg->cmd.createBus.busNo;
-       deviceCount = msg->cmd.createBus.deviceCount;
+       busNo = msg->cmd.create_bus.bus_no;
+       deviceCount = msg->cmd.create_bus.dev_count;
 
        POSTCODE_LINUX_4(BUS_CREATE_ENTRY_PC, busNo, deviceCount,
                         POSTCODE_SEVERITY_INFO);
@@ -188,25 +188,25 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf)
        /* Currently by default, the bus Number is the GuestHandle.
         * Configure Bus message can override this.
         */
-       if (msg->hdr.Flags.testMessage) {
+       if (msg->hdr.flags.test_message) {
                /* This implies we're the IOVM so set guest handle to 0... */
-               bus->guestHandle = 0;
-               bus->busNo = busNo;
-               bus->localVnic = 1;
+               bus->guest_handle = 0;
+               bus->bus_no = busNo;
+               bus->local_vnic = 1;
        } else
-               bus->busNo = bus->guestHandle = busNo;
-       sprintf(bus->name, "%d", (int) bus->busNo);
-       bus->deviceCount = deviceCount;
+               bus->bus_no = bus->guest_handle = busNo;
+       sprintf(bus->name, "%d", (int) bus->bus_no);
+       bus->device_count = deviceCount;
        bus->device =
            (struct device_info **) ((char *) bus + sizeof(struct bus_info));
-       bus->busInstGuid = msg->cmd.createBus.busInstGuid;
-       bus->busChannelBytes = 0;
-       bus->pBusChannel = NULL;
+       bus->bus_inst_uuid = msg->cmd.create_bus.bus_inst_uuid;
+       bus->bus_channel_bytes = 0;
+       bus->bus_channel = NULL;
 
        /* add bus to our bus list - but check for duplicates first */
        read_lock(&BusListLock);
        for (tmp = BusListHead; tmp; tmp = tmp->next) {
-               if (tmp->busNo == bus->busNo)
+               if (tmp->bus_no == bus->bus_no)
                        break;
        }
        read_unlock(&BusListLock);
@@ -215,39 +215,39 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf)
                 * reject add
                 */
                LOGERR("CONTROLVM_BUS_CREATE Failed: bus %d already exists.\n",
-                      bus->busNo);
-               POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->busNo,
+                      bus->bus_no);
+               POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no,
                                 POSTCODE_SEVERITY_ERR);
                kfree(bus);
                return CONTROLVM_RESP_ERROR_ALREADY_DONE;
        }
-       if ((msg->cmd.createBus.channelAddr != 0)
-           && (msg->cmd.createBus.channelBytes != 0)) {
-               bus->busChannelBytes = msg->cmd.createBus.channelBytes;
-               bus->pBusChannel =
-                   init_vbus_channel(msg->cmd.createBus.channelAddr,
-                                     msg->cmd.createBus.channelBytes);
+       if ((msg->cmd.create_bus.channel_addr != 0)
+           && (msg->cmd.create_bus.channel_bytes != 0)) {
+               bus->bus_channel_bytes = msg->cmd.create_bus.channel_bytes;
+               bus->bus_channel =
+                   init_vbus_channel(msg->cmd.create_bus.channel_addr,
+                                     msg->cmd.create_bus.channel_bytes);
        }
        /* the msg is bound for virtpci; send guest_msgs struct to callback */
-       if (!msg->hdr.Flags.server) {
+       if (!msg->hdr.flags.server) {
                struct guest_msgs cmd;
 
                cmd.msgtype = GUEST_ADD_VBUS;
-               cmd.add_vbus.busNo = busNo;
-               cmd.add_vbus.chanptr = bus->pBusChannel;
-               cmd.add_vbus.deviceCount = deviceCount;
-               cmd.add_vbus.busTypeGuid = msg->cmd.createBus.busDataTypeGuid;
-               cmd.add_vbus.busInstGuid = msg->cmd.createBus.busInstGuid;
-               if (!VirtControlChanFunc) {
+               cmd.add_vbus.bus_no = busNo;
+               cmd.add_vbus.chanptr = bus->bus_channel;
+               cmd.add_vbus.dev_count = deviceCount;
+               cmd.add_vbus.bus_uuid = msg->cmd.create_bus.bus_data_type_uuid;
+               cmd.add_vbus.instance_uuid = msg->cmd.create_bus.bus_inst_uuid;
+               if (!virt_control_chan_func) {
                        LOGERR("CONTROLVM_BUS_CREATE Failed: virtpci callback not registered.");
-                       POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->busNo,
+                       POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no,
                                         POSTCODE_SEVERITY_ERR);
                        kfree(bus);
                        return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
                }
-               if (!VirtControlChanFunc(&cmd)) {
+               if (!virt_control_chan_func(&cmd)) {
                        LOGERR("CONTROLVM_BUS_CREATE Failed: virtpci GUEST_ADD_VBUS returned error.");
-                       POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->busNo,
+                       POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no,
                                         POSTCODE_SEVERITY_ERR);
                        kfree(bus);
                        return
@@ -266,26 +266,26 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf)
        BusListCount++;
        write_unlock(&BusListLock);
 
-       POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus->busNo,
+       POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus->bus_no,
                         POSTCODE_SEVERITY_INFO);
        return CONTROLVM_RESP_SUCCESS;
 }
 
 static int
-destroy_bus(CONTROLVM_MESSAGE *msg, char *buf)
+destroy_bus(struct controlvm_message *msg, char *buf)
 {
        int i;
        struct bus_info *bus, *prev = NULL;
        struct guest_msgs cmd;
        u32 busNo;
 
-       busNo = msg->cmd.destroyBus.busNo;
+       busNo = msg->cmd.destroy_bus.bus_no;
 
        read_lock(&BusListLock);
 
        bus = BusListHead;
        while (bus) {
-               if (bus->busNo == busNo)
+               if (bus->bus_no == busNo)
                        break;
                prev = bus;
                bus = bus->next;
@@ -299,7 +299,7 @@ destroy_bus(CONTROLVM_MESSAGE *msg, char *buf)
        }
 
        /* verify that this bus has no devices. */
-       for (i = 0; i < bus->deviceCount; i++) {
+       for (i = 0; i < bus->device_count; i++) {
                if (bus->device[i] != NULL) {
                        LOGERR("CONTROLVM_BUS_DESTROY Failed: device %i attached to bus %d.",
                             i, busNo);
@@ -309,18 +309,18 @@ destroy_bus(CONTROLVM_MESSAGE *msg, char *buf)
        }
        read_unlock(&BusListLock);
 
-       if (msg->hdr.Flags.server)
+       if (msg->hdr.flags.server)
                goto remove;
 
        /* client messages require us to call the virtpci callback associated
           with this bus. */
        cmd.msgtype = GUEST_DEL_VBUS;
        cmd.del_vbus.bus_no = busNo;
-       if (!VirtControlChanFunc) {
+       if (!virt_control_chan_func) {
                LOGERR("CONTROLVM_BUS_DESTROY Failed: virtpci callback not registered.");
                return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
        }
-       if (!VirtControlChanFunc(&cmd)) {
+       if (!virt_control_chan_func(&cmd)) {
                LOGERR("CONTROLVM_BUS_DESTROY Failed: virtpci GUEST_DEL_VBUS returned error.");
                return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
        }
@@ -335,9 +335,9 @@ remove:
        BusListCount--;
        write_unlock(&BusListLock);
 
-       if (bus->pBusChannel) {
-               uislib_iounmap(bus->pBusChannel);
-               bus->pBusChannel = NULL;
+       if (bus->bus_channel) {
+               uislib_iounmap(bus->bus_channel);
+               bus->bus_channel = NULL;
        }
 
        kfree(bus);
@@ -345,17 +345,17 @@ remove:
 }
 
 static int
-create_device(CONTROLVM_MESSAGE *msg, char *buf)
+create_device(struct controlvm_message *msg, char *buf)
 {
        struct device_info *dev;
        struct bus_info *bus;
        u32 busNo, devNo;
        int result = CONTROLVM_RESP_SUCCESS;
        u64 minSize = MIN_IO_CHANNEL_SIZE;
-       ReqHandlerInfo_t *pReqHandler;
+       struct req_handler_info *pReqHandler;
 
-       busNo = msg->cmd.createDevice.busNo;
-       devNo = msg->cmd.createDevice.devNo;
+       busNo = msg->cmd.create_device.bus_no;
+       devNo = msg->cmd.create_device.dev_no;
 
        POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, devNo, busNo,
                         POSTCODE_SEVERITY_INFO);
@@ -368,26 +368,26 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf)
                return CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
        }
 
-       dev->channel_uuid = msg->cmd.createDevice.dataTypeGuid;
-       dev->intr = msg->cmd.createDevice.intr;
-       dev->channel_addr = msg->cmd.createDevice.channelAddr;
+       dev->channel_uuid = msg->cmd.create_device.data_type_uuid;
+       dev->intr = msg->cmd.create_device.intr;
+       dev->channel_addr = msg->cmd.create_device.channel_addr;
        dev->bus_no = busNo;
        dev->dev_no = devNo;
        sema_init(&dev->interrupt_callback_lock, 1);    /* unlocked */
        sprintf(dev->devid, "vbus%u:dev%u", (unsigned) busNo, (unsigned) devNo);
        /* map the channel memory for the device. */
-       if (msg->hdr.Flags.testMessage)
+       if (msg->hdr.flags.test_message)
                dev->chanptr = (void __iomem *)__va(dev->channel_addr);
        else {
-               pReqHandler = ReqHandlerFind(dev->channel_uuid);
+               pReqHandler = req_handler_find(dev->channel_uuid);
                if (pReqHandler)
                        /* generic service handler registered for this
                         * channel
                         */
                        minSize = pReqHandler->min_channel_bytes;
-               if (minSize > msg->cmd.createDevice.channelBytes) {
+               if (minSize > msg->cmd.create_device.channel_bytes) {
                        LOGERR("CONTROLVM_DEVICE_CREATE Failed: channel size is too small, channel size:0x%lx, required size:0x%lx",
-                            (ulong) msg->cmd.createDevice.channelBytes,
+                            (ulong) msg->cmd.create_device.channel_bytes,
                             (ulong) minSize);
                        POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo,
                                         POSTCODE_SEVERITY_ERR);
@@ -396,27 +396,27 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf)
                }
                dev->chanptr =
                    uislib_ioremap_cache(dev->channel_addr,
-                                        msg->cmd.createDevice.channelBytes);
+                                        msg->cmd.create_device.channel_bytes);
                if (!dev->chanptr) {
                        LOGERR("CONTROLVM_DEVICE_CREATE Failed: ioremap_cache of channelAddr:%Lx for channelBytes:%llu failed",
                             dev->channel_addr,
-                            msg->cmd.createDevice.channelBytes);
+                            msg->cmd.create_device.channel_bytes);
                        result = CONTROLVM_RESP_ERROR_IOREMAP_FAILED;
                        POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo,
                                         POSTCODE_SEVERITY_ERR);
                        goto Away;
                }
        }
-       dev->instance_uuid = msg->cmd.createDevice.devInstGuid;
-       dev->channel_bytes = msg->cmd.createDevice.channelBytes;
+       dev->instance_uuid = msg->cmd.create_device.dev_inst_uuid;
+       dev->channel_bytes = msg->cmd.create_device.channel_bytes;
 
        read_lock(&BusListLock);
        for (bus = BusListHead; bus; bus = bus->next) {
-               if (bus->busNo == busNo) {
+               if (bus->bus_no == busNo) {
                        /* make sure the device number is valid */
-                       if (devNo >= bus->deviceCount) {
+                       if (devNo >= bus->device_count) {
                                LOGERR("CONTROLVM_DEVICE_CREATE Failed: device (%d) >= deviceCount (%d).",
-                                    devNo, bus->deviceCount);
+                                    devNo, bus->device_count);
                                result = CONTROLVM_RESP_ERROR_MAX_DEVICES;
                                POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC,
                                                 devNo, busNo,
@@ -439,17 +439,18 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf)
                        /* the msg is bound for virtpci; send
                         * guest_msgs struct to callback
                         */
-                       if (!msg->hdr.Flags.server) {
+                       if (!msg->hdr.flags.server) {
                                struct guest_msgs cmd;
 
                                if (!uuid_le_cmp(dev->channel_uuid,
-                                    UltraVhbaChannelProtocolGuid)) {
-                                       wait_for_valid_guid(&((CHANNEL_HEADER
-                                                             __iomem *) (dev->
+                                    spar_vhba_channel_protocol_uuid)) {
+                                       wait_for_valid_guid(&((
+                                               struct channel_header
+                                                       __iomem *) (dev->
                                                                  chanptr))->
-                                                           Type);
-                                       if (!ULTRA_VHBA_CHANNEL_OK_CLIENT
-                                           (dev->chanptr, NULL)) {
+                                                           chtype);
+                                       if (!SPAR_VHBA_CHANNEL_OK_CLIENT
+                                           (dev->chanptr)) {
                                                LOGERR("CONTROLVM_DEVICE_CREATE Failed:[CLIENT]VHBA dev %d chan invalid.",
                                                     devNo);
                                                POSTCODE_LINUX_4
@@ -468,13 +469,14 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf)
                                        cmd.add_vhba.intr = dev->intr;
                                } else
                                    if (!uuid_le_cmp(dev->channel_uuid,
-                                        UltraVnicChannelProtocolGuid)) {
-                                       wait_for_valid_guid(&((CHANNEL_HEADER
-                                                             __iomem *) (dev->
+                                        spar_vnic_channel_protocol_uuid)) {
+                                       wait_for_valid_guid(&((
+                                               struct channel_header
+                                                       __iomem *) (dev->
                                                                  chanptr))->
-                                                           Type);
-                                       if (!ULTRA_VNIC_CHANNEL_OK_CLIENT
-                                           (dev->chanptr, NULL)) {
+                                                           chtype);
+                                       if (!SPAR_VNIC_CHANNEL_OK_CLIENT
+                                           (dev->chanptr)) {
                                                LOGERR("CONTROLVM_DEVICE_CREATE Failed: VNIC[CLIENT] dev %d chan invalid.",
                                                     devNo);
                                                POSTCODE_LINUX_4
@@ -500,7 +502,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf)
                                        goto Away;
                                }
 
-                               if (!VirtControlChanFunc) {
+                               if (!virt_control_chan_func) {
                                        LOGERR("CONTROLVM_DEVICE_CREATE Failed: virtpci callback not registered.");
                                        POSTCODE_LINUX_4
                                            (DEVICE_CREATE_FAILURE_PC, devNo,
@@ -509,7 +511,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf)
                                        goto Away;
                                }
 
-                               if (!VirtControlChanFunc(&cmd)) {
+                               if (!virt_control_chan_func(&cmd)) {
                                        LOGERR("CONTROLVM_DEVICE_CREATE Failed: virtpci GUEST_ADD_[VHBA||VNIC] returned error.");
                                        POSTCODE_LINUX_4
                                            (DEVICE_CREATE_FAILURE_PC, devNo,
@@ -532,7 +534,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf)
        result = CONTROLVM_RESP_ERROR_BUS_INVALID;
 
 Away:
-       if (!msg->hdr.Flags.testMessage) {
+       if (!msg->hdr.flags.test_message) {
                uislib_iounmap(dev->chanptr);
                dev->chanptr = NULL;
        }
@@ -542,7 +544,7 @@ Away:
 }
 
 static int
-pause_device(CONTROLVM_MESSAGE *msg)
+pause_device(struct controlvm_message *msg)
 {
        u32 busNo, devNo;
        struct bus_info *bus;
@@ -550,16 +552,16 @@ pause_device(CONTROLVM_MESSAGE *msg)
        struct guest_msgs cmd;
        int retval = CONTROLVM_RESP_SUCCESS;
 
-       busNo = msg->cmd.deviceChangeState.busNo;
-       devNo = msg->cmd.deviceChangeState.devNo;
+       busNo = msg->cmd.device_change_state.bus_no;
+       devNo = msg->cmd.device_change_state.dev_no;
 
        read_lock(&BusListLock);
        for (bus = BusListHead; bus; bus = bus->next) {
-               if (bus->busNo == busNo) {
+               if (bus->bus_no == busNo) {
                        /* make sure the device number is valid */
-                       if (devNo >= bus->deviceCount) {
+                       if (devNo >= bus->device_count) {
                                LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: device(%d) >= deviceCount(%d).",
-                                    devNo, bus->deviceCount);
+                                    devNo, bus->device_count);
                                retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID;
                        } else {
                                /* make sure this device exists */
@@ -585,22 +587,22 @@ pause_device(CONTROLVM_MESSAGE *msg)
                 * guest_msgs struct to callback
                 */
                if (!uuid_le_cmp(dev->channel_uuid,
-                               UltraVhbaChannelProtocolGuid)) {
+                               spar_vhba_channel_protocol_uuid)) {
                        cmd.msgtype = GUEST_PAUSE_VHBA;
                        cmd.pause_vhba.chanptr = dev->chanptr;
                } else if (!uuid_le_cmp(dev->channel_uuid,
-                                       UltraVnicChannelProtocolGuid)) {
+                                       spar_vnic_channel_protocol_uuid)) {
                        cmd.msgtype = GUEST_PAUSE_VNIC;
                        cmd.pause_vnic.chanptr = dev->chanptr;
                } else {
                        LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: unknown channelTypeGuid.\n");
                        return CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN;
                }
-               if (!VirtControlChanFunc) {
+               if (!virt_control_chan_func) {
                        LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: virtpci callback not registered.");
                        return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
                }
-               if (!VirtControlChanFunc(&cmd)) {
+               if (!virt_control_chan_func(&cmd)) {
                        LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: virtpci GUEST_PAUSE_[VHBA||VNIC] returned error.");
                        return
                          CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
@@ -610,7 +612,7 @@ pause_device(CONTROLVM_MESSAGE *msg)
 }
 
 static int
-resume_device(CONTROLVM_MESSAGE *msg)
+resume_device(struct controlvm_message *msg)
 {
        u32 busNo, devNo;
        struct bus_info *bus;
@@ -618,16 +620,16 @@ resume_device(CONTROLVM_MESSAGE *msg)
        struct guest_msgs cmd;
        int retval = CONTROLVM_RESP_SUCCESS;
 
-       busNo = msg->cmd.deviceChangeState.busNo;
-       devNo = msg->cmd.deviceChangeState.devNo;
+       busNo = msg->cmd.device_change_state.bus_no;
+       devNo = msg->cmd.device_change_state.dev_no;
 
        read_lock(&BusListLock);
        for (bus = BusListHead; bus; bus = bus->next) {
-               if (bus->busNo == busNo) {
+               if (bus->bus_no == busNo) {
                        /* make sure the device number is valid */
-                       if (devNo >= bus->deviceCount) {
+                       if (devNo >= bus->device_count) {
                                LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: device(%d) >= deviceCount(%d).",
-                                    devNo, bus->deviceCount);
+                                    devNo, bus->device_count);
                                retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID;
                        } else {
                                /* make sure this device exists */
@@ -654,22 +656,22 @@ resume_device(CONTROLVM_MESSAGE *msg)
         */
        if (retval == CONTROLVM_RESP_SUCCESS) {
                if (!uuid_le_cmp(dev->channel_uuid,
-                                UltraVhbaChannelProtocolGuid)) {
+                                spar_vhba_channel_protocol_uuid)) {
                        cmd.msgtype = GUEST_RESUME_VHBA;
                        cmd.resume_vhba.chanptr = dev->chanptr;
                } else if (!uuid_le_cmp(dev->channel_uuid,
-                                       UltraVnicChannelProtocolGuid)) {
+                                       spar_vnic_channel_protocol_uuid)) {
                        cmd.msgtype = GUEST_RESUME_VNIC;
                        cmd.resume_vnic.chanptr = dev->chanptr;
                } else {
                        LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: unknown channelTypeGuid.\n");
                        return CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN;
                }
-               if (!VirtControlChanFunc) {
+               if (!virt_control_chan_func) {
                        LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: virtpci callback not registered.");
                        return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
                }
-               if (!VirtControlChanFunc(&cmd)) {
+               if (!virt_control_chan_func(&cmd)) {
                        LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: virtpci GUEST_RESUME_[VHBA||VNIC] returned error.");
                        return
                          CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
@@ -679,7 +681,7 @@ resume_device(CONTROLVM_MESSAGE *msg)
 }
 
 static int
-destroy_device(CONTROLVM_MESSAGE *msg, char *buf)
+destroy_device(struct controlvm_message *msg, char *buf)
 {
        u32 busNo, devNo;
        struct bus_info *bus;
@@ -687,17 +689,17 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf)
        struct guest_msgs cmd;
        int retval = CONTROLVM_RESP_SUCCESS;
 
-       busNo = msg->cmd.destroyDevice.busNo;
-       devNo = msg->cmd.destroyDevice.devNo;
+       busNo = msg->cmd.destroy_device.bus_no;
+       devNo = msg->cmd.destroy_device.bus_no;
 
        read_lock(&BusListLock);
        LOGINF("destroy_device called for busNo=%u, devNo=%u", busNo, devNo);
        for (bus = BusListHead; bus; bus = bus->next) {
-               if (bus->busNo == busNo) {
+               if (bus->bus_no == busNo) {
                        /* make sure the device number is valid */
-                       if (devNo >= bus->deviceCount) {
+                       if (devNo >= bus->device_count) {
                                LOGERR("CONTROLVM_DEVICE_DESTORY Failed: device(%d) >= deviceCount(%d).",
-                                      devNo, bus->deviceCount);
+                                      devNo, bus->device_count);
                                retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID;
                        } else {
                                /* make sure this device exists */
@@ -724,11 +726,11 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf)
                 * guest_msgs struct to callback
                 */
                if (!uuid_le_cmp(dev->channel_uuid,
-                                UltraVhbaChannelProtocolGuid)) {
+                                spar_vhba_channel_protocol_uuid)) {
                        cmd.msgtype = GUEST_DEL_VHBA;
                        cmd.del_vhba.chanptr = dev->chanptr;
                } else if (!uuid_le_cmp(dev->channel_uuid,
-                                       UltraVnicChannelProtocolGuid)) {
+                                       spar_vnic_channel_protocol_uuid)) {
                        cmd.msgtype = GUEST_DEL_VNIC;
                        cmd.del_vnic.chanptr = dev->chanptr;
                } else {
@@ -736,12 +738,12 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf)
                        return
                            CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN;
                }
-               if (!VirtControlChanFunc) {
+               if (!virt_control_chan_func) {
                        LOGERR("CONTROLVM_DEVICE_DESTORY Failed: virtpci callback not registered.");
                        return
                            CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
                }
-               if (!VirtControlChanFunc(&cmd)) {
+               if (!virt_control_chan_func(&cmd)) {
                        LOGERR("CONTROLVM_DEVICE_DESTROY Failed: virtpci GUEST_DEL_[VHBA||VNIC] returned error.");
                        return
                            CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
@@ -756,7 +758,7 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf)
                        uislib_disable_channel_interrupts(busNo, devNo);
                }
                /* unmap the channel memory for the device. */
-               if (!msg->hdr.Flags.testMessage) {
+               if (!msg->hdr.flags.test_message) {
                        LOGINF("destroy_device, doing iounmap");
                        uislib_iounmap(dev->chanptr);
                }
@@ -767,23 +769,23 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf)
 }
 
 static int
-init_chipset(CONTROLVM_MESSAGE *msg, char *buf)
+init_chipset(struct controlvm_message *msg, char *buf)
 {
        POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC, POSTCODE_SEVERITY_INFO);
 
-       MaxBusCount = msg->cmd.initChipset.busCount;
-       PlatformNumber = msg->cmd.initChipset.platformNumber;
+       MaxBusCount = msg->cmd.init_chipset.bus_count;
+       PlatformNumber = msg->cmd.init_chipset.platform_number;
        PhysicalDataChan = 0;
 
        /* We need to make sure we have our functions registered
        * before processing messages.  If we are a test vehicle the
-       * testMessage for init_chipset will be set.  We can ignore the
+       * test_message for init_chipset will be set.  We can ignore the
        * waits for the callbacks, since this will be manually entered
-       * from a user.  If no testMessage is set, we will wait for the
+       * from a user.  If no test_message is set, we will wait for the
        * functions.
        */
-       if (!msg->hdr.Flags.testMessage)
-               WAIT_ON_CALLBACK(VirtControlChanFunc);
+       if (!msg->hdr.flags.test_message)
+               WAIT_ON_CALLBACK(virt_control_chan_func);
 
        chipset_inited = 1;
        POSTCODE_LINUX_2(CHIPSET_INIT_EXIT_PC, POSTCODE_SEVERITY_INFO);
@@ -794,10 +796,10 @@ init_chipset(CONTROLVM_MESSAGE *msg, char *buf)
 static int
 delete_bus_glue(u32 busNo)
 {
-       CONTROLVM_MESSAGE msg;
+       struct controlvm_message msg;
 
        init_msg_header(&msg, CONTROLVM_BUS_DESTROY, 0, 0);
-       msg.cmd.destroyBus.busNo = busNo;
+       msg.cmd.destroy_bus.bus_no = busNo;
        if (destroy_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) {
                LOGERR("destroy_bus failed. busNo=0x%x\n", busNo);
                return 0;
@@ -808,11 +810,11 @@ delete_bus_glue(u32 busNo)
 static int
 delete_device_glue(u32 busNo, u32 devNo)
 {
-       CONTROLVM_MESSAGE msg;
+       struct controlvm_message msg;
 
        init_msg_header(&msg, CONTROLVM_DEVICE_DESTROY, 0, 0);
-       msg.cmd.destroyDevice.busNo = busNo;
-       msg.cmd.destroyDevice.devNo = devNo;
+       msg.cmd.destroy_device.bus_no = busNo;
+       msg.cmd.destroy_device.dev_no = devNo;
        if (destroy_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) {
                LOGERR("destroy_device failed. busNo=0x%x devNo=0x%x\n", busNo,
                       devNo);
@@ -822,14 +824,14 @@ delete_device_glue(u32 busNo, u32 devNo)
 }
 
 int
-uislib_client_inject_add_bus(u32 busNo, uuid_le instGuid,
-                            u64 channelAddr, ulong nChannelBytes)
+uislib_client_inject_add_bus(u32 bus_no, uuid_le inst_uuid,
+                            u64 channel_addr, ulong n_channel_bytes)
 {
-       CONTROLVM_MESSAGE msg;
+       struct controlvm_message msg;
 
-       LOGINF("enter busNo=0x%x\n", busNo);
+       LOGINF("enter busNo=0x%x\n", bus_no);
        /* step 0: init the chipset */
-       POSTCODE_LINUX_3(CHIPSET_INIT_ENTRY_PC, busNo, POSTCODE_SEVERITY_INFO);
+       POSTCODE_LINUX_3(CHIPSET_INIT_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO);
 
        if (!chipset_inited) {
                /* step: initialize the chipset */
@@ -841,31 +843,32 @@ uislib_client_inject_add_bus(u32 busNo, uuid_le instGuid,
                * after number 4, then the add_vnic will fail, and the
                * ultraboot will fail.
                */
-               msg.cmd.initChipset.busCount = 23;
-               msg.cmd.initChipset.switchCount = 0;
+               msg.cmd.init_chipset.bus_count = 23;
+               msg.cmd.init_chipset.switch_count = 0;
                if (init_chipset(&msg, NULL) != CONTROLVM_RESP_SUCCESS) {
                        LOGERR("init_chipset failed.\n");
                        return 0;
                }
                LOGINF("chipset initialized\n");
-               POSTCODE_LINUX_3(CHIPSET_INIT_EXIT_PC, busNo,
+               POSTCODE_LINUX_3(CHIPSET_INIT_EXIT_PC, bus_no,
                                 POSTCODE_SEVERITY_INFO);
        }
 
        /* step 1: create a bus */
-       POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, busNo, POSTCODE_SEVERITY_WARNING);
+       POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no,
+                        POSTCODE_SEVERITY_WARNING);
        init_msg_header(&msg, CONTROLVM_BUS_CREATE, 0, 0);
-       msg.cmd.createBus.busNo = busNo;
-       msg.cmd.createBus.deviceCount = 23;     /* devNo+1; */
-       msg.cmd.createBus.channelAddr = channelAddr;
-       msg.cmd.createBus.channelBytes = nChannelBytes;
+       msg.cmd.create_bus.bus_no = bus_no;
+       msg.cmd.create_bus.dev_count = 23;      /* devNo+1; */
+       msg.cmd.create_bus.channel_addr = channel_addr;
+       msg.cmd.create_bus.channel_bytes = n_channel_bytes;
        if (create_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) {
                LOGERR("create_bus failed.\n");
-               POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo,
+               POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
                                 POSTCODE_SEVERITY_ERR);
                return 0;
        }
-       POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, busNo, POSTCODE_SEVERITY_INFO);
+       POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO);
 
        return 1;
 }
@@ -873,26 +876,26 @@ EXPORT_SYMBOL_GPL(uislib_client_inject_add_bus);
 
 
 int
-uislib_client_inject_del_bus(u32 busNo)
+uislib_client_inject_del_bus(u32 bus_no)
 {
-       return delete_bus_glue(busNo);
+       return delete_bus_glue(bus_no);
 }
 EXPORT_SYMBOL_GPL(uislib_client_inject_del_bus);
 
 int
-uislib_client_inject_pause_vhba(u32 busNo, u32 devNo)
+uislib_client_inject_pause_vhba(u32 bus_no, u32 dev_no)
 {
-       CONTROLVM_MESSAGE msg;
+       struct controlvm_message msg;
        int rc;
 
        init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0);
-       msg.cmd.deviceChangeState.busNo = busNo;
-       msg.cmd.deviceChangeState.devNo = devNo;
-       msg.cmd.deviceChangeState.state = SegmentStateStandby;
+       msg.cmd.device_change_state.bus_no = bus_no;
+       msg.cmd.device_change_state.dev_no = dev_no;
+       msg.cmd.device_change_state.state = segment_state_standby;
        rc = pause_device(&msg);
        if (rc != CONTROLVM_RESP_SUCCESS) {
                LOGERR("VHBA pause_device failed. busNo=0x%x devNo=0x%x\n",
-                      busNo, devNo);
+                      bus_no, dev_no);
                return rc;
        }
        return 0;
@@ -900,19 +903,19 @@ uislib_client_inject_pause_vhba(u32 busNo, u32 devNo)
 EXPORT_SYMBOL_GPL(uislib_client_inject_pause_vhba);
 
 int
-uislib_client_inject_resume_vhba(u32 busNo, u32 devNo)
+uislib_client_inject_resume_vhba(u32 bus_no, u32 dev_no)
 {
-       CONTROLVM_MESSAGE msg;
+       struct controlvm_message msg;
        int rc;
 
        init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0);
-       msg.cmd.deviceChangeState.busNo = busNo;
-       msg.cmd.deviceChangeState.devNo = devNo;
-       msg.cmd.deviceChangeState.state = SegmentStateRunning;
+       msg.cmd.device_change_state.bus_no = bus_no;
+       msg.cmd.device_change_state.dev_no = dev_no;
+       msg.cmd.device_change_state.state = segment_state_running;
        rc = resume_device(&msg);
        if (rc != CONTROLVM_RESP_SUCCESS) {
                LOGERR("VHBA resume_device failed. busNo=0x%x devNo=0x%x\n",
-                      busNo, devNo);
+                      bus_no, dev_no);
                return rc;
        }
        return 0;
@@ -921,19 +924,19 @@ uislib_client_inject_resume_vhba(u32 busNo, u32 devNo)
 EXPORT_SYMBOL_GPL(uislib_client_inject_resume_vhba);
 
 int
-uislib_client_inject_add_vhba(u32 busNo, u32 devNo,
+uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no,
                              u64 phys_chan_addr, u32 chan_bytes,
-                             int is_test_addr, uuid_le instGuid,
-                             struct InterruptInfo *intr)
+                             int is_test_addr, uuid_le inst_uuid,
+                             struct irq_info *intr)
 {
-       CONTROLVM_MESSAGE msg;
+       struct controlvm_message msg;
 
-       LOGINF(" enter busNo=0x%x devNo=0x%x\n", busNo, devNo);
+       LOGINF(" enter busNo=0x%x devNo=0x%x\n", bus_no, dev_no);
        /* chipset init'ed with bus bus has been previously created -
        * Verify it still exists step 2: create the VHBA device on the
        * bus
        */
-       POSTCODE_LINUX_4(VHBA_CREATE_ENTRY_PC, devNo, busNo,
+       POSTCODE_LINUX_4(VHBA_CREATE_ENTRY_PC, dev_no, bus_no,
                         POSTCODE_SEVERITY_INFO);
 
        init_msg_header(&msg, CONTROLVM_DEVICE_CREATE, 0, 0);
@@ -941,16 +944,16 @@ uislib_client_inject_add_vhba(u32 busNo, u32 devNo,
                /* signify that the physical channel address does NOT
                 * need to be ioremap()ed
                 */
-               msg.hdr.Flags.testMessage = 1;
-       msg.cmd.createDevice.busNo = busNo;
-       msg.cmd.createDevice.devNo = devNo;
-       msg.cmd.createDevice.devInstGuid = instGuid;
+               msg.hdr.flags.test_message = 1;
+       msg.cmd.create_device.bus_no = bus_no;
+       msg.cmd.create_device.dev_no = dev_no;
+       msg.cmd.create_device.dev_inst_uuid = inst_uuid;
        if (intr)
-               msg.cmd.createDevice.intr = *intr;
+               msg.cmd.create_device.intr = *intr;
        else
-               memset(&msg.cmd.createDevice.intr, 0,
-                      sizeof(struct InterruptInfo));
-       msg.cmd.createDevice.channelAddr = phys_chan_addr;
+               memset(&msg.cmd.create_device.intr, 0,
+                      sizeof(struct irq_info));
+       msg.cmd.create_device.channel_addr = phys_chan_addr;
        if (chan_bytes < MIN_IO_CHANNEL_SIZE) {
                LOGERR("wrong channel size.chan_bytes = 0x%x IO_CHANNEL_SIZE= 0x%x\n",
                     chan_bytes, (unsigned int) MIN_IO_CHANNEL_SIZE);
@@ -958,41 +961,41 @@ uislib_client_inject_add_vhba(u32 busNo, u32 devNo,
                                 MIN_IO_CHANNEL_SIZE, POSTCODE_SEVERITY_ERR);
                return 0;
        }
-       msg.cmd.createDevice.channelBytes = chan_bytes;
-       msg.cmd.createDevice.dataTypeGuid = UltraVhbaChannelProtocolGuid;
+       msg.cmd.create_device.channel_bytes = chan_bytes;
+       msg.cmd.create_device.data_type_uuid = spar_vhba_channel_protocol_uuid;
        if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) {
                LOGERR("VHBA create_device failed.\n");
-               POSTCODE_LINUX_4(VHBA_CREATE_FAILURE_PC, devNo, busNo,
+               POSTCODE_LINUX_4(VHBA_CREATE_FAILURE_PC, dev_no, bus_no,
                                 POSTCODE_SEVERITY_ERR);
                return 0;
        }
-       POSTCODE_LINUX_4(VHBA_CREATE_SUCCESS_PC, devNo, busNo,
+       POSTCODE_LINUX_4(VHBA_CREATE_SUCCESS_PC, dev_no, bus_no,
                         POSTCODE_SEVERITY_INFO);
        return 1;
 }
 EXPORT_SYMBOL_GPL(uislib_client_inject_add_vhba);
 
 int
-uislib_client_inject_del_vhba(u32 busNo, u32 devNo)
+uislib_client_inject_del_vhba(u32 bus_no, u32 dev_no)
 {
-       return delete_device_glue(busNo, devNo);
+       return delete_device_glue(bus_no, dev_no);
 }
 EXPORT_SYMBOL_GPL(uislib_client_inject_del_vhba);
 
 int
-uislib_client_inject_add_vnic(u32 busNo, u32 devNo,
+uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no,
                              u64 phys_chan_addr, u32 chan_bytes,
-                             int is_test_addr, uuid_le instGuid,
-                             struct InterruptInfo *intr)
+                             int is_test_addr, uuid_le inst_uuid,
+                             struct irq_info *intr)
 {
-       CONTROLVM_MESSAGE msg;
+       struct controlvm_message msg;
 
-       LOGINF(" enter busNo=0x%x devNo=0x%x\n", busNo, devNo);
+       LOGINF(" enter busNo=0x%x devNo=0x%x\n", bus_no, dev_no);
        /* chipset init'ed with bus bus has been previously created -
        * Verify it still exists step 2: create the VNIC device on the
        * bus
        */
-       POSTCODE_LINUX_4(VNIC_CREATE_ENTRY_PC, devNo, busNo,
+       POSTCODE_LINUX_4(VNIC_CREATE_ENTRY_PC, dev_no, bus_no,
                         POSTCODE_SEVERITY_INFO);
 
        init_msg_header(&msg, CONTROLVM_DEVICE_CREATE, 0, 0);
@@ -1000,16 +1003,16 @@ uislib_client_inject_add_vnic(u32 busNo, u32 devNo,
                /* signify that the physical channel address does NOT
                 * need to be ioremap()ed
                 */
-               msg.hdr.Flags.testMessage = 1;
-       msg.cmd.createDevice.busNo = busNo;
-       msg.cmd.createDevice.devNo = devNo;
-       msg.cmd.createDevice.devInstGuid = instGuid;
+               msg.hdr.flags.test_message = 1;
+       msg.cmd.create_device.bus_no = bus_no;
+       msg.cmd.create_device.dev_no = dev_no;
+       msg.cmd.create_device.dev_inst_uuid = inst_uuid;
        if (intr)
-               msg.cmd.createDevice.intr = *intr;
+               msg.cmd.create_device.intr = *intr;
        else
-               memset(&msg.cmd.createDevice.intr, 0,
-                      sizeof(struct InterruptInfo));
-       msg.cmd.createDevice.channelAddr = phys_chan_addr;
+               memset(&msg.cmd.create_device.intr, 0,
+                      sizeof(struct irq_info));
+       msg.cmd.create_device.channel_addr = phys_chan_addr;
        if (chan_bytes < MIN_IO_CHANNEL_SIZE) {
                LOGERR("wrong channel size.chan_bytes = 0x%x IO_CHANNEL_SIZE= 0x%x\n",
                     chan_bytes, (unsigned int) MIN_IO_CHANNEL_SIZE);
@@ -1017,35 +1020,35 @@ uislib_client_inject_add_vnic(u32 busNo, u32 devNo,
                                 MIN_IO_CHANNEL_SIZE, POSTCODE_SEVERITY_ERR);
                return 0;
        }
-       msg.cmd.createDevice.channelBytes = chan_bytes;
-       msg.cmd.createDevice.dataTypeGuid = UltraVnicChannelProtocolGuid;
+       msg.cmd.create_device.channel_bytes = chan_bytes;
+       msg.cmd.create_device.data_type_uuid = spar_vnic_channel_protocol_uuid;
        if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) {
                LOGERR("VNIC create_device failed.\n");
-               POSTCODE_LINUX_4(VNIC_CREATE_FAILURE_PC, devNo, busNo,
+               POSTCODE_LINUX_4(VNIC_CREATE_FAILURE_PC, dev_no, bus_no,
                                 POSTCODE_SEVERITY_ERR);
                return 0;
        }
 
-       POSTCODE_LINUX_4(VNIC_CREATE_SUCCESS_PC, devNo, busNo,
+       POSTCODE_LINUX_4(VNIC_CREATE_SUCCESS_PC, dev_no, bus_no,
                         POSTCODE_SEVERITY_INFO);
        return 1;
 }
 EXPORT_SYMBOL_GPL(uislib_client_inject_add_vnic);
 
 int
-uislib_client_inject_pause_vnic(u32 busNo, u32 devNo)
+uislib_client_inject_pause_vnic(u32 bus_no, u32 dev_no)
 {
-       CONTROLVM_MESSAGE msg;
+       struct controlvm_message msg;
        int rc;
 
        init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0);
-       msg.cmd.deviceChangeState.busNo = busNo;
-       msg.cmd.deviceChangeState.devNo = devNo;
-       msg.cmd.deviceChangeState.state = SegmentStateStandby;
+       msg.cmd.device_change_state.bus_no = bus_no;
+       msg.cmd.device_change_state.dev_no = dev_no;
+       msg.cmd.device_change_state.state = segment_state_standby;
        rc = pause_device(&msg);
        if (rc != CONTROLVM_RESP_SUCCESS) {
                LOGERR("VNIC pause_device failed. busNo=0x%x devNo=0x%x\n",
-                      busNo, devNo);
+                      bus_no, dev_no);
                return -1;
        }
        return 0;
@@ -1053,19 +1056,19 @@ uislib_client_inject_pause_vnic(u32 busNo, u32 devNo)
 EXPORT_SYMBOL_GPL(uislib_client_inject_pause_vnic);
 
 int
-uislib_client_inject_resume_vnic(u32 busNo, u32 devNo)
+uislib_client_inject_resume_vnic(u32 bus_no, u32 dev_no)
 {
-       CONTROLVM_MESSAGE msg;
+       struct controlvm_message msg;
        int rc;
 
        init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0);
-       msg.cmd.deviceChangeState.busNo = busNo;
-       msg.cmd.deviceChangeState.devNo = devNo;
-       msg.cmd.deviceChangeState.state = SegmentStateRunning;
+       msg.cmd.device_change_state.bus_no = bus_no;
+       msg.cmd.device_change_state.dev_no = dev_no;
+       msg.cmd.device_change_state.state = segment_state_running;
        rc = resume_device(&msg);
        if (rc != CONTROLVM_RESP_SUCCESS) {
                LOGERR("VNIC resume_device failed. busNo=0x%x devNo=0x%x\n",
-                      busNo, devNo);
+                      bus_no, dev_no);
                return -1;
        }
        return 0;
@@ -1074,9 +1077,9 @@ uislib_client_inject_resume_vnic(u32 busNo, u32 devNo)
 EXPORT_SYMBOL_GPL(uislib_client_inject_resume_vnic);
 
 int
-uislib_client_inject_del_vnic(u32 busNo, u32 devNo)
+uislib_client_inject_del_vnic(u32 bus_no, u32 dev_no)
 {
-       return delete_device_glue(busNo, devNo);
+       return delete_device_glue(bus_no, dev_no);
 }
 EXPORT_SYMBOL_GPL(uislib_client_inject_del_vnic);
 
@@ -1086,14 +1089,14 @@ uislib_client_add_vnic(u32 busNo)
        BOOL busCreated = FALSE;
        int devNo = 0;          /* Default to 0, since only one device
                                 * will be created for this bus... */
-       CONTROLVM_MESSAGE msg;
+       struct controlvm_message msg;
 
        init_msg_header(&msg, CONTROLVM_BUS_CREATE, 0, 0);
-       msg.hdr.Flags.testMessage = 1;
-       msg.cmd.createBus.busNo = busNo;
-       msg.cmd.createBus.deviceCount = 4;
-       msg.cmd.createBus.channelAddr = 0;
-       msg.cmd.createBus.channelBytes = 0;
+       msg.hdr.flags.test_message = 1;
+       msg.cmd.create_bus.bus_no = busNo;
+       msg.cmd.create_bus.dev_count = 4;
+       msg.cmd.create_bus.channel_addr = 0;
+       msg.cmd.create_bus.channel_bytes = 0;
        if (create_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) {
                LOGERR("client create_bus failed");
                return 0;
@@ -1101,14 +1104,14 @@ uislib_client_add_vnic(u32 busNo)
        busCreated = TRUE;
 
        init_msg_header(&msg, CONTROLVM_DEVICE_CREATE, 0, 0);
-       msg.hdr.Flags.testMessage = 1;
-       msg.cmd.createDevice.busNo = busNo;
-       msg.cmd.createDevice.devNo = devNo;
-       msg.cmd.createDevice.devInstGuid = NULL_UUID_LE;
-       memset(&msg.cmd.createDevice.intr, 0, sizeof(struct InterruptInfo));
-       msg.cmd.createDevice.channelAddr = PhysicalDataChan;
-       msg.cmd.createDevice.channelBytes = MIN_IO_CHANNEL_SIZE;
-       msg.cmd.createDevice.dataTypeGuid = UltraVnicChannelProtocolGuid;
+       msg.hdr.flags.test_message = 1;
+       msg.cmd.create_device.bus_no = busNo;
+       msg.cmd.create_device.dev_no = devNo;
+       msg.cmd.create_device.dev_inst_uuid = NULL_UUID_LE;
+       memset(&msg.cmd.create_device.intr, 0, sizeof(struct irq_info));
+       msg.cmd.create_device.channel_addr = PhysicalDataChan;
+       msg.cmd.create_device.channel_bytes = MIN_IO_CHANNEL_SIZE;
+       msg.cmd.create_device.data_type_uuid = spar_vnic_channel_protocol_uuid;
        if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) {
                LOGERR("client create_device failed");
                goto AwayCleanup;
@@ -1119,8 +1122,8 @@ uislib_client_add_vnic(u32 busNo)
 AwayCleanup:
        if (busCreated) {
                init_msg_header(&msg, CONTROLVM_BUS_DESTROY, 0, 0);
-               msg.hdr.Flags.testMessage = 1;
-               msg.cmd.destroyBus.busNo = busNo;
+               msg.hdr.flags.test_message = 1;
+               msg.cmd.destroy_bus.bus_no = busNo;
                if (destroy_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS)
                        LOGERR("client destroy_bus failed.\n");
        }
@@ -1134,20 +1137,20 @@ uislib_client_delete_vnic(u32 busNo)
 {
        int devNo = 0;          /* Default to 0, since only one device
                                 * will be created for this bus... */
-       CONTROLVM_MESSAGE msg;
+       struct controlvm_message msg;
 
        init_msg_header(&msg, CONTROLVM_DEVICE_DESTROY, 0, 0);
-       msg.hdr.Flags.testMessage = 1;
-       msg.cmd.destroyDevice.busNo = busNo;
-       msg.cmd.destroyDevice.devNo = devNo;
+       msg.hdr.flags.test_message = 1;
+       msg.cmd.destroy_device.bus_no = busNo;
+       msg.cmd.destroy_device.dev_no = devNo;
        if (destroy_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) {
                /* Don't error exit - try to see if bus can be destroyed... */
                LOGERR("client destroy_device failed.\n");
        }
 
        init_msg_header(&msg, CONTROLVM_BUS_DESTROY, 0, 0);
-       msg.hdr.Flags.testMessage = 1;
-       msg.cmd.destroyBus.busNo = busNo;
+       msg.hdr.flags.test_message = 1;
+       msg.cmd.destroy_bus.bus_no = busNo;
        if (destroy_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS)
                LOGERR("client destroy_bus failed.\n");
 
@@ -1206,17 +1209,17 @@ info_debugfs_read_helper(char **buff, int *buff_len)
        for (bus = BusListHead; bus; bus = bus->next) {
 
                if (PLINE("    bus=0x%p, busNo=%d, deviceCount=%d\n",
-                         bus, bus->busNo, bus->deviceCount) < 0)
+                         bus, bus->bus_no, bus->device_count) < 0)
                        goto err_done_unlock;
 
 
                if (PLINE("        Devices:\n") < 0)
                        goto err_done_unlock;
 
-               for (i = 0; i < bus->deviceCount; i++) {
+               for (i = 0; i < bus->device_count; i++) {
                        if (bus->device[i]) {
                                if (PLINE("            busNo %d, device[%i]: 0x%p, chanptr=0x%p, swtch=0x%p\n",
-                                         bus->busNo, i, bus->device[i],
+                                         bus->bus_no, i, bus->device[i],
                                          bus->device[i]->chanptr,
                                          bus->device[i]->swtch) < 0)
                                        goto err_done_unlock;
@@ -1232,7 +1235,7 @@ info_debugfs_read_helper(char **buff, int *buff_len)
        read_unlock(&BusListLock);
 
        if (PLINE("UisUtils_Registered_Services: %d\n",
-                 atomic_read(&UisUtils_Registered_Services)) < 0)
+                 atomic_read(&uisutils_registered_services)) < 0)
                goto err_done;
        if (PLINE("cycles_before_wait %llu wait_cycles:%llu\n",
                  cycles_before_wait, wait_cycles) < 0)
@@ -1294,9 +1297,9 @@ find_dev(u32 busNo, u32 devNo)
 
        read_lock(&BusListLock);
        for (bus = BusListHead; bus; bus = bus->next) {
-               if (bus->busNo == busNo) {
+               if (bus->bus_no == busNo) {
                        /* make sure the device number is valid */
-                       if (devNo >= bus->deviceCount) {
+                       if (devNo >= bus->device_count) {
                                LOGERR("%s bad busNo, devNo=%d,%d",
                                       __func__,
                                       (int) (busNo), (int) (devNo));
@@ -1560,13 +1563,13 @@ uislib_mod_init(void)
        LOGINF("sizeof(uiscmdrsp_net):%lu\n",
               (ulong) sizeof(struct uiscmdrsp_net));
        LOGINF("sizeof(CONTROLVM_MESSAGE):%lu bytes\n",
-              (ulong) sizeof(CONTROLVM_MESSAGE));
-       LOGINF("sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL):%lu bytes\n",
-              (ulong) sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL));
+              (ulong) sizeof(struct controlvm_message));
+       LOGINF("sizeof(struct spar_controlvm_channel_protocol):%lu bytes\n",
+              (ulong) sizeof(struct spar_controlvm_channel_protocol));
        LOGINF("sizeof(CHANNEL_HEADER):%lu bytes\n",
-              (ulong) sizeof(CHANNEL_HEADER));
-       LOGINF("sizeof(ULTRA_IO_CHANNEL_PROTOCOL):%lu bytes\n",
-              (ulong) sizeof(ULTRA_IO_CHANNEL_PROTOCOL));
+              (ulong) sizeof(struct channel_header));
+       LOGINF("sizeof(struct spar_io_channel_protocol):%lu bytes\n",
+              (ulong) sizeof(struct spar_io_channel_protocol));
        LOGINF("SIZEOF_CMDRSP:%lu bytes\n", SIZEOF_CMDRSP);
        LOGINF("SIZEOF_PROTOCOL:%lu bytes\n", SIZEOF_PROTOCOL);
 
@@ -1574,7 +1577,7 @@ uislib_mod_init(void)
        BusListHead = NULL;
        BusListCount = MaxBusCount = 0;
        rwlock_init(&BusListLock);
-       VirtControlChanFunc = NULL;
+       virt_control_chan_func = NULL;
 
        /* Issue VMCALL_GET_CONTROLVM_ADDR to get CtrlChanPhysAddr and
         * then map this physical address to a virtual address. */
index 4420884..f9f8442 100644 (file)
@@ -81,13 +81,13 @@ do_locked_client_insert(struct uisqueue_info *queueinfo,
        u8 rc = 0;
 
        spin_lock_irqsave(lock, flags);
-       if (!ULTRA_CHANNEL_CLIENT_ACQUIRE_OS(queueinfo->chan, channelId, NULL))
+       if (!spar_channel_client_acquire_os(queueinfo->chan, channelId))
                goto unlock;
-       if (visor_signal_insert(queueinfo->chan, whichqueue, pSignal)) {
+       if (spar_signal_insert(queueinfo->chan, whichqueue, pSignal)) {
                queueinfo->packets_sent++;
                rc = 1;
        }
-       ULTRA_CHANNEL_CLIENT_RELEASE_OS(queueinfo->chan, channelId, NULL);
+       spar_channel_client_release_os(queueinfo->chan, channelId);
 unlock:
        spin_unlock_irqrestore((spinlock_t *)lock, flags);
        return rc;
@@ -125,7 +125,7 @@ int
 uisqueue_get_cmdrsp(struct uisqueue_info *queueinfo,
                    void *cmdrsp, unsigned int whichqueue)
 {
-       if (!visor_signal_remove(queueinfo->chan, whichqueue, cmdrsp))
+       if (!spar_signal_remove(queueinfo->chan, whichqueue, cmdrsp))
                return 0;
 
        queueinfo->packets_received++;
index 8ff6d26..a8466e3 100644 (file)
@@ -39,7 +39,7 @@
 #define __MYFILE__ "uisutils.c"
 
 /* exports */
-atomic_t UisUtils_Registered_Services = ATOMIC_INIT(0);
+atomic_t uisutils_registered_services = ATOMIC_INIT(0);
                                        /* num registrations via
                                         * uisctrl_register_req_handler() or
                                         * uisctrl_register_req_handler_ex() */
@@ -75,20 +75,20 @@ EXPORT_SYMBOL_GPL(uisutil_add_proc_line_ex);
 
 int
 uisctrl_register_req_handler(int type, void *fptr,
-                            ULTRA_VBUS_DEVICEINFO *chipset_driver_info)
+                            struct ultra_vbus_deviceinfo *chipset_driver_info)
 {
        LOGINF("type = %d, fptr = 0x%p.\n", type, fptr);
 
        switch (type) {
        case 2:
                if (fptr) {
-                       if (!VirtControlChanFunc)
-                               atomic_inc(&UisUtils_Registered_Services);
-                       VirtControlChanFunc = fptr;
+                       if (!virt_control_chan_func)
+                               atomic_inc(&uisutils_registered_services);
+                       virt_control_chan_func = fptr;
                } else {
-                       if (VirtControlChanFunc)
-                               atomic_dec(&UisUtils_Registered_Services);
-                       VirtControlChanFunc = NULL;
+                       if (virt_control_chan_func)
+                               atomic_dec(&uisutils_registered_services);
+                       virt_control_chan_func = NULL;
                }
                break;
 
@@ -105,76 +105,75 @@ uisctrl_register_req_handler(int type, void *fptr,
 EXPORT_SYMBOL_GPL(uisctrl_register_req_handler);
 
 int
-uisctrl_register_req_handler_ex(uuid_le switchTypeGuid,
-                               const char *switch_type_name,
-                               int (*controlfunc)(struct io_msgs *),
-                               unsigned long min_channel_bytes,
-                               int (*Server_Channel_Ok)(unsigned long
-                                                         channelBytes),
-                               int (*Server_Channel_Init)
-                                (void *x, unsigned char *clientStr,
-                                 u32 clientStrLen, u64 bytes),
-                               ULTRA_VBUS_DEVICEINFO *chipset_DriverInfo)
+uisctrl_register_req_handler_ex(uuid_le switch_uuid,
+                       const char *switch_type_name,
+                       int (*controlfunc)(struct io_msgs *),
+                       unsigned long min_channel_bytes,
+                       int (*server_channel_ok)(unsigned long channel_bytes),
+                       int (*server_channel_init)(void *x,
+                                               unsigned char *client_str,
+                                               u32 client_str_len, u64 bytes),
+                       struct ultra_vbus_deviceinfo *chipset_driver_info)
 {
-       ReqHandlerInfo_t *pReqHandlerInfo;
+       struct req_handler_info *pReqHandlerInfo;
        int rc = 0;             /* assume failure */
 
        LOGINF("type=%pUL, controlfunc=0x%p.\n",
-              &switchTypeGuid, controlfunc);
+              &switch_uuid, controlfunc);
        if (!controlfunc) {
-               LOGERR("%pUL: controlfunc must be supplied\n", &switchTypeGuid);
+               LOGERR("%pUL: controlfunc must be supplied\n", &switch_uuid);
                goto Away;
        }
-       if (!Server_Channel_Ok) {
+       if (!server_channel_ok) {
                LOGERR("%pUL: Server_Channel_Ok must be supplied\n",
-                               &switchTypeGuid);
+                               &switch_uuid);
                goto Away;
        }
-       if (!Server_Channel_Init) {
+       if (!server_channel_init) {
                LOGERR("%pUL: Server_Channel_Init must be supplied\n",
-                               &switchTypeGuid);
+                               &switch_uuid);
                goto Away;
        }
-       pReqHandlerInfo = ReqHandlerAdd(switchTypeGuid,
+       pReqHandlerInfo = req_handler_add(switch_uuid,
                                        switch_type_name,
                                        controlfunc,
                                        min_channel_bytes,
-                                       Server_Channel_Ok, Server_Channel_Init);
+                                       server_channel_ok, server_channel_init);
        if (!pReqHandlerInfo) {
-               LOGERR("failed to add %pUL to server list\n", &switchTypeGuid);
+               LOGERR("failed to add %pUL to server list\n", &switch_uuid);
                goto Away;
        }
 
-       atomic_inc(&UisUtils_Registered_Services);
+       atomic_inc(&uisutils_registered_services);
        rc = 1;                 /* success */
 Away:
        if (rc) {
-               if (chipset_DriverInfo)
-                       bus_device_info_init(chipset_DriverInfo, "chipset",
+               if (chipset_driver_info)
+                       bus_device_info_init(chipset_driver_info, "chipset",
                                           "uislib", VERSION, NULL);
        } else
-               LOGERR("failed to register type %pUL.\n", &switchTypeGuid);
+               LOGERR("failed to register type %pUL.\n", &switch_uuid);
 
        return rc;
 }
 EXPORT_SYMBOL_GPL(uisctrl_register_req_handler_ex);
 
 int
-uisctrl_unregister_req_handler_ex(uuid_le switchTypeGuid)
+uisctrl_unregister_req_handler_ex(uuid_le switch_uuid)
 {
        int rc = 0;             /* assume failure */
 
-       LOGINF("type=%pUL.\n", &switchTypeGuid);
-       if (ReqHandlerDel(switchTypeGuid) < 0) {
+       LOGINF("type=%pUL.\n", &switch_uuid);
+       if (req_handler_del(switch_uuid) < 0) {
                LOGERR("failed to remove %pUL from server list\n",
-                               &switchTypeGuid);
+                               &switch_uuid);
                goto Away;
        }
-       atomic_dec(&UisUtils_Registered_Services);
+       atomic_dec(&uisutils_registered_services);
        rc = 1;                 /* success */
 Away:
        if (!rc)
-               LOGERR("failed to unregister type %pUL.\n", &switchTypeGuid);
+               LOGERR("failed to unregister type %pUL.\n", &switch_uuid);
        return rc;
 }
 EXPORT_SYMBOL_GPL(uisctrl_unregister_req_handler_ex);
@@ -275,11 +274,11 @@ dolist: if (skb_shinfo(skb)->frag_list) {
 }
 EXPORT_SYMBOL_GPL(uisutil_copy_fragsinfo_from_skb);
 
-static LIST_HEAD(ReqHandlerInfo_list); /* list of ReqHandlerInfo_t */
+static LIST_HEAD(ReqHandlerInfo_list); /* list of struct req_handler_info */
 static DEFINE_SPINLOCK(ReqHandlerInfo_list_lock);
 
-ReqHandlerInfo_t *
-ReqHandlerAdd(uuid_le switchTypeGuid,
+struct req_handler_info *
+req_handler_add(uuid_le switch_uuid,
              const char *switch_type_name,
              int (*controlfunc)(struct io_msgs *),
              unsigned long min_channel_bytes,
@@ -287,16 +286,16 @@ ReqHandlerAdd(uuid_le switchTypeGuid,
              int (*Server_Channel_Init)
               (void *x, unsigned char *clientStr, u32 clientStrLen, u64 bytes))
 {
-       ReqHandlerInfo_t *rc = NULL;
+       struct req_handler_info *rc = NULL;
 
        rc = kzalloc(sizeof(*rc), GFP_ATOMIC);
        if (!rc)
                return NULL;
-       rc->switchTypeGuid = switchTypeGuid;
+       rc->switch_uuid = switch_uuid;
        rc->controlfunc = controlfunc;
        rc->min_channel_bytes = min_channel_bytes;
-       rc->Server_Channel_Ok = Server_Channel_Ok;
-       rc->Server_Channel_Init = Server_Channel_Init;
+       rc->server_channel_ok = Server_Channel_Ok;
+       rc->server_channel_init = Server_Channel_Init;
        if (switch_type_name)
                strncpy(rc->switch_type_name, switch_type_name,
                        sizeof(rc->switch_type_name) - 1);
@@ -307,16 +306,16 @@ ReqHandlerAdd(uuid_le switchTypeGuid,
        return rc;
 }
 
-ReqHandlerInfo_t *
-ReqHandlerFind(uuid_le switchTypeGuid)
+struct req_handler_info *
+req_handler_find(uuid_le switch_uuid)
 {
        struct list_head *lelt, *tmp;
-       ReqHandlerInfo_t *entry = NULL;
+       struct req_handler_info *entry = NULL;
 
        spin_lock(&ReqHandlerInfo_list_lock);
        list_for_each_safe(lelt, tmp, &ReqHandlerInfo_list) {
-               entry = list_entry(lelt, ReqHandlerInfo_t, list_link);
-               if (uuid_le_cmp(entry->switchTypeGuid, switchTypeGuid) == 0) {
+               entry = list_entry(lelt, struct req_handler_info, list_link);
+               if (uuid_le_cmp(entry->switch_uuid, switch_uuid) == 0) {
                        spin_unlock(&ReqHandlerInfo_list_lock);
                        return entry;
                }
@@ -326,16 +325,16 @@ ReqHandlerFind(uuid_le switchTypeGuid)
 }
 
 int
-ReqHandlerDel(uuid_le switchTypeGuid)
+req_handler_del(uuid_le switch_uuid)
 {
        struct list_head *lelt, *tmp;
-       ReqHandlerInfo_t *entry = NULL;
+       struct req_handler_info *entry = NULL;
        int rc = -1;
 
        spin_lock(&ReqHandlerInfo_list_lock);
        list_for_each_safe(lelt, tmp, &ReqHandlerInfo_list) {
-               entry = list_entry(lelt, ReqHandlerInfo_t, list_link);
-               if (uuid_le_cmp(entry->switchTypeGuid, switchTypeGuid) == 0) {
+               entry = list_entry(lelt, struct req_handler_info, list_link);
+               if (uuid_le_cmp(entry->switch_uuid, switch_uuid) == 0) {
                        list_del(lelt);
                        kfree(entry);
                        rc++;
index 938e2c8..04d3c21 100644 (file)
@@ -172,7 +172,7 @@ struct virthba_info {
        struct virtpci_dev *virtpcidev;
        struct list_head dev_info_list;
        struct chaninfo chinfo;
-       struct InterruptInfo intr;      /* use recvInterrupt info to receive
+       struct irq_info intr;           /* use recvInterrupt info to receive
                                           interrupts when IOs complete */
        int interrupt_vector;
        struct scsipending pending[MAX_PENDING_REQUESTS]; /* Tracks the requests
@@ -420,8 +420,8 @@ static irqreturn_t
 virthba_ISR(int irq, void *dev_id)
 {
        struct virthba_info *virthbainfo = (struct virthba_info *) dev_id;
-       CHANNEL_HEADER __iomem *pChannelHeader;
-       SIGNAL_QUEUE_HEADER __iomem *pqhdr;
+       struct channel_header __iomem *pChannelHeader;
+       struct signal_queue_header __iomem *pqhdr;
        u64 mask;
        unsigned long long rc1;
 
@@ -429,24 +429,24 @@ virthba_ISR(int irq, void *dev_id)
                return IRQ_NONE;
        virthbainfo->interrupts_rcvd++;
        pChannelHeader = virthbainfo->chinfo.queueinfo->chan;
-       if (((readq(&pChannelHeader->Features)
+       if (((readq(&pChannelHeader->features)
              & ULTRA_IO_IOVM_IS_OK_WITH_DRIVER_DISABLING_INTS) != 0)
-           && ((readq(&pChannelHeader->Features) &
+           && ((readq(&pChannelHeader->features) &
                 ULTRA_IO_DRIVER_DISABLES_INTS) !=
                0)) {
                virthbainfo->interrupts_disabled++;
                mask = ~ULTRA_CHANNEL_ENABLE_INTS;
                rc1 = uisqueue_interlocked_and(virthbainfo->flags_addr, mask);
        }
-       if (visor_signalqueue_empty(pChannelHeader, IOCHAN_FROM_IOPART)) {
+       if (spar_signalqueue_empty(pChannelHeader, IOCHAN_FROM_IOPART)) {
                virthbainfo->interrupts_notme++;
                return IRQ_NONE;
        }
-       pqhdr = (SIGNAL_QUEUE_HEADER __iomem *)
+       pqhdr = (struct signal_queue_header __iomem *)
                ((char __iomem *) pChannelHeader +
-                readq(&pChannelHeader->oChannelSpace)) + IOCHAN_FROM_IOPART;
-       writeq(readq(&pqhdr->NumInterruptsReceived) + 1,
-              &pqhdr->NumInterruptsReceived);
+                readq(&pChannelHeader->ch_space_offset)) + IOCHAN_FROM_IOPART;
+       writeq(readq(&pqhdr->num_irq_received) + 1,
+              &pqhdr->num_irq_received);
        atomic_set(&virthbainfo->interrupt_rcvd, 1);
        wake_up_interruptible(&virthbainfo->rsp_queue);
        return IRQ_HANDLED;
@@ -461,17 +461,17 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id)
        int rsp;
        int i;
        irq_handler_t handler = virthba_ISR;
-       CHANNEL_HEADER __iomem *pChannelHeader;
-       SIGNAL_QUEUE_HEADER __iomem *pqhdr;
+       struct channel_header __iomem *pChannelHeader;
+       struct signal_queue_header __iomem *pqhdr;
        u64 mask;
 
        LOGVER("entering virthba_probe...\n");
-       LOGVER("virtpcidev busNo<<%d>>devNo<<%d>>", virtpcidev->busNo,
-              virtpcidev->deviceNo);
+       LOGVER("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no,
+              virtpcidev->device_no);
 
        LOGINF("entering virthba_probe...\n");
-       LOGINF("virtpcidev busNo<<%d>>devNo<<%d>>", virtpcidev->busNo,
-              virtpcidev->deviceNo);
+       LOGINF("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no,
+              virtpcidev->device_no);
        POSTCODE_LINUX_2(VHBA_PROBE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
        /* call scsi_host_alloc to register a scsi host adapter
         * instance - this virthba that has just been created is an
@@ -578,18 +578,18 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id)
        INIT_WORK(&virthbainfo->serverdown_completion,
                  virthba_serverdown_complete);
 
-       writeq(readq(&virthbainfo->chinfo.queueinfo->chan->Features) |
+       writeq(readq(&virthbainfo->chinfo.queueinfo->chan->features) |
               ULTRA_IO_CHANNEL_IS_POLLING,
-              &virthbainfo->chinfo.queueinfo->chan->Features);
+              &virthbainfo->chinfo.queueinfo->chan->features);
        /* start thread that will receive scsicmnd responses */
        DBGINF("starting rsp thread -- queueinfo: 0x%p, threadinfo: 0x%p.\n",
               virthbainfo->chinfo.queueinfo, &virthbainfo->chinfo.threadinfo);
 
        pChannelHeader = virthbainfo->chinfo.queueinfo->chan;
-       pqhdr = (SIGNAL_QUEUE_HEADER __iomem *)
+       pqhdr = (struct signal_queue_header __iomem *)
                ((char __iomem *)pChannelHeader +
-                readq(&pChannelHeader->oChannelSpace)) + IOCHAN_FROM_IOPART;
-       virthbainfo->flags_addr = &pqhdr->FeatureFlags;
+                readq(&pChannelHeader->ch_space_offset)) + IOCHAN_FROM_IOPART;
+       virthbainfo->flags_addr = &pqhdr->features;
 
        if (!uisthread_start(&virthbainfo->chinfo.threadinfo,
                             process_incoming_rsps,
@@ -603,16 +603,16 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id)
                return -ENODEV;
        }
        LOGINF("sendInterruptHandle=0x%16llX",
-              virthbainfo->intr.sendInterruptHandle);
+              virthbainfo->intr.send_irq_handle);
        LOGINF("recvInterruptHandle=0x%16llX",
-              virthbainfo->intr.recvInterruptHandle);
+              virthbainfo->intr.recv_irq_handle);
        LOGINF("recvInterruptVector=0x%8X",
-              virthbainfo->intr.recvInterruptVector);
+              virthbainfo->intr.recv_irq_vector);
        LOGINF("recvInterruptShared=0x%2X",
-              virthbainfo->intr.recvInterruptShared);
+              virthbainfo->intr.recv_irq_shared);
        LOGINF("scsihost.hostt->name=%s", scsihost->hostt->name);
        virthbainfo->interrupt_vector =
-           virthbainfo->intr.recvInterruptHandle & INTERRUPT_VECTOR_MASK;
+           virthbainfo->intr.recv_irq_handle & INTERRUPT_VECTOR_MASK;
        rsp = request_irq(virthbainfo->interrupt_vector, handler, IRQF_SHARED,
                          scsihost->hostt->name, virthbainfo);
        if (rsp != 0) {
@@ -622,7 +622,7 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id)
                POSTCODE_LINUX_2(VHBA_PROBE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
        } else {
                u64 __iomem *Features_addr =
-                   &virthbainfo->chinfo.queueinfo->chan->Features;
+                   &virthbainfo->chinfo.queueinfo->chan->features;
                LOGERR("request_irq(%d) uislib_virthba_ISR request succeeded\n",
                       virthbainfo->interrupt_vector);
                mask = ~(ULTRA_IO_CHANNEL_IS_POLLING |
@@ -649,8 +649,8 @@ virthba_remove(struct virtpci_dev *virtpcidev)
        struct Scsi_Host *scsihost =
            (struct Scsi_Host *) virtpcidev->scsi.scsihost;
 
-       LOGINF("virtpcidev busNo<<%d>>devNo<<%d>>", virtpcidev->busNo,
-              virtpcidev->deviceNo);
+       LOGINF("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no,
+              virtpcidev->device_no);
        virthbainfo = (struct virthba_info *) scsihost->hostdata;
        if (virthbainfo->interrupt_vector != -1)
                free_irq(virthbainfo->interrupt_vector, virthbainfo);
@@ -674,7 +674,7 @@ virthba_remove(struct virtpci_dev *virtpcidev)
 }
 
 static int
-forward_vdiskmgmt_command(VDISK_MGMT_TYPES vdiskcmdtype,
+forward_vdiskmgmt_command(enum vdisk_mgmt_types vdiskcmdtype,
                          struct Scsi_Host *scsihost,
                          struct uisscsi_dest *vdest)
 {
@@ -738,7 +738,8 @@ forward_vdiskmgmt_command(VDISK_MGMT_TYPES vdiskcmdtype,
 /*****************************************************/
 
 static int
-forward_taskmgmt_command(TASK_MGMT_TYPES tasktype, struct scsi_device *scsidev)
+forward_taskmgmt_command(enum task_mgmt_types tasktype,
+                        struct scsi_device *scsidev)
 {
        struct uiscmdrsp *cmdrsp;
        struct virthba_info *virthbainfo =
@@ -1142,9 +1143,9 @@ do_scsi_linuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd)
                               scsicmd, cmdrsp->scsi.cmnd[0],
                               scsidev->host->host_no, scsidev->id,
                               scsidev->channel, scsidev->lun,
-                              cmdrsp->scsi.linuxstat, sd->Valid, sd->SenseKey,
-                              sd->AdditionalSenseCode,
-                              sd->AdditionalSenseCodeQualifier);
+                              cmdrsp->scsi.linuxstat, sd->valid, sd->sense_key,
+                              sd->additional_sense_code,
+                              sd->additional_sense_code_qualifier);
                        if (atomic_read(&vdisk->error_count) ==
                            VIRTHBA_ERROR_COUNT) {
                                LOGERR("Throtling SCSICMD errors disk <%d:%d:%d:%llu>\n",
@@ -1276,8 +1277,8 @@ drain_queue(struct virthba_info *virthbainfo, struct chaninfo *dc,
 
        while (1) {
                spin_lock_irqsave(&virthbainfo->chinfo.insertlock, flags);
-               if (!ULTRA_CHANNEL_CLIENT_ACQUIRE_OS(dc->queueinfo->chan,
-                                                    "vhba", NULL)) {
+               if (!spar_channel_client_acquire_os(dc->queueinfo->chan,
+                                                    "vhba")) {
                        spin_unlock_irqrestore(&virthbainfo->chinfo.insertlock,
                                               flags);
                        virthbainfo->acquire_failed_cnt++;
@@ -1285,8 +1286,7 @@ drain_queue(struct virthba_info *virthbainfo, struct chaninfo *dc,
                }
                qrslt = uisqueue_get_cmdrsp(dc->queueinfo, cmdrsp,
                                            IOCHAN_FROM_IOPART);
-               ULTRA_CHANNEL_CLIENT_RELEASE_OS(dc->queueinfo->chan,
-                                               "vhba", NULL);
+               spar_channel_client_release_os(dc->queueinfo->chan, "vhba");
                spin_unlock_irqrestore(&virthbainfo->chinfo.insertlock, flags);
                if (qrslt == 0)
                        break;
@@ -1310,7 +1310,7 @@ drain_queue(struct virthba_info *virthbainfo, struct chaninfo *dc,
                         * a Client/Guest Partition. Let's be
                         * safe and set it to NULL now.  Do
                         * not use it here! */
-                       cmdrsp->disknotify.vHba = NULL;
+                       cmdrsp->disknotify.v_hba = NULL;
                        process_disk_notify(shost, cmdrsp);
                } else if (cmdrsp->cmdtype == CMD_VDISKMGMT_TYPE) {
                        if (!del_scsipending_entry(virthbainfo,
@@ -1453,7 +1453,7 @@ static ssize_t enable_ints_write(struct file *file,
                if (VirtHbasOpen[i].virthbainfo != NULL) {
                        virthbainfo = VirtHbasOpen[i].virthbainfo;
                        Features_addr =
-                               &virthbainfo->chinfo.queueinfo->chan->Features;
+                               &virthbainfo->chinfo.queueinfo->chan->features;
                        if (new_value == 1) {
                                mask = ~(ULTRA_IO_CHANNEL_IS_POLLING |
                                         ULTRA_IO_DRIVER_DISABLES_INTS);
@@ -1482,8 +1482,8 @@ virthba_serverup(struct virtpci_dev *virtpcidev)
            (struct virthba_info *) ((struct Scsi_Host *) virtpcidev->scsi.
                                     scsihost)->hostdata;
 
-       DBGINF("virtpcidev busNo<<%d>>devNo<<%d>>", virtpcidev->busNo,
-              virtpcidev->deviceNo);
+       DBGINF("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no,
+              virtpcidev->device_no);
 
        if (!virthbainfo->serverdown) {
                DBGINF("Server up message received while server is already up.\n");
@@ -1498,9 +1498,9 @@ virthba_serverup(struct virtpci_dev *virtpcidev)
        /* Must transition channel to ATTACHED state BEFORE we
         * can start using the device again
         */
-       ULTRA_CHANNEL_CLIENT_TRANSITION(virthbainfo->chinfo.queueinfo->chan,
-                                       dev_name(&virtpcidev->generic_dev),
-                                       CHANNELCLI_ATTACHED, NULL);
+       SPAR_CHANNEL_CLIENT_TRANSITION(virthbainfo->chinfo.queueinfo->chan,
+                                      dev_name(&virtpcidev->generic_dev),
+                                      CHANNELCLI_ATTACHED, NULL);
 
        /* Start Processing the IOVM Response Queue Again */
        if (!uisthread_start(&virthbainfo->chinfo.threadinfo,
@@ -1573,13 +1573,13 @@ virthba_serverdown_complete(struct work_struct *work)
 
        virtpcidev = virthbainfo->virtpcidev;
 
-       DBGINF("virtpcidev busNo<<%d>>devNo<<%d>>", virtpcidev->busNo,
-              virtpcidev->deviceNo);
+       DBGINF("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no,
+              virtpcidev->device_no);
        virthbainfo->serverdown = true;
        virthbainfo->serverchangingstate = false;
        /* Return the ServerDown response to Command */
-       visorchipset_device_pause_response(virtpcidev->busNo,
-                                          virtpcidev->deviceNo, 0);
+       visorchipset_device_pause_response(virtpcidev->bus_no,
+                                          virtpcidev->device_no, 0);
 }
 
 /* As per VirtpciFunc returns 1 for success and 0 for failure */
@@ -1591,8 +1591,8 @@ virthba_serverdown(struct virtpci_dev *virtpcidev, u32 state)
                                     scsihost)->hostdata;
 
        DBGINF("virthba_serverdown");
-       DBGINF("virtpcidev busNo<<%d>>devNo<<%d>>", virtpcidev->busNo,
-              virtpcidev->deviceNo);
+       DBGINF("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no,
+              virtpcidev->device_no);
 
        if (!virthbainfo->serverdown && !virthbainfo->serverchangingstate) {
                virthbainfo->serverchangingstate = true;
index ee9f826..b6c3130 100644 (file)
@@ -50,6 +50,7 @@ struct driver_private {
        struct module_kobject *mkobj;
        struct device_driver *driver;
 };
+
 #define to_driver(obj) container_of(obj, struct driver_private, kobj)
 
 /* bus_id went away in 2.6.30 - the size was 20 bytes, so we'll define
@@ -109,7 +110,7 @@ static int virtpci_device_probe(struct device *dev);
 static int virtpci_device_remove(struct device *dev);
 
 static ssize_t info_debugfs_read(struct file *file, char __user *buf,
-                             size_t len, loff_t *offset);
+                                size_t len, loff_t *offset);
 
 static const struct file_operations debugfs_info_fops = {
        .read = info_debugfs_read,
@@ -137,7 +138,7 @@ static struct device virtpci_rootbus_device = {
 };
 
 /* filled in with info about parent chipset driver when we register with it */
-static ULTRA_VBUS_DEVICEINFO Chipset_DriverInfo;
+static struct ultra_vbus_deviceinfo Chipset_DriverInfo;
 
 static const struct sysfs_ops virtpci_driver_sysfs_ops = {
        .show = virtpci_driver_attr_show,
@@ -152,7 +153,7 @@ static struct virtpci_dev *VpcidevListHead;
 static DEFINE_RWLOCK(VpcidevListLock);
 
 /* filled in with info about this driver, wrt it servicing client busses */
-static ULTRA_VBUS_DEVICEINFO Bus_DriverInfo;
+static struct ultra_vbus_deviceinfo Bus_DriverInfo;
 
 /*****************************************************/
 /* debugfs entries                                   */
@@ -171,13 +172,12 @@ struct virtpci_busdev {
 /*****************************************************/
 
 static inline
-int WAIT_FOR_IO_CHANNEL(ULTRA_IO_CHANNEL_PROTOCOL __iomem  *chanptr)
+int WAIT_FOR_IO_CHANNEL(struct spar_io_channel_protocol __iomem  *chanptr)
 {
        int count = 120;
 
        while (count > 0) {
-
-               if (ULTRA_CHANNEL_SERVER_READY(&chanptr->ChannelHeader))
+               if (SPAR_CHANNEL_SERVER_READY(&chanptr->channel_header))
                        return 1;
                UIS_THREAD_WAIT_SEC(1);
                count--;
@@ -186,8 +186,8 @@ int WAIT_FOR_IO_CHANNEL(ULTRA_IO_CHANNEL_PROTOCOL __iomem  *chanptr)
 }
 
 /* Write the contents of <info> to the ULTRA_VBUS_CHANNEL_PROTOCOL.ChpInfo. */
-static int write_vbus_chpInfo(ULTRA_VBUS_CHANNEL_PROTOCOL *chan,
-                             ULTRA_VBUS_DEVICEINFO *info)
+static int write_vbus_chpInfo(struct spar_vbus_channel_protocol *chan,
+                             struct ultra_vbus_deviceinfo *info)
 {
        int off;
 
@@ -195,18 +195,18 @@ static int write_vbus_chpInfo(ULTRA_VBUS_CHANNEL_PROTOCOL *chan,
                LOGERR("vbus channel not present");
                return -1;
        }
-       off = sizeof(ULTRA_CHANNEL_PROTOCOL) + chan->HdrInfo.chpInfoByteOffset;
-       if (chan->HdrInfo.chpInfoByteOffset == 0) {
-               LOGERR("vbus channel not used, because chpInfoByteOffset == 0");
+       off = sizeof(struct channel_header) + chan->hdr_info.chp_info_offset;
+       if (chan->hdr_info.chp_info_offset == 0) {
+               LOGERR("vbus channel not used, because chp_info_offset == 0");
                return -1;
        }
-       memcpy(((u8 *) (chan)) + off, info, sizeof(*info));
+       memcpy(((u8 *)(chan)) + off, info, sizeof(*info));
        return 0;
 }
 
 /* Write the contents of <info> to the ULTRA_VBUS_CHANNEL_PROTOCOL.BusInfo. */
-static int write_vbus_busInfo(ULTRA_VBUS_CHANNEL_PROTOCOL *chan,
-                             ULTRA_VBUS_DEVICEINFO *info)
+static int write_vbus_busInfo(struct spar_vbus_channel_protocol *chan,
+                             struct ultra_vbus_deviceinfo *info)
 {
        int off;
 
@@ -214,12 +214,12 @@ static int write_vbus_busInfo(ULTRA_VBUS_CHANNEL_PROTOCOL *chan,
                LOGERR("vbus channel not present");
                return -1;
        }
-       off = sizeof(ULTRA_CHANNEL_PROTOCOL) + chan->HdrInfo.busInfoByteOffset;
-       if (chan->HdrInfo.busInfoByteOffset == 0) {
-               LOGERR("vbus channel not used, because busInfoByteOffset == 0");
+       off = sizeof(struct channel_header) + chan->hdr_info.bus_info_offset;
+       if (chan->hdr_info.bus_info_offset == 0) {
+               LOGERR("vbus channel not used, because bus_info_offset == 0");
                return -1;
        }
-       memcpy(((u8 *) (chan)) + off, info, sizeof(*info));
+       memcpy(((u8 *)(chan)) + off, info, sizeof(*info));
        return 0;
 }
 
@@ -227,8 +227,8 @@ static int write_vbus_busInfo(ULTRA_VBUS_CHANNEL_PROTOCOL *chan,
  * ULTRA_VBUS_CHANNEL_PROTOCOL.DevInfo[<devix>].
  */
 static int
-write_vbus_devInfo(ULTRA_VBUS_CHANNEL_PROTOCOL *chan,
-                  ULTRA_VBUS_DEVICEINFO *info, int devix)
+write_vbus_devInfo(struct spar_vbus_channel_protocol *chan,
+                  struct ultra_vbus_deviceinfo *info, int devix)
 {
        int off;
 
@@ -237,14 +237,14 @@ write_vbus_devInfo(ULTRA_VBUS_CHANNEL_PROTOCOL *chan,
                return -1;
        }
        off =
-           (sizeof(ULTRA_CHANNEL_PROTOCOL) +
-            chan->HdrInfo.devInfoByteOffset) +
-           (chan->HdrInfo.deviceInfoStructBytes * devix);
-       if (chan->HdrInfo.devInfoByteOffset == 0) {
-               LOGERR("vbus channel not used, because devInfoByteOffset == 0");
+           (sizeof(struct channel_header) +
+            chan->hdr_info.dev_info_offset) +
+           (chan->hdr_info.device_info_struct_bytes * devix);
+       if (chan->hdr_info.dev_info_offset == 0) {
+               LOGERR("vbus channel not used, because dev_info_offset == 0");
                return -1;
        }
-       memcpy(((u8 *) (chan)) + off, info, sizeof(*info));
+       memcpy(((u8 *)(chan)) + off, info, sizeof(*info));
        return 0;
 }
 
@@ -256,13 +256,13 @@ static int add_vbus(struct add_vbus_guestpart *addparams)
        int ret;
        struct device *vbus;
 
-       vbus = kzalloc(sizeof(struct device), GFP_ATOMIC);
+       vbus = kzalloc(sizeof(*vbus), GFP_ATOMIC);
 
        POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
        if (!vbus)
                return 0;
 
-       dev_set_name(vbus, "vbus%d", addparams->busNo);
+       dev_set_name(vbus, "vbus%d", addparams->bus_no);
        vbus->release = virtpci_bus_release;
        vbus->parent = &virtpci_rootbus_device; /* root bus is parent */
        vbus->bus = &virtpci_bus_type;  /* bus type */
@@ -283,7 +283,7 @@ static int add_vbus(struct add_vbus_guestpart *addparams)
                           &Chipset_DriverInfo);
        write_vbus_busInfo(vbus->platform_data /* chanptr */ , &Bus_DriverInfo);
        LOGINF("Added vbus %d; device %s created successfully\n",
-              addparams->busNo, BUS_ID(vbus));
+              addparams->bus_no, BUS_ID(vbus));
        POSTCODE_LINUX_2(VPCI_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO);
        return 1;
 }
@@ -293,11 +293,11 @@ static int add_vbus(struct add_vbus_guestpart *addparams)
  */
 #define GET_SCSIADAPINFO_FROM_CHANPTR(chanptr) {                       \
        memcpy_fromio(&scsi.wwnn,                                       \
-                     &((ULTRA_IO_CHANNEL_PROTOCOL __iomem *)           \
+                     &((struct spar_io_channel_protocol __iomem *)     \
                        chanptr)->vhba.wwnn,                            \
                      sizeof(struct vhba_wwnn));                        \
        memcpy_fromio(&scsi.max,                                        \
-                     &((ULTRA_IO_CHANNEL_PROTOCOL __iomem *)           \
+                     &((struct spar_io_channel_protocol __iomem *)     \
                        chanptr)->vhba.max,                             \
                      sizeof(struct vhba_config_max));                  \
        }
@@ -325,7 +325,7 @@ static int add_vhba(struct add_virt_guestpart *addparams)
 
        POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
        if (!WAIT_FOR_IO_CHANNEL
-           ((ULTRA_IO_CHANNEL_PROTOCOL __iomem *) addparams->chanptr)) {
+           ((struct spar_io_channel_protocol __iomem *)addparams->chanptr)) {
                LOGERR("Timed out.  Channel not ready\n");
                POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
                return 0;
@@ -347,7 +347,6 @@ static int add_vhba(struct add_virt_guestpart *addparams)
                                 POSTCODE_SEVERITY_INFO);
        }
        return i;
-
 }
 
 /* for CHANSOCK macaddr is AUTO-GENERATED; for normal channels,
@@ -355,17 +354,17 @@ static int add_vhba(struct add_virt_guestpart *addparams)
  */
 #define GET_NETADAPINFO_FROM_CHANPTR(chanptr) {                                \
                memcpy_fromio(net.mac_addr,                             \
-                      ((ULTRA_IO_CHANNEL_PROTOCOL __iomem *)           \
-                       chanptr)->vnic.macaddr,                         \
+                      ((struct spar_io_channel_protocol __iomem *)     \
+                      chanptr)->vnic.macaddr,                          \
                       MAX_MACADDR_LEN);                                \
                net.num_rcv_bufs =                                      \
-                       readl(&((ULTRA_IO_CHANNEL_PROTOCOL __iomem *)   \
-                               chanptr)->vnic.num_rcv_bufs);           \
-               net.mtu = readl(&((ULTRA_IO_CHANNEL_PROTOCOL __iomem *) \
-                                 chanptr)->vnic.mtu);                  \
-               memcpy_fromio(&net.zoneGuid, \
-                             &((ULTRA_IO_CHANNEL_PROTOCOL __iomem *)   \
-                               chanptr)->vnic.zoneGuid,                \
+                       readl(&((struct spar_io_channel_protocol __iomem *)\
+                             chanptr)->vnic.num_rcv_bufs);             \
+               net.mtu = readl(&((struct spar_io_channel_protocol __iomem *) \
+                               chanptr)->vnic.mtu);                    \
+               memcpy_fromio(&net.zone_uuid, \
+                             &((struct spar_io_channel_protocol __iomem *)\
+                             chanptr)->vnic.zone_uuid,         \
                              sizeof(uuid_le));                         \
 }
 
@@ -382,7 +381,7 @@ add_vnic(struct add_virt_guestpart *addparams)
 
        POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
        if (!WAIT_FOR_IO_CHANNEL
-           ((ULTRA_IO_CHANNEL_PROTOCOL __iomem *) addparams->chanptr)) {
+           ((struct spar_io_channel_protocol __iomem *)addparams->chanptr)) {
                LOGERR("Timed out, channel not ready\n");
                POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
                return 0;
@@ -393,9 +392,9 @@ add_vnic(struct add_virt_guestpart *addparams)
        GET_BUS_DEV(addparams->bus_no);
 
        LOGINF("Adding vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x rcvbufs:%d mtu:%d chanptr:%p%pUL\n",
-            net.mac_addr[0], net.mac_addr[1], net.mac_addr[2], net.mac_addr[3],
-            net.mac_addr[4], net.mac_addr[5], net.num_rcv_bufs, net.mtu,
-            addparams->chanptr, &net.zoneGuid);
+              net.mac_addr[0], net.mac_addr[1], net.mac_addr[2],
+              net.mac_addr[3], net.mac_addr[4], net.mac_addr[5],
+              net.num_rcv_bufs, net.mtu, addparams->chanptr, &net.zone_uuid);
        i = virtpci_device_add(vbus, VIRTNIC_TYPE, addparams, NULL, &net);
        if (i) {
                LOGINF("Added vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n",
@@ -432,7 +431,7 @@ delete_vbus_device(struct device *vbus, void *data)
        int checkforroot = (data != NULL);
        struct device *pDev = &virtpci_rootbus_device;
 
-       if ((checkforroot) && match_busid(vbus, (void *) BUS_ID(pDev))) {
+       if ((checkforroot) && match_busid(vbus, (void *)BUS_ID(pDev))) {
                /* skip it - don't delete root bus */
                LOGINF("skipping root bus\n");
                return 0;       /* pretend no error */
@@ -607,14 +606,15 @@ static void delete_all(void)
 
        /* now delete each vbus */
        if (bus_for_each_dev
-           (&virtpci_bus_type, NULL, (void *) 1, delete_vbus_device))
+           (&virtpci_bus_type, NULL, (void *)1, delete_vbus_device))
                LOGERR("delete of all vbus failed\n");
 }
 
 /* deletes all vnics or vhbas
  * returns 0 failure, 1 success,
  */
-static int delete_all_virt(VIRTPCI_DEV_TYPE devtype, struct del_vbus_guestpart *delparams)
+static int delete_all_virt(enum virtpci_dev_type devtype,
+                          struct del_vbus_guestpart *delparams)
 {
        int i;
        unsigned char busid[BUS_ID_SIZE];
@@ -624,7 +624,7 @@ static int delete_all_virt(VIRTPCI_DEV_TYPE devtype, struct del_vbus_guestpart *
 
        if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) {
                LOGERR("**** FAILED to delete all devices; devtype:%d not vhba:%d or vnic:%d\n",
-                    devtype, VIRTHBA_TYPE, VIRTNIC_TYPE);
+                      devtype, VIRTHBA_TYPE, VIRTNIC_TYPE);
                return 0;
        }
 
@@ -694,10 +694,10 @@ virtpci_match_device(const struct pci_device_id *ids,
 {
        while (ids->vendor || ids->subvendor || ids->class_mask) {
                DBGINF("ids->vendor:%x dev->vendor:%x ids->device:%x dev->device:%x\n",
-                    ids->vendor, dev->vendor, ids->device, dev->device);
+                      ids->vendor, dev->vendor, ids->device, dev->device);
 
-               if ((ids->vendor == dev->vendor)
-                   && (ids->device == dev->device))
+               if ((ids->vendor == dev->vendor) &&
+                   (ids->device == dev->device))
                        return ids;
 
                ids++;
@@ -752,7 +752,7 @@ static int virtpci_device_resume(struct device *dev)
 
 /* For a child device just created on a client bus, fill in
  * information about the driver that is controlling this device into
- * the the appropriate slot within the vbus channel of the bus
+ * the appropriate slot within the vbus channel of the bus
  * instance.
  */
 static void fix_vbus_devInfo(struct device *dev, int devNo, int devType,
@@ -760,7 +760,7 @@ static void fix_vbus_devInfo(struct device *dev, int devNo, int devType,
 {
        struct device *vbus;
        void *pChan;
-       ULTRA_VBUS_DEVICEINFO devInfo;
+       struct ultra_vbus_deviceinfo devInfo;
        const char *stype;
 
        if (!dev) {
@@ -793,9 +793,9 @@ static void fix_vbus_devInfo(struct device *dev, int devNo, int devType,
                break;
        }
        bus_device_info_init(&devInfo, stype,
-                          virtpcidrv->name,
-                          virtpcidrv->version,
-                          virtpcidrv->vertag);
+                            virtpcidrv->name,
+                            virtpcidrv->version,
+                            virtpcidrv->vertag);
        write_vbus_devInfo(pChan, &devInfo, devNo);
 
        /* Re-write bus+chipset info, because it is possible that this
@@ -842,13 +842,14 @@ static int virtpci_device_probe(struct device *dev)
                 */
                error = virtpcidrv->probe(virtpcidev, id);
                if (!error) {
-                       fix_vbus_devInfo(dev, virtpcidev->deviceNo,
+                       fix_vbus_devInfo(dev, virtpcidev->device_no,
                                         virtpcidev->device, virtpcidrv);
                        virtpcidev->mydriver = virtpcidrv;
                        POSTCODE_LINUX_2(VPCI_PROBE_EXIT_PC,
                                         POSTCODE_SEVERITY_INFO);
-               } else
+               } else {
                        put_device(dev);
+               }
        }
        POSTCODE_LINUX_2(VPCI_PROBE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
        return error;           /* -ENODEV for probe failure */
@@ -896,16 +897,19 @@ static void virtpci_bus_release(struct device *dev)
 /* Adapter functions                                 */
 /*****************************************************/
 
+/* scsi is expected to be NULL for VNIC add
+ * net is expected to be NULL for VHBA add
+ */
 static int virtpci_device_add(struct device *parentbus, int devtype,
                              struct add_virt_guestpart *addparams,
-                             struct scsi_adap_info *scsi, /* NULL for VNIC add */
-                             struct net_adap_info *net /* NULL for VHBA add */)
+                             struct scsi_adap_info *scsi,
+                             struct net_adap_info *net)
 {
        struct virtpci_dev *virtpcidev = NULL;
        struct virtpci_dev *tmpvpcidev = NULL, *prev;
        unsigned long flags;
        int ret;
-       ULTRA_IO_CHANNEL_PROTOCOL __iomem *pIoChan = NULL;
+       struct spar_io_channel_protocol __iomem *pIoChan = NULL;
        struct device *pDev;
 
        LOGINF("virtpci_device_add parentbus:%p chanptr:%p\n", parentbus,
@@ -915,14 +919,14 @@ static int virtpci_device_add(struct device *parentbus, int devtype,
 
        if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) {
                LOGERR("**** FAILED to add device; devtype:%d not vhba:%d or vnic:%d\n",
-                    devtype, VIRTHBA_TYPE, VIRTNIC_TYPE);
+                      devtype, VIRTHBA_TYPE, VIRTNIC_TYPE);
                POSTCODE_LINUX_3(VPCI_CREATE_FAILURE_PC, devtype,
                                 POSTCODE_SEVERITY_ERR);
                return 0;
        }
 
        /* add a Virtual Device */
-       virtpcidev = kzalloc(sizeof(struct virtpci_dev), GFP_ATOMIC);
+       virtpcidev = kzalloc(sizeof(*virtpcidev), GFP_ATOMIC);
        if (virtpcidev == NULL) {
                LOGERR("can't add device - malloc FALLED\n");
                POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR);
@@ -939,14 +943,14 @@ static int virtpci_device_add(struct device *parentbus, int devtype,
                virtpcidev->net = *net;
        }
        virtpcidev->vendor = PCI_VENDOR_ID_UNISYS;
-       virtpcidev->busNo = addparams->bus_no;
-       virtpcidev->deviceNo = addparams->device_no;
+       virtpcidev->bus_no = addparams->bus_no;
+       virtpcidev->device_no = addparams->device_no;
 
        virtpcidev->queueinfo.chan = addparams->chanptr;
        virtpcidev->queueinfo.send_int_if_needed = NULL;
 
        /* Set up safe queue... */
-       pIoChan = (ULTRA_IO_CHANNEL_PROTOCOL __iomem *)
+       pIoChan = (struct spar_io_channel_protocol __iomem *)
                virtpcidev->queueinfo.chan;
 
        virtpcidev->intr = addparams->intr;
@@ -992,9 +996,9 @@ static int virtpci_device_add(struct device *parentbus, int devtype,
        }
 
        /* add it at the head */
-       if (!VpcidevListHead)
+       if (!VpcidevListHead) {
                VpcidevListHead = virtpcidev;
-       else {
+       else {
                /* insert virtpcidev at the head of our linked list of
                 * vpcidevs
                 */
@@ -1009,9 +1013,9 @@ static int virtpci_device_add(struct device *parentbus, int devtype,
         * queues can begin at any time after device_register().
         */
        pDev = &virtpcidev->generic_dev;
-       ULTRA_CHANNEL_CLIENT_TRANSITION(addparams->chanptr,
-                                       BUS_ID(pDev),
-                                       CHANNELCLI_ATTACHED, NULL);
+       SPAR_CHANNEL_CLIENT_TRANSITION(addparams->chanptr,
+                                      BUS_ID(pDev),
+                                      CHANNELCLI_ATTACHED, NULL);
 
        /* don't register until device has been added to
        * list. Otherwise, a device_unregister from this function can
@@ -1032,9 +1036,9 @@ static int virtpci_device_add(struct device *parentbus, int devtype,
        if (ret) {
                LOGERR("device_register returned %d\n", ret);
                pDev = &virtpcidev->generic_dev;
-               ULTRA_CHANNEL_CLIENT_TRANSITION(addparams->chanptr,
-                                               BUS_ID(pDev),
-                                               CHANNELCLI_DETACHED, NULL);
+               SPAR_CHANNEL_CLIENT_TRANSITION(addparams->chanptr,
+                                              BUS_ID(pDev),
+                                              CHANNELCLI_DETACHED, NULL);
                /* remove virtpcidev, the one we just added, from the list */
                write_lock_irqsave(&VpcidevListLock, flags);
                for (tmpvpcidev = VpcidevListHead, prev = NULL;
@@ -1172,7 +1176,8 @@ static int virtpci_device_serverup(struct device *parentbus,
                * ever have a bus that contains NO devices, since we
                * would never even get here in that case.
                */
-               fix_vbus_devInfo(&tmpvpcidev->generic_dev, tmpvpcidev->deviceNo,
+               fix_vbus_devInfo(&tmpvpcidev->generic_dev,
+                                tmpvpcidev->device_no,
                                 tmpvpcidev->device, vpcidriver);
                rc = vpcidriver->resume(tmpvpcidev);
        }
@@ -1425,7 +1430,7 @@ static int print_vbus(struct device *vbus, void *data)
 }
 
 static ssize_t info_debugfs_read(struct file *file, char __user *buf,
-                             size_t len, loff_t *offset)
+                                size_t len, loff_t *offset)
 {
        ssize_t bytes_read = 0;
        int str_pos = 0;
@@ -1446,7 +1451,7 @@ static ssize_t info_debugfs_read(struct file *file, char __user *buf,
        printparam.buf = vbuf;
        printparam.len = &len;
        if (bus_for_each_dev(&virtpci_bus_type, NULL,
-                            (void *) &printparam, print_vbus))
+                            (void *)&printparam, print_vbus))
                LOGERR("Failed to find bus\n");
 
        str_pos += scnprintf(vbuf + str_pos, len - str_pos,
@@ -1457,7 +1462,8 @@ static ssize_t info_debugfs_read(struct file *file, char __user *buf,
                if (tmpvpcidev->devtype == VIRTHBA_TYPE) {
                        str_pos += scnprintf(vbuf + str_pos, len - str_pos,
                                        "[%d:%d] VHba:%08x:%08x max-config:%d-%d-%d-%d",
-                                       tmpvpcidev->busNo, tmpvpcidev->deviceNo,
+                                       tmpvpcidev->bus_no,
+                                       tmpvpcidev->device_no,
                                        tmpvpcidev->scsi.wwnn.wwnn1,
                                        tmpvpcidev->scsi.wwnn.wwnn2,
                                        tmpvpcidev->scsi.max.max_channel,
@@ -1467,7 +1473,8 @@ static ssize_t info_debugfs_read(struct file *file, char __user *buf,
                } else {
                        str_pos += scnprintf(vbuf + str_pos, len - str_pos,
                                        "[%d:%d] VNic:%02x:%02x:%02x:%02x:%02x:%02x num_rcv_bufs:%d mtu:%d",
-                                       tmpvpcidev->busNo, tmpvpcidev->deviceNo,
+                                       tmpvpcidev->bus_no,
+                                       tmpvpcidev->device_no,
                                        tmpvpcidev->net.mac_addr[0],
                                        tmpvpcidev->net.mac_addr[1],
                                        tmpvpcidev->net.mac_addr[2],
@@ -1498,7 +1505,6 @@ static int __init virtpci_mod_init(void)
 {
        int ret;
 
-
        if (!unisys_spar_platform)
                return -ENODEV;
 
@@ -1516,7 +1522,7 @@ static int __init virtpci_mod_init(void)
        }
        DBGINF("bus_register successful\n");
        bus_device_info_init(&Bus_DriverInfo, "clientbus", "virtpci",
-                          VERSION, NULL);
+                            VERSION, NULL);
 
        /* create a root bus used to parent all the virtpci buses. */
        ret = device_register(&virtpci_rootbus_device);
@@ -1529,7 +1535,7 @@ static int __init virtpci_mod_init(void)
        }
        DBGINF("device_register successful ret:%x\n", ret);
 
-       if (!uisctrl_register_req_handler(2, (void *) &virtpci_ctrlchan_func,
+       if (!uisctrl_register_req_handler(2, (void *)&virtpci_ctrlchan_func,
                                          &Chipset_DriverInfo)) {
                LOGERR("uisctrl_register_req_handler ****FAILED.\n");
                POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
@@ -1539,11 +1545,11 @@ static int __init virtpci_mod_init(void)
        }
 
        LOGINF("successfully registered virtpci_ctrlchan_func (0x%p) as callback.\n",
-            (void *) &virtpci_ctrlchan_func);
+              (void *)&virtpci_ctrlchan_func);
        /* create debugfs directory and info file inside. */
        virtpci_debugfs_dir = debugfs_create_dir("virtpci", NULL);
        debugfs_create_file("info", S_IRUSR, virtpci_debugfs_dir,
-                       NULL, &debugfs_info_fops);
+                           NULL, &debugfs_info_fops);
        LOGINF("Leaving\n");
        POSTCODE_LINUX_2(VPCI_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO);
        return 0;
@@ -1561,7 +1567,6 @@ static void __exit virtpci_mod_exit(void)
        bus_unregister(&virtpci_bus_type);
        debugfs_remove_recursive(virtpci_debugfs_dir);
        LOGINF("Leaving\n");
-
 }
 
 module_init(virtpci_mod_init);
index 6e26956..9d85f55 100644 (file)
@@ -42,25 +42,25 @@ struct net_adap_info {
        u8 mac_addr[MAX_MACADDR_LEN];
        int num_rcv_bufs;
        unsigned mtu;
-       uuid_le zoneGuid;
+       uuid_le zone_uuid;
 };
 
-typedef enum {
+enum virtpci_dev_type {
        VIRTHBA_TYPE = 0,
        VIRTNIC_TYPE = 1,
        VIRTBUS_TYPE = 6,
-} VIRTPCI_DEV_TYPE;
+};
 
 struct virtpci_dev {
-       VIRTPCI_DEV_TYPE devtype;       /* indicates type of the
+       enum virtpci_dev_type devtype;  /* indicates type of the
                                         * virtual pci device */
        struct virtpci_driver *mydriver;        /* which driver has allocated
                                                 * this device */
        unsigned short vendor;  /* vendor id for device */
        unsigned short device;  /* device id for device */
-       u32 busNo;              /* number of bus on which device exists */
-       u32 deviceNo;           /* device's number on the bus */
-       struct InterruptInfo intr;      /* interrupt info */
+       u32 bus_no;             /* number of bus on which device exists */
+       u32 device_no;          /* device's number on the bus */
+       struct irq_info intr;   /* interrupt info */
        struct device generic_dev;      /* generic device */
        union {
                struct scsi_adap_info scsi;
@@ -80,15 +80,15 @@ struct virtpci_driver {
        const struct pci_device_id *id_table;   /* must be non-NULL for probe
                                                 * to be called */
        int (*probe)(struct virtpci_dev *dev,
-                     const struct pci_device_id *id); /* device inserted */
+                    const struct pci_device_id *id); /* device inserted */
        void (*remove)(struct virtpci_dev *dev); /* Device removed (NULL if
                                                    * not a hot-plug capable
                                                    * driver) */
        int (*suspend)(struct virtpci_dev *dev,
-                       u32 state);                /* Device suspended */
+                      u32 state);                 /* Device suspended */
        int (*resume)(struct virtpci_dev *dev); /* Device woken up */
        int (*enable_wake)(struct virtpci_dev *dev,
-                           u32 state, int enable);     /* Enable wake event */
+                          u32 state, int enable);      /* Enable wake event */
        struct device_driver core_driver;       /* VIRTPCI core fills this in */
 };
 
index 01a44c5..5fbd5ad 100644 (file)
@@ -30,7 +30,7 @@
 
 struct VISORCHANNEL_Tag {
        MEMREGION *memregion;   /* from visor_memregion_create() */
-       CHANNEL_HEADER chan_hdr;
+       struct channel_header chan_hdr;
        uuid_le guid;
        ulong size;
        BOOL needs_lock;
@@ -38,10 +38,10 @@ struct VISORCHANNEL_Tag {
        spinlock_t remove_lock;
 
        struct {
-               SIGNAL_QUEUE_HEADER req_queue;
-               SIGNAL_QUEUE_HEADER rsp_queue;
-               SIGNAL_QUEUE_HEADER event_queue;
-               SIGNAL_QUEUE_HEADER ack_queue;
+               struct signal_queue_header req_queue;
+               struct signal_queue_header rsp_queue;
+               struct signal_queue_header event_queue;
+               struct signal_queue_header ack_queue;
        } safe_uis_queue;
 };
 
@@ -70,29 +70,29 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channelBytes,
        /* prepare chan_hdr (abstraction to read/write channel memory) */
        if (parent == NULL)
                p->memregion =
-                   visor_memregion_create(physaddr, sizeof(CHANNEL_HEADER));
+                   visor_memregion_create(physaddr,
+                                          sizeof(struct channel_header));
        else
                p->memregion =
                    visor_memregion_create_overlapped(parent->memregion,
-                                                     off,
-                                                     sizeof(CHANNEL_HEADER));
+                               off, sizeof(struct channel_header));
        if (p->memregion == NULL) {
                ERRDRV("visor_memregion_create failed failed: (status=0)\n");
                rc = NULL;
                goto Away;
        }
        if (visor_memregion_read(p->memregion, 0, &p->chan_hdr,
-                                sizeof(CHANNEL_HEADER)) < 0) {
+                                sizeof(struct channel_header)) < 0) {
                ERRDRV("visor_memregion_read failed: (status=0)\n");
                rc = NULL;
                goto Away;
        }
        if (channelBytes == 0)
                /* we had better be a CLIENT of this channel */
-               channelBytes = (ulong) p->chan_hdr.Size;
+               channelBytes = (ulong) p->chan_hdr.size;
        if (uuid_le_cmp(guid, NULL_UUID_LE) == 0)
                /* we had better be a CLIENT of this channel */
-               guid = p->chan_hdr.Type;
+               guid = p->chan_hdr.chtype;
        if (visor_memregion_resize(p->memregion, channelBytes) < 0) {
                ERRDRV("visor_memregion_resize failed: (status=0)\n");
                rc = NULL;
@@ -194,14 +194,14 @@ EXPORT_SYMBOL_GPL(visorchannel_id);
 char *
 visorchannel_zoneid(VISORCHANNEL *channel, char *s)
 {
-       return visorchannel_uuid_id(&channel->chan_hdr.ZoneGuid, s);
+       return visorchannel_uuid_id(&channel->chan_hdr.zone_uuid, s);
 }
 EXPORT_SYMBOL_GPL(visorchannel_zoneid);
 
 HOSTADDRESS
 visorchannel_get_clientpartition(VISORCHANNEL *channel)
 {
-       return channel->chan_hdr.PartitionHandle;
+       return channel->chan_hdr.partition_handle;
 }
 EXPORT_SYMBOL_GPL(visorchannel_get_clientpartition);
 
@@ -225,8 +225,11 @@ visorchannel_read(VISORCHANNEL *channel, ulong offset,
 {
        int rc = visor_memregion_read(channel->memregion, offset,
                                      local, nbytes);
-       if ((rc >= 0) && (offset == 0) && (nbytes >= sizeof(CHANNEL_HEADER)))
-               memcpy(&channel->chan_hdr, local, sizeof(CHANNEL_HEADER));
+       if ((rc >= 0) && (offset == 0) &&
+          (nbytes >= sizeof(struct channel_header))) {
+               memcpy(&channel->chan_hdr, local,
+                      sizeof(struct channel_header));
+       }
        return rc;
 }
 EXPORT_SYMBOL_GPL(visorchannel_read);
@@ -235,8 +238,9 @@ int
 visorchannel_write(VISORCHANNEL *channel, ulong offset,
                   void *local, ulong nbytes)
 {
-       if (offset == 0 && nbytes >= sizeof(CHANNEL_HEADER))
-               memcpy(&channel->chan_hdr, local, sizeof(CHANNEL_HEADER));
+       if (offset == 0 && nbytes >= sizeof(struct channel_header))
+               memcpy(&channel->chan_hdr, local,
+                      sizeof(struct channel_header));
        return visor_memregion_write(channel->memregion, offset, local, nbytes);
 }
 EXPORT_SYMBOL_GPL(visorchannel_write);
@@ -291,14 +295,15 @@ EXPORT_SYMBOL_GPL(visorchannel_get_header);
  *  channel header
  */
 #define SIG_QUEUE_OFFSET(chan_hdr, q) \
-       ((chan_hdr)->oChannelSpace + ((q) * sizeof(SIGNAL_QUEUE_HEADER)))
+       ((chan_hdr)->ch_space_offset + \
+        ((q) * sizeof(struct signal_queue_header)))
 
 /** Return offset of a specific queue entry (data) from the beginning of a
  *  channel header
  */
 #define SIG_DATA_OFFSET(chan_hdr, q, sig_hdr, slot) \
-       (SIG_QUEUE_OFFSET(chan_hdr, q) + (sig_hdr)->oSignalBase + \
-           ((slot) * (sig_hdr)->SignalSize))
+       (SIG_QUEUE_OFFSET(chan_hdr, q) + (sig_hdr)->sig_base_offset + \
+           ((slot) * (sig_hdr)->signal_size))
 
 /** Write the contents of a specific field within a SIGNAL_QUEUE_HEADER back
  *  into host memory
@@ -306,17 +311,17 @@ EXPORT_SYMBOL_GPL(visorchannel_get_header);
 #define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD)                        \
        (visor_memregion_write(channel->memregion,                      \
                               SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)+ \
-                              offsetof(SIGNAL_QUEUE_HEADER, FIELD),    \
+                              offsetof(struct signal_queue_header, FIELD),\
                               &((sig_hdr)->FIELD),                     \
                               sizeof((sig_hdr)->FIELD)) >= 0)
 
 static BOOL
 sig_read_header(VISORCHANNEL *channel, u32 queue,
-               SIGNAL_QUEUE_HEADER *sig_hdr)
+               struct signal_queue_header *sig_hdr)
 {
        BOOL rc = FALSE;
 
-       if (channel->chan_hdr.oChannelSpace < sizeof(CHANNEL_HEADER)) {
+       if (channel->chan_hdr.ch_space_offset < sizeof(struct channel_header)) {
                ERRDRV("oChannelSpace too small: (status=%d)\n", rc);
                goto Away;
        }
@@ -325,7 +330,8 @@ sig_read_header(VISORCHANNEL *channel, u32 queue,
 
        if (visor_memregion_read(channel->memregion,
                                 SIG_QUEUE_OFFSET(&channel->chan_hdr, queue),
-                                sig_hdr, sizeof(SIGNAL_QUEUE_HEADER)) < 0) {
+                                sig_hdr,
+                                sizeof(struct signal_queue_header)) < 0) {
                ERRDRV("queue=%d SIG_QUEUE_OFFSET=%d",
                       queue, (int)SIG_QUEUE_OFFSET(&channel->chan_hdr, queue));
                ERRDRV("visor_memregion_read of signal queue failed: (status=%d)\n", rc);
@@ -338,7 +344,8 @@ Away:
 
 static BOOL
 sig_do_data(VISORCHANNEL *channel, u32 queue,
-           SIGNAL_QUEUE_HEADER *sig_hdr, u32 slot, void *data, BOOL is_write)
+           struct signal_queue_header *sig_hdr, u32 slot, void *data,
+           BOOL is_write)
 {
        BOOL rc = FALSE;
        int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue,
@@ -346,13 +353,13 @@ sig_do_data(VISORCHANNEL *channel, u32 queue,
        if (is_write) {
                if (visor_memregion_write(channel->memregion,
                                          signal_data_offset,
-                                         data, sig_hdr->SignalSize) < 0) {
+                                         data, sig_hdr->signal_size) < 0) {
                        ERRDRV("visor_memregion_write of signal data failed: (status=%d)\n", rc);
                        goto Away;
                }
        } else {
                if (visor_memregion_read(channel->memregion, signal_data_offset,
-                                        data, sig_hdr->SignalSize) < 0) {
+                                        data, sig_hdr->signal_size) < 0) {
                        ERRDRV("visor_memregion_read of signal data failed: (status=%d)\n", rc);
                        goto Away;
                }
@@ -364,35 +371,35 @@ Away:
 
 static inline BOOL
 sig_read_data(VISORCHANNEL *channel, u32 queue,
-             SIGNAL_QUEUE_HEADER *sig_hdr, u32 slot, void *data)
+             struct signal_queue_header *sig_hdr, u32 slot, void *data)
 {
        return sig_do_data(channel, queue, sig_hdr, slot, data, FALSE);
 }
 
 static inline BOOL
 sig_write_data(VISORCHANNEL *channel, u32 queue,
-              SIGNAL_QUEUE_HEADER *sig_hdr, u32 slot, void *data)
+              struct signal_queue_header *sig_hdr, u32 slot, void *data)
 {
        return sig_do_data(channel, queue, sig_hdr, slot, data, TRUE);
 }
 
 static inline unsigned char
-safe_sig_queue_validate(pSIGNAL_QUEUE_HEADER psafe_sqh,
-                       pSIGNAL_QUEUE_HEADER punsafe_sqh,
+safe_sig_queue_validate(struct signal_queue_header *psafe_sqh,
+                       struct signal_queue_header *punsafe_sqh,
                        u32 *phead, u32 *ptail)
 {
-       if ((*phead >= psafe_sqh->MaxSignalSlots)
-           || (*ptail >= psafe_sqh->MaxSignalSlots)) {
+       if ((*phead >= psafe_sqh->max_slots)
+           || (*ptail >= psafe_sqh->max_slots)) {
                /* Choose 0 or max, maybe based on current tail value */
                *phead = 0;
                *ptail = 0;
 
                /* Sync with client as necessary */
-               punsafe_sqh->Head = *phead;
-               punsafe_sqh->Tail = *ptail;
+               punsafe_sqh->head = *phead;
+               punsafe_sqh->tail = *ptail;
 
                ERRDRV("safe_sig_queue_validate: head = 0x%x, tail = 0x%x, MaxSlots = 0x%x",
-                    *phead, *ptail, psafe_sqh->MaxSignalSlots);
+                    *phead, *ptail, psafe_sqh->max_slots);
                return 0;
        }
        return 1;
@@ -402,7 +409,7 @@ BOOL
 visorchannel_signalremove(VISORCHANNEL *channel, u32 queue, void *msg)
 {
        BOOL rc = FALSE;
-       SIGNAL_QUEUE_HEADER sig_hdr;
+       struct signal_queue_header sig_hdr;
 
        if (channel->needs_lock)
                spin_lock(&channel->remove_lock);
@@ -411,27 +418,27 @@ visorchannel_signalremove(VISORCHANNEL *channel, u32 queue, void *msg)
                rc = FALSE;
                goto Away;
        }
-       if (sig_hdr.Head == sig_hdr.Tail) {
+       if (sig_hdr.head == sig_hdr.tail) {
                rc = FALSE;     /* no signals to remove */
                goto Away;
        }
-       sig_hdr.Tail = (sig_hdr.Tail + 1) % sig_hdr.MaxSignalSlots;
-       if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.Tail, msg)) {
+       sig_hdr.tail = (sig_hdr.tail + 1) % sig_hdr.max_slots;
+       if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg)) {
                ERRDRV("sig_read_data failed: (status=%d)\n", rc);
                goto Away;
        }
-       sig_hdr.NumSignalsReceived++;
+       sig_hdr.num_received++;
 
        /* For each data field in SIGNAL_QUEUE_HEADER that was modified,
         * update host memory.
         */
        mb(); /* required for channel synch */
-       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, Tail)) {
+       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, tail)) {
                ERRDRV("visor_memregion_write of Tail failed: (status=%d)\n",
                       rc);
                goto Away;
        }
-       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, NumSignalsReceived)) {
+       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received)) {
                ERRDRV("visor_memregion_write of NumSignalsReceived failed: (status=%d)\n", rc);
                goto Away;
        }
@@ -448,7 +455,7 @@ BOOL
 visorchannel_signalinsert(VISORCHANNEL *channel, u32 queue, void *msg)
 {
        BOOL rc = FALSE;
-       SIGNAL_QUEUE_HEADER sig_hdr;
+       struct signal_queue_header sig_hdr;
 
        if (channel->needs_lock)
                spin_lock(&channel->insert_lock);
@@ -458,10 +465,10 @@ visorchannel_signalinsert(VISORCHANNEL *channel, u32 queue, void *msg)
                goto Away;
        }
 
-       sig_hdr.Head = ((sig_hdr.Head + 1) % sig_hdr.MaxSignalSlots);
-       if (sig_hdr.Head == sig_hdr.Tail) {
-               sig_hdr.NumOverflows++;
-               if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, NumOverflows)) {
+       sig_hdr.head = ((sig_hdr.head + 1) % sig_hdr.max_slots);
+       if (sig_hdr.head == sig_hdr.tail) {
+               sig_hdr.num_overflows++;
+               if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_overflows)) {
                        ERRDRV("visor_memregion_write of NumOverflows failed: (status=%d)\n", rc);
                        goto Away;
                }
@@ -469,22 +476,22 @@ visorchannel_signalinsert(VISORCHANNEL *channel, u32 queue, void *msg)
                goto Away;
        }
 
-       if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.Head, msg)) {
+       if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.head, msg)) {
                ERRDRV("sig_write_data failed: (status=%d)\n", rc);
                goto Away;
        }
-       sig_hdr.NumSignalsSent++;
+       sig_hdr.num_sent++;
 
        /* For each data field in SIGNAL_QUEUE_HEADER that was modified,
         * update host memory.
         */
        mb(); /* required for channel synch */
-       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, Head)) {
+       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, head)) {
                ERRDRV("visor_memregion_write of Head failed: (status=%d)\n",
                       rc);
                goto Away;
        }
-       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, NumSignalsSent)) {
+       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent)) {
                ERRDRV("visor_memregion_write of NumSignalsSent failed: (status=%d)\n", rc);
                goto Away;
        }
@@ -501,18 +508,18 @@ EXPORT_SYMBOL_GPL(visorchannel_signalinsert);
 int
 visorchannel_signalqueue_slots_avail(VISORCHANNEL *channel, u32 queue)
 {
-       SIGNAL_QUEUE_HEADER sig_hdr;
+       struct signal_queue_header sig_hdr;
        u32 slots_avail, slots_used;
        u32 head, tail;
 
        if (!sig_read_header(channel, queue, &sig_hdr))
                return 0;
-       head = sig_hdr.Head;
-       tail = sig_hdr.Tail;
+       head = sig_hdr.head;
+       tail = sig_hdr.tail;
        if (head < tail)
-               head = head + sig_hdr.MaxSignalSlots;
+               head = head + sig_hdr.max_slots;
        slots_used = (head - tail);
-       slots_avail = sig_hdr.MaxSignals - slots_used;
+       slots_avail = sig_hdr.max_signals - slots_used;
        return (int) slots_avail;
 }
 EXPORT_SYMBOL_GPL(visorchannel_signalqueue_slots_avail);
@@ -520,36 +527,36 @@ EXPORT_SYMBOL_GPL(visorchannel_signalqueue_slots_avail);
 int
 visorchannel_signalqueue_max_slots(VISORCHANNEL *channel, u32 queue)
 {
-       SIGNAL_QUEUE_HEADER sig_hdr;
+       struct signal_queue_header sig_hdr;
 
        if (!sig_read_header(channel, queue, &sig_hdr))
                return 0;
-       return (int) sig_hdr.MaxSignals;
+       return (int) sig_hdr.max_signals;
 }
 EXPORT_SYMBOL_GPL(visorchannel_signalqueue_max_slots);
 
 static void
-sigqueue_debug(SIGNAL_QUEUE_HEADER *q, int which, struct seq_file *seq)
+sigqueue_debug(struct signal_queue_header *q, int which, struct seq_file *seq)
 {
        seq_printf(seq, "Signal Queue #%d\n", which);
-       seq_printf(seq, "   VersionId          = %lu\n", (ulong) q->VersionId);
-       seq_printf(seq, "   Type               = %lu\n", (ulong) q->Type);
+       seq_printf(seq, "   VersionId          = %lu\n", (ulong)q->version);
+       seq_printf(seq, "   Type               = %lu\n", (ulong)q->chtype);
        seq_printf(seq, "   oSignalBase        = %llu\n",
-                  (long long) q->oSignalBase);
-       seq_printf(seq, "   SignalSize         = %lu\n", (ulong) q->SignalSize);
+                  (long long)q->sig_base_offset);
+       seq_printf(seq, "   SignalSize         = %lu\n", (ulong)q->signal_size);
        seq_printf(seq, "   MaxSignalSlots     = %lu\n",
-                  (ulong) q->MaxSignalSlots);
-       seq_printf(seq, "   MaxSignals         = %lu\n", (ulong) q->MaxSignals);
+                  (ulong)q->max_slots);
+       seq_printf(seq, "   MaxSignals         = %lu\n", (ulong)q->max_signals);
        seq_printf(seq, "   FeatureFlags       = %-16.16Lx\n",
-                  (long long) q->FeatureFlags);
+                  (long long)q->features);
        seq_printf(seq, "   NumSignalsSent     = %llu\n",
-                  (long long) q->NumSignalsSent);
+                  (long long)q->num_sent);
        seq_printf(seq, "   NumSignalsReceived = %llu\n",
-                  (long long) q->NumSignalsReceived);
+                  (long long)q->num_received);
        seq_printf(seq, "   NumOverflows       = %llu\n",
-                  (long long) q->NumOverflows);
-       seq_printf(seq, "   Head               = %lu\n", (ulong) q->Head);
-       seq_printf(seq, "   Tail               = %lu\n", (ulong) q->Tail);
+                  (long long)q->num_overflows);
+       seq_printf(seq, "   Head               = %lu\n", (ulong)q->head);
+       seq_printf(seq, "   Tail               = %lu\n", (ulong)q->tail);
 }
 
 void
@@ -559,8 +566,8 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues,
        HOSTADDRESS addr = 0;
        ulong nbytes = 0, nbytes_region = 0;
        MEMREGION *memregion = NULL;
-       CHANNEL_HEADER hdr;
-       CHANNEL_HEADER *phdr = &hdr;
+       struct channel_header hdr;
+       struct channel_header *phdr = &hdr;
        int i = 0;
        int errcode = 0;
 
@@ -576,7 +583,7 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues,
        addr = visor_memregion_get_physaddr(memregion);
        nbytes_region = visor_memregion_get_nbytes(memregion);
        errcode = visorchannel_read(channel, off,
-                                   phdr, sizeof(CHANNEL_HEADER));
+                                   phdr, sizeof(struct channel_header));
        if (errcode < 0) {
                seq_printf(seq,
                           "Read of channel header failed with errcode=%d)\n",
@@ -587,38 +594,38 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues,
                } else
                        return;
        }
-       nbytes = (ulong) (phdr->Size);
+       nbytes = (ulong) (phdr->size);
        seq_printf(seq, "--- Begin channel @0x%-16.16Lx for 0x%lx bytes (region=0x%lx bytes) ---\n",
                   addr + off, nbytes, nbytes_region);
-       seq_printf(seq, "Type            = %pUL\n", &phdr->Type);
-       seq_printf(seq, "ZoneGuid        = %pUL\n", &phdr->ZoneGuid);
+       seq_printf(seq, "Type            = %pUL\n", &phdr->chtype);
+       seq_printf(seq, "ZoneGuid        = %pUL\n", &phdr->zone_uuid);
        seq_printf(seq, "Signature       = 0x%-16.16Lx\n",
-                  (long long) phdr->Signature);
-       seq_printf(seq, "LegacyState     = %lu\n", (ulong) phdr->LegacyState);
-       seq_printf(seq, "SrvState        = %lu\n", (ulong) phdr->SrvState);
-       seq_printf(seq, "CliStateBoot    = %lu\n", (ulong) phdr->CliStateBoot);
-       seq_printf(seq, "CliStateOS      = %lu\n", (ulong) phdr->CliStateOS);
-       seq_printf(seq, "HeaderSize      = %lu\n", (ulong) phdr->HeaderSize);
-       seq_printf(seq, "Size            = %llu\n", (long long) phdr->Size);
+                  (long long) phdr->signature);
+       seq_printf(seq, "LegacyState     = %lu\n", (ulong)phdr->legacy_state);
+       seq_printf(seq, "SrvState        = %lu\n", (ulong)phdr->srv_state);
+       seq_printf(seq, "CliStateBoot    = %lu\n", (ulong)phdr->cli_state_boot);
+       seq_printf(seq, "CliStateOS      = %lu\n", (ulong)phdr->cli_state_os);
+       seq_printf(seq, "HeaderSize      = %lu\n", (ulong)phdr->header_size);
+       seq_printf(seq, "Size            = %llu\n", (long long)phdr->size);
        seq_printf(seq, "Features        = 0x%-16.16llx\n",
-                  (long long) phdr->Features);
+                  (long long) phdr->features);
        seq_printf(seq, "PartitionHandle = 0x%-16.16llx\n",
-                  (long long) phdr->PartitionHandle);
+                  (long long) phdr->partition_handle);
        seq_printf(seq, "Handle          = 0x%-16.16llx\n",
-                  (long long) phdr->Handle);
-       seq_printf(seq, "VersionId       = %lu\n", (ulong) phdr->VersionId);
+                  (long long) phdr->handle);
+       seq_printf(seq, "VersionId       = %lu\n", (ulong) phdr->version_id);
        seq_printf(seq, "oChannelSpace   = %llu\n",
-                  (long long) phdr->oChannelSpace);
-       if ((phdr->oChannelSpace == 0) || (errcode < 0))
+                  (long long) phdr->ch_space_offset);
+       if ((phdr->ch_space_offset == 0) || (errcode < 0))
                ;
        else
                for (i = 0; i < nQueues; i++) {
-                       SIGNAL_QUEUE_HEADER q;
+                       struct signal_queue_header q;
 
                        errcode = visorchannel_read(channel,
-                                                   off + phdr->oChannelSpace +
-                                                   (i * sizeof(q)),
-                                                   &q, sizeof(q));
+                                       off + phdr->ch_space_offset +
+                                               (i * sizeof(q)),
+                                       &q, sizeof(q));
                        if (errcode < 0) {
                                seq_printf(seq,
                                           "failed to read signal queue #%d from channel @0x%-16.16Lx errcode=%d\n",
@@ -643,15 +650,17 @@ visorchannel_dump_section(VISORCHANNEL *chan, char *s,
 
        fmtbufsize = 100 * COVQ(len, 16);
        buf = kmalloc(len, GFP_KERNEL|__GFP_NORETRY);
+       if (!buf)
+               return;
        fmtbuf = kmalloc(fmtbufsize, GFP_KERNEL|__GFP_NORETRY);
-       if (buf == NULL || fmtbuf == NULL)
-               goto Away;
+       if (!fmtbuf)
+               goto fmt_failed;
 
        errcode = visorchannel_read(chan, off, buf, len);
        if (errcode < 0) {
                ERRDRV("%s failed to read %s from channel errcode=%d",
                       s, __func__, errcode);
-               goto Away;
+               goto read_failed;
        }
        seq_printf(seq, "channel %s:\n", s);
        tbuf = buf;
@@ -663,14 +672,9 @@ visorchannel_dump_section(VISORCHANNEL *chan, char *s,
                len -= 16;
        }
 
-Away:
-       if (buf != NULL) {
-               kfree(buf);
-               buf = NULL;
-       }
-       if (fmtbuf != NULL) {
-               kfree(fmtbuf);
-               fmtbuf = NULL;
-       }
+read_failed:
+       kfree(fmtbuf);
+fmt_failed:
+       kfree(buf);
 }
 EXPORT_SYMBOL_GPL(visorchannel_dump_section);
index 3321764..373fa36 100644 (file)
@@ -155,9 +155,9 @@ visorchipset_mmap(struct file *file, struct vm_area_struct *vma)
                        return -ENXIO;
                }
                visorchannel_read(*PControlVm_channel,
-                                 offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-                                          gpControlChannel), &addr,
-                                 sizeof(addr));
+                       offsetof(struct spar_controlvm_channel_protocol,
+                                gp_control_channel),
+                       &addr, sizeof(addr));
                if (addr == 0) {
                        ERRDRV("%s control channel address is 0", __func__);
                        return -ENXIO;
index 661aaae..6c2eac0 100644 (file)
@@ -48,7 +48,7 @@ parser_init_guts(u64 addr, u32 bytes, BOOL isLocal,
        PARSER_CONTEXT *rc = NULL;
        PARSER_CONTEXT *ctx = NULL;
        MEMREGION *rgn = NULL;
-       ULTRA_CONTROLVM_PARAMETERS_HEADER *phdr = NULL;
+       struct spar_controlvm_parameters_header *phdr = NULL;
 
        if (tryAgain)
                *tryAgain = FALSE;
@@ -110,27 +110,29 @@ parser_init_guts(u64 addr, u32 bytes, BOOL isLocal,
                rc = ctx;
                goto Away;
        }
-       phdr = (ULTRA_CONTROLVM_PARAMETERS_HEADER *) (ctx->data);
-       if (phdr->TotalLength != bytes) {
+       phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
+       if (phdr->total_length != bytes) {
                ERRDRV("%s - bad total length %lu (should be %lu)",
                       __func__,
-                      (ulong) (phdr->TotalLength), (ulong) (bytes));
+                      (ulong) (phdr->total_length), (ulong) (bytes));
                rc = NULL;
                goto Away;
        }
-       if (phdr->TotalLength < phdr->HeaderLength) {
+       if (phdr->total_length < phdr->header_length) {
                ERRDRV("%s - total length < header length (%lu < %lu)",
                       __func__,
-                      (ulong) (phdr->TotalLength),
-                      (ulong) (phdr->HeaderLength));
+                      (ulong) (phdr->total_length),
+                      (ulong) (phdr->header_length));
                rc = NULL;
                goto Away;
        }
-       if (phdr->HeaderLength < sizeof(ULTRA_CONTROLVM_PARAMETERS_HEADER)) {
+       if (phdr->header_length <
+           sizeof(struct spar_controlvm_parameters_header)) {
                ERRDRV("%s - header is too small (%lu < %lu)",
                       __func__,
-                      (ulong) (phdr->HeaderLength),
-                      (ulong) (sizeof(ULTRA_CONTROLVM_PARAMETERS_HEADER)));
+                      (ulong) (phdr->header_length),
+                      (ulong)(sizeof(
+                               struct spar_controlvm_parameters_header)));
                rc = NULL;
                goto Away;
        }
@@ -159,7 +161,7 @@ parser_init(u64 addr, u32 bytes, BOOL isLocal, BOOL *tryAgain)
 }
 
 /* Call this instead of parser_init() if the payload area consists of just
- * a sequence of bytes, rather than a ULTRA_CONTROLVM_PARAMETERS_HEADER
+ * a sequence of bytes, rather than a struct spar_controlvm_parameters_header
  * structures.  Afterwards, you can call parser_simpleString_get() or
  * parser_byteStream_get() to obtain the data.
  */
@@ -196,44 +198,44 @@ parser_byteStream_get(PARSER_CONTEXT *ctx, ulong *nbytes)
 uuid_le
 parser_id_get(PARSER_CONTEXT *ctx)
 {
-       ULTRA_CONTROLVM_PARAMETERS_HEADER *phdr = NULL;
+       struct spar_controlvm_parameters_header *phdr = NULL;
 
        if (ctx == NULL) {
                ERRDRV("%s (%s:%d) - no context",
                       __func__, __FILE__, __LINE__);
                return NULL_UUID_LE;
        }
-       phdr = (ULTRA_CONTROLVM_PARAMETERS_HEADER *) (ctx->data);
-       return phdr->Id;
+       phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
+       return phdr->id;
 }
 
 void
 parser_param_start(PARSER_CONTEXT *ctx, PARSER_WHICH_STRING which_string)
 {
-       ULTRA_CONTROLVM_PARAMETERS_HEADER *phdr = NULL;
+       struct spar_controlvm_parameters_header *phdr = NULL;
 
        if (ctx == NULL) {
                ERRDRV("%s (%s:%d) - no context",
                       __func__, __FILE__, __LINE__);
                goto Away;
        }
-       phdr = (ULTRA_CONTROLVM_PARAMETERS_HEADER *) (ctx->data);
+       phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
        switch (which_string) {
        case PARSERSTRING_INITIATOR:
-               ctx->curr = ctx->data + phdr->InitiatorOffset;
-               ctx->bytes_remaining = phdr->InitiatorLength;
+               ctx->curr = ctx->data + phdr->initiator_offset;
+               ctx->bytes_remaining = phdr->initiator_length;
                break;
        case PARSERSTRING_TARGET:
-               ctx->curr = ctx->data + phdr->TargetOffset;
-               ctx->bytes_remaining = phdr->TargetLength;
+               ctx->curr = ctx->data + phdr->target_offset;
+               ctx->bytes_remaining = phdr->target_length;
                break;
        case PARSERSTRING_CONNECTION:
-               ctx->curr = ctx->data + phdr->ConnectionOffset;
-               ctx->bytes_remaining = phdr->ConnectionLength;
+               ctx->curr = ctx->data + phdr->connection_offset;
+               ctx->bytes_remaining = phdr->connection_length;
                break;
        case PARSERSTRING_NAME:
-               ctx->curr = ctx->data + phdr->NameOffset;
-               ctx->bytes_remaining = phdr->NameLength;
+               ctx->curr = ctx->data + phdr->name_offset;
+               ctx->bytes_remaining = phdr->name_length;
                break;
        default:
                ERRDRV("%s - bad which_string %d", __func__, which_string);
index 015d502..573aa8b 100644 (file)
@@ -23,8 +23,9 @@
 #include "globals.h"
 #include "controlvmchannel.h"
 
-void test_produce_test_message(CONTROLVM_MESSAGE *msg, int isLocalTestAddr);
-BOOL test_consume_test_message(CONTROLVM_MESSAGE *msg);
+void test_produce_test_message(struct controlvm_message *msg,
+                              int isLocalTestAddr);
+BOOL test_consume_test_message(struct controlvm_message *msg);
 void test_manufacture_vnic_client_add(void *p);
 void test_manufacture_vnic_client_add_phys(HOSTADDRESS addr);
 void test_manufacture_preamble_messages(void);
index 2bf2e2f..feae368 100644 (file)
@@ -63,7 +63,7 @@ typedef enum {
 typedef struct {
        VISORCHIPSET_ADDRESSTYPE addrType;
        HOSTADDRESS channelAddr;
-       struct InterruptInfo intr;
+       struct irq_info intr;
        u64 nChannelBytes;
        uuid_le channelTypeGuid;
        uuid_le channelInstGuid;
@@ -82,11 +82,11 @@ typedef struct {
        uuid_le devInstGuid;
        VISORCHIPSET_STATE state;
        VISORCHIPSET_CHANNEL_INFO chanInfo;
-       u32 Reserved1;          /* CONTROLVM_ID */
+       u32 Reserved1;          /* control_vm_id */
        u64 Reserved2;
        u32 switchNo;           /* when devState.attached==1 */
        u32 internalPortNo;     /* when devState.attached==1 */
-       CONTROLVM_MESSAGE_HEADER pendingMsgHdr; /* CONTROLVM_MESSAGE */
+       struct controlvm_message_header pendingMsgHdr;  /* CONTROLVM_MESSAGE */
        /** For private use by the bus driver */
        void *bus_driver_context;
 
@@ -139,7 +139,7 @@ typedef struct {
                /* Add new fields above. */
                /* Remaining bits in this 32-bit word are unused. */
        } flags;
-       CONTROLVM_MESSAGE_HEADER pendingMsgHdr; /* CONTROLVM MsgHdr */
+       struct controlvm_message_header pendingMsgHdr;  /* CONTROLVM MsgHdr */
        /** For private use by the bus driver */
        void *bus_driver_context;
        u64 devNo;
@@ -169,10 +169,10 @@ typedef struct {
        u8 *authService3;
        u8 *securityContext;
        u64 Reserved;
-       u32 Reserved2;          /* CONTROLVM_ID */
+       u32 Reserved2;          /* control_vm_id */
        struct device dev;
        BOOL dev_exists;
-       CONTROLVM_MESSAGE_HEADER pendingMsgHdr;
+       struct controlvm_message_header pendingMsgHdr;
 
 } VISORCHIPSET_SWITCH_INFO;
 
@@ -192,10 +192,10 @@ typedef struct {
        u8 *ipGateway;
        u8 *ipDNS;
        u64 Reserved1;
-       u32 Reserved2;          /* CONTROLVM_ID */
+       u32 Reserved2;          /* control_vm_id */
        struct device dev;
        BOOL dev_exists;
-       CONTROLVM_MESSAGE_HEADER pendingMsgHdr;
+       struct controlvm_message_header pendingMsgHdr;
 
 } VISORCHIPSET_EXTERNALPORT_INFO;
 
@@ -210,7 +210,7 @@ typedef struct {
        u32 devNo;              /* valid only when state.attached == 1 */
        u64 Reserved1;
        u32 Reserved2;          /* CONTROLVM_ID */
-       CONTROLVM_MESSAGE_HEADER pendingMsgHdr;
+       struct controlvm_message_header pendingMsgHdr;
        MYPROCOBJECT *procObject;
 
 } VISORCHIPSET_INTERNALPORT_INFO;
@@ -254,7 +254,7 @@ typedef struct {
 void
 visorchipset_register_busdev_client(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers,
                                    VISORCHIPSET_BUSDEV_RESPONDERS *responders,
-                                   ULTRA_VBUS_DEVICEINFO *driverInfo);
+                                   struct ultra_vbus_deviceinfo *driverInfo);
 
 /** Register functions (in the bus driver) to get called by visorchipset
  *  whenever a bus or device appears for which this service partition is
@@ -265,9 +265,9 @@ visorchipset_register_busdev_client(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers,
 void
 visorchipset_register_busdev_server(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers,
                                    VISORCHIPSET_BUSDEV_RESPONDERS *responders,
-                                   ULTRA_VBUS_DEVICEINFO *driverInfo);
+                                   struct ultra_vbus_deviceinfo *driverInfo);
 
-typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (CONTROLVM_MESSAGE *msg,
+typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (struct controlvm_message *msg,
                                               int status);
 
 void visorchipset_device_pause_response(ulong busNo, ulong devNo, int response);
@@ -285,9 +285,10 @@ BOOL visorchipset_set_device_context(ulong busNo, ulong devNo, void *context);
 int visorchipset_chipset_ready(void);
 int visorchipset_chipset_selftest(void);
 int visorchipset_chipset_notready(void);
-void visorchipset_controlvm_respond_reportEvent(CONTROLVM_MESSAGE *msg,
+void visorchipset_controlvm_respond_reportEvent(struct controlvm_message *msg,
                                                void *payload);
-void visorchipset_save_message(CONTROLVM_MESSAGE *msg, CRASH_OBJ_TYPE type);
+void visorchipset_save_message(struct controlvm_message *msg,
+                              CRASH_OBJ_TYPE type);
 void *visorchipset_cache_alloc(struct kmem_cache *pool,
                               BOOL ok_to_block, char *fn, int ln);
 void visorchipset_cache_free(struct kmem_cache *pool, void *p,
index e5df395..392e046 100644 (file)
@@ -72,26 +72,28 @@ static struct workqueue_struct *Periodic_controlvm_workqueue;
 static DEFINE_SEMAPHORE(NotifierLock);
 
 typedef struct {
-       CONTROLVM_MESSAGE message;
+       struct controlvm_message message;
        unsigned int crc;
 } MESSAGE_ENVELOPE;
 
-static CONTROLVM_MESSAGE_HEADER g_DiagMsgHdr;
-static CONTROLVM_MESSAGE_HEADER g_ChipSetMsgHdr;
-static CONTROLVM_MESSAGE_HEADER g_DelDumpMsgHdr;
+static struct controlvm_message_header g_DiagMsgHdr;
+static struct controlvm_message_header g_ChipSetMsgHdr;
+static struct controlvm_message_header g_DelDumpMsgHdr;
 static const uuid_le UltraDiagPoolChannelProtocolGuid =
-       ULTRA_DIAG_POOL_CHANNEL_PROTOCOL_GUID;
+       SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID;
 /* 0xffffff is an invalid Bus/Device number */
 static ulong g_diagpoolBusNo = 0xffffff;
 static ulong g_diagpoolDevNo = 0xffffff;
-static CONTROLVM_MESSAGE_PACKET g_DeviceChangeStatePacket;
+static struct controlvm_message_packet g_DeviceChangeStatePacket;
 
 /* Only VNIC and VHBA channels are sent to visorclientbus (aka
  * "visorhackbus")
  */
 #define FOR_VISORHACKBUS(channel_type_guid) \
-       (((uuid_le_cmp(channel_type_guid, UltraVnicChannelProtocolGuid) == 0)\
-       || (uuid_le_cmp(channel_type_guid, UltraVhbaChannelProtocolGuid) == 0)))
+       (((uuid_le_cmp(channel_type_guid,\
+                      spar_vnic_channel_protocol_uuid) == 0)\
+       || (uuid_le_cmp(channel_type_guid,\
+                       spar_vhba_channel_protocol_uuid) == 0)))
 #define FOR_VISORBUS(channel_type_guid) (!(FOR_VISORHACKBUS(channel_type_guid)))
 
 #define is_diagpool_channel(channel_type_guid) \
@@ -112,12 +114,12 @@ typedef struct {
 /* Manages the request payload in the controlvm channel */
 static CONTROLVM_PAYLOAD_INFO ControlVm_payload_info;
 
-static pCHANNEL_HEADER Test_Vnic_channel;
+static struct channel_header *Test_Vnic_channel;
 
 typedef struct {
-       CONTROLVM_MESSAGE_HEADER Dumpcapture_header;
-       CONTROLVM_MESSAGE_HEADER Gettextdump_header;
-       CONTROLVM_MESSAGE_HEADER Dumpcomplete_header;
+       struct controlvm_message_header Dumpcapture_header;
+       struct controlvm_message_header Gettextdump_header;
+       struct controlvm_message_header Dumpcomplete_header;
        BOOL Gettextdump_outstanding;
        u32 crc32;
        ulong length;
@@ -134,7 +136,7 @@ static LIVEDUMP_INFO LiveDump_info;
  * this scenario, we simply stash the controlvm message, then attempt to
  * process it again the next time controlvm_periodic_work() runs.
  */
-static CONTROLVM_MESSAGE ControlVm_Pending_Msg;
+static struct controlvm_message ControlVm_Pending_Msg;
 static BOOL ControlVm_Pending_Msg_Valid = FALSE;
 
 /* Pool of struct putfile_buffer_entry, for keeping track of pending (incoming)
@@ -180,7 +182,7 @@ struct putfile_request {
        u64 sig;                /* PUTFILE_REQUEST_SIG */
 
        /* header from original TransmitFile request */
-       CONTROLVM_MESSAGE_HEADER controlvm_header;
+       struct controlvm_message_header controlvm_header;
        u64 file_request_number;        /* from original TransmitFile request */
 
        /* link to next struct putfile_request */
@@ -218,7 +220,7 @@ struct parahotplug_request {
        struct list_head list;
        int id;
        unsigned long expiration;
-       CONTROLVM_MESSAGE msg;
+       struct controlvm_message msg;
 };
 
 static LIST_HEAD(Parahotplug_request_list);
@@ -342,13 +344,14 @@ static struct platform_device Visorchipset_platform_device = {
 };
 
 /* Function prototypes */
-static void controlvm_respond(CONTROLVM_MESSAGE_HEADER *msgHdr, int response);
-static void controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER *msgHdr,
-                                          int response,
-                                          ULTRA_CHIPSET_FEATURE features);
-static void controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER *
-                                                 msgHdr, int response,
-                                                 ULTRA_SEGMENT_STATE state);
+static void controlvm_respond(struct controlvm_message_header *msgHdr,
+                             int response);
+static void controlvm_respond_chipset_init(
+               struct controlvm_message_header *msgHdr, int response,
+               enum ultra_chipset_feature features);
+static void controlvm_respond_physdev_changestate(
+               struct controlvm_message_header *msgHdr, int response,
+               struct spar_segment_state state);
 
 static ssize_t toolaction_show(struct device *dev,
                               struct device_attribute *attr,
@@ -357,8 +360,8 @@ static ssize_t toolaction_show(struct device *dev,
        u8 toolAction;
 
        visorchannel_read(ControlVm_channel,
-               offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-                          ToolAction), &toolAction, sizeof(u8));
+               offsetof(struct spar_controlvm_channel_protocol,
+                          tool_action), &toolAction, sizeof(u8));
        return scnprintf(buf, PAGE_SIZE, "%u\n", toolAction);
 }
 
@@ -373,7 +376,7 @@ static ssize_t toolaction_store(struct device *dev,
                return -EINVAL;
 
        ret = visorchannel_write(ControlVm_channel,
-               offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, ToolAction),
+               offsetof(struct spar_controlvm_channel_protocol, tool_action),
                &toolAction, sizeof(u8));
 
        if (ret)
@@ -385,14 +388,14 @@ static ssize_t boottotool_show(struct device *dev,
                               struct device_attribute *attr,
                               char *buf)
 {
-       ULTRA_EFI_SPAR_INDICATION efiSparIndication;
+       struct efi_spar_indication efiSparIndication;
 
        visorchannel_read(ControlVm_channel,
-               offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-                       EfiSparIndication), &efiSparIndication,
-               sizeof(ULTRA_EFI_SPAR_INDICATION));
+               offsetof(struct spar_controlvm_channel_protocol,
+                       efi_spar_ind), &efiSparIndication,
+               sizeof(struct efi_spar_indication));
        return scnprintf(buf, PAGE_SIZE, "%u\n",
-                       efiSparIndication.BootToTool);
+                       efiSparIndication.boot_to_tool);
 }
 
 static ssize_t boottotool_store(struct device *dev,
@@ -400,17 +403,17 @@ static ssize_t boottotool_store(struct device *dev,
                                const char *buf, size_t count)
 {
        int val, ret;
-       ULTRA_EFI_SPAR_INDICATION efiSparIndication;
+       struct efi_spar_indication efiSparIndication;
 
        if (kstrtoint(buf, 10, &val) != 0)
                return -EINVAL;
 
-       efiSparIndication.BootToTool = val;
+       efiSparIndication.boot_to_tool = val;
        ret = visorchannel_write(ControlVm_channel,
-                       offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-                               EfiSparIndication),
+                       offsetof(struct spar_controlvm_channel_protocol,
+                               efi_spar_ind),
                        &(efiSparIndication),
-               sizeof(ULTRA_EFI_SPAR_INDICATION));
+               sizeof(struct efi_spar_indication));
 
        if (ret)
                return ret;
@@ -423,7 +426,7 @@ static ssize_t error_show(struct device *dev, struct device_attribute *attr,
        u32 error;
 
        visorchannel_read(ControlVm_channel, offsetof(
-               ULTRA_CONTROLVM_CHANNEL_PROTOCOL, InstallationError),
+               struct spar_controlvm_channel_protocol, installation_error),
                &error, sizeof(u32));
        return scnprintf(buf, PAGE_SIZE, "%i\n", error);
 }
@@ -438,8 +441,8 @@ static ssize_t error_store(struct device *dev, struct device_attribute *attr,
                return -EINVAL;
 
        ret = visorchannel_write(ControlVm_channel,
-                       offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-                               InstallationError),
+                       offsetof(struct spar_controlvm_channel_protocol,
+                               installation_error),
                        &error, sizeof(u32));
        if (ret)
                return ret;
@@ -452,7 +455,7 @@ static ssize_t textid_show(struct device *dev, struct device_attribute *attr,
        u32 textId;
 
        visorchannel_read(ControlVm_channel, offsetof(
-               ULTRA_CONTROLVM_CHANNEL_PROTOCOL, InstallationTextId),
+               struct spar_controlvm_channel_protocol, installation_text_id),
                &textId, sizeof(u32));
        return scnprintf(buf, PAGE_SIZE, "%i\n", textId);
 }
@@ -467,8 +470,8 @@ static ssize_t textid_store(struct device *dev, struct device_attribute *attr,
                return -EINVAL;
 
        ret = visorchannel_write(ControlVm_channel,
-                       offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-                               InstallationTextId),
+                       offsetof(struct spar_controlvm_channel_protocol,
+                               installation_text_id),
                        &textId, sizeof(u32));
        if (ret)
                return ret;
@@ -482,8 +485,8 @@ static ssize_t remaining_steps_show(struct device *dev,
        u16 remainingSteps;
 
        visorchannel_read(ControlVm_channel,
-               offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-                       InstallationRemainingSteps),
+               offsetof(struct spar_controlvm_channel_protocol,
+                       installation_remaining_steps),
                &remainingSteps,
                sizeof(u16));
        return scnprintf(buf, PAGE_SIZE, "%hu\n", remainingSteps);
@@ -499,8 +502,8 @@ static ssize_t remaining_steps_store(struct device *dev,
                return -EINVAL;
 
        ret = visorchannel_write(ControlVm_channel,
-                       offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-                               InstallationRemainingSteps),
+                       offsetof(struct spar_controlvm_channel_protocol,
+                               installation_remaining_steps),
                        &remainingSteps, sizeof(u16));
        if (ret)
                return ret;
@@ -587,7 +590,7 @@ clear_chipset_events(void)
 void
 visorchipset_register_busdev_server(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers,
                                    VISORCHIPSET_BUSDEV_RESPONDERS *responders,
-                                   ULTRA_VBUS_DEVICEINFO *driverInfo)
+                                   struct ultra_vbus_deviceinfo *driverInfo)
 {
        down(&NotifierLock);
        if (notifiers == NULL) {
@@ -611,7 +614,7 @@ EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server);
 void
 visorchipset_register_busdev_client(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers,
                                    VISORCHIPSET_BUSDEV_RESPONDERS *responders,
-                                   ULTRA_VBUS_DEVICEINFO *driverInfo)
+                                   struct ultra_vbus_deviceinfo *driverInfo)
 {
        down(&NotifierLock);
        if (notifiers == NULL) {
@@ -651,10 +654,10 @@ cleanup_controlvm_structures(void)
 }
 
 static void
-chipset_init(CONTROLVM_MESSAGE *inmsg)
+chipset_init(struct controlvm_message *inmsg)
 {
        static int chipset_inited;
-       ULTRA_CHIPSET_FEATURE features = 0;
+       enum ultra_chipset_feature features = 0;
        int rc = CONTROLVM_RESP_SUCCESS;
 
        POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC, POSTCODE_SEVERITY_INFO);
@@ -669,7 +672,7 @@ chipset_init(CONTROLVM_MESSAGE *inmsg)
        /* Set features to indicate we support parahotplug (if Command
         * also supports it). */
        features =
-           inmsg->cmd.initChipset.
+           inmsg->cmd.init_chipset.
            features & ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG;
 
        /* Set the "reply" bit so Command knows this is a
@@ -679,42 +682,42 @@ chipset_init(CONTROLVM_MESSAGE *inmsg)
 Away:
        if (rc < 0)
                cleanup_controlvm_structures();
-       if (inmsg->hdr.Flags.responseExpected)
+       if (inmsg->hdr.flags.response_expected)
                controlvm_respond_chipset_init(&inmsg->hdr, rc, features);
 }
 
 static void
-controlvm_init_response(CONTROLVM_MESSAGE *msg,
-                       CONTROLVM_MESSAGE_HEADER *msgHdr, int response)
-{
-       memset(msg, 0, sizeof(CONTROLVM_MESSAGE));
-       memcpy(&msg->hdr, msgHdr, sizeof(CONTROLVM_MESSAGE_HEADER));
-       msg->hdr.PayloadBytes = 0;
-       msg->hdr.PayloadVmOffset = 0;
-       msg->hdr.PayloadMaxBytes = 0;
+controlvm_init_response(struct controlvm_message *msg,
+                       struct controlvm_message_header *msgHdr, int response)
+{
+       memset(msg, 0, sizeof(struct controlvm_message));
+       memcpy(&msg->hdr, msgHdr, sizeof(struct controlvm_message_header));
+       msg->hdr.payload_bytes = 0;
+       msg->hdr.payload_vm_offset = 0;
+       msg->hdr.payload_max_bytes = 0;
        if (response < 0) {
-               msg->hdr.Flags.failed = 1;
-               msg->hdr.CompletionStatus = (u32) (-response);
+               msg->hdr.flags.failed = 1;
+               msg->hdr.completion_status = (u32) (-response);
        }
 }
 
 static void
-controlvm_respond(CONTROLVM_MESSAGE_HEADER *msgHdr, int response)
+controlvm_respond(struct controlvm_message_header *msgHdr, int response)
 {
-       CONTROLVM_MESSAGE outmsg;
+       struct controlvm_message outmsg;
 
        controlvm_init_response(&outmsg, msgHdr, response);
        /* For DiagPool channel DEVICE_CHANGESTATE, we need to send
        * back the deviceChangeState structure in the packet. */
-       if (msgHdr->Id == CONTROLVM_DEVICE_CHANGESTATE
-           && g_DeviceChangeStatePacket.deviceChangeState.busNo ==
+       if (msgHdr->id == CONTROLVM_DEVICE_CHANGESTATE
+           && g_DeviceChangeStatePacket.device_change_state.bus_no ==
            g_diagpoolBusNo
-           && g_DeviceChangeStatePacket.deviceChangeState.devNo ==
+           && g_DeviceChangeStatePacket.device_change_state.dev_no ==
            g_diagpoolDevNo)
                outmsg.cmd = g_DeviceChangeStatePacket;
-       if (outmsg.hdr.Flags.testMessage == 1) {
+       if (outmsg.hdr.flags.test_message == 1) {
                LOGINF("%s controlvm_msg=0x%x response=%d for test message",
-                      __func__, outmsg.hdr.Id, response);
+                      __func__, outmsg.hdr.id, response);
                return;
        }
        if (!visorchannel_signalinsert(ControlVm_channel,
@@ -725,13 +728,14 @@ controlvm_respond(CONTROLVM_MESSAGE_HEADER *msgHdr, int response)
 }
 
 static void
-controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER *msgHdr, int response,
-                              ULTRA_CHIPSET_FEATURE features)
+controlvm_respond_chipset_init(struct controlvm_message_header *msgHdr,
+                              int response,
+                              enum ultra_chipset_feature features)
 {
-       CONTROLVM_MESSAGE outmsg;
+       struct controlvm_message outmsg;
 
        controlvm_init_response(&outmsg, msgHdr, response);
-       outmsg.cmd.initChipset.features = features;
+       outmsg.cmd.init_chipset.features = features;
        if (!visorchannel_signalinsert(ControlVm_channel,
                                       CONTROLVM_QUEUE_REQUEST, &outmsg)) {
                LOGERR("signalinsert failed!");
@@ -739,15 +743,15 @@ controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER *msgHdr, int response,
        }
 }
 
-static void
-controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER *msgHdr,
-                                     int response, ULTRA_SEGMENT_STATE state)
+static void controlvm_respond_physdev_changestate(
+               struct controlvm_message_header *msgHdr, int response,
+               struct spar_segment_state state)
 {
-       CONTROLVM_MESSAGE outmsg;
+       struct controlvm_message outmsg;
 
        controlvm_init_response(&outmsg, msgHdr, response);
-       outmsg.cmd.deviceChangeState.state = state;
-       outmsg.cmd.deviceChangeState.flags.physicalDevice = 1;
+       outmsg.cmd.device_change_state.state = state;
+       outmsg.cmd.device_change_state.flags.phys_device = 1;
        if (!visorchannel_signalinsert(ControlVm_channel,
                                       CONTROLVM_QUEUE_REQUEST, &outmsg)) {
                LOGERR("signalinsert failed!");
@@ -756,15 +760,15 @@ controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER *msgHdr,
 }
 
 void
-visorchipset_save_message(CONTROLVM_MESSAGE *msg, CRASH_OBJ_TYPE type)
+visorchipset_save_message(struct controlvm_message *msg, CRASH_OBJ_TYPE type)
 {
        u32 localSavedCrashMsgOffset;
        u16 localSavedCrashMsgCount;
 
        /* get saved message count */
        if (visorchannel_read(ControlVm_channel,
-                             offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-                                      SavedCrashMsgCount),
+                             offsetof(struct spar_controlvm_channel_protocol,
+                                      saved_crash_message_count),
                              &localSavedCrashMsgCount, sizeof(u16)) < 0) {
                LOGERR("failed to get Saved Message Count");
                POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
@@ -783,8 +787,8 @@ visorchipset_save_message(CONTROLVM_MESSAGE *msg, CRASH_OBJ_TYPE type)
 
        /* get saved crash message offset */
        if (visorchannel_read(ControlVm_channel,
-                             offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-                                      SavedCrashMsgOffset),
+                             offsetof(struct spar_controlvm_channel_protocol,
+                                      saved_crash_message_offset),
                              &localSavedCrashMsgOffset, sizeof(u32)) < 0) {
                LOGERR("failed to get Saved Message Offset");
                POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
@@ -795,7 +799,8 @@ visorchipset_save_message(CONTROLVM_MESSAGE *msg, CRASH_OBJ_TYPE type)
        if (type == CRASH_bus) {
                if (visorchannel_write(ControlVm_channel,
                                       localSavedCrashMsgOffset,
-                                      msg, sizeof(CONTROLVM_MESSAGE)) < 0) {
+                                      msg,
+                                      sizeof(struct controlvm_message)) < 0) {
                        LOGERR("SAVE_MSG_BUS_FAILURE: Failed to write CrashCreateBusMsg!");
                        POSTCODE_LINUX_2(SAVE_MSG_BUS_FAILURE_PC,
                                         POSTCODE_SEVERITY_ERR);
@@ -804,8 +809,8 @@ visorchipset_save_message(CONTROLVM_MESSAGE *msg, CRASH_OBJ_TYPE type)
        } else {
                if (visorchannel_write(ControlVm_channel,
                                       localSavedCrashMsgOffset +
-                                      sizeof(CONTROLVM_MESSAGE), msg,
-                                      sizeof(CONTROLVM_MESSAGE)) < 0) {
+                                      sizeof(struct controlvm_message), msg,
+                                      sizeof(struct controlvm_message)) < 0) {
                        LOGERR("SAVE_MSG_DEV_FAILURE: Failed to write CrashCreateDevMsg!");
                        POSTCODE_LINUX_2(SAVE_MSG_DEV_FAILURE_PC,
                                         POSTCODE_SEVERITY_ERR);
@@ -816,7 +821,7 @@ visorchipset_save_message(CONTROLVM_MESSAGE *msg, CRASH_OBJ_TYPE type)
 EXPORT_SYMBOL_GPL(visorchipset_save_message);
 
 static void
-bus_responder(CONTROLVM_ID cmdId, ulong busNo, int response)
+bus_responder(enum controlvm_id cmdId, ulong busNo, int response)
 {
        VISORCHIPSET_BUS_INFO *p = NULL;
        BOOL need_clear = FALSE;
@@ -838,16 +843,16 @@ bus_responder(CONTROLVM_ID cmdId, ulong busNo, int response)
                        need_clear = TRUE;
        }
 
-       if (p->pendingMsgHdr.Id == CONTROLVM_INVALID) {
+       if (p->pendingMsgHdr.id == CONTROLVM_INVALID) {
                LOGERR("bus_responder no pending msg");
                return;         /* no controlvm response needed */
        }
-       if (p->pendingMsgHdr.Id != (u32) cmdId) {
-               LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.Id);
+       if (p->pendingMsgHdr.id != (u32) cmdId) {
+               LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.id);
                return;
        }
        controlvm_respond(&p->pendingMsgHdr, response);
-       p->pendingMsgHdr.Id = CONTROLVM_INVALID;
+       p->pendingMsgHdr.id = CONTROLVM_INVALID;
        if (need_clear) {
                busInfo_clear(p);
                delbusdevices(&DevInfoList, busNo);
@@ -855,32 +860,32 @@ bus_responder(CONTROLVM_ID cmdId, ulong busNo, int response)
 }
 
 static void
-device_changestate_responder(CONTROLVM_ID cmdId,
+device_changestate_responder(enum controlvm_id cmdId,
                             ulong busNo, ulong devNo, int response,
-                            ULTRA_SEGMENT_STATE responseState)
+                            struct spar_segment_state responseState)
 {
        VISORCHIPSET_DEVICE_INFO *p = NULL;
-       CONTROLVM_MESSAGE outmsg;
+       struct controlvm_message outmsg;
 
        p = finddevice(&DevInfoList, busNo, devNo);
        if (!p) {
                LOGERR("internal error; busNo=%lu, devNo=%lu", busNo, devNo);
                return;
        }
-       if (p->pendingMsgHdr.Id == CONTROLVM_INVALID) {
+       if (p->pendingMsgHdr.id == CONTROLVM_INVALID) {
                LOGERR("device_responder no pending msg");
                return;         /* no controlvm response needed */
        }
-       if (p->pendingMsgHdr.Id != cmdId) {
-               LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.Id);
+       if (p->pendingMsgHdr.id != cmdId) {
+               LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.id);
                return;
        }
 
        controlvm_init_response(&outmsg, &p->pendingMsgHdr, response);
 
-       outmsg.cmd.deviceChangeState.busNo = busNo;
-       outmsg.cmd.deviceChangeState.devNo = devNo;
-       outmsg.cmd.deviceChangeState.state = responseState;
+       outmsg.cmd.device_change_state.bus_no = busNo;
+       outmsg.cmd.device_change_state.dev_no = devNo;
+       outmsg.cmd.device_change_state.state = responseState;
 
        if (!visorchannel_signalinsert(ControlVm_channel,
                                       CONTROLVM_QUEUE_REQUEST, &outmsg)) {
@@ -888,11 +893,12 @@ device_changestate_responder(CONTROLVM_ID cmdId,
                return;
        }
 
-       p->pendingMsgHdr.Id = CONTROLVM_INVALID;
+       p->pendingMsgHdr.id = CONTROLVM_INVALID;
 }
 
 static void
-device_responder(CONTROLVM_ID cmdId, ulong busNo, ulong devNo, int response)
+device_responder(enum controlvm_id cmdId, ulong busNo, ulong devNo,
+                int response)
 {
        VISORCHIPSET_DEVICE_INFO *p = NULL;
        BOOL need_clear = FALSE;
@@ -909,23 +915,23 @@ device_responder(CONTROLVM_ID cmdId, ulong busNo, ulong devNo, int response)
                        need_clear = TRUE;
        }
 
-       if (p->pendingMsgHdr.Id == CONTROLVM_INVALID) {
+       if (p->pendingMsgHdr.id == CONTROLVM_INVALID) {
                LOGERR("device_responder no pending msg");
                return;         /* no controlvm response needed */
        }
-       if (p->pendingMsgHdr.Id != (u32) cmdId) {
-               LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.Id);
+       if (p->pendingMsgHdr.id != (u32) cmdId) {
+               LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.id);
                return;
        }
        controlvm_respond(&p->pendingMsgHdr, response);
-       p->pendingMsgHdr.Id = CONTROLVM_INVALID;
+       p->pendingMsgHdr.id = CONTROLVM_INVALID;
        if (need_clear)
                devInfo_clear(p);
 }
 
 static void
 bus_epilog(u32 busNo,
-          u32 cmd, CONTROLVM_MESSAGE_HEADER *msgHdr,
+          u32 cmd, struct controlvm_message_header *msgHdr,
           int response, BOOL needResponse)
 {
        BOOL notified = FALSE;
@@ -938,9 +944,9 @@ bus_epilog(u32 busNo,
        }
        if (needResponse) {
                memcpy(&pBusInfo->pendingMsgHdr, msgHdr,
-                      sizeof(CONTROLVM_MESSAGE_HEADER));
+                      sizeof(struct controlvm_message_header));
        } else
-               pBusInfo->pendingMsgHdr.Id = CONTROLVM_INVALID;
+               pBusInfo->pendingMsgHdr.id = CONTROLVM_INVALID;
 
        down(&NotifierLock);
        if (response == CONTROLVM_RESP_SUCCESS) {
@@ -991,8 +997,8 @@ bus_epilog(u32 busNo,
 }
 
 static void
-device_epilog(u32 busNo, u32 devNo, ULTRA_SEGMENT_STATE state, u32 cmd,
-             CONTROLVM_MESSAGE_HEADER *msgHdr, int response,
+device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd,
+             struct controlvm_message_header *msgHdr, int response,
              BOOL needResponse, BOOL for_visorbus)
 {
        VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers = NULL;
@@ -1015,9 +1021,9 @@ device_epilog(u32 busNo, u32 devNo, ULTRA_SEGMENT_STATE state, u32 cmd,
                notifiers = &BusDev_Client_Notifiers;
        if (needResponse) {
                memcpy(&pDevInfo->pendingMsgHdr, msgHdr,
-                      sizeof(CONTROLVM_MESSAGE_HEADER));
+                      sizeof(struct controlvm_message_header));
        } else
-               pDevInfo->pendingMsgHdr.Id = CONTROLVM_INVALID;
+               pDevInfo->pendingMsgHdr.id = CONTROLVM_INVALID;
 
        down(&NotifierLock);
        if (response >= 0) {
@@ -1030,8 +1036,9 @@ device_epilog(u32 busNo, u32 devNo, ULTRA_SEGMENT_STATE state, u32 cmd,
                        break;
                case CONTROLVM_DEVICE_CHANGESTATE:
                        /* ServerReady / ServerRunning / SegmentStateRunning */
-                       if (state.Alive == SegmentStateRunning.Alive &&
-                           state.Operating == SegmentStateRunning.Operating) {
+                       if (state.alive == segment_state_running.alive &&
+                           state.operating ==
+                               segment_state_running.operating) {
                                if (notifiers->device_resume) {
                                        (*notifiers->device_resume) (busNo,
                                                                     devNo);
@@ -1039,9 +1046,9 @@ device_epilog(u32 busNo, u32 devNo, ULTRA_SEGMENT_STATE state, u32 cmd,
                                }
                        }
                        /* ServerNotReady / ServerLost / SegmentStateStandby */
-                       else if (state.Alive == SegmentStateStandby.Alive &&
-                                state.Operating ==
-                                SegmentStateStandby.Operating) {
+                       else if (state.alive == segment_state_standby.alive &&
+                                state.operating ==
+                                segment_state_standby.operating) {
                                /* technically this is standby case
                                 * where server is lost
                                 */
@@ -1050,9 +1057,9 @@ device_epilog(u32 busNo, u32 devNo, ULTRA_SEGMENT_STATE state, u32 cmd,
                                                                    devNo);
                                        notified = TRUE;
                                }
-                       } else if (state.Alive == SegmentStatePaused.Alive &&
-                                  state.Operating ==
-                                  SegmentStatePaused.Operating) {
+                       } else if (state.alive == segment_state_paused.alive &&
+                                  state.operating ==
+                                  segment_state_paused.operating) {
                                /* this is lite pause where channel is
                                 * still valid just 'pause' of it
                                 */
@@ -1089,10 +1096,10 @@ device_epilog(u32 busNo, u32 devNo, ULTRA_SEGMENT_STATE state, u32 cmd,
 }
 
 static void
-bus_create(CONTROLVM_MESSAGE *inmsg)
+bus_create(struct controlvm_message *inmsg)
 {
-       CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd;
-       ulong busNo = cmd->createBus.busNo;
+       struct controlvm_message_packet *cmd = &inmsg->cmd;
+       ulong busNo = cmd->create_bus.bus_no;
        int rc = CONTROLVM_RESP_SUCCESS;
        VISORCHIPSET_BUS_INFO *pBusInfo = NULL;
 
@@ -1118,20 +1125,20 @@ bus_create(CONTROLVM_MESSAGE *inmsg)
 
        INIT_LIST_HEAD(&pBusInfo->entry);
        pBusInfo->busNo = busNo;
-       pBusInfo->devNo = cmd->createBus.deviceCount;
+       pBusInfo->devNo = cmd->create_bus.dev_count;
 
        POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, busNo, POSTCODE_SEVERITY_INFO);
 
-       if (inmsg->hdr.Flags.testMessage == 1)
+       if (inmsg->hdr.flags.test_message == 1)
                pBusInfo->chanInfo.addrType = ADDRTYPE_localTest;
        else
                pBusInfo->chanInfo.addrType = ADDRTYPE_localPhysical;
 
-       pBusInfo->flags.server = inmsg->hdr.Flags.server;
-       pBusInfo->chanInfo.channelAddr = cmd->createBus.channelAddr;
-       pBusInfo->chanInfo.nChannelBytes = cmd->createBus.channelBytes;
-       pBusInfo->chanInfo.channelTypeGuid = cmd->createBus.busDataTypeGuid;
-       pBusInfo->chanInfo.channelInstGuid = cmd->createBus.busInstGuid;
+       pBusInfo->flags.server = inmsg->hdr.flags.server;
+       pBusInfo->chanInfo.channelAddr = cmd->create_bus.channel_addr;
+       pBusInfo->chanInfo.nChannelBytes = cmd->create_bus.channel_bytes;
+       pBusInfo->chanInfo.channelTypeGuid = cmd->create_bus.bus_data_type_uuid;
+       pBusInfo->chanInfo.channelInstGuid = cmd->create_bus.bus_inst_uuid;
 
        list_add(&pBusInfo->entry, &BusInfoList);
 
@@ -1139,14 +1146,14 @@ bus_create(CONTROLVM_MESSAGE *inmsg)
 
 Away:
        bus_epilog(busNo, CONTROLVM_BUS_CREATE, &inmsg->hdr,
-                  rc, inmsg->hdr.Flags.responseExpected == 1);
+                  rc, inmsg->hdr.flags.response_expected == 1);
 }
 
 static void
-bus_destroy(CONTROLVM_MESSAGE *inmsg)
+bus_destroy(struct controlvm_message *inmsg)
 {
-       CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd;
-       ulong busNo = cmd->destroyBus.busNo;
+       struct controlvm_message_packet *cmd = &inmsg->cmd;
+       ulong busNo = cmd->destroy_bus.bus_no;
        VISORCHIPSET_BUS_INFO *pBusInfo;
        int rc = CONTROLVM_RESP_SUCCESS;
 
@@ -1165,19 +1172,19 @@ bus_destroy(CONTROLVM_MESSAGE *inmsg)
 
 Away:
        bus_epilog(busNo, CONTROLVM_BUS_DESTROY, &inmsg->hdr,
-                  rc, inmsg->hdr.Flags.responseExpected == 1);
+                  rc, inmsg->hdr.flags.response_expected == 1);
 }
 
 static void
-bus_configure(CONTROLVM_MESSAGE *inmsg, PARSER_CONTEXT *parser_ctx)
+bus_configure(struct controlvm_message *inmsg, PARSER_CONTEXT *parser_ctx)
 {
-       CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd;
-       ulong busNo = cmd->configureBus.busNo;
+       struct controlvm_message_packet *cmd = &inmsg->cmd;
+       ulong busNo = cmd->configure_bus.bus_no;
        VISORCHIPSET_BUS_INFO *pBusInfo = NULL;
        int rc = CONTROLVM_RESP_SUCCESS;
        char s[99];
 
-       busNo = cmd->configureBus.busNo;
+       busNo = cmd->configure_bus.bus_no;
        POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC, busNo, POSTCODE_SEVERITY_INFO);
 
        pBusInfo = findbus(&BusInfoList, busNo);
@@ -1198,16 +1205,16 @@ bus_configure(CONTROLVM_MESSAGE *inmsg, PARSER_CONTEXT *parser_ctx)
                goto Away;
        }
        /* TBD - add this check to other commands also... */
-       if (pBusInfo->pendingMsgHdr.Id != CONTROLVM_INVALID) {
+       if (pBusInfo->pendingMsgHdr.id != CONTROLVM_INVALID) {
                LOGERR("CONTROLVM_BUS_CONFIGURE Failed: bus %lu MsgId=%u outstanding",
-                    busNo, (uint) pBusInfo->pendingMsgHdr.Id);
+                    busNo, (uint) pBusInfo->pendingMsgHdr.id);
                POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT;
                goto Away;
        }
 
-       pBusInfo->partitionHandle = cmd->configureBus.guestHandle;
+       pBusInfo->partitionHandle = cmd->configure_bus.guest_handle;
        pBusInfo->partitionGuid = parser_id_get(parser_ctx);
        parser_param_start(parser_ctx, PARSERSTRING_NAME);
        pBusInfo->name = parser_string_get(parser_ctx);
@@ -1216,15 +1223,15 @@ bus_configure(CONTROLVM_MESSAGE *inmsg, PARSER_CONTEXT *parser_ctx)
        POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, busNo, POSTCODE_SEVERITY_INFO);
 Away:
        bus_epilog(busNo, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr,
-                  rc, inmsg->hdr.Flags.responseExpected == 1);
+                  rc, inmsg->hdr.flags.response_expected == 1);
 }
 
 static void
-my_device_create(CONTROLVM_MESSAGE *inmsg)
+my_device_create(struct controlvm_message *inmsg)
 {
-       CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd;
-       ulong busNo = cmd->createDevice.busNo;
-       ulong devNo = cmd->createDevice.devNo;
+       struct controlvm_message_packet *cmd = &inmsg->cmd;
+       ulong busNo = cmd->create_device.bus_no;
+       ulong devNo = cmd->create_device.dev_no;
        VISORCHIPSET_DEVICE_INFO *pDevInfo = NULL;
        VISORCHIPSET_BUS_INFO *pBusInfo = NULL;
        int rc = CONTROLVM_RESP_SUCCESS;
@@ -1268,18 +1275,18 @@ my_device_create(CONTROLVM_MESSAGE *inmsg)
        INIT_LIST_HEAD(&pDevInfo->entry);
        pDevInfo->busNo = busNo;
        pDevInfo->devNo = devNo;
-       pDevInfo->devInstGuid = cmd->createDevice.devInstGuid;
+       pDevInfo->devInstGuid = cmd->create_device.dev_inst_uuid;
        POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, devNo, busNo,
                         POSTCODE_SEVERITY_INFO);
 
-       if (inmsg->hdr.Flags.testMessage == 1)
+       if (inmsg->hdr.flags.test_message == 1)
                pDevInfo->chanInfo.addrType = ADDRTYPE_localTest;
        else
                pDevInfo->chanInfo.addrType = ADDRTYPE_localPhysical;
-       pDevInfo->chanInfo.channelAddr = cmd->createDevice.channelAddr;
-       pDevInfo->chanInfo.nChannelBytes = cmd->createDevice.channelBytes;
-       pDevInfo->chanInfo.channelTypeGuid = cmd->createDevice.dataTypeGuid;
-       pDevInfo->chanInfo.intr = cmd->createDevice.intr;
+       pDevInfo->chanInfo.channelAddr = cmd->create_device.channel_addr;
+       pDevInfo->chanInfo.nChannelBytes = cmd->create_device.channel_bytes;
+       pDevInfo->chanInfo.channelTypeGuid = cmd->create_device.data_type_uuid;
+       pDevInfo->chanInfo.intr = cmd->create_device.intr;
        list_add(&pDevInfo->entry, &DevInfoList);
        POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, devNo, busNo,
                         POSTCODE_SEVERITY_INFO);
@@ -1291,19 +1298,19 @@ Away:
                LOGINF("CONTROLVM_DEVICE_CREATE for DiagPool channel: busNo=%lu, devNo=%lu",
                     g_diagpoolBusNo, g_diagpoolDevNo);
        }
-       device_epilog(busNo, devNo, SegmentStateRunning,
+       device_epilog(busNo, devNo, segment_state_running,
                      CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc,
-                     inmsg->hdr.Flags.responseExpected == 1,
+                     inmsg->hdr.flags.response_expected == 1,
                      FOR_VISORBUS(pDevInfo->chanInfo.channelTypeGuid));
 }
 
 static void
-my_device_changestate(CONTROLVM_MESSAGE *inmsg)
+my_device_changestate(struct controlvm_message *inmsg)
 {
-       CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd;
-       ulong busNo = cmd->deviceChangeState.busNo;
-       ulong devNo = cmd->deviceChangeState.devNo;
-       ULTRA_SEGMENT_STATE state = cmd->deviceChangeState.state;
+       struct controlvm_message_packet *cmd = &inmsg->cmd;
+       ulong busNo = cmd->device_change_state.bus_no;
+       ulong devNo = cmd->device_change_state.dev_no;
+       struct spar_segment_state state = cmd->device_change_state.state;
        VISORCHIPSET_DEVICE_INFO *pDevInfo = NULL;
        int rc = CONTROLVM_RESP_SUCCESS;
 
@@ -1327,16 +1334,16 @@ Away:
        if ((rc >= CONTROLVM_RESP_SUCCESS) && pDevInfo)
                device_epilog(busNo, devNo, state, CONTROLVM_DEVICE_CHANGESTATE,
                              &inmsg->hdr, rc,
-                             inmsg->hdr.Flags.responseExpected == 1,
+                             inmsg->hdr.flags.response_expected == 1,
                              FOR_VISORBUS(pDevInfo->chanInfo.channelTypeGuid));
 }
 
 static void
-my_device_destroy(CONTROLVM_MESSAGE *inmsg)
+my_device_destroy(struct controlvm_message *inmsg)
 {
-       CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd;
-       ulong busNo = cmd->destroyDevice.busNo;
-       ulong devNo = cmd->destroyDevice.devNo;
+       struct controlvm_message_packet *cmd = &inmsg->cmd;
+       ulong busNo = cmd->destroy_device.bus_no;
+       ulong devNo = cmd->destroy_device.dev_no;
        VISORCHIPSET_DEVICE_INFO *pDevInfo = NULL;
        int rc = CONTROLVM_RESP_SUCCESS;
 
@@ -1355,9 +1362,9 @@ my_device_destroy(CONTROLVM_MESSAGE *inmsg)
 
 Away:
        if ((rc >= CONTROLVM_RESP_SUCCESS) && pDevInfo)
-               device_epilog(busNo, devNo, SegmentStateRunning,
+               device_epilog(busNo, devNo, segment_state_running,
                              CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc,
-                             inmsg->hdr.Flags.responseExpected == 1,
+                             inmsg->hdr.flags.response_expected == 1,
                              FOR_VISORBUS(pDevInfo->chanInfo.channelTypeGuid));
 }
 
@@ -1382,7 +1389,7 @@ initialize_controlvm_payload_info(HOSTADDRESS phys_addr, u64 offset, u32 bytes,
        }
        memset(info, 0, sizeof(CONTROLVM_PAYLOAD_INFO));
        if ((offset == 0) || (bytes == 0)) {
-               LOGERR("CONTROLVM_PAYLOAD_INIT Failed: RequestPayloadOffset=%llu RequestPayloadBytes=%llu!",
+               LOGERR("CONTROLVM_PAYLOAD_INIT Failed: request_payload_offset=%llu request_payload_bytes=%llu!",
                     (u64) offset, (u64) bytes);
                rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID;
                goto Away;
@@ -1429,8 +1436,8 @@ initialize_controlvm_payload(void)
        u32 payloadBytes = 0;
 
        if (visorchannel_read(ControlVm_channel,
-                             offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-                                      RequestPayloadOffset),
+                             offsetof(struct spar_controlvm_channel_protocol,
+                                      request_payload_offset),
                              &payloadOffset, sizeof(payloadOffset)) < 0) {
                LOGERR("CONTROLVM_PAYLOAD_INIT Failed to read controlvm channel!");
                POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC,
@@ -1438,8 +1445,8 @@ initialize_controlvm_payload(void)
                return;
        }
        if (visorchannel_read(ControlVm_channel,
-                             offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-                                      RequestPayloadBytes),
+                             offsetof(struct spar_controlvm_channel_protocol,
+                                      request_payload_bytes),
                              &payloadBytes, sizeof(payloadBytes)) < 0) {
                LOGERR("CONTROLVM_PAYLOAD_INIT Failed to read controlvm channel!");
                POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC,
@@ -1487,15 +1494,15 @@ visorchipset_chipset_notready(void)
 EXPORT_SYMBOL_GPL(visorchipset_chipset_notready);
 
 static void
-chipset_ready(CONTROLVM_MESSAGE_HEADER *msgHdr)
+chipset_ready(struct controlvm_message_header *msgHdr)
 {
        int rc = visorchipset_chipset_ready();
 
        if (rc != CONTROLVM_RESP_SUCCESS)
                rc = -rc;
-       if (msgHdr->Flags.responseExpected && !visorchipset_holdchipsetready)
+       if (msgHdr->flags.response_expected && !visorchipset_holdchipsetready)
                controlvm_respond(msgHdr, rc);
-       if (msgHdr->Flags.responseExpected && visorchipset_holdchipsetready) {
+       if (msgHdr->flags.response_expected && visorchipset_holdchipsetready) {
                /* Send CHIPSET_READY response when all modules have been loaded
                 * and disks mounted for the partition
                 */
@@ -1505,24 +1512,24 @@ chipset_ready(CONTROLVM_MESSAGE_HEADER *msgHdr)
 }
 
 static void
-chipset_selftest(CONTROLVM_MESSAGE_HEADER *msgHdr)
+chipset_selftest(struct controlvm_message_header *msgHdr)
 {
        int rc = visorchipset_chipset_selftest();
 
        if (rc != CONTROLVM_RESP_SUCCESS)
                rc = -rc;
-       if (msgHdr->Flags.responseExpected)
+       if (msgHdr->flags.response_expected)
                controlvm_respond(msgHdr, rc);
 }
 
 static void
-chipset_notready(CONTROLVM_MESSAGE_HEADER *msgHdr)
+chipset_notready(struct controlvm_message_header *msgHdr)
 {
        int rc = visorchipset_chipset_notready();
 
        if (rc != CONTROLVM_RESP_SUCCESS)
                rc = -rc;
-       if (msgHdr->Flags.responseExpected)
+       if (msgHdr->flags.response_expected)
                controlvm_respond(msgHdr, rc);
 }
 
@@ -1530,13 +1537,14 @@ chipset_notready(CONTROLVM_MESSAGE_HEADER *msgHdr)
  * CONTROLVM_QUEUE_EVENT queue in the controlvm channel.
  */
 static BOOL
-read_controlvm_event(CONTROLVM_MESSAGE *msg)
+read_controlvm_event(struct controlvm_message *msg)
 {
        if (visorchannel_signalremove(ControlVm_channel,
                                      CONTROLVM_QUEUE_EVENT, msg)) {
                /* got a message */
-               if (msg->hdr.Flags.testMessage == 1) {
-                       LOGERR("ignoring bad CONTROLVM_QUEUE_EVENT msg with controlvm_msg_id=0x%x because Flags.testMessage is nonsensical (=1)", msg->hdr.Id);
+               if (msg->hdr.flags.test_message == 1) {
+                       LOGERR("ignoring bad CONTROLVM_QUEUE_EVENT msg with controlvm_msg_id=0x%x because Flags.testMessage is nonsensical (=1)",
+                              msg->hdr.id);
                        return FALSE;
                }
                return TRUE;
@@ -1586,7 +1594,7 @@ parahotplug_next_expiration(void)
  * CONTROLVM_MESSAGE that we can stick on a list
  */
 static struct parahotplug_request *
-parahotplug_request_create(CONTROLVM_MESSAGE *msg)
+parahotplug_request_create(struct controlvm_message *msg)
 {
        struct parahotplug_request *req =
            kmalloc(sizeof(struct parahotplug_request),
@@ -1618,7 +1626,7 @@ parahotplug_request_destroy(struct parahotplug_request *req)
 static void
 parahotplug_request_kickoff(struct parahotplug_request *req)
 {
-       CONTROLVM_MESSAGE_PACKET *cmd = &req->msg.cmd;
+       struct controlvm_message_packet *cmd = &req->msg.cmd;
        char env_cmd[40], env_id[40], env_state[40], env_bus[40], env_dev[40],
            env_func[40];
        char *envp[] = {
@@ -1628,18 +1636,19 @@ parahotplug_request_kickoff(struct parahotplug_request *req)
        sprintf(env_cmd, "SPAR_PARAHOTPLUG=1");
        sprintf(env_id, "SPAR_PARAHOTPLUG_ID=%d", req->id);
        sprintf(env_state, "SPAR_PARAHOTPLUG_STATE=%d",
-               cmd->deviceChangeState.state.Active);
+               cmd->device_change_state.state.active);
        sprintf(env_bus, "SPAR_PARAHOTPLUG_BUS=%d",
-               cmd->deviceChangeState.busNo);
+               cmd->device_change_state.bus_no);
        sprintf(env_dev, "SPAR_PARAHOTPLUG_DEVICE=%d",
-               cmd->deviceChangeState.devNo >> 3);
+               cmd->device_change_state.dev_no >> 3);
        sprintf(env_func, "SPAR_PARAHOTPLUG_FUNCTION=%d",
-               cmd->deviceChangeState.devNo & 0x7);
+               cmd->device_change_state.dev_no & 0x7);
 
        LOGINF("parahotplug_request_kickoff: state=%d, bdf=%d/%d/%d, id=%u\n",
-              cmd->deviceChangeState.state.Active,
-              cmd->deviceChangeState.busNo, cmd->deviceChangeState.devNo >> 3,
-              cmd->deviceChangeState.devNo & 7, req->id);
+              cmd->device_change_state.state.active,
+              cmd->device_change_state.bus_no,
+              cmd->device_change_state.dev_no >> 3,
+              cmd->device_change_state.dev_no & 7, req->id);
 
        kobject_uevent_env(&Visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
                           envp);
@@ -1662,11 +1671,11 @@ parahotplug_process_list(void)
                    list_entry(pos, struct parahotplug_request, list);
                if (time_after_eq(jiffies, req->expiration)) {
                        list_del(pos);
-                       if (req->msg.hdr.Flags.responseExpected)
+                       if (req->msg.hdr.flags.response_expected)
                                controlvm_respond_physdev_changestate(
                                        &req->msg.hdr,
                                        CONTROLVM_RESP_ERROR_DEVICE_UDEV_TIMEOUT,
-                                       req->msg.cmd.deviceChangeState.state);
+                                       req->msg.cmd.device_change_state.state);
                        parahotplug_request_destroy(req);
                }
        }
@@ -1697,11 +1706,11 @@ parahotplug_request_complete(int id, u16 active)
                         */
                        list_del(pos);
                        spin_unlock(&Parahotplug_request_list_lock);
-                       req->msg.cmd.deviceChangeState.state.Active = active;
-                       if (req->msg.hdr.Flags.responseExpected)
+                       req->msg.cmd.device_change_state.state.active = active;
+                       if (req->msg.hdr.flags.response_expected)
                                controlvm_respond_physdev_changestate(
                                        &req->msg.hdr, CONTROLVM_RESP_SUCCESS,
-                                       req->msg.cmd.deviceChangeState.state);
+                                       req->msg.cmd.device_change_state.state);
                        parahotplug_request_destroy(req);
                        return 0;
                }
@@ -1715,7 +1724,7 @@ parahotplug_request_complete(int id, u16 active)
  * Enables or disables a PCI device by kicking off a udev script
  */
 static void
-parahotplug_process_message(CONTROLVM_MESSAGE *inmsg)
+parahotplug_process_message(struct controlvm_message *inmsg)
 {
        struct parahotplug_request *req;
 
@@ -1726,7 +1735,7 @@ parahotplug_process_message(CONTROLVM_MESSAGE *inmsg)
                return;
        }
 
-       if (inmsg->cmd.deviceChangeState.state.Active) {
+       if (inmsg->cmd.device_change_state.state.active) {
                /* For enable messages, just respond with success
                * right away.  This is a bit of a hack, but there are
                * issues with the early enable messages we get (with
@@ -1738,9 +1747,8 @@ parahotplug_process_message(CONTROLVM_MESSAGE *inmsg)
                */
                parahotplug_request_kickoff(req);
                controlvm_respond_physdev_changestate(&inmsg->hdr,
-                                                     CONTROLVM_RESP_SUCCESS,
-                                                     inmsg->cmd.
-                                                     deviceChangeState.state);
+                               CONTROLVM_RESP_SUCCESS, inmsg->cmd.
+                               device_change_state.state);
                parahotplug_request_destroy(req);
        } else {
                /* For disable messages, add the request to the
@@ -1768,23 +1776,23 @@ parahotplug_process_message(CONTROLVM_MESSAGE *inmsg)
  *            either successfully or with an error.
  */
 static BOOL
-handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr)
+handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
 {
-       CONTROLVM_MESSAGE_PACKET *cmd = &inmsg.cmd;
+       struct controlvm_message_packet *cmd = &inmsg.cmd;
        u64 parametersAddr = 0;
        u32 parametersBytes = 0;
        PARSER_CONTEXT *parser_ctx = NULL;
        BOOL isLocalAddr = FALSE;
-       CONTROLVM_MESSAGE ackmsg;
+       struct controlvm_message ackmsg;
 
        /* create parsing context if necessary */
-       isLocalAddr = (inmsg.hdr.Flags.testMessage == 1);
+       isLocalAddr = (inmsg.hdr.flags.test_message == 1);
        if (channel_addr == 0) {
                LOGERR("HUH? channel_addr is 0!");
                return TRUE;
        }
-       parametersAddr = channel_addr + inmsg.hdr.PayloadVmOffset;
-       parametersBytes = inmsg.hdr.PayloadBytes;
+       parametersAddr = channel_addr + inmsg.hdr.payload_vm_offset;
+       parametersBytes = inmsg.hdr.payload_bytes;
 
        /* Parameter and channel addresses within test messages actually lie
         * within our OS-controlled memory.  We need to know that, because it
@@ -1802,7 +1810,7 @@ handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr)
                                return FALSE;
                        }
                        LOGWRN("parsing failed");
-                       LOGWRN("inmsg.hdr.Id=0x%lx", (ulong) inmsg.hdr.Id);
+                       LOGWRN("inmsg.hdr.Id=0x%lx", (ulong) inmsg.hdr.id);
                        LOGWRN("parametersAddr=0x%llx", (u64) parametersAddr);
                        LOGWRN("parametersBytes=%lu", (ulong) parametersBytes);
                        LOGWRN("isLocalAddr=%d", isLocalAddr);
@@ -1818,45 +1826,45 @@ handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr)
                     (ControlVm_channel, CONTROLVM_QUEUE_ACK, &ackmsg)))
                        LOGWRN("failed to send ACK failed");
        }
-       switch (inmsg.hdr.Id) {
+       switch (inmsg.hdr.id) {
        case CONTROLVM_CHIPSET_INIT:
                LOGINF("CHIPSET_INIT(#busses=%lu,#switches=%lu)",
-                      (ulong) inmsg.cmd.initChipset.busCount,
-                      (ulong) inmsg.cmd.initChipset.switchCount);
+                      (ulong) inmsg.cmd.init_chipset.bus_count,
+                      (ulong) inmsg.cmd.init_chipset.switch_count);
                chipset_init(&inmsg);
                break;
        case CONTROLVM_BUS_CREATE:
                LOGINF("BUS_CREATE(%lu,#devs=%lu)",
-                      (ulong) cmd->createBus.busNo,
-                      (ulong) cmd->createBus.deviceCount);
+                      (ulong) cmd->create_bus.bus_no,
+                      (ulong) cmd->create_bus.dev_count);
                bus_create(&inmsg);
                break;
        case CONTROLVM_BUS_DESTROY:
-               LOGINF("BUS_DESTROY(%lu)", (ulong) cmd->destroyBus.busNo);
+               LOGINF("BUS_DESTROY(%lu)", (ulong) cmd->destroy_bus.bus_no);
                bus_destroy(&inmsg);
                break;
        case CONTROLVM_BUS_CONFIGURE:
-               LOGINF("BUS_CONFIGURE(%lu)", (ulong) cmd->configureBus.busNo);
+               LOGINF("BUS_CONFIGURE(%lu)", (ulong) cmd->configure_bus.bus_no);
                bus_configure(&inmsg, parser_ctx);
                break;
        case CONTROLVM_DEVICE_CREATE:
                LOGINF("DEVICE_CREATE(%lu,%lu)",
-                      (ulong) cmd->createDevice.busNo,
-                      (ulong) cmd->createDevice.devNo);
+                      (ulong) cmd->create_device.bus_no,
+                      (ulong) cmd->create_device.dev_no);
                my_device_create(&inmsg);
                break;
        case CONTROLVM_DEVICE_CHANGESTATE:
-               if (cmd->deviceChangeState.flags.physicalDevice) {
+               if (cmd->device_change_state.flags.phys_device) {
                        LOGINF("DEVICE_CHANGESTATE for physical device (%lu,%lu, active=%lu)",
-                            (ulong) cmd->deviceChangeState.busNo,
-                            (ulong) cmd->deviceChangeState.devNo,
-                            (ulong) cmd->deviceChangeState.state.Active);
+                            (ulong) cmd->device_change_state.bus_no,
+                            (ulong) cmd->device_change_state.dev_no,
+                            (ulong) cmd->device_change_state.state.active);
                        parahotplug_process_message(&inmsg);
                } else {
                        LOGINF("DEVICE_CHANGESTATE for virtual device (%lu,%lu, state.Alive=0x%lx)",
-                            (ulong) cmd->deviceChangeState.busNo,
-                            (ulong) cmd->deviceChangeState.devNo,
-                            (ulong) cmd->deviceChangeState.state.Alive);
+                            (ulong) cmd->device_change_state.bus_no,
+                            (ulong) cmd->device_change_state.dev_no,
+                            (ulong) cmd->device_change_state.state.alive);
                        /* save the hdr and cmd structures for later use */
                        /* when sending back the response to Command */
                        my_device_changestate(&inmsg);
@@ -1867,16 +1875,16 @@ handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr)
                break;
        case CONTROLVM_DEVICE_DESTROY:
                LOGINF("DEVICE_DESTROY(%lu,%lu)",
-                      (ulong) cmd->destroyDevice.busNo,
-                      (ulong) cmd->destroyDevice.devNo);
+                      (ulong) cmd->destroy_device.bus_no,
+                      (ulong) cmd->destroy_device.dev_no);
                my_device_destroy(&inmsg);
                break;
        case CONTROLVM_DEVICE_CONFIGURE:
                LOGINF("DEVICE_CONFIGURE(%lu,%lu)",
-                      (ulong) cmd->configureDevice.busNo,
-                      (ulong) cmd->configureDevice.devNo);
+                      (ulong) cmd->configure_device.bus_no,
+                      (ulong) cmd->configure_device.dev_no);
                /* no op for now, just send a respond that we passed */
-               if (inmsg.hdr.Flags.responseExpected)
+               if (inmsg.hdr.flags.response_expected)
                        controlvm_respond(&inmsg.hdr, CONTROLVM_RESP_SUCCESS);
                break;
        case CONTROLVM_CHIPSET_READY:
@@ -1892,8 +1900,8 @@ handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr)
                chipset_notready(&inmsg.hdr);
                break;
        default:
-               LOGERR("unrecognized controlvm cmd=%d", (int) inmsg.hdr.Id);
-               if (inmsg.hdr.Flags.responseExpected)
+               LOGERR("unrecognized controlvm cmd=%d", (int) inmsg.hdr.id);
+               if (inmsg.hdr.flags.response_expected)
                        controlvm_respond(&inmsg.hdr,
                                          -CONTROLVM_RESP_ERROR_MESSAGE_ID_UNKNOWN);
                break;
@@ -1924,7 +1932,7 @@ static void
 controlvm_periodic_work(struct work_struct *work)
 {
        VISORCHIPSET_CHANNEL_INFO chanInfo;
-       CONTROLVM_MESSAGE inmsg;
+       struct controlvm_message inmsg;
        BOOL gotACommand = FALSE;
        BOOL handle_command_failed = FALSE;
        static u64 Poll_Count;
@@ -1950,24 +1958,24 @@ controlvm_periodic_work(struct work_struct *work)
         * should be sent
         */
        if (visorchipset_holdchipsetready
-           && (g_ChipSetMsgHdr.Id != CONTROLVM_INVALID)) {
+           && (g_ChipSetMsgHdr.id != CONTROLVM_INVALID)) {
                if (check_chipset_events() == 1) {
                        LOGINF("Sending CHIPSET_READY response");
                        controlvm_respond(&g_ChipSetMsgHdr, 0);
                        clear_chipset_events();
                        memset(&g_ChipSetMsgHdr, 0,
-                              sizeof(CONTROLVM_MESSAGE_HEADER));
+                              sizeof(struct controlvm_message_header));
                }
        }
 
        while (visorchannel_signalremove(ControlVm_channel,
                                         CONTROLVM_QUEUE_RESPONSE,
                                         &inmsg)) {
-               if (inmsg.hdr.PayloadMaxBytes != 0) {
+               if (inmsg.hdr.payload_max_bytes != 0) {
                        LOGERR("Payload of size %lu returned @%lu with unexpected message id %d.",
-                            (ulong) inmsg.hdr.PayloadMaxBytes,
-                            (ulong) inmsg.hdr.PayloadVmOffset,
-                            inmsg.hdr.Id);
+                            (ulong) inmsg.hdr.payload_max_bytes,
+                            (ulong) inmsg.hdr.payload_vm_offset,
+                            inmsg.hdr.id);
                }
        }
        if (!gotACommand) {
@@ -2033,9 +2041,9 @@ static void
 setup_crash_devices_work_queue(struct work_struct *work)
 {
 
-       CONTROLVM_MESSAGE localCrashCreateBusMsg;
-       CONTROLVM_MESSAGE localCrashCreateDevMsg;
-       CONTROLVM_MESSAGE msg;
+       struct controlvm_message localCrashCreateBusMsg;
+       struct controlvm_message localCrashCreateDevMsg;
+       struct controlvm_message msg;
        u32 localSavedCrashMsgOffset;
        u16 localSavedCrashMsgCount;
 
@@ -2052,16 +2060,16 @@ setup_crash_devices_work_queue(struct work_struct *work)
        POSTCODE_LINUX_2(CRASH_DEV_ENTRY_PC, POSTCODE_SEVERITY_INFO);
 
        /* send init chipset msg */
-       msg.hdr.Id = CONTROLVM_CHIPSET_INIT;
-       msg.cmd.initChipset.busCount = 23;
-       msg.cmd.initChipset.switchCount = 0;
+       msg.hdr.id = CONTROLVM_CHIPSET_INIT;
+       msg.cmd.init_chipset.bus_count = 23;
+       msg.cmd.init_chipset.switch_count = 0;
 
        chipset_init(&msg);
 
        /* get saved message count */
        if (visorchannel_read(ControlVm_channel,
-                             offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-                                      SavedCrashMsgCount),
+                             offsetof(struct spar_controlvm_channel_protocol,
+                                      saved_crash_message_count),
                              &localSavedCrashMsgCount, sizeof(u16)) < 0) {
                LOGERR("failed to get Saved Message Count");
                POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
@@ -2080,8 +2088,8 @@ setup_crash_devices_work_queue(struct work_struct *work)
 
        /* get saved crash message offset */
        if (visorchannel_read(ControlVm_channel,
-                             offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-                                      SavedCrashMsgOffset),
+                             offsetof(struct spar_controlvm_channel_protocol,
+                                      saved_crash_message_offset),
                              &localSavedCrashMsgOffset, sizeof(u32)) < 0) {
                LOGERR("failed to get Saved Message Offset");
                POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
@@ -2093,7 +2101,7 @@ setup_crash_devices_work_queue(struct work_struct *work)
        if (visorchannel_read(ControlVm_channel,
                              localSavedCrashMsgOffset,
                              &localCrashCreateBusMsg,
-                             sizeof(CONTROLVM_MESSAGE)) < 0) {
+                             sizeof(struct controlvm_message)) < 0) {
                LOGERR("CRASH_DEV_RD_BUS_FAIULRE: Failed to read CrashCreateBusMsg!");
                POSTCODE_LINUX_2(CRASH_DEV_RD_BUS_FAIULRE_PC,
                                 POSTCODE_SEVERITY_ERR);
@@ -2103,9 +2111,9 @@ setup_crash_devices_work_queue(struct work_struct *work)
        /* read create device message for storage device */
        if (visorchannel_read(ControlVm_channel,
                              localSavedCrashMsgOffset +
-                             sizeof(CONTROLVM_MESSAGE),
+                             sizeof(struct controlvm_message),
                              &localCrashCreateDevMsg,
-                             sizeof(CONTROLVM_MESSAGE)) < 0) {
+                             sizeof(struct controlvm_message)) < 0) {
                LOGERR("CRASH_DEV_RD_DEV_FAIULRE: Failed to read CrashCreateDevMsg!");
                POSTCODE_LINUX_2(CRASH_DEV_RD_DEV_FAIULRE_PC,
                                 POSTCODE_SEVERITY_ERR);
@@ -2113,7 +2121,7 @@ setup_crash_devices_work_queue(struct work_struct *work)
        }
 
        /* reuse IOVM create bus message */
-       if (localCrashCreateBusMsg.cmd.createBus.channelAddr != 0)
+       if (localCrashCreateBusMsg.cmd.create_bus.channel_addr != 0)
                bus_create(&localCrashCreateBusMsg);
        else {
                LOGERR("CrashCreateBusMsg is null, no dump will be taken");
@@ -2123,7 +2131,7 @@ setup_crash_devices_work_queue(struct work_struct *work)
        }
 
        /* reuse create device message for storage device */
-       if (localCrashCreateDevMsg.cmd.createDevice.channelAddr != 0)
+       if (localCrashCreateDevMsg.cmd.create_device.channel_addr != 0)
                my_device_create(&localCrashCreateDevMsg);
        else {
                LOGERR("CrashCreateDevMsg is null, no dump will be taken");
@@ -2173,7 +2181,7 @@ visorchipset_device_pause_response(ulong busNo, ulong devNo, int response)
 
        device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
                                     busNo, devNo, response,
-                                    SegmentStateStandby);
+                                    segment_state_standby);
 }
 EXPORT_SYMBOL_GPL(visorchipset_device_pause_response);
 
@@ -2182,7 +2190,7 @@ device_resume_response(ulong busNo, ulong devNo, int response)
 {
        device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
                                     busNo, devNo, response,
-                                    SegmentStateRunning);
+                                    segment_state_running);
 }
 
 BOOL
@@ -2377,11 +2385,10 @@ visorchipset_init(void)
                ControlVm_channel =
                    visorchannel_create_with_lock
                    (addr,
-                    sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL),
-                    UltraControlvmChannelProtocolGuid);
-               if (ULTRA_CONTROLVM_CHANNEL_OK_CLIENT
-                        (visorchannel_get_header(ControlVm_channel),
-                         NULL)) {
+                    sizeof(struct spar_controlvm_channel_protocol),
+                    spar_controlvm_channel_protocol_uuid);
+               if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT(
+                               visorchannel_get_header(ControlVm_channel))) {
                        LOGINF("Channel %s (ControlVm) discovered",
                               visorchannel_id(ControlVm_channel, s));
                        initialize_controlvm_payload();
@@ -2404,11 +2411,11 @@ visorchipset_init(void)
                goto Away;
        }
 
-       memset(&g_DiagMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
+       memset(&g_DiagMsgHdr, 0, sizeof(struct controlvm_message_header));
 
-       memset(&g_ChipSetMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
+       memset(&g_ChipSetMsgHdr, 0, sizeof(struct controlvm_message_header));
 
-       memset(&g_DelDumpMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
+       memset(&g_DelDumpMsgHdr, 0, sizeof(struct controlvm_message_header));
 
        Putfile_buffer_list_pool =
            kmem_cache_create(Putfile_buffer_list_pool_name,
@@ -2497,11 +2504,11 @@ visorchipset_exit(void)
 
        cleanup_controlvm_structures();
 
-       memset(&g_DiagMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
+       memset(&g_DiagMsgHdr, 0, sizeof(struct controlvm_message_header));
 
-       memset(&g_ChipSetMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
+       memset(&g_ChipSetMsgHdr, 0, sizeof(struct controlvm_message_header));
 
-       memset(&g_DelDumpMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
+       memset(&g_DelDumpMsgHdr, 0, sizeof(struct controlvm_message_header));
 
        LOGINF("Channel %s (ControlVm) disconnected",
               visorchannel_id(ControlVm_channel, s));
index 3b38849..40f1ae9 100644 (file)
@@ -254,9 +254,9 @@ void visor_easyproc_CreateDeviceProperty(struct easyproc_device_info *p,
        }
        strcpy(px->property_name, property_name);
        if (px->procEntry == NULL) {
-               ERRDEVX(p->devno, "failed to register /proc/%s/device/%d/%s entry",
-                       p->pdriver->ProcId, p->devno, property_name
-                      );
+               ERRDEVX(p->devno,
+                       "failed to register /proc/%s/device/%d/%s entry",
+                       p->pdriver->ProcId, p->devno, property_name);
                return;
        }
        px->show_device_property_info = show_property_info;
index c476036..195772d 100644 (file)
@@ -320,19 +320,18 @@ void visor_proc_DestroyObject(MYPROCOBJECT *obj)
                kfree(obj->procDirProperties);
                obj->procDirProperties = NULL;
        }
-       if (obj->procDirPropertyContexts != NULL) {
-               kfree(obj->procDirPropertyContexts);
-               obj->procDirPropertyContexts = NULL;
-       }
+
+       kfree(obj->procDirPropertyContexts);
+       obj->procDirPropertyContexts = NULL;
+
        if (obj->procDir != NULL) {
                if (obj->name != NULL)
                        remove_proc_entry(obj->name, type->procDir);
                obj->procDir = NULL;
        }
-       if (obj->name != NULL) {
-               kfree(obj->name);
-               obj->name = NULL;
-       }
+
+       kfree(obj->name);
+       obj->name = NULL;
        kfree(obj);
 }
 EXPORT_SYMBOL_GPL(visor_proc_DestroyObject);
index d6815f9..64b135d 100644 (file)
 int unisys_spar_platform;
 EXPORT_SYMBOL_GPL(unisys_spar_platform);
 
-/** Callers to interfaces that set __GFP_NORETRY flag below
- *  must check for a NULL (error) result as we are telling the
- *  kernel interface that it is okay to fail.
- */
-
-void *kmalloc_kernel(size_t siz)
-{
-       return kmalloc(siz, GFP_KERNEL | __GFP_NORETRY);
-}
-
 static __init uint32_t
 visorutil_spar_detect(void)
 {
index 8e8bbb1..1d2ff0c 100644 (file)
@@ -8,6 +8,9 @@ config VME_USER
          VME windows in a manner at least semi-compatible with the interface
          provided with the original driver at <http://www.vmelinux.org/>.
 
+         To compile this driver as a module, choose M here. The module will
+         be called vme_user. If unsure, say N.
+
 config VME_PIO2
        tristate "GE PIO2 VME"
        depends on STAGING && GPIOLIB
index c64776f..da34d55 100644 (file)
@@ -191,11 +191,11 @@ int pio2_gpio_init(struct pio2_card *card)
        int retval = 0;
        char *label;
 
-       label = kmalloc(PIO2_NUM_CHANNELS, GFP_KERNEL);
+       label = kasprintf(GFP_KERNEL,
+                         "%s@%s", driver_name, dev_name(&card->vdev->dev));
        if (label == NULL)
                return -ENOMEM;
 
-       sprintf(label, "%s@%s", driver_name, dev_name(&card->vdev->dev));
        card->gc.label = label;
 
        card->gc.ngpio = PIO2_NUM_CHANNELS;
diff --git a/drivers/staging/vt6655/80211hdr.h b/drivers/staging/vt6655/80211hdr.h
deleted file mode 100644 (file)
index 36e14ec..0000000
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: 80211hdr.h
- *
- * Purpose: 802.11 MAC headers related pre-defines and macros.
- *
- *
- * Author: Lyndon Chen
- *
- * Date: Apr 8, 2002
- *
- */
-
-#ifndef __80211HDR_H__
-#define __80211HDR_H__
-
-#include "ttype.h"
-
-/* bit type */
-#define BIT0   0x00000001
-#define BIT1   0x00000002
-#define BIT2   0x00000004
-#define BIT3   0x00000008
-#define BIT4   0x00000010
-#define BIT5   0x00000020
-#define BIT6   0x00000040
-#define BIT7   0x00000080
-#define BIT8   0x00000100
-#define BIT9   0x00000200
-#define BIT10  0x00000400
-#define BIT11  0x00000800
-#define BIT12  0x00001000
-#define BIT13  0x00002000
-#define BIT14  0x00004000
-#define BIT15  0x00008000
-#define BIT16  0x00010000
-#define BIT17  0x00020000
-#define BIT18  0x00040000
-#define BIT19  0x00080000
-#define BIT20  0x00100000
-#define BIT21  0x00200000
-#define BIT22  0x00400000
-#define BIT23  0x00800000
-#define BIT24  0x01000000
-#define BIT25  0x02000000
-#define BIT26  0x04000000
-#define BIT27  0x08000000
-#define BIT28  0x10000000
-#define BIT29  0x20000000
-#define BIT30  0x40000000
-#define BIT31  0x80000000
-
-/* 802.11 frame related, defined as 802.11 spec */
-#define WLAN_ADDR_LEN               6
-#define WLAN_CRC_LEN                4
-#define WLAN_CRC32_LEN              4
-#define WLAN_FCS_LEN                4
-#define WLAN_BSSID_LEN              6
-#define WLAN_BSS_TS_LEN             8
-#define WLAN_HDR_ADDR2_LEN          16
-#define WLAN_HDR_ADDR3_LEN          24
-#define WLAN_HDR_ADDR4_LEN          30
-#define WLAN_IEHDR_LEN              2
-#define WLAN_SSID_MAXLEN            32
-#define WLAN_RATES_MAXLEN           16
-#define WLAN_RATES_MAXLEN_11B       4
-#define WLAN_RSN_MAXLEN             32
-#define WLAN_DATA_MAXLEN            2312
-#define WLAN_A3FR_MAXLEN            (WLAN_HDR_ADDR3_LEN + WLAN_DATA_MAXLEN + \
-                                    WLAN_CRC_LEN)
-
-#define WLAN_BEACON_FR_MAXLEN       WLAN_A3FR_MAXLEN
-#define WLAN_ATIM_FR_MAXLEN         (WLAN_HDR_ADDR3_LEN + 0)
-#define WLAN_NULLDATA_FR_MAXLEN     (WLAN_HDR_ADDR3_LEN + 0)
-#define WLAN_DISASSOC_FR_MAXLEN     (WLAN_HDR_ADDR3_LEN + 2)
-#define WLAN_ASSOCREQ_FR_MAXLEN     WLAN_A3FR_MAXLEN
-#define WLAN_ASSOCRESP_FR_MAXLEN    WLAN_A3FR_MAXLEN
-#define WLAN_REASSOCREQ_FR_MAXLEN   WLAN_A3FR_MAXLEN
-#define WLAN_REASSOCRESP_FR_MAXLEN  WLAN_A3FR_MAXLEN
-#define WLAN_PROBEREQ_FR_MAXLEN     WLAN_A3FR_MAXLEN
-#define WLAN_PROBERESP_FR_MAXLEN    WLAN_A3FR_MAXLEN
-#define WLAN_AUTHEN_FR_MAXLEN       WLAN_A3FR_MAXLEN
-#define WLAN_DEAUTHEN_FR_MAXLEN     (WLAN_HDR_ADDR3_LEN + 2)
-
-#define WLAN_WEP_NKEYS              4
-#define WLAN_WEP40_KEYLEN           5
-#define WLAN_WEP104_KEYLEN          13
-#define WLAN_WEP232_KEYLEN          29
-#define WLAN_WEPMAX_KEYLEN          32
-#define WLAN_CHALLENGE_IE_MAXLEN    255
-#define WLAN_CHALLENGE_IE_LEN       130
-#define WLAN_CHALLENGE_LEN          128
-#define WLAN_WEP_IV_LEN             4
-#define WLAN_WEP_ICV_LEN            4
-#define WLAN_FRAGS_MAX              16
-
-/* Frame Type */
-#define WLAN_TYPE_MGR 0x00
-#define WLAN_TYPE_CTL  0x01
-#define WLAN_TYPE_DATA 0x02
-
-#define WLAN_FTYPE_MGMT 0x00
-#define WLAN_FTYPE_CTL  0x01
-#define WLAN_FTYPE_DATA 0x02
-
-/* Frame Subtypes */
-#define WLAN_FSTYPE_ASSOCREQ        0x00
-#define WLAN_FSTYPE_ASSOCRESP       0x01
-#define WLAN_FSTYPE_REASSOCREQ      0x02
-#define WLAN_FSTYPE_REASSOCRESP     0x03
-#define WLAN_FSTYPE_PROBEREQ        0x04
-#define WLAN_FSTYPE_PROBERESP       0x05
-#define WLAN_FSTYPE_BEACON          0x08
-#define WLAN_FSTYPE_ATIM            0x09
-#define WLAN_FSTYPE_DISASSOC        0x0a
-#define WLAN_FSTYPE_AUTHEN          0x0b
-#define WLAN_FSTYPE_DEAUTHEN        0x0c
-#define WLAN_FSTYPE_ACTION          0x0d
-
-/* Control */
-#define WLAN_FSTYPE_PSPOLL          0x0a
-#define WLAN_FSTYPE_RTS             0x0b
-#define WLAN_FSTYPE_CTS             0x0c
-#define WLAN_FSTYPE_ACK             0x0d
-#define WLAN_FSTYPE_CFEND           0x0e
-#define WLAN_FSTYPE_CFENDCFACK      0x0f
-
-/* Data */
-#define WLAN_FSTYPE_DATAONLY        0x00
-#define WLAN_FSTYPE_DATA_CFACK      0x01
-#define WLAN_FSTYPE_DATA_CFPOLL     0x02
-#define WLAN_FSTYPE_DATA_CFACK_CFPOLL   0x03
-#define WLAN_FSTYPE_NULL            0x04
-#define WLAN_FSTYPE_CFACK           0x05
-#define WLAN_FSTYPE_CFPOLL          0x06
-#define WLAN_FSTYPE_CFACK_CFPOLL    0x07
-
-#ifdef __BIG_ENDIAN
-
-/* GET & SET Frame Control bit */
-#define WLAN_GET_FC_PRVER(n)    (((unsigned short)(n) >> 8) & (BIT0 | BIT1))
-#define WLAN_GET_FC_FTYPE(n)    ((((unsigned short)(n) >> 8) & (BIT2 | BIT3)) >> 2)
-#define WLAN_GET_FC_FSTYPE(n)   ((((unsigned short)(n) >> 8) & (BIT4|BIT5|BIT6|BIT7)) >> 4)
-#define WLAN_GET_FC_TODS(n)     ((((unsigned short)(n) << 8) & (BIT8)) >> 8)
-#define WLAN_GET_FC_FROMDS(n)   ((((unsigned short)(n) << 8) & (BIT9)) >> 9)
-#define WLAN_GET_FC_MOREFRAG(n) ((((unsigned short)(n) << 8) & (BIT10)) >> 10)
-#define WLAN_GET_FC_RETRY(n)    ((((unsigned short)(n) << 8) & (BIT11)) >> 11)
-#define WLAN_GET_FC_PWRMGT(n)   ((((unsigned short)(n) << 8) & (BIT12)) >> 12)
-#define WLAN_GET_FC_MOREDATA(n) ((((unsigned short)(n) << 8) & (BIT13)) >> 13)
-#define WLAN_GET_FC_ISWEP(n)    ((((unsigned short)(n) << 8) & (BIT14)) >> 14)
-#define WLAN_GET_FC_ORDER(n)    ((((unsigned short)(n) << 8) & (BIT15)) >> 15)
-
-/* Sequence Field bit */
-#define WLAN_GET_SEQ_FRGNUM(n) (((unsigned short)(n) >> 8) & (BIT0|BIT1|BIT2|BIT3))
-#define WLAN_GET_SEQ_SEQNUM(n) ((((unsigned short)(n) >> 8) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4)
-
-/* Capability Field bit */
-#define WLAN_GET_CAP_INFO_ESS(n)           (((n) >> 8) & BIT0)
-#define WLAN_GET_CAP_INFO_IBSS(n)          ((((n) >> 8) & BIT1) >> 1)
-#define WLAN_GET_CAP_INFO_CFPOLLABLE(n)    ((((n) >> 8) & BIT2) >> 2)
-#define WLAN_GET_CAP_INFO_CFPOLLREQ(n)     ((((n) >> 8) & BIT3) >> 3)
-#define WLAN_GET_CAP_INFO_PRIVACY(n)       ((((n) >> 8) & BIT4) >> 4)
-#define WLAN_GET_CAP_INFO_SHORTPREAMBLE(n) ((((n) >> 8) & BIT5) >> 5)
-#define WLAN_GET_CAP_INFO_PBCC(n)          ((((n) >> 8) & BIT6) >> 6)
-#define WLAN_GET_CAP_INFO_AGILITY(n)       ((((n) >> 8) & BIT7) >> 7)
-#define WLAN_GET_CAP_INFO_SPECTRUMMNG(n)   ((((n))      & BIT8) >> 10)
-#define WLAN_GET_CAP_INFO_SHORTSLOTTIME(n) ((((n))      & BIT10) >> 10)
-#define WLAN_GET_CAP_INFO_DSSSOFDM(n)      ((((n))      & BIT13) >> 13)
-#define WLAN_GET_CAP_INFO_GRPACK(n)        ((((n))      & BIT14) >> 14)
-
-#else
-
-/* GET & SET Frame Control bit */
-#define WLAN_GET_FC_PRVER(n)    (((unsigned short)(n)) & (BIT0 | BIT1))
-#define WLAN_GET_FC_FTYPE(n)    ((((unsigned short)(n)) & (BIT2 | BIT3)) >> 2)
-#define WLAN_GET_FC_FSTYPE(n)   ((((unsigned short)(n)) & (BIT4|BIT5|BIT6|BIT7)) >> 4)
-#define WLAN_GET_FC_TODS(n)     ((((unsigned short)(n)) & (BIT8)) >> 8)
-#define WLAN_GET_FC_FROMDS(n)   ((((unsigned short)(n)) & (BIT9)) >> 9)
-#define WLAN_GET_FC_MOREFRAG(n) ((((unsigned short)(n)) & (BIT10)) >> 10)
-#define WLAN_GET_FC_RETRY(n)    ((((unsigned short)(n)) & (BIT11)) >> 11)
-#define WLAN_GET_FC_PWRMGT(n)   ((((unsigned short)(n)) & (BIT12)) >> 12)
-#define WLAN_GET_FC_MOREDATA(n) ((((unsigned short)(n)) & (BIT13)) >> 13)
-#define WLAN_GET_FC_ISWEP(n)    ((((unsigned short)(n)) & (BIT14)) >> 14)
-#define WLAN_GET_FC_ORDER(n)    ((((unsigned short)(n)) & (BIT15)) >> 15)
-
-/* Sequence Field bit */
-#define WLAN_GET_SEQ_FRGNUM(n) (((unsigned short)(n)) & (BIT0|BIT1|BIT2|BIT3))
-#define WLAN_GET_SEQ_SEQNUM(n) ((((unsigned short)(n)) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4)
-
-/* Capability Field bit */
-#define WLAN_GET_CAP_INFO_ESS(n)           ((n) & BIT0)
-#define WLAN_GET_CAP_INFO_IBSS(n)          (((n) & BIT1) >> 1)
-#define WLAN_GET_CAP_INFO_CFPOLLABLE(n)    (((n) & BIT2) >> 2)
-#define WLAN_GET_CAP_INFO_CFPOLLREQ(n)     (((n) & BIT3) >> 3)
-#define WLAN_GET_CAP_INFO_PRIVACY(n)       (((n) & BIT4) >> 4)
-#define WLAN_GET_CAP_INFO_SHORTPREAMBLE(n) (((n) & BIT5) >> 5)
-#define WLAN_GET_CAP_INFO_PBCC(n)          (((n) & BIT6) >> 6)
-#define WLAN_GET_CAP_INFO_AGILITY(n)       (((n) & BIT7) >> 7)
-#define WLAN_GET_CAP_INFO_SPECTRUMMNG(n)   (((n) & BIT8) >> 10)
-#define WLAN_GET_CAP_INFO_SHORTSLOTTIME(n) (((n) & BIT10) >> 10)
-#define WLAN_GET_CAP_INFO_DSSSOFDM(n)      (((n) & BIT13) >> 13)
-#define WLAN_GET_CAP_INFO_GRPACK(n)        (((n) & BIT14) >> 14)
-
-#endif /*#ifdef __BIG_ENDIAN */
-
-#define WLAN_SET_CAP_INFO_ESS(n)           (n)
-#define WLAN_SET_CAP_INFO_IBSS(n)          ((n) << 1)
-#define WLAN_SET_CAP_INFO_CFPOLLABLE(n)    ((n) << 2)
-#define WLAN_SET_CAP_INFO_CFPOLLREQ(n)     ((n) << 3)
-#define WLAN_SET_CAP_INFO_PRIVACY(n)       ((n) << 4)
-#define WLAN_SET_CAP_INFO_SHORTPREAMBLE(n) ((n) << 5)
-#define WLAN_SET_CAP_INFO_SPECTRUMMNG(n)   ((n) << 8)
-#define WLAN_SET_CAP_INFO_PBCC(n)          ((n) << 6)
-#define WLAN_SET_CAP_INFO_AGILITY(n)       ((n) << 7)
-#define WLAN_SET_CAP_INFO_SHORTSLOTTIME(n) ((n) << 10)
-#define WLAN_SET_CAP_INFO_DSSSOFDM(n)      ((n) << 13)
-#define WLAN_SET_CAP_INFO_GRPACK(n)        ((n) << 14)
-
-#define WLAN_SET_FC_PRVER(n)    ((unsigned short)(n))
-#define WLAN_SET_FC_FTYPE(n)    (((unsigned short)(n)) << 2)
-#define WLAN_SET_FC_FSTYPE(n)   (((unsigned short)(n)) << 4)
-#define WLAN_SET_FC_TODS(n)     (((unsigned short)(n)) << 8)
-#define WLAN_SET_FC_FROMDS(n)   (((unsigned short)(n)) << 9)
-#define WLAN_SET_FC_MOREFRAG(n) (((unsigned short)(n)) << 10)
-#define WLAN_SET_FC_RETRY(n)    (((unsigned short)(n)) << 11)
-#define WLAN_SET_FC_PWRMGT(n)   (((unsigned short)(n)) << 12)
-#define WLAN_SET_FC_MOREDATA(n) (((unsigned short)(n)) << 13)
-#define WLAN_SET_FC_ISWEP(n)    (((unsigned short)(n)) << 14)
-#define WLAN_SET_FC_ORDER(n)    (((unsigned short)(n)) << 15)
-
-#define WLAN_SET_SEQ_FRGNUM(n) ((unsigned short)(n))
-#define WLAN_SET_SEQ_SEQNUM(n) (((unsigned short)(n)) << 4)
-
-/* ERP Field bit */
-
-#define WLAN_GET_ERP_NONERP_PRESENT(n)     ((n) & BIT0)
-#define WLAN_GET_ERP_USE_PROTECTION(n)     (((n) & BIT1) >> 1)
-#define WLAN_GET_ERP_BARKER_MODE(n)        (((n) & BIT2) >> 2)
-
-#define WLAN_SET_ERP_NONERP_PRESENT(n)     (n)
-#define WLAN_SET_ERP_USE_PROTECTION(n)     ((n) << 1)
-#define WLAN_SET_ERP_BARKER_MODE(n)        ((n) << 2)
-
-/* Support & Basic Rates field */
-#define WLAN_MGMT_IS_BASICRATE(b)    ((b) & BIT7)
-#define WLAN_MGMT_GET_RATE(b)        ((b) & ~BIT7)
-
-/* TIM field */
-#define WLAN_MGMT_IS_MULTICAST_TIM(b)   ((b) & BIT0)
-#define WLAN_MGMT_GET_TIM_OFFSET(b)     (((b) & ~BIT0) >> 1)
-
-/* 3-Addr & 4-Addr */
-#define WLAN_HDR_A3_DATA_PTR(p) (((unsigned char *)(p)) + WLAN_HDR_ADDR3_LEN)
-#define WLAN_HDR_A4_DATA_PTR(p) (((unsigned char *)(p)) + WLAN_HDR_ADDR4_LEN)
-
-/* IEEE ADDR */
-#define IEEE_ADDR_UNIVERSAL         0x02
-#define IEEE_ADDR_GROUP             0x01
-
-typedef struct {
-       unsigned char abyAddr[6];
-} IEEE_ADDR, *PIEEE_ADDR;
-
-/* 802.11 Header Format */
-
-typedef struct tagWLAN_80211HDR_A2 {
-       unsigned short wFrameCtl;
-       unsigned short wDurationID;
-       unsigned char abyAddr1[WLAN_ADDR_LEN];
-       unsigned char abyAddr2[WLAN_ADDR_LEN];
-} __attribute__ ((__packed__))
-WLAN_80211HDR_A2, *PWLAN_80211HDR_A2;
-
-typedef struct tagWLAN_80211HDR_A3 {
-       unsigned short wFrameCtl;
-       unsigned short wDurationID;
-       unsigned char abyAddr1[WLAN_ADDR_LEN];
-       unsigned char abyAddr2[WLAN_ADDR_LEN];
-       unsigned char abyAddr3[WLAN_ADDR_LEN];
-       unsigned short wSeqCtl;
-} __attribute__ ((__packed__))
-WLAN_80211HDR_A3, *PWLAN_80211HDR_A3;
-
-typedef struct tagWLAN_80211HDR_A4 {
-       unsigned short wFrameCtl;
-       unsigned short wDurationID;
-       unsigned char abyAddr1[WLAN_ADDR_LEN];
-       unsigned char abyAddr2[WLAN_ADDR_LEN];
-       unsigned char abyAddr3[WLAN_ADDR_LEN];
-       unsigned short wSeqCtl;
-       unsigned char abyAddr4[WLAN_ADDR_LEN];
-} __attribute__ ((__packed__))
-WLAN_80211HDR_A4, *PWLAN_80211HDR_A4;
-
-typedef union tagUWLAN_80211HDR {
-       WLAN_80211HDR_A2        sA2;
-       WLAN_80211HDR_A3        sA3;
-       WLAN_80211HDR_A4        sA4;
-} UWLAN_80211HDR, *PUWLAN_80211HDR;
-
-#endif /* __80211HDR_H__ */
diff --git a/drivers/staging/vt6655/80211mgr.c b/drivers/staging/vt6655/80211mgr.c
deleted file mode 100644 (file)
index 7d2c647..0000000
+++ /dev/null
@@ -1,1019 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: 80211mgr.c
- *
- * Purpose: Handles the 802.11 management support functions
- *
- * Author: Lyndon Chen
- *
- * Date: May 8, 2002
- *
- * Functions:
- *      vMgrEncodeBeacon - Encode the Beacon frame
- *      vMgrDecodeBeacon - Decode the Beacon frame
- *      vMgrEncodeIBSSATIM - Encode the IBSS ATIM frame
- *      vMgrDecodeIBSSATIM - Decode the IBSS ATIM frame
- *      vMgrEncodeDisassociation - Encode the Disassociation frame
- *      vMgrDecodeDisassociation - Decode the Disassociation frame
- *      vMgrEncodeAssocRequest - Encode the Association request frame
- *      vMgrDecodeAssocRequest - Decode the Association request frame
- *      vMgrEncodeAssocResponse - Encode the Association response frame
- *      vMgrDecodeAssocResponse - Decode the Association response frame
- *      vMgrEncodeReAssocRequest - Encode the ReAssociation request frame
- *      vMgrDecodeReAssocRequest - Decode the ReAssociation request frame
- *      vMgrEncodeProbeRequest - Encode the Probe request frame
- *      vMgrDecodeProbeRequest - Decode the Probe request frame
- *      vMgrEncodeProbeResponse - Encode the Probe response frame
- *      vMgrDecodeProbeResponse - Decode the Probe response frame
- *      vMgrEncodeAuthen - Encode the Authentication frame
- *      vMgrDecodeAuthen - Decode the Authentication frame
- *      vMgrEncodeDeauthen - Encode the DeAuthentication frame
- *      vMgrDecodeDeauthen - Decode the DeAuthentication frame
- *      vMgrEncodeReassocResponse - Encode the Reassociation response frame
- *      vMgrDecodeReassocResponse - Decode the Reassociation response frame
- *
- * Revision History:
- *
- */
-
-#include "tmacro.h"
-#include "tether.h"
-#include "80211mgr.h"
-#include "80211hdr.h"
-#include "device.h"
-#include "wpa.h"
-
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Functions  --------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-/*+
- *
- * Routine Description:
- * Encode Beacon frame body offset
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrEncodeBeacon(
-       PWLAN_FR_BEACON  pFrame
-)
-{
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-
-       /* Fixed Fields */
-       pFrame->pqwTimestamp = (__le64 *)
-                               (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                                WLAN_BEACON_OFF_TS);
-       pFrame->pwBeaconInterval = (unsigned short *)
-                               (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                                WLAN_BEACON_OFF_BCN_INT);
-       pFrame->pwCapInfo = (unsigned short *)
-                           (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                            WLAN_BEACON_OFF_CAPINFO);
-
-       pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_BEACON_OFF_SSID;
-}
-
-/*+
- *
- * Routine Description:
- * Decode Beacon frame body offset
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrDecodeBeacon(
-       PWLAN_FR_BEACON  pFrame
-)
-{
-       PWLAN_IE        pItem;
-
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-
-       /* Fixed Fields */
-       pFrame->pqwTimestamp = (__le64 *)
-                               (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                                WLAN_BEACON_OFF_TS);
-       pFrame->pwBeaconInterval = (unsigned short *)
-                                  (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                                   WLAN_BEACON_OFF_BCN_INT);
-       pFrame->pwCapInfo = (unsigned short *)
-                           (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                            WLAN_BEACON_OFF_CAPINFO);
-
-       /* Information elements */
-       pItem = (PWLAN_IE)((unsigned char *)
-                          (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))) +
-                           WLAN_BEACON_OFF_SSID);
-       while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
-               switch (pItem->byElementID) {
-               case WLAN_EID_SSID:
-                       if (pFrame->pSSID == NULL)
-                               pFrame->pSSID = (PWLAN_IE_SSID)pItem;
-                       break;
-               case WLAN_EID_SUPP_RATES:
-                       if (pFrame->pSuppRates == NULL)
-                               pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
-                       break;
-               case WLAN_EID_FH_PARMS:
-                       /* pFrame->pFHParms = (PWLAN_IE_FH_PARMS)pItem; */
-                       break;
-               case WLAN_EID_DS_PARMS:
-                       if (pFrame->pDSParms == NULL)
-                               pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
-                       break;
-               case WLAN_EID_CF_PARMS:
-                       if (pFrame->pCFParms == NULL)
-                               pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
-                       break;
-               case WLAN_EID_IBSS_PARMS:
-                       if (pFrame->pIBSSParms == NULL)
-                               pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
-                       break;
-               case WLAN_EID_TIM:
-                       if (pFrame->pTIM == NULL)
-                               pFrame->pTIM = (PWLAN_IE_TIM)pItem;
-                       break;
-
-               case WLAN_EID_RSN:
-                       if (pFrame->pRSN == NULL)
-                               pFrame->pRSN = (PWLAN_IE_RSN)pItem;
-                       break;
-               case WLAN_EID_RSN_WPA:
-                       if (pFrame->pRSNWPA == NULL) {
-                               if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
-                                       pFrame->pRSNWPA =
-                                                      (PWLAN_IE_RSN_EXT)pItem;
-                       }
-                       break;
-
-               case WLAN_EID_ERP:
-                       if (pFrame->pERP == NULL)
-                               pFrame->pERP = (PWLAN_IE_ERP)pItem;
-                       break;
-               case WLAN_EID_EXTSUPP_RATES:
-                       if (pFrame->pExtSuppRates == NULL)
-                               pFrame->pExtSuppRates =
-                                                   (PWLAN_IE_SUPP_RATES)pItem;
-                       break;
-
-               case WLAN_EID_COUNTRY:      /* 7 */
-                       if (pFrame->pIE_Country == NULL)
-                               pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
-                       break;
-
-               case WLAN_EID_PWR_CONSTRAINT:   /* 32 */
-                       if (pFrame->pIE_PowerConstraint == NULL)
-                               pFrame->pIE_PowerConstraint =
-                                                     (PWLAN_IE_PW_CONST)pItem;
-                       break;
-
-               case WLAN_EID_CH_SWITCH:    /* 37 */
-                       if (pFrame->pIE_CHSW == NULL)
-                               pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
-                       break;
-
-               case WLAN_EID_QUIET:        /* 40 */
-                       if (pFrame->pIE_Quiet == NULL)
-                               pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
-                       break;
-
-               case WLAN_EID_IBSS_DFS:
-                       if (pFrame->pIE_IBSSDFS == NULL)
-                               pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
-                       break;
-
-               default:
-                       pr_debug("Unrecognized EID=%dd in beacon decode\n",
-                                pItem->byElementID);
-                       break;
-
-               }
-               pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
-       }
-}
-
-/*+
- *
- * Routine Description:
- *  Encode IBSS ATIM
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrEncodeIBSSATIM(
-       PWLAN_FR_IBSSATIM   pFrame
-)
-{
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-       pFrame->len = WLAN_HDR_ADDR3_LEN;
-}
-
-/*+
- *
- * Routine Description:
- *  Decode IBSS ATIM
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrDecodeIBSSATIM(
-       PWLAN_FR_IBSSATIM   pFrame
-)
-{
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-}
-
-/*+
- *
- * Routine Description:
- *  Encode Disassociation
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrEncodeDisassociation(
-       PWLAN_FR_DISASSOC  pFrame
-)
-{
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-
-       /* Fixed Fields */
-       pFrame->pwReason = (unsigned short *)
-                          (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                           WLAN_DISASSOC_OFF_REASON);
-       pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DISASSOC_OFF_REASON +
-                     sizeof(*(pFrame->pwReason));
-}
-
-/*+
- *
- * Routine Description:
- *  Decode Disassociation
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrDecodeDisassociation(
-       PWLAN_FR_DISASSOC  pFrame
-)
-{
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-
-       /* Fixed Fields */
-       pFrame->pwReason = (unsigned short *)
-                          (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                           WLAN_DISASSOC_OFF_REASON);
-}
-
-/*+
- *
- * Routine Description:
- *  Encode Association Request
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrEncodeAssocRequest(
-       PWLAN_FR_ASSOCREQ  pFrame
-)
-{
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-       /* Fixed Fields */
-       pFrame->pwCapInfo = (unsigned short *)
-                           (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                            WLAN_ASSOCREQ_OFF_CAP_INFO);
-       pFrame->pwListenInterval = (unsigned short *)
-                                  (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                                   WLAN_ASSOCREQ_OFF_LISTEN_INT);
-       pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCREQ_OFF_LISTEN_INT +
-                     sizeof(*(pFrame->pwListenInterval));
-}
-
-/*+
- *
- * Routine Description: (AP)
- *  Decode Association Request
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrDecodeAssocRequest(
-       PWLAN_FR_ASSOCREQ  pFrame
-)
-{
-       PWLAN_IE   pItem;
-
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-       /* Fixed Fields */
-       pFrame->pwCapInfo = (unsigned short *)
-                           (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                            WLAN_ASSOCREQ_OFF_CAP_INFO);
-       pFrame->pwListenInterval = (unsigned short *)
-                                  (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                                   WLAN_ASSOCREQ_OFF_LISTEN_INT);
-
-       /* Information elements */
-       pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
-                          + WLAN_ASSOCREQ_OFF_SSID);
-
-       while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
-               switch (pItem->byElementID) {
-               case WLAN_EID_SSID:
-                       if (pFrame->pSSID == NULL)
-                               pFrame->pSSID = (PWLAN_IE_SSID)pItem;
-                       break;
-               case WLAN_EID_SUPP_RATES:
-                       if (pFrame->pSuppRates == NULL)
-                               pFrame->pSuppRates =
-                                                  (PWLAN_IE_SUPP_RATES)pItem;
-                       break;
-
-               case WLAN_EID_RSN:
-                       if (pFrame->pRSN == NULL)
-                               pFrame->pRSN = (PWLAN_IE_RSN)pItem;
-                       break;
-               case WLAN_EID_RSN_WPA:
-                       if (pFrame->pRSNWPA == NULL) {
-                               if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
-                                       pFrame->pRSNWPA =
-                                                      (PWLAN_IE_RSN_EXT)pItem;
-                       }
-                       break;
-               case WLAN_EID_EXTSUPP_RATES:
-                       if (pFrame->pExtSuppRates == NULL)
-                               pFrame->pExtSuppRates =
-                                                   (PWLAN_IE_SUPP_RATES)pItem;
-                       break;
-
-               default:
-                       pr_debug("Unrecognized EID=%dd in assocreq decode\n",
-                                pItem->byElementID);
-                       break;
-               }
-               pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
-       }
-}
-
-/*+
- *
- * Routine Description: (AP)
- *  Encode Association Response
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrEncodeAssocResponse(
-       PWLAN_FR_ASSOCRESP  pFrame
-)
-{
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-
-       /* Fixed Fields */
-       pFrame->pwCapInfo = (unsigned short *)
-                           (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                            WLAN_ASSOCRESP_OFF_CAP_INFO);
-       pFrame->pwStatus = (unsigned short *)
-                          (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                           WLAN_ASSOCRESP_OFF_STATUS);
-       pFrame->pwAid = (unsigned short *)
-                       (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                        WLAN_ASSOCRESP_OFF_AID);
-       pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCRESP_OFF_AID +
-                     sizeof(*(pFrame->pwAid));
-}
-
-/*+
- *
- * Routine Description:
- *  Decode Association Response
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrDecodeAssocResponse(
-       PWLAN_FR_ASSOCRESP  pFrame
-)
-{
-       PWLAN_IE   pItem;
-
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-
-       /* Fixed Fields */
-       pFrame->pwCapInfo = (unsigned short *)
-                           (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                            WLAN_ASSOCRESP_OFF_CAP_INFO);
-       pFrame->pwStatus = (unsigned short *)
-                          (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                           WLAN_ASSOCRESP_OFF_STATUS);
-       pFrame->pwAid = (unsigned short *)
-                       (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                        WLAN_ASSOCRESP_OFF_AID);
-
-       /* Information elements */
-       pFrame->pSuppRates  = (PWLAN_IE_SUPP_RATES)
-                             (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                              WLAN_ASSOCRESP_OFF_SUPP_RATES);
-
-       pItem = (PWLAN_IE)(pFrame->pSuppRates);
-       pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
-
-       if ((((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) &&
-           (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) {
-               pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
-               pr_debug("pFrame->pExtSuppRates=[%p]\n", pItem);
-       } else {
-               pFrame->pExtSuppRates = NULL;
-       }
-}
-
-/*+
- *
- * Routine Description:
- *  Encode Reassociation Request
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrEncodeReassocRequest(
-       PWLAN_FR_REASSOCREQ  pFrame
-)
-{
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-
-       /* Fixed Fields */
-       pFrame->pwCapInfo = (unsigned short *)
-                           (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                            WLAN_REASSOCREQ_OFF_CAP_INFO);
-       pFrame->pwListenInterval = (unsigned short *)
-                                  (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                                   WLAN_REASSOCREQ_OFF_LISTEN_INT);
-       pFrame->pAddrCurrAP = (PIEEE_ADDR)
-                             (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                              WLAN_REASSOCREQ_OFF_CURR_AP);
-       pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCREQ_OFF_CURR_AP +
-                     sizeof(*(pFrame->pAddrCurrAP));
-}
-
-/*+
- *
- * Routine Description: (AP)
- *  Decode Reassociation Request
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrDecodeReassocRequest(
-       PWLAN_FR_REASSOCREQ  pFrame
-)
-{
-       PWLAN_IE   pItem;
-
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-
-       /* Fixed Fields */
-       pFrame->pwCapInfo = (unsigned short *)
-                           (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                            WLAN_REASSOCREQ_OFF_CAP_INFO);
-       pFrame->pwListenInterval = (unsigned short *)
-                                  (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                                   WLAN_REASSOCREQ_OFF_LISTEN_INT);
-       pFrame->pAddrCurrAP = (PIEEE_ADDR)
-                             (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                              WLAN_REASSOCREQ_OFF_CURR_AP);
-
-       /* Information elements */
-       pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
-                          + WLAN_REASSOCREQ_OFF_SSID);
-
-       while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
-               switch (pItem->byElementID) {
-               case WLAN_EID_SSID:
-                       if (pFrame->pSSID == NULL)
-                               pFrame->pSSID = (PWLAN_IE_SSID)pItem;
-                       break;
-               case WLAN_EID_SUPP_RATES:
-                       if (pFrame->pSuppRates == NULL)
-                               pFrame->pSuppRates =
-                                                   (PWLAN_IE_SUPP_RATES)pItem;
-                       break;
-
-               case WLAN_EID_RSN:
-                       if (pFrame->pRSN == NULL)
-                               pFrame->pRSN = (PWLAN_IE_RSN)pItem;
-                       break;
-               case WLAN_EID_RSN_WPA:
-                       if (pFrame->pRSNWPA == NULL) {
-                               if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
-                                       pFrame->pRSNWPA =
-                                                      (PWLAN_IE_RSN_EXT)pItem;
-                       }
-                       break;
-
-               case WLAN_EID_EXTSUPP_RATES:
-                       if (pFrame->pExtSuppRates == NULL)
-                               pFrame->pExtSuppRates =
-                                                   (PWLAN_IE_SUPP_RATES)pItem;
-                       break;
-               default:
-                       pr_debug("Unrecognized EID=%dd in reassocreq decode\n",
-                                pItem->byElementID);
-                       break;
-               }
-               pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
-       }
-}
-
-/*+
- *
- * Routine Description:
- *  Encode Probe Request
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrEncodeProbeRequest(
-       PWLAN_FR_PROBEREQ  pFrame
-)
-{
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-       pFrame->len = WLAN_HDR_ADDR3_LEN;
-}
-
-/*+
- *
- * Routine Description:
- *  Decode Probe Request
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrDecodeProbeRequest(
-       PWLAN_FR_PROBEREQ  pFrame
-)
-{
-       PWLAN_IE   pItem;
-
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-
-       /* Information elements */
-       pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)));
-
-       while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
-               switch (pItem->byElementID) {
-               case WLAN_EID_SSID:
-                       if (pFrame->pSSID == NULL)
-                               pFrame->pSSID = (PWLAN_IE_SSID)pItem;
-                       break;
-
-               case WLAN_EID_SUPP_RATES:
-                       if (pFrame->pSuppRates == NULL)
-                               pFrame->pSuppRates =
-                                                  (PWLAN_IE_SUPP_RATES)pItem;
-                       break;
-
-               case WLAN_EID_EXTSUPP_RATES:
-                       if (pFrame->pExtSuppRates == NULL)
-                               pFrame->pExtSuppRates =
-                                                   (PWLAN_IE_SUPP_RATES)pItem;
-                       break;
-
-               default:
-                       pr_debug("Bad EID=%dd in probereq\n",
-                                pItem->byElementID);
-                       break;
-               }
-
-               pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 +  pItem->len);
-       }
-}
-
-/*+
- *
- * Routine Description:
- *  Encode Probe Response
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrEncodeProbeResponse(
-       PWLAN_FR_PROBERESP  pFrame
-)
-{
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-
-       /* Fixed Fields */
-       pFrame->pqwTimestamp = (__le64 *)
-                              (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                               WLAN_PROBERESP_OFF_TS);
-       pFrame->pwBeaconInterval = (unsigned short *)
-                                  (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                                   WLAN_PROBERESP_OFF_BCN_INT);
-       pFrame->pwCapInfo = (unsigned short *)
-                           (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                            WLAN_PROBERESP_OFF_CAP_INFO);
-
-       pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_PROBERESP_OFF_CAP_INFO +
-                     sizeof(*(pFrame->pwCapInfo));
-}
-
-/*+
- *
- * Routine Description:
- *  Decode Probe Response
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrDecodeProbeResponse(
-       PWLAN_FR_PROBERESP  pFrame
-)
-{
-       PWLAN_IE    pItem;
-
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-
-       /* Fixed Fields */
-       pFrame->pqwTimestamp = (__le64 *)
-                              (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                               WLAN_PROBERESP_OFF_TS);
-       pFrame->pwBeaconInterval = (unsigned short *)
-                                  (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                                   WLAN_PROBERESP_OFF_BCN_INT);
-       pFrame->pwCapInfo = (unsigned short *)
-                           (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                            WLAN_PROBERESP_OFF_CAP_INFO);
-
-       /* Information elements */
-       pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
-                          + WLAN_PROBERESP_OFF_SSID);
-
-       while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
-               switch (pItem->byElementID) {
-               case WLAN_EID_SSID:
-                       if (pFrame->pSSID == NULL)
-                               pFrame->pSSID = (PWLAN_IE_SSID)pItem;
-                       break;
-               case WLAN_EID_SUPP_RATES:
-                       if (pFrame->pSuppRates == NULL)
-                               pFrame->pSuppRates =
-                                                  (PWLAN_IE_SUPP_RATES)pItem;
-                       break;
-               case WLAN_EID_FH_PARMS:
-                       break;
-               case WLAN_EID_DS_PARMS:
-                       if (pFrame->pDSParms == NULL)
-                               pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
-                       break;
-               case WLAN_EID_CF_PARMS:
-                       if (pFrame->pCFParms == NULL)
-                               pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
-                       break;
-               case WLAN_EID_IBSS_PARMS:
-                       if (pFrame->pIBSSParms == NULL)
-                               pFrame->pIBSSParms =
-                                                  (PWLAN_IE_IBSS_PARMS)pItem;
-                       break;
-
-               case WLAN_EID_RSN:
-                       if (pFrame->pRSN == NULL)
-                               pFrame->pRSN = (PWLAN_IE_RSN)pItem;
-                       break;
-               case WLAN_EID_RSN_WPA:
-                       if (pFrame->pRSNWPA == NULL) {
-                               if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
-                                       pFrame->pRSNWPA =
-                                                      (PWLAN_IE_RSN_EXT)pItem;
-                       }
-                       break;
-               case WLAN_EID_ERP:
-                       if (pFrame->pERP == NULL)
-                               pFrame->pERP = (PWLAN_IE_ERP)pItem;
-                       break;
-               case WLAN_EID_EXTSUPP_RATES:
-                       if (pFrame->pExtSuppRates == NULL)
-                               pFrame->pExtSuppRates =
-                                                   (PWLAN_IE_SUPP_RATES)pItem;
-                       break;
-
-               case WLAN_EID_COUNTRY:      /* 7 */
-                       if (pFrame->pIE_Country == NULL)
-                               pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
-                       break;
-
-               case WLAN_EID_PWR_CONSTRAINT:   /* 32 */
-                       if (pFrame->pIE_PowerConstraint == NULL)
-                               pFrame->pIE_PowerConstraint =
-                                                     (PWLAN_IE_PW_CONST)pItem;
-                       break;
-
-               case WLAN_EID_CH_SWITCH:    /* 37 */
-                       if (pFrame->pIE_CHSW == NULL)
-                               pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
-                       break;
-
-               case WLAN_EID_QUIET:        /* 40 */
-                       if (pFrame->pIE_Quiet == NULL)
-                               pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
-                       break;
-
-               case WLAN_EID_IBSS_DFS:
-                       if (pFrame->pIE_IBSSDFS == NULL)
-                               pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
-                       break;
-
-               default:
-                       pr_debug("Bad EID=%dd in proberesp\n",
-                                pItem->byElementID);
-                       break;
-               }
-
-               pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 +  pItem->len);
-       }
-}
-
-/*+
- *
- * Routine Description:
- *     Encode Authentication frame
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrEncodeAuthen(
-       PWLAN_FR_AUTHEN  pFrame
-)
-{
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-
-       /* Fixed Fields */
-       pFrame->pwAuthAlgorithm = (unsigned short *)
-                                 (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                                  WLAN_AUTHEN_OFF_AUTH_ALG);
-       pFrame->pwAuthSequence = (unsigned short *)
-                                (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                                 WLAN_AUTHEN_OFF_AUTH_SEQ);
-       pFrame->pwStatus = (unsigned short *)
-                          (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                           WLAN_AUTHEN_OFF_STATUS);
-       pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_AUTHEN_OFF_STATUS +
-                     sizeof(*(pFrame->pwStatus));
-}
-
-/*+
- *
- * Routine Description:
- *   Decode Authentication
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrDecodeAuthen(
-       PWLAN_FR_AUTHEN  pFrame
-)
-{
-       PWLAN_IE    pItem;
-
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-
-       /* Fixed Fields */
-       pFrame->pwAuthAlgorithm = (unsigned short *)
-                                 (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                                  WLAN_AUTHEN_OFF_AUTH_ALG);
-       pFrame->pwAuthSequence = (unsigned short *)
-                                (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                                 WLAN_AUTHEN_OFF_AUTH_SEQ);
-       pFrame->pwStatus = (unsigned short *)
-                          (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                           WLAN_AUTHEN_OFF_STATUS);
-
-       /* Information elements */
-       pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
-                          + WLAN_AUTHEN_OFF_CHALLENGE);
-
-       if (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len) &&
-           pItem->byElementID == WLAN_EID_CHALLENGE)
-               pFrame->pChallenge = (PWLAN_IE_CHALLENGE)pItem;
-}
-
-/*+
- *
- * Routine Description:
- *   Encode Authentication
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrEncodeDeauthen(
-       PWLAN_FR_DEAUTHEN  pFrame
-)
-{
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-
-       /* Fixed Fields */
-       pFrame->pwReason = (unsigned short *)
-                          (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                           WLAN_DEAUTHEN_OFF_REASON);
-       pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DEAUTHEN_OFF_REASON +
-                     sizeof(*(pFrame->pwReason));
-}
-
-/*+
- *
- * Routine Description:
- *   Decode Deauthentication
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrDecodeDeauthen(
-       PWLAN_FR_DEAUTHEN  pFrame
-)
-{
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-
-       /* Fixed Fields */
-       pFrame->pwReason = (unsigned short *)
-                          (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                           WLAN_DEAUTHEN_OFF_REASON);
-}
-
-/*+
- *
- * Routine Description: (AP)
- *   Encode Reassociation Response
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrEncodeReassocResponse(
-       PWLAN_FR_REASSOCRESP  pFrame
-)
-{
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-
-       /* Fixed Fields */
-       pFrame->pwCapInfo = (unsigned short *)
-                           (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                            WLAN_REASSOCRESP_OFF_CAP_INFO);
-       pFrame->pwStatus = (unsigned short *)
-                          (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                           WLAN_REASSOCRESP_OFF_STATUS);
-       pFrame->pwAid = (unsigned short *)
-                       (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                        WLAN_REASSOCRESP_OFF_AID);
-
-       pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCRESP_OFF_AID +
-                     sizeof(*(pFrame->pwAid));
-}
-
-/*+
- *
- * Routine Description:
- *   Decode Reassociation Response
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrDecodeReassocResponse(
-       PWLAN_FR_REASSOCRESP  pFrame
-)
-{
-       PWLAN_IE   pItem;
-
-       pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
-
-       /* Fixed Fields */
-       pFrame->pwCapInfo = (unsigned short *)
-                           (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                            WLAN_REASSOCRESP_OFF_CAP_INFO);
-       pFrame->pwStatus = (unsigned short *)
-                          (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                           WLAN_REASSOCRESP_OFF_STATUS);
-       pFrame->pwAid = (unsigned short *)
-                       (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                        WLAN_REASSOCRESP_OFF_AID);
-
-       /* Information elements */
-       pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)
-                            (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
-                             WLAN_REASSOCRESP_OFF_SUPP_RATES);
-
-       pItem = (PWLAN_IE)(pFrame->pSuppRates);
-       pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
-
-       if ((((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) &&
-           (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) {
-               pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
-       }
-}
diff --git a/drivers/staging/vt6655/80211mgr.h b/drivers/staging/vt6655/80211mgr.h
deleted file mode 100644 (file)
index d462a8a..0000000
+++ /dev/null
@@ -1,725 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: 80211mgr.h
- *
- * Purpose: 802.11 management frames pre-defines.
- *
- *
- * Author: Lyndon Chen
- *
- * Date: May 8, 2002
- *
- */
-
-#ifndef __80211MGR_H__
-#define __80211MGR_H__
-
-#include <linux/types.h>
-#include "linux/ieee80211.h"
-
-#include "ttype.h"
-#include "80211hdr.h"
-
-#define WLAN_MIN_ARRAY          1
-
-/* Information Element ID value */
-#define WLAN_EID_FH_PARMS       2
-#define WLAN_EID_DS_PARMS       3
-#define WLAN_EID_CF_PARMS       4
-#define WLAN_EID_IBSS_PARMS     6
-#define WLAN_EID_TPC_REQ        34
-#define WLAN_EID_TPC_REP        35
-#define WLAN_EID_SUPP_CH        36
-#define WLAN_EID_CH_SWITCH      37
-#define WLAN_EID_MEASURE_REQ    38
-#define WLAN_EID_MEASURE_REP    39
-#define WLAN_EID_QUIET          40
-#define WLAN_EID_IBSS_DFS       41
-#define WLAN_EID_ERP            42
-/* reference 802.11i 7.3.2 table 20 */
-#define WLAN_EID_EXTSUPP_RATES  50
-/* reference WiFi WPA spec. */
-#define WLAN_EID_RSN_WPA        221
-
-#define WLAN_EID_ERP_NONERP_PRESENT             0x01
-#define WLAN_EID_ERP_USE_PROTECTION             0x02
-#define WLAN_EID_ERP_BARKER_MODE                0x04
-
-/* Reason Codes */
-#define WLAN_MGMT_REASON_RSVD                       0
-#define WLAN_MGMT_REASON_UNSPEC                     1
-#define WLAN_MGMT_REASON_PRIOR_AUTH_INVALID         2
-#define WLAN_MGMT_REASON_DEAUTH_LEAVING             3
-#define WLAN_MGMT_REASON_DISASSOC_INACTIVE          4
-#define WLAN_MGMT_REASON_DISASSOC_AP_BUSY           5
-#define WLAN_MGMT_REASON_CLASS2_NONAUTH             6
-#define WLAN_MGMT_REASON_CLASS3_NONASSOC            7
-#define WLAN_MGMT_REASON_DISASSOC_STA_HASLEFT       8
-#define WLAN_MGMT_REASON_CANT_ASSOC_NONAUTH         9
-#define WLAN_MGMT_REASON_DISASSOC_PWR_CAP_UNACCEPT      10
-#define WLAN_MGMT_REASON_DISASSOC_SUPP_CH_UNACCEPT      11
-#define WLAN_MGMT_REASON_INVALID_IE                 13
-#define WLAN_MGMT_REASON_MIC_FAILURE                14
-#define WLAN_MGMT_REASON_4WAY_HANDSHAKE_TIMEOUT     15
-#define WLAN_MGMT_REASON_GRPKEY_UPDATE_TIMEOUT      16
-#define WLAN_MGMT_REASON_4WAY_INFO_DIFFERENT        17
-#define WLAN_MGMT_REASON_MULTCAST_CIPHER_INVALID    18
-#define WLAN_MGMT_REASON_UNCAST_CIPHER_INVALID      19
-#define WLAN_MGMT_REASON_AKMP_INVALID               20
-#define WLAN_MGMT_REASON_RSNE_UNSUPPORTED           21
-#define WLAN_MGMT_REASON_RSNE_CAP_INVALID           22
-#define WLAN_MGMT_REASON_80211X_AUTH_FAILED         23
-
-/* Status Codes */
-#define WLAN_MGMT_STATUS_SUCCESS                        0
-#define WLAN_MGMT_STATUS_UNSPEC_FAILURE                 1
-#define WLAN_MGMT_STATUS_CAPS_UNSUPPORTED               10
-#define WLAN_MGMT_STATUS_REASSOC_NO_ASSOC               11
-#define WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC            12
-#define WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG            13
-#define WLAN_MGMT_STATUS_RX_AUTH_NOSEQ                  14
-#define WLAN_MGMT_STATUS_CHALLENGE_FAIL                 15
-#define WLAN_MGMT_STATUS_AUTH_TIMEOUT                   16
-#define WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY              17
-#define WLAN_MGMT_STATUS_ASSOC_DENIED_RATES             18
-#define WLAN_MGMT_STATUS_ASSOC_DENIED_SHORTPREAMBLE     19
-#define WLAN_MGMT_STATUS_ASSOC_DENIED_PBCC              20
-#define WLAN_MGMT_STATUS_ASSOC_DENIED_AGILITY           21
-
-/* reference 802.11h 7.3.1.9 */
-#define WLAN_MGMT_STATUS_ASSOC_REJECT_BCS_SPECTRUM_MNG  22
-#define WLAN_MGMT_STATUS_ASSOC_REJECT_BCS_PWR_CAP       23
-#define WLAN_MGMT_STATUS_ASSOC_REJECT_BCS_SUPP_CH       24
-/* reference 802.11g 7.3.1.9 */
-#define WLAN_MGMT_STATUS_SHORTSLOTTIME_UNSUPPORTED      25
-#define WLAN_MGMT_STATUS_DSSSOFDM_UNSUPPORTED           26
-/* reference 802.11i 3.7.1.9 table 19 */
-#define WLAN_MGMT_STATUS_INVALID_IE                     40
-#define WLAN_MGMT_STATUS_GROUP_CIPHER_INVALID           41
-#define WLAN_MGMT_STATUS_PAIRWISE_CIPHER_INVALID        42
-#define WLAN_MGMT_STATUS_AKMP_INVALID                   43
-#define WLAN_MGMT_STATUS_UNSUPPORT_RSN_IE_VER           44
-#define WLAN_MGMT_STATUS_INVALID_RSN_IE_CAP             45
-#define WLAN_MGMT_STATUS_CIPHER_REJECT                  46
-
-/* Auth Algorithm */
-#define WLAN_AUTH_ALG_OPENSYSTEM                0
-#define WLAN_AUTH_ALG_SHAREDKEY                 1
-
-/* Management Frame Field Offsets */
-/* Note: Not all fields are listed because of variable lengths. */
-/* Note: These offsets are from the start of the frame data */
-
-#define WLAN_BEACON_OFF_TS                  0
-#define WLAN_BEACON_OFF_BCN_INT             8
-#define WLAN_BEACON_OFF_CAPINFO             10
-#define WLAN_BEACON_OFF_SSID                12
-
-#define WLAN_DISASSOC_OFF_REASON            0
-
-#define WLAN_ASSOCREQ_OFF_CAP_INFO          0
-#define WLAN_ASSOCREQ_OFF_LISTEN_INT        2
-#define WLAN_ASSOCREQ_OFF_SSID              4
-
-#define WLAN_ASSOCRESP_OFF_CAP_INFO         0
-#define WLAN_ASSOCRESP_OFF_STATUS           2
-#define WLAN_ASSOCRESP_OFF_AID              4
-#define WLAN_ASSOCRESP_OFF_SUPP_RATES       6
-
-#define WLAN_REASSOCREQ_OFF_CAP_INFO        0
-#define WLAN_REASSOCREQ_OFF_LISTEN_INT      2
-#define WLAN_REASSOCREQ_OFF_CURR_AP         4
-#define WLAN_REASSOCREQ_OFF_SSID            10
-
-#define WLAN_REASSOCRESP_OFF_CAP_INFO       0
-#define WLAN_REASSOCRESP_OFF_STATUS         2
-#define WLAN_REASSOCRESP_OFF_AID            4
-#define WLAN_REASSOCRESP_OFF_SUPP_RATES     6
-
-#define WLAN_PROBEREQ_OFF_SSID              0
-
-#define WLAN_PROBERESP_OFF_TS               0
-#define WLAN_PROBERESP_OFF_BCN_INT          8
-#define WLAN_PROBERESP_OFF_CAP_INFO         10
-#define WLAN_PROBERESP_OFF_SSID             12
-
-#define WLAN_AUTHEN_OFF_AUTH_ALG            0
-#define WLAN_AUTHEN_OFF_AUTH_SEQ            2
-#define WLAN_AUTHEN_OFF_STATUS              4
-#define WLAN_AUTHEN_OFF_CHALLENGE           6
-
-#define WLAN_DEAUTHEN_OFF_REASON            0
-
-/* Cipher Suite Selectors defined in 802.11i */
-#define WLAN_11i_CSS_USE_GROUP              0
-#define WLAN_11i_CSS_WEP40                  1
-#define WLAN_11i_CSS_TKIP                   2
-#define WLAN_11i_CSS_CCMP                   4
-#define WLAN_11i_CSS_WEP104                 5
-#define WLAN_11i_CSS_UNKNOWN                255
-
-/* Authentication and Key Management Suite Selectors defined in 802.11i */
-#define WLAN_11i_AKMSS_802_1X               1
-#define WLAN_11i_AKMSS_PSK                  2
-#define WLAN_11i_AKMSS_UNKNOWN              255
-
-/* Measurement type definitions reference ieee 802.11h Table 20b */
-#define MEASURE_TYPE_BASIC      0
-#define MEASURE_TYPE_CCA        1
-#define MEASURE_TYPE_RPI        2
-
-/* Measurement request mode definitions reference ieee 802.11h Figure 46h */
-#define MEASURE_MODE_ENABLE     0x02
-#define MEASURE_MODE_REQ        0x04
-#define MEASURE_MODE_REP        0x08
-
-/* Measurement report mode definitions reference ieee 802.11h Figure 46m */
-#define MEASURE_MODE_LATE       0x01
-#define MEASURE_MODE_INCAPABLE  0x02
-#define MEASURE_MODE_REFUSED    0x04
-
-/* Information Element Types */
-
-#pragma pack(1)
-typedef struct tagWLAN_IE {
-       unsigned char byElementID;
-       unsigned char len;
-} __attribute__ ((__packed__))
-WLAN_IE, *PWLAN_IE;
-
-/* Service Set Identity (SSID) */
-#pragma pack(1)
-typedef struct tagWLAN_IE_SSID {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned char abySSID[1];
-} __attribute__ ((__packed__))
-WLAN_IE_SSID, *PWLAN_IE_SSID;
-
-/* Supported Rates */
-#pragma pack(1)
-typedef struct tagWLAN_IE_SUPP_RATES {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned char abyRates[1];
-} __attribute__ ((__packed__))
-WLAN_IE_SUPP_RATES,  *PWLAN_IE_SUPP_RATES;
-
-/* FH Parameter Set */
-#pragma pack(1)
-typedef struct _WLAN_IE_FH_PARMS {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned short wDwellTime;
-       unsigned char byHopSet;
-       unsigned char byHopPattern;
-       unsigned char byHopIndex;
-} WLAN_IE_FH_PARMS,  *PWLAN_IE_FH_PARMS;
-
-/* DS Parameter Set */
-#pragma pack(1)
-typedef struct tagWLAN_IE_DS_PARMS {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned char byCurrChannel;
-} __attribute__ ((__packed__))
-WLAN_IE_DS_PARMS,  *PWLAN_IE_DS_PARMS;
-
-/* CF Parameter Set */
-#pragma pack(1)
-typedef struct tagWLAN_IE_CF_PARMS {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned char byCFPCount;
-       unsigned char byCFPPeriod;
-       unsigned short wCFPMaxDuration;
-       unsigned short wCFPDurRemaining;
-} __attribute__ ((__packed__))
-WLAN_IE_CF_PARMS,  *PWLAN_IE_CF_PARMS;
-
-/* TIM */
-#pragma pack(1)
-typedef struct tagWLAN_IE_TIM {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned char byDTIMCount;
-       unsigned char byDTIMPeriod;
-       unsigned char byBitMapCtl;
-       unsigned char byVirtBitMap[1];
-} __attribute__ ((__packed__))
-WLAN_IE_TIM,  *PWLAN_IE_TIM;
-
-/* IBSS Parameter Set */
-#pragma pack(1)
-typedef struct tagWLAN_IE_IBSS_PARMS {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned short wATIMWindow;
-} __attribute__ ((__packed__))
-WLAN_IE_IBSS_PARMS, *PWLAN_IE_IBSS_PARMS;
-
-/* Challenge Text */
-#pragma pack(1)
-typedef struct tagWLAN_IE_CHALLENGE {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned char abyChallenge[1];
-} __attribute__ ((__packed__))
-WLAN_IE_CHALLENGE,  *PWLAN_IE_CHALLENGE;
-
-#pragma pack(1)
-typedef struct tagWLAN_IE_RSN_EXT {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned char abyOUI[4];
-       unsigned short wVersion;
-       unsigned char abyMulticast[4];
-       unsigned short wPKCount;
-       struct {
-               unsigned char abyOUI[4];
-       } PKSList[1]; /* the rest is variable so need to */
-       /* overlay ieauth structure */
-} WLAN_IE_RSN_EXT, *PWLAN_IE_RSN_EXT;
-
-#pragma pack(1)
-typedef struct tagWLAN_IE_RSN_AUTH {
-       unsigned short wAuthCount;
-       struct {
-               unsigned char abyOUI[4];
-       } AuthKSList[1];
-} WLAN_IE_RSN_AUTH, *PWLAN_IE_RSN_AUTH;
-
-/* RSN Identity */
-#pragma pack(1)
-typedef struct tagWLAN_IE_RSN {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned short wVersion;
-       unsigned char abyRSN[WLAN_MIN_ARRAY];
-} WLAN_IE_RSN, *PWLAN_IE_RSN;
-
-/* ERP */
-#pragma pack(1)
-typedef struct tagWLAN_IE_ERP {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned char byContext;
-} __attribute__ ((__packed__))
-WLAN_IE_ERP,  *PWLAN_IE_ERP;
-
-#pragma pack(1)
-typedef struct _MEASEURE_REQ {
-       unsigned char byChannel;
-       unsigned char abyStartTime[8];
-       unsigned char abyDuration[2];
-} MEASEURE_REQ, *PMEASEURE_REQ,
-       MEASEURE_REQ_BASIC, *PMEASEURE_REQ_BASIC,
-       MEASEURE_REQ_CCA, *PMEASEURE_REQ_CCA,
-       MEASEURE_REQ_RPI, *PMEASEURE_REQ_RPI;
-
-typedef struct _MEASEURE_REP_BASIC {
-       unsigned char byChannel;
-       unsigned char abyStartTime[8];
-       unsigned char abyDuration[2];
-       unsigned char byMap;
-} MEASEURE_REP_BASIC, *PMEASEURE_REP_BASIC;
-
-typedef struct _MEASEURE_REP_CCA {
-       unsigned char byChannel;
-       unsigned char abyStartTime[8];
-       unsigned char abyDuration[2];
-       unsigned char byCCABusyFraction;
-} MEASEURE_REP_CCA, *PMEASEURE_REP_CCA;
-
-typedef struct _MEASEURE_REP_RPI {
-       unsigned char byChannel;
-       unsigned char abyStartTime[8];
-       unsigned char abyDuration[2];
-       unsigned char abyRPIdensity[8];
-} MEASEURE_REP_RPI, *PMEASEURE_REP_RPI;
-
-typedef union _MEASEURE_REP {
-       MEASEURE_REP_BASIC  sBasic;
-       MEASEURE_REP_CCA    sCCA;
-       MEASEURE_REP_RPI    sRPI;
-} MEASEURE_REP, *PMEASEURE_REP;
-
-typedef struct _WLAN_IE_MEASURE_REQ {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned char byToken;
-       unsigned char byMode;
-       unsigned char byType;
-       MEASEURE_REQ        sReq;
-} WLAN_IE_MEASURE_REQ, *PWLAN_IE_MEASURE_REQ;
-
-typedef struct _WLAN_IE_MEASURE_REP {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned char byToken;
-       unsigned char byMode;
-       unsigned char byType;
-       MEASEURE_REP        sRep;
-} WLAN_IE_MEASURE_REP, *PWLAN_IE_MEASURE_REP;
-
-typedef struct _WLAN_IE_CH_SW {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned char byMode;
-       unsigned char byChannel;
-       unsigned char byCount;
-} WLAN_IE_CH_SW, *PWLAN_IE_CH_SW;
-
-typedef struct _WLAN_IE_QUIET {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned char byQuietCount;
-       unsigned char byQuietPeriod;
-       unsigned char abyQuietDuration[2];
-       unsigned char abyQuietOffset[2];
-} WLAN_IE_QUIET, *PWLAN_IE_QUIET;
-
-typedef struct _WLAN_IE_COUNTRY {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned char abyCountryString[3];
-       unsigned char abyCountryInfo[3];
-} WLAN_IE_COUNTRY, *PWLAN_IE_COUNTRY;
-
-typedef struct _WLAN_IE_PW_CONST {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned char byPower;
-} WLAN_IE_PW_CONST, *PWLAN_IE_PW_CONST;
-
-typedef struct _WLAN_IE_PW_CAP {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned char byMinPower;
-       unsigned char byMaxPower;
-} WLAN_IE_PW_CAP, *PWLAN_IE_PW_CAP;
-
-typedef struct _WLAN_IE_SUPP_CH {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned char abyChannelTuple[2];
-} WLAN_IE_SUPP_CH, *PWLAN_IE_SUPP_CH;
-
-typedef struct _WLAN_IE_TPC_REQ {
-       unsigned char byElementID;
-       unsigned char len;
-} WLAN_IE_TPC_REQ, *PWLAN_IE_TPC_REQ;
-
-typedef struct _WLAN_IE_TPC_REP {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned char byTxPower;
-       unsigned char byLinkMargin;
-} WLAN_IE_TPC_REP, *PWLAN_IE_TPC_REP;
-
-typedef struct _WLAN_IE_IBSS_DFS {
-       unsigned char byElementID;
-       unsigned char len;
-       unsigned char abyDFSOwner[6];
-       unsigned char byDFSRecovery;
-       unsigned char abyChannelMap[2];
-} WLAN_IE_IBSS_DFS, *PWLAN_IE_IBSS_DFS;
-
-#pragma pack()
-
-/* Frame Types */
-/* prototype structure, all mgmt frame types will start with these members */
-typedef struct tagWLAN_FR_MGMT {
-       unsigned int    uType;
-       unsigned int    len;
-       unsigned char *pBuf;
-       PUWLAN_80211HDR       pHdr;
-} WLAN_FR_MGMT,  *PWLAN_FR_MGMT;
-
-/* Beacon frame */
-typedef struct tagWLAN_FR_BEACON {
-       unsigned int    uType;
-       unsigned int    len;
-       unsigned char *pBuf;
-       PUWLAN_80211HDR         pHdr;
-       __le64 *pqwTimestamp;
-       unsigned short *pwBeaconInterval;
-       unsigned short *pwCapInfo;
-       PWLAN_IE_SSID           pSSID;
-       PWLAN_IE_SUPP_RATES     pSuppRates;
-       PWLAN_IE_DS_PARMS       pDSParms;
-       PWLAN_IE_CF_PARMS       pCFParms;
-       PWLAN_IE_TIM            pTIM;
-       PWLAN_IE_IBSS_PARMS     pIBSSParms;
-       PWLAN_IE_RSN            pRSN;
-       PWLAN_IE_RSN_EXT        pRSNWPA;
-       PWLAN_IE_ERP            pERP;
-       PWLAN_IE_SUPP_RATES     pExtSuppRates;
-       PWLAN_IE_COUNTRY        pIE_Country;
-       PWLAN_IE_PW_CONST       pIE_PowerConstraint;
-       PWLAN_IE_CH_SW          pIE_CHSW;
-       PWLAN_IE_IBSS_DFS       pIE_IBSSDFS;
-       PWLAN_IE_QUIET          pIE_Quiet;
-} WLAN_FR_BEACON, *PWLAN_FR_BEACON;
-
-/* IBSS ATIM frame */
-typedef struct tagWLAN_FR_IBSSATIM {
-       unsigned int    uType;
-       unsigned int    len;
-       unsigned char *pBuf;
-       PUWLAN_80211HDR         pHdr;
-} WLAN_FR_IBSSATIM, *PWLAN_FR_IBSSATIM;
-
-/* Disassociation */
-typedef struct tagWLAN_FR_DISASSOC {
-       unsigned int    uType;
-       unsigned int    len;
-       unsigned char *pBuf;
-       PUWLAN_80211HDR         pHdr;
-       unsigned short *pwReason;
-} WLAN_FR_DISASSOC, *PWLAN_FR_DISASSOC;
-
-/* Association Request */
-typedef struct tagWLAN_FR_ASSOCREQ {
-       unsigned int    uType;
-       unsigned int    len;
-       unsigned char *pBuf;
-       PUWLAN_80211HDR         pHdr;
-       unsigned short *pwCapInfo;
-       unsigned short *pwListenInterval;
-       PWLAN_IE_SSID           pSSID;
-       PWLAN_IE_SUPP_RATES     pSuppRates;
-       PWLAN_IE_RSN            pRSN;
-       PWLAN_IE_RSN_EXT        pRSNWPA;
-       PWLAN_IE_SUPP_RATES     pExtSuppRates;
-       PWLAN_IE_PW_CAP         pCurrPowerCap;
-       PWLAN_IE_SUPP_CH        pCurrSuppCh;
-} WLAN_FR_ASSOCREQ, *PWLAN_FR_ASSOCREQ;
-
-/* Association Response */
-typedef struct tagWLAN_FR_ASSOCRESP {
-       unsigned int    uType;
-       unsigned int    len;
-       unsigned char *pBuf;
-       PUWLAN_80211HDR         pHdr;
-       unsigned short *pwCapInfo;
-       unsigned short *pwStatus;
-       unsigned short *pwAid;
-       PWLAN_IE_SUPP_RATES     pSuppRates;
-       PWLAN_IE_SUPP_RATES     pExtSuppRates;
-} WLAN_FR_ASSOCRESP, *PWLAN_FR_ASSOCRESP;
-
-/* Reassociation Request */
-typedef struct tagWLAN_FR_REASSOCREQ {
-       unsigned int    uType;
-       unsigned int    len;
-       unsigned char *pBuf;
-       PUWLAN_80211HDR         pHdr;
-       unsigned short *pwCapInfo;
-       unsigned short *pwListenInterval;
-       PIEEE_ADDR              pAddrCurrAP;
-       PWLAN_IE_SSID           pSSID;
-       PWLAN_IE_SUPP_RATES     pSuppRates;
-       PWLAN_IE_RSN            pRSN;
-       PWLAN_IE_RSN_EXT        pRSNWPA;
-       PWLAN_IE_SUPP_RATES     pExtSuppRates;
-} WLAN_FR_REASSOCREQ, *PWLAN_FR_REASSOCREQ;
-
-/* Reassociation Response */
-typedef struct tagWLAN_FR_REASSOCRESP {
-       unsigned int    uType;
-       unsigned int    len;
-       unsigned char *pBuf;
-       PUWLAN_80211HDR         pHdr;
-       unsigned short *pwCapInfo;
-       unsigned short *pwStatus;
-       unsigned short *pwAid;
-       PWLAN_IE_SUPP_RATES     pSuppRates;
-       PWLAN_IE_SUPP_RATES     pExtSuppRates;
-} WLAN_FR_REASSOCRESP, *PWLAN_FR_REASSOCRESP;
-
-/* Probe Request */
-typedef struct tagWLAN_FR_PROBEREQ {
-       unsigned int    uType;
-       unsigned int    len;
-       unsigned char *pBuf;
-       PUWLAN_80211HDR         pHdr;
-       PWLAN_IE_SSID           pSSID;
-       PWLAN_IE_SUPP_RATES     pSuppRates;
-       PWLAN_IE_SUPP_RATES     pExtSuppRates;
-} WLAN_FR_PROBEREQ, *PWLAN_FR_PROBEREQ;
-
-/* Probe Response */
-typedef struct tagWLAN_FR_PROBERESP {
-       unsigned int    uType;
-       unsigned int    len;
-       unsigned char *pBuf;
-       PUWLAN_80211HDR         pHdr;
-       __le64 *pqwTimestamp;
-       unsigned short *pwBeaconInterval;
-       unsigned short *pwCapInfo;
-       PWLAN_IE_SSID           pSSID;
-       PWLAN_IE_SUPP_RATES     pSuppRates;
-       PWLAN_IE_DS_PARMS       pDSParms;
-       PWLAN_IE_CF_PARMS       pCFParms;
-       PWLAN_IE_IBSS_PARMS     pIBSSParms;
-       PWLAN_IE_RSN            pRSN;
-       PWLAN_IE_RSN_EXT        pRSNWPA;
-       PWLAN_IE_ERP            pERP;
-       PWLAN_IE_SUPP_RATES     pExtSuppRates;
-       PWLAN_IE_COUNTRY        pIE_Country;
-       PWLAN_IE_PW_CONST       pIE_PowerConstraint;
-       PWLAN_IE_CH_SW          pIE_CHSW;
-       PWLAN_IE_IBSS_DFS       pIE_IBSSDFS;
-       PWLAN_IE_QUIET          pIE_Quiet;
-} WLAN_FR_PROBERESP, *PWLAN_FR_PROBERESP;
-
-/* Authentication */
-typedef struct tagWLAN_FR_AUTHEN {
-       unsigned int    uType;
-       unsigned int    len;
-       unsigned char *pBuf;
-       PUWLAN_80211HDR         pHdr;
-       unsigned short *pwAuthAlgorithm;
-       unsigned short *pwAuthSequence;
-       unsigned short *pwStatus;
-       PWLAN_IE_CHALLENGE      pChallenge;
-} WLAN_FR_AUTHEN, *PWLAN_FR_AUTHEN;
-
-/* Deauthenication */
-typedef struct tagWLAN_FR_DEAUTHEN {
-       unsigned int    uType;
-       unsigned int    len;
-       unsigned char *pBuf;
-       PUWLAN_80211HDR         pHdr;
-       unsigned short *pwReason;
-} WLAN_FR_DEAUTHEN, *PWLAN_FR_DEAUTHEN;
-
-void
-vMgrEncodeBeacon(
-       PWLAN_FR_BEACON  pFrame
-);
-
-void
-vMgrDecodeBeacon(
-       PWLAN_FR_BEACON  pFrame
-);
-
-void
-vMgrEncodeIBSSATIM(
-       PWLAN_FR_IBSSATIM   pFrame
-);
-
-void
-vMgrDecodeIBSSATIM(
-       PWLAN_FR_IBSSATIM   pFrame
-);
-
-void
-vMgrEncodeDisassociation(
-       PWLAN_FR_DISASSOC  pFrame
-);
-
-void
-vMgrDecodeDisassociation(
-       PWLAN_FR_DISASSOC  pFrame
-);
-
-void
-vMgrEncodeAssocRequest(
-       PWLAN_FR_ASSOCREQ  pFrame
-);
-
-void
-vMgrDecodeAssocRequest(
-       PWLAN_FR_ASSOCREQ  pFrame
-);
-
-void
-vMgrEncodeAssocResponse(
-       PWLAN_FR_ASSOCRESP  pFrame
-);
-
-void
-vMgrDecodeAssocResponse(
-       PWLAN_FR_ASSOCRESP  pFrame
-);
-
-void
-vMgrEncodeReassocRequest(
-       PWLAN_FR_REASSOCREQ  pFrame
-);
-
-void
-vMgrDecodeReassocRequest(
-       PWLAN_FR_REASSOCREQ  pFrame
-);
-
-void
-vMgrEncodeProbeRequest(
-       PWLAN_FR_PROBEREQ  pFrame
-);
-
-void
-vMgrDecodeProbeRequest(
-       PWLAN_FR_PROBEREQ  pFrame
-);
-
-void
-vMgrEncodeProbeResponse(
-       PWLAN_FR_PROBERESP  pFrame
-);
-
-void
-vMgrDecodeProbeResponse(
-       PWLAN_FR_PROBERESP  pFrame
-);
-
-void
-vMgrEncodeAuthen(
-       PWLAN_FR_AUTHEN  pFrame
-);
-
-void
-vMgrDecodeAuthen(
-       PWLAN_FR_AUTHEN  pFrame
-);
-
-void
-vMgrEncodeDeauthen(
-       PWLAN_FR_DEAUTHEN  pFrame
-);
-
-void
-vMgrDecodeDeauthen(
-       PWLAN_FR_DEAUTHEN  pFrame
-);
-
-void
-vMgrEncodeReassocResponse(
-       PWLAN_FR_REASSOCRESP  pFrame
-);
-
-void
-vMgrDecodeReassocResponse(
-       PWLAN_FR_REASSOCRESP  pFrame
-);
-
-#endif/* __80211MGR_H__ */
diff --git a/drivers/staging/vt6655/IEEE11h.c b/drivers/staging/vt6655/IEEE11h.c
deleted file mode 100644 (file)
index 180a27c..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 1996, 2005 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: IEEE11h.c
- *
- * Purpose:
- *
- * Functions:
- *
- * Revision History:
- *
- * Author: Yiching Chen
- *
- * Date: Mar. 31, 2005
- *
- */
-
-#include "ttype.h"
-#include "tmacro.h"
-#include "tether.h"
-#include "IEEE11h.h"
-#include "device.h"
-#include "wmgr.h"
-#include "rxtx.h"
-#include "channel.h"
-
-/*---------------------  Static Definitions -------------------------*/
-
-#pragma pack(1)
-
-typedef struct _WLAN_FRAME_ACTION {
-       WLAN_80211HDR_A3    Header;
-       unsigned char byCategory;
-       unsigned char byAction;
-       unsigned char abyVars[1];
-} WLAN_FRAME_ACTION, *PWLAN_FRAME_ACTION;
-
-typedef struct _WLAN_FRAME_MSRREQ {
-       WLAN_80211HDR_A3    Header;
-       unsigned char byCategory;
-       unsigned char byAction;
-       unsigned char byDialogToken;
-       WLAN_IE_MEASURE_REQ sMSRReqEIDs[1];
-} WLAN_FRAME_MSRREQ, *PWLAN_FRAME_MSRREQ;
-
-typedef struct _WLAN_FRAME_MSRREP {
-       WLAN_80211HDR_A3    Header;
-       unsigned char byCategory;
-       unsigned char byAction;
-       unsigned char byDialogToken;
-       WLAN_IE_MEASURE_REP sMSRRepEIDs[1];
-} WLAN_FRAME_MSRREP, *PWLAN_FRAME_MSRREP;
-
-typedef struct _WLAN_FRAME_TPCREQ {
-       WLAN_80211HDR_A3    Header;
-       unsigned char byCategory;
-       unsigned char byAction;
-       unsigned char byDialogToken;
-       WLAN_IE_TPC_REQ     sTPCReqEIDs;
-} WLAN_FRAME_TPCREQ, *PWLAN_FRAME_TPCREQ;
-
-typedef struct _WLAN_FRAME_TPCREP {
-       WLAN_80211HDR_A3    Header;
-       unsigned char byCategory;
-       unsigned char byAction;
-       unsigned char byDialogToken;
-       WLAN_IE_TPC_REP     sTPCRepEIDs;
-} WLAN_FRAME_TPCREP, *PWLAN_FRAME_TPCREP;
-
-#pragma pack()
-
-/* action field reference ieee 802.11h Table 20e */
-#define ACTION_MSRREQ       0
-#define ACTION_MSRREP       1
-#define ACTION_TPCREQ       2
-#define ACTION_TPCREP       3
-#define ACTION_CHSW         4
-
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Variables  --------------------------*/
-
-/*---------------------  Static Functions  --------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-bool IEEE11hbMSRRepTx(void *pMgmtHandle)
-{
-       PSMgmtObject            pMgmt = (PSMgmtObject) pMgmtHandle;
-       PWLAN_FRAME_MSRREP      pMSRRep = (PWLAN_FRAME_MSRREP)
-               (pMgmt->abyCurrentMSRRep + sizeof(STxMgmtPacket));
-       size_t                    uLength = 0;
-       PSTxMgmtPacket          pTxPacket = NULL;
-
-       pTxPacket = (PSTxMgmtPacket)pMgmt->abyCurrentMSRRep;
-       memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN);
-       pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket +
-                                                   sizeof(STxMgmtPacket));
-
-       pMSRRep->Header.wFrameCtl = (WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT) |
-                                    WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION)
-);
-
-       memcpy(pMSRRep->Header.abyAddr1, ((PWLAN_FRAME_MSRREQ)
-                                         (pMgmt->abyCurrentMSRReq))->Header.abyAddr2, WLAN_ADDR_LEN);
-       memcpy(pMSRRep->Header.abyAddr2,
-              CARDpGetCurrentAddress(pMgmt->pAdapter), WLAN_ADDR_LEN);
-       memcpy(pMSRRep->Header.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
-
-       pMSRRep->byCategory = 0;
-       pMSRRep->byAction = 1;
-       pMSRRep->byDialogToken = ((PWLAN_FRAME_MSRREQ)
-                                 (pMgmt->abyCurrentMSRReq))->byDialogToken;
-
-       uLength = pMgmt->uLengthOfRepEIDs + offsetof(WLAN_FRAME_MSRREP,
-                                                    sMSRRepEIDs);
-
-       pTxPacket->cbMPDULen = uLength;
-       pTxPacket->cbPayloadLen = uLength - WLAN_HDR_ADDR3_LEN;
-       if (csMgmt_xmit(pMgmt->pAdapter, pTxPacket) != CMD_STATUS_PENDING)
-               return false;
-       return true;
-}
diff --git a/drivers/staging/vt6655/IEEE11h.h b/drivers/staging/vt6655/IEEE11h.h
deleted file mode 100644 (file)
index 5519220..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 1996, 2005 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: IEEE11h.h
- *
- * Purpose: Defines the macros, types, and functions for dealing
- *          with IEEE 802.11h.
- *
- * Author: Yiching Chen
- *
- * Date: Mar. 31, 2005
- *
- */
-
-#ifndef __IEEE11h_H__
-#define __IEEE11h_H__
-
-#include "ttype.h"
-#include "80211hdr.h"
-#include "80211mgr.h"
-
-bool IEEE11hbMSRRepTx(
-       void *pMgmtHandle
-);
-
-#endif // __IEEE11h_H__
index c3ba693..77cfc70 100644 (file)
@@ -1,8 +1,6 @@
 config VT6655
    tristate "VIA Technologies VT6655 support"
-   depends on PCI && WLAN && m
-   select WIRELESS_EXT
-   select WEXT_PRIV
+   depends on PCI && MAC80211 && m
    ---help---
    This is a vendor-written driver for VIA VT6655.
 
index f7544a6..115b951 100644 (file)
@@ -7,33 +7,12 @@ vt6655_stage-y +=     device_main.o \
        channel.o \
        mac.o \
        baseband.o \
-       wctl.o \
-       80211mgr.o \
-       wcmd.o \
-       wmgr.o \
-       bssdb.o \
        rxtx.o \
        dpc.o \
        power.o \
-       datarate.o \
        srom.o \
        mib.o \
-       rc4.o \
-       tether.o \
-       tcrc.o \
-       ioctl.o \
-       hostap.o \
-       wpa.o \
        key.o \
-       tkip.o \
-       michael.o \
-       wroute.o \
-       rf.o \
-       iwctl.o \
-       wpactl.o \
-       wpa2.o \
-       aes_ccmp.o \
-       vntwifi.o \
-       IEEE11h.o
+       rf.o
 
 obj-$(CONFIG_VT6655) +=        vt6655_stage.o
diff --git a/drivers/staging/vt6655/aes_ccmp.c b/drivers/staging/vt6655/aes_ccmp.c
deleted file mode 100644 (file)
index 1dfcfcb..0000000
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: aes_ccmp.c
- *
- * Purpose: AES_CCMP decryption
- *
- * Author: Warren Hsu
- *
- * Date: Feb 15, 2005
- *
- * Functions:
- *      AESbGenCCMP - Parsing RX-packet
- *
- *
- * Revision History:
- *
- */
-
-#include "device.h"
-#include "80211hdr.h"
-#include "aes_ccmp.h"
-
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Variables  --------------------------*/
-
-/*
- * SBOX Table
- */
-
-static unsigned char sbox_table[256] = {
-       0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
-       0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
-       0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
-       0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
-       0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
-       0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
-       0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
-       0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
-       0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
-       0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
-       0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
-       0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
-       0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
-       0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
-       0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
-       0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
-};
-
-static unsigned char dot2_table[256] = {
-       0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e,
-       0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e,
-       0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e,
-       0x60, 0x62, 0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e,
-       0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e,
-       0xa0, 0xa2, 0xa4, 0xa6, 0xa8, 0xaa, 0xac, 0xae, 0xb0, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe,
-       0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde,
-       0xe0, 0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee, 0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfc, 0xfe,
-       0x1b, 0x19, 0x1f, 0x1d, 0x13, 0x11, 0x17, 0x15, 0x0b, 0x09, 0x0f, 0x0d, 0x03, 0x01, 0x07, 0x05,
-       0x3b, 0x39, 0x3f, 0x3d, 0x33, 0x31, 0x37, 0x35, 0x2b, 0x29, 0x2f, 0x2d, 0x23, 0x21, 0x27, 0x25,
-       0x5b, 0x59, 0x5f, 0x5d, 0x53, 0x51, 0x57, 0x55, 0x4b, 0x49, 0x4f, 0x4d, 0x43, 0x41, 0x47, 0x45,
-       0x7b, 0x79, 0x7f, 0x7d, 0x73, 0x71, 0x77, 0x75, 0x6b, 0x69, 0x6f, 0x6d, 0x63, 0x61, 0x67, 0x65,
-       0x9b, 0x99, 0x9f, 0x9d, 0x93, 0x91, 0x97, 0x95, 0x8b, 0x89, 0x8f, 0x8d, 0x83, 0x81, 0x87, 0x85,
-       0xbb, 0xb9, 0xbf, 0xbd, 0xb3, 0xb1, 0xb7, 0xb5, 0xab, 0xa9, 0xaf, 0xad, 0xa3, 0xa1, 0xa7, 0xa5,
-       0xdb, 0xd9, 0xdf, 0xdd, 0xd3, 0xd1, 0xd7, 0xd5, 0xcb, 0xc9, 0xcf, 0xcd, 0xc3, 0xc1, 0xc7, 0xc5,
-       0xfb, 0xf9, 0xff, 0xfd, 0xf3, 0xf1, 0xf7, 0xf5, 0xeb, 0xe9, 0xef, 0xed, 0xe3, 0xe1, 0xe7, 0xe5
-};
-
-static unsigned char dot3_table[256] = {
-       0x00, 0x03, 0x06, 0x05, 0x0c, 0x0f, 0x0a, 0x09, 0x18, 0x1b, 0x1e, 0x1d, 0x14, 0x17, 0x12, 0x11,
-       0x30, 0x33, 0x36, 0x35, 0x3c, 0x3f, 0x3a, 0x39, 0x28, 0x2b, 0x2e, 0x2d, 0x24, 0x27, 0x22, 0x21,
-       0x60, 0x63, 0x66, 0x65, 0x6c, 0x6f, 0x6a, 0x69, 0x78, 0x7b, 0x7e, 0x7d, 0x74, 0x77, 0x72, 0x71,
-       0x50, 0x53, 0x56, 0x55, 0x5c, 0x5f, 0x5a, 0x59, 0x48, 0x4b, 0x4e, 0x4d, 0x44, 0x47, 0x42, 0x41,
-       0xc0, 0xc3, 0xc6, 0xc5, 0xcc, 0xcf, 0xca, 0xc9, 0xd8, 0xdb, 0xde, 0xdd, 0xd4, 0xd7, 0xd2, 0xd1,
-       0xf0, 0xf3, 0xf6, 0xf5, 0xfc, 0xff, 0xfa, 0xf9, 0xe8, 0xeb, 0xee, 0xed, 0xe4, 0xe7, 0xe2, 0xe1,
-       0xa0, 0xa3, 0xa6, 0xa5, 0xac, 0xaf, 0xaa, 0xa9, 0xb8, 0xbb, 0xbe, 0xbd, 0xb4, 0xb7, 0xb2, 0xb1,
-       0x90, 0x93, 0x96, 0x95, 0x9c, 0x9f, 0x9a, 0x99, 0x88, 0x8b, 0x8e, 0x8d, 0x84, 0x87, 0x82, 0x81,
-       0x9b, 0x98, 0x9d, 0x9e, 0x97, 0x94, 0x91, 0x92, 0x83, 0x80, 0x85, 0x86, 0x8f, 0x8c, 0x89, 0x8a,
-       0xab, 0xa8, 0xad, 0xae, 0xa7, 0xa4, 0xa1, 0xa2, 0xb3, 0xb0, 0xb5, 0xb6, 0xbf, 0xbc, 0xb9, 0xba,
-       0xfb, 0xf8, 0xfd, 0xfe, 0xf7, 0xf4, 0xf1, 0xf2, 0xe3, 0xe0, 0xe5, 0xe6, 0xef, 0xec, 0xe9, 0xea,
-       0xcb, 0xc8, 0xcd, 0xce, 0xc7, 0xc4, 0xc1, 0xc2, 0xd3, 0xd0, 0xd5, 0xd6, 0xdf, 0xdc, 0xd9, 0xda,
-       0x5b, 0x58, 0x5d, 0x5e, 0x57, 0x54, 0x51, 0x52, 0x43, 0x40, 0x45, 0x46, 0x4f, 0x4c, 0x49, 0x4a,
-       0x6b, 0x68, 0x6d, 0x6e, 0x67, 0x64, 0x61, 0x62, 0x73, 0x70, 0x75, 0x76, 0x7f, 0x7c, 0x79, 0x7a,
-       0x3b, 0x38, 0x3d, 0x3e, 0x37, 0x34, 0x31, 0x32, 0x23, 0x20, 0x25, 0x26, 0x2f, 0x2c, 0x29, 0x2a,
-       0x0b, 0x08, 0x0d, 0x0e, 0x07, 0x04, 0x01, 0x02, 0x13, 0x10, 0x15, 0x16, 0x1f, 0x1c, 0x19, 0x1a
-};
-
-/*---------------------  Static Functions  --------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-static void xor_128(unsigned char *a, unsigned char *b, unsigned char *out)
-{
-       unsigned long *dwPtrA = (unsigned long *)a;
-       unsigned long *dwPtrB = (unsigned long *)b;
-       unsigned long *dwPtrOut = (unsigned long *)out;
-
-       (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++);
-       (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++);
-       (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++);
-       (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++);
-}
-
-static void xor_32(unsigned char *a, unsigned char *b, unsigned char *out)
-{
-       unsigned long *dwPtrA = (unsigned long *)a;
-       unsigned long *dwPtrB = (unsigned long *)b;
-       unsigned long *dwPtrOut = (unsigned long *)out;
-
-       (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++);
-}
-
-static void AddRoundKey(unsigned char *key, int round)
-{
-       unsigned char sbox_key[4];
-       unsigned char rcon_table[10] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36};
-
-       sbox_key[0] = sbox_table[key[13]];
-       sbox_key[1] = sbox_table[key[14]];
-       sbox_key[2] = sbox_table[key[15]];
-       sbox_key[3] = sbox_table[key[12]];
-
-       key[0] = key[0] ^ rcon_table[round];
-       xor_32(&key[0], sbox_key, &key[0]);
-
-       xor_32(&key[4], &key[0], &key[4]);
-       xor_32(&key[8], &key[4], &key[8]);
-       xor_32(&key[12], &key[8], &key[12]);
-}
-
-static void SubBytes(unsigned char *in, unsigned char *out)
-{
-       int i;
-
-       for (i = 0; i < 16; i++)
-               out[i] = sbox_table[in[i]];
-}
-
-static void ShiftRows(unsigned char *in, unsigned char *out)
-{
-       out[0]  = in[0];
-       out[1]  = in[5];
-       out[2]  = in[10];
-       out[3]  = in[15];
-       out[4]  = in[4];
-       out[5]  = in[9];
-       out[6]  = in[14];
-       out[7]  = in[3];
-       out[8]  = in[8];
-       out[9]  = in[13];
-       out[10] = in[2];
-       out[11] = in[7];
-       out[12] = in[12];
-       out[13] = in[1];
-       out[14] = in[6];
-       out[15] = in[11];
-}
-
-static void MixColumns(unsigned char *in, unsigned char *out)
-{
-       out[0] = dot2_table[in[0]] ^ dot3_table[in[1]] ^ in[2] ^ in[3];
-       out[1] = in[0] ^ dot2_table[in[1]] ^ dot3_table[in[2]] ^ in[3];
-       out[2] = in[0] ^ in[1] ^ dot2_table[in[2]] ^ dot3_table[in[3]];
-       out[3] = dot3_table[in[0]] ^ in[1] ^ in[2] ^ dot2_table[in[3]];
-}
-
-static void AESv128(unsigned char *key, unsigned char *data, unsigned char *ciphertext)
-{
-       int  i;
-       int  round;
-       unsigned char TmpdataA[16];
-       unsigned char TmpdataB[16];
-       unsigned char abyRoundKey[16];
-
-       for (i = 0; i < 16; i++)
-               abyRoundKey[i] = key[i];
-
-       for (round = 0; round < 11; round++) {
-               if (round == 0) {
-                       xor_128(abyRoundKey, data, ciphertext);
-                       AddRoundKey(abyRoundKey, round);
-               } else if (round == 10) {
-                       SubBytes(ciphertext, TmpdataA);
-                       ShiftRows(TmpdataA, TmpdataB);
-                       xor_128(TmpdataB, abyRoundKey, ciphertext);
-               } else /* round 1 ~ 9 */{
-                       SubBytes(ciphertext, TmpdataA);
-                       ShiftRows(TmpdataA, TmpdataB);
-                       MixColumns(&TmpdataB[0], &TmpdataA[0]);
-                       MixColumns(&TmpdataB[4], &TmpdataA[4]);
-                       MixColumns(&TmpdataB[8], &TmpdataA[8]);
-                       MixColumns(&TmpdataB[12], &TmpdataA[12]);
-                       xor_128(TmpdataA, abyRoundKey, ciphertext);
-                       AddRoundKey(abyRoundKey, round);
-               }
-       }
-}
-
-/*
- * Description: AES decryption
- *
- * Parameters:
- *  In:
- *      pbyRxKey            - The key used to decrypt
- *      pbyFrame            - Starting address of packet header
- *      wFrameSize          - Total packet size including CRC
- *  Out:
- *      none
- *
- * Return Value: MIC compare result
- *
- */
-bool AESbGenCCMP(unsigned char *pbyRxKey, unsigned char *pbyFrame, unsigned short wFrameSize)
-{
-       unsigned char abyNonce[13];
-       unsigned char MIC_IV[16];
-       unsigned char MIC_HDR1[16];
-       unsigned char MIC_HDR2[16];
-       unsigned char abyMIC[16];
-       unsigned char abyCTRPLD[16];
-       unsigned char abyTmp[16];
-       unsigned char abyPlainText[16];
-       unsigned char abyLastCipher[16];
-
-       PS802_11Header  pMACHeader = (PS802_11Header) pbyFrame;
-       unsigned char *pbyIV;
-       unsigned char *pbyPayload;
-       unsigned short wHLen = 22;
-       unsigned short wPayloadSize = wFrameSize - 8 - 8 - 4 - WLAN_HDR_ADDR3_LEN;/* 8 is IV, 8 is MIC, 4 is CRC */
-       bool bA4 = false;
-       unsigned char byTmp;
-       unsigned short wCnt;
-       int ii, jj, kk;
-
-       pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN;
-       if (WLAN_GET_FC_TODS(*(unsigned short *)pbyFrame) &&
-           WLAN_GET_FC_FROMDS(*(unsigned short *)pbyFrame)) {
-               bA4 = true;
-               pbyIV += 6;             /* 6 is 802.11 address4 */
-               wHLen += 6;
-               wPayloadSize -= 6;
-       }
-       pbyPayload = pbyIV + 8; /* IV-length */
-
-       abyNonce[0]  = 0x00; /* now is 0, if Qos here will be priority */
-       memcpy(&(abyNonce[1]), pMACHeader->abyAddr2, ETH_ALEN);
-       abyNonce[7]  = pbyIV[7];
-       abyNonce[8]  = pbyIV[6];
-       abyNonce[9]  = pbyIV[5];
-       abyNonce[10] = pbyIV[4];
-       abyNonce[11] = pbyIV[1];
-       abyNonce[12] = pbyIV[0];
-
-       /* MIC_IV */
-       MIC_IV[0] = 0x59;
-       memcpy(&(MIC_IV[1]), &(abyNonce[0]), 13);
-       MIC_IV[14] = (unsigned char)(wPayloadSize >> 8);
-       MIC_IV[15] = (unsigned char)(wPayloadSize & 0xff);
-
-       /* MIC_HDR1 */
-       MIC_HDR1[0] = (unsigned char)(wHLen >> 8);
-       MIC_HDR1[1] = (unsigned char)(wHLen & 0xff);
-       byTmp = (unsigned char)(pMACHeader->wFrameCtl & 0xff);
-       MIC_HDR1[2] = byTmp & 0x8f;
-       byTmp = (unsigned char)(pMACHeader->wFrameCtl >> 8);
-       byTmp &= 0x87;
-       MIC_HDR1[3] = byTmp | 0x40;
-       memcpy(&(MIC_HDR1[4]), pMACHeader->abyAddr1, ETH_ALEN);
-       memcpy(&(MIC_HDR1[10]), pMACHeader->abyAddr2, ETH_ALEN);
-
-       /* MIC_HDR2 */
-       memcpy(&(MIC_HDR2[0]), pMACHeader->abyAddr3, ETH_ALEN);
-       byTmp = (unsigned char)(pMACHeader->wSeqCtl & 0xff);
-       MIC_HDR2[6] = byTmp & 0x0f;
-       MIC_HDR2[7] = 0;
-       if (bA4) {
-               memcpy(&(MIC_HDR2[8]), pMACHeader->abyAddr4, ETH_ALEN);
-       } else {
-               MIC_HDR2[8]  = 0x00;
-               MIC_HDR2[9]  = 0x00;
-               MIC_HDR2[10] = 0x00;
-               MIC_HDR2[11] = 0x00;
-               MIC_HDR2[12] = 0x00;
-               MIC_HDR2[13] = 0x00;
-       }
-       MIC_HDR2[14] = 0x00;
-       MIC_HDR2[15] = 0x00;
-
-       /* CCMP */
-       AESv128(pbyRxKey, MIC_IV, abyMIC);
-       for (kk = 0; kk < 16; kk++)
-               abyTmp[kk] = MIC_HDR1[kk] ^ abyMIC[kk];
-       AESv128(pbyRxKey, abyTmp, abyMIC);
-       for (kk = 0; kk < 16; kk++)
-               abyTmp[kk] = MIC_HDR2[kk] ^ abyMIC[kk];
-       AESv128(pbyRxKey, abyTmp, abyMIC);
-
-       wCnt = 1;
-       abyCTRPLD[0] = 0x01;
-       memcpy(&(abyCTRPLD[1]), &(abyNonce[0]), 13);
-
-       for (jj = wPayloadSize; jj > 16; jj = jj - 16) {
-               abyCTRPLD[14] = (unsigned char)(wCnt >> 8);
-               abyCTRPLD[15] = (unsigned char)(wCnt & 0xff);
-
-               AESv128(pbyRxKey, abyCTRPLD, abyTmp);
-
-               for (kk = 0; kk < 16; kk++)
-                       abyPlainText[kk] = abyTmp[kk] ^ pbyPayload[kk];
-               for (kk = 0; kk < 16; kk++)
-                       abyTmp[kk] = abyMIC[kk] ^ abyPlainText[kk];
-               AESv128(pbyRxKey, abyTmp, abyMIC);
-
-               memcpy(pbyPayload, abyPlainText, 16);
-               wCnt++;
-               pbyPayload += 16;
-       } /* for wPayloadSize */
-
-       /* last payload */
-       memcpy(&(abyLastCipher[0]), pbyPayload, jj);
-       for (ii = jj; ii < 16; ii++)
-               abyLastCipher[ii] = 0x00;
-
-       abyCTRPLD[14] = (unsigned char)(wCnt >> 8);
-       abyCTRPLD[15] = (unsigned char)(wCnt & 0xff);
-
-       AESv128(pbyRxKey, abyCTRPLD, abyTmp);
-       for (kk = 0; kk < 16; kk++)
-               abyPlainText[kk] = abyTmp[kk] ^ abyLastCipher[kk];
-       memcpy(pbyPayload, abyPlainText, jj);
-       pbyPayload += jj;
-
-       /* for MIC calculation */
-       for (ii = jj; ii < 16; ii++)
-               abyPlainText[ii] = 0x00;
-       for (kk = 0; kk < 16; kk++)
-               abyTmp[kk] = abyMIC[kk] ^ abyPlainText[kk];
-       AESv128(pbyRxKey, abyTmp, abyMIC);
-
-       /* =>above is the calculate MIC */
-       /* -------------------------------------------- */
-
-       wCnt = 0;
-       abyCTRPLD[14] = (unsigned char)(wCnt >> 8);
-       abyCTRPLD[15] = (unsigned char)(wCnt & 0xff);
-       AESv128(pbyRxKey, abyCTRPLD, abyTmp);
-       for (kk = 0; kk < 8; kk++)
-               abyTmp[kk] = abyTmp[kk] ^ pbyPayload[kk];
-       /* =>above is the dec-MIC from packet */
-       /* -------------------------------------------- */
-
-       return !memcmp(abyMIC, abyTmp, 8);
-}
diff --git a/drivers/staging/vt6655/aes_ccmp.h b/drivers/staging/vt6655/aes_ccmp.h
deleted file mode 100644 (file)
index fe0c506..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: aes_ccmp.h
- *
- * Purpose: AES_CCMP Decryption
- *
- * Author: Warren Hsu
- *
- * Date: Feb 15, 2005
- *
- */
-
-#ifndef __AES_H__
-#define __AES_H__
-
-#include "ttype.h"
-
-bool AESbGenCCMP(unsigned char *pbyRxKey, unsigned char *pbyFrame, unsigned short wFrameSize);
-
-#endif /* __AES_H__ */
index de54923..b04dfd9 100644 (file)
@@ -50,7 +50,6 @@
  */
 
 #include "tmacro.h"
-#include "tether.h"
 #include "mac.h"
 #include "baseband.h"
 #include "srom.h"
@@ -1792,18 +1791,17 @@ BBuGetFrameTime(
                        uFrameTime++;
 
                return uPreamble + uFrameTime;
-       } else {
-               uFrameTime = (cbFrameLength * 8 + 22) / uRate; /* ???????? */
-               uTmp = ((uFrameTime * uRate) - 22) / 8;
-               if (cbFrameLength != uTmp)
-                       uFrameTime++;
+       }
+       uFrameTime = (cbFrameLength * 8 + 22) / uRate; /* ???????? */
+       uTmp = ((uFrameTime * uRate) - 22) / 8;
+       if (cbFrameLength != uTmp)
+               uFrameTime++;
 
-               uFrameTime = uFrameTime * 4;    /* ??????? */
-               if (byPktType != PK_TYPE_11A)
-                       uFrameTime += 6;     /* ?????? */
+       uFrameTime = uFrameTime * 4;    /* ??????? */
+       if (byPktType != PK_TYPE_11A)
+               uFrameTime += 6;     /* ?????? */
 
-               return 20 + uFrameTime; /* ?????? */
-       }
+       return 20 + uFrameTime; /* ?????? */
 }
 
 /*
@@ -2117,7 +2115,7 @@ bool BBbVT3253Init(struct vnt_private *pDevice)
                                bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC4_RFMD2959[ii][0], byVT3253B0_AGC4_RFMD2959[ii][1]);
 
                        VNSvOutPortD(dwIoBase + MAC_REG_ITRTMSET, 0x23);
-                       MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT0);
+                       MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT(0));
                }
                pDevice->abyBBVGA[0] = 0x18;
                pDevice->abyBBVGA[1] = 0x0A;
@@ -2150,7 +2148,7 @@ bool BBbVT3253Init(struct vnt_private *pDevice)
                        bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
 
                VNSvOutPortB(dwIoBase + MAC_REG_ITRTMSET, 0x23);
-               MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT0);
+               MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT(0));
 
                pDevice->abyBBVGA[0] = 0x14;
                pDevice->abyBBVGA[1] = 0x0A;
@@ -2456,7 +2454,7 @@ BBvPowerSaveModeON(void __iomem *dwIoBase)
        unsigned char byOrgData;
 
        BBbReadEmbedded(dwIoBase, 0x0D, &byOrgData);
-       byOrgData |= BIT0;
+       byOrgData |= BIT(0);
        BBbWriteEmbedded(dwIoBase, 0x0D, byOrgData);
 }
 
@@ -2478,7 +2476,7 @@ BBvPowerSaveModeOFF(void __iomem *dwIoBase)
        unsigned char byOrgData;
 
        BBbReadEmbedded(dwIoBase, 0x0D, &byOrgData);
-       byOrgData &= ~(BIT0);
+       byOrgData &= ~(BIT(0));
        BBbWriteEmbedded(dwIoBase, 0x0D, byOrgData);
 }
 
@@ -2783,13 +2781,15 @@ void BBvAntennaDiversity(struct vnt_private *pDevice,
 
 void
 TimerSQ3CallBack(
-       void *hDeviceContext
+       unsigned long data
 )
 {
-       struct vnt_private *pDevice = hDeviceContext;
+       struct vnt_private *pDevice = (struct vnt_private *)data;
+       unsigned long flags;
 
        pr_debug("TimerSQ3CallBack...\n");
-       spin_lock_irq(&pDevice->lock);
+
+       spin_lock_irqsave(&pDevice->lock, flags);
 
        pr_debug("3.[%08x][%08x], %d\n",
                 (int)pDevice->ulRatio_State0, (int)pDevice->ulRatio_State1,
@@ -2804,7 +2804,7 @@ TimerSQ3CallBack(
        add_timer(&pDevice->TimerSQ3Tmax3);
        add_timer(&pDevice->TimerSQ3Tmax2);
 
-       spin_unlock_irq(&pDevice->lock);
+       spin_unlock_irqrestore(&pDevice->lock, flags);
 }
 
 /*+
@@ -2827,14 +2827,16 @@ TimerSQ3CallBack(
 
 void
 TimerState1CallBack(
-       void *hDeviceContext
+       unsigned long data
 )
 {
-       struct vnt_private *pDevice = hDeviceContext;
+       struct vnt_private *pDevice = (struct vnt_private *)data;
+       unsigned long flags;
 
        pr_debug("TimerState1CallBack...\n");
 
-       spin_lock_irq(&pDevice->lock);
+       spin_lock_irqsave(&pDevice->lock, flags);
+
        if (pDevice->uDiversityCnt < pDevice->ulDiversityMValue/100) {
                s_vChangeAntenna(pDevice);
                pDevice->TimerSQ3Tmax3.expires =  RUN_AT(pDevice->byTMax3 * HZ);
@@ -2865,5 +2867,6 @@ TimerState1CallBack(
        }
        pDevice->byAntennaState = 0;
        BBvClearAntDivSQ3Value(pDevice);
-       spin_unlock_irq(&pDevice->lock);
+
+       spin_unlock_irqrestore(&pDevice->lock, flags);
 }
index 31f2255..bfdd422 100644 (file)
@@ -30,8 +30,6 @@
 #ifndef __BASEBAND_H__
 #define __BASEBAND_H__
 
-#include "ttype.h"
-#include "tether.h"
 #include "device.h"
 
 /*
@@ -104,12 +102,12 @@ void BBvExitDeepSleep(void __iomem *dwIoBase, unsigned char byLocalID);
 
 void
 TimerSQ3CallBack(
-       void *hDeviceContext
+       unsigned long
 );
 
 void
 TimerState1CallBack(
-       void *hDeviceContext
+       unsigned long
 );
 
 void BBvAntennaDiversity(struct vnt_private *pDevice,
diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c
deleted file mode 100644 (file)
index 996d330..0000000
+++ /dev/null
@@ -1,1512 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: bssdb.c
- *
- * Purpose: Handles the Basic Service Set & Node Database functions
- *
- * Functions:
- *      BSSpSearchBSSList - Search known BSS list for Desire SSID or BSSID
- *      BSSvClearBSSList - Clear BSS List
- *      BSSbInsertToBSSList - Insert a BSS set into known BSS list
- *      BSSbUpdateToBSSList - Update BSS set in known BSS list
- *      BSSDBbIsSTAInNodeDB - Search Node DB table to find the index of matched DstAddr
- *      BSSvCreateOneNode - Allocate an Node for Node DB
- *      BSSvUpdateAPNode - Update AP Node content in Index 0 of KnownNodeDB
- *      BSSvSecondCallBack - One second timer callback function to update Node DB info & AP link status
- *      BSSvUpdateNodeTxCounter - Update Tx attemps, Tx failure counter in Node DB for auto-fall back rate control
- *
- * Revision History:
- *
- * Author: Lyndon Chen
- *
- * Date: July 17, 2002
- *
- */
-
-#include "ttype.h"
-#include "tmacro.h"
-#include "tether.h"
-#include "device.h"
-#include "80211hdr.h"
-#include "bssdb.h"
-#include "wmgr.h"
-#include "datarate.h"
-#include "desc.h"
-#include "wcmd.h"
-#include "wpa.h"
-#include "baseband.h"
-#include "rf.h"
-#include "card.h"
-#include "channel.h"
-#include "mac.h"
-#include "wpa2.h"
-#include "iowpa.h"
-
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Variables  --------------------------*/
-static const unsigned short awHWRetry0[5][5] = {
-       {RATE_18M, RATE_18M, RATE_12M, RATE_12M, RATE_12M},
-       {RATE_24M, RATE_24M, RATE_18M, RATE_12M, RATE_12M},
-       {RATE_36M, RATE_36M, RATE_24M, RATE_18M, RATE_18M},
-       {RATE_48M, RATE_48M, RATE_36M, RATE_24M, RATE_24M},
-       {RATE_54M, RATE_54M, RATE_48M, RATE_36M, RATE_36M}
-};
-static const unsigned short awHWRetry1[5][5] = {
-       {RATE_18M, RATE_18M, RATE_12M, RATE_6M, RATE_6M},
-       {RATE_24M, RATE_24M, RATE_18M, RATE_6M, RATE_6M},
-       {RATE_36M, RATE_36M, RATE_24M, RATE_12M, RATE_12M},
-       {RATE_48M, RATE_48M, RATE_24M, RATE_12M, RATE_12M},
-       {RATE_54M, RATE_54M, RATE_36M, RATE_18M, RATE_18M}
-};
-
-/*---------------------  Static Functions  --------------------------*/
-
-void s_vCheckSensitivity(
-       void *hDeviceContext
-);
-
-#ifdef Calcu_LinkQual
-void s_uCalculateLinkQual(
-       void *hDeviceContext
-);
-#endif
-
-void s_vCheckPreEDThreshold(
-       void *hDeviceContext
-);
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-/*+
- *
- * Routine Description:
- *    Search known BSS list for Desire SSID or BSSID.
- *
- * Return Value:
- *    PTR to KnownBSS or NULL
- *
- -*/
-
-PKnownBSS
-BSSpSearchBSSList(
-       void *hDeviceContext,
-       unsigned char *pbyDesireBSSID,
-       unsigned char *pbyDesireSSID,
-       CARD_PHY_TYPE  ePhyType
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       unsigned char *pbyBSSID = NULL;
-       PWLAN_IE_SSID   pSSID = NULL;
-       PKnownBSS       pCurrBSS = NULL;
-       PKnownBSS       pSelect = NULL;
-       unsigned char ZeroBSSID[WLAN_BSSID_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-       unsigned int ii = 0;
-
-       if (pbyDesireBSSID != NULL) {
-               pr_debug("BSSpSearchBSSList BSSID[%pM]\n", pbyDesireBSSID);
-               if ((!is_broadcast_ether_addr(pbyDesireBSSID)) &&
-                   (memcmp(pbyDesireBSSID, ZeroBSSID, 6) != 0))
-                       pbyBSSID = pbyDesireBSSID;
-       }
-       if (pbyDesireSSID != NULL) {
-               if (((PWLAN_IE_SSID)pbyDesireSSID)->len != 0)
-                       pSSID = (PWLAN_IE_SSID) pbyDesireSSID;
-       }
-
-       if (pbyBSSID != NULL) {
-               /* match BSSID first */
-               for (ii = 0; ii < MAX_BSS_NUM; ii++) {
-                       pCurrBSS = &(pMgmt->sBSSList[ii]);
-                       if (!pDevice->bLinkPass)
-                               pCurrBSS->bSelected = false;
-                       if ((pCurrBSS->bActive) &&
-                           (!pCurrBSS->bSelected)) {
-                               if (ether_addr_equal(pCurrBSS->abyBSSID,
-                                                    pbyBSSID)) {
-                                       if (pSSID != NULL) {
-                                               /* compare ssid */
-                                               if (!memcmp(pSSID->abySSID,
-                                                           ((PWLAN_IE_SSID)pCurrBSS->abySSID)->abySSID,
-                                                           pSSID->len)) {
-                                                       if ((pMgmt->eConfigMode == WMAC_CONFIG_AUTO) ||
-                                                           ((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) ||
-                                                           ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo))
-) {
-                                                               pCurrBSS->bSelected = true;
-                                                               return pCurrBSS;
-                                                       }
-                                               }
-                                       } else {
-                                               if ((pMgmt->eConfigMode == WMAC_CONFIG_AUTO) ||
-                                                   ((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) ||
-                                                   ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo))
-) {
-                                                       pCurrBSS->bSelected = true;
-                                                       return pCurrBSS;
-                                               }
-                                       }
-                               }
-                       }
-               }
-       } else {
-               /* ignore BSSID */
-               for (ii = 0; ii < MAX_BSS_NUM; ii++) {
-                       pCurrBSS = &(pMgmt->sBSSList[ii]);
-                       /* 2007-0721-01<Add>by MikeLiu */
-                       pCurrBSS->bSelected = false;
-                       if (pCurrBSS->bActive) {
-                               if (pSSID != NULL) {
-                                       /* matched SSID */
-                                       if (!!memcmp(pSSID->abySSID,
-                                                    ((PWLAN_IE_SSID)pCurrBSS->abySSID)->abySSID,
-                                                    pSSID->len) ||
-                                           (pSSID->len != ((PWLAN_IE_SSID)pCurrBSS->abySSID)->len)) {
-                                               /* SSID not match skip this BSS */
-                                               continue;
-                                       }
-                               }
-                               if (((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo)) ||
-                                   ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo))
-) {
-                                       /* Type not match skip this BSS */
-                                       pr_debug("BSS type mismatch.... Config[%d] BSS[0x%04x]\n",
-                                                pMgmt->eConfigMode,
-                                                pCurrBSS->wCapInfo);
-                                       continue;
-                               }
-
-                               if (ePhyType != PHY_TYPE_AUTO) {
-                                       if (((ePhyType == PHY_TYPE_11A) && (PHY_TYPE_11A != pCurrBSS->eNetworkTypeInUse)) ||
-                                           ((ePhyType != PHY_TYPE_11A) && (PHY_TYPE_11A == pCurrBSS->eNetworkTypeInUse))) {
-                                               /* PhyType not match skip this BSS */
-                                               pr_debug("Physical type mismatch.... ePhyType[%d] BSS[%d]\n",
-                                                        ePhyType,
-                                                        pCurrBSS->eNetworkTypeInUse);
-                                               continue;
-                                       }
-                               }
-
-                               if (pSelect == NULL) {
-                                       pSelect = pCurrBSS;
-                               } else {
-                                       /* compare RSSI, select signal strong one */
-                                       if (pCurrBSS->uRSSI < pSelect->uRSSI)
-                                               pSelect = pCurrBSS;
-                               }
-                       }
-               }
-               if (pSelect != NULL) {
-                       pSelect->bSelected = true;
-                       return pSelect;
-               }
-       }
-       return NULL;
-}
-
-/*+
- *
- * Routine Description:
- *    Clear BSS List
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-BSSvClearBSSList(
-       void *hDeviceContext,
-       bool bKeepCurrBSSID
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       unsigned int ii;
-
-       for (ii = 0; ii < MAX_BSS_NUM; ii++) {
-               if (bKeepCurrBSSID) {
-                       if (pMgmt->sBSSList[ii].bActive &&
-                           ether_addr_equal(pMgmt->sBSSList[ii].abyBSSID,
-                                            pMgmt->abyCurrBSSID)) {
-                               continue;
-                       }
-               }
-
-               if ((pMgmt->sBSSList[ii].bActive) && (pMgmt->sBSSList[ii].uClearCount < BSS_CLEAR_COUNT)) {
-                       pMgmt->sBSSList[ii].uClearCount++;
-                       continue;
-               }
-
-               pMgmt->sBSSList[ii].bActive = false;
-               memset(&pMgmt->sBSSList[ii], 0, sizeof(KnownBSS));
-       }
-       BSSvClearAnyBSSJoinRecord(pDevice);
-}
-
-/*+
- *
- * Routine Description:
- *    search BSS list by BSSID & SSID if matched
- *
- * Return Value:
- *    true if found.
- *
- -*/
-PKnownBSS
-BSSpAddrIsInBSSList(
-       void *hDeviceContext,
-       unsigned char *abyBSSID,
-       PWLAN_IE_SSID pSSID
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       PKnownBSS       pBSSList = NULL;
-       unsigned int ii;
-
-       for (ii = 0; ii < MAX_BSS_NUM; ii++) {
-               pBSSList = &(pMgmt->sBSSList[ii]);
-               if (pBSSList->bActive) {
-                       if (ether_addr_equal(pBSSList->abyBSSID, abyBSSID)) {
-                               if (pSSID->len == ((PWLAN_IE_SSID)pBSSList->abySSID)->len) {
-                                       if (memcmp(pSSID->abySSID,
-                                                  ((PWLAN_IE_SSID)pBSSList->abySSID)->abySSID,
-                                                  pSSID->len) == 0)
-                                               return pBSSList;
-                               }
-                       }
-               }
-       }
-
-       return NULL;
-};
-
-/*+
- *
- * Routine Description:
- *    Insert a BSS set into known BSS list
- *
- * Return Value:
- *    true if success.
- *
- -*/
-
-bool
-BSSbInsertToBSSList(
-       void *hDeviceContext,
-       unsigned char *abyBSSIDAddr,
-       __le64 qwTimestamp,
-       unsigned short wBeaconInterval,
-       unsigned short wCapInfo,
-       unsigned char byCurrChannel,
-       PWLAN_IE_SSID pSSID,
-       PWLAN_IE_SUPP_RATES pSuppRates,
-       PWLAN_IE_SUPP_RATES pExtSuppRates,
-       PERPObject psERP,
-       PWLAN_IE_RSN pRSN,
-       PWLAN_IE_RSN_EXT pRSNWPA,
-       PWLAN_IE_COUNTRY pIE_Country,
-       PWLAN_IE_QUIET pIE_Quiet,
-       unsigned int uIELength,
-       unsigned char *pbyIEs,
-       void *pRxPacketContext
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       PSRxMgmtPacket  pRxPacket = (PSRxMgmtPacket)pRxPacketContext;
-       PKnownBSS       pBSSList = NULL;
-       unsigned int ii;
-       bool bParsingQuiet = false;
-       PWLAN_IE_QUIET  pQuiet = NULL;
-
-       pBSSList = (PKnownBSS)&(pMgmt->sBSSList[0]);
-
-       for (ii = 0; ii < MAX_BSS_NUM; ii++) {
-               pBSSList = (PKnownBSS)&(pMgmt->sBSSList[ii]);
-               if (!pBSSList->bActive)
-                       break;
-       }
-
-       if (ii == MAX_BSS_NUM) {
-               pr_debug("Get free KnowBSS node failed\n");
-               return false;
-       }
-       /* save the BSS info */
-       pBSSList->bActive = true;
-       memcpy(pBSSList->abyBSSID, abyBSSIDAddr, WLAN_BSSID_LEN);
-       pBSSList->qwBSSTimestamp = le64_to_cpu(qwTimestamp);
-       pBSSList->wBeaconInterval = cpu_to_le16(wBeaconInterval);
-       pBSSList->wCapInfo = cpu_to_le16(wCapInfo);
-       pBSSList->uClearCount = 0;
-
-       if (pSSID->len > WLAN_SSID_MAXLEN)
-               pSSID->len = WLAN_SSID_MAXLEN;
-       memcpy(pBSSList->abySSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
-
-       pBSSList->uChannel = byCurrChannel;
-
-       if (pSuppRates->len > WLAN_RATES_MAXLEN)
-               pSuppRates->len = WLAN_RATES_MAXLEN;
-       memcpy(pBSSList->abySuppRates, pSuppRates, pSuppRates->len + WLAN_IEHDR_LEN);
-
-       if (pExtSuppRates != NULL) {
-               if (pExtSuppRates->len > WLAN_RATES_MAXLEN)
-                       pExtSuppRates->len = WLAN_RATES_MAXLEN;
-               memcpy(pBSSList->abyExtSuppRates, pExtSuppRates, pExtSuppRates->len + WLAN_IEHDR_LEN);
-               pr_debug("BSSbInsertToBSSList: pExtSuppRates->len = %d\n",
-                        pExtSuppRates->len);
-
-       } else {
-               memset(pBSSList->abyExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
-       }
-       pBSSList->sERP.byERP = psERP->byERP;
-       pBSSList->sERP.bERPExist = psERP->bERPExist;
-
-       /* check if BSS is 802.11a/b/g */
-       if (pBSSList->uChannel > CB_MAX_CHANNEL_24G) {
-               pBSSList->eNetworkTypeInUse = PHY_TYPE_11A;
-       } else {
-               if (pBSSList->sERP.bERPExist)
-                       pBSSList->eNetworkTypeInUse = PHY_TYPE_11G;
-               else
-                       pBSSList->eNetworkTypeInUse = PHY_TYPE_11B;
-       }
-
-       pBSSList->byRxRate = pRxPacket->byRxRate;
-       pBSSList->qwLocalTSF = pRxPacket->qwLocalTSF;
-       pBSSList->uRSSI = pRxPacket->uRSSI;
-       pBSSList->bySQ = pRxPacket->bySQ;
-
-       if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
-           (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
-               /* assoc with BSS */
-               if (pBSSList == pMgmt->pCurrBSS)
-                       bParsingQuiet = true;
-       }
-
-       WPA_ClearRSN(pBSSList);
-
-       if (pRSNWPA != NULL) {
-               unsigned int uLen = pRSNWPA->len + 2;
-
-               if (uLen <= (uIELength - (unsigned int)((unsigned char *)pRSNWPA - pbyIEs))) {
-                       pBSSList->wWPALen = uLen;
-                       memcpy(pBSSList->byWPAIE, pRSNWPA, uLen);
-                       WPA_ParseRSN(pBSSList, pRSNWPA);
-               }
-       }
-
-       WPA2_ClearRSN(pBSSList);
-
-       if (pRSN != NULL) {
-               unsigned int uLen = pRSN->len + 2;
-
-               if (uLen <= (uIELength - (unsigned int)((unsigned char *)pRSN - pbyIEs))) {
-                       pBSSList->wRSNLen = uLen;
-                       memcpy(pBSSList->byRSNIE, pRSN, uLen);
-                       WPA2vParseRSN(pBSSList, pRSN);
-               }
-       }
-
-       if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || pBSSList->bWPA2Valid) {
-               PSKeyItem  pTransmitKey = NULL;
-               bool bIs802_1x = false;
-
-               for (ii = 0; ii < pBSSList->wAKMSSAuthCount; ii++) {
-                       if (pBSSList->abyAKMSSAuthType[ii] == WLAN_11i_AKMSS_802_1X) {
-                               bIs802_1x = true;
-                               break;
-                       }
-               }
-               if (bIs802_1x && (pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len) &&
-                   (!memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySSID, pSSID->len))) {
-                       bAdd_PMKID_Candidate((void *)pDevice, pBSSList->abyBSSID, &pBSSList->sRSNCapObj);
-
-                       if (pDevice->bLinkPass && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
-                               if (KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, PAIRWISE_KEY, &pTransmitKey) ||
-                                   KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, GROUP_KEY, &pTransmitKey)) {
-                                       pDevice->gsPMKIDCandidate.StatusType = Ndis802_11StatusType_PMKID_CandidateList;
-                                       pDevice->gsPMKIDCandidate.Version = 1;
-
-                               }
-
-                       }
-               }
-       }
-
-       if (pDevice->bUpdateBBVGA) {
-               /* monitor if RSSI is too strong */
-               pBSSList->byRSSIStatCnt = 0;
-               RFvRSSITodBm(pDevice, (unsigned char)(pRxPacket->uRSSI), &pBSSList->ldBmMAX);
-               pBSSList->ldBmAverage[0] = pBSSList->ldBmMAX;
-               for (ii = 1; ii < RSSI_STAT_COUNT; ii++)
-                       pBSSList->ldBmAverage[ii] = 0;
-       }
-
-       if ((pIE_Country != NULL) && pMgmt->b11hEnable) {
-               set_country_info(pMgmt->pAdapter, pBSSList->eNetworkTypeInUse,
-                                pIE_Country);
-       }
-
-       if (bParsingQuiet && (pIE_Quiet != NULL)) {
-               if ((((PWLAN_IE_QUIET)pIE_Quiet)->len == 8) &&
-                   (((PWLAN_IE_QUIET)pIE_Quiet)->byQuietCount != 0)) {
-                       /* valid EID */
-                       if (pQuiet == NULL) {
-                               pQuiet = (PWLAN_IE_QUIET)pIE_Quiet;
-                               CARDbSetQuiet(pMgmt->pAdapter,
-                                             true,
-                                             pQuiet->byQuietCount,
-                                             pQuiet->byQuietPeriod,
-                                             *((unsigned short *)pQuiet->abyQuietDuration),
-                                             *((unsigned short *)pQuiet->abyQuietOffset)
-);
-                       } else {
-                               pQuiet = (PWLAN_IE_QUIET)pIE_Quiet;
-                               CARDbSetQuiet(pMgmt->pAdapter,
-                                             false,
-                                             pQuiet->byQuietCount,
-                                             pQuiet->byQuietPeriod,
-                                             *((unsigned short *)pQuiet->abyQuietDuration),
-                                             *((unsigned short *)pQuiet->abyQuietOffset)
-                                       );
-                       }
-               }
-       }
-
-       if (bParsingQuiet && (pQuiet != NULL))
-               CARDbStartQuiet(pMgmt->pAdapter);
-
-       pBSSList->uIELength = uIELength;
-       if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN)
-               pBSSList->uIELength = WLAN_BEACON_FR_MAXLEN;
-       memcpy(pBSSList->abyIEs, pbyIEs, pBSSList->uIELength);
-
-       return true;
-}
-
-/*+
- *
- * Routine Description:
- *    Update BSS set in known BSS list
- *
- * Return Value:
- *    true if success.
- *
- -*/
-/* TODO: input structure modify */
-
-bool
-BSSbUpdateToBSSList(
-       void *hDeviceContext,
-       __le64 qwTimestamp,
-       unsigned short wBeaconInterval,
-       unsigned short wCapInfo,
-       unsigned char byCurrChannel,
-       bool bChannelHit,
-       PWLAN_IE_SSID pSSID,
-       PWLAN_IE_SUPP_RATES pSuppRates,
-       PWLAN_IE_SUPP_RATES pExtSuppRates,
-       PERPObject psERP,
-       PWLAN_IE_RSN pRSN,
-       PWLAN_IE_RSN_EXT pRSNWPA,
-       PWLAN_IE_COUNTRY pIE_Country,
-       PWLAN_IE_QUIET pIE_Quiet,
-       PKnownBSS pBSSList,
-       unsigned int uIELength,
-       unsigned char *pbyIEs,
-       void *pRxPacketContext
-)
-{
-       int             ii;
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       PSRxMgmtPacket  pRxPacket = (PSRxMgmtPacket)pRxPacketContext;
-       long            ldBm;
-       bool bParsingQuiet = false;
-       PWLAN_IE_QUIET  pQuiet = NULL;
-
-       if (pBSSList == NULL)
-               return false;
-
-       pBSSList->qwBSSTimestamp = le64_to_cpu(qwTimestamp);
-       pBSSList->wBeaconInterval = cpu_to_le16(wBeaconInterval);
-       pBSSList->wCapInfo = cpu_to_le16(wCapInfo);
-       pBSSList->uClearCount = 0;
-       pBSSList->uChannel = byCurrChannel;
-
-       if (pSSID->len > WLAN_SSID_MAXLEN)
-               pSSID->len = WLAN_SSID_MAXLEN;
-
-       if ((pSSID->len != 0) && (pSSID->abySSID[0] != 0))
-               memcpy(pBSSList->abySSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
-       memcpy(pBSSList->abySuppRates, pSuppRates, pSuppRates->len + WLAN_IEHDR_LEN);
-
-       if (pExtSuppRates != NULL)
-               memcpy(pBSSList->abyExtSuppRates, pExtSuppRates, pExtSuppRates->len + WLAN_IEHDR_LEN);
-       else
-               memset(pBSSList->abyExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
-       pBSSList->sERP.byERP = psERP->byERP;
-       pBSSList->sERP.bERPExist = psERP->bERPExist;
-
-       /* check if BSS is 802.11a/b/g */
-       if (pBSSList->uChannel > CB_MAX_CHANNEL_24G) {
-               pBSSList->eNetworkTypeInUse = PHY_TYPE_11A;
-       } else {
-               if (pBSSList->sERP.bERPExist)
-                       pBSSList->eNetworkTypeInUse = PHY_TYPE_11G;
-               else
-                       pBSSList->eNetworkTypeInUse = PHY_TYPE_11B;
-       }
-
-       pBSSList->byRxRate = pRxPacket->byRxRate;
-       pBSSList->qwLocalTSF = pRxPacket->qwLocalTSF;
-       if (bChannelHit)
-               pBSSList->uRSSI = pRxPacket->uRSSI;
-       pBSSList->bySQ = pRxPacket->bySQ;
-
-       if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
-           (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
-               /* assoc with BSS */
-               if (pBSSList == pMgmt->pCurrBSS)
-                       bParsingQuiet = true;
-       }
-
-       WPA_ClearRSN(pBSSList);         /* mike update */
-
-       if (pRSNWPA != NULL) {
-               unsigned int uLen = pRSNWPA->len + 2;
-
-               if (uLen <= (uIELength - (unsigned int)((unsigned char *)pRSNWPA - pbyIEs))) {
-                       pBSSList->wWPALen = uLen;
-                       memcpy(pBSSList->byWPAIE, pRSNWPA, uLen);
-                       WPA_ParseRSN(pBSSList, pRSNWPA);
-               }
-       }
-
-       WPA2_ClearRSN(pBSSList);  /* mike update */
-
-       if (pRSN != NULL) {
-               unsigned int uLen = pRSN->len + 2;
-
-               if (uLen <= (uIELength - (unsigned int)((unsigned char *)pRSN - pbyIEs))) {
-                       pBSSList->wRSNLen = uLen;
-                       memcpy(pBSSList->byRSNIE, pRSN, uLen);
-                       WPA2vParseRSN(pBSSList, pRSN);
-               }
-       }
-
-       if (pRxPacket->uRSSI != 0) {
-               RFvRSSITodBm(pDevice, (unsigned char)(pRxPacket->uRSSI), &ldBm);
-               /* monitor if RSSI is too strong */
-               pBSSList->byRSSIStatCnt++;
-               pBSSList->byRSSIStatCnt %= RSSI_STAT_COUNT;
-               pBSSList->ldBmAverage[pBSSList->byRSSIStatCnt] = ldBm;
-               for (ii = 0; ii < RSSI_STAT_COUNT; ii++) {
-                       if (pBSSList->ldBmAverage[ii] != 0)
-                               pBSSList->ldBmMAX = max(pBSSList->ldBmAverage[ii], ldBm);
-               }
-       }
-
-       if ((pIE_Country != NULL) && pMgmt->b11hEnable) {
-               set_country_info(pMgmt->pAdapter, pBSSList->eNetworkTypeInUse,
-                                pIE_Country);
-       }
-
-       if (bParsingQuiet && (pIE_Quiet != NULL)) {
-               if ((((PWLAN_IE_QUIET)pIE_Quiet)->len == 8) &&
-                   (((PWLAN_IE_QUIET)pIE_Quiet)->byQuietCount != 0)) {
-                       /* valid EID */
-                       if (pQuiet == NULL) {
-                               pQuiet = (PWLAN_IE_QUIET)pIE_Quiet;
-                               CARDbSetQuiet(pMgmt->pAdapter,
-                                             true,
-                                             pQuiet->byQuietCount,
-                                             pQuiet->byQuietPeriod,
-                                             *((unsigned short *)pQuiet->abyQuietDuration),
-                                             *((unsigned short *)pQuiet->abyQuietOffset)
-);
-                       } else {
-                               pQuiet = (PWLAN_IE_QUIET)pIE_Quiet;
-                               CARDbSetQuiet(pMgmt->pAdapter,
-                                             false,
-                                             pQuiet->byQuietCount,
-                                             pQuiet->byQuietPeriod,
-                                             *((unsigned short *)pQuiet->abyQuietDuration),
-                                             *((unsigned short *)pQuiet->abyQuietOffset)
-                                       );
-                       }
-               }
-       }
-
-       if (bParsingQuiet && (pQuiet != NULL))
-               CARDbStartQuiet(pMgmt->pAdapter);
-
-       pBSSList->uIELength = uIELength;
-       if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN)
-               pBSSList->uIELength = WLAN_BEACON_FR_MAXLEN;
-       memcpy(pBSSList->abyIEs, pbyIEs, pBSSList->uIELength);
-
-       return true;
-}
-
-/*+
- *
- * Routine Description:
- *    Search Node DB table to find the index of matched DstAddr
- *
- * Return Value:
- *    None
- *
- -*/
-
-bool
-BSSDBbIsSTAInNodeDB(void *pMgmtObject, unsigned char *abyDstAddr,
-                   unsigned int *puNodeIndex)
-{
-       PSMgmtObject    pMgmt = (PSMgmtObject) pMgmtObject;
-       unsigned int ii;
-
-       /* Index = 0 reserved for AP Node */
-       for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
-               if (pMgmt->sNodeDBTable[ii].bActive) {
-                       if (ether_addr_equal(abyDstAddr,
-                                            pMgmt->sNodeDBTable[ii].abyMACAddr)) {
-                               *puNodeIndex = ii;
-                               return true;
-                       }
-               }
-       }
-
-       return false;
-};
-
-/*+
- *
- * Routine Description:
- *    Find an empty node and allocat it; if there is no empty node,
- *    then use the most inactive one.
- *
- * Return Value:
- *    None
- *
- -*/
-void
-BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       unsigned int ii;
-       unsigned int BigestCount = 0;
-       unsigned int SelectIndex;
-       struct sk_buff  *skb;
-       /*
-        * Index = 0 reserved for AP Node (In STA mode)
-        * Index = 0 reserved for Broadcast/MultiCast (In AP mode)
-        */
-       SelectIndex = 1;
-       for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
-               if (pMgmt->sNodeDBTable[ii].bActive) {
-                       if (pMgmt->sNodeDBTable[ii].uInActiveCount > BigestCount) {
-                               BigestCount = pMgmt->sNodeDBTable[ii].uInActiveCount;
-                               SelectIndex = ii;
-                       }
-               } else {
-                       break;
-               }
-       }
-
-       /* if not found replace uInActiveCount is largest one */
-       if (ii == (MAX_NODE_NUM + 1)) {
-               *puNodeIndex = SelectIndex;
-               pr_info("Replace inactive node = %d\n", SelectIndex);
-               /* clear ps buffer */
-               if (pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue.next != NULL) {
-                       while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue)) != NULL)
-                               dev_kfree_skb(skb);
-               }
-       } else {
-               *puNodeIndex = ii;
-       }
-
-       memset(&pMgmt->sNodeDBTable[*puNodeIndex], 0, sizeof(KnownNodeDB));
-       pMgmt->sNodeDBTable[*puNodeIndex].bActive = true;
-       pMgmt->sNodeDBTable[*puNodeIndex].uRatePollTimeout = FALLBACK_POLL_SECOND;
-       /* for AP mode PS queue */
-       skb_queue_head_init(&pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue);
-       pMgmt->sNodeDBTable[*puNodeIndex].byAuthSequence = 0;
-       pMgmt->sNodeDBTable[*puNodeIndex].wEnQueueCnt = 0;
-       pr_debug("Create node index = %d\n", ii);
-       return;
-};
-
-/*+
- *
- * Routine Description:
- *    Remove Node by NodeIndex
- *
- *
- * Return Value:
- *    None
- *
- -*/
-void
-BSSvRemoveOneNode(
-       void *hDeviceContext,
-       unsigned int uNodeIndex
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       unsigned char byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
-       struct sk_buff  *skb;
-
-       while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue)) != NULL)
-               dev_kfree_skb(skb);
-       /* clear context */
-       memset(&pMgmt->sNodeDBTable[uNodeIndex], 0, sizeof(KnownNodeDB));
-       /* clear tx bit map */
-       pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[uNodeIndex].wAID >> 3] &=  ~byMask[pMgmt->sNodeDBTable[uNodeIndex].wAID & 7];
-
-       return;
-};
-/*+
- *
- * Routine Description:
- *    Update AP Node content in Index 0 of KnownNodeDB
- *
- *
- * Return Value:
- *    None
- *
- -*/
-
-void
-BSSvUpdateAPNode(
-       void *hDeviceContext,
-       unsigned short *pwCapInfo,
-       PWLAN_IE_SUPP_RATES pSuppRates,
-       PWLAN_IE_SUPP_RATES pExtSuppRates
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       unsigned int uRateLen = WLAN_RATES_MAXLEN;
-
-       memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB));
-
-       pMgmt->sNodeDBTable[0].bActive = true;
-       if (pDevice->eCurrentPHYType == PHY_TYPE_11B)
-               uRateLen = WLAN_RATES_MAXLEN_11B;
-       pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pSuppRates,
-                                               (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                                               uRateLen);
-       pMgmt->abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pExtSuppRates,
-                                                  (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
-                                                  uRateLen);
-       RATEvParseMaxRate((void *)pDevice,
-                         (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                         (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
-                         true,
-                         &(pMgmt->sNodeDBTable[0].wMaxBasicRate),
-                         &(pMgmt->sNodeDBTable[0].wMaxSuppRate),
-                         &(pMgmt->sNodeDBTable[0].wSuppRate),
-                         &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate),
-                         &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate)
-);
-       memcpy(pMgmt->sNodeDBTable[0].abyMACAddr, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN);
-       pMgmt->sNodeDBTable[0].wTxDataRate = pMgmt->sNodeDBTable[0].wMaxSuppRate;
-       pMgmt->sNodeDBTable[0].bShortPreamble = WLAN_GET_CAP_INFO_SHORTPREAMBLE(*pwCapInfo);
-       pMgmt->sNodeDBTable[0].uRatePollTimeout = FALLBACK_POLL_SECOND;
-       netdev_dbg(pDevice->dev, "BSSvUpdateAPNode:MaxSuppRate is %d\n",
-                  pMgmt->sNodeDBTable[0].wMaxSuppRate);
-       /* auto rate fallback function initiation */
-       pr_debug("pMgmt->sNodeDBTable[0].wTxDataRate = %d\n",
-                pMgmt->sNodeDBTable[0].wTxDataRate);
-};
-
-/*+
- *
- * Routine Description:
- *    Add Multicast Node content in Index 0 of KnownNodeDB
- *
- *
- * Return Value:
- *    None
- *
- -*/
-
-void
-BSSvAddMulticastNode(
-       void *hDeviceContext
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-
-       if (!pDevice->bEnableHostWEP)
-               memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB));
-       memset(pMgmt->sNodeDBTable[0].abyMACAddr, 0xff, WLAN_ADDR_LEN);
-       pMgmt->sNodeDBTable[0].bActive = true;
-       pMgmt->sNodeDBTable[0].bPSEnable = false;
-       skb_queue_head_init(&pMgmt->sNodeDBTable[0].sTxPSQueue);
-       RATEvParseMaxRate((void *)pDevice,
-                         (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                         (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
-                         true,
-                         &(pMgmt->sNodeDBTable[0].wMaxBasicRate),
-                         &(pMgmt->sNodeDBTable[0].wMaxSuppRate),
-                         &(pMgmt->sNodeDBTable[0].wSuppRate),
-                         &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate),
-                         &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate)
-);
-       pMgmt->sNodeDBTable[0].wTxDataRate = pMgmt->sNodeDBTable[0].wMaxBasicRate;
-       netdev_dbg(pDevice->dev,
-                  "BSSvAddMultiCastNode:pMgmt->sNodeDBTable[0].wTxDataRate is %d\n",
-                  pMgmt->sNodeDBTable[0].wTxDataRate);
-       pMgmt->sNodeDBTable[0].uRatePollTimeout = FALLBACK_POLL_SECOND;
-};
-
-/*+
- *
- * Routine Description:
- *
- *
- *  Second call back function to update Node DB info & AP link status
- *
- *
- * Return Value:
- *    none.
- *
- -*/
-void
-BSSvSecondCallBack(
-       void *hDeviceContext
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       unsigned int ii;
-       PWLAN_IE_SSID   pItemSSID, pCurrSSID;
-       unsigned int uSleepySTACnt = 0;
-       unsigned int uNonShortSlotSTACnt = 0;
-       unsigned int uLongPreambleSTACnt = 0;
-       viawget_wpa_header *wpahdr;  /* DavidWang */
-
-       spin_lock_irq(&pDevice->lock);
-
-       pDevice->uAssocCount = 0;
-
-       pDevice->byERPFlag &=
-               ~(WLAN_SET_ERP_BARKER_MODE(1) | WLAN_SET_ERP_NONERP_PRESENT(1));
-
-       if (pDevice->wUseProtectCntDown > 0) {
-               pDevice->wUseProtectCntDown--;
-       } else {
-               /* disable protect mode */
-               pDevice->byERPFlag &= ~(WLAN_SET_ERP_USE_PROTECTION(1));
-       }
-
-       if (pDevice->eCommandState == WLAN_ASSOCIATE_WAIT) {
-               pDevice->byReAssocCount++;
-               /* 10 sec timeout */
-               if ((pDevice->byReAssocCount > 10) && (!pDevice->bLinkPass)) {
-                       netdev_info(pDevice->dev, "Re-association timeout!!!\n");
-                       pDevice->byReAssocCount = 0;
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-                       {
-                               union iwreq_data  wrqu;
-
-                               memset(&wrqu, 0, sizeof(wrqu));
-                               wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-                               PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
-                               wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
-                       }
-#endif
-               } else if (pDevice->bLinkPass)
-                       pDevice->byReAssocCount = 0;
-       }
-
-#ifdef Calcu_LinkQual
-       s_uCalculateLinkQual((void *)pDevice);
-#endif
-
-       for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
-               if (pMgmt->sNodeDBTable[ii].bActive) {
-                       /* increase in-activity counter */
-                       pMgmt->sNodeDBTable[ii].uInActiveCount++;
-
-                       if (ii > 0) {
-                               if (pMgmt->sNodeDBTable[ii].uInActiveCount > MAX_INACTIVE_COUNT) {
-                                       BSSvRemoveOneNode(pDevice, ii);
-                                       pr_debug("Inactive timeout [%d] sec, STA index = [%d] remove\n",
-                                                MAX_INACTIVE_COUNT, ii);
-                                       continue;
-                               }
-
-                               if (pMgmt->sNodeDBTable[ii].eNodeState >= NODE_ASSOC) {
-                                       pDevice->uAssocCount++;
-
-                                       /* check if Non ERP exist */
-                                       if (pMgmt->sNodeDBTable[ii].uInActiveCount < ERP_RECOVER_COUNT) {
-                                               if (!pMgmt->sNodeDBTable[ii].bShortPreamble) {
-                                                       pDevice->byERPFlag |= WLAN_SET_ERP_BARKER_MODE(1);
-                                                       uLongPreambleSTACnt++;
-                                               }
-                                               if (!pMgmt->sNodeDBTable[ii].bERPExist) {
-                                                       pDevice->byERPFlag |= WLAN_SET_ERP_NONERP_PRESENT(1);
-                                                       pDevice->byERPFlag |= WLAN_SET_ERP_USE_PROTECTION(1);
-                                               }
-                                               if (!pMgmt->sNodeDBTable[ii].bShortSlotTime)
-                                                       uNonShortSlotSTACnt++;
-                                       }
-                               }
-
-                               /* check if any STA in PS mode */
-                               if (pMgmt->sNodeDBTable[ii].bPSEnable)
-                                       uSleepySTACnt++;
-
-                       }
-
-                       /* rate fallback check */
-                       if (!pDevice->bFixRate) {
-                               if (ii > 0) {
-                                       /* ii = 0 for multicast node (AP & Adhoc) */
-                                       RATEvTxRateFallBack((void *)pDevice, &(pMgmt->sNodeDBTable[ii]));
-                               } else {
-                                       /* ii = 0 reserved for unicast AP node (Infra STA) */
-                                       if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA)
-                                               netdev_dbg(pDevice->dev,
-                                                          "SecondCallback:Before:TxDataRate is %d\n",
-                                                          pMgmt->sNodeDBTable[0].wTxDataRate);
-                                       RATEvTxRateFallBack((void *)pDevice, &(pMgmt->sNodeDBTable[ii]));
-                                       netdev_dbg(pDevice->dev,
-                                                  "SecondCallback:After:TxDataRate is %d\n",
-                                                  pMgmt->sNodeDBTable[0].wTxDataRate);
-
-                               }
-
-                       }
-
-                       /* check if pending PS queue */
-                       if (pMgmt->sNodeDBTable[ii].wEnQueueCnt != 0) {
-                               pr_debug("Index= %d, Queue = %d pending\n",
-                                        ii,
-                                        pMgmt->sNodeDBTable[ii].wEnQueueCnt);
-                               if ((ii > 0) && (pMgmt->sNodeDBTable[ii].wEnQueueCnt > 15)) {
-                                       BSSvRemoveOneNode(pDevice, ii);
-                                       pr_info("Pending many queues PS STA Index = %d remove\n",
-                                               ii);
-                                       continue;
-                               }
-                       }
-               }
-
-       }
-
-       if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->eCurrentPHYType == PHY_TYPE_11G)) {
-               /* on/off protect mode */
-               if (WLAN_GET_ERP_USE_PROTECTION(pDevice->byERPFlag)) {
-                       if (!pDevice->bProtectMode) {
-                               MACvEnableProtectMD(pDevice->PortOffset);
-                               pDevice->bProtectMode = true;
-                       }
-               } else {
-                       if (pDevice->bProtectMode) {
-                               MACvDisableProtectMD(pDevice->PortOffset);
-                               pDevice->bProtectMode = false;
-                       }
-               }
-               /* on/off short slot time */
-
-               if (uNonShortSlotSTACnt > 0) {
-                       if (pDevice->bShortSlotTime) {
-                               pDevice->bShortSlotTime = false;
-                               BBvSetShortSlotTime(pDevice);
-                               vUpdateIFS((void *)pDevice);
-                       }
-               } else {
-                       if (!pDevice->bShortSlotTime) {
-                               pDevice->bShortSlotTime = true;
-                               BBvSetShortSlotTime(pDevice);
-                               vUpdateIFS((void *)pDevice);
-                       }
-               }
-
-               /* on/off barker long preamble mode */
-
-               if (uLongPreambleSTACnt > 0) {
-                       if (!pDevice->bBarkerPreambleMd) {
-                               MACvEnableBarkerPreambleMd(pDevice->PortOffset);
-                               pDevice->bBarkerPreambleMd = true;
-                       }
-               } else {
-                       if (pDevice->bBarkerPreambleMd) {
-                               MACvDisableBarkerPreambleMd(pDevice->PortOffset);
-                               pDevice->bBarkerPreambleMd = false;
-                       }
-               }
-
-       }
-
-       /* check if any STA in PS mode, enable DTIM multicast deliver */
-       if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
-               if (uSleepySTACnt > 0)
-                       pMgmt->sNodeDBTable[0].bPSEnable = true;
-               else
-                       pMgmt->sNodeDBTable[0].bPSEnable = false;
-       }
-
-       pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
-       pCurrSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
-
-       if ((pMgmt->eCurrMode == WMAC_MODE_STANDBY) ||
-           (pMgmt->eCurrMode == WMAC_MODE_ESS_STA)) {
-               /* assoc with BSS */
-               if (pMgmt->sNodeDBTable[0].bActive) {
-                       if (pDevice->bUpdateBBVGA)
-                               s_vCheckPreEDThreshold((void *)pDevice);
-
-                       if ((pMgmt->sNodeDBTable[0].uInActiveCount >= (LOST_BEACON_COUNT/2)) &&
-                           (pDevice->byBBVGACurrent != pDevice->abyBBVGA[0])) {
-                               pDevice->byBBVGANew = pDevice->abyBBVGA[0];
-                               bScheduleCommand((void *)pDevice, WLAN_CMD_CHANGE_BBSENSITIVITY, NULL);
-                       }
-
-                       if (pMgmt->sNodeDBTable[0].uInActiveCount >= LOST_BEACON_COUNT) {
-                               pMgmt->sNodeDBTable[0].bActive = false;
-                               pMgmt->eCurrMode = WMAC_MODE_STANDBY;
-                               pMgmt->eCurrState = WMAC_STATE_IDLE;
-                               netif_stop_queue(pDevice->dev);
-                               pDevice->bLinkPass = false;
-                               pDevice->bRoaming = true;
-                               pr_info("Lost AP beacon [%d] sec, disconnected !\n",
-                                       pMgmt->sNodeDBTable[0].uInActiveCount);
-                               if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
-                                       wpahdr = (viawget_wpa_header *)pDevice->skb->data;
-                                       wpahdr->type = VIAWGET_DISASSOC_MSG;
-                                       wpahdr->resp_ie_len = 0;
-                                       wpahdr->req_ie_len = 0;
-                                       skb_put(pDevice->skb, sizeof(viawget_wpa_header));
-                                       pDevice->skb->dev = pDevice->wpadev;
-                                       skb_reset_mac_header(pDevice->skb);
-                                       pDevice->skb->pkt_type = PACKET_HOST;
-                                       pDevice->skb->protocol = htons(ETH_P_802_2);
-                                       memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
-                                       netif_rx(pDevice->skb);
-                                       pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
-                               }
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-                               {
-                                       union iwreq_data  wrqu;
-
-                                       memset(&wrqu, 0, sizeof(wrqu));
-                                       wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-                                       PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
-                                       wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
-                               }
-#endif
-                       }
-               } else if (pItemSSID->len != 0) {
-                       if (pDevice->uAutoReConnectTime < 10) {
-                               pDevice->uAutoReConnectTime++;
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-                               /*
-                                * network manager support need not do
-                                * Roaming scan???
-                                */
-                               if (pDevice->bWPASuppWextEnabled)
-                                       pDevice->uAutoReConnectTime = 0;
-#endif
-                       } else {
-                               /*
-                                * mike use old encryption status
-                                * for wpa reauthentication
-                                */
-                               if (pDevice->bWPADEVUp)
-                                       pDevice->eEncryptionStatus = pDevice->eOldEncryptionStatus;
-
-                               pr_debug("Roaming ...\n");
-                               BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass);
-                               pMgmt->eScanType = WMAC_SCAN_ACTIVE;
-                               bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
-                               bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID);
-                               pDevice->uAutoReConnectTime = 0;
-                       }
-               }
-       }
-
-       if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
-               /* if adhoc started which essid is NULL string, rescanning */
-               if ((pMgmt->eCurrState == WMAC_STATE_STARTED) && (pCurrSSID->len == 0)) {
-                       if (pDevice->uAutoReConnectTime < 10) {
-                               pDevice->uAutoReConnectTime++;
-                       } else {
-                               pr_info("Adhoc re-scanning ...\n");
-                               pMgmt->eScanType = WMAC_SCAN_ACTIVE;
-                               bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL);
-                               bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL);
-                               pDevice->uAutoReConnectTime = 0;
-                       }
-               }
-               if (pMgmt->eCurrState == WMAC_STATE_JOINTED) {
-                       if (pDevice->bUpdateBBVGA)
-                               s_vCheckPreEDThreshold((void *)pDevice);
-                       if (pMgmt->sNodeDBTable[0].uInActiveCount >= ADHOC_LOST_BEACON_COUNT) {
-                               pr_info("Lost other STA beacon [%d] sec, started !\n",
-                                       pMgmt->sNodeDBTable[0].uInActiveCount);
-                               pMgmt->sNodeDBTable[0].uInActiveCount = 0;
-                               pMgmt->eCurrState = WMAC_STATE_STARTED;
-                               netif_stop_queue(pDevice->dev);
-                               pDevice->bLinkPass = false;
-                       }
-               }
-       }
-
-       spin_unlock_irq(&pDevice->lock);
-
-       pMgmt->sTimerSecondCallback.expires = RUN_AT(HZ);
-       add_timer(&pMgmt->sTimerSecondCallback);
-}
-
-/*+
- *
- * Routine Description:
- *
- *
- *  Update Tx attemps, Tx failure counter in Node DB
- *
- *
- * Return Value:
- *    none.
- *
- -*/
-
-void
-BSSvUpdateNodeTxCounter(
-       void *hDeviceContext,
-       unsigned char byTsr0,
-       unsigned char byTsr1,
-       unsigned char *pbyBuffer,
-       unsigned int uFIFOHeaderSize
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       unsigned int uNodeIndex = 0;
-       unsigned char byTxRetry = (byTsr0 & TSR0_NCR);
-       PSTxBufHead     pTxBufHead;
-       PS802_11Header  pMACHeader;
-       unsigned short wRate;
-       unsigned short wFallBackRate = RATE_1M;
-       unsigned char byFallBack;
-       unsigned int ii;
-
-       pTxBufHead = (PSTxBufHead) pbyBuffer;
-       if (pTxBufHead->wFIFOCtl & FIFOCTL_AUTO_FB_0)
-               byFallBack = AUTO_FB_0;
-       else if (pTxBufHead->wFIFOCtl & FIFOCTL_AUTO_FB_1)
-               byFallBack = AUTO_FB_1;
-       else
-               byFallBack = AUTO_FB_NONE;
-       wRate = pTxBufHead->wReserved;
-
-       /* Only Unicast using support rates */
-       if (pTxBufHead->wFIFOCtl & FIFOCTL_NEEDACK) {
-               pr_debug("wRate %04X, byTsr0 %02X, byTsr1 %02X\n",
-                        wRate, byTsr0, byTsr1);
-               if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) {
-                       pMgmt->sNodeDBTable[0].uTxAttempts += 1;
-                       if ((byTsr1 & TSR1_TERR) == 0) {
-                               /* transmit success, TxAttempts at least plus one */
-                               pMgmt->sNodeDBTable[0].uTxOk[MAX_RATE]++;
-                               if ((byFallBack == AUTO_FB_NONE) ||
-                                   (wRate < RATE_18M)) {
-                                       wFallBackRate = wRate;
-                               } else if (byFallBack == AUTO_FB_0) {
-                                       if (byTxRetry < 5)
-                                               wFallBackRate = awHWRetry0[wRate-RATE_18M][byTxRetry];
-                                       else
-                                               wFallBackRate = awHWRetry0[wRate-RATE_18M][4];
-                               } else if (byFallBack == AUTO_FB_1) {
-                                       if (byTxRetry < 5)
-                                               wFallBackRate = awHWRetry1[wRate-RATE_18M][byTxRetry];
-                                       else
-                                               wFallBackRate = awHWRetry1[wRate-RATE_18M][4];
-                               }
-                               pMgmt->sNodeDBTable[0].uTxOk[wFallBackRate]++;
-                       } else {
-                               pMgmt->sNodeDBTable[0].uTxFailures++;
-                       }
-                       pMgmt->sNodeDBTable[0].uTxRetry += byTxRetry;
-                       if (byTxRetry != 0) {
-                               pMgmt->sNodeDBTable[0].uTxFail[MAX_RATE] += byTxRetry;
-                               if ((byFallBack == AUTO_FB_NONE) ||
-                                   (wRate < RATE_18M)) {
-                                       pMgmt->sNodeDBTable[0].uTxFail[wRate] += byTxRetry;
-                               } else if (byFallBack == AUTO_FB_0) {
-                                       for (ii = 0; ii < byTxRetry; ii++) {
-                                               if (ii < 5)
-                                                       wFallBackRate = awHWRetry0[wRate-RATE_18M][ii];
-                                               else
-                                                       wFallBackRate = awHWRetry0[wRate-RATE_18M][4];
-                                               pMgmt->sNodeDBTable[0].uTxFail[wFallBackRate]++;
-                                       }
-                               } else if (byFallBack == AUTO_FB_1) {
-                                       for (ii = 0; ii < byTxRetry; ii++) {
-                                               if (ii < 5)
-                                                       wFallBackRate = awHWRetry1[wRate-RATE_18M][ii];
-                                               else
-                                                       wFallBackRate = awHWRetry1[wRate-RATE_18M][4];
-                                               pMgmt->sNodeDBTable[0].uTxFail[wFallBackRate]++;
-                                       }
-                               }
-                       }
-               }
-
-               if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
-                   (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
-                       pMACHeader = (PS802_11Header)(pbyBuffer + uFIFOHeaderSize);
-
-                       if (BSSDBbIsSTAInNodeDB((void *)pMgmt,  &(pMACHeader->abyAddr1[0]), &uNodeIndex)) {
-                               pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts += 1;
-                               if ((byTsr1 & TSR1_TERR) == 0) {
-                                       /* transmit success, TxAttempts at least plus one */
-                                       pMgmt->sNodeDBTable[uNodeIndex].uTxOk[MAX_RATE]++;
-                                       if ((byFallBack == AUTO_FB_NONE) ||
-                                           (wRate < RATE_18M)) {
-                                               wFallBackRate = wRate;
-                                       } else if (byFallBack == AUTO_FB_0) {
-                                               if (byTxRetry < 5)
-                                                       wFallBackRate = awHWRetry0[wRate-RATE_18M][byTxRetry];
-                                               else
-                                                       wFallBackRate = awHWRetry0[wRate-RATE_18M][4];
-                                       } else if (byFallBack == AUTO_FB_1) {
-                                               if (byTxRetry < 5)
-                                                       wFallBackRate = awHWRetry1[wRate-RATE_18M][byTxRetry];
-                                               else
-                                                       wFallBackRate = awHWRetry1[wRate-RATE_18M][4];
-                                       }
-                                       pMgmt->sNodeDBTable[uNodeIndex].uTxOk[wFallBackRate]++;
-                               } else {
-                                       pMgmt->sNodeDBTable[uNodeIndex].uTxFailures++;
-                               }
-                               pMgmt->sNodeDBTable[uNodeIndex].uTxRetry += byTxRetry;
-                               if (byTxRetry != 0) {
-                                       pMgmt->sNodeDBTable[uNodeIndex].uTxFail[MAX_RATE] += byTxRetry;
-                                       if ((byFallBack == AUTO_FB_NONE) ||
-                                           (wRate < RATE_18M)) {
-                                               pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wRate] += byTxRetry;
-                                       } else if (byFallBack == AUTO_FB_0) {
-                                               for (ii = 0; ii < byTxRetry; ii++) {
-                                                       if (ii < 5)
-                                                               wFallBackRate = awHWRetry0[wRate - RATE_18M][ii];
-                                                       else
-                                                               wFallBackRate = awHWRetry0[wRate - RATE_18M][4];
-                                                       pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wFallBackRate]++;
-                                               }
-                                       } else if (byFallBack == AUTO_FB_1) {
-                                               for (ii = 0; ii < byTxRetry; ii++) {
-                                                       if (ii < 5)
-                                                               wFallBackRate = awHWRetry1[wRate-RATE_18M][ii];
-                                                       else
-                                                               wFallBackRate = awHWRetry1[wRate-RATE_18M][4];
-                                                       pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wFallBackRate]++;
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-}
-
-/*+
- *
- * Routine Description:
- *    Clear Nodes & skb in DB Table
- *
- *
- * Parameters:
- *  In:
- *      hDeviceContext        - The adapter context.
- *      uStartIndex           - starting index
- *  Out:
- *      none
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-BSSvClearNodeDBTable(
-       void *hDeviceContext,
-       unsigned int uStartIndex
-)
-
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       struct sk_buff  *skb;
-       unsigned int ii;
-
-       for (ii = uStartIndex; ii < (MAX_NODE_NUM + 1); ii++) {
-               if (pMgmt->sNodeDBTable[ii].bActive) {
-                       /* check if sTxPSQueue has been initial */
-                       if (pMgmt->sNodeDBTable[ii].sTxPSQueue.next != NULL) {
-                               while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL) {
-                                       pr_debug("PS skb != NULL %d\n", ii);
-                                       dev_kfree_skb(skb);
-                               }
-                       }
-                       memset(&pMgmt->sNodeDBTable[ii], 0, sizeof(KnownNodeDB));
-               }
-       }
-
-       return;
-};
-
-void s_vCheckSensitivity(
-       void *hDeviceContext
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PKnownBSS       pBSSList = NULL;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       int             ii;
-
-       if ((pDevice->byLocalID <= REV_ID_VT3253_A1) && (pDevice->byRFType == RF_RFMD2959) &&
-           (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) {
-               return;
-       }
-
-       if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
-           ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
-               pBSSList = BSSpAddrIsInBSSList(pDevice, pMgmt->abyCurrBSSID, (PWLAN_IE_SSID)pMgmt->abyCurrSSID);
-               if (pBSSList != NULL) {
-                       /* Update BB Reg if RSSI is too strong */
-                       long    LocalldBmAverage = 0;
-                       long    uNumofdBm = 0;
-
-                       for (ii = 0; ii < RSSI_STAT_COUNT; ii++) {
-                               if (pBSSList->ldBmAverage[ii] != 0) {
-                                       uNumofdBm++;
-                                       LocalldBmAverage += pBSSList->ldBmAverage[ii];
-                               }
-                       }
-                       if (uNumofdBm > 0) {
-                               LocalldBmAverage = LocalldBmAverage/uNumofdBm;
-                               for (ii = 0; ii < BB_VGA_LEVEL; ii++) {
-                                       pr_debug("LocalldBmAverage:%ld, %ld %02x\n",
-                                                LocalldBmAverage,
-                                                pDevice->ldBmThreshold[ii],
-                                                pDevice->abyBBVGA[ii]);
-                                       if (LocalldBmAverage < pDevice->ldBmThreshold[ii]) {
-                                               pDevice->byBBVGANew = pDevice->abyBBVGA[ii];
-                                               break;
-                                       }
-                               }
-                               if (pDevice->byBBVGANew != pDevice->byBBVGACurrent) {
-                                       pDevice->uBBVGADiffCount++;
-                                       if (pDevice->uBBVGADiffCount >= BB_VGA_CHANGE_THRESHOLD)
-                                               bScheduleCommand((void *)pDevice, WLAN_CMD_CHANGE_BBSENSITIVITY, NULL);
-                               } else {
-                                       pDevice->uBBVGADiffCount = 0;
-                               }
-                       }
-               }
-       }
-}
-
-void
-BSSvClearAnyBSSJoinRecord(
-       void *hDeviceContext
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       unsigned int ii;
-
-       for (ii = 0; ii < MAX_BSS_NUM; ii++)
-               pMgmt->sBSSList[ii].bSelected = false;
-}
-
-#ifdef Calcu_LinkQual
-void s_uCalculateLinkQual(
-       void *hDeviceContext
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       unsigned long TxOkRatio, TxCnt;
-       unsigned long RxOkRatio, RxCnt;
-       unsigned long RssiRatio;
-       long ldBm;
-
-       TxCnt = pDevice->scStatistic.TxNoRetryOkCount +
-               pDevice->scStatistic.TxRetryOkCount +
-               pDevice->scStatistic.TxFailCount;
-       RxCnt = pDevice->scStatistic.RxFcsErrCnt +
-               pDevice->scStatistic.RxOkCnt;
-       TxOkRatio = (TxCnt < 6) ? 4000 : ((pDevice->scStatistic.TxNoRetryOkCount * 4000) / TxCnt);
-       RxOkRatio = (RxCnt < 6) ? 2000 : ((pDevice->scStatistic.RxOkCnt * 2000) / RxCnt);
-       /* decide link quality */
-       if (!pDevice->bLinkPass) {
-               pDevice->scStatistic.LinkQuality = 0;
-               pDevice->scStatistic.SignalStren = 0;
-       } else {
-               RFvRSSITodBm(pDevice, (unsigned char)(pDevice->uCurrRSSI), &ldBm);
-               if (-ldBm < 50)
-                       RssiRatio = 4000;
-               else if (-ldBm > 90)
-                       RssiRatio = 0;
-               else
-                       RssiRatio = (40-(-ldBm-50))*4000/40;
-               pDevice->scStatistic.SignalStren = RssiRatio/40;
-               pDevice->scStatistic.LinkQuality = (RssiRatio+TxOkRatio+RxOkRatio)/100;
-       }
-       pDevice->scStatistic.RxFcsErrCnt = 0;
-       pDevice->scStatistic.RxOkCnt = 0;
-       pDevice->scStatistic.TxFailCount = 0;
-       pDevice->scStatistic.TxNoRetryOkCount = 0;
-       pDevice->scStatistic.TxRetryOkCount = 0;
-}
-#endif
-
-void s_vCheckPreEDThreshold(
-       void *hDeviceContext
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PKnownBSS       pBSSList = NULL;
-       PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-
-       if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
-           ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
-               pBSSList = BSSpAddrIsInBSSList(pDevice, pMgmt->abyCurrBSSID, (PWLAN_IE_SSID)pMgmt->abyCurrSSID);
-               if (pBSSList != NULL)
-                       pDevice->byBBPreEDRSSI = (unsigned char) (~(pBSSList->ldBmAverRange) + 1);
-       }
-}
diff --git a/drivers/staging/vt6655/bssdb.h b/drivers/staging/vt6655/bssdb.h
deleted file mode 100644 (file)
index 5d4dd28..0000000
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: bssdb.h
- *
- * Purpose: Handles the Basic Service Set & Node Database functions
- *
- * Author: Lyndon Chen
- *
- * Date: July 16, 2002
- *
- */
-
-#ifndef __BSSDB_H__
-#define __BSSDB_H__
-
-#include <linux/skbuff.h>
-#include "80211hdr.h"
-#include "80211mgr.h"
-#include "card.h"
-
-#define MAX_NODE_NUM             64
-#define MAX_BSS_NUM              42
-#define LOST_BEACON_COUNT        10   // 10 sec, XP defined
-#define MAX_PS_TX_BUF            32   // sta max power saving tx buf
-#define ADHOC_LOST_BEACON_COUNT  30   // 30 sec, beacon lost for adhoc only
-#define MAX_INACTIVE_COUNT       300  // 300 sec, inactive STA node refresh
-
-#define USE_PROTECT_PERIOD       10   // 10 sec, Use protect mode check period
-#define ERP_RECOVER_COUNT        30   // 30 sec, ERP support callback check
-#define BSS_CLEAR_COUNT           1
-
-#define RSSI_STAT_COUNT          10
-#define MAX_CHECK_RSSI_COUNT     8
-
-// STA dwflags
-#define WLAN_STA_AUTH            BIT0
-#define WLAN_STA_ASSOC           BIT1
-#define WLAN_STA_PS              BIT2
-#define WLAN_STA_TIM             BIT3
-// permanent; do not remove entry on expiration
-#define WLAN_STA_PERM            BIT4
-// If 802.1X is used, this flag is
-// controlling whether STA is authorized to
-// send and receive non-IEEE 802.1X frames
-#define WLAN_STA_AUTHORIZED      BIT5
-
-#define MAX_RATE            12
-
-#define MAX_WPA_IE_LEN      64
-
-//
-// IEEE 802.11 Structures and definitions
-//
-
-typedef enum _NDIS_802_11_NETWORK_TYPE {
-       Ndis802_11FH,
-       Ndis802_11DS,
-       Ndis802_11OFDM5,
-       Ndis802_11OFDM24,
-       Ndis802_11NetworkTypeMax    // not a real type, defined as an upper bound
-} NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE;
-
-typedef struct tagSERPObject {
-       bool bERPExist;
-       unsigned char byERP;
-} ERPObject, *PERPObject;
-
-typedef struct tagSRSNCapObject {
-       bool bRSNCapExist;
-       unsigned short wRSNCap;
-} SRSNCapObject, *PSRSNCapObject;
-
-// BSS info(AP)
-#pragma pack(1)
-typedef struct tagKnownBSS {
-       bool bActive;
-       unsigned char abyBSSID[WLAN_BSSID_LEN];
-       unsigned int    uChannel;
-       unsigned char abySuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
-       unsigned char abyExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
-       unsigned int    uRSSI;
-       unsigned char bySQ;
-       unsigned short wBeaconInterval;
-       unsigned short wCapInfo;
-       unsigned char abySSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
-       unsigned char byRxRate;
-
-       unsigned char byRSSIStatCnt;
-       long            ldBmMAX;
-       long            ldBmAverage[RSSI_STAT_COUNT];
-       long            ldBmAverRange;
-       bool bSelected;
-
-       bool bWPAValid;
-       unsigned char byGKType;
-       unsigned char abyPKType[4];
-       unsigned short wPKCount;
-       unsigned char abyAuthType[4];
-       unsigned short wAuthCount;
-       unsigned char byDefaultK_as_PK;
-       unsigned char byReplayIdx;
-
-       bool bWPA2Valid;
-       unsigned char byCSSGK;
-       unsigned short wCSSPKCount;
-       unsigned char abyCSSPK[4];
-       unsigned short wAKMSSAuthCount;
-       unsigned char abyAKMSSAuthType[4];
-
-       unsigned char byWPAIE[MAX_WPA_IE_LEN];
-       unsigned char byRSNIE[MAX_WPA_IE_LEN];
-       unsigned short wWPALen;
-       unsigned short wRSNLen;
-
-       unsigned int    uClearCount;
-       unsigned int    uIELength;
-       u64 qwBSSTimestamp;
-       u64 qwLocalTSF;
-
-       CARD_PHY_TYPE   eNetworkTypeInUse;
-
-       ERPObject       sERP;
-       SRSNCapObject   sRSNCapObj;
-       unsigned char abyIEs[1024];
-} __attribute__ ((__packed__))
-KnownBSS , *PKnownBSS;
-
-#pragma pack()
-
-typedef enum tagNODE_STATE {
-       NODE_FREE,
-       NODE_AGED,
-       NODE_KNOWN,
-       NODE_AUTH,
-       NODE_ASSOC
-} NODE_STATE, *PNODE_STATE;
-
-// STA node info
-typedef struct tagKnownNodeDB {
-       bool bActive;
-       unsigned char abyMACAddr[WLAN_ADDR_LEN];
-       unsigned char abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
-       unsigned char abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
-       unsigned short wTxDataRate;
-       bool bShortPreamble;
-       bool bERPExist;
-       bool bShortSlotTime;
-       unsigned int    uInActiveCount;
-       unsigned short wMaxBasicRate;     //Get from byTopOFDMBasicRate or byTopCCKBasicRate which depends on packetTyp.
-       unsigned short wMaxSuppRate;      //Records the highest supported rate getting from SuppRates IE and ExtSuppRates IE in Beacon.
-       unsigned short wSuppRate;
-       unsigned char byTopOFDMBasicRate;//Records the highest basic rate in OFDM mode
-       unsigned char byTopCCKBasicRate; //Records the highest basic rate in CCK mode
-
-       // For AP mode
-       struct sk_buff_head sTxPSQueue;
-       unsigned short wCapInfo;
-       unsigned short wListenInterval;
-       unsigned short wAID;
-       NODE_STATE      eNodeState;
-       bool bPSEnable;
-       bool bRxPSPoll;
-       unsigned char byAuthSequence;
-       unsigned long ulLastRxJiffer;
-       unsigned char bySuppRate;
-       unsigned long dwFlags;
-       unsigned short wEnQueueCnt;
-
-       bool bOnFly;
-       unsigned long long       KeyRSC;
-       unsigned char byKeyIndex;
-       unsigned long dwKeyIndex;
-       unsigned char byCipherSuite;
-       unsigned long dwTSC47_16;
-       unsigned short wTSC15_0;
-       unsigned int    uWepKeyLength;
-       unsigned char abyWepKey[WLAN_WEPMAX_KEYLEN];
-       // Auto rate fallback vars
-       bool bIsInFallback;
-       unsigned int    uAverageRSSI;
-       unsigned int    uRateRecoveryTimeout;
-       unsigned int    uRatePollTimeout;
-       unsigned int    uTxFailures;
-       unsigned int    uTxAttempts;
-
-       unsigned int    uTxRetry;
-       unsigned int    uFailureRatio;
-       unsigned int    uRetryRatio;
-       unsigned int    uTxOk[MAX_RATE+1];
-       unsigned int    uTxFail[MAX_RATE+1];
-       unsigned int    uTimeCount;
-} KnownNodeDB, *PKnownNodeDB;
-
-PKnownBSS
-BSSpSearchBSSList(
-       void *hDeviceContext,
-       unsigned char *pbyDesireBSSID,
-       unsigned char *pbyDesireSSID,
-       CARD_PHY_TYPE ePhyType
-);
-
-PKnownBSS
-BSSpAddrIsInBSSList(
-       void *hDeviceContext,
-       unsigned char *abyBSSID,
-       PWLAN_IE_SSID pSSID
-);
-
-void
-BSSvClearBSSList(
-       void *hDeviceContext,
-       bool bKeepCurrBSSID
-);
-
-bool
-BSSbInsertToBSSList(
-       void *hDeviceContext,
-       unsigned char *abyBSSIDAddr,
-       __le64 qwTimestamp,
-       unsigned short wBeaconInterval,
-       unsigned short wCapInfo,
-       unsigned char byCurrChannel,
-       PWLAN_IE_SSID pSSID,
-       PWLAN_IE_SUPP_RATES pSuppRates,
-       PWLAN_IE_SUPP_RATES pExtSuppRates,
-       PERPObject psERP,
-       PWLAN_IE_RSN pRSN,
-       PWLAN_IE_RSN_EXT pRSNWPA,
-       PWLAN_IE_COUNTRY pIE_Country,
-       PWLAN_IE_QUIET pIE_Quiet,
-       unsigned int uIELength,
-       unsigned char *pbyIEs,
-       void *pRxPacketContext
-);
-
-bool
-BSSbUpdateToBSSList(
-       void *hDeviceContext,
-       __le64 qwTimestamp,
-       unsigned short wBeaconInterval,
-       unsigned short wCapInfo,
-       unsigned char byCurrChannel,
-       bool bChannelHit,
-       PWLAN_IE_SSID pSSID,
-       PWLAN_IE_SUPP_RATES pSuppRates,
-       PWLAN_IE_SUPP_RATES pExtSuppRates,
-       PERPObject psERP,
-       PWLAN_IE_RSN pRSN,
-       PWLAN_IE_RSN_EXT pRSNWPA,
-       PWLAN_IE_COUNTRY pIE_Country,
-       PWLAN_IE_QUIET pIE_Quiet,
-       PKnownBSS pBSSList,
-       unsigned int uIELength,
-       unsigned char *pbyIEs,
-       void *pRxPacketContext
-);
-
-bool
-BSSDBbIsSTAInNodeDB(void *hDeviceContext, unsigned char *abyDstAddr,
-                   unsigned int *puNodeIndex);
-
-void
-BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex);
-
-void
-BSSvUpdateAPNode(
-       void *hDeviceContext,
-       unsigned short *pwCapInfo,
-       PWLAN_IE_SUPP_RATES pItemRates,
-       PWLAN_IE_SUPP_RATES pExtSuppRates
-);
-
-void
-BSSvSecondCallBack(
-       void *hDeviceContext
-);
-
-void
-BSSvUpdateNodeTxCounter(
-       void *hDeviceContext,
-       unsigned char byTsr0,
-       unsigned char byTsr1,
-       unsigned char *pbyBuffer,
-       unsigned int uFIFOHeaderSize
-);
-
-void
-BSSvRemoveOneNode(
-       void *hDeviceContext,
-       unsigned int uNodeIndex
-);
-
-void
-BSSvAddMulticastNode(
-       void *hDeviceContext
-);
-
-void
-BSSvClearNodeDBTable(
-       void *hDeviceContext,
-       unsigned int uStartIndex
-);
-
-void
-BSSvClearAnyBSSJoinRecord(
-       void *hDeviceContext
-);
-
-#endif //__BSSDB_H__
index 5a69502..bff77c8 100644 (file)
@@ -34,8 +34,6 @@
  *      CARDvUpdateNextTBTT - Sync. NIC Beacon time
  *      CARDbRadioPowerOff - Turn Off NIC Radio Power
  *      CARDbRadioPowerOn - Turn On NIC Radio Power
- *      CARDbSetWEPMode - Set NIC Wep mode
- *      CARDbSetTxPower - Set NIC tx power
  *
  * Revision History:
  *      06-10-2003 Bryan YC Fan:  Re-write codes to support VT3253 spec.
 #include "mac.h"
 #include "desc.h"
 #include "rf.h"
-#include "vntwifi.h"
 #include "power.h"
-#include "key.h"
-#include "rc4.h"
-#include "country.h"
-#include "channel.h"
 
 /*---------------------  Static Definitions -------------------------*/
 
-#define C_SIFS_A        16      // micro sec.
+#define C_SIFS_A        16      /* micro sec. */
 #define C_SIFS_BG       10
 
-#define C_EIFS          80      // micro sec.
+#define C_EIFS          80      /* micro sec. */
 
-#define C_SLOT_SHORT    9       // micro sec.
+#define C_SLOT_SHORT    9       /* micro sec. */
 #define C_SLOT_LONG     20
 
-#define C_CWMIN_A       15      // slot time
+#define C_CWMIN_A       15      /* slot time */
 #define C_CWMIN_B       31
 
-#define C_CWMAX         1023    // slot time
+#define C_CWMAX         1023    /* slot time */
 
-#define WAIT_BEACON_TX_DOWN_TMO         3    // Times
-
-//1M,   2M,   5M,  11M,  18M,  24M,  36M,  54M
-static unsigned char abyDefaultSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
-//6M,   9M,  12M,  48M
-static unsigned char abyDefaultExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60};
-//6M,   9M,  12M,  18M,  24M,  36M,  48M,  54M
-static unsigned char abyDefaultSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
-//1M,   2M,   5M,  11M,
-static unsigned char abyDefaultSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
+#define WAIT_BEACON_TX_DOWN_TMO         3    /* Times */
 
 /*---------------------  Static Variables  --------------------------*/
 
@@ -113,7 +97,6 @@ s_vCalculateOFDMRParameter(
  *      pbyRsvTime      - pointer to RSPINF RsvTime field
  *
  * Return Value: none
- *
  */
 static
 void
@@ -126,7 +109,7 @@ s_vCalculateOFDMRParameter(
 {
        switch (byRate) {
        case RATE_6M:
-               if (ePHYType == PHY_TYPE_11A) {//5GHZ
+               if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */
                        *pbyTxRate = 0x9B;
                        *pbyRsvTime = 44;
                } else {
@@ -136,7 +119,7 @@ s_vCalculateOFDMRParameter(
                break;
 
        case RATE_9M:
-               if (ePHYType == PHY_TYPE_11A) {//5GHZ
+               if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */
                        *pbyTxRate = 0x9F;
                        *pbyRsvTime = 36;
                } else {
@@ -146,7 +129,7 @@ s_vCalculateOFDMRParameter(
                break;
 
        case RATE_12M:
-               if (ePHYType == PHY_TYPE_11A) {//5GHZ
+               if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */
                        *pbyTxRate = 0x9A;
                        *pbyRsvTime = 32;
                } else {
@@ -156,7 +139,7 @@ s_vCalculateOFDMRParameter(
                break;
 
        case RATE_18M:
-               if (ePHYType == PHY_TYPE_11A) {//5GHZ
+               if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */
                        *pbyTxRate = 0x9E;
                        *pbyRsvTime = 28;
                } else {
@@ -166,7 +149,7 @@ s_vCalculateOFDMRParameter(
                break;
 
        case RATE_36M:
-               if (ePHYType == PHY_TYPE_11A) {//5GHZ
+               if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */
                        *pbyTxRate = 0x9D;
                        *pbyRsvTime = 24;
                } else {
@@ -176,7 +159,7 @@ s_vCalculateOFDMRParameter(
                break;
 
        case RATE_48M:
-               if (ePHYType == PHY_TYPE_11A) {//5GHZ
+               if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */
                        *pbyTxRate = 0x98;
                        *pbyRsvTime = 24;
                } else {
@@ -186,7 +169,7 @@ s_vCalculateOFDMRParameter(
                break;
 
        case RATE_54M:
-               if (ePHYType == PHY_TYPE_11A) {//5GHZ
+               if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */
                        *pbyTxRate = 0x9C;
                        *pbyRsvTime = 24;
                } else {
@@ -197,7 +180,7 @@ s_vCalculateOFDMRParameter(
 
        case RATE_24M:
        default:
-               if (ePHYType == PHY_TYPE_11A) {//5GHZ
+               if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */
                        *pbyTxRate = 0x99;
                        *pbyRsvTime = 28;
                } else {
@@ -208,166 +191,8 @@ s_vCalculateOFDMRParameter(
        }
 }
 
-/*
- * Description: Set RSPINF
- *
- * Parameters:
- *  In:
- *      pDevice             - The adapter to be set
- *  Out:
- *      none
- *
- * Return Value: None.
- *
- */
-static
-void
-s_vSetRSPINF(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType,
-            void *pvSupportRateIEs, void *pvExtSupportRateIEs)
-{
-       union vnt_phy_field_swap phy;
-       unsigned char byTxRate = 0, byRsvTime = 0;    // For OFDM
-
-       //Set to Page1
-       MACvSelectPage1(pDevice->PortOffset);
-
-       /* RSPINF_b_1 */
-       vnt_get_phy_field(pDevice,
-                         14,
-                         VNTWIFIbyGetACKTxRate(RATE_1M, pvSupportRateIEs, pvExtSupportRateIEs),
-                         PK_TYPE_11B,
-                         &phy.field_read);
-
-        /* swap over to get correct write order */
-       swap(phy.swap[0], phy.swap[1]);
-
-       VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_1, phy.field_write);
-
-       /* RSPINF_b_2 */
-       vnt_get_phy_field(pDevice, 14,
-                         VNTWIFIbyGetACKTxRate(RATE_2M, pvSupportRateIEs, pvExtSupportRateIEs),
-                         PK_TYPE_11B, &phy.field_read);
-
-       swap(phy.swap[0], phy.swap[1]);
-
-       VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_2, phy.field_write);
-
-       /* RSPINF_b_5 */
-       vnt_get_phy_field(pDevice, 14,
-                         VNTWIFIbyGetACKTxRate(RATE_5M, pvSupportRateIEs, pvExtSupportRateIEs),
-                         PK_TYPE_11B, &phy.field_read);
-
-       swap(phy.swap[0], phy.swap[1]);
-
-       VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_5, phy.field_write);
-
-       /* RSPINF_b_11 */
-       vnt_get_phy_field(pDevice, 14,
-                         VNTWIFIbyGetACKTxRate(RATE_11M, pvSupportRateIEs, pvExtSupportRateIEs),
-                         PK_TYPE_11B, &phy.field_read);
-
-       swap(phy.swap[0], phy.swap[1]);
-
-       VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_11, phy.field_write);
-
-       //RSPINF_a_6
-       s_vCalculateOFDMRParameter(RATE_6M,
-                                  ePHYType,
-                                  &byTxRate,
-                                  &byRsvTime);
-       VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_6, MAKEWORD(byTxRate, byRsvTime));
-       //RSPINF_a_9
-       s_vCalculateOFDMRParameter(RATE_9M,
-                                  ePHYType,
-                                  &byTxRate,
-                                  &byRsvTime);
-       VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_9, MAKEWORD(byTxRate, byRsvTime));
-       //RSPINF_a_12
-       s_vCalculateOFDMRParameter(RATE_12M,
-                                  ePHYType,
-                                  &byTxRate,
-                                  &byRsvTime);
-       VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_12, MAKEWORD(byTxRate, byRsvTime));
-       //RSPINF_a_18
-       s_vCalculateOFDMRParameter(RATE_18M,
-                                  ePHYType,
-                                  &byTxRate,
-                                  &byRsvTime);
-       VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_18, MAKEWORD(byTxRate, byRsvTime));
-       //RSPINF_a_24
-       s_vCalculateOFDMRParameter(RATE_24M,
-                                  ePHYType,
-                                  &byTxRate,
-                                  &byRsvTime);
-       VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate, byRsvTime));
-       //RSPINF_a_36
-       s_vCalculateOFDMRParameter(
-               VNTWIFIbyGetACKTxRate(RATE_36M, pvSupportRateIEs, pvExtSupportRateIEs),
-               ePHYType,
-               &byTxRate,
-               &byRsvTime);
-       VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate, byRsvTime));
-       //RSPINF_a_48
-       s_vCalculateOFDMRParameter(
-               VNTWIFIbyGetACKTxRate(RATE_48M, pvSupportRateIEs, pvExtSupportRateIEs),
-               ePHYType,
-               &byTxRate,
-               &byRsvTime);
-       VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate, byRsvTime));
-       //RSPINF_a_54
-       s_vCalculateOFDMRParameter(
-               VNTWIFIbyGetACKTxRate(RATE_54M, pvSupportRateIEs, pvExtSupportRateIEs),
-               ePHYType,
-               &byTxRate,
-               &byRsvTime);
-       VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate, byRsvTime));
-       //RSPINF_a_72
-       VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_72, MAKEWORD(byTxRate, byRsvTime));
-       //Set to Page0
-       MACvSelectPage0(pDevice->PortOffset);
-}
-
 /*---------------------  Export Functions  --------------------------*/
 
-/*
- * Description: Get Card short preamble option value
- *
- * Parameters:
- *  In:
- *      pDevice             - The adapter to be set
- *  Out:
- *      none
- *
- * Return Value: true if short preamble; otherwise false
- *
- */
-bool CARDbIsShortPreamble(struct vnt_private *pDevice)
-{
-
-       if (pDevice->byPreambleType == 0)
-               return false;
-
-       return true;
-}
-
-/*
- * Description: Get Card short slot time option value
- *
- * Parameters:
- *  In:
- *      pDevice             - The adapter to be set
- *  Out:
- *      none
- *
- * Return Value: true if short slot time; otherwise false
- *
- */
-bool CARDbIsShorSlotTime(struct vnt_private *pDevice)
-{
-
-       return pDevice->bShortSlotTime;
-}
-
 /*
  * Description: Update IFS
  *
@@ -378,7 +203,6 @@ bool CARDbIsShorSlotTime(struct vnt_private *pDevice)
  *      none
  *
  * Return Value: None.
- *
  */
 bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType,
                          unsigned short wCapInfo, unsigned char byERPField,
@@ -389,16 +213,12 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType,
        unsigned char bySIFS = 0;
        unsigned char byDIFS = 0;
        unsigned char byData;
-       PWLAN_IE_SUPP_RATES pSupportRates = (PWLAN_IE_SUPP_RATES) pvSupportRateIEs;
-       PWLAN_IE_SUPP_RATES pExtSupportRates = (PWLAN_IE_SUPP_RATES) pvExtSupportRateIEs;
+       int i;
 
-       //Set SIFS, DIFS, EIFS, SlotTime, CwMin
+       /* Set SIFS, DIFS, EIFS, SlotTime, CwMin */
        if (ePHYType == PHY_TYPE_11A) {
-               if (pSupportRates == NULL)
-                       pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesA;
-
                if (pDevice->byRFType == RF_AIROHA7230) {
-                       // AL7230 use single PAPE and connect to PAPE_2.4G
+                       /* AL7230 use single PAPE and connect to PAPE_2.4G */
                        MACvSetBBType(pDevice->PortOffset, BB_TYPE_11G);
                        pDevice->abyBBVGA[0] = 0x20;
                        pDevice->abyBBVGA[2] = 0x10;
@@ -424,9 +244,6 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType,
                byDIFS = C_SIFS_A + 2*C_SLOT_SHORT;
                byCWMaxMin = 0xA4;
        } else if (ePHYType == PHY_TYPE_11B) {
-               if (pSupportRates == NULL)
-                       pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesB;
-
                MACvSetBBType(pDevice->PortOffset, BB_TYPE_11B);
                if (pDevice->byRFType == RF_AIROHA7230) {
                        pDevice->abyBBVGA[0] = 0x1C;
@@ -449,11 +266,7 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType,
                bySIFS = C_SIFS_BG;
                byDIFS = C_SIFS_BG + 2*C_SLOT_LONG;
                byCWMaxMin = 0xA5;
-       } else {// PK_TYPE_11GA & PK_TYPE_11GB
-               if (pSupportRates == NULL) {
-                       pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesG;
-                       pExtSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultExtSuppRatesG;
-               }
+       } else { /* PK_TYPE_11GA & PK_TYPE_11GB */
                MACvSetBBType(pDevice->PortOffset, BB_TYPE_11G);
                if (pDevice->byRFType == RF_AIROHA7230) {
                        pDevice->abyBBVGA[0] = 0x1C;
@@ -473,43 +286,37 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType,
                }
                BBbWriteEmbedded(pDevice->PortOffset, 0x88, 0x08);
                bySIFS = C_SIFS_BG;
-               if (VNTWIFIbIsShortSlotTime(wCapInfo)) {
+
+               if (pDevice->bShortSlotTime) {
                        bySlot = C_SLOT_SHORT;
                        byDIFS = C_SIFS_BG + 2*C_SLOT_SHORT;
                } else {
                        bySlot = C_SLOT_LONG;
                        byDIFS = C_SIFS_BG + 2*C_SLOT_LONG;
                }
-               if (VNTWIFIbyGetMaxSupportRate(pSupportRates, pExtSupportRates) > RATE_11M)
-                       byCWMaxMin = 0xA4;
-               else
-                       byCWMaxMin = 0xA5;
 
-               if (pDevice->bProtectMode != VNTWIFIbIsProtectMode(byERPField)) {
-                       pDevice->bProtectMode = VNTWIFIbIsProtectMode(byERPField);
-                       if (pDevice->bProtectMode)
-                               MACvEnableProtectMD(pDevice->PortOffset);
-                       else
-                               MACvDisableProtectMD(pDevice->PortOffset);
+               byCWMaxMin = 0xa4;
 
-               }
-               if (pDevice->bBarkerPreambleMd != VNTWIFIbIsBarkerMode(byERPField)) {
-                       pDevice->bBarkerPreambleMd = VNTWIFIbIsBarkerMode(byERPField);
-                       if (pDevice->bBarkerPreambleMd)
-                               MACvEnableBarkerPreambleMd(pDevice->PortOffset);
-                       else
-                               MACvDisableBarkerPreambleMd(pDevice->PortOffset);
+               for (i = RATE_54M; i >= RATE_6M; i--) {
+                       if (pDevice->basic_rates & ((u32)(0x1 << i))) {
+                               byCWMaxMin |= 0x1;
+                               break;
+                       }
                }
        }
 
        if (pDevice->byRFType == RF_RFMD2959) {
-               // bcs TX_PE will reserve 3 us
-               // hardware's processing time here is 2 us.
+               /*
+                * bcs TX_PE will reserve 3 us hardware's processing
+                * time here is 2 us.
+                */
                bySIFS -= 3;
                byDIFS -= 3;
-               //{{ RobertYu: 20041202
-               //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput
-               //// MAC will need 2 us to process, so the SIFS, DIFS can be shorter by 2 us.
+               /*
+                * TX_PE will reserve 3 us for MAX2829 A mode only, it is for
+                * better TX throughput; MAC will need 2 us to process, so the
+                * SIFS, DIFS can be shorter by 2 us.
+                */
        }
 
        if (pDevice->bySIFS != bySIFS) {
@@ -527,10 +334,6 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType,
        if (pDevice->bySlot != bySlot) {
                pDevice->bySlot = bySlot;
                VNSvOutPortB(pDevice->PortOffset + MAC_REG_SLOT, pDevice->bySlot);
-               if (pDevice->bySlot == C_SLOT_SHORT)
-                       pDevice->bShortSlotTime = true;
-               else
-                       pDevice->bShortSlotTime = false;
 
                BBvSetShortSlotTime(pDevice);
        }
@@ -538,14 +341,9 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType,
                pDevice->byCWMaxMin = byCWMaxMin;
                VNSvOutPortB(pDevice->PortOffset + MAC_REG_CWMAXMIN0, pDevice->byCWMaxMin);
        }
-       if (VNTWIFIbIsShortPreamble(wCapInfo))
-               pDevice->byPreambleType = pDevice->byShortPreamble;
-       else
-               pDevice->byPreambleType = 0;
 
-       s_vSetRSPINF(pDevice, ePHYType, pSupportRates, pExtSupportRates);
-       pDevice->eCurrentPHYType = ePHYType;
-       // set for NDIS OID_802_11SUPPORTED_RATES
+       CARDvSetRSPINF(pDevice, ePHYType);
+
        return true;
 }
 
@@ -563,7 +361,6 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType,
  *      none
  *
  * Return Value: none
- *
  */
 bool CARDbUpdateTSF(struct vnt_private *pDevice, unsigned char byRxRate,
                    u64 qwBSSTimestamp, u64 qwLocalTSF)
@@ -572,8 +369,7 @@ bool CARDbUpdateTSF(struct vnt_private *pDevice, unsigned char byRxRate,
 
        if (qwBSSTimestamp != qwLocalTSF) {
                qwTSFOffset = CARDqGetTSFOffset(byRxRate, qwBSSTimestamp, qwLocalTSF);
-               // adjust TSF
-               // HW's TSF add TSF Offset reg
+               /* adjust TSF, HW's TSF add TSF Offset reg */
                VNSvOutPortD(pDevice->PortOffset + MAC_REG_TSFOFST, (u32)qwTSFOffset);
                VNSvOutPortD(pDevice->PortOffset + MAC_REG_TSFOFST + 4, (u32)(qwTSFOffset >> 32));
                MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_TSFSYNCEN);
@@ -593,21 +389,20 @@ bool CARDbUpdateTSF(struct vnt_private *pDevice, unsigned char byRxRate,
  *      none
  *
  * Return Value: true if succeed; otherwise false
- *
  */
 bool CARDbSetBeaconPeriod(struct vnt_private *pDevice,
                          unsigned short wBeaconInterval)
 {
        u64 qwNextTBTT = 0;
 
-       CARDbGetCurrentTSF(pDevice->PortOffset, &qwNextTBTT); //Get Local TSF counter
+       CARDbGetCurrentTSF(pDevice->PortOffset, &qwNextTBTT); /* Get Local TSF counter */
 
        qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval);
 
-       // set HW beacon interval
+       /* set HW beacon interval */
        VNSvOutPortW(pDevice->PortOffset + MAC_REG_BI, wBeaconInterval);
        pDevice->wBeaconInterval = wBeaconInterval;
-       // Set NextTBTT
+       /* Set NextTBTT */
        VNSvOutPortD(pDevice->PortOffset + MAC_REG_NEXTTBTT, (u32)qwNextTBTT);
        VNSvOutPortD(pDevice->PortOffset + MAC_REG_NEXTTBTT + 4, (u32)(qwNextTBTT >> 32));
        MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN);
@@ -615,225 +410,6 @@ bool CARDbSetBeaconPeriod(struct vnt_private *pDevice,
        return true;
 }
 
-/*
- * Description: Card Stop Hardware Tx
- *
- * Parameters:
- *  In:
- *      pDeviceHandler      - The adapter to be set
- *      ePktType            - Packet type to stop
- *  Out:
- *      none
- *
- * Return Value: true if all data packet complete; otherwise false.
- *
- */
-bool CARDbStopTxPacket(struct vnt_private *pDevice, CARD_PKT_TYPE ePktType)
-{
-
-       if (ePktType == PKT_TYPE_802_11_ALL) {
-               pDevice->bStopBeacon = true;
-               pDevice->bStopTx0Pkt = true;
-               pDevice->bStopDataPkt = true;
-       } else if (ePktType == PKT_TYPE_802_11_BCN) {
-               pDevice->bStopBeacon = true;
-       } else if (ePktType == PKT_TYPE_802_11_MNG) {
-               pDevice->bStopTx0Pkt = true;
-       } else if (ePktType == PKT_TYPE_802_11_DATA) {
-               pDevice->bStopDataPkt = true;
-       }
-
-       if (pDevice->bStopBeacon == true) {
-               if (pDevice->bIsBeaconBufReadySet == true) {
-                       if (pDevice->cbBeaconBufReadySetCnt < WAIT_BEACON_TX_DOWN_TMO) {
-                               pDevice->cbBeaconBufReadySetCnt++;
-                               return false;
-                       }
-               }
-               pDevice->bIsBeaconBufReadySet = false;
-               pDevice->cbBeaconBufReadySetCnt = 0;
-               MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
-       }
-       // wait all TD0 complete
-       if (pDevice->bStopTx0Pkt == true) {
-               if (pDevice->iTDUsed[TYPE_TXDMA0] != 0)
-                       return false;
-       }
-       // wait all Data TD complete
-       if (pDevice->bStopDataPkt == true) {
-               if (pDevice->iTDUsed[TYPE_AC0DMA] != 0)
-                       return false;
-       }
-
-       return true;
-}
-
-/*
- * Description: Card Start Hardware Tx
- *
- * Parameters:
- *  In:
- *      pDeviceHandler      - The adapter to be set
- *      ePktType            - Packet type to start
- *  Out:
- *      none
- *
- * Return Value: true if success; false if failed.
- *
- */
-bool CARDbStartTxPacket(struct vnt_private *pDevice, CARD_PKT_TYPE ePktType)
-{
-
-       if (ePktType == PKT_TYPE_802_11_ALL) {
-               pDevice->bStopBeacon = false;
-               pDevice->bStopTx0Pkt = false;
-               pDevice->bStopDataPkt = false;
-       } else if (ePktType == PKT_TYPE_802_11_BCN) {
-               pDevice->bStopBeacon = false;
-       } else if (ePktType == PKT_TYPE_802_11_MNG) {
-               pDevice->bStopTx0Pkt = false;
-       } else if (ePktType == PKT_TYPE_802_11_DATA) {
-               pDevice->bStopDataPkt = false;
-       }
-
-       if ((pDevice->bStopBeacon == false) &&
-           (pDevice->bBeaconBufReady == true) &&
-           (pDevice->op_mode == NL80211_IFTYPE_ADHOC)) {
-               MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
-       }
-
-       return true;
-}
-
-/*
- * Description: Card Set BSSID value
- *
- * Parameters:
- *  In:
- *      pDeviceHandler      - The adapter to be set
- *      pbyBSSID            - pointer to BSSID field
- *      bAdhoc              - flag to indicate IBSS
- *  Out:
- *      none
- *
- * Return Value: true if success; false if failed.
- *
- */
-bool CARDbSetBSSID(struct vnt_private *pDevice,
-                  unsigned char *pbyBSSID, enum nl80211_iftype op_mode)
-{
-
-       MACvWriteBSSIDAddress(pDevice->PortOffset, pbyBSSID);
-       memcpy(pDevice->abyBSSID, pbyBSSID, WLAN_BSSID_LEN);
-       if (op_mode == NL80211_IFTYPE_ADHOC)
-               MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC);
-       else
-               MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC);
-
-       if (op_mode == NL80211_IFTYPE_AP)
-               MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP);
-       else
-               MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP);
-
-       if (op_mode == NL80211_IFTYPE_UNSPECIFIED) {
-               MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID);
-               pDevice->bBSSIDFilter = false;
-               pDevice->byRxMode &= ~RCR_BSSID;
-               pr_debug("wcmd: rx_mode = %x\n", pDevice->byRxMode);
-       } else {
-               if (is_zero_ether_addr(pDevice->abyBSSID) == false) {
-                       MACvRegBitsOn(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID);
-                       pDevice->bBSSIDFilter = true;
-                       pDevice->byRxMode |= RCR_BSSID;
-               }
-               pr_debug("wmgr: rx_mode = %x\n", pDevice->byRxMode);
-       }
-       // Adopt BSS state in Adapter Device Object
-       pDevice->op_mode = op_mode;
-       return true;
-}
-
-/*
- * Description: Card indicate status
- *
- * Parameters:
- *  In:
- *      pDeviceHandler      - The adapter to be set
- *      eStatus             - Status
- *  Out:
- *      none
- *
- * Return Value: true if success; false if failed.
- *
- */
-
-/*
- * Description: Save Assoc info. contain in assoc. response frame
- *
- * Parameters:
- *  In:
- *      pDevice             - The adapter to be set
- *      wCapabilityInfo     - Capability information
- *      wStatus             - Status code
- *      wAID                - Assoc. ID
- *      uLen                - Length of IEs
- *      pbyIEs              - pointer to IEs
- *  Out:
- *      none
- *
- * Return Value: true if succeed; otherwise false
- *
- */
-bool CARDbSetTxDataRate(
-       struct vnt_private *pDevice,
-       unsigned short wDataRate
-)
-{
-
-       pDevice->wCurrentRate = wDataRate;
-       return true;
-}
-
-/*+
- *
- * Routine Description:
- *      Consider to power down when no more packets to tx or rx.
- *
- * Parameters:
- *  In:
- *      pDevice             - The adapter to be set
- *  Out:
- *      none
- *
- * Return Value: true if power down success; otherwise false
- *
- -*/
-bool
-CARDbPowerDown(
-       struct vnt_private *pDevice
-)
-{
-       unsigned int uIdx;
-
-       // check if already in Doze mode
-       if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS))
-               return true;
-
-       // Froce PSEN on
-       MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PSEN);
-
-       // check if all TD are empty,
-
-       for (uIdx = 0; uIdx < TYPE_MAXTD; uIdx++) {
-               if (pDevice->iTDUsed[uIdx] != 0)
-                       return false;
-       }
-
-       MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_GO2DOZE);
-       pr_debug("Go to Doze ZZZZZZZZZZZZZZZ\n");
-       return true;
-}
-
 /*
  * Description: Turn off Radio power
  *
@@ -844,7 +420,6 @@ CARDbPowerDown(
  *      none
  *
  * Return Value: true if success; otherwise false
- *
  */
 bool CARDbRadioPowerOff(struct vnt_private *pDevice)
 {
@@ -861,7 +436,7 @@ bool CARDbRadioPowerOff(struct vnt_private *pDevice)
 
        case RF_AIROHA:
        case RF_AL2230S:
-       case RF_AIROHA7230: //RobertYu:20050104
+       case RF_AIROHA7230:
                MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE2);
                MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3);
                break;
@@ -873,9 +448,8 @@ bool CARDbRadioPowerOff(struct vnt_private *pDevice)
        BBvSetDeepSleep(pDevice->PortOffset, pDevice->byLocalID);
 
        pDevice->bRadioOff = true;
-       //2007-0409-03,<Add> by chester
        pr_debug("chester power off\n");
-       MACvRegBitsOn(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET);  //LED issue
+       MACvRegBitsOn(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET);  /* LED issue */
        return bResult;
 }
 
@@ -889,7 +463,6 @@ bool CARDbRadioPowerOff(struct vnt_private *pDevice)
  *      none
  *
  * Return Value: true if success; otherwise false
- *
  */
 bool CARDbRadioPowerOn(struct vnt_private *pDevice)
 {
@@ -919,7 +492,7 @@ bool CARDbRadioPowerOn(struct vnt_private *pDevice)
 
        case RF_AIROHA:
        case RF_AL2230S:
-       case RF_AIROHA7230: //RobertYu:20050104
+       case RF_AIROHA7230:
                MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 |
                                                                            SOFTPWRCTL_SWPE3));
                break;
@@ -927,493 +500,11 @@ bool CARDbRadioPowerOn(struct vnt_private *pDevice)
        }
 
        pDevice->bRadioOff = false;
-//  2007-0409-03,<Add> by chester
        pr_debug("chester power on\n");
-       MACvRegBitsOff(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); //LED issue
+       MACvRegBitsOff(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); /* LED issue */
        return bResult;
 }
 
-bool CARDbRemoveKey(struct vnt_private *pDevice, unsigned char *pbyBSSID)
-{
-
-       KeybRemoveAllKey(&(pDevice->sKey), pbyBSSID, pDevice->PortOffset);
-       return true;
-}
-
-/*
- *
- * Description:
- *    Add BSSID in PMKID Candidate list.
- *
- * Parameters:
- *  In:
- *      hDeviceContext - device structure point
- *      pbyBSSID - BSSID address for adding
- *      wRSNCap - BSS's RSN capability
- *  Out:
- *      none
- *
- * Return Value: none.
- *
- -*/
-bool
-CARDbAdd_PMKID_Candidate(
-       struct vnt_private *pDevice,
-       unsigned char *pbyBSSID,
-       bool bRSNCapExist,
-       unsigned short wRSNCap
-)
-{
-       struct pmkid_candidate *pCandidateList;
-       unsigned int ii = 0;
-
-       pr_debug("bAdd_PMKID_Candidate START: (%d)\n",
-                (int)pDevice->gsPMKIDCandidate.NumCandidates);
-
-       if (pDevice->gsPMKIDCandidate.NumCandidates >= MAX_PMKIDLIST) {
-               pr_debug("vFlush_PMKID_Candidate: 3\n");
-               memset(&pDevice->gsPMKIDCandidate, 0, sizeof(SPMKIDCandidateEvent));
-       }
-
-       for (ii = 0; ii < 6; ii++)
-               pr_debug("%02X ", *(pbyBSSID + ii));
-
-       pr_debug("\n");
-
-       // Update Old Candidate
-       for (ii = 0; ii < pDevice->gsPMKIDCandidate.NumCandidates; ii++) {
-               pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[ii];
-               if (!memcmp(pCandidateList->BSSID, pbyBSSID, ETH_ALEN)) {
-                       if (bRSNCapExist && (wRSNCap & BIT0))
-                               pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED;
-                       else
-                               pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED);
-
-                       return true;
-               }
-       }
-
-       // New Candidate
-       pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[pDevice->gsPMKIDCandidate.NumCandidates];
-       if (bRSNCapExist && (wRSNCap & BIT0))
-               pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED;
-       else
-               pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED);
-
-       memcpy(pCandidateList->BSSID, pbyBSSID, ETH_ALEN);
-       pDevice->gsPMKIDCandidate.NumCandidates++;
-       pr_debug("NumCandidates:%d\n",
-                (int)pDevice->gsPMKIDCandidate.NumCandidates);
-       return true;
-}
-
-void *
-CARDpGetCurrentAddress(
-       struct vnt_private *pDevice
-)
-{
-
-       return pDevice->abyCurrentNetAddr;
-}
-
-/*
- *
- * Description:
- *    Start Spectrum Measure defined in 802.11h
- *
- * Parameters:
- *  In:
- *      hDeviceContext - device structure point
- *  Out:
- *      none
- *
- * Return Value: none.
- *
- -*/
-bool
-CARDbStartMeasure(
-       struct vnt_private *pDevice,
-       void *pvMeasureEIDs,
-       unsigned int uNumOfMeasureEIDs
-)
-{
-       PWLAN_IE_MEASURE_REQ    pEID = (PWLAN_IE_MEASURE_REQ) pvMeasureEIDs;
-       u64 qwCurrTSF;
-       u64 qwStartTSF;
-       bool bExpired = true;
-       unsigned short wDuration = 0;
-
-       if ((pEID == NULL) ||
-           (uNumOfMeasureEIDs == 0)) {
-               return true;
-       }
-       CARDbGetCurrentTSF(pDevice->PortOffset, &qwCurrTSF);
-       if (pDevice->bMeasureInProgress == true) {
-               pDevice->bMeasureInProgress = false;
-               VNSvOutPortB(pDevice->PortOffset + MAC_REG_RCR, pDevice->byOrgRCR);
-               MACvSelectPage1(pDevice->PortOffset);
-               VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0, pDevice->dwOrgMAR0);
-               VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR4, pDevice->dwOrgMAR4);
-               // clear measure control
-               MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN);
-               MACvSelectPage0(pDevice->PortOffset);
-               set_channel(pDevice, pDevice->byOrgChannel);
-               MACvSelectPage1(pDevice->PortOffset);
-               MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
-               MACvSelectPage0(pDevice->PortOffset);
-       }
-       pDevice->uNumOfMeasureEIDs = uNumOfMeasureEIDs;
-
-       do {
-               pDevice->pCurrMeasureEID = pEID;
-               pEID++;
-               pDevice->uNumOfMeasureEIDs--;
-
-               if (pDevice->byLocalID > REV_ID_VT3253_B1) {
-                       qwStartTSF = *((u64 *)(pDevice->pCurrMeasureEID->sReq.abyStartTime));
-                       wDuration = *((unsigned short *)(pDevice->pCurrMeasureEID->sReq.abyDuration));
-                       wDuration += 1; // 1 TU for channel switching
-
-                       if (qwStartTSF == 0) {
-                               // start immediately by setting start TSF == current TSF + 2 TU
-                               qwStartTSF = qwCurrTSF + 2048;
-
-                               bExpired = false;
-                               break;
-                       } else {
-                               // start at setting start TSF - 1TU(for channel switching)
-                               qwStartTSF -= 1024;
-                       }
-
-                       if (qwCurrTSF < qwStartTSF) {
-                               bExpired = false;
-                               break;
-                       }
-                       VNTWIFIbMeasureReport(pDevice->pMgmt,
-                                             false,
-                                             pDevice->pCurrMeasureEID,
-                                             MEASURE_MODE_LATE,
-                                             pDevice->byBasicMap,
-                                             pDevice->byCCAFraction,
-                                             pDevice->abyRPIs
-                               );
-               } else {
-                       // hardware do not support measure
-                       VNTWIFIbMeasureReport(pDevice->pMgmt,
-                                             false,
-                                             pDevice->pCurrMeasureEID,
-                                             MEASURE_MODE_INCAPABLE,
-                                             pDevice->byBasicMap,
-                                             pDevice->byCCAFraction,
-                                             pDevice->abyRPIs
-                               );
-               }
-       } while (pDevice->uNumOfMeasureEIDs != 0);
-
-       if (!bExpired) {
-               MACvSelectPage1(pDevice->PortOffset);
-               VNSvOutPortD(pDevice->PortOffset + MAC_REG_MSRSTART, (u32)qwStartTSF);
-               VNSvOutPortD(pDevice->PortOffset + MAC_REG_MSRSTART + 4, (u32)(qwStartTSF >> 32));
-               VNSvOutPortW(pDevice->PortOffset + MAC_REG_MSRDURATION, wDuration);
-               MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN);
-               MACvSelectPage0(pDevice->PortOffset);
-       } else {
-               // all measure start time expired we should complete action
-               VNTWIFIbMeasureReport(pDevice->pMgmt,
-                                     true,
-                                     NULL,
-                                     0,
-                                     pDevice->byBasicMap,
-                                     pDevice->byCCAFraction,
-                                     pDevice->abyRPIs
-                       );
-       }
-       return true;
-}
-
-/*
- *
- * Description:
- *    Do Channel Switch defined in 802.11h
- *
- * Parameters:
- *  In:
- *      hDeviceContext - device structure point
- *  Out:
- *      none
- *
- * Return Value: none.
- *
- -*/
-bool
-CARDbChannelSwitch(
-       struct vnt_private *pDevice,
-       unsigned char byMode,
-       unsigned char byNewChannel,
-       unsigned char byCount
-)
-{
-       bool bResult = true;
-
-       if (byCount == 0) {
-               bResult = set_channel(pDevice, byNewChannel);
-               VNTWIFIbChannelSwitch(pDevice->pMgmt, byNewChannel);
-               MACvSelectPage1(pDevice->PortOffset);
-               MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
-               MACvSelectPage0(pDevice->PortOffset);
-               return bResult;
-       }
-       pDevice->byChannelSwitchCount = byCount;
-       pDevice->byNewChannel = byNewChannel;
-       pDevice->bChannelSwitch = true;
-       if (byMode == 1)
-               bResult = CARDbStopTxPacket(pDevice, PKT_TYPE_802_11_ALL);
-
-       return bResult;
-}
-
-/*
- *
- * Description:
- *    Handle Quiet EID defined in 802.11h
- *
- * Parameters:
- *  In:
- *      hDeviceContext - device structure point
- *  Out:
- *      none
- *
- * Return Value: none.
- *
- -*/
-bool
-CARDbSetQuiet(
-       struct vnt_private *pDevice,
-       bool bResetQuiet,
-       unsigned char byQuietCount,
-       unsigned char byQuietPeriod,
-       unsigned short wQuietDuration,
-       unsigned short wQuietOffset
-)
-{
-       unsigned int ii = 0;
-
-       if (bResetQuiet) {
-               MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN));
-               for (ii = 0; ii < MAX_QUIET_COUNT; ii++)
-                       pDevice->sQuiet[ii].bEnable = false;
-
-               pDevice->uQuietEnqueue = 0;
-               pDevice->bEnableFirstQuiet = false;
-               pDevice->bQuietEnable = false;
-               pDevice->byQuietStartCount = byQuietCount;
-       }
-       if (pDevice->sQuiet[pDevice->uQuietEnqueue].bEnable == false) {
-               pDevice->sQuiet[pDevice->uQuietEnqueue].bEnable = true;
-               pDevice->sQuiet[pDevice->uQuietEnqueue].byPeriod = byQuietPeriod;
-               pDevice->sQuiet[pDevice->uQuietEnqueue].wDuration = wQuietDuration;
-               pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime = (unsigned long) byQuietCount;
-               pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime *= pDevice->wBeaconInterval;
-               pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime += wQuietOffset;
-               pDevice->uQuietEnqueue++;
-               pDevice->uQuietEnqueue %= MAX_QUIET_COUNT;
-               if (pDevice->byQuietStartCount < byQuietCount)
-                       pDevice->byQuietStartCount = byQuietCount;
-       }
-       return true;
-}
-
-/*
- *
- * Description:
- *    Do Quiet, It will be called by either ISR(after start)
- *    or VNTWIFI(before start) so we do not need a SPINLOCK
- *
- * Parameters:
- *  In:
- *      hDeviceContext - device structure point
- *  Out:
- *      none
- *
- * Return Value: none.
- *
- -*/
-bool
-CARDbStartQuiet(
-       struct vnt_private *pDevice
-)
-{
-       unsigned int ii = 0;
-       unsigned long dwStartTime = 0xFFFFFFFF;
-       unsigned int uCurrentQuietIndex = 0;
-       unsigned long dwNextTime = 0;
-       unsigned long dwGap = 0;
-       unsigned long dwDuration = 0;
-
-       for (ii = 0; ii < MAX_QUIET_COUNT; ii++) {
-               if ((pDevice->sQuiet[ii].bEnable == true) &&
-                   (dwStartTime > pDevice->sQuiet[ii].dwStartTime)) {
-                       dwStartTime = pDevice->sQuiet[ii].dwStartTime;
-                       uCurrentQuietIndex = ii;
-               }
-       }
-       if (dwStartTime == 0xFFFFFFFF) {
-               // no more quiet
-               pDevice->bQuietEnable = false;
-               MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN));
-       } else {
-               if (pDevice->bQuietEnable == false) {
-                       // first quiet
-                       pDevice->byQuietStartCount--;
-                       dwNextTime = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime;
-                       dwNextTime %= pDevice->wBeaconInterval;
-                       MACvSelectPage1(pDevice->PortOffset);
-                       VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETINIT, (unsigned short) dwNextTime);
-                       VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETDUR, (unsigned short) pDevice->sQuiet[uCurrentQuietIndex].wDuration);
-                       if (pDevice->byQuietStartCount == 0) {
-                               pDevice->bEnableFirstQuiet = false;
-                               MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN));
-                       } else {
-                               pDevice->bEnableFirstQuiet = true;
-                       }
-                       MACvSelectPage0(pDevice->PortOffset);
-               } else {
-                       if (pDevice->dwCurrentQuietEndTime > pDevice->sQuiet[uCurrentQuietIndex].dwStartTime) {
-                               // overlap with previous Quiet
-                               dwGap =  pDevice->dwCurrentQuietEndTime - pDevice->sQuiet[uCurrentQuietIndex].dwStartTime;
-                               if (dwGap >= pDevice->sQuiet[uCurrentQuietIndex].wDuration) {
-                                       // return false to indicate next quiet expired, should call this function again
-                                       return false;
-                               }
-                               dwDuration = pDevice->sQuiet[uCurrentQuietIndex].wDuration - dwGap;
-                               dwGap = 0;
-                       } else {
-                               dwGap = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime - pDevice->dwCurrentQuietEndTime;
-                               dwDuration = pDevice->sQuiet[uCurrentQuietIndex].wDuration;
-                       }
-                       // set GAP and Next duration
-                       MACvSelectPage1(pDevice->PortOffset);
-                       VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETGAP, (unsigned short) dwGap);
-                       VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETDUR, (unsigned short) dwDuration);
-                       MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_QUIETRPT);
-                       MACvSelectPage0(pDevice->PortOffset);
-               }
-               pDevice->bQuietEnable = true;
-               pDevice->dwCurrentQuietEndTime = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime;
-               pDevice->dwCurrentQuietEndTime += pDevice->sQuiet[uCurrentQuietIndex].wDuration;
-               if (pDevice->sQuiet[uCurrentQuietIndex].byPeriod == 0) {
-                       // not period disable current quiet element
-                       pDevice->sQuiet[uCurrentQuietIndex].bEnable = false;
-               } else {
-                       // set next period start time
-                       dwNextTime = (unsigned long) pDevice->sQuiet[uCurrentQuietIndex].byPeriod;
-                       dwNextTime *= pDevice->wBeaconInterval;
-                       pDevice->sQuiet[uCurrentQuietIndex].dwStartTime = dwNextTime;
-               }
-               if (pDevice->dwCurrentQuietEndTime > 0x80010000) {
-                       // decreament all time to avoid wrap around
-                       for (ii = 0; ii < MAX_QUIET_COUNT; ii++) {
-                               if (pDevice->sQuiet[ii].bEnable == true)
-                                       pDevice->sQuiet[ii].dwStartTime -= 0x80000000;
-
-                       }
-                       pDevice->dwCurrentQuietEndTime -= 0x80000000;
-               }
-       }
-       return true;
-}
-
-/*
- *
- * Description:
- *    Set Local Power Constraint
- *
- * Parameters:
- *  In:
- *      hDeviceContext - device structure point
- *  Out:
- *      none
- *
- * Return Value: none.
- *
- -*/
-void
-CARDvSetPowerConstraint(
-       struct vnt_private *pDevice,
-       unsigned char byChannel,
-       char byPower
-)
-{
-
-       if (byChannel > CB_MAX_CHANNEL_24G) {
-               if (pDevice->bCountryInfo5G == true)
-                       pDevice->abyLocalPwr[byChannel] = pDevice->abyRegPwr[byChannel] - byPower;
-
-       } else {
-               if (pDevice->bCountryInfo24G == true)
-                       pDevice->abyLocalPwr[byChannel] = pDevice->abyRegPwr[byChannel] - byPower;
-
-       }
-}
-
-/*
- *
- * Description:
- *    Set Local Power Constraint
- *
- * Parameters:
- *  In:
- *      hDeviceContext - device structure point
- *  Out:
- *      none
- *
- * Return Value: none.
- *
- -*/
-void
-CARDvGetPowerCapability(
-       struct vnt_private *pDevice,
-       unsigned char *pbyMinPower,
-       unsigned char *pbyMaxPower
-)
-{
-       unsigned char byDec = 0;
-
-       *pbyMaxPower = pDevice->abyOFDMDefaultPwr[pDevice->byCurrentCh];
-       byDec = pDevice->abyOFDMPwrTbl[pDevice->byCurrentCh];
-       if (pDevice->byRFType == RF_UW2452) {
-               byDec *= 3;
-               byDec >>= 1;
-       } else {
-               byDec <<= 1;
-       }
-       *pbyMinPower = pDevice->abyOFDMDefaultPwr[pDevice->byCurrentCh] - byDec;
-}
-
-/*
- *
- * Description:
- *    Get Current Tx Power
- *
- * Parameters:
- *  In:
- *      hDeviceContext - device structure point
- *  Out:
- *      none
- *
- * Return Value: none.
- *
- */
-char
-CARDbyGetTransmitPower(
-       struct vnt_private *pDevice
-)
-{
-
-       return pDevice->byCurPwrdBm;
-}
-
-//xxx
 void
 CARDvSafeResetTx(
        struct vnt_private *pDevice
@@ -1422,7 +513,7 @@ CARDvSafeResetTx(
        unsigned int uu;
        PSTxDesc    pCurrTD;
 
-       // initialize TD index
+       /* initialize TD index */
        pDevice->apTailTD[0] = pDevice->apCurrTD[0] = &(pDevice->apTD0Rings[0]);
        pDevice->apTailTD[1] = pDevice->apCurrTD[1] = &(pDevice->apTD1Rings[0]);
 
@@ -1432,28 +523,27 @@ CARDvSafeResetTx(
        for (uu = 0; uu < pDevice->sOpts.nTxDescs[0]; uu++) {
                pCurrTD = &(pDevice->apTD0Rings[uu]);
                pCurrTD->m_td0TD0.f1Owner = OWNED_BY_HOST;
-               // init all Tx Packet pointer to NULL
+               /* init all Tx Packet pointer to NULL */
        }
        for (uu = 0; uu < pDevice->sOpts.nTxDescs[1]; uu++) {
                pCurrTD = &(pDevice->apTD1Rings[uu]);
                pCurrTD->m_td0TD0.f1Owner = OWNED_BY_HOST;
-               // init all Tx Packet pointer to NULL
+               /* init all Tx Packet pointer to NULL */
        }
 
-       // set MAC TD pointer
+       /* set MAC TD pointer */
        MACvSetCurrTXDescAddr(TYPE_TXDMA0, pDevice->PortOffset,
                              (pDevice->td0_pool_dma));
 
        MACvSetCurrTXDescAddr(TYPE_AC0DMA, pDevice->PortOffset,
                              (pDevice->td1_pool_dma));
 
-       // set MAC Beacon TX pointer
+       /* set MAC Beacon TX pointer */
        MACvSetCurrBCNTxDescAddr(pDevice->PortOffset,
                                 (pDevice->tx_beacon_dma));
 }
 
-/*+
- *
+/*
  * Description:
  *      Reset Rx
  *
@@ -1464,8 +554,7 @@ CARDvSafeResetTx(
  *      none
  *
  * Return Value: none
- *
- -*/
+ */
 void
 CARDvSafeResetRx(
        struct vnt_private *pDevice
@@ -1474,11 +563,11 @@ CARDvSafeResetRx(
        unsigned int uu;
        PSRxDesc    pDesc;
 
-       // initialize RD index
+       /* initialize RD index */
        pDevice->pCurrRD[0] = &(pDevice->aRD0Ring[0]);
        pDevice->pCurrRD[1] = &(pDevice->aRD1Ring[0]);
 
-       // init state, all RD is chip's
+       /* init state, all RD is chip's */
        for (uu = 0; uu < pDevice->sOpts.nRxDescs0; uu++) {
                pDesc = &(pDevice->aRD0Ring[uu]);
                pDesc->m_rd0RD0.wResCount = (unsigned short)(pDevice->rx_buf_sz);
@@ -1486,7 +575,7 @@ CARDvSafeResetRx(
                pDesc->m_rd1RD1.wReqCount = (unsigned short)(pDevice->rx_buf_sz);
        }
 
-       // init state, all RD is chip's
+       /* init state, all RD is chip's */
        for (uu = 0; uu < pDevice->sOpts.nRxDescs1; uu++) {
                pDesc = &(pDevice->aRD1Ring[uu]);
                pDesc->m_rd0RD0.wResCount = (unsigned short)(pDevice->rx_buf_sz);
@@ -1497,10 +586,10 @@ CARDvSafeResetRx(
        pDevice->cbDFCB = CB_MAX_RX_FRAG;
        pDevice->cbFreeDFCB = pDevice->cbDFCB;
 
-       // set perPkt mode
+       /* set perPkt mode */
        MACvRx0PerPktMode(pDevice->PortOffset);
        MACvRx1PerPktMode(pDevice->PortOffset);
-       // set MAC RD pointer
+       /* set MAC RD pointer */
        MACvSetCurrRx0DescAddr(pDevice->PortOffset,
                               pDevice->rd0_pool_dma);
 
@@ -1519,7 +608,6 @@ CARDvSafeResetRx(
  *      none
  *
  * Return Value: response Control frame rate
- *
  */
 static unsigned short CARDwGetCCKControlRate(struct vnt_private *pDevice,
                                             unsigned short wRateIdx)
@@ -1527,7 +615,7 @@ static unsigned short CARDwGetCCKControlRate(struct vnt_private *pDevice,
        unsigned int ui = (unsigned int) wRateIdx;
 
        while (ui > RATE_1M) {
-               if (pDevice->wBasicRate & ((unsigned short)1 << ui))
+               if (pDevice->basic_rates & ((u32)0x1 << ui))
                        return (unsigned short)ui;
 
                ui--;
@@ -1546,14 +634,13 @@ static unsigned short CARDwGetCCKControlRate(struct vnt_private *pDevice,
  *      none
  *
  * Return Value: response Control frame rate
- *
  */
 static unsigned short CARDwGetOFDMControlRate(struct vnt_private *pDevice,
                                              unsigned short wRateIdx)
 {
        unsigned int ui = (unsigned int) wRateIdx;
 
-       pr_debug("BASIC RATE: %X\n", pDevice->wBasicRate);
+       pr_debug("BASIC RATE: %X\n", pDevice->basic_rates);
 
        if (!CARDbIsOFDMinBasicRate((void *)pDevice)) {
                pr_debug("CARDwGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx);
@@ -1562,7 +649,7 @@ static unsigned short CARDwGetOFDMControlRate(struct vnt_private *pDevice,
                return wRateIdx;
        }
        while (ui > RATE_11M) {
-               if (pDevice->wBasicRate & ((unsigned short)1 << ui)) {
+               if (pDevice->basic_rates & ((u32)0x1 << ui)) {
                        pr_debug("CARDwGetOFDMControlRate : %d\n", ui);
                        return (unsigned short)ui;
                }
@@ -1582,14 +669,13 @@ static unsigned short CARDwGetOFDMControlRate(struct vnt_private *pDevice,
  *      none
  *
  * Return Value: None.
- *
  */
 void CARDvSetRSPINF(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType)
 {
        union vnt_phy_field_swap phy;
-       unsigned char byTxRate, byRsvTime;             //For OFDM
+       unsigned char byTxRate, byRsvTime;      /* For OFDM */
 
-       //Set to Page1
+       /* Set to Page1 */
        MACvSelectPage1(pDevice->PortOffset);
 
        /* RSPINF_b_1 */
@@ -1629,62 +715,61 @@ void CARDvSetRSPINF(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType)
 
        VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_11, phy.field_write);
 
-       //RSPINF_a_6
+       /* RSPINF_a_6 */
        s_vCalculateOFDMRParameter(RATE_6M,
                                   ePHYType,
                                   &byTxRate,
                                   &byRsvTime);
        VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_6, MAKEWORD(byTxRate, byRsvTime));
-       //RSPINF_a_9
+       /* RSPINF_a_9 */
        s_vCalculateOFDMRParameter(RATE_9M,
                                   ePHYType,
                                   &byTxRate,
                                   &byRsvTime);
        VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_9, MAKEWORD(byTxRate, byRsvTime));
-       //RSPINF_a_12
+       /* RSPINF_a_12 */
        s_vCalculateOFDMRParameter(RATE_12M,
                                   ePHYType,
                                   &byTxRate,
                                   &byRsvTime);
        VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_12, MAKEWORD(byTxRate, byRsvTime));
-       //RSPINF_a_18
+       /* RSPINF_a_18 */
        s_vCalculateOFDMRParameter(RATE_18M,
                                   ePHYType,
                                   &byTxRate,
                                   &byRsvTime);
        VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_18, MAKEWORD(byTxRate, byRsvTime));
-       //RSPINF_a_24
+       /* RSPINF_a_24 */
        s_vCalculateOFDMRParameter(RATE_24M,
                                   ePHYType,
                                   &byTxRate,
                                   &byRsvTime);
        VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate, byRsvTime));
-       //RSPINF_a_36
+       /* RSPINF_a_36 */
        s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_36M),
                                   ePHYType,
                                   &byTxRate,
                                   &byRsvTime);
        VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate, byRsvTime));
-       //RSPINF_a_48
+       /* RSPINF_a_48 */
        s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_48M),
                                   ePHYType,
                                   &byTxRate,
                                   &byRsvTime);
        VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate, byRsvTime));
-       //RSPINF_a_54
+       /* RSPINF_a_54 */
        s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_54M),
                                   ePHYType,
                                   &byTxRate,
                                   &byRsvTime);
        VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate, byRsvTime));
-
-       //RSPINF_a_72
+       /* RSPINF_a_72 */
        s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_54M),
                                   ePHYType,
                                   &byTxRate,
                                   &byRsvTime);
        VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_72, MAKEWORD(byTxRate, byRsvTime));
-       //Set to Page0
+       /* Set to Page0 */
        MACvSelectPage0(pDevice->PortOffset);
 }
 
@@ -1698,7 +783,6 @@ void CARDvSetRSPINF(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType)
  *      none
  *
  * Return Value: None.
- *
  */
 void vUpdateIFS(struct vnt_private *pDevice)
 {
@@ -1706,19 +790,20 @@ void vUpdateIFS(struct vnt_private *pDevice)
 
        unsigned char byMaxMin = 0;
 
-       if (pDevice->byPacketType == PK_TYPE_11A) {//0000 0000 0000 0000,11a
+       if (pDevice->byPacketType == PK_TYPE_11A) { /*0000 0000 0000 0000,11a*/
                pDevice->uSlot = C_SLOT_SHORT;
                pDevice->uSIFS = C_SIFS_A;
                pDevice->uDIFS = C_SIFS_A + 2*C_SLOT_SHORT;
                pDevice->uCwMin = C_CWMIN_A;
                byMaxMin = 4;
-       } else if (pDevice->byPacketType == PK_TYPE_11B) {//0000 0001 0000 0000,11b
+       } else if (pDevice->byPacketType == PK_TYPE_11B) {
+                                       /* 0000 0001 0000 0000,11b */
                pDevice->uSlot = C_SLOT_LONG;
                pDevice->uSIFS = C_SIFS_BG;
                pDevice->uDIFS = C_SIFS_BG + 2*C_SLOT_LONG;
                pDevice->uCwMin = C_CWMIN_B;
                byMaxMin = 5;
-       } else { // PK_TYPE_11GA & PK_TYPE_11GB
+       } else { /* PK_TYPE_11GA & PK_TYPE_11GB */
                pDevice->uSIFS = C_SIFS_BG;
                if (pDevice->bShortSlotTime)
                        pDevice->uSlot = C_SLOT_SHORT;
@@ -1726,7 +811,8 @@ void vUpdateIFS(struct vnt_private *pDevice)
                        pDevice->uSlot = C_SLOT_LONG;
 
                pDevice->uDIFS = C_SIFS_BG + 2*pDevice->uSlot;
-               if (pDevice->wBasicRate & 0x0150) { //0000 0001 0101 0000,24M,12M,6M
+               if (pDevice->wBasicRate & 0x0150) {
+                       /* 0000 0001 0101 0000,24M,12M,6M */
                        pDevice->uCwMin = C_CWMIN_A;
                        byMaxMin = 4;
                } else {
@@ -1738,7 +824,7 @@ void vUpdateIFS(struct vnt_private *pDevice)
        pDevice->uCwMax = C_CWMAX;
        pDevice->uEIFS = C_EIFS;
        if (pDevice->byRFType == RF_RFMD2959) {
-               // bcs TX_PE will reserve 3 us
+               /* bcs TX_PE will reserve 3 us */
                VNSvOutPortB(pDevice->PortOffset + MAC_REG_SIFS, (unsigned char)(pDevice->uSIFS - 3));
                VNSvOutPortB(pDevice->PortOffset + MAC_REG_DIFS, (unsigned char)(pDevice->uDIFS - 3));
        } else {
@@ -1747,7 +833,7 @@ void vUpdateIFS(struct vnt_private *pDevice)
        }
        VNSvOutPortB(pDevice->PortOffset + MAC_REG_EIFS, (unsigned char)pDevice->uEIFS);
        VNSvOutPortB(pDevice->PortOffset + MAC_REG_SLOT, (unsigned char)pDevice->uSlot);
-       byMaxMin |= 0xA0;//1010 1111,C_CWMAX = 1023
+       byMaxMin |= 0xA0; /* 1010 1111,C_CWMAX = 1023 */
        VNSvOutPortB(pDevice->PortOffset + MAC_REG_CWMAXMIN0, (unsigned char)byMaxMin);
 }
 
@@ -1756,7 +842,7 @@ void CARDvUpdateBasicTopRate(struct vnt_private *pDevice)
        unsigned char byTopOFDM = RATE_24M, byTopCCK = RATE_1M;
        unsigned char ii;
 
-       //Determines the highest basic rate.
+       /* Determines the highest basic rate. */
        for (ii = RATE_54M; ii >= RATE_6M; ii--) {
                if ((pDevice->wBasicRate) & ((unsigned short)(1<<ii))) {
                        byTopOFDM = ii;
@@ -1782,7 +868,7 @@ bool CARDbAddBasicRate(struct vnt_private *pDevice, unsigned short wRateIdx)
 
        pDevice->wBasicRate |= wRate;
 
-       //Determines the highest basic rate.
+       /* Determines the highest basic rate. */
        CARDvUpdateBasicTopRate((void *)pDevice);
 
        return true;
@@ -1821,7 +907,6 @@ unsigned char CARDbyGetPktType(struct vnt_private *pDevice)
  *      none
  *
  * Return Value: none
- *
  */
 void CARDvSetLoopbackMode(void __iomem *dwIoBase, unsigned short wLoopbackMode)
 {
@@ -1834,9 +919,9 @@ void CARDvSetLoopbackMode(void __iomem *dwIoBase, unsigned short wLoopbackMode)
                ASSERT(false);
                break;
        }
-       // set MAC loopback
+       /* set MAC loopback */
        MACvSetLoopbackMode(dwIoBase, LOBYTE(wLoopbackMode));
-       // set Baseband loopback
+       /* set Baseband loopback */
 }
 
 /*
@@ -1849,12 +934,11 @@ void CARDvSetLoopbackMode(void __iomem *dwIoBase, unsigned short wLoopbackMode)
  *      none
  *
  * Return Value: none
- *
  */
 bool CARDbSoftwareReset(struct vnt_private *pDevice)
 {
 
-       // reset MAC
+       /* reset MAC */
        if (!MACbSafeSoftwareReset(pDevice->PortOffset))
                return false;
 
@@ -1874,7 +958,6 @@ bool CARDbSoftwareReset(struct vnt_private *pDevice)
  *      none
  *
  * Return Value: TSF Offset value
- *
  */
 u64 CARDqGetTSFOffset(unsigned char byRxRate, u64 qwTSF1, u64 qwTSF2)
 {
@@ -1901,7 +984,6 @@ u64 CARDqGetTSFOffset(unsigned char byRxRate, u64 qwTSF1, u64 qwTSF2)
  *      qwCurrTSF       - Current TSF counter
  *
  * Return Value: true if success; otherwise false
- *
  */
 bool CARDbGetCurrentTSF(void __iomem *dwIoBase, u64 *pqwCurrTSF)
 {
@@ -1934,17 +1016,12 @@ bool CARDbGetCurrentTSF(void __iomem *dwIoBase, u64 *pqwCurrTSF)
  *      qwCurrTSF       - Current TSF counter
  *
  * Return Value: TSF value of next Beacon
- *
  */
 u64 CARDqGetNextTBTT(u64 qwTSF, unsigned short wBeaconInterval)
 {
        u32 beacon_int;
 
        beacon_int = wBeaconInterval * 1024;
-
-       /* Next TBTT =
-       *       ((local_current_TSF / beacon_interval) + 1) * beacon_interval
-       */
        if (beacon_int) {
                do_div(qwTSF, beacon_int);
                qwTSF += 1;
@@ -1966,16 +1043,15 @@ u64 CARDqGetNextTBTT(u64 qwTSF, unsigned short wBeaconInterval)
  *      none
  *
  * Return Value: none
- *
  */
 void CARDvSetFirstNextTBTT(void __iomem *dwIoBase, unsigned short wBeaconInterval)
 {
        u64 qwNextTBTT = 0;
 
-       CARDbGetCurrentTSF(dwIoBase, &qwNextTBTT); //Get Local TSF counter
+       CARDbGetCurrentTSF(dwIoBase, &qwNextTBTT); /* Get Local TSF counter */
 
        qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval);
-       // Set NextTBTT
+       /* Set NextTBTT */
        VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT, (u32)qwNextTBTT);
        VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT + 4, (u32)(qwNextTBTT >> 32));
        MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN);
@@ -1994,12 +1070,11 @@ void CARDvSetFirstNextTBTT(void __iomem *dwIoBase, unsigned short wBeaconInterva
  *      none
  *
  * Return Value: none
- *
  */
 void CARDvUpdateNextTBTT(void __iomem *dwIoBase, u64 qwTSF, unsigned short wBeaconInterval)
 {
        qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval);
-       // Set NextTBTT
+       /* Set NextTBTT */
        VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT, (u32)qwTSF);
        VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT + 4, (u32)(qwTSF >> 32));
        MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN);
index 96f5b6c..f12afef 100644 (file)
 #ifndef __CARD_H__
 #define __CARD_H__
 
-#include "ttype.h"
 #include <linux/types.h>
 #include <linux/nl80211.h>
 
-//
-// Loopback mode
-//
-// LOBYTE is MAC LB mode, HIBYTE is MII LB mode
+/*
+ * Loopback mode
+ *
+ * LOBYTE is MAC LB mode, HIBYTE is MII LB mode
+ */
 #define CARD_LB_NONE            MAKEWORD(MAC_LB_NONE, 0)
-#define CARD_LB_MAC             MAKEWORD(MAC_LB_INTERNAL, 0)   // PHY must ISO, avoid MAC loopback packet go out
+#define CARD_LB_MAC             MAKEWORD(MAC_LB_INTERNAL, 0)   /* PHY must ISO, avoid MAC loopback packet go out */
 #define CARD_LB_PHY             MAKEWORD(MAC_LB_EXT, 0)
 
-#define DEFAULT_MSDU_LIFETIME           512  // ms
-#define DEFAULT_MSDU_LIFETIME_RES_64us  8000 // 64us
+#define DEFAULT_MSDU_LIFETIME           512  /* ms */
+#define DEFAULT_MSDU_LIFETIME_RES_64us  8000 /* 64us */
 
-#define DEFAULT_MGN_LIFETIME            8    // ms
-#define DEFAULT_MGN_LIFETIME_RES_64us   125  // 64us
+#define DEFAULT_MGN_LIFETIME            8    /* ms */
+#define DEFAULT_MGN_LIFETIME_RES_64us   125  /* 64us */
 
 #define CB_MAX_CHANNEL_24G      14
 #define CB_MAX_CHANNEL_5G       42
 #define CB_MAX_CHANNEL          (CB_MAX_CHANNEL_24G+CB_MAX_CHANNEL_5G)
 
 typedef enum _CARD_PHY_TYPE {
-       PHY_TYPE_AUTO,
+       PHY_TYPE_11A = 0,
        PHY_TYPE_11B,
        PHY_TYPE_11G,
-       PHY_TYPE_11A
+       PHY_TYPE_AUTO
 } CARD_PHY_TYPE, *PCARD_PHY_TYPE;
 
 typedef enum _CARD_PKT_TYPE {
@@ -85,91 +85,16 @@ void CARDvUpdateNextTBTT(void __iomem *dwIoBase, u64 qwTSF, unsigned short wBeac
 bool CARDbGetCurrentTSF(void __iomem *dwIoBase, u64 *pqwCurrTSF);
 u64 CARDqGetNextTBTT(u64 qwTSF, unsigned short wBeaconInterval);
 u64 CARDqGetTSFOffset(unsigned char byRxRate, u64 qwTSF1, u64 qwTSF2);
-bool CARDbSetTxPower(struct vnt_private *, unsigned long ulTxPower);
 unsigned char CARDbyGetPktType(struct vnt_private *);
 void CARDvSafeResetTx(struct vnt_private *);
 void CARDvSafeResetRx(struct vnt_private *);
 bool CARDbRadioPowerOff(struct vnt_private *);
 bool CARDbRadioPowerOn(struct vnt_private *);
-bool CARDbIsShortPreamble(struct vnt_private *);
-bool CARDbIsShorSlotTime(struct vnt_private *);
 bool CARDbSetPhyParameter(struct vnt_private *, CARD_PHY_TYPE ePHYType,
                          unsigned short wCapInfo, unsigned char byERPField,
                          void *pvSupportRateIEs, void *pvExtSupportRateIEs);
 bool CARDbUpdateTSF(struct vnt_private *, unsigned char byRxRate,
                    u64 qwBSSTimestamp, u64 qwLocalTSF);
-bool CARDbStopTxPacket(struct vnt_private *, CARD_PKT_TYPE ePktType);
-bool CARDbStartTxPacket(struct vnt_private *, CARD_PKT_TYPE ePktType);
 bool CARDbSetBeaconPeriod(struct vnt_private *, unsigned short wBeaconInterval);
-bool CARDbSetBSSID(struct vnt_private *,
-                  unsigned char *pbyBSSID, enum nl80211_iftype);
-
-bool CARDbPowerDown(struct vnt_private *);
-
-bool CARDbSetTxDataRate(struct vnt_private *, unsigned short wDataRate);
-
-bool CARDbRemoveKey(struct vnt_private *, unsigned char *pbyBSSID);
-
-bool
-CARDbAdd_PMKID_Candidate(
-       struct vnt_private *,
-       unsigned char *pbyBSSID,
-       bool bRSNCapExist,
-       unsigned short wRSNCap
-);
-
-void *
-CARDpGetCurrentAddress(
-       struct vnt_private *
-);
-
-bool
-CARDbStartMeasure(
-       struct vnt_private *,
-       void *pvMeasureEIDs,
-       unsigned int uNumOfMeasureEIDs
-);
-
-bool
-CARDbChannelSwitch(
-       struct vnt_private *,
-       unsigned char byMode,
-       unsigned char byNewChannel,
-       unsigned char byCount
-);
-
-bool
-CARDbSetQuiet(
-       struct vnt_private *,
-       bool bResetQuiet,
-       unsigned char byQuietCount,
-       unsigned char byQuietPeriod,
-       unsigned short wQuietDuration,
-       unsigned short wQuietOffset
-);
-
-bool
-CARDbStartQuiet(
-       struct vnt_private *
-);
-
-void
-CARDvSetPowerConstraint(
-       struct vnt_private *,
-       unsigned char byChannel,
-       char byPower
-);
-
-void
-CARDvGetPowerCapability(
-       struct vnt_private *,
-       unsigned char *pbyMinPower,
-       unsigned char *pbyMaxPower
-);
-
-char
-CARDbyGetTransmitPower(
-       struct vnt_private *
-);
 
-#endif // __CARD_H__
+#endif /* __CARD_H__ */
index 4ce964b..6bd5f16 100644 (file)
  */
 
 #include "baseband.h"
-#include "country.h"
 #include "channel.h"
 #include "device.h"
 #include "rf.h"
 
-/*---------------------  Static Definitions -------------------------*/
-
-#define CARD_MAX_CHANNEL_TBL    56
-
-/*---------------------  Static Variables  --------------------------*/
-
-static SChannelTblElement sChannelTbl[CARD_MAX_CHANNEL_TBL + 1] =
-{
-       {0,   0,    false,    0},
-       {1,   2412, true,     0},
-       {2,   2417, true,     0},
-       {3,   2422, true,     0},
-       {4,   2427, true,     0},
-       {5,   2432, true,     0},
-       {6,   2437, true,     0},
-       {7,   2442, true,     0},
-       {8,   2447, true,     0},
-       {9,   2452, true,     0},
-       {10,  2457, true,     0},
-       {11,  2462, true,     0},
-       {12,  2467, true,     0},
-       {13,  2472, true,     0},
-       {14,  2484, true,     0},
-       {183, 4915, true,     0},
-       {184, 4920, true,     0},
-       {185, 4925, true,     0},
-       {187, 4935, true,     0},
-       {188, 4940, true,     0},
-       {189, 4945, true,     0},
-       {192, 4960, true,     0},
-       {196, 4980, true,     0},
-       {7,   5035, true,     0},
-       {8,   5040, true,     0},
-       {9,   5045, true,     0},
-       {11,  5055, true,     0},
-       {12,  5060, true,     0},
-       {16,  5080, true,     0},
-       {34,  5170, true,     0},
-       {36,  5180, true,     0},
-       {38,  5190, true,     0},
-       {40,  5200, true,     0},
-       {42,  5210, true,     0},
-       {44,  5220, true,     0},
-       {46,  5230, true,     0},
-       {48,  5240, true,     0},
-       {52,  5260, true,     0},
-       {56,  5280, true,     0},
-       {60,  5300, true,     0},
-       {64,  5320, true,     0},
-       {100, 5500, true,     0},
-       {104, 5520, true,     0},
-       {108, 5540, true,     0},
-       {112, 5560, true,     0},
-       {116, 5580, true,     0},
-       {120, 5600, true,     0},
-       {124, 5620, true,     0},
-       {128, 5640, true,     0},
-       {132, 5660, true,     0},
-       {136, 5680, true,     0},
-       {140, 5700, true,     0},
-       {149, 5745, true,     0},
-       {153, 5765, true,     0},
-       {157, 5785, true,     0},
-       {161, 5805, true,     0},
-       {165, 5825, true,     0}
+static struct ieee80211_rate vnt_rates_bg[] = {
+       { .bitrate = 10,  .hw_value = RATE_1M },
+       { .bitrate = 20,  .hw_value = RATE_2M },
+       { .bitrate = 55,  .hw_value = RATE_5M },
+       { .bitrate = 110, .hw_value = RATE_11M },
+       { .bitrate = 60,  .hw_value = RATE_6M },
+       { .bitrate = 90,  .hw_value = RATE_9M },
+       { .bitrate = 120, .hw_value = RATE_12M },
+       { .bitrate = 180, .hw_value = RATE_18M },
+       { .bitrate = 240, .hw_value = RATE_24M },
+       { .bitrate = 360, .hw_value = RATE_36M },
+       { .bitrate = 480, .hw_value = RATE_48M },
+       { .bitrate = 540, .hw_value = RATE_54M },
 };
 
-/************************************************************************
- * The Radar regulation rules for each country
- ************************************************************************/
-static struct
-{
-       unsigned char byChannelCountryCode;             /* The country code         */
-       char chCountryCode[2];
-       unsigned char bChannelIdxList[CB_MAX_CHANNEL];  /* Available channels Index */
-       unsigned char byPower[CB_MAX_CHANNEL];
-} ChannelRuleTab[] =
-{
-/************************************************************************
- * This table is based on Athero driver rules
- ************************************************************************/
-/* Country          Available channels, ended with 0                    */
-/*                                              1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  */
-       {CCODE_FCC,                     {'U' , 'S'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 17,  0, 17,  0, 17,  0, 17, 23, 23, 23, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_TELEC,                   {'J' , 'P'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  0,  0,  1,  0,  1,  1,  0,  1,  0,  0,  1,  1,  1,  0,  1,  0,  1,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0, 23,  0,  0, 23,  0, 23, 23,  0, 23,  0,  0, 23, 23, 23,  0, 23,  0, 23,  0, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_ETSI,                    {'E' , 'U'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_RESV3,                   {' ' , ' '},  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_RESV4,                   {' ' , ' '},  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_RESV5,                   {' ' , ' '},  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_RESV6,                   {' ' , ' '},  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_RESV7,                   {' ' , ' '},  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_RESV8,                   {' ' , ' '},  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_RESV9,                   {' ' , ' '},  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_RESVa,                   {' ' , ' '},  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_RESVb,                   {' ' , ' '},  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_RESVc,                   {' ' , ' '},  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_RESVd,                   {' ' , ' '},  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_RESVe,                   {' ' , ' '},  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_ALLBAND,                 {' ' , ' '},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_ALBANIA,                 {'A' , 'L'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_ALGERIA,                 {'D' , 'Z'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_ARGENTINA,               {'A' , 'R'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 17, 17, 17,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30,  0}  },
-       {CCODE_ARMENIA,                 {'A' , 'M'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 18,  0, 18,  0, 18,  0, 18, 18, 18, 18, 18,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_AUSTRALIA,               {'A' , 'U'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 23,  0, 23,  0, 23,  0, 23, 23, 23, 23, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_AUSTRIA,                 {'A' , 'T'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 15,  0, 15,  0, 15,  0, 15,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_AZERBAIJAN,              {'A' , 'Z'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 18,  0, 18,  0, 18,  0, 18, 18, 18, 18, 18,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_BAHRAIN,                 {'B' , 'H'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_BELARUS,                 {'B' , 'Y'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_BELGIUM,                 {'B' , 'E'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 18,  0, 18,  0, 18,  0, 18,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_BELIZE,                  {'B' , 'Z'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_BOLIVIA,                 {'B' , 'O'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_BRAZIL,                  {'B' , 'R'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_BRUNEI_DARUSSALAM,       {'B' , 'N'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_BULGARIA,                {'B' , 'G'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 23,  0, 23,  0, 23,  0, 23, 23, 23,  0,  0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,  0,  0,  0,  0,  0}  },
-       {CCODE_CANADA,                  {'C' , 'A'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 17,  0, 17,  0, 17,  0, 17, 23, 23, 23, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_CHILE,                   {'C' , 'L'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 17, 17, 17, 17, 17}  },
-       {CCODE_CHINA,                   {'C' , 'N'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_COLOMBIA,                {'C' , 'O'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 17,  0, 17,  0, 17,  0, 17, 23, 23, 23, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_COSTA_RICA,              {'C' , 'R'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_CROATIA,                 {'H' , 'R'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_CYPRUS,                  {'C' , 'Y'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_CZECH,                   {'C' , 'Z'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_DENMARK,                 {'D' , 'K'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_DOMINICAN_REPUBLIC,      {'D' , 'O'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 17,  0, 17,  0, 17,  0, 17, 23, 23, 23, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_ECUADOR,                 {'E' , 'C'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_EGYPT,                   {'E' , 'G'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_EL_SALVADOR,             {'S' , 'V'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_ESTONIA,                 {'E' , 'E'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_FINLAND,                 {'F' , 'I'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_FRANCE,                  {'F' , 'R'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_GERMANY,                 {'D' , 'E'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_GREECE,                  {'G' , 'R'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_GEORGIA,                 {'G' , 'E'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 18,  0, 18,  0, 18,  0, 18, 18, 18, 18, 18,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_GUATEMALA,               {'G' , 'T'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 17,  0, 17,  0, 17,  0, 17, 23, 23, 23, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_HONDURAS,                {'H' , 'N'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_HONG_KONG,               {'H' , 'K'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 23,  0, 23,  0, 23,  0, 23, 23, 23, 23, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_HUNGARY,                 {'H' , 'U'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 18,  0, 18,  0, 18,  0, 18,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_ICELAND,                 {'I' , 'S'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_INDIA,                   {'I' , 'N'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_INDONESIA,               {'I' , 'D'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_IRAN,                    {'I' , 'R'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_IRELAND,                 {'I' , 'E'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_ITALY,                   {'I' , 'T'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_ISRAEL,                  {'I' , 'L'},  {   0,  0,  0,  0,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_JAPAN,                   {'J' , 'P'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 23,  0, 23,  0, 23,  0, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_JORDAN,                  {'J' , 'O'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_KAZAKHSTAN,              {'K' , 'Z'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_KUWAIT,                  {'K' , 'W'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_LATVIA,                  {'L' , 'V'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_LEBANON,                 {'L' , 'B'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_LEICHTENSTEIN,           {'L' , 'I'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 18,  0, 18,  0, 18,  0, 18,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_LITHUANIA,               {'L' , 'T'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_LUXEMBURG,               {'L' , 'U'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_MACAU,                   {'M' , 'O'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 23,  0, 23,  0, 23,  0, 23, 23, 23, 23, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_MACEDONIA,               {'M' , 'K'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_MALTA,                   {'M' , 'T'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  0}
-        ,  {  23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 16,  0, 16,  0, 16,  0, 16, 16, 16, 16, 16,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 16, 16, 16, 16,  0}  },
-       {CCODE_MALAYSIA,                {'M' , 'Y'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_MEXICO,                  {'M' , 'X'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 17,  0, 17,  0, 17,  0, 17, 23, 23, 23, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_MONACO,                  {'M' , 'C'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 18,  0, 18,  0, 18,  0, 18, 18, 18, 18, 18,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_MOROCCO,                 {'M' , 'A'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_NETHERLANDS,             {'N' , 'L'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_NEW_ZEALAND,             {'N' , 'Z'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 23,  0, 23,  0, 23,  0, 23, 23, 23, 23, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_NORTH_KOREA,             {'K' , 'P'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 23, 23, 23, 23,  0}  },
-       {CCODE_NORWAY,                  {'N' , 'O'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_OMAN,                    {'O' , 'M'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_PAKISTAN,                {'P' , 'K'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_PANAMA,                  {'P' , 'A'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 17,  0, 17,  0, 17,  0, 17, 23, 23, 23, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_PERU,                    {'P' , 'E'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_PHILIPPINES,             {'P' , 'H'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 17,  0, 17,  0, 17,  0, 17, 23, 23, 23, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_POLAND,                  {'P' , 'L'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_PORTUGAL,                {'P' , 'T'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_PUERTO_RICO,             {'P' , 'R'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 17,  0, 17,  0, 17,  0, 17, 23, 23, 23, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_QATAR,                   {'Q' , 'A'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_ROMANIA,                 {'R' , 'O'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_RUSSIA,                  {'R' , 'U'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_SAUDI_ARABIA,            {'S' , 'A'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_SINGAPORE,               {'S' , 'G'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20, 20, 20, 20, 20}  },
-       {CCODE_SLOVAKIA,                {'S' , 'K'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  0}
-        ,  {  23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 16,  0, 16,  0, 16,  0, 16, 16, 16, 16, 16,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 16, 16, 16, 16,  0}  },
-       {CCODE_SLOVENIA,                {'S' , 'I'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_SOUTH_AFRICA,            {'Z' , 'A'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_SOUTH_KOREA,             {'K' , 'R'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 23, 23, 23, 23,  0}  },
-       {CCODE_SPAIN,                   {'E' , 'S'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  0}
-        ,  {  23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 16,  0, 16,  0, 16,  0, 16, 16, 16, 16, 16,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 16, 16, 16, 16,  0}  },
-       {CCODE_SWEDEN,                  {'S' , 'E'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_SWITZERLAND,             {'C' , 'H'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 18,  0, 18,  0, 18,  0, 18,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_SYRIA,                   {'S' , 'Y'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_TAIWAN,                  {'T' , 'W'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 17, 17, 17,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30,  0}  },
-       {CCODE_THAILAND,                {'T' , 'H'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 23, 23, 23, 23,  0}  },
-       {CCODE_TRINIDAD_TOBAGO,         {'T' , 'T'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 18,  0, 18,  0, 18,  0, 18, 18, 18, 18, 18,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_TUNISIA,                 {'T' , 'N'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_TURKEY,                  {'T' , 'R'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_UK,                      {'G' , 'B'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0, 20,  0, 20,  0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0}  },
-       {CCODE_UKRAINE,                 {'U' , 'A'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_UNITED_ARAB_EMIRATES,    {'A' , 'E'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_UNITED_STATES,           {'U' , 'S'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1}
-        ,  {  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 17,  0, 17,  0, 17,  0, 17, 23, 23, 23, 23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30, 30}  },
-       {CCODE_URUGUAY,                 {'U' , 'Y'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 23, 23, 23, 23,  0}  },
-       {CCODE_UZBEKISTAN,              {'U' , 'Z'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_VENEZUELA,               {'V' , 'E'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  0}
-        ,  {  20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 23, 23, 23, 23,  0}  },
-       {CCODE_VIETNAM,                 {'V' , 'N'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_YEMEN,                   {'Y' , 'E'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_ZIMBABWE,                {'Z' , 'W'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_JAPAN_W52_W53,           {'J' , 'J'},  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  1,  0,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  },
-       {CCODE_MAX,                     {'U' , 'N'},  {   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1}
-        ,  {   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}  }
-/*                                              1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  */
+static struct ieee80211_rate vnt_rates_a[] = {
+       { .bitrate = 60,  .hw_value = RATE_6M },
+       { .bitrate = 90,  .hw_value = RATE_9M },
+       { .bitrate = 120, .hw_value = RATE_12M },
+       { .bitrate = 180, .hw_value = RATE_18M },
+       { .bitrate = 240, .hw_value = RATE_24M },
+       { .bitrate = 360, .hw_value = RATE_36M },
+       { .bitrate = 480, .hw_value = RATE_48M },
+       { .bitrate = 540, .hw_value = RATE_54M },
 };
 
-/*---------------------  Export Functions  --------------------------*/
-
-/**
- * is_channel_valid() - Is Country Channel Valid
- *  @ChanneIndex: defined as VT3253 MAC channel:
- *              1   = 2.4G channel 1
- *              2   = 2.4G channel 2
- *              ...
- *              14  = 2.4G channel 14
- *              15  = 4.9G channel 183
- *              16  = 4.9G channel 184
- *              .....
- *  Output: true if the specified 5GHz band is allowed to be used,
- *          false otherwise.
- * 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196 (Value:15 ~ 22)
- *
- * 5G => Ch 7, 8, 9, 11, 12, 16, 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64,
- * 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165 (Value 23 ~ 56)
- */
-
-bool is_channel_valid(unsigned int ChannelIndex)
-{
-       bool bValid;
-
-       bValid = false;
-       /*
-        * If Channel Index is invalid, return invalid
-        */
-       if ((ChannelIndex > CB_MAX_CHANNEL) ||
-           (ChannelIndex == 0)) {
-               bValid = false;
-               goto exit;
-       }
+static struct ieee80211_channel vnt_channels_2ghz[] = {
+       { .center_freq = 2412, .hw_value = 1 },
+       { .center_freq = 2417, .hw_value = 2 },
+       { .center_freq = 2422, .hw_value = 3 },
+       { .center_freq = 2427, .hw_value = 4 },
+       { .center_freq = 2432, .hw_value = 5 },
+       { .center_freq = 2437, .hw_value = 6 },
+       { .center_freq = 2442, .hw_value = 7 },
+       { .center_freq = 2447, .hw_value = 8 },
+       { .center_freq = 2452, .hw_value = 9 },
+       { .center_freq = 2457, .hw_value = 10 },
+       { .center_freq = 2462, .hw_value = 11 },
+       { .center_freq = 2467, .hw_value = 12 },
+       { .center_freq = 2472, .hw_value = 13 },
+       { .center_freq = 2484, .hw_value = 14 }
+};
 
-       bValid = sChannelTbl[ChannelIndex].bValid;
+static struct ieee80211_channel vnt_channels_5ghz[] = {
+       { .center_freq = 4915, .hw_value = 15 },
+       { .center_freq = 4920, .hw_value = 16 },
+       { .center_freq = 4925, .hw_value = 17 },
+       { .center_freq = 4935, .hw_value = 18 },
+       { .center_freq = 4940, .hw_value = 19 },
+       { .center_freq = 4945, .hw_value = 20 },
+       { .center_freq = 4960, .hw_value = 21 },
+       { .center_freq = 4980, .hw_value = 22 },
+       { .center_freq = 5035, .hw_value = 23 },
+       { .center_freq = 5040, .hw_value = 24 },
+       { .center_freq = 5045, .hw_value = 25 },
+       { .center_freq = 5055, .hw_value = 26 },
+       { .center_freq = 5060, .hw_value = 27 },
+       { .center_freq = 5080, .hw_value = 28 },
+       { .center_freq = 5170, .hw_value = 29 },
+       { .center_freq = 5180, .hw_value = 30 },
+       { .center_freq = 5190, .hw_value = 31 },
+       { .center_freq = 5200, .hw_value = 32 },
+       { .center_freq = 5210, .hw_value = 33 },
+       { .center_freq = 5220, .hw_value = 34 },
+       { .center_freq = 5230, .hw_value = 35 },
+       { .center_freq = 5240, .hw_value = 36 },
+       { .center_freq = 5260, .hw_value = 37 },
+       { .center_freq = 5280, .hw_value = 38 },
+       { .center_freq = 5300, .hw_value = 39 },
+       { .center_freq = 5320, .hw_value = 40 },
+       { .center_freq = 5500, .hw_value = 41 },
+       { .center_freq = 5520, .hw_value = 42 },
+       { .center_freq = 5540, .hw_value = 43 },
+       { .center_freq = 5560, .hw_value = 44 },
+       { .center_freq = 5580, .hw_value = 45 },
+       { .center_freq = 5600, .hw_value = 46 },
+       { .center_freq = 5620, .hw_value = 47 },
+       { .center_freq = 5640, .hw_value = 48 },
+       { .center_freq = 5660, .hw_value = 49 },
+       { .center_freq = 5680, .hw_value = 50 },
+       { .center_freq = 5700, .hw_value = 51 },
+       { .center_freq = 5745, .hw_value = 52 },
+       { .center_freq = 5765, .hw_value = 53 },
+       { .center_freq = 5785, .hw_value = 54 },
+       { .center_freq = 5805, .hw_value = 55 },
+       { .center_freq = 5825, .hw_value = 56 }
+};
 
-exit:
-       return bValid;
-}
+static struct ieee80211_supported_band vnt_supported_2ghz_band = {
+       .channels = vnt_channels_2ghz,
+       .n_channels = ARRAY_SIZE(vnt_channels_2ghz),
+       .bitrates = vnt_rates_bg,
+       .n_bitrates = ARRAY_SIZE(vnt_rates_bg),
+};
 
-/**
- * channel_get_list() - Get Available Channel List for a given country
- * @CountryCode: The country code defined in country.h
- *
- * Output:
- *      pbyChannelTable:   (QWORD *) correspondent bit mask
- *                          of available channels
- *                          0x0000000000000001 means channel 1 is supported
- *                          0x0000000000000003 means channel 1,2 are supported
- *                          0x000000000000000F means channel 1,2,..15 are supported
- */
+static struct ieee80211_supported_band vnt_supported_5ghz_band = {
+       .channels = vnt_channels_5ghz,
+       .n_channels = ARRAY_SIZE(vnt_channels_5ghz),
+       .bitrates = vnt_rates_a,
+       .n_bitrates = ARRAY_SIZE(vnt_rates_a),
+};
 
-bool channel_get_list(unsigned int uCountryCodeIdx, unsigned char *pbyChannelTable)
+void vnt_init_bands(struct vnt_private *priv)
 {
-       if (uCountryCodeIdx >= CCODE_MAX)
-               return false;
-
-       memcpy(pbyChannelTable, ChannelRuleTab[uCountryCodeIdx].bChannelIdxList, CB_MAX_CHANNEL);
-
-       return true;
-}
+       struct ieee80211_channel *ch;
+       int i;
 
-void init_channel_table(void *pDeviceHandler)
-{
-       struct vnt_private *pDevice = pDeviceHandler;
-       bool bMultiBand = false;
-       unsigned int ii;
+       switch (priv->byRFType) {
+       case RF_AIROHA7230:
+       case RF_UW2452:
+       case RF_NOTHING:
+       default:
+               ch = vnt_channels_5ghz;
 
-       for (ii = 1; ii <= CARD_MAX_CHANNEL_TBL; ii++)
-               sChannelTbl[ii].bValid = false;
+               for (i = 0; i < ARRAY_SIZE(vnt_channels_5ghz); i++) {
+                       ch[i].max_power = 0x3f;
+                       ch[i].flags = IEEE80211_CHAN_NO_HT40;
+               }
 
-       switch (pDevice->byRFType) {
+               priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
+                                               &vnt_supported_5ghz_band;
+       /* fallthrough */
        case RF_RFMD2959:
        case RF_AIROHA:
        case RF_AL2230S:
        case RF_UW2451:
        case RF_VT3226:
-               bMultiBand = false;
-               break;
-       case RF_AIROHA7230:
-       case RF_UW2452:
-       case RF_NOTHING:
-       default:
-               bMultiBand = true;
-               break;
-       }
+               ch = vnt_channels_2ghz;
 
-       if ((pDevice->dwDiagRefCount != 0) || pDevice->b11hEnable) {
-               if (bMultiBand) {
-                       for (ii = 0; ii < CARD_MAX_CHANNEL_TBL; ii++) {
-                               sChannelTbl[ii + 1].bValid = true;
-                               pDevice->abyRegPwr[ii + 1] = pDevice->abyOFDMDefaultPwr[ii + 1];
-                               pDevice->abyLocalPwr[ii + 1] = pDevice->abyOFDMDefaultPwr[ii + 1];
-                       }
-                       for (ii = 0; ii < CHANNEL_MAX_24G; ii++) {
-                               pDevice->abyRegPwr[ii + 1] = pDevice->abyCCKDefaultPwr[ii + 1];
-                               pDevice->abyLocalPwr[ii + 1] = pDevice->abyCCKDefaultPwr[ii + 1];
-                       }
-               } else {
-                       for (ii = 0; ii < CHANNEL_MAX_24G; ii++) {
-                               //2008-8-4 <add> by chester
-                               if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) {
-                                       sChannelTbl[ii + 1].bValid = true;
-                                       pDevice->abyRegPwr[ii + 1] = pDevice->abyCCKDefaultPwr[ii + 1];
-                                       pDevice->abyLocalPwr[ii + 1] = pDevice->abyCCKDefaultPwr[ii + 1];
-                               }
-                       }
+               for (i = 0; i < ARRAY_SIZE(vnt_channels_2ghz); i++) {
+                       ch[i].max_power = 0x3f;
+                       ch[i].flags = IEEE80211_CHAN_NO_HT40;
                }
-       } else if (pDevice->byZoneType <= CCODE_MAX) {
-               if (bMultiBand) {
-                       for (ii = 0; ii < CARD_MAX_CHANNEL_TBL; ii++) {
-                               if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) {
-                                       sChannelTbl[ii + 1].bValid = true;
-                                       pDevice->abyRegPwr[ii + 1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
-                                       pDevice->abyLocalPwr[ii + 1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
-                               }
-                       }
-               } else {
-                       for (ii = 0; ii < CHANNEL_MAX_24G; ii++) {
-                               if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) {
-                                       sChannelTbl[ii + 1].bValid = true;
-                                       pDevice->abyRegPwr[ii + 1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
-                                       pDevice->abyLocalPwr[ii + 1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
-                               }
-                       }
-               }
-       }
 
-       pr_info("Zone=[%d][%c][%c]!!\n",
-               pDevice->byZoneType,
-               ChannelRuleTab[pDevice->byZoneType].chCountryCode[0],
-               ChannelRuleTab[pDevice->byZoneType].chCountryCode[1]);
-
-       for (ii = 0; ii < CARD_MAX_CHANNEL_TBL; ii++) {
-               if (pDevice->abyRegPwr[ii + 1] == 0)
-                       pDevice->abyRegPwr[ii + 1] = pDevice->abyOFDMDefaultPwr[ii + 1];
-               if (pDevice->abyLocalPwr[ii + 1] == 0)
-                       pDevice->abyLocalPwr[ii + 1] = pDevice->abyOFDMDefaultPwr[ii + 1];
-       }
-}
-
-unsigned char get_channel_mapping(void *pDeviceHandler, unsigned char byChannelNumber, CARD_PHY_TYPE ePhyType)
-{
-       unsigned int ii;
-
-       if ((ePhyType == PHY_TYPE_11B) || (ePhyType == PHY_TYPE_11G))
-               return byChannelNumber;
-
-       for (ii = (CB_MAX_CHANNEL_24G + 1); ii <= CB_MAX_CHANNEL;) {
-               if (sChannelTbl[ii].byChannelNumber == byChannelNumber)
-                       return (unsigned char) ii;
-               ii++;
+               priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
+                                               &vnt_supported_2ghz_band;
+               break;
        }
-       return 0;
-}
-
-unsigned char get_channel_number(void *pDeviceHandler, unsigned char byChannelIndex)
-{
-       return sChannelTbl[byChannelIndex].byChannelNumber;
 }
 
 /**
@@ -528,37 +182,25 @@ bool set_channel(void *pDeviceHandler, unsigned int uConnectionChannel)
        if (pDevice->byCurrentCh == uConnectionChannel)
                return bResult;
 
-       if (!sChannelTbl[uConnectionChannel].bValid)
-               return false;
-
-       if ((uConnectionChannel > CB_MAX_CHANNEL_24G) &&
-           (pDevice->eCurrentPHYType != PHY_TYPE_11A)) {
-               CARDbSetPhyParameter(pDevice, PHY_TYPE_11A, 0, 0, NULL, NULL);
-       } else if ((uConnectionChannel <= CB_MAX_CHANNEL_24G) &&
-                  (pDevice->eCurrentPHYType == PHY_TYPE_11A)) {
-               CARDbSetPhyParameter(pDevice, PHY_TYPE_11G, 0, 0, NULL, NULL);
-       }
-       // clear NAV
+       /* clear NAV */
        MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MACCR, MACCR_CLRNAV);
 
-       //{{ RobertYu: 20041202
-       //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput
+       /* TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput */
 
        if (pDevice->byRFType == RF_AIROHA7230)
                RFbAL7230SelectChannelPostProcess(pDevice->PortOffset, pDevice->byCurrentCh, (unsigned char)uConnectionChannel);
-       //}} RobertYu
 
        pDevice->byCurrentCh = (unsigned char)uConnectionChannel;
        bResult &= RFbSelectChannel(pDevice->PortOffset, pDevice->byRFType, (unsigned char)uConnectionChannel);
 
-       // Init Synthesizer Table
+       /* Init Synthesizer Table */
        if (pDevice->bEnablePSMode)
                RFvWriteWakeProgSyn(pDevice->PortOffset, pDevice->byRFType, uConnectionChannel);
 
        BBvSoftwareReset(pDevice->PortOffset);
 
        if (pDevice->byLocalID > REV_ID_VT3253_B1) {
-               // set HW default power register
+               /* set HW default power register */
                MACvSelectPage1(pDevice->PortOffset);
                RFbSetPower(pDevice, RATE_1M, pDevice->byCurrentCh);
                VNSvOutPortB(pDevice->PortOffset + MAC_REG_PWRCCK, pDevice->byCurPwr);
@@ -567,242 +209,10 @@ bool set_channel(void *pDeviceHandler, unsigned int uConnectionChannel)
                MACvSelectPage0(pDevice->PortOffset);
        }
 
-       if (pDevice->eCurrentPHYType == PHY_TYPE_11B)
+       if (pDevice->byBBType == BB_TYPE_11B)
                RFbSetPower(pDevice, RATE_1M, pDevice->byCurrentCh);
        else
                RFbSetPower(pDevice, RATE_6M, pDevice->byCurrentCh);
 
        return bResult;
 }
-
-/**
- * set_country_info() - Set Channel Info of Country
- *
- * Return Value: none.
- *
- */
-
-void set_country_info(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, void *pIE)
-{
-       struct vnt_private *pDevice = pDeviceHandler;
-       unsigned int ii = 0;
-       unsigned int uu = 0;
-       unsigned int step = 0;
-       unsigned int uNumOfCountryInfo = 0;
-       unsigned char byCh = 0;
-       PWLAN_IE_COUNTRY pIE_Country = (PWLAN_IE_COUNTRY) pIE;
-
-       uNumOfCountryInfo = (pIE_Country->len - 3);
-       uNumOfCountryInfo /= 3;
-
-       if (ePHYType == PHY_TYPE_11A) {
-               pDevice->bCountryInfo5G = true;
-               for (ii = CB_MAX_CHANNEL_24G + 1; ii <= CARD_MAX_CHANNEL_TBL; ii++)
-                       sChannelTbl[ii].bValid = false;
-
-               step = 4;
-       } else {
-               pDevice->bCountryInfo24G = true;
-               for (ii = 1; ii <= CB_MAX_CHANNEL_24G; ii++)
-                       sChannelTbl[ii].bValid = false;
-
-               step = 1;
-       }
-       pDevice->abyCountryCode[0] = pIE_Country->abyCountryString[0];
-       pDevice->abyCountryCode[1] = pIE_Country->abyCountryString[1];
-       pDevice->abyCountryCode[2] = pIE_Country->abyCountryString[2];
-
-       for (ii = 0; ii < uNumOfCountryInfo; ii++) {
-               for (uu = 0; uu < pIE_Country->abyCountryInfo[ii*3+1]; uu++) {
-                       byCh = get_channel_mapping(pDevice, (unsigned char)(pIE_Country->abyCountryInfo[ii*3]+step*uu), ePHYType);
-                       sChannelTbl[byCh].bValid = true;
-                       pDevice->abyRegPwr[byCh] = pIE_Country->abyCountryInfo[ii*3+2];
-               }
-       }
-}
-
-/**
- *
- * set_support_channels() - Set Support Channels IE defined in 802.11h
- *
- * @hDeviceContext: device structure point
- *
- * Return Value: none.
- *
- */
-
-unsigned char set_support_channels(void *pDeviceHandler, unsigned char *pbyIEs)
-{
-       struct vnt_private *pDevice = pDeviceHandler;
-       unsigned int ii;
-       unsigned char byCount;
-       PWLAN_IE_SUPP_CH pIE = (PWLAN_IE_SUPP_CH) pbyIEs;
-       unsigned char *pbyChTupple;
-       unsigned char byLen = 0;
-
-       pIE->byElementID = WLAN_EID_SUPP_CH;
-       pIE->len = 0;
-       pbyChTupple = pIE->abyChannelTuple;
-       byLen = 2;
-       // lower band
-       byCount = 0;
-       if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[28] == true) {
-               for (ii = 28; ii < 36; ii += 2) {
-                       if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true)
-                               byCount++;
-               }
-
-               *pbyChTupple++ = 34;
-               *pbyChTupple++ = byCount;
-               byLen += 2;
-       } else if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[29] == true) {
-               for (ii = 29; ii < 36; ii += 2) {
-                       if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true)
-                               byCount++;
-               }
-
-               *pbyChTupple++ = 36;
-               *pbyChTupple++ = byCount;
-               byLen += 2;
-       }
-       // middle band
-       byCount = 0;
-       if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[36] == true) {
-               for (ii = 36; ii < 40; ii++) {
-                       if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true)
-                               byCount++;
-               }
-
-               *pbyChTupple++ = 52;
-               *pbyChTupple++ = byCount;
-               byLen += 2;
-       }
-       // higher band
-       byCount = 0;
-       if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[40] == true) {
-               for (ii = 40; ii < 51; ii++) {
-                       if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true)
-                               byCount++;
-               }
-
-               *pbyChTupple++ = 100;
-               *pbyChTupple++ = byCount;
-               byLen += 2;
-       } else if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[51] == true) {
-               for (ii = 51; ii < 56; ii++) {
-                       if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true)
-                               byCount++;
-               }
-
-               *pbyChTupple++ = 149;
-               *pbyChTupple++ = byCount;
-               byLen += 2;
-       }
-       pIE->len += (byLen - 2);
-       return byLen;
-}
-
-void set_country_IE(void *pDeviceHandler, void *pIE)
-{
-       struct vnt_private *pDevice = pDeviceHandler;
-       unsigned int ii;
-       PWLAN_IE_COUNTRY pIECountry = (PWLAN_IE_COUNTRY) pIE;
-
-       pIECountry->byElementID = WLAN_EID_COUNTRY;
-       pIECountry->len = 0;
-       pIECountry->abyCountryString[0] = ChannelRuleTab[pDevice->byZoneType].chCountryCode[0];
-       pIECountry->abyCountryString[1] = ChannelRuleTab[pDevice->byZoneType].chCountryCode[1];
-       pIECountry->abyCountryString[2] = ' ';
-       for (ii = CB_MAX_CHANNEL_24G; ii < CB_MAX_CHANNEL; ii++) {
-               if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) {
-                       pIECountry->abyCountryInfo[pIECountry->len++] = sChannelTbl[ii + 1].byChannelNumber;
-                       pIECountry->abyCountryInfo[pIECountry->len++] = 1;
-                       pIECountry->abyCountryInfo[pIECountry->len++] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
-               }
-       }
-       pIECountry->len += 3;
-}
-
-bool get_channel_map_info(void *pDeviceHandler, unsigned int uChannelIndex,
-                         unsigned char *pbyChannelNumber, unsigned char *pbyMap)
-{
-       if (uChannelIndex > CB_MAX_CHANNEL)
-               return false;
-
-       *pbyChannelNumber = sChannelTbl[uChannelIndex].byChannelNumber;
-       *pbyMap = sChannelTbl[uChannelIndex].byMAP;
-       return sChannelTbl[uChannelIndex].bValid;
-}
-
-void set_channel_map_info(void *pDeviceHandler, unsigned int uChannelIndex,
-                         unsigned char byMap)
-{
-       if (uChannelIndex > CB_MAX_CHANNEL)
-               return;
-
-       sChannelTbl[uChannelIndex].byMAP |= byMap;
-}
-
-void clear_channel_map_info(void *pDeviceHandler)
-{
-       unsigned int ii = 0;
-
-       for (ii = 1; ii <=  CB_MAX_CHANNEL; ii++)
-               sChannelTbl[ii].byMAP = 0;
-}
-
-unsigned char auto_channel_select(void *pDeviceHandler, CARD_PHY_TYPE ePHYType)
-{
-       unsigned int ii = 0;
-       unsigned char byOptionChannel = 0;
-       int aiWeight[CB_MAX_CHANNEL_24G + 1] = {-1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-
-       if (ePHYType == PHY_TYPE_11A) {
-               for (ii = CB_MAX_CHANNEL_24G + 1; ii <= CB_MAX_CHANNEL; ii++) {
-                       if (sChannelTbl[ii].bValid) {
-                               if (byOptionChannel == 0)
-                                       byOptionChannel = (unsigned char) ii;
-
-                               if (sChannelTbl[ii].byMAP == 0)
-                                       return (unsigned char) ii;
-                               else if (!(sChannelTbl[ii].byMAP & 0x08))
-                                       byOptionChannel = (unsigned char) ii;
-                       }
-               }
-       } else {
-               byOptionChannel = 0;
-               for (ii = 1; ii <= CB_MAX_CHANNEL_24G; ii++) {
-                       if (sChannelTbl[ii].bValid) {
-                               if (sChannelTbl[ii].byMAP == 0) {
-                                       aiWeight[ii] += 100;
-                               } else if (sChannelTbl[ii].byMAP & 0x01) {
-                                       if (ii > 3)
-                                               aiWeight[ii - 3] -= 10;
-
-                                       if (ii > 2)
-                                               aiWeight[ii - 2] -= 20;
-
-                                       if (ii > 1)
-                                               aiWeight[ii - 1] -= 40;
-
-                                       aiWeight[ii] -= 80;
-                                       if (ii < CB_MAX_CHANNEL_24G)
-                                               aiWeight[ii + 1] -= 40;
-
-                                       if (ii < (CB_MAX_CHANNEL_24G - 1))
-                                               aiWeight[ii+2] -= 20;
-
-                                       if (ii < (CB_MAX_CHANNEL_24G - 2))
-                                               aiWeight[ii+3] -= 10;
-                               }
-                       }
-               }
-               for (ii = 1; ii <= CB_MAX_CHANNEL_24G; ii++) {
-                       if (sChannelTbl[ii].bValid &&
-                           (aiWeight[ii] > aiWeight[byOptionChannel])) {
-                               byOptionChannel = (unsigned char) ii;
-                       }
-               }
-       }
-       return byOptionChannel;
-}
index 4f44c8a..4f4264e 100644 (file)
 #ifndef _CHANNEL_H_
 #define _CHANNEL_H_
 
-#include "ttype.h"
 #include "card.h"
 
-typedef struct tagSChannelTblElement {
-       unsigned char byChannelNumber;
-       unsigned int uFrequency;
-       bool bValid;
-       unsigned char byMAP;
-} SChannelTblElement, *PSChannelTblElement;
+void vnt_init_bands(struct vnt_private *);
 
-bool is_channel_valid(unsigned int CountryCode);
-void init_channel_table(void *pDeviceHandler);
-unsigned char get_channel_mapping(void *pDeviceHandler, unsigned char byChannelNumber, CARD_PHY_TYPE ePhyType);
-bool channel_get_list(unsigned int uCountryCodeIdx, unsigned char *pbyChannelTable);
-unsigned char get_channel_number(void *pDeviceHandler, unsigned char byChannelIndex);
 bool set_channel(void *pDeviceHandler, unsigned int uConnectionChannel);
-void set_country_info(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, void *pIE);
-unsigned char set_support_channels(void *pDeviceHandler, unsigned char *pbyIEs);
-void set_country_IE(void *pDeviceHandler, void *pIE);
-bool get_channel_map_info(void *pDeviceHandler, unsigned int uChannelIndex,
-                         unsigned char *pbyChannelNumber, unsigned char *pbyMap);
-void set_channel_map_info(void *pDeviceHandler, unsigned int uChannelIndex,
-                         unsigned char byMap);
-void clear_channel_map_info(void *pDeviceHandler);
-unsigned char auto_channel_select(void *pDeviceHandler, CARD_PHY_TYPE ePHYType);
 
 #endif /* _CHANNEL_H_ */
diff --git a/drivers/staging/vt6655/country.h b/drivers/staging/vt6655/country.h
deleted file mode 100644 (file)
index 2365fb1..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: country.h
- *
- * Purpose: Country Code information
- *
- * Author: Lucas Lin
- *
- * Date: Dec 23, 2004
- *
- */
-
-#ifndef __COUNTRY_H__
-#define __COUNTRY_H__
-
-#include "ttype.h"
-
-/************************************************************************
- * The definition here should be complied with the INF country order
- * Please check with VNWL.inf/VNWL64.inf/VNWL*.inf
- ************************************************************************/
-typedef enum _COUNTRY_CODE {
-       CCODE_FCC = 0,
-       CCODE_TELEC,
-       CCODE_ETSI,
-       CCODE_RESV3,
-       CCODE_RESV4,
-       CCODE_RESV5,
-       CCODE_RESV6,
-       CCODE_RESV7,
-       CCODE_RESV8,
-       CCODE_RESV9,
-       CCODE_RESVa,
-       CCODE_RESVb,
-       CCODE_RESVc,
-       CCODE_RESVd,
-       CCODE_RESVe,
-       CCODE_ALLBAND,
-       CCODE_ALBANIA,
-       CCODE_ALGERIA,
-       CCODE_ARGENTINA,
-       CCODE_ARMENIA,
-       CCODE_AUSTRALIA,
-       CCODE_AUSTRIA,
-       CCODE_AZERBAIJAN,
-       CCODE_BAHRAIN,
-       CCODE_BELARUS,
-       CCODE_BELGIUM,
-       CCODE_BELIZE,
-       CCODE_BOLIVIA,
-       CCODE_BRAZIL,
-       CCODE_BRUNEI_DARUSSALAM,
-       CCODE_BULGARIA,
-       CCODE_CANADA,
-       CCODE_CHILE,
-       CCODE_CHINA,
-       CCODE_COLOMBIA,
-       CCODE_COSTA_RICA,
-       CCODE_CROATIA,
-       CCODE_CYPRUS,
-       CCODE_CZECH,
-       CCODE_DENMARK,
-       CCODE_DOMINICAN_REPUBLIC,
-       CCODE_ECUADOR,
-       CCODE_EGYPT,
-       CCODE_EL_SALVADOR,
-       CCODE_ESTONIA,
-       CCODE_FINLAND,
-       CCODE_FRANCE,
-       CCODE_GERMANY,
-       CCODE_GREECE,
-       CCODE_GEORGIA,
-       CCODE_GUATEMALA,
-       CCODE_HONDURAS,
-       CCODE_HONG_KONG,
-       CCODE_HUNGARY,
-       CCODE_ICELAND,
-       CCODE_INDIA,
-       CCODE_INDONESIA,
-       CCODE_IRAN,
-       CCODE_IRELAND,
-       CCODE_ITALY,
-       CCODE_ISRAEL,
-       CCODE_JAPAN,
-       CCODE_JORDAN,
-       CCODE_KAZAKHSTAN,
-       CCODE_KUWAIT,
-       CCODE_LATVIA,
-       CCODE_LEBANON,
-       CCODE_LEICHTENSTEIN,
-       CCODE_LITHUANIA,
-       CCODE_LUXEMBURG,
-       CCODE_MACAU,
-       CCODE_MACEDONIA,
-       CCODE_MALTA,
-       CCODE_MALAYSIA,
-       CCODE_MEXICO,
-       CCODE_MONACO,
-       CCODE_MOROCCO,
-       CCODE_NETHERLANDS,
-       CCODE_NEW_ZEALAND,
-       CCODE_NORTH_KOREA,
-       CCODE_NORWAY,
-       CCODE_OMAN,
-       CCODE_PAKISTAN,
-       CCODE_PANAMA,
-       CCODE_PERU,
-       CCODE_PHILIPPINES,
-       CCODE_POLAND,
-       CCODE_PORTUGAL,
-       CCODE_PUERTO_RICO,
-       CCODE_QATAR,
-       CCODE_ROMANIA,
-       CCODE_RUSSIA,
-       CCODE_SAUDI_ARABIA,
-       CCODE_SINGAPORE,
-       CCODE_SLOVAKIA,
-       CCODE_SLOVENIA,
-       CCODE_SOUTH_AFRICA,
-       CCODE_SOUTH_KOREA,
-       CCODE_SPAIN,
-       CCODE_SWEDEN,
-       CCODE_SWITZERLAND,
-       CCODE_SYRIA,
-       CCODE_TAIWAN,
-       CCODE_THAILAND,
-       CCODE_TRINIDAD_TOBAGO,
-       CCODE_TUNISIA,
-       CCODE_TURKEY,
-       CCODE_UK,
-       CCODE_UKRAINE,
-       CCODE_UNITED_ARAB_EMIRATES,
-       CCODE_UNITED_STATES,
-       CCODE_URUGUAY,
-       CCODE_UZBEKISTAN,
-       CCODE_VENEZUELA,
-       CCODE_VIETNAM,
-       CCODE_YEMEN,
-       CCODE_ZIMBABWE,
-       CCODE_JAPAN_W52_W53,
-       CCODE_MAX
-} COUNTRY_CODE;
-
-#endif  /* __COUNTRY_H__ */
diff --git a/drivers/staging/vt6655/datarate.c b/drivers/staging/vt6655/datarate.c
deleted file mode 100644 (file)
index 52907a4..0000000
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: datarate.c
- *
- * Purpose: Handles the auto fallback & data rates functions
- *
- * Author: Lyndon Chen
- *
- * Date: July 17, 2002
- *
- * Functions:
- *      RATEvParseMaxRate - Parsing the highest basic & support rate in rate field of frame
- *      RATEvTxRateFallBack - Rate fallback Algorithm Implementaion
- *      RATEuSetIE- Set rate IE field.
- *
- * Revision History:
- *
- */
-
-#include "ttype.h"
-#include "tmacro.h"
-#include "mac.h"
-#include "80211mgr.h"
-#include "bssdb.h"
-#include "datarate.h"
-#include "card.h"
-#include "baseband.h"
-#include "srom.h"
-
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Classes  ----------------------------*/
-
-extern unsigned short TxRate_iwconfig; /* 2008-5-8 <add> by chester */
-/*---------------------  Static Variables  --------------------------*/
-static const unsigned char acbyIERate[MAX_RATE] = {
-0x02, 0x04, 0x0B, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C
-};
-
-#define AUTORATE_TXOK_CNT       0x0400
-#define AUTORATE_TXFAIL_CNT     0x0064
-#define AUTORATE_TIMEOUT        10
-
-/*---------------------  Static Functions  --------------------------*/
-
-void s_vResetCounter(
-       PKnownNodeDB psNodeDBTable
-);
-
-void
-s_vResetCounter(
-       PKnownNodeDB psNodeDBTable
-)
-{
-       unsigned char ii;
-
-       /* clear statistic counter for auto_rate */
-       for (ii = 0; ii <= MAX_RATE; ii++) {
-               psNodeDBTable->uTxOk[ii] = 0;
-               psNodeDBTable->uTxFail[ii] = 0;
-       }
-}
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-/*+
- *
- * Description:
- *      Get RateIdx from the value in SuppRates IE or ExtSuppRates IE
- *
- * Parameters:
- *  In:
- *      unsigned char - Rate value in SuppRates IE or ExtSuppRates IE
- *  Out:
- *      none
- *
- * Return Value: RateIdx
- *
- -*/
-unsigned char
-DATARATEbyGetRateIdx(
-       unsigned char byRate
-)
-{
-       unsigned char ii;
-
-       /* Erase basicRate flag. */
-       byRate = byRate & 0x7F;/* 0111 1111 */
-
-       for (ii = 0; ii < MAX_RATE; ii++) {
-               if (acbyIERate[ii] == byRate)
-                       return ii;
-       }
-       return 0;
-}
-
-/*+
- *
- * Routine Description:
- *      Rate fallback Algorithm Implementation
- *
- * Parameters:
- *  In:
- *      pDevice         - Pointer to the adapter
- *      psNodeDBTable   - Pointer to Node Data Base
- *  Out:
- *      none
- *
- * Return Value: none
- *
- -*/
-#define AUTORATE_TXCNT_THRESHOLD        20
-#define AUTORATE_INC_THRESHOLD          30
-
-/*+
- *
- * Description:
- *      Get RateIdx from the value in SuppRates IE or ExtSuppRates IE
- *
- * Parameters:
- *  In:
- *      unsigned char - Rate value in SuppRates IE or ExtSuppRates IE
- *  Out:
- *      none
- *
- * Return Value: RateIdx
- *
- -*/
-unsigned short
-wGetRateIdx(
-       unsigned char byRate
-)
-{
-       unsigned short ii;
-
-       /* Erase basicRate flag. */
-       byRate = byRate & 0x7F;/* 0111 1111 */
-
-       for (ii = 0; ii < MAX_RATE; ii++) {
-               if (acbyIERate[ii] == byRate)
-                       return ii;
-       }
-
-       return 0;
-}
-
-/*+
- *
- * Description:
- *      Parsing the highest basic & support rate in rate field of frame.
- *
- * Parameters:
- *  In:
- *      pDevice         - Pointer to the adapter
- *      pItemRates      - Pointer to Rate field defined in 802.11 spec.
- *      pItemExtRates      - Pointer to Extended Rate field defined in 802.11 spec.
- *  Out:
- *      pwMaxBasicRate  - Maximum Basic Rate
- *      pwMaxSuppRate   - Maximum Supported Rate
- *      pbyTopCCKRate   - Maximum Basic Rate in CCK mode
- *      pbyTopOFDMRate  - Maximum Basic Rate in OFDM mode
- *
- * Return Value: none
- *
- -*/
-void
-RATEvParseMaxRate(
-       void *pDeviceHandler,
-       PWLAN_IE_SUPP_RATES pItemRates,
-       PWLAN_IE_SUPP_RATES pItemExtRates,
-       bool bUpdateBasicRate,
-       unsigned short *pwMaxBasicRate,
-       unsigned short *pwMaxSuppRate,
-       unsigned short *pwSuppRate,
-       unsigned char *pbyTopCCKRate,
-       unsigned char *pbyTopOFDMRate
-)
-{
-       struct vnt_private *pDevice = pDeviceHandler;
-       unsigned int ii;
-       unsigned char byHighSuppRate = 0;
-       unsigned char byRate = 0;
-       unsigned short wOldBasicRate = pDevice->wBasicRate;
-       unsigned int uRateLen;
-
-       if (pItemRates == NULL)
-               return;
-
-       *pwSuppRate = 0;
-       uRateLen = pItemRates->len;
-
-       pr_debug("ParseMaxRate Len: %d\n", uRateLen);
-       if (pDevice->eCurrentPHYType != PHY_TYPE_11B) {
-               if (uRateLen > WLAN_RATES_MAXLEN)
-                       uRateLen = WLAN_RATES_MAXLEN;
-       } else {
-               if (uRateLen > WLAN_RATES_MAXLEN_11B)
-                       uRateLen = WLAN_RATES_MAXLEN_11B;
-       }
-
-       for (ii = 0; ii < uRateLen; ii++) {
-               byRate = (unsigned char)(pItemRates->abyRates[ii]);
-               if (WLAN_MGMT_IS_BASICRATE(byRate) && bUpdateBasicRate)  {
-                       /* Add to basic rate set, update pDevice->byTopCCKBasicRate and pDevice->byTopOFDMBasicRate */
-                       CARDbAddBasicRate((void *)pDevice, wGetRateIdx(byRate));
-                       pr_debug("ParseMaxRate AddBasicRate: %d\n",
-                                wGetRateIdx(byRate));
-               }
-               byRate = (unsigned char)(pItemRates->abyRates[ii]&0x7F);
-               if (byHighSuppRate == 0)
-                       byHighSuppRate = byRate;
-               if (byRate > byHighSuppRate)
-                       byHighSuppRate = byRate;
-               *pwSuppRate |= (1<<wGetRateIdx(byRate));
-       }
-       if ((pItemExtRates != NULL) && (pItemExtRates->byElementID == WLAN_EID_EXTSUPP_RATES) &&
-           (pDevice->eCurrentPHYType != PHY_TYPE_11B)) {
-               unsigned int uExtRateLen = pItemExtRates->len;
-
-               if (uExtRateLen > WLAN_RATES_MAXLEN)
-                       uExtRateLen = WLAN_RATES_MAXLEN;
-
-               for (ii = 0; ii < uExtRateLen; ii++) {
-                       byRate = (unsigned char)(pItemExtRates->abyRates[ii]);
-                       /* select highest basic rate */
-                       if (WLAN_MGMT_IS_BASICRATE(pItemExtRates->abyRates[ii])) {
-                               /* Add to basic rate set, update pDevice->byTopCCKBasicRate and pDevice->byTopOFDMBasicRate */
-                               CARDbAddBasicRate((void *)pDevice, wGetRateIdx(byRate));
-                               pr_debug("ParseMaxRate AddBasicRate: %d\n",
-                                        wGetRateIdx(byRate));
-                       }
-                       byRate = (unsigned char)(pItemExtRates->abyRates[ii]&0x7F);
-                       if (byHighSuppRate == 0)
-                               byHighSuppRate = byRate;
-                       if (byRate > byHighSuppRate)
-                               byHighSuppRate = byRate;
-                       *pwSuppRate |= (1<<wGetRateIdx(byRate));
-               }
-       }
-
-       if ((pDevice->byPacketType == PK_TYPE_11GB) && CARDbIsOFDMinBasicRate((void *)pDevice))
-               pDevice->byPacketType = PK_TYPE_11GA;
-
-       *pbyTopCCKRate = pDevice->byTopCCKBasicRate;
-       *pbyTopOFDMRate = pDevice->byTopOFDMBasicRate;
-       *pwMaxSuppRate = wGetRateIdx(byHighSuppRate);
-       if ((pDevice->byPacketType == PK_TYPE_11B) || (pDevice->byPacketType == PK_TYPE_11GB))
-               *pwMaxBasicRate = pDevice->byTopCCKBasicRate;
-       else
-               *pwMaxBasicRate = pDevice->byTopOFDMBasicRate;
-       if (wOldBasicRate != pDevice->wBasicRate)
-               CARDvSetRSPINF((void *)pDevice, pDevice->eCurrentPHYType);
-
-       pr_debug("Exit ParseMaxRate\n");
-}
-
-/*+
- *
- * Routine Description:
- *      Rate fallback Algorithm Implementaion
- *
- * Parameters:
- *  In:
- *      pDevice         - Pointer to the adapter
- *      psNodeDBTable   - Pointer to Node Data Base
- *  Out:
- *      none
- *
- * Return Value: none
- *
- -*/
-#define AUTORATE_TXCNT_THRESHOLD        20
-#define AUTORATE_INC_THRESHOLD          30
-
-void
-RATEvTxRateFallBack(
-       void *pDeviceHandler,
-       PKnownNodeDB psNodeDBTable
-)
-{
-       struct vnt_private *pDevice = pDeviceHandler;
-       unsigned short wIdxDownRate = 0;
-       unsigned int ii;
-       bool bAutoRate[MAX_RATE]    = {true, true, true, true, false, false, true, true, true, true, true, true};
-       unsigned long dwThroughputTbl[MAX_RATE] = {10, 20, 55, 110, 60, 90, 120, 180, 240, 360, 480, 540};
-       unsigned long dwThroughput = 0;
-       unsigned short wIdxUpRate = 0;
-       unsigned long dwTxDiff = 0;
-
-       if (pDevice->pMgmt->eScanState != WMAC_NO_SCANNING)
-               /* Don't do Fallback when scanning Channel */
-               return;
-
-       psNodeDBTable->uTimeCount++;
-
-       if (psNodeDBTable->uTxFail[MAX_RATE] > psNodeDBTable->uTxOk[MAX_RATE])
-               dwTxDiff = psNodeDBTable->uTxFail[MAX_RATE] - psNodeDBTable->uTxOk[MAX_RATE];
-
-       if ((psNodeDBTable->uTxOk[MAX_RATE] < AUTORATE_TXOK_CNT) &&
-           (dwTxDiff < AUTORATE_TXFAIL_CNT) &&
-           (psNodeDBTable->uTimeCount < AUTORATE_TIMEOUT)) {
-               return;
-       }
-
-       if (psNodeDBTable->uTimeCount >= AUTORATE_TIMEOUT)
-               psNodeDBTable->uTimeCount = 0;
-
-       for (ii = 0; ii < MAX_RATE; ii++) {
-               if (psNodeDBTable->wSuppRate & (0x0001<<ii)) {
-                       if (bAutoRate[ii])
-                               wIdxUpRate = (unsigned short) ii;
-
-               } else {
-                       bAutoRate[ii] = false;
-               }
-       }
-
-       for (ii = 0; ii <= psNodeDBTable->wTxDataRate; ii++) {
-               if ((psNodeDBTable->uTxOk[ii] != 0) ||
-                   (psNodeDBTable->uTxFail[ii] != 0)) {
-                       dwThroughputTbl[ii] *= psNodeDBTable->uTxOk[ii];
-                       if (ii < RATE_11M)
-                               psNodeDBTable->uTxFail[ii] *= 4;
-
-                       dwThroughputTbl[ii] /= (psNodeDBTable->uTxOk[ii] + psNodeDBTable->uTxFail[ii]);
-               }
-       }
-       dwThroughput = dwThroughputTbl[psNodeDBTable->wTxDataRate];
-
-       wIdxDownRate = psNodeDBTable->wTxDataRate;
-       for (ii = psNodeDBTable->wTxDataRate; ii > 0;) {
-               ii--;
-               if ((dwThroughputTbl[ii] > dwThroughput) && bAutoRate[ii]) {
-                       dwThroughput = dwThroughputTbl[ii];
-                       wIdxDownRate = (unsigned short) ii;
-               }
-       }
-       psNodeDBTable->wTxDataRate = wIdxDownRate;
-       if (psNodeDBTable->uTxOk[MAX_RATE]) {
-               if (psNodeDBTable->uTxOk[MAX_RATE] >
-                   (psNodeDBTable->uTxFail[MAX_RATE] * 4)) {
-                       psNodeDBTable->wTxDataRate = wIdxUpRate;
-               }
-       } else {
-               /* adhoc, if uTxOk =0 & uTxFail = 0 */
-               if (psNodeDBTable->uTxFail[MAX_RATE] == 0)
-                       psNodeDBTable->wTxDataRate = wIdxUpRate;
-       }
-
-       /* 2008-5-8 <add> by chester */
-       TxRate_iwconfig = psNodeDBTable->wTxDataRate;
-       s_vResetCounter(psNodeDBTable);
-}
-
-/*+
- *
- * Description:
- *    This routine is used to assemble available Rate IE.
- *
- * Parameters:
- *  In:
- *    pDevice
- *  Out:
- *
- * Return Value: None
- *
- -*/
-unsigned char
-RATEuSetIE(
-       PWLAN_IE_SUPP_RATES pSrcRates,
-       PWLAN_IE_SUPP_RATES pDstRates,
-       unsigned int uRateLen
-)
-{
-       unsigned int ii, uu, uRateCnt = 0;
-
-       if ((pSrcRates == NULL) || (pDstRates == NULL))
-               return 0;
-
-       if (pSrcRates->len == 0)
-               return 0;
-
-       for (ii = 0; ii < uRateLen; ii++) {
-               for (uu = 0; uu < pSrcRates->len; uu++) {
-                       if ((pSrcRates->abyRates[uu] & 0x7F) == acbyIERate[ii]) {
-                               pDstRates->abyRates[uRateCnt++] = pSrcRates->abyRates[uu];
-                               break;
-                       }
-               }
-       }
-       return (unsigned char)uRateCnt;
-}
diff --git a/drivers/staging/vt6655/datarate.h b/drivers/staging/vt6655/datarate.h
deleted file mode 100644 (file)
index 0509c4f..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: datarate.h
- *
- * Purpose: Handles the auto fallback & data rates functions
- *
- * Author: Lyndon Chen
- *
- * Date: July 16, 2002
- *
- */
-#ifndef __DATARATE_H__
-#define __DATARATE_H__
-
-#define FALLBACK_PKT_COLLECT_TR_H  50
-#define FALLBACK_PKT_COLLECT_TR_L  10
-#define FALLBACK_POLL_SECOND       5
-#define FALLBACK_RECOVER_SECOND    30
-#define FALLBACK_THRESHOLD         15
-#define UPGRADE_THRESHOLD          5
-#define UPGRADE_CNT_THRD           3
-#define RETRY_TIMES_THRD_H         2
-#define RETRY_TIMES_THRD_L         1
-
-void
-RATEvParseMaxRate(
-       void *pDeviceHandler,
-       PWLAN_IE_SUPP_RATES pItemRates,
-       PWLAN_IE_SUPP_RATES pItemExtRates,
-       bool bUpdateBasicRate,
-       unsigned short *pwMaxBasicRate,
-       unsigned short *pwMaxSuppRate,
-       unsigned short *pwSuppRate,
-       unsigned char *pbyTopCCKRate,
-       unsigned char *pbyTopOFDMRate
-);
-
-void
-RATEvTxRateFallBack(
-       void *pDeviceHandler,
-       PKnownNodeDB psNodeDBTable
-);
-
-unsigned char
-RATEuSetIE(
-       PWLAN_IE_SUPP_RATES pSrcRates,
-       PWLAN_IE_SUPP_RATES pDstRates,
-       unsigned int uRateLen
-);
-
-unsigned short
-wGetRateIdx(
-       unsigned char byRate
-);
-
-unsigned char
-DATARATEbyGetRateIdx(
-       unsigned char byRate
-);
-
-#endif //__DATARATE_H__
index 5a2bbd2..758eeb2 100644 (file)
 #include <linux/types.h>
 #include <linux/mm.h>
 #include "linux/ieee80211.h"
-#include "ttype.h"
-#include "tether.h"
 
 #define B_OWNED_BY_CHIP     1
 #define B_OWNED_BY_HOST     0
 
-//
-// Bits in the RSR register
-//
+/* Bits in the RSR register */
 #define RSR_ADDRBROAD       0x80
 #define RSR_ADDRMULTI       0x40
 #define RSR_ADDRUNI         0x00
 #define RSR_IVLDTYP         0x20
-#define RSR_IVLDLEN         0x10        // invalid len (> 2312 byte)
+#define RSR_IVLDLEN         0x10        /* invalid len (> 2312 byte) */
 #define RSR_BSSIDOK         0x08
 #define RSR_CRCOK           0x04
 #define RSR_BCNSSIDOK       0x02
 #define RSR_ADDROK          0x01
 
-//
-// Bits in the new RSR register
-//
+/* Bits in the new RSR register */
 #define NEWRSR_DECRYPTOK    0x10
 #define NEWRSR_CFPIND       0x08
 #define NEWRSR_HWUTSF       0x04
 #define NEWRSR_BCNHITAID    0x02
 #define NEWRSR_BCNHITAID0   0x01
 
-//
-// Bits in the TSR0 register
-//
+/* Bits in the TSR0 register */
 #define TSR0_PWRSTS1_2      0xC0
 #define TSR0_PWRSTS7        0x20
 #define TSR0_NCR            0x1F
 
-//
-// Bits in the TSR1 register
-//
+/* Bits in the TSR1 register */
 #define TSR1_TERR           0x80
 #define TSR1_PWRSTS4_6      0x70
 #define TSR1_RETRYTMO       0x08
 #define TSR1_PWRSTS3        0x02
 #define ACK_DATA            0x01
 
-//
-// Bits in the TCR register
-//
-#define EDMSDU              0x04        // end of sdu
-#define TCR_EDP             0x02        // end of packet
-#define TCR_STP             0x01        // start of packet
+/* Bits in the TCR register */
+#define EDMSDU              0x04        /* end of sdu */
+#define TCR_EDP             0x02        /* end of packet */
+#define TCR_STP             0x01        /* start of packet */
 
-// max transmit or receive buffer size
+/* max transmit or receive buffer size */
 #define CB_MAX_BUF_SIZE     2900U
-                                       // NOTE: must be multiple of 4
+                                       /* NOTE: must be multiple of 4 */
 #define CB_MAX_TX_BUF_SIZE          CB_MAX_BUF_SIZE
 #define CB_MAX_RX_BUF_SIZE_NORMAL   CB_MAX_BUF_SIZE
 
 #define CB_MIN_TX_DESC      16
 
 #define CB_MAX_RECEIVED_PACKETS     16
-                                       // limit our receive routine to indicating
-                                       // this many at a time for 2 reasons:
-                                       // 1. driver flow control to protocol layer
-                                       // 2. limit the time used in ISR routine
+                               /*
+                                * limit our receive routine to indicating
+                                * this many at a time for 2 reasons:
+                                * 1. driver flow control to protocol layer
+                                * 2. limit the time used in ISR routine
+                                */
 
 #define CB_EXTRA_RD_NUM     32
 #define CB_RD_NUM           32
 #define CB_TD_NUM           32
 
-// max number of physical segments
-// in a single NDIS packet. Above this threshold, the packet
-// is copied into a single physically contiguous buffer
+/*
+ * max number of physical segments in a single NDIS packet. Above this
+ * threshold, the packet is copied into a single physically contiguous buffer
+ */
 #define CB_MAX_SEGMENT      4
 
 #define CB_MIN_MAP_REG_NUM  4
 
 #define CB_PROTOCOL_RESERVED_SECTION    16
 
-// if retrys excess 15 times , tx will abort, and
-// if tx fifo underflow, tx will fail
-// we should try to resend it
+/*
+ * if retrys excess 15 times , tx will abort, and if tx fifo underflow,
+ * tx will fail, we should try to resend it
+ */
 #define CB_MAX_TX_ABORT_RETRY   3
 
-#ifdef __BIG_ENDIAN
-
-// WMAC definition FIFO Control
-#define FIFOCTL_AUTO_FB_1   0x0010
-#define FIFOCTL_AUTO_FB_0   0x0008
-#define FIFOCTL_GRPACK      0x0004
-#define FIFOCTL_11GA        0x0003
-#define FIFOCTL_11GB        0x0002
-#define FIFOCTL_11B         0x0001
-#define FIFOCTL_11A         0x0000
-#define FIFOCTL_RTS         0x8000
-#define FIFOCTL_ISDMA0      0x4000
-#define FIFOCTL_GENINT      0x2000
-#define FIFOCTL_TMOEN       0x1000
-#define FIFOCTL_LRETRY      0x0800
-#define FIFOCTL_CRCDIS      0x0400
-#define FIFOCTL_NEEDACK     0x0200
-#define FIFOCTL_LHEAD       0x0100
-
-//WMAC definition Frag Control
-#define FRAGCTL_AES         0x0003
-#define FRAGCTL_TKIP        0x0002
-#define FRAGCTL_LEGACY      0x0001
-#define FRAGCTL_NONENCRYPT  0x0000
-#define FRAGCTL_ENDFRAG     0x0300
-#define FRAGCTL_MIDFRAG     0x0200
-#define FRAGCTL_STAFRAG     0x0100
-#define FRAGCTL_NONFRAG     0x0000
-
-#else
-
+/* WMAC definition FIFO Control */
 #define FIFOCTL_AUTO_FB_1   0x1000
 #define FIFOCTL_AUTO_FB_0   0x0800
 #define FIFOCTL_GRPACK      0x0400
 #define FIFOCTL_NEEDACK     0x0002
 #define FIFOCTL_LHEAD       0x0001
 
-//WMAC definition Frag Control
+/* WMAC definition Frag Control */
 #define FRAGCTL_AES         0x0300
 #define FRAGCTL_TKIP        0x0200
 #define FRAGCTL_LEGACY      0x0100
 #define FRAGCTL_STAFRAG     0x0001
 #define FRAGCTL_NONFRAG     0x0000
 
-#endif
-
 #define TYPE_TXDMA0     0
 #define TYPE_AC0DMA     1
 #define TYPE_ATIMDMA    2
 #define TYPE_RXDMA1     1
 #define TYPE_MAXRD      2
 
-// TD_INFO flags control bit
-#define TD_FLAGS_NETIF_SKB               0x01       // check if need release skb
-#define TD_FLAGS_PRIV_SKB                0x02       // check if called from private skb(hostap)
-#define TD_FLAGS_PS_RETRY                0x04       // check if PS STA frame re-transmit
+/* TD_INFO flags control bit */
+#define TD_FLAGS_NETIF_SKB      0x01    /* check if need release skb */
+#define TD_FLAGS_PRIV_SKB       0x02    /* check if called from private skb (hostap) */
+#define TD_FLAGS_PS_RETRY       0x04    /* check if PS STA frame re-transmit */
 
-// ref_sk_buff is used for mapping the skb structure between pre-built driver-obj & running kernel.
-// Since different kernel version (2.4x) may change skb structure, i.e. pre-built driver-obj
-// may link to older skb that leads error.
+/*
+ * ref_sk_buff is used for mapping the skb structure between pre-built
+ * driver-obj & running kernel. Since different kernel version (2.4x) may
+ * change skb structure, i.e. pre-built driver-obj may link to older skb that
+ * leads error.
+ */
 
 typedef struct tagDEVICE_RD_INFO {
        struct sk_buff *skb;
@@ -242,9 +205,7 @@ typedef struct tagRDES1 {
 } __attribute__ ((__packed__))
 SRDES1;
 
-//
-// Rx descriptor
-//
+/* Rx descriptor*/
 typedef struct tagSRxDesc {
        volatile SRDES0 m_rd0RD0;
        volatile SRDES1 m_rd1RD1;
@@ -292,6 +253,7 @@ typedef struct tagTDES1 {
 STDES1;
 
 typedef struct tagDEVICE_TD_INFO {
+       void *mic_hdr;
        struct sk_buff *skb;
        unsigned char *buf;
        dma_addr_t          skb_dma;
@@ -302,9 +264,7 @@ typedef struct tagDEVICE_TD_INFO {
        unsigned char byFlags;
 } DEVICE_TD_INFO,    *PDEVICE_TD_INFO;
 
-//
-// transmit descriptor
-//
+/* transmit descriptor */
 typedef struct tagSTxDesc {
        volatile    STDES0  m_td0TD0;
        volatile    STDES1  m_td1TD1;
@@ -319,8 +279,8 @@ typedef const STxDesc *PCSTxDesc;
 typedef struct tagSTxSyncDesc {
        volatile    STDES0  m_td0TD0;
        volatile    STDES1  m_td1TD1;
-       volatile    u32 buff_addr; // pointer to logical buffer
-       volatile    u32 next_desc; // pointer to next logical descriptor
+       volatile    u32 buff_addr; /* pointer to logical buffer */
+       volatile    u32 next_desc; /* pointer to next logical descriptor */
        volatile    unsigned short m_wFIFOCtl;
        volatile    unsigned short m_wTimeStamp;
        struct tagSTxSyncDesc *next __aligned(8);
@@ -329,9 +289,7 @@ typedef struct tagSTxSyncDesc {
 STxSyncDesc, *PSTxSyncDesc;
 typedef const STxSyncDesc *PCSTxSyncDesc;
 
-//
-// RsvTime buffer header
-//
+/* RsvTime buffer header */
 typedef struct tagSRrvTime_atim {
        unsigned short wCTSTxRrvTime_ba;
        unsigned short wTxRrvTime_a;
@@ -352,9 +310,7 @@ union vnt_phy_field_swap {
        u32 field_write;
 };
 
-//
-// Tx FIFO header
-//
+/* Tx FIFO header */
 typedef struct tagSTxBufHead {
        u32 adwTxKey[4];
        unsigned short wFIFOCtl;
@@ -392,4 +348,4 @@ typedef struct tagSKeyEntry {
 } __attribute__ ((__packed__))
 SKeyEntry;
 
-#endif // __DESC_H__
+#endif /* __DESC_H__ */
index ddd356a..93d2ccb 100644 (file)
 #include <linux/io.h>
 #include <linux/if.h>
 #include <linux/crc32.h>
-//#include <linux/config.h>
 #include <linux/uaccess.h>
 #include <linux/proc_fs.h>
 #include <linux/inetdevice.h>
 #include <linux/reboot.h>
 #include <linux/ethtool.h>
 /* Include Wireless Extension definition and check version - Jean II */
+#include <net/mac80211.h>
 #include <linux/wireless.h>
-#include <net/iw_handler.h>    // New driver API
+#include <net/iw_handler.h>    /* New driver API */
 
-//2008-0409-07, <Add> by Einsn Liu
 #ifndef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
 #define WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
 #endif
 
-//
-// device specific
-//
+/* device specific */
 
 #include "device_cfg.h"
-#include "ttype.h"
-#include "80211hdr.h"
-#include "tether.h"
-#include "wmgr.h"
-#include "wcmd.h"
+#include "card.h"
 #include "mib.h"
 #include "srom.h"
-#include "rc4.h"
 #include "desc.h"
 #include "key.h"
 #include "mac.h"
 
 /*---------------------  Export Definitions -------------------------*/
 
+#define RATE_1M                0
+#define RATE_2M                1
+#define RATE_5M                2
+#define RATE_11M       3
+#define RATE_6M                4
+#define RATE_9M                5
+#define RATE_12M       6
+#define RATE_18M       7
+#define RATE_24M       8
+#define RATE_36M       9
+#define RATE_48M       10
+#define RATE_54M       11
+#define RATE_AUTO      12
+#define MAX_RATE       12
+
 #define MAC_MAX_CONTEXT_REG     (256+128)
 
 #define MAX_MULTICAST_ADDRESS_NUM       32
 #define FB_RATE0                0
 #define FB_RATE1                1
 
-// Antenna Mode
+/* Antenna Mode */
 #define ANT_A                   0
 #define ANT_B                   1
 #define ANT_DIVERSITY           2
 #define RUN_AT(x)                       (jiffies+(x))
 #endif
 
-// DMA related
+#define MAKE_BEACON_RESERVED   10  /* (us) */
+
+/* DMA related */
 #define RESERV_AC0DMA                   4
 
-// BUILD OBJ mode
+/* BUILD OBJ mode */
 
 #define        AVAIL_TD(p, q)  ((p)->sOpts.nTxDescs[(q)] - ((p)->iTDUsed[(q)]))
 
 #define        NUM                             64
 
-#define PRIVATE_Message                 0
-
-/*---------------------  Export Types  ------------------------------*/
-
-#define PRINT_K(p, args...)            \
-do {                                   \
-       if (PRIVATE_Message)            \
-               printk(p, ##args);      \
-} while (0)
-
-//0:11A 1:11B 2:11G
+/* 0:11A 1:11B 2:11G */
 typedef enum _VIA_BB_TYPE
 {
        BB_TYPE_11A = 0,
@@ -156,7 +155,7 @@ typedef enum _VIA_BB_TYPE
        BB_TYPE_11G
 } VIA_BB_TYPE, *PVIA_BB_TYPE;
 
-//0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate)
+/* 0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate) */
 typedef enum _VIA_PKT_TYPE
 {
        PK_TYPE_11A = 0,
@@ -165,84 +164,6 @@ typedef enum _VIA_PKT_TYPE
        PK_TYPE_11GA
 } VIA_PKT_TYPE, *PVIA_PKT_TYPE;
 
-typedef enum __device_msg_level {
-       MSG_LEVEL_ERR = 0,            //Errors that will cause abnormal operation.
-       MSG_LEVEL_NOTICE = 1,         //Some errors need users to be notified.
-       MSG_LEVEL_INFO = 2,           //Normal message.
-       MSG_LEVEL_VERBOSE = 3,        //Will report all trival errors.
-       MSG_LEVEL_DEBUG = 4           //Only for debug purpose.
-} DEVICE_MSG_LEVEL, *PDEVICE_MSG_LEVEL;
-
-//++ NDIS related
-
-#define MAX_BSSIDINFO_4_PMKID   16
-#define MAX_PMKIDLIST           5
-//Flags for PMKID Candidate list structure
-#define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED    0x01
-
-// PMKID Structures
-typedef unsigned char NDIS_802_11_PMKID_VALUE[16];
-
-typedef enum _NDIS_802_11_WEP_STATUS {
-       Ndis802_11WEPEnabled,
-       Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
-       Ndis802_11WEPDisabled,
-       Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
-       Ndis802_11WEPKeyAbsent,
-       Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
-       Ndis802_11WEPNotSupported,
-       Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
-       Ndis802_11Encryption2Enabled,
-       Ndis802_11Encryption2KeyAbsent,
-       Ndis802_11Encryption3Enabled,
-       Ndis802_11Encryption3KeyAbsent
-} NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
-       NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
-
-typedef enum _NDIS_802_11_STATUS_TYPE {
-       Ndis802_11StatusType_Authentication,
-       Ndis802_11StatusType_MediaStreamMode,
-       Ndis802_11StatusType_PMKID_CandidateList,
-       Ndis802_11StatusTypeMax    // not a real type, defined as an upper bound
-} NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
-
-//Added new types for PMKID Candidate lists.
-struct pmkid_candidate {
-       NDIS_802_11_MAC_ADDRESS BSSID;
-       unsigned long Flags;
-};
-
-typedef struct _BSSID_INFO {
-       NDIS_802_11_MAC_ADDRESS BSSID;
-       NDIS_802_11_PMKID_VALUE PMKID;
-} BSSID_INFO, *PBSSID_INFO;
-
-typedef struct tagSPMKID {
-       unsigned long Length;
-       unsigned long BSSIDInfoCount;
-       BSSID_INFO BSSIDInfo[MAX_BSSIDINFO_4_PMKID];
-} SPMKID, *PSPMKID;
-
-typedef struct tagSPMKIDCandidateEvent {
-       NDIS_802_11_STATUS_TYPE     StatusType;
-       unsigned long Version;       // Version of the structure
-       unsigned long NumCandidates; // No. of pmkid candidates
-       struct pmkid_candidate CandidateList[MAX_PMKIDLIST];
-} SPMKIDCandidateEvent, *PSPMKIDCandidateEvent;
-
-//--
-
-//++ 802.11h related
-#define MAX_QUIET_COUNT     8
-
-typedef struct tagSQuietControl {
-       bool bEnable;
-       unsigned long dwStartTime;
-       unsigned char byPeriod;
-       unsigned short wDuration;
-} SQuietControl, *PSQuietControl;
-
-//--
 typedef struct __chip_info_tbl {
        CHIP_TYPE   chip_id;
        char *name;
@@ -256,22 +177,8 @@ typedef enum {
        OWNED_BY_NIC = 1
 } DEVICE_OWNER_TYPE, *PDEVICE_OWNER_TYPE;
 
-// The receive duplicate detection cache entry
-typedef struct tagSCacheEntry {
-       unsigned short wFmSequence;
-       unsigned char abyAddr2[ETH_ALEN];
-} SCacheEntry, *PSCacheEntry;
-
-typedef struct tagSCache {
-/* The receive cache is updated circularly.  The next entry to be written is
- * indexed by the "InPtr".
- */
-       unsigned int uInPtr;         // Place to use next
-       SCacheEntry     asCacheEntry[DUPLICATE_RX_CACHE_LENGTH];
-} SCache, *PSCache;
-
 #define CB_MAX_RX_FRAG                 64
-// DeFragment Control Block, used for collecting fragments prior to reassembly
+/* DeFragment Control Block, used for collecting fragments prior to reassembly */
 typedef struct tagSDeFragControlBlock {
        unsigned short wSequence;
        unsigned short wFragNum;
@@ -283,7 +190,7 @@ typedef struct tagSDeFragControlBlock {
        bool bInUse;
 } SDeFragControlBlock, *PSDeFragControlBlock;
 
-//flags for options
+/* flags for options */
 #define     DEVICE_FLAGS_IP_ALIGN        0x00000001UL
 #define     DEVICE_FLAGS_PREAMBLE_TYPE   0x00000002UL
 #define     DEVICE_FLAGS_OP_MODE         0x00000004UL
@@ -291,15 +198,15 @@ typedef struct tagSDeFragControlBlock {
 #define                DEVICE_FLAGS_80211h_MODE         0x00000010UL
 #define                DEVICE_FLAGS_DiversityANT        0x00000020UL
 
-//flags for driver status
+/* flags for driver status */
 #define     DEVICE_FLAGS_OPENED          0x00010000UL
 #define     DEVICE_FLAGS_WOL_ENABLED     0x00080000UL
-//flags for capabilities
+/* flags for capabilities */
 #define     DEVICE_FLAGS_TX_ALIGN        0x01000000UL
 #define     DEVICE_FLAGS_HAVE_CAM        0x02000000UL
 #define     DEVICE_FLAGS_FLOW_CTRL       0x04000000UL
 
-//flags for MII status
+/* flags for MII status */
 #define     DEVICE_LINK_FAIL             0x00000001UL
 #define     DEVICE_SPEED_10              0x00000002UL
 #define     DEVICE_SPEED_100             0x00000004UL
@@ -307,15 +214,15 @@ typedef struct tagSDeFragControlBlock {
 #define     DEVICE_DUPLEX_FULL           0x00000010UL
 #define     DEVICE_AUTONEG_ENABLE        0x00000020UL
 #define     DEVICE_FORCED_BY_EEPROM      0x00000040UL
-//for device_set_media_duplex
+/* for device_set_media_duplex */
 #define     DEVICE_LINK_CHANGE           0x00000001UL
 
 typedef struct __device_opt {
-       int         nRxDescs0;    //Number of RX descriptors0
-       int         nRxDescs1;    //Number of RX descriptors1
-       int         nTxDescs[2];  //Number of TX descriptors 0, 1
-       int         int_works;    //interrupt limits
-       int         rts_thresh;   //rts threshold
+       int         nRxDescs0;          /* Number of RX descriptors0 */
+       int         nRxDescs1;          /* Number of RX descriptors1 */
+       int         nTxDescs[2];        /* Number of TX descriptors 0, 1 */
+       int         int_works;          /* interrupt limits */
+       int         rts_thresh;         /* rts threshold */
        int         frag_thresh;
        int         data_rate;
        int         channel_num;
@@ -327,11 +234,16 @@ typedef struct __device_opt {
 
 struct vnt_private {
        struct pci_dev *pcid;
-
-// netdev
-       struct net_device *dev;
-
-//dma addr, rx/tx pool
+       /* mac80211 */
+       struct ieee80211_hw *hw;
+       struct ieee80211_vif *vif;
+       unsigned long key_entry_inuse;
+       u32 basic_rates;
+       u16 current_aid;
+       int mc_list_count;
+       u8 mac_hw;
+
+/* dma addr, rx/tx pool */
        dma_addr_t                  pool_dma;
        dma_addr_t                  rd0_pool_dma;
        dma_addr_t                  rd1_pool_dma;
@@ -356,9 +268,12 @@ struct vnt_private {
        u32                         io_size;
 
        unsigned char byRevId;
+       unsigned char byRxMode;
        unsigned short SubSystemID;
        unsigned short SubVendorID;
 
+       spinlock_t                  lock;
+
        int                         nTxQueues;
        volatile int                iTDUsed[TYPE_MAXTD];
 
@@ -371,7 +286,6 @@ struct vnt_private {
        volatile PSRxDesc           aRD0Ring;
        volatile PSRxDesc           aRD1Ring;
        volatile PSRxDesc           pCurrRD[TYPE_MAXRD];
-       SCache                      sDupRxCache;
 
        SDeFragControlBlock         sRxDFCB[CB_MAX_RX_FRAG];
        unsigned int    cbDFCB;
@@ -383,18 +297,12 @@ struct vnt_private {
        u32                         flags;
 
        u32                         rx_buf_sz;
+       u8 rx_rate;
        int                         multicast_limit;
-       unsigned char byRxMode;
-
-       spinlock_t                  lock;
-
-       pid_t                   MLMEThr_pid;
-       struct completion       notify;
-       struct semaphore        mlme_semaphore;
 
        u32                         rx_bytes;
 
-       // Version control
+       /* Version control */
        unsigned char byLocalID;
        unsigned char byRFType;
 
@@ -402,20 +310,15 @@ struct vnt_private {
        unsigned char byZoneType;
        bool bZoneRegExist;
        unsigned char byOriginalZonetype;
-       unsigned char abyMacContext[MAC_MAX_CONTEXT_REG];
-       bool bLinkPass;          // link status: OK or fail
+
        unsigned char abyCurrentNetAddr[ETH_ALEN];
+       bool bLinkPass;          /* link status: OK or fail */
 
-       // Adapter statistics
+       /* Adapter statistics */
        SStatCounter                scStatistic;
-       // 802.11 counter
+       /* 802.11 counter */
        SDot11Counters              s802_11Counter;
 
-       // 802.11 management
-       PSMgmtObject                pMgmt;
-       SMgmtObject                 sMgmtObj;
-
-       // 802.11 MAC specific
        unsigned int    uCurrRSSI;
        unsigned char byCurrSQ;
 
@@ -427,22 +330,26 @@ struct vnt_private {
        bool bTxRxAntInv;
 
        unsigned char *pbyTmpBuff;
-       unsigned int    uSIFS;    //Current SIFS
-       unsigned int    uDIFS;    //Current DIFS
-       unsigned int    uEIFS;    //Current EIFS
-       unsigned int    uSlot;    //Current SlotTime
-       unsigned int    uCwMin;   //Current CwMin
-       unsigned int    uCwMax;   //CwMax is fixed on 1023.
-       // PHY parameter
+       unsigned int    uSIFS;    /* Current SIFS */
+       unsigned int    uDIFS;    /* Current DIFS */
+       unsigned int    uEIFS;    /* Current EIFS */
+       unsigned int    uSlot;    /* Current SlotTime */
+       unsigned int    uCwMin;   /* Current CwMin */
+       unsigned int    uCwMax;   /* CwMax is fixed on 1023. */
+       /* PHY parameter */
        unsigned char bySIFS;
        unsigned char byDIFS;
        unsigned char byEIFS;
        unsigned char bySlot;
        unsigned char byCWMaxMin;
-       CARD_PHY_TYPE               eCurrentPHYType;
-
-       VIA_BB_TYPE                 byBBType; //0: 11A, 1:11B, 2:11G
-       VIA_PKT_TYPE                byPacketType; //0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate)
+       CARD_PHY_TYPE           eCurrentPHYType;
+
+       VIA_BB_TYPE             byBBType; /* 0:11A, 1:11B, 2:11G */
+       VIA_PKT_TYPE            byPacketType; /*
+                                              * 0:11a,1:11b,2:11gb (only CCK
+                                              * in BasicRate), 3:11ga (OFDM in
+                                              * Basic Rate)
+                                              */
        unsigned short wBasicRate;
        unsigned char byACKRate;
        unsigned char byTopOFDMBasicRate;
@@ -464,14 +371,6 @@ struct vnt_private {
        unsigned char byOpMode;
        bool bBSSIDFilter;
        unsigned short wMaxTransmitMSDULifetime;
-       unsigned char abyBSSID[ETH_ALEN];
-       unsigned char abyDesireBSSID[ETH_ALEN];
-       unsigned short wACKDuration;       // update while speed change
-       unsigned short wRTSTransmitLen;    // update while speed change
-       unsigned char byRTSServiceField;  // update while speed change
-       unsigned char byRTSSignalField;   // update while speed change
-
-       unsigned long dwMaxReceiveLifetime;       // dot11MaxReceiveLifetime
 
        bool bEncryptionEnable;
        bool bLongHeader;
@@ -480,24 +379,20 @@ struct vnt_private {
        bool bNonERPPresent;
        bool bBarkerPreambleMd;
 
-       unsigned char byERPFlag;
-       unsigned short wUseProtectCntDown;
-
        bool bRadioControlOff;
        bool bRadioOff;
        bool bEnablePSMode;
        unsigned short wListenInterval;
        bool bPWBitOn;
-       WMAC_POWER_MODE         ePSMode;
 
-       // GPIO Radio Control
+       /* GPIO Radio Control */
        unsigned char byRadioCtl;
        unsigned char byGPIO;
        bool bHWRadioOff;
        bool bPrvActive4RadioOFF;
        bool bGPIOBlockRead;
 
-       // Beacon related
+       /* Beacon related */
        unsigned short wSeqCounter;
        unsigned short wBCNBufLen;
        bool bBeaconBufReady;
@@ -506,71 +401,12 @@ struct vnt_private {
        unsigned int    cbBeaconBufReadySetCnt;
        bool bFixRate;
        unsigned char byCurrentCh;
-       unsigned int    uScanTime;
-
-       CMD_STATE               eCommandState;
-
-       CMD_CODE                eCommand;
-       bool bBeaconTx;
-
-       bool bStopBeacon;
-       bool bStopDataPkt;
-       bool bStopTx0Pkt;
-       unsigned int    uAutoReConnectTime;
-
-       // 802.11 counter
-
-       CMD_ITEM                eCmdQueue[CMD_Q_SIZE];
-       unsigned int    uCmdDequeueIdx;
-       unsigned int    uCmdEnqueueIdx;
-       unsigned int    cbFreeCmdQueue;
-       bool bCmdRunning;
-       bool bCmdClear;
-
-       bool bRoaming;
-       //WOW
-       unsigned char abyIPAddr[4];
-
-       unsigned long ulTxPower;
-       NDIS_802_11_WEP_STATUS  eEncryptionStatus;
-       bool bTransmitKey;
-//2007-0925-01<Add>by MikeLiu
-//mike add :save old Encryption
-       NDIS_802_11_WEP_STATUS  eOldEncryptionStatus;
-
-       SKeyManagement          sKey;
-       unsigned long dwIVCounter;
-
-       u64 qwPacketNumber; /* For CCMP and TKIP as TSC(6 bytes) */
-       unsigned int    uCurrentWEPMode;
-
-       RC4Ext                  SBox;
-       unsigned char abyPRNG[WLAN_WEPMAX_KEYLEN+3];
-       unsigned char byKeyIndex;
-       unsigned int    uKeyLength;
-       unsigned char abyKey[WLAN_WEP232_KEYLEN];
 
        bool bAES;
-       unsigned char byCntMeasure;
-
-       // for AP mode
-       unsigned int    uAssocCount;
-       bool bMoreData;
-
-       // QoS
-       bool bGrpAckPolicy;
-
-       // for OID_802_11_ASSOCIATION_INFORMATION
-       bool bAssocInfoSet;
 
        unsigned char byAutoFBCtrl;
 
-       bool bTxMICFail;
-       bool bRxMICFail;
-
-       unsigned int    uRATEIdx;
-
-       // For Update BaseBand VGA Gain Offset
+       /* For Update BaseBand VGA Gain Offset */
        bool bUpdateBBVGA;
        unsigned int    uBBVGADiffCount;
        unsigned char byBBVGANew;
@@ -581,24 +417,12 @@ struct vnt_private {
        unsigned char byBBPreEDRSSI;
        unsigned char byBBPreEDIndex;
 
-       bool bRadioCmd;
        unsigned long dwDiagRefCount;
 
-       // For FOE Tuning
+       /* For FOE Tuning */
        unsigned char byFOETuning;
 
-       // For Auto Power Tunning
-
-       unsigned char byAutoPwrTunning;
-       short                   sPSetPointCCK;
-       short                   sPSetPointOFDMG;
-       short                   sPSetPointOFDMA;
-       long                    lPFormulaOffset;
-       short                   sPThreshold;
-       char                    cAdjustStep;
-       char                    cMinTxAGC;
-
-       // For RF Power table
+       /* For RF Power table */
        unsigned char byCCKPwr;
        unsigned char byOFDMPwrG;
        unsigned char byCurPwr;
@@ -610,27 +434,12 @@ struct vnt_private {
        char    abyRegPwr[CB_MAX_CHANNEL+1];
        char    abyLocalPwr[CB_MAX_CHANNEL+1];
 
-       // BaseBand Loopback Use
+       /* BaseBand Loopback Use */
        unsigned char byBBCR4d;
        unsigned char byBBCRc9;
        unsigned char byBBCR88;
        unsigned char byBBCR09;
 
-       // command timer
-       struct timer_list       sTimerCommand;
-       struct timer_list       sTimerTxData;
-       unsigned long nTxDataTimeCout;
-       bool fTxDataInSleep;
-       bool IsTxDataTrigger;
-
-#ifdef WPA_SM_Transtatus
-       bool fWPA_Authened;           //is WPA/WPA-PSK or WPA2/WPA2-PSK authen??
-#endif
-       unsigned char byReAssocCount;   //mike add:re-association retry times!
-       unsigned char byLinkWaitCount;
-
-       unsigned char abyNodeName[17];
-
        bool bDiversityRegCtlON;
        bool bDiversityEnable;
        unsigned long ulDiversityNValue;
@@ -640,13 +449,13 @@ struct vnt_private {
        unsigned char byTMax3;
        unsigned long ulSQ3TH;
 
-// ANT diversity
+       /* ANT diversity */
        unsigned long uDiversityCnt;
        unsigned char byAntennaState;
        unsigned long ulRatio_State0;
        unsigned long ulRatio_State1;
 
-       //SQ3 functions for antenna diversity
+       /* SQ3 functions for antenna diversity */
        struct timer_list           TimerSQ3Tmax1;
        struct timer_list           TimerSQ3Tmax2;
        struct timer_list           TimerSQ3Tmax3;
@@ -654,86 +463,21 @@ struct vnt_private {
        unsigned long uNumSQ3[MAX_RATE];
        unsigned short wAntDiversityMaxRate;
 
-       SEthernetHeader         sTxEthHeader;
-       SEthernetHeader         sRxEthHeader;
        unsigned char abyBroadcastAddr[ETH_ALEN];
        unsigned char abySNAP_RFC1042[ETH_ALEN];
        unsigned char abySNAP_Bridgetunnel[ETH_ALEN];
-       unsigned char abyEEPROM[EEP_MAX_CONTEXT_SIZE];  //unsigned long alignment
-       // Pre-Authentication & PMK cache
-       SPMKID                  gsPMKID;
-       SPMKIDCandidateEvent    gsPMKIDCandidate;
+       unsigned char abyEEPROM[EEP_MAX_CONTEXT_SIZE]; /* unsigned long alignment */
 
-       // for 802.11h
+       /* for 802.11h */
        bool b11hEnable;
-       unsigned char abyCountryCode[3];
-       // for 802.11h DFS
-       unsigned int    uNumOfMeasureEIDs;
-       PWLAN_IE_MEASURE_REQ    pCurrMeasureEID;
-       bool bMeasureInProgress;
-       unsigned char byOrgChannel;
-       unsigned char byOrgRCR;
-       unsigned long dwOrgMAR0;
-       unsigned long dwOrgMAR4;
-       unsigned char byBasicMap;
-       unsigned char byCCAFraction;
-       unsigned char abyRPIs[8];
-       unsigned long dwRPIs[8];
-       bool bChannelSwitch;
-       unsigned char byNewChannel;
-       unsigned char byChannelSwitchCount;
-       bool bQuietEnable;
-       bool bEnableFirstQuiet;
-       unsigned char byQuietStartCount;
-       unsigned int    uQuietEnqueue;
-       unsigned long dwCurrentQuietEndTime;
-       SQuietControl           sQuiet[MAX_QUIET_COUNT];
-       // for 802.11h TPC
-       bool bCountryInfo5G;
-       bool bCountryInfo24G;
 
        unsigned short wBeaconInterval;
 
-       //WPA supplicant deamon
-       struct net_device       *wpadev;
-       bool bWPADEVUp;
-       struct sk_buff          *skb;
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-       unsigned int    bwextcount;
-       bool bWPASuppWextEnabled;
-#endif
-
-       //--
-#ifdef HOSTAP
-       // user space daemon: hostapd, is used for HOSTAP
-       bool bEnableHostapd;
-       bool bEnable8021x;
-       bool bEnableHostWEP;
-       struct net_device       *apdev;
-       int (*tx_80211)(struct sk_buff *skb, struct net_device *dev);
-#endif
        unsigned int    uChannel;
-       bool bMACSuspend;
 
-       struct iw_statistics    wstats;         // wireless stats
-       bool bCommit;
+       struct iw_statistics    wstats;         /* wireless stats */
 };
 
-static inline bool device_get_ip(struct vnt_private *pInfo)
-{
-       struct in_device *in_dev = (struct in_device *)pInfo->dev->ip_ptr;
-       struct in_ifaddr *ifa;
-
-       if (in_dev != NULL) {
-               ifa = (struct in_ifaddr *)in_dev->ifa_list;
-               if (ifa != NULL) {
-                       memcpy(pInfo->abyIPAddr, &ifa->ifa_address, 4);
-                       return true;
-               }
-       }
-       return false;
-}
-
 static inline PDEVICE_RD_INFO alloc_rd_info(void)
 {
        return kzalloc(sizeof(DEVICE_RD_INFO), GFP_ATOMIC);
@@ -746,10 +490,6 @@ static inline PDEVICE_TD_INFO alloc_td_info(void)
 
 /*---------------------  Export Functions  --------------------------*/
 
-bool device_dma0_xmit(struct vnt_private *pDevice,
-                     struct sk_buff *skb, unsigned int uNodeIndex);
 bool device_alloc_frag_buf(struct vnt_private *pDevice,
                           PSDeFragControlBlock pDeF);
-int Config_FileOperation(struct vnt_private *pDevice,
-                        bool fwrite, unsigned char *Parameter);
 #endif
index 7221824..a4a8a84 100644 (file)
@@ -29,8 +29,6 @@
 
 #include <linux/types.h>
 
-#include "ttype.h"
-
 typedef
 struct _version {
        unsigned char   major;
index 54e16f4..f0b336b 100644 (file)
  *   device_free_info - device structure resource free function
  *   device_get_pci_info - get allocated pci io/mem resource
  *   device_print_info - print out resource
- *   device_open - allocate dma/descripter resource & initial mac/bbp function
- *   device_xmit - asynchrous data tx function
  *   device_intr - interrupt handle function
- *   device_set_multi - set mac filter
- *   device_ioctl - ioctl entry
- *   device_close - shutdown mac/bbp & free dma/descripter resource
  *   device_rx_srv - rx service function
- *   device_receive_frame - rx data function
  *   device_alloc_rx_buf - rx buffer pre-allocated function
  *   device_alloc_frag_buf - rx fragement pre-allocated function
  *   device_free_tx_buf - free tx buffer function
  *   device_free_frag_buf- free de-fragement buffer
- *   device_dma0_tx_80211- tx 802.11 frame via dma0
- *   device_dma0_xmit- tx PS bufferred frame via dma0
  *   device_init_rd0_ring- initial rd dma0 ring
  *   device_init_rd1_ring- initial rd dma1 ring
  *   device_init_td0_ring- initial tx dma0 ring buffer
 #include "channel.h"
 #include "baseband.h"
 #include "mac.h"
-#include "tether.h"
-#include "wmgr.h"
-#include "wctl.h"
 #include "power.h"
-#include "wcmd.h"
-#include "iocmd.h"
-#include "tcrc.h"
 #include "rxtx.h"
-#include "wroute.h"
-#include "bssdb.h"
-#include "hostap.h"
-#include "wpactl.h"
-#include "ioctl.h"
-#include "iwctl.h"
 #include "dpc.h"
-#include "datarate.h"
 #include "rf.h"
-#include "iowpa.h"
 #include <linux/delay.h>
 #include <linux/kthread.h>
 #include <linux/slab.h>
@@ -265,17 +243,10 @@ static void device_free_info(struct vnt_private *pDevice);
 static bool device_get_pci_info(struct vnt_private *, struct pci_dev *pcid);
 static void device_print_info(struct vnt_private *pDevice);
 static void device_init_diversity_timer(struct vnt_private *pDevice);
-static int  device_open(struct net_device *dev);
-static int  device_xmit(struct sk_buff *skb, struct net_device *dev);
 static  irqreturn_t  device_intr(int irq,  void *dev_instance);
-static void device_set_multi(struct net_device *dev);
-static int  device_close(struct net_device *dev);
-static int  device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 
 #ifdef CONFIG_PM
 static int device_notify_reboot(struct notifier_block *, unsigned long event, void *ptr);
-static int viawget_suspend(struct pci_dev *pcid, pm_message_t state);
-static int viawget_resume(struct pci_dev *pcid);
 static struct notifier_block device_notifier = {
        .notifier_call = device_notify_reboot,
        .next = NULL,
@@ -289,11 +260,6 @@ static void device_init_defrag_cb(struct vnt_private *pDevice);
 static void device_init_td0_ring(struct vnt_private *pDevice);
 static void device_init_td1_ring(struct vnt_private *pDevice);
 
-static int  device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev);
-//2008-0714<Add>by Mike Liu
-static bool device_release_WPADEV(struct vnt_private *pDevice);
-
-static int  ethtool_ioctl(struct net_device *dev, void __user *useraddr);
 static int  device_rx_srv(struct vnt_private *pDevice, unsigned int uIdx);
 static int  device_tx_srv(struct vnt_private *pDevice, unsigned int uIdx);
 static bool device_alloc_rx_buf(struct vnt_private *pDevice, PSRxDesc pDesc);
@@ -305,8 +271,6 @@ static void device_free_rd0_ring(struct vnt_private *pDevice);
 static void device_free_rd1_ring(struct vnt_private *pDevice);
 static void device_free_rings(struct vnt_private *pDevice);
 static void device_free_frag_buf(struct vnt_private *pDevice);
-static int Config_FileGetParameter(unsigned char *string,
-                                  unsigned char *dest, unsigned char *source);
 
 /*---------------------  Export Variables  --------------------------*/
 
@@ -362,9 +326,9 @@ device_set_options(struct vnt_private *pDevice)
        unsigned char abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
        unsigned char abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
 
-       memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, ETH_ALEN);
-       memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, ETH_ALEN);
-       memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, ETH_ALEN);
+       ether_addr_copy(pDevice->abyBroadcastAddr, abyBroadcastAddr);
+       ether_addr_copy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042);
+       ether_addr_copy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel);
 
        pDevice->uChannel = pDevice->sOpts.channel_num;
        pDevice->wRTSThreshold = pDevice->sOpts.rts_thresh;
@@ -374,7 +338,6 @@ device_set_options(struct vnt_private *pDevice)
        pDevice->wMaxTransmitMSDULifetime = DEFAULT_MSDU_LIFETIME;
        pDevice->byShortPreamble = (pDevice->sOpts.flags & DEVICE_FLAGS_PREAMBLE_TYPE) ? 1 : 0;
        pDevice->byOpMode = (pDevice->sOpts.flags & DEVICE_FLAGS_OP_MODE) ? 1 : 0;
-       pDevice->ePSMode = (pDevice->sOpts.flags & DEVICE_FLAGS_PS_MODE) ? 1 : 0;
        pDevice->b11hEnable = (pDevice->sOpts.flags & DEVICE_FLAGS_80211h_MODE) ? 1 : 0;
        pDevice->bDiversityRegCtlON = (pDevice->sOpts.flags & DEVICE_FLAGS_DiversityANT) ? 1 : 0;
        pDevice->uConnectionRate = pDevice->sOpts.data_rate;
@@ -389,7 +352,6 @@ device_set_options(struct vnt_private *pDevice)
 
        pr_debug(" uChannel= %d\n", (int)pDevice->uChannel);
        pr_debug(" byOpMode= %d\n", (int)pDevice->byOpMode);
-       pr_debug(" ePSMode= %d\n", (int)pDevice->ePSMode);
        pr_debug(" wRTSThreshold= %d\n", (int)pDevice->wRTSThreshold);
        pr_debug(" byShortRetryLimit= %d\n", (int)pDevice->byShortRetryLimit);
        pr_debug(" byLongRetryLimit= %d\n", (int)pDevice->byLongRetryLimit);
@@ -402,58 +364,18 @@ device_set_options(struct vnt_private *pDevice)
                 (int)pDevice->bDiversityRegCtlON);
 }
 
-static void s_vCompleteCurrentMeasure(struct vnt_private *pDevice,
-                                     unsigned char byResult)
-{
-       unsigned int ii;
-       unsigned long dwDuration = 0;
-       unsigned char byRPI0 = 0;
-
-       for (ii = 1; ii < 8; ii++) {
-               pDevice->dwRPIs[ii] *= 255;
-               dwDuration |= *((unsigned short *)(pDevice->pCurrMeasureEID->sReq.abyDuration));
-               dwDuration <<= 10;
-               pDevice->dwRPIs[ii] /= dwDuration;
-               pDevice->abyRPIs[ii] = (unsigned char)pDevice->dwRPIs[ii];
-               byRPI0 += pDevice->abyRPIs[ii];
-       }
-       pDevice->abyRPIs[0] = (0xFF - byRPI0);
-
-       if (pDevice->uNumOfMeasureEIDs == 0) {
-               VNTWIFIbMeasureReport(pDevice->pMgmt,
-                                     true,
-                                     pDevice->pCurrMeasureEID,
-                                     byResult,
-                                     pDevice->byBasicMap,
-                                     pDevice->byCCAFraction,
-                                     pDevice->abyRPIs
-                       );
-       } else {
-               VNTWIFIbMeasureReport(pDevice->pMgmt,
-                                     false,
-                                     pDevice->pCurrMeasureEID,
-                                     byResult,
-                                     pDevice->byBasicMap,
-                                     pDevice->byCCAFraction,
-                                     pDevice->abyRPIs
-                       );
-               CARDbStartMeasure(pDevice, pDevice->pCurrMeasureEID++, pDevice->uNumOfMeasureEIDs);
-       }
-}
-
 //
 // Initialisation of MAC & BBP registers
 //
 
 static void device_init_registers(struct vnt_private *pDevice)
 {
+       unsigned long flags;
        unsigned int ii;
        unsigned char byValue;
        unsigned char byValue1;
        unsigned char byCCKPwrdBm = 0;
        unsigned char byOFDMPwrdBm = 0;
-       int zonetype = 0;
-       PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
 
        MACbShutdown(pDevice->PortOffset);
        BBvSoftwareReset(pDevice->PortOffset);
@@ -481,11 +403,11 @@ static void device_init_registers(struct vnt_private *pDevice)
        /* Get Local ID */
        VNSvInPortB(pDevice->PortOffset + MAC_REG_LOCALID, &pDevice->byLocalID);
 
-       spin_lock_irq(&pDevice->lock);
+       spin_lock_irqsave(&pDevice->lock, flags);
 
        SROMvReadAllContents(pDevice->PortOffset, pDevice->abyEEPROM);
 
-       spin_unlock_irq(&pDevice->lock);
+       spin_unlock_irqrestore(&pDevice->lock, flags);
 
        /* Get Channel range */
        pDevice->byMinChannel = 1;
@@ -558,41 +480,6 @@ static void device_init_registers(struct vnt_private *pDevice)
 
        /* zonetype initial */
        pDevice->byOriginalZonetype = pDevice->abyEEPROM[EEP_OFS_ZONETYPE];
-       zonetype = Config_FileOperation(pDevice, false, NULL);
-
-       if (zonetype >= 0) {
-               if ((zonetype == 0) &&
-                   (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] != 0x00)) {
-                       /* for USA */
-                       pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0;
-                       pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0B;
-
-                       pr_debug("Init Zone Type :USA\n");
-               } else if ((zonetype == 1) &&
-                        (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] != 0x01)) {
-                       /* for Japan */
-                       pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0x01;
-                       pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D;
-               } else if ((zonetype == 2) &&
-                         (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] != 0x02)) {
-                       /* for Europe */
-                       pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0x02;
-                       pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D;
-
-                       pr_debug("Init Zone Type :Europe\n");
-               } else {
-                       if (zonetype != pDevice->abyEEPROM[EEP_OFS_ZONETYPE])
-                               pr_debug("zonetype in file[%02x] mismatch with in EEPROM[%02x]\n",
-                                        zonetype,
-                                        pDevice->abyEEPROM[EEP_OFS_ZONETYPE]);
-                       else
-                               pr_debug("Read Zonetype file success,use default zonetype setting[%02x]\n",
-                                        zonetype);
-               }
-       } else {
-               pr_debug("Read Zonetype file fail,use default zonetype setting[%02x]\n",
-                        SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_ZONETYPE));
-       }
 
        /* Get RFType */
        pDevice->byRFType = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_RFTYPE);
@@ -636,14 +523,9 @@ static void device_init_registers(struct vnt_private *pDevice)
        }
 
        /* recover 12,13 ,14channel for EUROPE by 11 channel */
-       if (((pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Japan) ||
-            (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Europe)) &&
-           (pDevice->byOriginalZonetype == ZoneType_USA)) {
-               for (ii = 11; ii < 14; ii++) {
-                       pDevice->abyCCKPwrTbl[ii] = pDevice->abyCCKPwrTbl[10];
-                       pDevice->abyOFDMPwrTbl[ii] = pDevice->abyOFDMPwrTbl[10];
-
-               }
+       for (ii = 11; ii < 14; ii++) {
+               pDevice->abyCCKPwrTbl[ii] = pDevice->abyCCKPwrTbl[10];
+               pDevice->abyOFDMPwrTbl[ii] = pDevice->abyOFDMPwrTbl[10];
        }
 
        /* Load OFDM A Power Table */
@@ -657,8 +539,6 @@ static void device_init_registers(struct vnt_private *pDevice)
                                           (unsigned char)(ii + EEP_OFS_OFDMA_PWR_dBm));
        }
 
-       init_channel_table((void *)pDevice);
-
        if (pDevice->byLocalID > REV_ID_VT3253_B1) {
                MACvSelectPage1(pDevice->PortOffset);
 
@@ -693,8 +573,6 @@ static void device_init_registers(struct vnt_private *pDevice)
        BBvSetRxAntennaMode(pDevice->PortOffset, pDevice->byRxAntennaMode);
        BBvSetTxAntennaMode(pDevice->PortOffset, pDevice->byTxAntennaMode);
 
-       pDevice->byCurrentCh = 0;
-
        /* Set BB and packet type at the same time. */
        /* Set Short Slot Time, xIFS, and RSPINF. */
        if (pDevice->uConnectionRate == RATE_AUTO)
@@ -702,10 +580,6 @@ static void device_init_registers(struct vnt_private *pDevice)
        else
                pDevice->wCurrentRate = (unsigned short)pDevice->uConnectionRate;
 
-       /* default G Mode */
-       VNTWIFIbConfigPhyMode(pDevice->pMgmt, PHY_TYPE_11G);
-       VNTWIFIbConfigPhyMode(pDevice->pMgmt, PHY_TYPE_AUTO);
-
        pDevice->bRadioOff = false;
 
        pDevice->byRadioCtl = SROMbyReadEmbedded(pDevice->PortOffset,
@@ -726,8 +600,6 @@ static void device_init_registers(struct vnt_private *pDevice)
        if (pDevice->bHWRadioOff || pDevice->bRadioControlOff)
                CARDbRadioPowerOff(pDevice);
 
-       pMgmt->eScanType = WMAC_SCAN_PASSIVE;
-
        /* get Permanent network address */
        SROMvReadEtherAddress(pDevice->PortOffset, pDevice->abyCurrentNetAddr);
        pr_debug("Network address = %pM\n", pDevice->abyCurrentNetAddr);
@@ -740,223 +612,39 @@ static void device_init_registers(struct vnt_private *pDevice)
        if (pDevice->byLocalID <= REV_ID_VT3253_A1)
                MACvRegBitsOn(pDevice->PortOffset, MAC_REG_RCR, RCR_WPAERR);
 
-       pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
-
        /* Turn On Rx DMA */
        MACvReceive0(pDevice->PortOffset);
        MACvReceive1(pDevice->PortOffset);
 
        /* start the adapter */
        MACvStart(pDevice->PortOffset);
-
-       netif_stop_queue(pDevice->dev);
 }
 
 static void device_init_diversity_timer(struct vnt_private *pDevice)
 {
        init_timer(&pDevice->TimerSQ3Tmax1);
        pDevice->TimerSQ3Tmax1.data = (unsigned long) pDevice;
-       pDevice->TimerSQ3Tmax1.function = (TimerFunction)TimerSQ3CallBack;
+       pDevice->TimerSQ3Tmax1.function = TimerSQ3CallBack;
        pDevice->TimerSQ3Tmax1.expires = RUN_AT(HZ);
 
        init_timer(&pDevice->TimerSQ3Tmax2);
        pDevice->TimerSQ3Tmax2.data = (unsigned long) pDevice;
-       pDevice->TimerSQ3Tmax2.function = (TimerFunction)TimerSQ3CallBack;
+       pDevice->TimerSQ3Tmax2.function = TimerSQ3CallBack;
        pDevice->TimerSQ3Tmax2.expires = RUN_AT(HZ);
 
        init_timer(&pDevice->TimerSQ3Tmax3);
        pDevice->TimerSQ3Tmax3.data = (unsigned long) pDevice;
-       pDevice->TimerSQ3Tmax3.function = (TimerFunction)TimerState1CallBack;
+       pDevice->TimerSQ3Tmax3.function = TimerState1CallBack;
        pDevice->TimerSQ3Tmax3.expires = RUN_AT(HZ);
 }
 
-static bool device_release_WPADEV(struct vnt_private *pDevice)
-{
-       viawget_wpa_header *wpahdr;
-       int ii = 0;
-
-       //send device close to wpa_supplicnat layer
-       if (pDevice->bWPADEVUp) {
-               wpahdr = (viawget_wpa_header *)pDevice->skb->data;
-               wpahdr->type = VIAWGET_DEVICECLOSE_MSG;
-               wpahdr->resp_ie_len = 0;
-               wpahdr->req_ie_len = 0;
-               skb_put(pDevice->skb, sizeof(viawget_wpa_header));
-               pDevice->skb->dev = pDevice->wpadev;
-               skb_reset_mac_header(pDevice->skb);
-               pDevice->skb->pkt_type = PACKET_HOST;
-               pDevice->skb->protocol = htons(ETH_P_802_2);
-               memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
-               netif_rx(pDevice->skb);
-               pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
-
-               while (pDevice->bWPADEVUp) {
-                       set_current_state(TASK_UNINTERRUPTIBLE);
-                       schedule_timeout(HZ / 20);          //wait 50ms
-                       ii++;
-                       if (ii > 20)
-                               break;
-               }
-       }
-       return true;
-}
-
-static const struct net_device_ops device_netdev_ops = {
-       .ndo_open               = device_open,
-       .ndo_stop               = device_close,
-       .ndo_do_ioctl           = device_ioctl,
-       .ndo_start_xmit         = device_xmit,
-       .ndo_set_rx_mode        = device_set_multi,
-};
-
-static int
-vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent)
-{
-       static bool bFirst = true;
-       struct net_device *dev = NULL;
-       PCHIP_INFO  pChip_info = (PCHIP_INFO)ent->driver_data;
-       struct vnt_private *pDevice;
-       int         rc;
-
-       dev = alloc_etherdev(sizeof(*pDevice));
-
-       pDevice = netdev_priv(dev);
-
-       if (dev == NULL) {
-               pr_err(DEVICE_NAME ": allocate net device failed\n");
-               return -ENOMEM;
-       }
-
-       // Chain it all together
-       SET_NETDEV_DEV(dev, &pcid->dev);
-
-       if (bFirst) {
-               pr_notice("%s Ver. %s\n", DEVICE_FULL_DRV_NAM, DEVICE_VERSION);
-               pr_notice("Copyright (c) 2003 VIA Networking Technologies, Inc.\n");
-               bFirst = false;
-       }
-
-       vt6655_init_info(pcid, &pDevice, pChip_info);
-       pDevice->dev = dev;
-
-       if (pci_enable_device(pcid)) {
-               device_free_info(pDevice);
-               return -ENODEV;
-       }
-       dev->irq = pcid->irq;
-
-#ifdef DEBUG
-       pr_debug("Before get pci_info memaddr is %x\n", pDevice->memaddr);
-#endif
-       if (!device_get_pci_info(pDevice, pcid)) {
-               pr_err(DEVICE_NAME ": Failed to find PCI device.\n");
-               device_free_info(pDevice);
-               return -ENODEV;
-       }
-
-#if 1
-
-#ifdef DEBUG
-
-       pr_debug("after get pci_info memaddr is %x, io addr is %x,io_size is %d\n", pDevice->memaddr, pDevice->ioaddr, pDevice->io_size);
-       {
-               int i;
-               u32 bar, len;
-               u32 address[] = {
-                       PCI_BASE_ADDRESS_0,
-                       PCI_BASE_ADDRESS_1,
-                       PCI_BASE_ADDRESS_2,
-                       PCI_BASE_ADDRESS_3,
-                       PCI_BASE_ADDRESS_4,
-                       PCI_BASE_ADDRESS_5,
-                       0};
-               for (i = 0; address[i]; i++) {
-                       pci_read_config_dword(pcid, address[i], &bar);
-                       pr_debug("bar %d is %x\n", i, bar);
-                       if (!bar) {
-                               pr_debug("bar %d not implemented\n", i);
-                               continue;
-                       }
-                       if (bar & PCI_BASE_ADDRESS_SPACE_IO) {
-                               /* This is IO */
-
-                               len = bar & (PCI_BASE_ADDRESS_IO_MASK & 0xFFFF);
-                               len = len & ~(len - 1);
-
-                               pr_debug("IO space:  len in IO %x, BAR %d\n", len, i);
-                       } else {
-                               len = bar & 0xFFFFFFF0;
-                               len = ~len + 1;
-
-                               pr_debug("len in MEM %x, BAR %d\n", len, i);
-                       }
-               }
-       }
-#endif
-
-#endif
-
-       pDevice->PortOffset = ioremap(pDevice->memaddr & PCI_BASE_ADDRESS_MEM_MASK, pDevice->io_size);
-
-       if (pDevice->PortOffset == NULL) {
-               pr_err(DEVICE_NAME ": Failed to IO remapping ..\n");
-               device_free_info(pDevice);
-               return -ENODEV;
-       }
-
-       rc = pci_request_regions(pcid, DEVICE_NAME);
-       if (rc) {
-               pr_err(DEVICE_NAME ": Failed to find PCI device\n");
-               device_free_info(pDevice);
-               return -ENODEV;
-       }
-
-       dev->base_addr = pDevice->ioaddr;
-       // do reset
-       if (!MACbSoftwareReset(pDevice->PortOffset)) {
-               pr_err(DEVICE_NAME ": Failed to access MAC hardware..\n");
-               device_free_info(pDevice);
-               return -ENODEV;
-       }
-       // initial to reload eeprom
-       MACvInitialize(pDevice->PortOffset);
-       MACvReadEtherAddress(pDevice->PortOffset, dev->dev_addr);
-
-       device_get_options(pDevice);
-       device_set_options(pDevice);
-       //Mask out the options cannot be set to the chip
-       pDevice->sOpts.flags &= pChip_info->flags;
-
-       //Enable the chip specified capabilities
-       pDevice->flags = pDevice->sOpts.flags | (pChip_info->flags & 0xFF000000UL);
-       pDevice->tx_80211 = device_dma0_tx_80211;
-       pDevice->sMgmtObj.pAdapter = (void *)pDevice;
-       pDevice->pMgmt = &(pDevice->sMgmtObj);
-
-       dev->irq                = pcid->irq;
-       dev->netdev_ops         = &device_netdev_ops;
-
-       dev->wireless_handlers = (struct iw_handler_def *)&iwctl_handler_def;
-
-       rc = register_netdev(dev);
-       if (rc) {
-               pr_err(DEVICE_NAME " Failed to register netdev\n");
-               device_free_info(pDevice);
-               return -ENODEV;
-       }
-       device_print_info(pDevice);
-       pci_set_drvdata(pcid, pDevice);
-       return 0;
-}
-
 static void device_print_info(struct vnt_private *pDevice)
 {
-       struct net_device *dev = pDevice->dev;
+       dev_info(&pDevice->pcid->dev, "%s\n", get_chip_name(pDevice->chip_id));
 
-       pr_info("%s: %s\n", dev->name, get_chip_name(pDevice->chip_id));
-       pr_info("%s: MAC=%pM IO=0x%lx Mem=0x%lx IRQ=%d\n",
-               dev->name, dev->dev_addr, (unsigned long)pDevice->ioaddr,
-               (unsigned long)pDevice->PortOffset, pDevice->dev->irq);
+       dev_info(&pDevice->pcid->dev, "MAC=%pM IO=0x%lx Mem=0x%lx IRQ=%d\n",
+                pDevice->abyCurrentNetAddr, (unsigned long)pDevice->ioaddr,
+                (unsigned long)pDevice->PortOffset, pDevice->pcid->irq);
 }
 
 static void vt6655_init_info(struct pci_dev *pcid,
@@ -1003,31 +691,20 @@ static bool device_get_pci_info(struct vnt_private *pDevice,
 
 static void device_free_info(struct vnt_private *pDevice)
 {
-       struct net_device *dev = pDevice->dev;
-
-       ASSERT(pDevice);
-//2008-0714-01<Add>by chester
-       device_release_WPADEV(pDevice);
-
-//2008-07-21-01<Add>by MikeLiu
-//unregister wpadev
-       if (wpa_set_wpadev(pDevice, 0) != 0)
-               pr_err("unregister wpadev fail?\n");
+       if (!pDevice)
+               return;
 
-#ifdef HOSTAP
-       if (dev)
-               vt6655_hostap_set_hostapd(pDevice, 0, 0);
-#endif
-       if (dev)
-               unregister_netdev(dev);
+       if (pDevice->mac_hw)
+               ieee80211_unregister_hw(pDevice->hw);
 
        if (pDevice->PortOffset)
                iounmap(pDevice->PortOffset);
 
        if (pDevice->pcid)
                pci_release_regions(pDevice->pcid);
-       if (dev)
-               free_netdev(dev);
+
+       if (pDevice->hw)
+               ieee80211_free_hw(pDevice->hw);
 }
 
 static bool device_init_rings(struct vnt_private *pDevice)
@@ -1204,7 +881,7 @@ static void device_free_rd0_ring(struct vnt_private *pDevice)
 
                dev_kfree_skb(pRDInfo->skb);
 
-               kfree((void *)pDesc->pRDInfo);
+               kfree(pDesc->pRDInfo);
        }
 }
 
@@ -1221,7 +898,7 @@ static void device_free_rd1_ring(struct vnt_private *pDevice)
 
                dev_kfree_skb(pRDInfo->skb);
 
-               kfree((void *)pDesc->pRDInfo);
+               kfree(pDesc->pRDInfo);
        }
 }
 
@@ -1305,7 +982,7 @@ static void device_free_td0_ring(struct vnt_private *pDevice)
                if (pTDInfo->skb)
                        dev_kfree_skb(pTDInfo->skb);
 
-               kfree((void *)pDesc->pTDInfo);
+               kfree(pDesc->pTDInfo);
        }
 }
 
@@ -1324,7 +1001,7 @@ static void device_free_td1_ring(struct vnt_private *pDevice)
                if (pTDInfo->skb)
                        dev_kfree_skb(pTDInfo->skb);
 
-               kfree((void *)pDesc->pTDInfo);
+               kfree(pDesc->pTDInfo);
        }
 }
 
@@ -1340,7 +1017,7 @@ static int device_rx_srv(struct vnt_private *pDevice, unsigned int uIdx)
             pRD = pRD->next) {
                if (works++ > 15)
                        break;
-               if (device_receive_frame(pDevice, pRD)) {
+               if (vnt_receive_frame(pDevice, pRD)) {
                        if (!device_alloc_rx_buf(pDevice, pRD)) {
                                dev_err(&pDevice->pcid->dev,
                                        "can not allocate rx buf\n");
@@ -1348,7 +1025,6 @@ static int device_rx_srv(struct vnt_private *pDevice, unsigned int uIdx)
                        }
                }
                pRD->m_rd0RD0.f1Owner = OWNED_BY_NIC;
-               pDevice->dev->last_rx = jiffies;
        }
 
        pDevice->pCurrRD[uIdx] = pRD;
@@ -1364,9 +1040,12 @@ static bool device_alloc_rx_buf(struct vnt_private *pDevice, PSRxDesc pRD)
        if (pRDInfo->skb == NULL)
                return false;
        ASSERT(pRDInfo->skb);
-       pRDInfo->skb->dev = pDevice->dev;
-       pRDInfo->skb_dma = pci_map_single(pDevice->pcid, skb_tail_pointer(pRDInfo->skb),
-                                         pDevice->rx_buf_sz, PCI_DMA_FROMDEVICE);
+
+       pRDInfo->skb_dma =
+               pci_map_single(pDevice->pcid,
+                              skb_put(pRDInfo->skb, skb_tailroom(pRDInfo->skb)),
+                              pDevice->rx_buf_sz, PCI_DMA_FROMDEVICE);
+
        *((unsigned int *)&(pRD->m_rd0RD0)) = 0; /* FIX cast */
 
        pRD->m_rd0RD0.wResCount = cpu_to_le16(pDevice->rx_buf_sz);
@@ -1384,24 +1063,88 @@ bool device_alloc_frag_buf(struct vnt_private *pDevice,
        if (pDeF->skb == NULL)
                return false;
        ASSERT(pDeF->skb);
-       pDeF->skb->dev = pDevice->dev;
 
        return true;
 }
 
+static const u8 fallback_rate0[5][5] = {
+       {RATE_18M, RATE_18M, RATE_12M, RATE_12M, RATE_12M},
+       {RATE_24M, RATE_24M, RATE_18M, RATE_12M, RATE_12M},
+       {RATE_36M, RATE_36M, RATE_24M, RATE_18M, RATE_18M},
+       {RATE_48M, RATE_48M, RATE_36M, RATE_24M, RATE_24M},
+       {RATE_54M, RATE_54M, RATE_48M, RATE_36M, RATE_36M}
+};
+
+static const u8 fallback_rate1[5][5] = {
+       {RATE_18M, RATE_18M, RATE_12M, RATE_6M, RATE_6M},
+       {RATE_24M, RATE_24M, RATE_18M, RATE_6M, RATE_6M},
+       {RATE_36M, RATE_36M, RATE_24M, RATE_12M, RATE_12M},
+       {RATE_48M, RATE_48M, RATE_24M, RATE_12M, RATE_12M},
+       {RATE_54M, RATE_54M, RATE_36M, RATE_18M, RATE_18M}
+};
+
+static int vnt_int_report_rate(struct vnt_private *priv,
+                              PDEVICE_TD_INFO context, u8 tsr0, u8 tsr1)
+{
+       struct vnt_tx_fifo_head *fifo_head;
+       struct ieee80211_tx_info *info;
+       struct ieee80211_rate *rate;
+       u16 fb_option;
+       u8 tx_retry = (tsr0 & TSR0_NCR);
+       s8 idx;
+
+       if (!context)
+               return -ENOMEM;
+
+       if (!context->skb)
+               return -EINVAL;
+
+       fifo_head = (struct vnt_tx_fifo_head *)context->buf;
+       fb_option = (le16_to_cpu(fifo_head->fifo_ctl) &
+                       (FIFOCTL_AUTO_FB_0 | FIFOCTL_AUTO_FB_1));
+
+       info = IEEE80211_SKB_CB(context->skb);
+       idx = info->control.rates[0].idx;
+
+       if (fb_option && !(tsr1 & TSR1_TERR)) {
+               u8 tx_rate;
+               u8 retry = tx_retry;
+
+               rate = ieee80211_get_tx_rate(priv->hw, info);
+               tx_rate = rate->hw_value - RATE_18M;
+
+               if (retry > 4)
+                       retry = 4;
+
+               if (fb_option & FIFOCTL_AUTO_FB_0)
+                       tx_rate = fallback_rate0[tx_rate][retry];
+               else if (fb_option & FIFOCTL_AUTO_FB_1)
+                       tx_rate = fallback_rate1[tx_rate][retry];
+
+               if (info->band == IEEE80211_BAND_5GHZ)
+                       idx = tx_rate - RATE_6M;
+               else
+                       idx = tx_rate;
+       }
+
+       ieee80211_tx_info_clear_status(info);
+
+       info->status.rates[0].count = tx_retry;
+
+       if (!(tsr1 & TSR1_TERR)) {
+               info->status.rates[0].idx = idx;
+               info->flags |= IEEE80211_TX_STAT_ACK;
+       }
+
+       return 0;
+}
+
 static int device_tx_srv(struct vnt_private *pDevice, unsigned int uIdx)
 {
        PSTxDesc                 pTD;
-       bool bFull = false;
        int                      works = 0;
        unsigned char byTsr0;
        unsigned char byTsr1;
-       unsigned int    uFrameSize, uFIFOHeaderSize;
-       PSTxBufHead              pTxBufHead;
-       struct net_device_stats *pStats = &pDevice->dev->stats;
-       struct sk_buff *skb;
-       unsigned int    uNodeIndex;
-       PSMgmtObject             pMgmt = pDevice->pMgmt;
 
        for (pTD = pDevice->apTailTD[uIdx]; pDevice->iTDUsed[uIdx] > 0; pTD = pTD->next) {
                if (pTD->m_td0TD0.f1Owner == OWNED_BY_NIC)
@@ -1415,22 +1158,8 @@ static int device_tx_srv(struct vnt_private *pDevice, unsigned int uIdx)
                //Only the status of first TD in the chain is correct
                if (pTD->m_td1TD1.byTCR & TCR_STP) {
                        if ((pTD->pTDInfo->byFlags & TD_FLAGS_NETIF_SKB) != 0) {
-                               uFIFOHeaderSize = pTD->pTDInfo->dwHeaderLength;
-                               uFrameSize = pTD->pTDInfo->dwReqCount - uFIFOHeaderSize;
-                               pTxBufHead = (PSTxBufHead) (pTD->pTDInfo->buf);
-                               // Update the statistics based on the Transmit status
-                               // now, we DONT check TSR0_CDH
-
-                               STAvUpdateTDStatCounter(&pDevice->scStatistic,
-                                                       byTsr0, byTsr1,
-                                                       (unsigned char *)(pTD->pTDInfo->buf + uFIFOHeaderSize),
-                                                       uFrameSize, uIdx);
-
-                               BSSvUpdateNodeTxCounter(pDevice,
-                                                       byTsr0, byTsr1,
-                                                       (unsigned char *)(pTD->pTDInfo->buf),
-                                                       uFIFOHeaderSize
-                                       );
+
+                               vnt_int_report_rate(pDevice, pTD->pTDInfo, byTsr0, byTsr1);
 
                                if (!(byTsr1 & TSR1_TERR)) {
                                        if (byTsr0 != 0) {
@@ -1438,28 +1167,9 @@ static int device_tx_srv(struct vnt_private *pDevice, unsigned int uIdx)
                                                         (int)uIdx, byTsr1,
                                                         byTsr0);
                                        }
-                                       if ((pTxBufHead->wFragCtl & FRAGCTL_ENDFRAG) != FRAGCTL_NONFRAG)
-                                               pDevice->s802_11Counter.TransmittedFragmentCount++;
-
-                                       pStats->tx_packets++;
-                                       pStats->tx_bytes += pTD->pTDInfo->skb->len;
                                } else {
                                        pr_debug(" Tx[%d] dropped & tsr1[%02X] tsr0[%02X]\n",
                                                 (int)uIdx, byTsr1, byTsr0);
-                                       pStats->tx_errors++;
-                                       pStats->tx_dropped++;
-                               }
-                       }
-
-                       if ((pTD->pTDInfo->byFlags & TD_FLAGS_PRIV_SKB) != 0) {
-                               if (pDevice->bEnableHostapd) {
-                                       pr_debug("tx call back netif..\n");
-                                       skb = pTD->pTDInfo->skb;
-                                       skb->dev = pDevice->apdev;
-                                       skb_reset_mac_header(skb);
-                                       skb->pkt_type = PACKET_OTHERHOST;
-                                       memset(skb->cb, 0, sizeof(skb->cb));
-                                       netif_rx(skb);
                                }
                        }
 
@@ -1468,47 +1178,14 @@ static int device_tx_srv(struct vnt_private *pDevice, unsigned int uIdx)
                                        pr_debug(" Tx[%d] fail has error. tsr1[%02X] tsr0[%02X]\n",
                                                 (int)uIdx, byTsr1, byTsr0);
                                }
-
-
-                               if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) &&
-                                   (pTD->pTDInfo->byFlags & TD_FLAGS_NETIF_SKB)) {
-                                       unsigned short wAID;
-                                       unsigned char byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
-
-                                       skb = pTD->pTDInfo->skb;
-                                       if (BSSDBbIsSTAInNodeDB(pMgmt, (unsigned char *)(skb->data), &uNodeIndex)) {
-                                               if (pMgmt->sNodeDBTable[uNodeIndex].bPSEnable) {
-                                                       skb_queue_tail(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue, skb);
-                                                       pMgmt->sNodeDBTable[uNodeIndex].wEnQueueCnt++;
-                                                       // set tx map
-                                                       wAID = pMgmt->sNodeDBTable[uNodeIndex].wAID;
-                                                       pMgmt->abyPSTxMap[wAID >> 3] |=  byMask[wAID & 7];
-                                                       pTD->pTDInfo->byFlags &= ~(TD_FLAGS_NETIF_SKB);
-                                                       pr_debug("tx_srv:tx fail re-queue sta index= %d, QueCnt= %d\n",
-                                                                (int)uNodeIndex,
-                                                                pMgmt->sNodeDBTable[uNodeIndex].wEnQueueCnt);
-                                                       pStats->tx_errors--;
-                                                       pStats->tx_dropped--;
-                                               }
-                                       }
-                               }
                        }
                        device_free_tx_buf(pDevice, pTD);
                        pDevice->iTDUsed[uIdx]--;
-               }
-       }
-
-       if (uIdx == TYPE_AC0DMA) {
-               // RESERV_AC0DMA reserved for relay
 
-               if (AVAIL_TD(pDevice, uIdx) < RESERV_AC0DMA) {
-                       bFull = true;
-                       pr_debug(" AC0DMA is Full = %d\n",
-                                pDevice->iTDUsed[uIdx]);
+                       /* Make sure queue is available */
+                       if (AVAIL_TD(pDevice, uIdx))
+                               ieee80211_wake_queues(pDevice->hw);
                }
-               if (netif_queue_stopped(pDevice->dev) && !bFull)
-                       netif_wake_queue(pDevice->dev);
-
        }
 
        pDevice->apTailTD[uIdx] = pTD;
@@ -1521,10 +1198,6 @@ static void device_error(struct vnt_private *pDevice, unsigned short status)
        if (status & ISR_FETALERR) {
                dev_err(&pDevice->pcid->dev, "Hardware fatal error\n");
 
-               netif_stop_queue(pDevice->dev);
-               del_timer(&pDevice->sTimerCommand);
-               del_timer(&(pDevice->pMgmt->sTimerSecondCallback));
-               pDevice->bCmdRunning = false;
                MACbShutdown(pDevice->PortOffset);
                return;
        }
@@ -1541,7 +1214,9 @@ static void device_free_tx_buf(struct vnt_private *pDevice, PSTxDesc pDesc)
                                 PCI_DMA_TODEVICE);
        }
 
-       if ((pTDInfo->byFlags & TD_FLAGS_NETIF_SKB) != 0)
+       if (pTDInfo->byFlags & TD_FLAGS_NETIF_SKB)
+               ieee80211_tx_status_irqsafe(pDevice->hw, skb);
+       else
                dev_kfree_skb_irq(skb);
 
        pTDInfo->skb_dma = 0;
@@ -1549,1473 +1224,812 @@ static void device_free_tx_buf(struct vnt_private *pDevice, PSTxDesc pDesc)
        pTDInfo->byFlags = 0;
 }
 
-static int  device_open(struct net_device *dev)
+static  irqreturn_t  device_intr(int irq,  void *dev_instance)
 {
-       struct vnt_private *pDevice = netdev_priv(dev);
-       int i;
-#ifdef WPA_SM_Transtatus
-       extern SWPAResult wpa_Result;
-#endif
+       struct vnt_private *pDevice = dev_instance;
+       int             max_count = 0;
+       unsigned long dwMIBCounter = 0;
+       unsigned char byOrgPageSel = 0;
+       int             handled = 0;
+       int             ii = 0;
+       unsigned long flags;
 
-       pDevice->rx_buf_sz = PKT_BUF_SZ;
-       if (!device_init_rings(pDevice))
-               return -ENOMEM;
+       MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr);
 
-//2008-5-13 <add> by chester
-       i = request_irq(pDevice->pcid->irq, &device_intr, IRQF_SHARED, dev->name, dev);
-       if (i)
-               return i;
-
-#ifdef WPA_SM_Transtatus
-       memset(wpa_Result.ifname, 0, sizeof(wpa_Result.ifname));
-       wpa_Result.proto = 0;
-       wpa_Result.key_mgmt = 0;
-       wpa_Result.eap_type = 0;
-       wpa_Result.authenticated = false;
-       pDevice->fWPA_Authened = false;
-#endif
-       pr_debug("call device init rd0 ring\n");
-       device_init_rd0_ring(pDevice);
-       device_init_rd1_ring(pDevice);
-       device_init_defrag_cb(pDevice);
-       device_init_td0_ring(pDevice);
-       device_init_td1_ring(pDevice);
+       if (pDevice->dwIsr == 0)
+               return IRQ_RETVAL(handled);
 
-       if (pDevice->bDiversityRegCtlON)
-               device_init_diversity_timer(pDevice);
+       if (pDevice->dwIsr == 0xffffffff) {
+               pr_debug("dwIsr = 0xffff\n");
+               return IRQ_RETVAL(handled);
+       }
 
-       vMgrObjectInit(pDevice);
-       vMgrTimerInit(pDevice);
+       handled = 1;
+       MACvIntDisable(pDevice->PortOffset);
 
-       pr_debug("call device_init_registers\n");
-       device_init_registers(pDevice);
+       spin_lock_irqsave(&pDevice->lock, flags);
 
-       MACvReadEtherAddress(pDevice->PortOffset, pDevice->abyCurrentNetAddr);
-       memcpy(pDevice->pMgmt->abyMACAddr, pDevice->abyCurrentNetAddr, ETH_ALEN);
-       device_set_multi(pDevice->dev);
+       //Make sure current page is 0
+       VNSvInPortB(pDevice->PortOffset + MAC_REG_PAGE1SEL, &byOrgPageSel);
+       if (byOrgPageSel == 1)
+               MACvSelectPage0(pDevice->PortOffset);
+       else
+               byOrgPageSel = 0;
 
-       // Init for Key Management
-       KeyvInitTable(&pDevice->sKey, pDevice->PortOffset);
-       add_timer(&(pDevice->pMgmt->sTimerSecondCallback));
+       MACvReadMIBCounter(pDevice->PortOffset, &dwMIBCounter);
+       // TBD....
+       // Must do this after doing rx/tx, cause ISR bit is slow
+       // than RD/TD write back
+       // update ISR counter
+       STAvUpdate802_11Counter(&pDevice->s802_11Counter, &pDevice->scStatistic , dwMIBCounter);
+       while (pDevice->dwIsr != 0) {
+               STAvUpdateIsrStatCounter(&pDevice->scStatistic, pDevice->dwIsr);
+               MACvWriteISR(pDevice->PortOffset, pDevice->dwIsr);
 
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-       pDevice->bwextcount = 0;
-       pDevice->bWPASuppWextEnabled = false;
-#endif
-       pDevice->byReAssocCount = 0;
-       pDevice->bWPADEVUp = false;
-       // Patch: if WEP key already set by iwconfig but device not yet open
-       if (pDevice->bEncryptionEnable && pDevice->bTransmitKey) {
-               KeybSetDefaultKey(&(pDevice->sKey),
-                                 (unsigned long)(pDevice->byKeyIndex | (1 << 31)),
-                                 pDevice->uKeyLength,
-                                 NULL,
-                                 pDevice->abyKey,
-                                 KEY_CTL_WEP,
-                                 pDevice->PortOffset,
-                                 pDevice->byLocalID
-                       );
-               pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
-       }
+               if (pDevice->dwIsr & ISR_FETALERR) {
+                       pr_debug(" ISR_FETALERR\n");
+                       VNSvOutPortB(pDevice->PortOffset + MAC_REG_SOFTPWRCTL, 0);
+                       VNSvOutPortW(pDevice->PortOffset + MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPECTI);
+                       device_error(pDevice, pDevice->dwIsr);
+               }
 
-       pr_debug("call MACvIntEnable\n");
-       MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
+               if (pDevice->dwIsr & ISR_TBTT) {
+                       if (pDevice->vif &&
+                           pDevice->op_mode != NL80211_IFTYPE_ADHOC) {
+                               if (pDevice->bUpdateBBVGA &&
+                                   !(pDevice->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) &&
+                                   pDevice->vif->bss_conf.assoc &&
+                                   pDevice->uCurrRSSI) {
+                                       long            ldBm;
 
-       if (pDevice->pMgmt->eConfigMode == WMAC_CONFIG_AP) {
-               bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL);
-       } else {
-               bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL);
-               bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL);
-       }
-       pDevice->flags |= DEVICE_FLAGS_OPENED;
+                                       RFvRSSITodBm(pDevice, (unsigned char) pDevice->uCurrRSSI, &ldBm);
+                                       for (ii = 0; ii < BB_VGA_LEVEL; ii++) {
+                                               if (ldBm < pDevice->ldBmThreshold[ii]) {
+                                                       pDevice->byBBVGANew = pDevice->abyBBVGA[ii];
+                                                       break;
+                                               }
+                                       }
+                                       if (pDevice->byBBVGANew != pDevice->byBBVGACurrent) {
+                                               pDevice->uBBVGADiffCount++;
+                                               if (pDevice->uBBVGADiffCount == 1) {
+                                                       // first VGA diff gain
+                                                       BBvSetVGAGainOffset(pDevice, pDevice->byBBVGANew);
+                                                       pr_debug("First RSSI[%d] NewGain[%d] OldGain[%d] Count[%d]\n",
+                                                                (int)ldBm,
+                                                                pDevice->byBBVGANew,
+                                                                pDevice->byBBVGACurrent,
+                                                                (int)pDevice->uBBVGADiffCount);
+                                               }
+                                               if (pDevice->uBBVGADiffCount >= BB_VGA_CHANGE_THRESHOLD) {
+                                                       pr_debug("RSSI[%d] NewGain[%d] OldGain[%d] Count[%d]\n",
+                                                                (int)ldBm,
+                                                                pDevice->byBBVGANew,
+                                                                pDevice->byBBVGACurrent,
+                                                                (int)pDevice->uBBVGADiffCount);
+                                                       BBvSetVGAGainOffset(pDevice, pDevice->byBBVGANew);
+                                               }
+                                       } else {
+                                               pDevice->uBBVGADiffCount = 1;
+                                       }
+                               }
+                       }
 
-       pr_debug("device_open success..\n");
-       return 0;
-}
+                       pDevice->bBeaconSent = false;
+                       if (pDevice->bEnablePSMode)
+                               PSbIsNextTBTTWakeUp((void *)pDevice);
 
-static int  device_close(struct net_device *dev)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject     pMgmt = pDevice->pMgmt;
-//2007-1121-02<Add>by EinsnLiu
-       if (pDevice->bLinkPass) {
-               bScheduleCommand((void *)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
-               mdelay(30);
-       }
+                       if ((pDevice->op_mode == NL80211_IFTYPE_AP ||
+                           pDevice->op_mode == NL80211_IFTYPE_ADHOC) &&
+                           pDevice->vif->bss_conf.enable_beacon) {
+                               MACvOneShotTimer1MicroSec(pDevice->PortOffset,
+                                                         (pDevice->vif->bss_conf.beacon_int - MAKE_BEACON_RESERVED) << 10);
+                       }
 
-       del_timer(&pDevice->sTimerTxData);
-       del_timer(&pDevice->sTimerCommand);
-       del_timer(&pMgmt->sTimerSecondCallback);
-       if (pDevice->bDiversityRegCtlON) {
-               del_timer(&pDevice->TimerSQ3Tmax1);
-               del_timer(&pDevice->TimerSQ3Tmax2);
-               del_timer(&pDevice->TimerSQ3Tmax3);
-       }
+                       /* TODO: adhoc PS mode */
 
-       netif_stop_queue(dev);
-       pDevice->bCmdRunning = false;
-       MACbShutdown(pDevice->PortOffset);
-       MACbSoftwareReset(pDevice->PortOffset);
-       CARDbRadioPowerOff(pDevice);
-
-       pDevice->bLinkPass = false;
-       memset(pMgmt->abyCurrBSSID, 0, 6);
-       pMgmt->eCurrState = WMAC_STATE_IDLE;
-       device_free_td0_ring(pDevice);
-       device_free_td1_ring(pDevice);
-       device_free_rd0_ring(pDevice);
-       device_free_rd1_ring(pDevice);
-       device_free_frag_buf(pDevice);
-       device_free_rings(pDevice);
-       BSSvClearNodeDBTable(pDevice, 0);
-       free_irq(dev->irq, dev);
-       pDevice->flags &= (~DEVICE_FLAGS_OPENED);
-       //2008-0714-01<Add>by chester
-       device_release_WPADEV(pDevice);
-
-       pr_debug("device_close..\n");
-       return 0;
-}
+               }
 
-static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       unsigned char *pbMPDU;
-       unsigned int cbMPDULen = 0;
-
-       pr_debug("device_dma0_tx_80211\n");
-       spin_lock_irq(&pDevice->lock);
-
-       if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 0) {
-               pr_debug("device_dma0_tx_80211, td0 <=0\n");
-               dev_kfree_skb_irq(skb);
-               spin_unlock_irq(&pDevice->lock);
-               return 0;
-       }
-
-       if (pDevice->bStopTx0Pkt) {
-               dev_kfree_skb_irq(skb);
-               spin_unlock_irq(&pDevice->lock);
-               return 0;
-       }
-
-       cbMPDULen = skb->len;
-       pbMPDU = skb->data;
-
-       vDMA0_tx_80211(pDevice, skb, pbMPDU, cbMPDULen);
-
-       spin_unlock_irq(&pDevice->lock);
-
-       return 0;
-}
-
-bool device_dma0_xmit(struct vnt_private *pDevice,
-                     struct sk_buff *skb, unsigned int uNodeIndex)
-{
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       PSTxDesc        pHeadTD, pLastTD;
-       unsigned int cbFrameBodySize;
-       unsigned int uMACfragNum;
-       unsigned char byPktType;
-       bool bNeedEncryption = false;
-       PSKeyItem       pTransmitKey = NULL;
-       unsigned int cbHeaderSize;
-       unsigned int ii;
-       SKeyItem        STempKey;
-
-       if (pDevice->bStopTx0Pkt) {
-               dev_kfree_skb_irq(skb);
-               return false;
-       }
-
-       if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 0) {
-               dev_kfree_skb_irq(skb);
-               pr_debug("device_dma0_xmit, td0 <=0\n");
-               return false;
-       }
+               if (pDevice->dwIsr & ISR_BNTX) {
+                       if (pDevice->op_mode == NL80211_IFTYPE_ADHOC) {
+                               pDevice->bIsBeaconBufReadySet = false;
+                               pDevice->cbBeaconBufReadySetCnt = 0;
+                       }
 
-       if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
-               if (pDevice->uAssocCount == 0) {
-                       dev_kfree_skb_irq(skb);
-                       pr_debug("device_dma0_xmit, assocCount = 0\n");
-                       return false;
+                       pDevice->bBeaconSent = true;
                }
-       }
-
-       pHeadTD = pDevice->apCurrTD[TYPE_TXDMA0];
 
-       pHeadTD->m_td1TD1.byTCR = (TCR_EDP|TCR_STP);
-
-       memcpy(pDevice->sTxEthHeader.abyDstAddr, (unsigned char *)(skb->data), ETH_HLEN);
-       cbFrameBodySize = skb->len - ETH_HLEN;
+               if (pDevice->dwIsr & ISR_RXDMA0)
+                       max_count += device_rx_srv(pDevice, TYPE_RXDMA0);
 
-       // 802.1H
-       if (ntohs(pDevice->sTxEthHeader.wType) > ETH_DATA_LEN)
-               cbFrameBodySize += 8;
+               if (pDevice->dwIsr & ISR_RXDMA1)
+                       max_count += device_rx_srv(pDevice, TYPE_RXDMA1);
 
-       uMACfragNum = cbGetFragCount(pDevice, pTransmitKey, cbFrameBodySize, &pDevice->sTxEthHeader);
+               if (pDevice->dwIsr & ISR_TXDMA0)
+                       max_count += device_tx_srv(pDevice, TYPE_TXDMA0);
 
-       if (uMACfragNum > AVAIL_TD(pDevice, TYPE_TXDMA0)) {
-               dev_kfree_skb_irq(skb);
-               return false;
-       }
-       byPktType = (unsigned char)pDevice->byPacketType;
+               if (pDevice->dwIsr & ISR_AC0DMA)
+                       max_count += device_tx_srv(pDevice, TYPE_AC0DMA);
 
-       if (pDevice->bFixRate) {
-               if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
-                       if (pDevice->uConnectionRate >= RATE_11M)
-                               pDevice->wCurrentRate = RATE_11M;
-                       else
-                               pDevice->wCurrentRate = (unsigned short)pDevice->uConnectionRate;
-               } else {
-                       if (pDevice->uConnectionRate >= RATE_54M)
-                               pDevice->wCurrentRate = RATE_54M;
-                       else
-                               pDevice->wCurrentRate = (unsigned short)pDevice->uConnectionRate;
+               if (pDevice->dwIsr & ISR_SOFTTIMER1) {
+                       if (pDevice->vif) {
+                               if (pDevice->vif->bss_conf.enable_beacon)
+                                       vnt_beacon_make(pDevice, pDevice->vif);
+                       }
                }
-       } else {
-               pDevice->wCurrentRate = pDevice->pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate;
-       }
-
-       //preamble type
-       if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble)
-               pDevice->byPreambleType = pDevice->byShortPreamble;
-       else
-               pDevice->byPreambleType = PREAMBLE_LONG;
-
-       pr_debug("dma0: pDevice->wCurrentRate = %d\n", pDevice->wCurrentRate);
-
-       if (pDevice->wCurrentRate <= RATE_11M) {
-               byPktType = PK_TYPE_11B;
-       } else if (pDevice->eCurrentPHYType == PHY_TYPE_11A) {
-               byPktType = PK_TYPE_11A;
-       } else {
-               if (pDevice->bProtectMode)
-                       byPktType = PK_TYPE_11GB;
-               else
-                       byPktType = PK_TYPE_11GA;
-       }
 
-       if (pDevice->bEncryptionEnable)
-               bNeedEncryption = true;
-
-       if (pDevice->bEnableHostWEP) {
-               pTransmitKey = &STempKey;
-               pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite;
-               pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex;
-               pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength;
-               pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16;
-               pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0;
-               memcpy(pTransmitKey->abyKey,
-                      &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0],
-                      pTransmitKey->uKeyLength
-                       );
-       }
-       vGenerateFIFOHeader(pDevice, byPktType, pDevice->pbyTmpBuff, bNeedEncryption,
-                           cbFrameBodySize, TYPE_TXDMA0, pHeadTD,
-                           &pDevice->sTxEthHeader, (unsigned char *)skb->data, pTransmitKey, uNodeIndex,
-                           &uMACfragNum,
-                           &cbHeaderSize
-               );
+               MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr);
 
-       if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) {
-               // Disable PS
-               MACbPSWakeup(pDevice->PortOffset);
-       }
+               MACvReceive0(pDevice->PortOffset);
+               MACvReceive1(pDevice->PortOffset);
 
-       pDevice->bPWBitOn = false;
-
-       pLastTD = pHeadTD;
-       for (ii = 0; ii < uMACfragNum; ii++) {
-               // Poll Transmit the adapter
-               wmb();
-               pHeadTD->m_td0TD0.f1Owner = OWNED_BY_NIC;
-               wmb();
-               if (ii == (uMACfragNum - 1))
-                       pLastTD = pHeadTD;
-               pHeadTD = pHeadTD->next;
+               if (max_count > pDevice->sOpts.int_works)
+                       break;
        }
 
-       // Save the information needed by the tx interrupt handler
-       // to complete the Send request
-       pLastTD->pTDInfo->skb = skb;
-       pLastTD->pTDInfo->byFlags = 0;
-       pLastTD->pTDInfo->byFlags |= TD_FLAGS_NETIF_SKB;
+       if (byOrgPageSel == 1)
+               MACvSelectPage1(pDevice->PortOffset);
 
-       pDevice->apCurrTD[TYPE_TXDMA0] = pHeadTD;
+       spin_unlock_irqrestore(&pDevice->lock, flags);
 
-       MACvTransmit0(pDevice->PortOffset);
+       MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
 
-       return true;
+       return IRQ_RETVAL(handled);
 }
 
-//TYPE_AC0DMA data tx
-static int  device_xmit(struct sk_buff *skb, struct net_device *dev) {
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       PSTxDesc        pHeadTD, pLastTD;
-       unsigned int uNodeIndex = 0;
-       unsigned char byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
-       unsigned short wAID;
-       unsigned int uMACfragNum = 1;
-       unsigned int cbFrameBodySize;
-       unsigned char byPktType;
-       unsigned int cbHeaderSize;
-       bool bNeedEncryption = false;
-       PSKeyItem       pTransmitKey = NULL;
-       SKeyItem        STempKey;
-       unsigned int ii;
-       bool bTKIP_UseGTK = false;
-       bool bNeedDeAuth = false;
-       unsigned char *pbyBSSID;
-       bool bNodeExist = false;
-
-       spin_lock_irq(&pDevice->lock);
-       if (!pDevice->bLinkPass) {
-               dev_kfree_skb_irq(skb);
-               spin_unlock_irq(&pDevice->lock);
-               return 0;
-       }
-
-       if (pDevice->bStopDataPkt) {
-               dev_kfree_skb_irq(skb);
-               spin_unlock_irq(&pDevice->lock);
-               return 0;
-       }
-
-       if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
-               if (pDevice->uAssocCount == 0) {
-                       dev_kfree_skb_irq(skb);
-                       spin_unlock_irq(&pDevice->lock);
-                       return 0;
-               }
-               if (is_multicast_ether_addr((unsigned char *)(skb->data))) {
-                       uNodeIndex = 0;
-                       bNodeExist = true;
-                       if (pMgmt->sNodeDBTable[0].bPSEnable) {
-                               skb_queue_tail(&(pMgmt->sNodeDBTable[0].sTxPSQueue), skb);
-                               pMgmt->sNodeDBTable[0].wEnQueueCnt++;
-                               // set tx map
-                               pMgmt->abyPSTxMap[0] |= byMask[0];
-                               spin_unlock_irq(&pDevice->lock);
-                               return 0;
-                       }
-               } else {
-                       if (BSSDBbIsSTAInNodeDB(pMgmt, (unsigned char *)(skb->data), &uNodeIndex)) {
-                               if (pMgmt->sNodeDBTable[uNodeIndex].bPSEnable) {
-                                       skb_queue_tail(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue, skb);
-                                       pMgmt->sNodeDBTable[uNodeIndex].wEnQueueCnt++;
-                                       // set tx map
-                                       wAID = pMgmt->sNodeDBTable[uNodeIndex].wAID;
-                                       pMgmt->abyPSTxMap[wAID >> 3] |=  byMask[wAID & 7];
-                                       pr_debug("Set:pMgmt->abyPSTxMap[%d]= %d\n",
-                                                (wAID >> 3),
-                                                pMgmt->abyPSTxMap[wAID >> 3]);
-                                       spin_unlock_irq(&pDevice->lock);
-                                       return 0;
-                               }
-
-                               if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble)
-                                       pDevice->byPreambleType = pDevice->byShortPreamble;
-                               else
-                                       pDevice->byPreambleType = PREAMBLE_LONG;
-
-                               bNodeExist = true;
-
-                       }
-               }
-
-               if (!bNodeExist) {
-                       pr_debug("Unknown STA not found in node DB\n");
-                       dev_kfree_skb_irq(skb);
-                       spin_unlock_irq(&pDevice->lock);
-                       return 0;
-               }
-       }
-
-       pHeadTD = pDevice->apCurrTD[TYPE_AC0DMA];
-
-       pHeadTD->m_td1TD1.byTCR = (TCR_EDP|TCR_STP);
-
-       memcpy(pDevice->sTxEthHeader.abyDstAddr, (unsigned char *)(skb->data), ETH_HLEN);
-       cbFrameBodySize = skb->len - ETH_HLEN;
-       // 802.1H
-       if (ntohs(pDevice->sTxEthHeader.wType) > ETH_DATA_LEN)
-               cbFrameBodySize += 8;
-
-       if (pDevice->bEncryptionEnable) {
-               bNeedEncryption = true;
-               // get Transmit key
-               do {
-                       if ((pDevice->pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
-                           (pDevice->pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
-                               pbyBSSID = pDevice->abyBSSID;
-                               // get pairwise key
-                               if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == false) {
-                                       // get group key
-                                       if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == true) {
-                                               bTKIP_UseGTK = true;
-                                               pr_debug("Get GTK\n");
-                                               break;
-                                       }
-                               } else {
-                                       pr_debug("Get PTK\n");
-                                       break;
-                               }
-                       } else if (pDevice->pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
-                               pbyBSSID = pDevice->sTxEthHeader.abyDstAddr;  //TO_DS = 0 and FROM_DS = 0 --> 802.11 MAC Address1
-                               pr_debug("IBSS Serach Key:\n");
-                               for (ii = 0; ii < 6; ii++)
-                                       pr_debug("%x\n", *(pbyBSSID+ii));
-                               pr_debug("\n");
-
-                               // get pairwise key
-                               if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == true)
-                                       break;
-                       }
-                       // get group key
-                       pbyBSSID = pDevice->abyBroadcastAddr;
-                       if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == false) {
-                               pTransmitKey = NULL;
-                               if (pDevice->pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)
-                                       pr_debug("IBSS and KEY is NULL. [%d]\n",
-                                                pDevice->pMgmt->eCurrMode);
-                               else
-                                       pr_debug("NOT IBSS and KEY is NULL. [%d]\n",
-                                                pDevice->pMgmt->eCurrMode);
-                       } else {
-                               bTKIP_UseGTK = true;
-                               pr_debug("Get GTK\n");
-                       }
-               } while (false);
-       }
-
-       if (pDevice->bEnableHostWEP) {
-               pr_debug("acdma0: STA index %d\n", uNodeIndex);
-               if (pDevice->bEncryptionEnable) {
-                       pTransmitKey = &STempKey;
-                       pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite;
-                       pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex;
-                       pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength;
-                       pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16;
-                       pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0;
-                       memcpy(pTransmitKey->abyKey,
-                              &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0],
-                              pTransmitKey->uKeyLength
-                               );
-               }
-       }
-
-       uMACfragNum = cbGetFragCount(pDevice, pTransmitKey, cbFrameBodySize, &pDevice->sTxEthHeader);
-
-       if (uMACfragNum > AVAIL_TD(pDevice, TYPE_AC0DMA)) {
-               pr_debug("uMACfragNum > AVAIL_TD(TYPE_AC0DMA) = %d\n",
-                        uMACfragNum);
-               dev_kfree_skb_irq(skb);
-               spin_unlock_irq(&pDevice->lock);
-               return 0;
-       }
-
-       if (pTransmitKey != NULL) {
-               if ((pTransmitKey->byCipherSuite == KEY_CTL_WEP) &&
-                   (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN)) {
-                       uMACfragNum = 1; //WEP256 doesn't support fragment
-               }
-       }
+static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
+{
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+       PSTxDesc head_td;
+       u32 dma_idx = TYPE_AC0DMA;
+       unsigned long flags;
 
-       byPktType = (unsigned char)pDevice->byPacketType;
+       spin_lock_irqsave(&priv->lock, flags);
 
-       if (pDevice->bFixRate) {
-               if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
-                       if (pDevice->uConnectionRate >= RATE_11M)
-                               pDevice->wCurrentRate = RATE_11M;
-                       else
-                               pDevice->wCurrentRate = (unsigned short)pDevice->uConnectionRate;
-               } else {
-                       if ((pDevice->eCurrentPHYType == PHY_TYPE_11A) &&
-                           (pDevice->uConnectionRate <= RATE_6M)) {
-                               pDevice->wCurrentRate = RATE_6M;
-                       } else {
-                               if (pDevice->uConnectionRate >= RATE_54M)
-                                       pDevice->wCurrentRate = RATE_54M;
-                               else
-                                       pDevice->wCurrentRate = (unsigned short)pDevice->uConnectionRate;
-
-                       }
-               }
-               pDevice->byACKRate = (unsigned char) pDevice->wCurrentRate;
-               pDevice->byTopCCKBasicRate = RATE_1M;
-               pDevice->byTopOFDMBasicRate = RATE_6M;
-       } else {
-               //auto rate
-               if (pDevice->sTxEthHeader.wType == TYPE_PKT_802_1x) {
-                       if (pDevice->eCurrentPHYType != PHY_TYPE_11A) {
-                               pDevice->wCurrentRate = RATE_1M;
-                               pDevice->byACKRate = RATE_1M;
-                               pDevice->byTopCCKBasicRate = RATE_1M;
-                               pDevice->byTopOFDMBasicRate = RATE_6M;
-                       } else {
-                               pDevice->wCurrentRate = RATE_6M;
-                               pDevice->byACKRate = RATE_6M;
-                               pDevice->byTopCCKBasicRate = RATE_1M;
-                               pDevice->byTopOFDMBasicRate = RATE_6M;
-                       }
-               } else {
-                       VNTWIFIvGetTxRate(pDevice->pMgmt,
-                                         pDevice->sTxEthHeader.abyDstAddr,
-                                         &(pDevice->wCurrentRate),
-                                         &(pDevice->byACKRate),
-                                         &(pDevice->byTopCCKBasicRate),
-                                         &(pDevice->byTopOFDMBasicRate));
+       if (!ieee80211_is_data(hdr->frame_control))
+               dma_idx = TYPE_TXDMA0;
 
-               }
+       if (AVAIL_TD(priv, dma_idx) < 1) {
+               spin_unlock_irqrestore(&priv->lock, flags);
+               return -ENOMEM;
        }
 
+       head_td = priv->apCurrTD[dma_idx];
 
-       if (pDevice->wCurrentRate <= RATE_11M) {
-               byPktType = PK_TYPE_11B;
-       } else if (pDevice->eCurrentPHYType == PHY_TYPE_11A) {
-               byPktType = PK_TYPE_11A;
-       } else {
-               if (pDevice->bProtectMode)
-                       byPktType = PK_TYPE_11GB;
-               else
-                       byPktType = PK_TYPE_11GA;
-       }
+       head_td->m_td1TD1.byTCR = (TCR_EDP|TCR_STP);
 
-       if (bNeedEncryption) {
-               pr_debug("ntohs Pkt Type=%04x\n",
-                        ntohs(pDevice->sTxEthHeader.wType));
-               if ((pDevice->sTxEthHeader.wType) == TYPE_PKT_802_1x) {
-                       bNeedEncryption = false;
-                       pr_debug("Pkt Type=%04x\n",
-                                (pDevice->sTxEthHeader.wType));
-                       if ((pDevice->pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pDevice->pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
-                               if (pTransmitKey == NULL) {
-                                       pr_debug("Don't Find TX KEY\n");
-                               } else {
-                                       if (bTKIP_UseGTK) {
-                                               pr_debug("error: KEY is GTK!!~~\n");
-                                       } else {
-                                               pr_debug("Find PTK [%lX]\n",
-                                                        pTransmitKey->dwKeyIndex);
-                                               bNeedEncryption = true;
-                                       }
-                               }
-                       }
+       head_td->pTDInfo->skb = skb;
 
-                       if (pDevice->byCntMeasure == 2) {
-                               bNeedDeAuth = true;
-                               pDevice->s802_11Counter.TKIPCounterMeasuresInvoked++;
-                       }
+       priv->iTDUsed[dma_idx]++;
 
-                       if (pDevice->bEnableHostWEP) {
-                               if ((uNodeIndex != 0) &&
-                                   (pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex & PAIRWISE_KEY)) {
-                                       pr_debug("Find PTK [%lX]\n",
-                                                pTransmitKey->dwKeyIndex);
-                                       bNeedEncryption = true;
-                               }
-                       }
-               } else {
-                       if (pTransmitKey == NULL) {
-                               pr_debug("return no tx key\n");
-                               dev_kfree_skb_irq(skb);
-                               spin_unlock_irq(&pDevice->lock);
-                               return 0;
-                       }
-               }
-       }
+       /* Take ownership */
+       wmb();
+       head_td->m_td0TD0.f1Owner = OWNED_BY_NIC;
 
-       vGenerateFIFOHeader(pDevice, byPktType, pDevice->pbyTmpBuff, bNeedEncryption,
-                           cbFrameBodySize, TYPE_AC0DMA, pHeadTD,
-                           &pDevice->sTxEthHeader, (unsigned char *)skb->data, pTransmitKey, uNodeIndex,
-                           &uMACfragNum,
-                           &cbHeaderSize
-               );
+       /* get Next */
+       wmb();
+       priv->apCurrTD[dma_idx] = head_td->next;
 
-       if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) {
-               // Disable PS
-               MACbPSWakeup(pDevice->PortOffset);
-       }
-       pDevice->bPWBitOn = false;
-
-       pLastTD = pHeadTD;
-       for (ii = 0; ii < uMACfragNum; ii++) {
-               // Poll Transmit the adapter
-               wmb();
-               pHeadTD->m_td0TD0.f1Owner = OWNED_BY_NIC;
-               wmb();
-               if (ii == uMACfragNum - 1)
-                       pLastTD = pHeadTD;
-               pHeadTD = pHeadTD->next;
-       }
+       spin_unlock_irqrestore(&priv->lock, flags);
 
-       // Save the information needed by the tx interrupt handler
-       // to complete the Send request
-       pLastTD->pTDInfo->skb = skb;
-       pLastTD->pTDInfo->byFlags = 0;
-       pLastTD->pTDInfo->byFlags |= TD_FLAGS_NETIF_SKB;
-       pDevice->nTxDataTimeCout = 0; //2008-8-21 chester <add> for send null packet
+       vnt_generate_fifo_header(priv, dma_idx, head_td, skb);
 
-       if (AVAIL_TD(pDevice, TYPE_AC0DMA) <= 1)
-               netif_stop_queue(dev);
+       if (MACbIsRegBitsOn(priv->PortOffset, MAC_REG_PSCTL, PSCTL_PS))
+               MACbPSWakeup(priv->PortOffset);
 
-       pDevice->apCurrTD[TYPE_AC0DMA] = pHeadTD;
+       spin_lock_irqsave(&priv->lock, flags);
 
-       if (pDevice->bFixRate)
-               pr_debug("FixRate:Rate is %d,TxPower is %d\n", pDevice->wCurrentRate, pDevice->byCurPwr);
+       priv->bPWBitOn = false;
 
-       {
-               unsigned char Protocol_Version;    //802.1x Authentication
-               unsigned char Packet_Type;           //802.1x Authentication
-               unsigned char Descriptor_type;
-               unsigned short Key_info;
-               bool bTxeapol_key = false;
-
-               Protocol_Version = skb->data[ETH_HLEN];
-               Packet_Type = skb->data[ETH_HLEN+1];
-               Descriptor_type = skb->data[ETH_HLEN+1+1+2];
-               Key_info = (skb->data[ETH_HLEN+1+1+2+1] << 8)|(skb->data[ETH_HLEN+1+1+2+2]);
-               if (pDevice->sTxEthHeader.wType == TYPE_PKT_802_1x) {
-                       if (((Protocol_Version == 1) || (Protocol_Version == 2)) &&
-                           (Packet_Type == 3)) {  //802.1x OR eapol-key challenge frame transfer
-                               bTxeapol_key = true;
-                               if ((Descriptor_type == 254) || (Descriptor_type == 2)) {       //WPA or RSN
-                                       if (!(Key_info & BIT3) &&   //group-key challenge
-                                           (Key_info & BIT8) && (Key_info & BIT9)) {    //send 2/2 key
-                                               pDevice->fWPA_Authened = true;
-                                               if (Descriptor_type == 254)
-                                                       pr_debug("WPA ");
-                                               else
-                                                       pr_debug("WPA2 ");
-                                               pr_debug("Authentication completed!!\n");
-                                       }
-                               }
-                       }
-               }
-       }
+       head_td->pTDInfo->byFlags = TD_FLAGS_NETIF_SKB;
 
-       MACvTransmitAC0(pDevice->PortOffset);
+       if (dma_idx == TYPE_AC0DMA)
+               MACvTransmitAC0(priv->PortOffset);
+       else
+               MACvTransmit0(priv->PortOffset);
 
-       dev->trans_start = jiffies;
+       spin_unlock_irqrestore(&priv->lock, flags);
 
-       spin_unlock_irq(&pDevice->lock);
        return 0;
 }
 
-static  irqreturn_t  device_intr(int irq,  void *dev_instance)
+static void vnt_tx_80211(struct ieee80211_hw *hw,
+                        struct ieee80211_tx_control *control,
+                        struct sk_buff *skb)
 {
-       struct net_device *dev = dev_instance;
-       struct vnt_private *pDevice = netdev_priv(dev);
-       int             max_count = 0;
-       unsigned long dwMIBCounter = 0;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       unsigned char byOrgPageSel = 0;
-       int             handled = 0;
-       unsigned char byData = 0;
-       int             ii = 0;
-       unsigned long flags;
+       struct vnt_private *priv = hw->priv;
 
-       MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr);
+       ieee80211_stop_queues(hw);
 
-       if (pDevice->dwIsr == 0)
-               return IRQ_RETVAL(handled);
+       if (vnt_tx_packet(priv, skb)) {
+               ieee80211_free_txskb(hw, skb);
 
-       if (pDevice->dwIsr == 0xffffffff) {
-               pr_debug("dwIsr = 0xffff\n");
-               return IRQ_RETVAL(handled);
+               ieee80211_wake_queues(hw);
        }
+}
 
-       handled = 1;
-       MACvIntDisable(pDevice->PortOffset);
-
-       spin_lock_irqsave(&pDevice->lock, flags);
-
-       //Make sure current page is 0
-       VNSvInPortB(pDevice->PortOffset + MAC_REG_PAGE1SEL, &byOrgPageSel);
-       if (byOrgPageSel == 1)
-               MACvSelectPage0(pDevice->PortOffset);
-       else
-               byOrgPageSel = 0;
-
-       MACvReadMIBCounter(pDevice->PortOffset, &dwMIBCounter);
-       // TBD....
-       // Must do this after doing rx/tx, cause ISR bit is slow
-       // than RD/TD write back
-       // update ISR counter
-       STAvUpdate802_11Counter(&pDevice->s802_11Counter, &pDevice->scStatistic , dwMIBCounter);
-       while (pDevice->dwIsr != 0) {
-               STAvUpdateIsrStatCounter(&pDevice->scStatistic, pDevice->dwIsr);
-               MACvWriteISR(pDevice->PortOffset, pDevice->dwIsr);
-
-               if (pDevice->dwIsr & ISR_FETALERR) {
-                       pr_debug(" ISR_FETALERR\n");
-                       VNSvOutPortB(pDevice->PortOffset + MAC_REG_SOFTPWRCTL, 0);
-                       VNSvOutPortW(pDevice->PortOffset + MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPECTI);
-                       device_error(pDevice, pDevice->dwIsr);
-               }
-
-               if (pDevice->byLocalID > REV_ID_VT3253_B1) {
-                       if (pDevice->dwIsr & ISR_MEASURESTART) {
-                               // 802.11h measure start
-                               pDevice->byOrgChannel = pDevice->byCurrentCh;
-                               VNSvInPortB(pDevice->PortOffset + MAC_REG_RCR, &(pDevice->byOrgRCR));
-                               VNSvOutPortB(pDevice->PortOffset + MAC_REG_RCR, (RCR_RXALLTYPE | RCR_UNICAST | RCR_BROADCAST | RCR_MULTICAST | RCR_WPAERR));
-                               MACvSelectPage1(pDevice->PortOffset);
-                               VNSvInPortD(pDevice->PortOffset + MAC_REG_MAR0, &(pDevice->dwOrgMAR0));
-                               VNSvInPortD(pDevice->PortOffset + MAC_REG_MAR4, &(pDevice->dwOrgMAR4));
-                               MACvSelectPage0(pDevice->PortOffset);
-                               //xxxx
-                               if (set_channel(pDevice, pDevice->pCurrMeasureEID->sReq.byChannel)) {
-                                       pDevice->bMeasureInProgress = true;
-                                       MACvSelectPage1(pDevice->PortOffset);
-                                       MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_READY);
-                                       MACvSelectPage0(pDevice->PortOffset);
-                                       pDevice->byBasicMap = 0;
-                                       pDevice->byCCAFraction = 0;
-                                       for (ii = 0; ii < 8; ii++)
-                                               pDevice->dwRPIs[ii] = 0;
-
-                               } else {
-                                       // can not measure because set channel fail
-                                       // clear measure control
-                                       MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN);
-                                       s_vCompleteCurrentMeasure(pDevice, MEASURE_MODE_INCAPABLE);
-                                       MACvSelectPage1(pDevice->PortOffset);
-                                       MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
-                                       MACvSelectPage0(pDevice->PortOffset);
-                               }
-                       }
-                       if (pDevice->dwIsr & ISR_MEASUREEND) {
-                               // 802.11h measure end
-                               pDevice->bMeasureInProgress = false;
-                               VNSvOutPortB(pDevice->PortOffset + MAC_REG_RCR, pDevice->byOrgRCR);
-                               MACvSelectPage1(pDevice->PortOffset);
-                               VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0, pDevice->dwOrgMAR0);
-                               VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR4, pDevice->dwOrgMAR4);
-                               VNSvInPortB(pDevice->PortOffset + MAC_REG_MSRBBSTS, &byData);
-                               pDevice->byBasicMap |= (byData >> 4);
-                               VNSvInPortB(pDevice->PortOffset + MAC_REG_CCAFRACTION, &pDevice->byCCAFraction);
-                               VNSvInPortB(pDevice->PortOffset + MAC_REG_MSRCTL, &byData);
-                               // clear measure control
-                               MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN);
-                               MACvSelectPage0(pDevice->PortOffset);
-                               set_channel(pDevice, pDevice->byOrgChannel);
-                               MACvSelectPage1(pDevice->PortOffset);
-                               MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
-                               MACvSelectPage0(pDevice->PortOffset);
-                               if (byData & MSRCTL_FINISH) {
-                                       // measure success
-                                       s_vCompleteCurrentMeasure(pDevice, 0);
-                               } else {
-                                       // can not measure because not ready before end of measure time
-                                       s_vCompleteCurrentMeasure(pDevice, MEASURE_MODE_LATE);
-                               }
-                       }
-                       if (pDevice->dwIsr & ISR_QUIETSTART) {
-                               do {
-                                       ;
-                               } while (!CARDbStartQuiet(pDevice));
-                       }
-               }
-
-               if (pDevice->dwIsr & ISR_TBTT) {
-                       if (pDevice->bEnableFirstQuiet) {
-                               pDevice->byQuietStartCount--;
-                               if (pDevice->byQuietStartCount == 0) {
-                                       pDevice->bEnableFirstQuiet = false;
-                                       MACvSelectPage1(pDevice->PortOffset);
-                                       MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN));
-                                       MACvSelectPage0(pDevice->PortOffset);
-                               }
-                       }
-                       if (pDevice->bChannelSwitch &&
-                           (pDevice->op_mode == NL80211_IFTYPE_STATION)) {
-                               pDevice->byChannelSwitchCount--;
-                               if (pDevice->byChannelSwitchCount == 0) {
-                                       pDevice->bChannelSwitch = false;
-                                       set_channel(pDevice, pDevice->byNewChannel);
-                                       VNTWIFIbChannelSwitch(pDevice->pMgmt, pDevice->byNewChannel);
-                                       MACvSelectPage1(pDevice->PortOffset);
-                                       MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
-                                       MACvSelectPage0(pDevice->PortOffset);
-                                       CARDbStartTxPacket(pDevice, PKT_TYPE_802_11_ALL);
-
-                               }
-                       }
-                       if (pDevice->op_mode != NL80211_IFTYPE_ADHOC) {
-                               if ((pDevice->bUpdateBBVGA) && pDevice->bLinkPass && (pDevice->uCurrRSSI != 0)) {
-                                       long            ldBm;
-
-                                       RFvRSSITodBm(pDevice, (unsigned char) pDevice->uCurrRSSI, &ldBm);
-                                       for (ii = 0; ii < BB_VGA_LEVEL; ii++) {
-                                               if (ldBm < pDevice->ldBmThreshold[ii]) {
-                                                       pDevice->byBBVGANew = pDevice->abyBBVGA[ii];
-                                                       break;
-                                               }
-                                       }
-                                       if (pDevice->byBBVGANew != pDevice->byBBVGACurrent) {
-                                               pDevice->uBBVGADiffCount++;
-                                               if (pDevice->uBBVGADiffCount == 1) {
-                                                       // first VGA diff gain
-                                                       BBvSetVGAGainOffset(pDevice, pDevice->byBBVGANew);
-                                                       pr_debug("First RSSI[%d] NewGain[%d] OldGain[%d] Count[%d]\n",
-                                                                (int)ldBm,
-                                                                pDevice->byBBVGANew,
-                                                                pDevice->byBBVGACurrent,
-                                                                (int)pDevice->uBBVGADiffCount);
-                                               }
-                                               if (pDevice->uBBVGADiffCount >= BB_VGA_CHANGE_THRESHOLD) {
-                                                       pr_debug("RSSI[%d] NewGain[%d] OldGain[%d] Count[%d]\n",
-                                                                (int)ldBm,
-                                                                pDevice->byBBVGANew,
-                                                                pDevice->byBBVGACurrent,
-                                                                (int)pDevice->uBBVGADiffCount);
-                                                       BBvSetVGAGainOffset(pDevice, pDevice->byBBVGANew);
-                                               }
-                                       } else {
-                                               pDevice->uBBVGADiffCount = 1;
-                                       }
-                               }
-                       }
-
-                       pDevice->bBeaconSent = false;
-                       if (pDevice->bEnablePSMode)
-                               PSbIsNextTBTTWakeUp((void *)pDevice);
-
-                       if ((pDevice->op_mode == NL80211_IFTYPE_AP) ||
-                           (pDevice->op_mode == NL80211_IFTYPE_ADHOC)) {
-                               MACvOneShotTimer1MicroSec(pDevice->PortOffset,
-                                                         (pMgmt->wIBSSBeaconPeriod - MAKE_BEACON_RESERVED) << 10);
-                       }
-
-                       /* TODO: adhoc PS mode */
-
-               }
-
-               if (pDevice->dwIsr & ISR_BNTX) {
-                       if (pDevice->op_mode == NL80211_IFTYPE_ADHOC) {
-                               pDevice->bIsBeaconBufReadySet = false;
-                               pDevice->cbBeaconBufReadySetCnt = 0;
-                       }
-
-                       if (pDevice->op_mode == NL80211_IFTYPE_AP) {
-                               if (pMgmt->byDTIMCount > 0) {
-                                       pMgmt->byDTIMCount--;
-                                       pMgmt->sNodeDBTable[0].bRxPSPoll = false;
-                               } else {
-                                       if (pMgmt->byDTIMCount == 0) {
-                                               // check if mutltcast tx bufferring
-                                               pMgmt->byDTIMCount = pMgmt->byDTIMPeriod - 1;
-                                               pMgmt->sNodeDBTable[0].bRxPSPoll = true;
-                                               bScheduleCommand((void *)pDevice, WLAN_CMD_RX_PSPOLL, NULL);
-                                       }
-                               }
-                       }
-                       pDevice->bBeaconSent = true;
-
-                       if (pDevice->bChannelSwitch) {
-                               pDevice->byChannelSwitchCount--;
-                               if (pDevice->byChannelSwitchCount == 0) {
-                                       pDevice->bChannelSwitch = false;
-                                       set_channel(pDevice, pDevice->byNewChannel);
-                                       VNTWIFIbChannelSwitch(pDevice->pMgmt, pDevice->byNewChannel);
-                                       MACvSelectPage1(pDevice->PortOffset);
-                                       MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
-                                       MACvSelectPage0(pDevice->PortOffset);
-                                       CARDbStartTxPacket(pDevice, PKT_TYPE_802_11_ALL);
-                               }
-                       }
-
-               }
+static int vnt_start(struct ieee80211_hw *hw)
+{
+       struct vnt_private *priv = hw->priv;
+       int ret;
 
-               if (pDevice->dwIsr & ISR_RXDMA0)
-                       max_count += device_rx_srv(pDevice, TYPE_RXDMA0);
+       priv->rx_buf_sz = PKT_BUF_SZ;
+       if (!device_init_rings(priv))
+               return -ENOMEM;
 
-               if (pDevice->dwIsr & ISR_RXDMA1)
-                       max_count += device_rx_srv(pDevice, TYPE_RXDMA1);
+       ret = request_irq(priv->pcid->irq, &device_intr,
+                         IRQF_SHARED, "vt6655", priv);
+       if (ret) {
+               dev_dbg(&priv->pcid->dev, "failed to start irq\n");
+               return ret;
+       }
 
-               if (pDevice->dwIsr & ISR_TXDMA0)
-                       max_count += device_tx_srv(pDevice, TYPE_TXDMA0);
+       dev_dbg(&priv->pcid->dev, "call device init rd0 ring\n");
+       device_init_rd0_ring(priv);
+       device_init_rd1_ring(priv);
+       device_init_defrag_cb(priv);
+       device_init_td0_ring(priv);
+       device_init_td1_ring(priv);
 
-               if (pDevice->dwIsr & ISR_AC0DMA)
-                       max_count += device_tx_srv(pDevice, TYPE_AC0DMA);
+       device_init_registers(priv);
 
-               if (pDevice->dwIsr & ISR_SOFTTIMER1) {
-                       if (pDevice->op_mode == NL80211_IFTYPE_AP) {
-                               if (pDevice->bShortSlotTime)
-                                       pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);
-                               else
-                                       pMgmt->wCurrCapInfo &= ~(WLAN_SET_CAP_INFO_SHORTSLOTTIME(1));
-                       }
-                       bMgrPrepareBeaconToSend(pDevice, pMgmt);
-                       pDevice->byCntMeasure = 0;
-               }
+       dev_dbg(&priv->pcid->dev, "call MACvIntEnable\n");
+       MACvIntEnable(priv->PortOffset, IMR_MASK_VALUE);
 
-               MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr);
+       ieee80211_wake_queues(hw);
 
-               MACvReceive0(pDevice->PortOffset);
-               MACvReceive1(pDevice->PortOffset);
+       return 0;
+}
 
-               if (max_count > pDevice->sOpts.int_works)
-                       break;
-       }
+static void vnt_stop(struct ieee80211_hw *hw)
+{
+       struct vnt_private *priv = hw->priv;
 
-       if (byOrgPageSel == 1)
-               MACvSelectPage1(pDevice->PortOffset);
+       ieee80211_stop_queues(hw);
 
-       spin_unlock_irqrestore(&pDevice->lock, flags);
+       MACbShutdown(priv->PortOffset);
+       MACbSoftwareReset(priv->PortOffset);
+       CARDbRadioPowerOff(priv);
 
-       MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
+       device_free_td0_ring(priv);
+       device_free_td1_ring(priv);
+       device_free_rd0_ring(priv);
+       device_free_rd1_ring(priv);
+       device_free_frag_buf(priv);
+       device_free_rings(priv);
 
-       return IRQ_RETVAL(handled);
+       free_irq(priv->pcid->irq, priv);
 }
 
-//2008-8-4 <add> by chester
-static int Config_FileGetParameter(unsigned char *string,
-                                  unsigned char *dest, unsigned char *source)
+static int vnt_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 {
-       unsigned char buf1[100];
-       int source_len = strlen(source);
+       struct vnt_private *priv = hw->priv;
 
-       memset(buf1, 0, 100);
-       strcat(buf1, string);
-       strcat(buf1, "=");
-       source += strlen(buf1);
+       priv->vif = vif;
 
-       memcpy(dest, source, source_len - strlen(buf1));
-       return true;
-}
+       switch (vif->type) {
+       case NL80211_IFTYPE_STATION:
+               if (priv->bDiversityRegCtlON)
+                       device_init_diversity_timer(priv);
+               break;
+       case NL80211_IFTYPE_ADHOC:
+               MACvRegBitsOff(priv->PortOffset, MAC_REG_RCR, RCR_UNICAST);
 
-int Config_FileOperation(struct vnt_private *pDevice,
-                        bool fwrite, unsigned char *Parameter)
-{
-       unsigned char *buffer = kmalloc(1024, GFP_KERNEL);
-       unsigned char tmpbuffer[20];
-       struct file *file;
-       int result = 0;
-
-       if (!buffer) {
-               pr_err("allocate mem for file fail?\n");
-               return -1;
-       }
-       file = filp_open(CONFIG_PATH, O_RDONLY, 0);
-       if (IS_ERR(file)) {
-               kfree(buffer);
-               pr_err("Config_FileOperation:open file fail?\n");
-               return -1;
-       }
+               MACvRegBitsOn(priv->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC);
 
-       if (kernel_read(file, 0, buffer, 1024) < 0) {
-               pr_err("read file error?\n");
-               result = -1;
-               goto error1;
-       }
+               break;
+       case NL80211_IFTYPE_AP:
+               MACvRegBitsOff(priv->PortOffset, MAC_REG_RCR, RCR_UNICAST);
+
+               MACvRegBitsOn(priv->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP);
 
-       if (Config_FileGetParameter("ZONETYPE", tmpbuffer, buffer) != true) {
-               pr_err("get parameter error?\n");
-               result = -1;
-               goto error1;
+               break;
+       default:
+               return -EOPNOTSUPP;
        }
 
-       if (memcmp(tmpbuffer, "USA", 3) == 0) {
-               result = ZoneType_USA;
-       } else if (memcmp(tmpbuffer, "JAPAN", 5) == 0) {
-               result = ZoneType_Japan;
-       } else if (memcmp(tmpbuffer, "EUROPE", 5) == 0) {
-               result = ZoneType_Europe;
-       } else {
-               result = -1;
-               pr_err("Unknown Zonetype[%s]?\n", tmpbuffer);
+       priv->op_mode = vif->type;
+
+       return 0;
+}
+
+static void vnt_remove_interface(struct ieee80211_hw *hw,
+                                struct ieee80211_vif *vif)
+{
+       struct vnt_private *priv = hw->priv;
+
+       switch (vif->type) {
+       case NL80211_IFTYPE_STATION:
+               if (priv->bDiversityRegCtlON) {
+                       del_timer(&priv->TimerSQ3Tmax1);
+                       del_timer(&priv->TimerSQ3Tmax2);
+                       del_timer(&priv->TimerSQ3Tmax3);
+               }
+               break;
+       case NL80211_IFTYPE_ADHOC:
+               MACvRegBitsOff(priv->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
+               MACvRegBitsOff(priv->PortOffset,
+                              MAC_REG_TFTCTL, TFTCTL_TSFCNTREN);
+               MACvRegBitsOff(priv->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC);
+               break;
+       case NL80211_IFTYPE_AP:
+               MACvRegBitsOff(priv->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
+               MACvRegBitsOff(priv->PortOffset,
+                              MAC_REG_TFTCTL, TFTCTL_TSFCNTREN);
+               MACvRegBitsOff(priv->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP);
+               break;
+       default:
+               break;
        }
 
-error1:
-       kfree(buffer);
-       fput(file);
-       return result;
+       priv->op_mode = NL80211_IFTYPE_UNSPECIFIED;
 }
 
-static void device_set_multi(struct net_device *dev) {
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject     pMgmt = pDevice->pMgmt;
-       u32              mc_filter[2];
-       struct netdev_hw_addr *ha;
 
-       VNSvInPortB(pDevice->PortOffset + MAC_REG_RCR, &(pDevice->byRxMode));
+static int vnt_config(struct ieee80211_hw *hw, u32 changed)
+{
+       struct vnt_private *priv = hw->priv;
+       struct ieee80211_conf *conf = &hw->conf;
+       u8 bb_type;
 
-       if (dev->flags & IFF_PROMISC) {         /* Set promiscuous. */
-               pr_notice("%s: Promiscuous mode enabled\n", dev->name);
-               /* Unconditionally log net taps. */
-               pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST|RCR_UNICAST);
-       } else if ((netdev_mc_count(dev) > pDevice->multicast_limit)
-                ||  (dev->flags & IFF_ALLMULTI)) {
-               MACvSelectPage1(pDevice->PortOffset);
-               VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0, 0xffffffff);
-               VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0 + 4, 0xffffffff);
-               MACvSelectPage0(pDevice->PortOffset);
-               pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
-       } else {
-               memset(mc_filter, 0, sizeof(mc_filter));
-               netdev_for_each_mc_addr(ha, dev) {
-                       int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
+       if (changed & IEEE80211_CONF_CHANGE_PS) {
+               if (conf->flags & IEEE80211_CONF_PS)
+                       PSvEnablePowerSaving(priv, conf->listen_interval);
+               else
+                       PSvDisablePowerSaving(priv);
+       }
+
+       if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) ||
+           (conf->flags & IEEE80211_CONF_OFFCHANNEL)) {
+               set_channel(priv, conf->chandef.chan->hw_value);
+
+               if (conf->chandef.chan->band == IEEE80211_BAND_5GHZ)
+                       bb_type = BB_TYPE_11A;
+               else
+                       bb_type = BB_TYPE_11G;
 
-                       mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31));
+               if (priv->byBBType != bb_type) {
+                       priv->byBBType = bb_type;
+
+                       CARDbSetPhyParameter(priv,
+                                            priv->byBBType, 0, 0, NULL, NULL);
                }
-               MACvSelectPage1(pDevice->PortOffset);
-               VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0, mc_filter[0]);
-               VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0 + 4, mc_filter[1]);
-               MACvSelectPage0(pDevice->PortOffset);
-               pDevice->byRxMode &= ~(RCR_UNICAST);
-               pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
        }
 
-       if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
-               // If AP mode, don't enable RCR_UNICAST. Since hw only compare addr1 with local mac.
-               pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
-               pDevice->byRxMode &= ~(RCR_UNICAST);
+       if (changed & IEEE80211_CONF_CHANGE_POWER) {
+               if (priv->byBBType == BB_TYPE_11B)
+                       priv->wCurrentRate = RATE_1M;
+               else
+                       priv->wCurrentRate = RATE_54M;
+
+               RFbSetPower(priv, priv->wCurrentRate,
+                           conf->chandef.chan->hw_value);
        }
 
-       VNSvOutPortB(pDevice->PortOffset + MAC_REG_RCR, pDevice->byRxMode);
-       pr_debug("pDevice->byRxMode = %x\n", pDevice->byRxMode);
+       return 0;
 }
 
-static int  device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+static void vnt_bss_info_changed(struct ieee80211_hw *hw,
+               struct ieee80211_vif *vif, struct ieee80211_bss_conf *conf,
+               u32 changed)
 {
-       struct vnt_private *pDevice = netdev_priv(dev);
-       struct iwreq *wrq = (struct iwreq *)rq;
-       int rc = 0;
-       PSMgmtObject pMgmt = pDevice->pMgmt;
-       PSCmdRequest pReq;
-
-       if (pMgmt == NULL) {
-               rc = -EFAULT;
-               return rc;
-       }
-
-       switch (cmd) {
-       case SIOCGIWNAME:
-               rc = iwctl_giwname(dev, NULL, (char *)&(wrq->u.name), NULL);
-               break;
+       struct vnt_private *priv = hw->priv;
 
-       case SIOCGIWNWID:     //0x8b03  support
-               rc = -EOPNOTSUPP;
-               break;
+       priv->current_aid = conf->aid;
 
-               // Set frequency/channel
-       case SIOCSIWFREQ:
-               rc = iwctl_siwfreq(dev, NULL, &(wrq->u.freq), NULL);
-               break;
+       if (changed & BSS_CHANGED_BSSID)
+               MACvWriteBSSIDAddress(priv->PortOffset, (u8 *)conf->bssid);
 
-               // Get frequency/channel
-       case SIOCGIWFREQ:
-               rc = iwctl_giwfreq(dev, NULL, &(wrq->u.freq), NULL);
-               break;
+       if (changed & BSS_CHANGED_BASIC_RATES) {
+               priv->basic_rates = conf->basic_rates;
 
-               // Set desired network name (ESSID)
-       case SIOCSIWESSID:
+               CARDvUpdateBasicTopRate(priv);
 
-       {
-               char essid[IW_ESSID_MAX_SIZE+1];
+               dev_dbg(&priv->pcid->dev,
+                       "basic rates %x\n", conf->basic_rates);
+       }
 
-               if (wrq->u.essid.length > IW_ESSID_MAX_SIZE) {
-                       rc = -E2BIG;
-                       break;
-               }
-               if (copy_from_user(essid, wrq->u.essid.pointer,
-                                  wrq->u.essid.length)) {
-                       rc = -EFAULT;
-                       break;
+       if (changed & BSS_CHANGED_ERP_PREAMBLE) {
+               if (conf->use_short_preamble) {
+                       MACvEnableBarkerPreambleMd(priv->PortOffset);
+                       priv->byPreambleType = true;
+               } else {
+                       MACvDisableBarkerPreambleMd(priv->PortOffset);
+                       priv->byPreambleType = false;
                }
-               rc = iwctl_siwessid(dev, NULL,
-                                   &(wrq->u.essid), essid);
        }
-       break;
-
-       // Get current network name (ESSID)
-       case SIOCGIWESSID:
 
-       {
-               char essid[IW_ESSID_MAX_SIZE+1];
-
-               if (wrq->u.essid.pointer)
-                       rc = iwctl_giwessid(dev, NULL,
-                                           &(wrq->u.essid), essid);
-               if (copy_to_user(wrq->u.essid.pointer,
-                                essid,
-                                wrq->u.essid.length))
-                       rc = -EFAULT;
+       if (changed & BSS_CHANGED_ERP_CTS_PROT) {
+               if (conf->use_cts_prot)
+                       MACvEnableProtectMD(priv->PortOffset);
+               else
+                       MACvDisableProtectMD(priv->PortOffset);
        }
-       break;
 
-       case SIOCSIWAP:
-
-               rc = iwctl_siwap(dev, NULL, &(wrq->u.ap_addr), NULL);
-               break;
+       if (changed & BSS_CHANGED_ERP_SLOT) {
+               if (conf->use_short_slot)
+                       priv->bShortSlotTime = true;
+               else
+                       priv->bShortSlotTime = false;
 
-               // Get current Access Point (BSSID)
-       case SIOCGIWAP:
-               rc = iwctl_giwap(dev, NULL, &(wrq->u.ap_addr), NULL);
-               break;
+               vUpdateIFS(priv);
+               CARDbSetPhyParameter(priv, priv->byBBType, 0, 0, NULL, NULL);
+               BBvSetVGAGainOffset(priv, priv->abyBBVGA[0]);
+       }
 
-               // Set desired station name
-       case SIOCSIWNICKN:
-               pr_debug(" SIOCSIWNICKN\n");
-               rc = -EOPNOTSUPP;
-               break;
+       if (changed & BSS_CHANGED_TXPOWER)
+               RFbSetPower(priv, priv->wCurrentRate,
+                           conf->chandef.chan->hw_value);
 
-               // Get current station name
-       case SIOCGIWNICKN:
-               pr_debug(" SIOCGIWNICKN\n");
-               rc = -EOPNOTSUPP;
-               break;
+       if (changed & BSS_CHANGED_BEACON_ENABLED) {
+               dev_dbg(&priv->pcid->dev,
+                       "Beacon enable %d\n", conf->enable_beacon);
 
-               // Set the desired bit-rate
-       case SIOCSIWRATE:
-               rc = iwctl_siwrate(dev, NULL, &(wrq->u.bitrate), NULL);
-               break;
+               if (conf->enable_beacon) {
+                       vnt_beacon_enable(priv, vif, conf);
 
-               // Get the current bit-rate
-       case SIOCGIWRATE:
+                       MACvRegBitsOn(priv, MAC_REG_TCR, TCR_AUTOBCNTX);
+               } else {
+                       MACvRegBitsOff(priv, MAC_REG_TCR, TCR_AUTOBCNTX);
+               }
+       }
 
-               rc = iwctl_giwrate(dev, NULL, &(wrq->u.bitrate), NULL);
-               break;
+       if (changed & BSS_CHANGED_ASSOC && priv->op_mode != NL80211_IFTYPE_AP) {
+               if (conf->assoc) {
+                       CARDbUpdateTSF(priv, conf->beacon_rate->hw_value,
+                                      conf->sync_device_ts, conf->sync_tsf);
 
-               // Set the desired RTS threshold
-       case SIOCSIWRTS:
+                       CARDbSetBeaconPeriod(priv, conf->beacon_int);
 
-               rc = iwctl_siwrts(dev, NULL, &(wrq->u.rts), NULL);
-               break;
+                       CARDvSetFirstNextTBTT(priv->PortOffset,
+                                             conf->beacon_int);
+               } else {
+                       VNSvOutPortB(priv->PortOffset + MAC_REG_TFTCTL,
+                                    TFTCTL_TSFCNTRST);
+                       VNSvOutPortB(priv->PortOffset + MAC_REG_TFTCTL,
+                                    TFTCTL_TSFCNTREN);
+               }
+       }
+}
 
-               // Get the current RTS threshold
-       case SIOCGIWRTS:
+static u64 vnt_prepare_multicast(struct ieee80211_hw *hw,
+       struct netdev_hw_addr_list *mc_list)
+{
+       struct vnt_private *priv = hw->priv;
+       struct netdev_hw_addr *ha;
+       u64 mc_filter = 0;
+       u32 bit_nr = 0;
 
-               rc = iwctl_giwrts(dev, NULL, &(wrq->u.rts), NULL);
-               break;
+       netdev_hw_addr_list_for_each(ha, mc_list) {
+               bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
 
-               // Set the desired fragmentation threshold
-       case SIOCSIWFRAG:
+               mc_filter |= 1ULL << (bit_nr & 0x3f);
+       }
 
-               rc = iwctl_siwfrag(dev, NULL, &(wrq->u.frag), NULL);
-               break;
+       priv->mc_list_count = mc_list->count;
 
-               // Get the current fragmentation threshold
-       case SIOCGIWFRAG:
+       return mc_filter;
+}
 
-               rc = iwctl_giwfrag(dev, NULL, &(wrq->u.frag), NULL);
-               break;
+static void vnt_configure(struct ieee80211_hw *hw,
+       unsigned int changed_flags, unsigned int *total_flags, u64 multicast)
+{
+       struct vnt_private *priv = hw->priv;
+       u8 rx_mode = 0;
 
-               // Set mode of operation
-       case SIOCSIWMODE:
-               rc = iwctl_siwmode(dev, NULL, &(wrq->u.mode), NULL);
-               break;
+       *total_flags &= FIF_ALLMULTI | FIF_OTHER_BSS | FIF_PROMISC_IN_BSS |
+               FIF_BCN_PRBRESP_PROMISC;
 
-               // Get mode of operation
-       case SIOCGIWMODE:
-               rc = iwctl_giwmode(dev, NULL, &(wrq->u.mode), NULL);
-               break;
+       VNSvInPortB(priv->PortOffset + MAC_REG_RCR, &rx_mode);
 
-               // Set WEP keys and mode
-       case SIOCSIWENCODE: {
-               char abyKey[WLAN_WEP232_KEYLEN];
+       dev_dbg(&priv->pcid->dev, "rx mode in = %x\n", rx_mode);
 
-               if (wrq->u.encoding.pointer) {
-                       if (wrq->u.encoding.length > WLAN_WEP232_KEYLEN) {
-                               rc = -E2BIG;
-                               break;
-                       }
-                       memset(abyKey, 0, WLAN_WEP232_KEYLEN);
-                       if (copy_from_user(abyKey,
-                                          wrq->u.encoding.pointer,
-                                          wrq->u.encoding.length)) {
-                               rc = -EFAULT;
-                               break;
-                       }
-               } else if (wrq->u.encoding.length != 0) {
-                       rc = -EINVAL;
-                       break;
-               }
-               rc = iwctl_siwencode(dev, NULL, &(wrq->u.encoding), abyKey);
+       if (changed_flags & FIF_PROMISC_IN_BSS) {
+               /* unconditionally log net taps */
+               if (*total_flags & FIF_PROMISC_IN_BSS)
+                       rx_mode |= RCR_UNICAST;
+               else
+                       rx_mode &= ~RCR_UNICAST;
        }
-       break;
 
-       // Get the WEP keys and mode
-       case SIOCGIWENCODE:
+       if (changed_flags & FIF_ALLMULTI) {
+               if (*total_flags & FIF_ALLMULTI) {
+                       if (priv->mc_list_count > 2) {
+                               MACvSelectPage1(priv->PortOffset);
 
-               if (!capable(CAP_NET_ADMIN)) {
-                       rc = -EPERM;
-                       break;
-               }
-               {
-                       char abyKey[WLAN_WEP232_KEYLEN];
+                               VNSvOutPortD(priv->PortOffset +
+                                            MAC_REG_MAR0, 0xffffffff);
+                               VNSvOutPortD(priv->PortOffset +
+                                           MAC_REG_MAR0 + 4, 0xffffffff);
 
-                       rc = iwctl_giwencode(dev, NULL, &(wrq->u.encoding), abyKey);
-                       if (rc != 0)
-                               break;
-                       if (wrq->u.encoding.pointer) {
-                               if (copy_to_user(wrq->u.encoding.pointer,
-                                                abyKey,
-                                                wrq->u.encoding.length))
-                                       rc = -EFAULT;
+                               MACvSelectPage0(priv->PortOffset);
+                       } else {
+                               MACvSelectPage1(priv->PortOffset);
+
+                               VNSvOutPortD(priv->PortOffset +
+                                            MAC_REG_MAR0, (u32)multicast);
+                               VNSvOutPortD(priv->PortOffset +
+                                            MAC_REG_MAR0 + 4,
+                                            (u32)(multicast >> 32));
+
+                               MACvSelectPage0(priv->PortOffset);
                        }
+
+                       rx_mode |= RCR_MULTICAST | RCR_BROADCAST;
+               } else {
+                       rx_mode &= ~(RCR_MULTICAST | RCR_BROADCAST);
                }
-               break;
+       }
 
-               // Get the current Tx-Power
-       case SIOCGIWTXPOW:
-               pr_debug(" SIOCGIWTXPOW\n");
-               rc = -EOPNOTSUPP;
-               break;
+       if (changed_flags & (FIF_OTHER_BSS | FIF_BCN_PRBRESP_PROMISC)) {
+               rx_mode |= RCR_MULTICAST | RCR_BROADCAST;
 
-       case SIOCSIWTXPOW:
-               pr_debug(" SIOCSIWTXPOW\n");
-               rc = -EOPNOTSUPP;
-               break;
+               if (*total_flags & (FIF_OTHER_BSS | FIF_BCN_PRBRESP_PROMISC))
+                       rx_mode &= ~RCR_BSSID;
+               else
+                       rx_mode |= RCR_BSSID;
+       }
 
-       case SIOCSIWRETRY:
+       VNSvOutPortB(priv->PortOffset + MAC_REG_RCR, rx_mode);
 
-               rc = iwctl_siwretry(dev, NULL, &(wrq->u.retry), NULL);
-               break;
+       dev_dbg(&priv->pcid->dev, "rx mode out= %x\n", rx_mode);
+}
 
-       case SIOCGIWRETRY:
+static int vnt_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
+       struct ieee80211_vif *vif, struct ieee80211_sta *sta,
+               struct ieee80211_key_conf *key)
+{
+       struct vnt_private *priv = hw->priv;
 
-               rc = iwctl_giwretry(dev, NULL, &(wrq->u.retry), NULL);
+       switch (cmd) {
+       case SET_KEY:
+               if (vnt_set_keys(hw, sta, vif, key))
+                       return -EOPNOTSUPP;
+               break;
+       case DISABLE_KEY:
+               if (test_bit(key->hw_key_idx, &priv->key_entry_inuse))
+                       clear_bit(key->hw_key_idx, &priv->key_entry_inuse);
+       default:
                break;
+       }
 
-               // Get range of parameters
-       case SIOCGIWRANGE:
+       return 0;
+}
 
-       {
-               struct iw_range range;
+static u64 vnt_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
+{
+       struct vnt_private *priv = hw->priv;
+       u64 tsf;
 
-               rc = iwctl_giwrange(dev, NULL, &(wrq->u.data), (char *)&range);
-               if (copy_to_user(wrq->u.data.pointer, &range, sizeof(struct iw_range)))
-                       rc = -EFAULT;
-       }
+       CARDbGetCurrentTSF(priv->PortOffset, &tsf);
 
-       break;
+       return tsf;
+}
 
-       case SIOCGIWPOWER:
+static void vnt_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+                       u64 tsf)
+{
+       struct vnt_private *priv = hw->priv;
 
-               rc = iwctl_giwpower(dev, NULL, &(wrq->u.power), NULL);
-               break;
+       CARDvUpdateNextTBTT(priv->PortOffset, tsf, vif->bss_conf.beacon_int);
+}
 
-       case SIOCSIWPOWER:
+static void vnt_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
+{
+       struct vnt_private *priv = hw->priv;
 
-               rc = iwctl_siwpower(dev, NULL, &(wrq->u.power), NULL);
-               break;
+       /* reset TSF counter */
+       VNSvOutPortB(priv->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTRST);
+}
 
-       case SIOCGIWSENS:
+static const struct ieee80211_ops vnt_mac_ops = {
+       .tx                     = vnt_tx_80211,
+       .start                  = vnt_start,
+       .stop                   = vnt_stop,
+       .add_interface          = vnt_add_interface,
+       .remove_interface       = vnt_remove_interface,
+       .config                 = vnt_config,
+       .bss_info_changed       = vnt_bss_info_changed,
+       .prepare_multicast      = vnt_prepare_multicast,
+       .configure_filter       = vnt_configure,
+       .set_key                = vnt_set_key,
+       .get_tsf                = vnt_get_tsf,
+       .set_tsf                = vnt_set_tsf,
+       .reset_tsf              = vnt_reset_tsf,
+};
 
-               rc = iwctl_giwsens(dev, NULL, &(wrq->u.sens), NULL);
-               break;
+int vnt_init(struct vnt_private *priv)
+{
+       SET_IEEE80211_PERM_ADDR(priv->hw, priv->abyCurrentNetAddr);
 
-       case SIOCSIWSENS:
-               pr_debug(" SIOCSIWSENS\n");
-               rc = -EOPNOTSUPP;
-               break;
+       vnt_init_bands(priv);
 
-       case SIOCGIWAPLIST: {
-               char buffer[IW_MAX_AP * (sizeof(struct sockaddr) + sizeof(struct iw_quality))];
-
-               if (wrq->u.data.pointer) {
-                       rc = iwctl_giwaplist(dev, NULL, &(wrq->u.data), buffer);
-                       if (rc == 0) {
-                               if (copy_to_user(wrq->u.data.pointer,
-                                                buffer,
-                                                (wrq->u.data.length * (sizeof(struct sockaddr) +  sizeof(struct iw_quality)))
-                                           ))
-                                       rc = -EFAULT;
-                       }
-               }
-       }
-       break;
+       if (ieee80211_register_hw(priv->hw))
+               return -ENODEV;
 
-#ifdef WIRELESS_SPY
-       // Set the spy list
-       case SIOCSIWSPY:
+       priv->mac_hw = true;
 
-               pr_debug(" SIOCSIWSPY\n");
-               rc = -EOPNOTSUPP;
-               break;
+       CARDbRadioPowerOff(priv);
 
-               // Get the spy list
-       case SIOCGIWSPY:
+       return 0;
+}
 
-               pr_debug(" SIOCGIWSPY\n");
-               rc = -EOPNOTSUPP;
-               break;
+static int
+vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent)
+{
+       PCHIP_INFO  pChip_info = (PCHIP_INFO)ent->driver_data;
+       struct vnt_private *priv;
+       struct ieee80211_hw *hw;
+       struct wiphy *wiphy;
+       int         rc;
 
-#endif // WIRELESS_SPY
+       dev_notice(&pcid->dev,
+                  "%s Ver. %s\n", DEVICE_FULL_DRV_NAM, DEVICE_VERSION);
 
-       case SIOCGIWPRIV:
-               pr_debug(" SIOCGIWPRIV\n");
-               rc = -EOPNOTSUPP;
-               break;
+       dev_notice(&pcid->dev,
+                  "Copyright (c) 2003 VIA Networking Technologies, Inc.\n");
 
-//2008-0409-07, <Add> by Einsn Liu
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-       case SIOCSIWAUTH:
-               pr_debug(" SIOCSIWAUTH\n");
-               rc = iwctl_siwauth(dev, NULL, &(wrq->u.param), NULL);
-               break;
+       hw = ieee80211_alloc_hw(sizeof(*priv), &vnt_mac_ops);
+       if (!hw) {
+               dev_err(&pcid->dev, "could not register ieee80211_hw\n");
+               return -ENOMEM;
+       }
 
-       case SIOCGIWAUTH:
-               pr_debug(" SIOCGIWAUTH\n");
-               rc = iwctl_giwauth(dev, NULL, &(wrq->u.param), NULL);
-               break;
+       priv = hw->priv;
 
-       case SIOCSIWGENIE:
-               pr_debug(" SIOCSIWGENIE\n");
-               rc = iwctl_siwgenie(dev, NULL, &(wrq->u.data), wrq->u.data.pointer);
-               break;
+       vt6655_init_info(pcid, &priv, pChip_info);
 
-       case SIOCGIWGENIE:
-               pr_debug(" SIOCGIWGENIE\n");
-               rc = iwctl_giwgenie(dev, NULL, &(wrq->u.data), wrq->u.data.pointer);
-               break;
+       priv->hw = hw;
 
-       case SIOCSIWENCODEEXT: {
-               char extra[sizeof(struct iw_encode_ext)+MAX_KEY_LEN+1];
+       SET_IEEE80211_DEV(priv->hw, &pcid->dev);
 
-               pr_debug(" SIOCSIWENCODEEXT\n");
-               if (wrq->u.encoding.pointer) {
-                       memset(extra, 0, sizeof(struct iw_encode_ext)+MAX_KEY_LEN + 1);
-                       if (wrq->u.encoding.length > (sizeof(struct iw_encode_ext) + MAX_KEY_LEN)) {
-                               rc = -E2BIG;
-                               break;
-                       }
-                       if (copy_from_user(extra, wrq->u.encoding.pointer, wrq->u.encoding.length)) {
-                               rc = -EFAULT;
-                               break;
-                       }
-               } else if (wrq->u.encoding.length != 0) {
-                       rc = -EINVAL;
-                       break;
-               }
-               rc = iwctl_siwencodeext(dev, NULL, &(wrq->u.encoding), extra);
+       if (pci_enable_device(pcid)) {
+               device_free_info(priv);
+               return -ENODEV;
        }
-       break;
 
-       case SIOCGIWENCODEEXT:
-               pr_debug(" SIOCGIWENCODEEXT\n");
-               rc = iwctl_giwencodeext(dev, NULL, &(wrq->u.encoding), NULL);
-               break;
+       dev_dbg(&pcid->dev,
+               "Before get pci_info memaddr is %x\n", priv->memaddr);
 
-       case SIOCSIWMLME:
-               pr_debug(" SIOCSIWMLME\n");
-               rc = iwctl_siwmlme(dev, NULL, &(wrq->u.data), wrq->u.data.pointer);
-               break;
+       if (!device_get_pci_info(priv, pcid)) {
+               dev_err(&pcid->dev, ": Failed to find PCI device.\n");
+               device_free_info(priv);
+               return -ENODEV;
+       }
+
+#ifdef DEBUG
+       dev_dbg(&pcid->dev,
+               "after get pci_info memaddr is %x, io addr is %x,io_size is %d\n",
+               priv->memaddr, priv->ioaddr, priv->io_size);
+       {
+               int i;
+               u32 bar, len;
+               u32 address[] = {
+                       PCI_BASE_ADDRESS_0,
+                       PCI_BASE_ADDRESS_1,
+                       PCI_BASE_ADDRESS_2,
+                       PCI_BASE_ADDRESS_3,
+                       PCI_BASE_ADDRESS_4,
+                       PCI_BASE_ADDRESS_5,
+                       0};
+               for (i = 0; address[i]; i++) {
+                       pci_read_config_dword(pcid, address[i], &bar);
 
-#endif // #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-//End Add -- //2008-0409-07, <Add> by Einsn Liu
+                       dev_dbg(&pcid->dev, "bar %d is %x\n", i, bar);
 
-       case IOCTL_CMD_TEST:
+                       if (!bar) {
+                               dev_dbg(&pcid->dev,
+                                       "bar %d not implemented\n", i);
+                               continue;
+                       }
 
-               if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
-                       rc = -EFAULT;
-                       break;
-               } else {
-                       rc = 0;
-               }
-               pReq = (PSCmdRequest)rq;
-               pReq->wResult = MAGIC_CODE;
-               break;
+                       if (bar & PCI_BASE_ADDRESS_SPACE_IO) {
+                               /* This is IO */
 
-       case IOCTL_CMD_SET:
+                               len = bar & (PCI_BASE_ADDRESS_IO_MASK & 0xffff);
+                               len = len & ~(len - 1);
 
-#ifdef SndEvt_ToAPI
-               if ((((PSCmdRequest)rq)->wCmdCode != WLAN_CMD_SET_EVT) &&
-                   !(pDevice->flags & DEVICE_FLAGS_OPENED))
-#else
-                       if (!(pDevice->flags & DEVICE_FLAGS_OPENED) &&
-                           (((PSCmdRequest)rq)->wCmdCode != WLAN_CMD_SET_WPA))
-#endif
-                       {
-                               rc = -EFAULT;
-                               break;
+                               dev_dbg(&pcid->dev,
+                                       "IO space:  len in IO %x, BAR %d\n",
+                                       len, i);
                        } else {
-                               rc = 0;
+                               len = bar & 0xfffffff0;
+                               len = ~len + 1;
+
+                               dev_dbg(&pcid->dev,
+                                       "len in MEM %x, BAR %d\n", len, i);
                        }
+               }
+       }
+#endif
 
-               if (test_and_set_bit(0, (void *)&(pMgmt->uCmdBusy)))
-                       return -EBUSY;
+       priv->PortOffset = ioremap(priv->memaddr & PCI_BASE_ADDRESS_MEM_MASK,
+                                  priv->io_size);
+       if (!priv->PortOffset) {
+               dev_err(&pcid->dev, ": Failed to IO remapping ..\n");
+               device_free_info(priv);
+               return -ENODEV;
+       }
 
-               rc = private_ioctl(pDevice, rq);
-               clear_bit(0, (void *)&(pMgmt->uCmdBusy));
-               break;
+       rc = pci_request_regions(pcid, DEVICE_NAME);
+       if (rc) {
+               dev_err(&pcid->dev, ": Failed to find PCI device\n");
+               device_free_info(priv);
+               return -ENODEV;
+       }
 
-       case IOCTL_CMD_HOSTAPD:
+       /* do reset */
+       if (!MACbSoftwareReset(priv->PortOffset)) {
+               dev_err(&pcid->dev, ": Failed to access MAC hardware..\n");
+               device_free_info(priv);
+               return -ENODEV;
+       }
+       /* initial to reload eeprom */
+       MACvInitialize(priv->PortOffset);
+       MACvReadEtherAddress(priv->PortOffset, priv->abyCurrentNetAddr);
 
-               rc = vt6655_hostap_ioctl(pDevice, &wrq->u.data);
-               break;
+       device_get_options(priv);
+       device_set_options(priv);
+       /* Mask out the options cannot be set to the chip */
+       priv->sOpts.flags &= pChip_info->flags;
 
-       case IOCTL_CMD_WPA:
+       /* Enable the chip specified capabilities */
+       priv->flags = priv->sOpts.flags | (pChip_info->flags & 0xff000000UL);
 
-               rc = wpa_ioctl(pDevice, &wrq->u.data);
-               break;
+       wiphy = priv->hw->wiphy;
 
-       case SIOCETHTOOL:
-               return ethtool_ioctl(dev, rq->ifr_data);
-               // All other calls are currently unsupported
+       wiphy->frag_threshold = FRAG_THRESH_DEF;
+       wiphy->rts_threshold = RTS_THRESH_DEF;
+       wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
+               BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP);
 
-       default:
-               rc = -EOPNOTSUPP;
-               pr_debug("Ioctl command not support..%x\n", cmd);
+       priv->hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
+               IEEE80211_HW_REPORTS_TX_ACK_STATUS |
+               IEEE80211_HW_SIGNAL_DBM |
+               IEEE80211_HW_TIMING_BEACON_ONLY;
 
-       }
+       priv->hw->max_signal = 100;
 
-       if (pDevice->bCommit) {
-               if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
-                       netif_stop_queue(pDevice->dev);
-                       spin_lock_irq(&pDevice->lock);
-                       bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL);
-                       spin_unlock_irq(&pDevice->lock);
-               } else {
-                       pr_debug("Commit the settings\n");
-                       spin_lock_irq(&pDevice->lock);
-                       pDevice->bLinkPass = false;
-                       memset(pMgmt->abyCurrBSSID, 0, 6);
-                       pMgmt->eCurrState = WMAC_STATE_IDLE;
-                       netif_stop_queue(pDevice->dev);
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-                       pMgmt->eScanType = WMAC_SCAN_ACTIVE;
-                       if (!pDevice->bWPASuppWextEnabled)
-#endif
-                               bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
-                       bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL);
-                       spin_unlock_irq(&pDevice->lock);
-               }
-               pDevice->bCommit = false;
-       }
+       if (vnt_init(priv))
+               return -ENODEV;
 
-       return rc;
+       device_print_info(priv);
+       pci_set_drvdata(pcid, priv);
+
+       return 0;
 }
 
-static int ethtool_ioctl(struct net_device *dev, void __user *useraddr)
+/*------------------------------------------------------------------*/
+
+#ifdef CONFIG_PM
+static int vt6655_suspend(struct pci_dev *pcid, pm_message_t state)
 {
-       u32 ethcmd;
+       struct vnt_private *priv = pci_get_drvdata(pcid);
+       unsigned long flags;
 
-       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
-               return -EFAULT;
+       spin_lock_irqsave(&priv->lock, flags);
 
-       switch (ethcmd) {
-       case ETHTOOL_GDRVINFO: {
-               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
+       pci_save_state(pcid);
 
-               strncpy(info.driver, DEVICE_NAME, sizeof(info.driver)-1);
-               strncpy(info.version, DEVICE_VERSION, sizeof(info.version)-1);
-               if (copy_to_user(useraddr, &info, sizeof(info)))
-                       return -EFAULT;
-               return 0;
-       }
+       MACbShutdown(priv->PortOffset);
 
-       }
+       pci_disable_device(pcid);
+       pci_set_power_state(pcid, pci_choose_state(pcid, state));
 
-       return -EOPNOTSUPP;
+       spin_unlock_irqrestore(&priv->lock, flags);
+
+       return 0;
 }
 
-/*------------------------------------------------------------------*/
+static int vt6655_resume(struct pci_dev *pcid)
+{
+
+       pci_set_power_state(pcid, PCI_D0);
+       pci_enable_wake(pcid, PCI_D0, 0);
+       pci_restore_state(pcid);
+
+       return 0;
+}
+#endif
 
 MODULE_DEVICE_TABLE(pci, vt6655_pci_id_table);
 
@@ -3025,8 +2039,8 @@ static struct pci_driver device_driver = {
        .probe = vt6655_probe,
        .remove = vt6655_remove,
 #ifdef CONFIG_PM
-       .suspend = viawget_suspend,
-       .resume = viawget_resume,
+       .suspend = vt6655_suspend,
+       .resume = vt6655_resume,
 #endif
 };
 
@@ -3067,75 +2081,10 @@ device_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
                for_each_pci_dev(pdev) {
                        if (pci_dev_driver(pdev) == &device_driver) {
                                if (pci_get_drvdata(pdev))
-                                       viawget_suspend(pdev, PMSG_HIBERNATE);
+                                       vt6655_suspend(pdev, PMSG_HIBERNATE);
                        }
                }
        }
        return NOTIFY_DONE;
 }
-
-static int
-viawget_suspend(struct pci_dev *pcid, pm_message_t state)
-{
-       int power_status;   // to silence the compiler
-
-       struct vnt_private *pDevice = pci_get_drvdata(pcid);
-       PSMgmtObject  pMgmt = pDevice->pMgmt;
-
-       netif_stop_queue(pDevice->dev);
-       spin_lock_irq(&pDevice->lock);
-       pci_save_state(pcid);
-       del_timer(&pDevice->sTimerCommand);
-       del_timer(&pMgmt->sTimerSecondCallback);
-       pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
-       pDevice->uCmdDequeueIdx = 0;
-       pDevice->uCmdEnqueueIdx = 0;
-       pDevice->bCmdRunning = false;
-       MACbShutdown(pDevice->PortOffset);
-       MACvSaveContext(pDevice->PortOffset, pDevice->abyMacContext);
-       pDevice->bLinkPass = false;
-       memset(pMgmt->abyCurrBSSID, 0, 6);
-       pMgmt->eCurrState = WMAC_STATE_IDLE;
-       pci_disable_device(pcid);
-       power_status = pci_set_power_state(pcid, pci_choose_state(pcid, state));
-       spin_unlock_irq(&pDevice->lock);
-       return 0;
-}
-
-static int
-viawget_resume(struct pci_dev *pcid)
-{
-       struct vnt_private *pDevice = pci_get_drvdata(pcid);
-       PSMgmtObject  pMgmt = pDevice->pMgmt;
-       int power_status;   // to silence the compiler
-
-       power_status = pci_set_power_state(pcid, PCI_D0);
-       power_status = pci_enable_wake(pcid, PCI_D0, 0);
-       pci_restore_state(pcid);
-       if (netif_running(pDevice->dev)) {
-               spin_lock_irq(&pDevice->lock);
-               MACvRestoreContext(pDevice->PortOffset, pDevice->abyMacContext);
-               device_init_registers(pDevice);
-               if (pMgmt->sNodeDBTable[0].bActive) { // Assoc with BSS
-                       pMgmt->sNodeDBTable[0].bActive = false;
-                       pDevice->bLinkPass = false;
-                       if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
-                               // In Adhoc, BSS state set back to started.
-                               pMgmt->eCurrState = WMAC_STATE_STARTED;
-                       } else {
-                               pMgmt->eCurrMode = WMAC_MODE_STANDBY;
-                               pMgmt->eCurrState = WMAC_STATE_IDLE;
-                       }
-               }
-               init_timer(&pMgmt->sTimerSecondCallback);
-               init_timer(&pDevice->sTimerCommand);
-               MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
-               BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass);
-               bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL);
-               bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL);
-               spin_unlock_irq(&pDevice->lock);
-       }
-       return 0;
-}
-
 #endif
index 8515b8c..977683c 100644 (file)
  * Date: May 20, 2003
  *
  * Functions:
- *      device_receive_frame - Rcv 802.11 frame function
- *      s_bAPModeRxCtl- AP Rcv frame filer Ctl.
- *      s_bAPModeRxData- AP Rcv data frame handle
- *      s_bHandleRxEncryption- Rcv decrypted data via on-fly
- *      s_bHostWepRxEncryption- Rcv encrypted data via host
- *      s_byGetRateIdx- get rate index
- *      s_vGetDASA- get data offset
- *      s_vProcessRxMACHeader- Rcv 802.11 and translate to 802.3
  *
  * Revision History:
  *
  */
 
 #include "device.h"
-#include "rxtx.h"
-#include "tether.h"
-#include "card.h"
-#include "bssdb.h"
-#include "mac.h"
 #include "baseband.h"
-#include "michael.h"
-#include "tkip.h"
-#include "tcrc.h"
-#include "wctl.h"
-#include "wroute.h"
-#include "hostap.h"
 #include "rf.h"
-#include "iowpa.h"
-#include "aes_ccmp.h"
 #include "dpc.h"
 
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Variables  --------------------------*/
-static const unsigned char acbyRxRate[MAX_RATE] =
-{2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108};
-
-/*---------------------  Static Functions  --------------------------*/
-
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Functions  --------------------------*/
-
-static unsigned char s_byGetRateIdx(unsigned char byRate);
-
-static void
-s_vGetDASA(unsigned char *pbyRxBufferAddr, unsigned int *pcbHeaderSize,
-          PSEthernetHeader psEthHeader);
-
-static void
-s_vProcessRxMACHeader(struct vnt_private *pDevice, unsigned char *pbyRxBufferAddr,
-                     unsigned int cbPacketSize, bool bIsWEP, bool bExtIV,
-                     unsigned int *pcbHeadSize);
-
-static bool s_bAPModeRxCtl(
-       struct vnt_private *pDevice,
-       unsigned char *pbyFrame,
-       int      iSANodeIndex
-);
-
-static bool s_bAPModeRxData(
-       struct vnt_private *pDevice,
-       struct sk_buff *skb,
-       unsigned int FrameSize,
-       unsigned int cbHeaderOffset,
-       int      iSANodeIndex,
-       int      iDANodeIndex
-);
-
-static bool s_bHandleRxEncryption(
-       struct vnt_private *pDevice,
-       unsigned char *pbyFrame,
-       unsigned int FrameSize,
-       unsigned char *pbyRsr,
-       unsigned char *pbyNewRsr,
-       PSKeyItem   *pKeyOut,
-       bool *pbExtIV,
-       unsigned short *pwRxTSC15_0,
-       unsigned long *pdwRxTSC47_16
-);
-
-static bool s_bHostWepRxEncryption(
-
-       struct vnt_private *pDevice,
-       unsigned char *pbyFrame,
-       unsigned int FrameSize,
-       unsigned char *pbyRsr,
-       bool bOnFly,
-       PSKeyItem    pKey,
-       unsigned char *pbyNewRsr,
-       bool *pbExtIV,
-       unsigned short *pwRxTSC15_0,
-       unsigned long *pdwRxTSC47_16
-
-);
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*+
- *
- * Description:
- *    Translate Rcv 802.11 header to 802.3 header with Rx buffer
- *
- * Parameters:
- *  In:
- *      pDevice
- *      dwRxBufferAddr  - Address of Rcv Buffer
- *      cbPacketSize    - Rcv Packet size
- *      bIsWEP          - If Rcv with WEP
- *  Out:
- *      pcbHeaderSize   - 802.11 header size
- *
- * Return Value: None
- *
- -*/
-static void
-s_vProcessRxMACHeader(struct vnt_private *pDevice,
-                     unsigned char *pbyRxBufferAddr,
-                     unsigned int cbPacketSize, bool bIsWEP, bool bExtIV,
-                     unsigned int *pcbHeadSize)
+static bool vnt_rx_data(struct vnt_private *priv, struct sk_buff *skb,
+                       u16 bytes_received)
 {
-       unsigned char *pbyRxBuffer;
-       unsigned int cbHeaderSize = 0;
-       unsigned short *pwType;
-       PS802_11Header  pMACHeader;
-       int             ii;
-
-       pMACHeader = (PS802_11Header) (pbyRxBufferAddr + cbHeaderSize);
-
-       s_vGetDASA((unsigned char *)pMACHeader, &cbHeaderSize, &pDevice->sRxEthHeader);
-
-       if (bIsWEP) {
-               if (bExtIV) {
-                       // strip IV&ExtIV , add 8 byte
-                       cbHeaderSize += (WLAN_HDR_ADDR3_LEN + 8);
-               } else {
-                       // strip IV , add 4 byte
-                       cbHeaderSize += (WLAN_HDR_ADDR3_LEN + 4);
-               }
-       } else {
-               cbHeaderSize += WLAN_HDR_ADDR3_LEN;
-       }
-
-       pbyRxBuffer = (unsigned char *)(pbyRxBufferAddr + cbHeaderSize);
-       if (ether_addr_equal(pbyRxBuffer, pDevice->abySNAP_Bridgetunnel)) {
-               cbHeaderSize += 6;
-       } else if (ether_addr_equal(pbyRxBuffer, pDevice->abySNAP_RFC1042)) {
-               cbHeaderSize += 6;
-               pwType = (unsigned short *)(pbyRxBufferAddr + cbHeaderSize);
-               if ((*pwType != TYPE_PKT_IPX) && (*pwType != cpu_to_le16(0xF380))) {
-               } else {
-                       cbHeaderSize -= 8;
-                       pwType = (unsigned short *)(pbyRxBufferAddr + cbHeaderSize);
-                       if (bIsWEP) {
-                               if (bExtIV)
-                                       *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 8);    // 8 is IV&ExtIV
-                               else
-                                       *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 4);    // 4 is IV
-
-                       } else {
-                               *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN);
-                       }
-               }
-       } else {
-               cbHeaderSize -= 2;
-               pwType = (unsigned short *)(pbyRxBufferAddr + cbHeaderSize);
-               if (bIsWEP) {
-                       if (bExtIV)
-                               *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 8);    // 8 is IV&ExtIV
-                       else
-                               *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 4);    // 4 is IV
-
-               } else {
-                       *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN);
-               }
-       }
-
-       cbHeaderSize -= (ETH_ALEN * 2);
-       pbyRxBuffer = (unsigned char *)(pbyRxBufferAddr + cbHeaderSize);
-       for (ii = 0; ii < ETH_ALEN; ii++)
-               *pbyRxBuffer++ = pDevice->sRxEthHeader.abyDstAddr[ii];
-       for (ii = 0; ii < ETH_ALEN; ii++)
-               *pbyRxBuffer++ = pDevice->sRxEthHeader.abySrcAddr[ii];
-
-       *pcbHeadSize = cbHeaderSize;
-}
-
-static unsigned char s_byGetRateIdx(unsigned char byRate)
-{
-       unsigned char byRateIdx;
-
-       for (byRateIdx = 0; byRateIdx < MAX_RATE; byRateIdx++) {
-               if (acbyRxRate[byRateIdx % MAX_RATE] == byRate)
-                       return byRateIdx;
-       }
-
-       return 0;
-}
-
-static void
-s_vGetDASA(unsigned char *pbyRxBufferAddr, unsigned int *pcbHeaderSize,
-          PSEthernetHeader psEthHeader)
-{
-       unsigned int cbHeaderSize = 0;
-       PS802_11Header  pMACHeader;
-       int             ii;
-
-       pMACHeader = (PS802_11Header) (pbyRxBufferAddr + cbHeaderSize);
-
-       if ((pMACHeader->wFrameCtl & FC_TODS) == 0) {
-               if (pMACHeader->wFrameCtl & FC_FROMDS) {
-                       for (ii = 0; ii < ETH_ALEN; ii++) {
-                               psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr1[ii];
-                               psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr3[ii];
-                       }
-               } else {
-                       // IBSS mode
-                       for (ii = 0; ii < ETH_ALEN; ii++) {
-                               psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr1[ii];
-                               psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr2[ii];
-                       }
-               }
-       } else {
-               // Is AP mode..
-               if (pMACHeader->wFrameCtl & FC_FROMDS) {
-                       for (ii = 0; ii < ETH_ALEN; ii++) {
-                               psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr3[ii];
-                               psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr4[ii];
-                               cbHeaderSize += 6;
-                       }
-               } else {
-                       for (ii = 0; ii < ETH_ALEN; ii++) {
-                               psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr3[ii];
-                               psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr2[ii];
-                       }
-               }
-       }
-       *pcbHeaderSize = cbHeaderSize;
-}
-
-bool
-device_receive_frame(
-       struct vnt_private *pDevice,
-       PSRxDesc pCurrRD
-)
-{
-       PDEVICE_RD_INFO  pRDInfo = pCurrRD->pRDInfo;
-       struct net_device_stats *pStats = &pDevice->dev->stats;
-       struct sk_buff *skb;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       PSRxMgmtPacket  pRxPacket = &(pDevice->pMgmt->sRxPacket);
-       PS802_11Header  p802_11Header;
-       unsigned char *pbyRsr;
-       unsigned char *pbyNewRsr;
-       unsigned char *pbyRSSI;
-       __le64 *pqwTSFTime;
-       unsigned short *pwFrameSize;
-       unsigned char *pbyFrame;
-       bool bDeFragRx = false;
-       bool bIsWEP = false;
-       unsigned int cbHeaderOffset;
-       unsigned int FrameSize;
-       unsigned short wEtherType = 0;
-       int             iSANodeIndex = -1;
-       int             iDANodeIndex = -1;
-       unsigned int ii;
-       unsigned int cbIVOffset;
-       bool bExtIV = false;
-       unsigned char *pbyRxSts;
-       unsigned char *pbyRxRate;
-       unsigned char *pbySQ;
-       unsigned int cbHeaderSize;
-       PSKeyItem       pKey = NULL;
-       unsigned short wRxTSC15_0 = 0;
-       unsigned long dwRxTSC47_16 = 0;
-       SKeyItem        STempKey;
-       // 802.11h RPI
-       unsigned long dwDuration = 0;
-       long            ldBm = 0;
-       long            ldBmThreshold = 0;
-       PS802_11Header pMACHeader;
-       bool bRxeapol_key = false;
-
-       skb = pRDInfo->skb;
-
-       pci_unmap_single(pDevice->pcid, pRDInfo->skb_dma,
-                        pDevice->rx_buf_sz, PCI_DMA_FROMDEVICE);
-
-       pwFrameSize = (unsigned short *)(skb->data + 2);
-       FrameSize = cpu_to_le16(pCurrRD->m_rd1RD1.wReqCount) - cpu_to_le16(pCurrRD->m_rd0RD0.wResCount);
-
-       // Max: 2312Payload + 30HD +4CRC + 2Padding + 4Len + 8TSF + 4RSR
-       // Min (ACK): 10HD +4CRC + 2Padding + 4Len + 8TSF + 4RSR
-       if ((FrameSize > 2364) || (FrameSize <= 32)) {
-               // Frame Size error drop this packet.
-               pr_debug("---------- WRONG Length 1\n");
-               return false;
-       }
-
-       pbyRxSts = (unsigned char *)(skb->data);
-       pbyRxRate = (unsigned char *)(skb->data + 1);
-       pbyRsr = (unsigned char *)(skb->data + FrameSize - 1);
-       pbyRSSI = (unsigned char *)(skb->data + FrameSize - 2);
-       pbyNewRsr = (unsigned char *)(skb->data + FrameSize - 3);
-       pbySQ = (unsigned char *)(skb->data + FrameSize - 4);
-       pqwTSFTime = (__le64 *)(skb->data + FrameSize - 12);
-       pbyFrame = (unsigned char *)(skb->data + 4);
-
-       // get packet size
-       FrameSize = cpu_to_le16(*pwFrameSize);
-
-       if ((FrameSize > 2346)|(FrameSize < 14)) { // Max: 2312Payload + 30HD +4CRC
-               // Min: 14 bytes ACK
-               pr_debug("---------- WRONG Length 2\n");
-               return false;
-       }
-
-       // update receive statistic counter
-       STAvUpdateRDStatCounter(&pDevice->scStatistic,
-                               *pbyRsr,
-                               *pbyNewRsr,
-                               *pbyRxRate,
-                               pbyFrame,
-                               FrameSize);
-
-       pMACHeader = (PS802_11Header)((unsigned char *)(skb->data) + 8);
-
-       if (pDevice->bMeasureInProgress) {
-               if ((*pbyRsr & RSR_CRCOK) != 0)
-                       pDevice->byBasicMap |= 0x01;
-
-               dwDuration = (FrameSize << 4);
-               dwDuration /= acbyRxRate[*pbyRxRate%MAX_RATE];
-               if (*pbyRxRate <= RATE_11M) {
-                       if (*pbyRxSts & 0x01) {
-                               // long preamble
-                               dwDuration += 192;
-                       } else {
-                               // short preamble
-                               dwDuration += 96;
-                       }
-               } else {
-                       dwDuration += 16;
-               }
-               RFvRSSITodBm(pDevice, *pbyRSSI, &ldBm);
-               ldBmThreshold = -57;
-               for (ii = 7; ii > 0;) {
-                       if (ldBm > ldBmThreshold)
-                               break;
-
-                       ldBmThreshold -= 5;
-                       ii--;
-               }
-               pDevice->dwRPIs[ii] += dwDuration;
-               return false;
-       }
-
-       if (!is_multicast_ether_addr(pbyFrame)) {
-               if (WCTLbIsDuplicate(&(pDevice->sDupRxCache), (PS802_11Header)(skb->data + 4))) {
-                       pDevice->s802_11Counter.FrameDuplicateCount++;
-                       return false;
-               }
-       }
-
-       // Use for TKIP MIC
-       s_vGetDASA(skb->data+4, &cbHeaderSize, &pDevice->sRxEthHeader);
-
-       // filter packet send from myself
-       if (ether_addr_equal(pDevice->sRxEthHeader.abySrcAddr,
-                            pDevice->abyCurrentNetAddr))
-               return false;
-
-       if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) {
-               if (IS_CTL_PSPOLL(pbyFrame) || !IS_TYPE_CONTROL(pbyFrame)) {
-                       p802_11Header = (PS802_11Header)(pbyFrame);
-                       // get SA NodeIndex
-                       if (BSSDBbIsSTAInNodeDB(pMgmt, (unsigned char *)(p802_11Header->abyAddr2), &iSANodeIndex)) {
-                               pMgmt->sNodeDBTable[iSANodeIndex].ulLastRxJiffer = jiffies;
-                               pMgmt->sNodeDBTable[iSANodeIndex].uInActiveCount = 0;
-                       }
-               }
-       }
-
-       if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
-               if (s_bAPModeRxCtl(pDevice, pbyFrame, iSANodeIndex))
-                       return false;
-       }
-
-       if (IS_FC_WEP(pbyFrame)) {
-               bool bRxDecryOK = false;
-
-               pr_debug("rx WEP pkt\n");
-               bIsWEP = true;
-               if ((pDevice->bEnableHostWEP) && (iSANodeIndex >= 0)) {
-                       pKey = &STempKey;
-                       pKey->byCipherSuite = pMgmt->sNodeDBTable[iSANodeIndex].byCipherSuite;
-                       pKey->dwKeyIndex = pMgmt->sNodeDBTable[iSANodeIndex].dwKeyIndex;
-                       pKey->uKeyLength = pMgmt->sNodeDBTable[iSANodeIndex].uWepKeyLength;
-                       pKey->dwTSC47_16 = pMgmt->sNodeDBTable[iSANodeIndex].dwTSC47_16;
-                       pKey->wTSC15_0 = pMgmt->sNodeDBTable[iSANodeIndex].wTSC15_0;
-                       memcpy(pKey->abyKey,
-                              &pMgmt->sNodeDBTable[iSANodeIndex].abyWepKey[0],
-                              pKey->uKeyLength
-);
-
-                       bRxDecryOK = s_bHostWepRxEncryption(pDevice,
-                                                           pbyFrame,
-                                                           FrameSize,
-                                                           pbyRsr,
-                                                           pMgmt->sNodeDBTable[iSANodeIndex].bOnFly,
-                                                           pKey,
-                                                           pbyNewRsr,
-                                                           &bExtIV,
-                                                           &wRxTSC15_0,
-                                                           &dwRxTSC47_16);
-               } else {
-                       bRxDecryOK = s_bHandleRxEncryption(pDevice,
-                                                          pbyFrame,
-                                                          FrameSize,
-                                                          pbyRsr,
-                                                          pbyNewRsr,
-                                                          &pKey,
-                                                          &bExtIV,
-                                                          &wRxTSC15_0,
-                                                          &dwRxTSC47_16);
-               }
-
-               if (bRxDecryOK) {
-                       if ((*pbyNewRsr & NEWRSR_DECRYPTOK) == 0) {
-                               pr_debug("ICV Fail\n");
-                               if ((pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPA) ||
-                                   (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) ||
-                                   (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) ||
-                                   (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
-                                   (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) {
-                                       if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP))
-                                               pDevice->s802_11Counter.TKIPICVErrors++;
-                                       else if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_CCMP))
-                                               pDevice->s802_11Counter.CCMPDecryptErrors++;
-                               }
-                               return false;
-                       }
-               } else {
-                       pr_debug("WEP Func Fail\n");
-                       return false;
-               }
-               if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_CCMP))
-                       FrameSize -= 8;         // Message Integrity Code
-               else
-                       FrameSize -= 4;         // 4 is ICV
-       }
-
-       //
-       // RX OK
-       //
-       //remove the CRC length
-       FrameSize -= ETH_FCS_LEN;
-
-       if ((!(*pbyRsr & (RSR_ADDRBROAD | RSR_ADDRMULTI))) && // unicast address
-           (IS_FRAGMENT_PKT((skb->data+4)))
-) {
-               // defragment
-               bDeFragRx = WCTLbHandleFragment(pDevice, (PS802_11Header)(skb->data+4), FrameSize, bIsWEP, bExtIV);
-               pDevice->s802_11Counter.ReceivedFragmentCount++;
-               if (bDeFragRx) {
-                       // defrag complete
-                       skb = pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].skb;
-                       FrameSize = pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength;
-
-               } else {
-                       return false;
-               }
-       }
-
-// Management & Control frame Handle
-       if ((IS_TYPE_DATA((skb->data+4))) == false) {
-               // Handle Control & Manage Frame
-
-               if (IS_TYPE_MGMT((skb->data+4))) {
-                       unsigned char *pbyData1;
-                       unsigned char *pbyData2;
-
-                       pRxPacket->p80211Header = (PUWLAN_80211HDR)(skb->data+4);
-                       pRxPacket->cbMPDULen = FrameSize;
-                       pRxPacket->uRSSI = *pbyRSSI;
-                       pRxPacket->bySQ = *pbySQ;
-                       pRxPacket->qwLocalTSF = le64_to_cpu(*pqwTSFTime);
-                       if (bIsWEP) {
-                               // strip IV
-                               pbyData1 = WLAN_HDR_A3_DATA_PTR(skb->data+4);
-                               pbyData2 = WLAN_HDR_A3_DATA_PTR(skb->data+4) + 4;
-                               for (ii = 0; ii < (FrameSize - 4); ii++) {
-                                       *pbyData1 = *pbyData2;
-                                       pbyData1++;
-                                       pbyData2++;
-                               }
-                       }
-                       pRxPacket->byRxRate = s_byGetRateIdx(*pbyRxRate);
-                       pRxPacket->byRxChannel = (*pbyRxSts) >> 2;
-
-                       vMgrRxManagePacket((void *)pDevice, pDevice->pMgmt, pRxPacket);
-
-                       // hostap Deamon handle 802.11 management
-                       if (pDevice->bEnableHostapd) {
-                               skb->dev = pDevice->apdev;
-                               skb->data += 4;
-                               skb->tail += 4;
-                               skb_put(skb, FrameSize);
-                               skb_reset_mac_header(skb);
-                               skb->pkt_type = PACKET_OTHERHOST;
-                               skb->protocol = htons(ETH_P_802_2);
-                               memset(skb->cb, 0, sizeof(skb->cb));
-                               netif_rx(skb);
-                               return true;
-                       }
-               }
-
+       struct ieee80211_hw *hw = priv->hw;
+       struct ieee80211_supported_band *sband;
+       struct ieee80211_rx_status rx_status = { 0 };
+       struct ieee80211_hdr *hdr;
+       __le16 fc;
+       u8 *rsr, *new_rsr, *rssi;
+       __le64 *tsf_time;
+       u16 frame_size;
+       int ii, r;
+       u8 *rx_sts, *rx_rate, *sq;
+       u8 *skb_data;
+       u8 rate_idx = 0;
+       u8 rate[MAX_RATE] = {2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108};
+       long rx_dbm;
+
+       /* [31:16]RcvByteCount ( not include 4-byte Status ) */
+       frame_size = le16_to_cpu(*((__le16 *)(skb->data + 2)));
+       if (frame_size > 2346 || frame_size < 14) {
+               dev_dbg(&priv->pcid->dev, "------- WRONG Length 1\n");
                return false;
-       } else {
-               if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
-                       //In AP mode, hw only check addr1(BSSID or RA) if equal to local MAC.
-                       if (!(*pbyRsr & RSR_BSSIDOK)) {
-                               if (bDeFragRx) {
-                                       if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
-                                               pr_err("%s: can not alloc more frag bufs\n",
-                                                      pDevice->dev->name);
-                                       }
-                               }
-                               return false;
-                       }
-               } else {
-                       // discard DATA packet while not associate || BSSID error
-                       if (!pDevice->bLinkPass || !(*pbyRsr & RSR_BSSIDOK)) {
-                               if (bDeFragRx) {
-                                       if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
-                                               pr_err("%s: can not alloc more frag bufs\n",
-                                                      pDevice->dev->name);
-                                       }
-                               }
-                               return false;
-                       }
-                       //mike add:station mode check eapol-key challenge--->
-                       {
-                               unsigned char Protocol_Version;    //802.1x Authentication
-                               unsigned char Packet_Type;           //802.1x Authentication
-
-                               if (bIsWEP)
-                                       cbIVOffset = 8;
-                               else
-                                       cbIVOffset = 0;
-                               wEtherType = (skb->data[cbIVOffset + 8 + 24 + 6] << 8) |
-                                       skb->data[cbIVOffset + 8 + 24 + 6 + 1];
-                               Protocol_Version = skb->data[cbIVOffset + 8 + 24 + 6 + 1 + 1];
-                               Packet_Type = skb->data[cbIVOffset + 8 + 24 + 6 + 1 + 1 + 1];
-                               if (wEtherType == ETH_P_PAE) {         //Protocol Type in LLC-Header
-                                       if (((Protocol_Version == 1) || (Protocol_Version == 2)) &&
-                                           (Packet_Type == 3)) {  //802.1x OR eapol-key challenge frame receive
-                                               bRxeapol_key = true;
-                                       }
-                               }
-                       }
-                       //mike add:station mode check eapol-key challenge<---
-               }
-       }
-
-// Data frame Handle
-
-       if (pDevice->bEnablePSMode) {
-               if (!IS_FC_MOREDATA((skb->data+4))) {
-                       if (pDevice->pMgmt->bInTIMWake == true)
-                               pDevice->pMgmt->bInTIMWake = false;
-               }
-       }
-
-       // Now it only supports 802.11g Infrastructure Mode, and support rate must up to 54 Mbps
-       if (pDevice->bDiversityEnable && (FrameSize > 50) &&
-           (pDevice->op_mode == NL80211_IFTYPE_STATION) &&
-           pDevice->bLinkPass) {
-               BBvAntennaDiversity(pDevice, s_byGetRateIdx(*pbyRxRate), 0);
-       }
-
-       if (pDevice->byLocalID != REV_ID_VT3253_B1)
-               pDevice->uCurrRSSI = *pbyRSSI;
-
-       pDevice->byCurrSQ = *pbySQ;
-
-       if ((*pbyRSSI != 0) &&
-           (pMgmt->pCurrBSS != NULL)) {
-               RFvRSSITodBm(pDevice, *pbyRSSI, &ldBm);
-               // Monitor if RSSI is too strong.
-               pMgmt->pCurrBSS->byRSSIStatCnt++;
-               pMgmt->pCurrBSS->byRSSIStatCnt %= RSSI_STAT_COUNT;
-               pMgmt->pCurrBSS->ldBmAverage[pMgmt->pCurrBSS->byRSSIStatCnt] = ldBm;
-               for (ii = 0; ii < RSSI_STAT_COUNT; ii++)
-                       if (pMgmt->pCurrBSS->ldBmAverage[ii] != 0)
-                               pMgmt->pCurrBSS->ldBmMAX = max(pMgmt->pCurrBSS->ldBmAverage[ii], ldBm);
-
        }
 
-       // -----------------------------------------------
+       skb_data = (u8 *)skb->data;
 
-       if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && pDevice->bEnable8021x) {
-               unsigned char abyMacHdr[24];
+       rx_sts = skb_data;
+       rx_rate = skb_data + 1;
 
-               // Only 802.1x packet incoming allowed
-               if (bIsWEP)
-                       cbIVOffset = 8;
-               else
-                       cbIVOffset = 0;
-               wEtherType = (skb->data[cbIVOffset + 4 + 24 + 6] << 8) |
-                       skb->data[cbIVOffset + 4 + 24 + 6 + 1];
+       sband = hw->wiphy->bands[hw->conf.chandef.chan->band];
 
-               pr_debug("wEtherType = %04x\n", wEtherType);
-               if (wEtherType == ETH_P_PAE) {
-                       skb->dev = pDevice->apdev;
-
-                       if (bIsWEP) {
-                               // strip IV header(8)
-                               memcpy(&abyMacHdr[0], (skb->data + 4), 24);
-                               memcpy((skb->data + 4 + cbIVOffset), &abyMacHdr[0], 24);
-                       }
-                       skb->data +=  (cbIVOffset + 4);
-                       skb->tail +=  (cbIVOffset + 4);
-                       skb_put(skb, FrameSize);
-                       skb_reset_mac_header(skb);
-
-                       skb->pkt_type = PACKET_OTHERHOST;
-                       skb->protocol = htons(ETH_P_802_2);
-                       memset(skb->cb, 0, sizeof(skb->cb));
-                       netif_rx(skb);
-                       return true;
-
-               }
-               // check if 802.1x authorized
-               if (!(pMgmt->sNodeDBTable[iSANodeIndex].dwFlags & WLAN_STA_AUTHORIZED))
-                       return false;
+       for (r = RATE_1M; r < MAX_RATE; r++) {
+               if (*rx_rate == rate[r])
+                       break;
        }
 
-       if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) {
-               if (bIsWEP)
-                       FrameSize -= 8;  //MIC
-       }
-
-       //--------------------------------------------------------------------------------
-       // Soft MIC
-       if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) {
-               if (bIsWEP) {
-                       __le32 *pdwMIC_L;
-                       __le32 *pdwMIC_R;
-                       __le32 dwMIC_Priority;
-                       __le32 dwMICKey0 = 0, dwMICKey1 = 0;
-                       u32 dwLocalMIC_L = 0;
-                       u32 dwLocalMIC_R = 0;
-                       viawget_wpa_header *wpahdr;
-
-                       if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
-                               dwMICKey0 = cpu_to_le32(*(u32 *)(&pKey->abyKey[24]));
-                               dwMICKey1 = cpu_to_le32(*(u32 *)(&pKey->abyKey[28]));
-                       } else {
-                               if (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
-                                       dwMICKey0 = cpu_to_le32(*(u32 *)(&pKey->abyKey[16]));
-                                       dwMICKey1 = cpu_to_le32(*(u32 *)(&pKey->abyKey[20]));
-                               } else if ((pKey->dwKeyIndex & BIT28) == 0) {
-                                       dwMICKey0 = cpu_to_le32(*(u32 *)(&pKey->abyKey[16]));
-                                       dwMICKey1 = cpu_to_le32(*(u32 *)(&pKey->abyKey[20]));
-                               } else {
-                                       dwMICKey0 = cpu_to_le32(*(u32 *)(&pKey->abyKey[24]));
-                                       dwMICKey1 = cpu_to_le32(*(u32 *)(&pKey->abyKey[28]));
-                               }
-                       }
-
-                       MIC_vInit(dwMICKey0, dwMICKey1);
-                       MIC_vAppend((unsigned char *)&(pDevice->sRxEthHeader.abyDstAddr[0]), 12);
-                       dwMIC_Priority = 0;
-                       MIC_vAppend((unsigned char *)&dwMIC_Priority, 4);
-                       // 4 is Rcv buffer header, 24 is MAC Header, and 8 is IV and Ext IV.
-                       MIC_vAppend((unsigned char *)(skb->data + 4 + WLAN_HDR_ADDR3_LEN + 8),
-                                   FrameSize - WLAN_HDR_ADDR3_LEN - 8);
-                       MIC_vGetMIC(&dwLocalMIC_L, &dwLocalMIC_R);
-                       MIC_vUnInit();
-
-                       pdwMIC_L = (__le32 *)(skb->data + 4 + FrameSize);
-                       pdwMIC_R = (__le32 *)(skb->data + 4 + FrameSize + 4);
-
-                       if ((le32_to_cpu(*pdwMIC_L) != dwLocalMIC_L) ||
-                           (le32_to_cpu(*pdwMIC_R) != dwLocalMIC_R) ||
-                           pDevice->bRxMICFail) {
-                               pr_debug("MIC comparison is fail!\n");
-                               pDevice->bRxMICFail = false;
-                               pDevice->s802_11Counter.TKIPLocalMICFailures++;
-                               if (bDeFragRx) {
-                                       if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
-                                               pr_err("%s: can not alloc more frag bufs\n",
-                                                      pDevice->dev->name);
-                                       }
-                               }
-                               //2008-0409-07, <Add> by Einsn Liu
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-                               //send event to wpa_supplicant
-                               {
-                                       union iwreq_data wrqu;
-                                       struct iw_michaelmicfailure ev;
-                                       int keyidx = pbyFrame[cbHeaderSize+3] >> 6; //top two-bits
-
-                                       memset(&ev, 0, sizeof(ev));
-                                       ev.flags = keyidx & IW_MICFAILURE_KEY_ID;
-                                       if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
-                                           (pMgmt->eCurrState == WMAC_STATE_ASSOC) &&
-                                           (*pbyRsr & (RSR_ADDRBROAD | RSR_ADDRMULTI)) == 0) {
-                                               ev.flags |= IW_MICFAILURE_PAIRWISE;
-                                       } else {
-                                               ev.flags |= IW_MICFAILURE_GROUP;
-                                       }
-
-                                       ev.src_addr.sa_family = ARPHRD_ETHER;
-                                       memcpy(ev.src_addr.sa_data, pMACHeader->abyAddr2, ETH_ALEN);
-                                       memset(&wrqu, 0, sizeof(wrqu));
-                                       wrqu.data.length = sizeof(ev);
-                                       wireless_send_event(pDevice->dev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&ev);
-
-                               }
-#endif
+       priv->rx_rate = r;
 
-                               if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
-                                       wpahdr = (viawget_wpa_header *)pDevice->skb->data;
-                                       if ((pDevice->pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
-                                           (pDevice->pMgmt->eCurrState == WMAC_STATE_ASSOC) &&
-                                           (*pbyRsr & (RSR_ADDRBROAD | RSR_ADDRMULTI)) == 0) {
-                                               wpahdr->type = VIAWGET_PTK_MIC_MSG;
-                                       } else {
-                                               wpahdr->type = VIAWGET_GTK_MIC_MSG;
-                                       }
-                                       wpahdr->resp_ie_len = 0;
-                                       wpahdr->req_ie_len = 0;
-                                       skb_put(pDevice->skb, sizeof(viawget_wpa_header));
-                                       pDevice->skb->dev = pDevice->wpadev;
-                                       skb_reset_mac_header(pDevice->skb);
-                                       pDevice->skb->pkt_type = PACKET_HOST;
-                                       pDevice->skb->protocol = htons(ETH_P_802_2);
-                                       memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
-                                       netif_rx(pDevice->skb);
-                                       pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
-                               }
-
-                               return false;
-
-                       }
-               }
-       } //---end of SOFT MIC-----------------------------------------------------------------------
-
-       // ++++++++++ Reply Counter Check +++++++++++++
-
-       if ((pKey != NULL) && ((pKey->byCipherSuite == KEY_CTL_TKIP) ||
-                              (pKey->byCipherSuite == KEY_CTL_CCMP))) {
-               if (bIsWEP) {
-                       unsigned short wLocalTSC15_0 = 0;
-                       unsigned long dwLocalTSC47_16 = 0;
-                       unsigned long long       RSC = 0;
-                       // endian issues
-                       RSC = *((unsigned long long *)&(pKey->KeyRSC));
-                       wLocalTSC15_0 = (unsigned short)RSC;
-                       dwLocalTSC47_16 = (unsigned long)(RSC>>16);
-
-                       RSC = dwRxTSC47_16;
-                       RSC <<= 16;
-                       RSC += wRxTSC15_0;
-                       pKey->KeyRSC = RSC;
-
-                       if ((pDevice->sMgmtObj.eCurrMode == WMAC_MODE_ESS_STA) &&
-                           (pDevice->sMgmtObj.eCurrState == WMAC_STATE_ASSOC)) {
-                               // check RSC
-                               if ((wRxTSC15_0 < wLocalTSC15_0) &&
-                                   (dwRxTSC47_16 <= dwLocalTSC47_16) &&
-                                   !((dwRxTSC47_16 == 0) && (dwLocalTSC47_16 == 0xFFFFFFFF))) {
-                                       pr_debug("TSC is illegal~~!\n ");
-                                       if (pKey->byCipherSuite == KEY_CTL_TKIP)
-                                               pDevice->s802_11Counter.TKIPReplays++;
-                                       else
-                                               pDevice->s802_11Counter.CCMPReplays++;
-
-                                       if (bDeFragRx) {
-                                               if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
-                                                       pr_err("%s: can not alloc more frag bufs\n",
-                                                              pDevice->dev->name);
-                                               }
-                                       }
-                                       return false;
-                               }
-                       }
-               }
-       } // ----- End of Reply Counter Check --------------------------
-
-       s_vProcessRxMACHeader(pDevice, (unsigned char *)(skb->data+4), FrameSize, bIsWEP, bExtIV, &cbHeaderOffset);
-       FrameSize -= cbHeaderOffset;
-       cbHeaderOffset += 4;        // 4 is Rcv buffer header
-
-       // Null data, framesize = 14
-       if (FrameSize < 15)
-               return false;
-
-       if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
-               if (!s_bAPModeRxData(pDevice,
-                                   skb,
-                                   FrameSize,
-                                   cbHeaderOffset,
-                                   iSANodeIndex,
-                                   iDANodeIndex
-)) {
-                       if (bDeFragRx) {
-                               if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
-                                       pr_err("%s: can not alloc more frag bufs\n",
-                                              pDevice->dev->name);
-                               }
-                       }
-                       return false;
+       for (ii = 0; ii < sband->n_bitrates; ii++) {
+               if (sband->bitrates[ii].hw_value == r) {
+                       rate_idx = ii;
+                               break;
                }
        }
 
-       skb->data += cbHeaderOffset;
-       skb->tail += cbHeaderOffset;
-       skb_put(skb, FrameSize);
-       skb->protocol = eth_type_trans(skb, skb->dev);
-
-       //drop frame not met IEEE 802.3
-
-       skb->ip_summed = CHECKSUM_NONE;
-       pStats->rx_bytes += skb->len;
-       pStats->rx_packets++;
-       netif_rx(skb);
-
-       if (bDeFragRx) {
-               if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
-                       pr_err("%s: can not alloc more frag bufs\n",
-                              pDevice->dev->name);
-               }
+       if (ii == sband->n_bitrates) {
+               dev_dbg(&priv->pcid->dev, "Wrong RxRate %x\n", *rx_rate);
                return false;
        }
 
-       return true;
-}
-
-static bool s_bAPModeRxCtl(
-       struct vnt_private *pDevice,
-       unsigned char *pbyFrame,
-       int      iSANodeIndex
-)
-{
-       PS802_11Header      p802_11Header;
-       CMD_STATUS          Status;
-       PSMgmtObject        pMgmt = pDevice->pMgmt;
-
-       if (IS_CTL_PSPOLL(pbyFrame) || !IS_TYPE_CONTROL(pbyFrame)) {
-               p802_11Header = (PS802_11Header)(pbyFrame);
-               if (!IS_TYPE_MGMT(pbyFrame)) {
-                       // Data & PS-Poll packet
-                       // check frame class
-                       if (iSANodeIndex > 0) {
-                               // frame class 3 fliter & checking
-                               if (pMgmt->sNodeDBTable[iSANodeIndex].eNodeState < NODE_AUTH) {
-                                       // send deauth notification
-                                       // reason = (6) class 2 received from nonauth sta
-                                       vMgrDeAuthenBeginSta(pDevice,
-                                                            pMgmt,
-                                                            (unsigned char *)(p802_11Header->abyAddr2),
-                                                            (WLAN_MGMT_REASON_CLASS2_NONAUTH),
-                                                            &Status
-);
-                                       pr_debug("dpc: send vMgrDeAuthenBeginSta 1\n");
-                                       return true;
-                               }
-                               if (pMgmt->sNodeDBTable[iSANodeIndex].eNodeState < NODE_ASSOC) {
-                                       // send deassoc notification
-                                       // reason = (7) class 3 received from nonassoc sta
-                                       vMgrDisassocBeginSta(pDevice,
-                                                            pMgmt,
-                                                            (unsigned char *)(p802_11Header->abyAddr2),
-                                                            (WLAN_MGMT_REASON_CLASS3_NONASSOC),
-                                                            &Status
-);
-                                       pr_debug("dpc: send vMgrDisassocBeginSta 2\n");
-                                       return true;
-                               }
-
-                               if (pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable) {
-                                       // delcare received ps-poll event
-                                       if (IS_CTL_PSPOLL(pbyFrame)) {
-                                               pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = true;
-                                               bScheduleCommand((void *)pDevice, WLAN_CMD_RX_PSPOLL, NULL);
-                                               pr_debug("dpc: WLAN_CMD_RX_PSPOLL 1\n");
-                                       } else {
-                                               // check Data PS state
-                                               // if PW bit off, send out all PS bufferring packets.
-                                               if (!IS_FC_POWERMGT(pbyFrame)) {
-                                                       pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = false;
-                                                       pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = true;
-                                                       bScheduleCommand((void *)pDevice, WLAN_CMD_RX_PSPOLL, NULL);
-                                                       pr_debug("dpc: WLAN_CMD_RX_PSPOLL 2\n");
-                                               }
-                                       }
-                               } else {
-                                       if (IS_FC_POWERMGT(pbyFrame)) {
-                                               pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = true;
-                                               // Once if STA in PS state, enable multicast bufferring
-                                               pMgmt->sNodeDBTable[0].bPSEnable = true;
-                                       } else {
-                                               // clear all pending PS frame.
-                                               if (pMgmt->sNodeDBTable[iSANodeIndex].wEnQueueCnt > 0) {
-                                                       pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = false;
-                                                       pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = true;
-                                                       bScheduleCommand((void *)pDevice, WLAN_CMD_RX_PSPOLL, NULL);
-                                                       pr_debug("dpc: WLAN_CMD_RX_PSPOLL 3\n");
-
-                                               }
-                                       }
-                               }
-                       } else {
-                               vMgrDeAuthenBeginSta(pDevice,
-                                                    pMgmt,
-                                                    (unsigned char *)(p802_11Header->abyAddr2),
-                                                    (WLAN_MGMT_REASON_CLASS2_NONAUTH),
-                                                    &Status
-);
-                               pr_debug("dpc: send vMgrDeAuthenBeginSta 3\n");
-                               pr_debug("BSSID:%pM\n",
-                                        p802_11Header->abyAddr3);
-                               pr_debug("ADDR2:%pM\n",
-                                        p802_11Header->abyAddr2);
-                               pr_debug("ADDR1:%pM\n",
-                                        p802_11Header->abyAddr1);
-                               pr_debug("dpc: wFrameCtl= %x\n",
-                                        p802_11Header->wFrameCtl);
-                               VNSvInPortB(pDevice->PortOffset + MAC_REG_RCR, &(pDevice->byRxMode));
-                               pr_debug("dpc:pDevice->byRxMode = %x\n",
-                                        pDevice->byRxMode);
-                               return true;
-                       }
-               }
-       }
-       return false;
-}
-
-static bool s_bHandleRxEncryption(
-       struct vnt_private *pDevice,
-       unsigned char *pbyFrame,
-       unsigned int FrameSize,
-       unsigned char *pbyRsr,
-       unsigned char *pbyNewRsr,
-       PSKeyItem   *pKeyOut,
-       bool *pbExtIV,
-       unsigned short *pwRxTSC15_0,
-       unsigned long *pdwRxTSC47_16
-)
-{
-       unsigned int PayloadLen = FrameSize;
-       unsigned char *pbyIV;
-       unsigned char byKeyIdx;
-       PSKeyItem       pKey = NULL;
-       unsigned char byDecMode = KEY_CTL_WEP;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
+       tsf_time = (__le64 *)(skb_data + bytes_received - 12);
+       sq = skb_data + bytes_received - 4;
+       new_rsr = skb_data + bytes_received - 3;
+       rssi = skb_data + bytes_received - 2;
+       rsr = skb_data + bytes_received - 1;
 
-       *pwRxTSC15_0 = 0;
-       *pdwRxTSC47_16 = 0;
+       RFvRSSITodBm(priv, *rssi, &rx_dbm);
 
-       pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN;
-       if (WLAN_GET_FC_TODS(*(unsigned short *)pbyFrame) &&
-           WLAN_GET_FC_FROMDS(*(unsigned short *)pbyFrame)) {
-               pbyIV += 6;             // 6 is 802.11 address4
-               PayloadLen -= 6;
-       }
-       byKeyIdx = (*(pbyIV+3) & 0xc0);
-       byKeyIdx >>= 6;
-       pr_debug("\nKeyIdx: %d\n", byKeyIdx);
+       priv->byBBPreEDRSSI = (u8)rx_dbm + 1;
+       priv->uCurrRSSI = *rssi;
 
-       if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA) ||
-           (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) ||
-           (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) ||
-           (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
-           (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) {
-               if (((*pbyRsr & (RSR_ADDRBROAD | RSR_ADDRMULTI)) == 0) &&
-                   (pDevice->pMgmt->byCSSPK != KEY_CTL_NONE)) {
-                       // unicast pkt use pairwise key
-                       pr_debug("unicast pkt\n");
-                       if (KeybGetKey(&(pDevice->sKey), pDevice->abyBSSID, 0xFFFFFFFF, &pKey) == true) {
-                               if (pDevice->pMgmt->byCSSPK == KEY_CTL_TKIP)
-                                       byDecMode = KEY_CTL_TKIP;
-                               else if (pDevice->pMgmt->byCSSPK == KEY_CTL_CCMP)
-                                       byDecMode = KEY_CTL_CCMP;
-                       }
-                       pr_debug("unicast pkt: %d, %p\n", byDecMode, pKey);
-               } else {
-                       // use group key
-                       KeybGetKey(&(pDevice->sKey), pDevice->abyBSSID, byKeyIdx, &pKey);
-                       if (pDevice->pMgmt->byCSSGK == KEY_CTL_TKIP)
-                               byDecMode = KEY_CTL_TKIP;
-                       else if (pDevice->pMgmt->byCSSGK == KEY_CTL_CCMP)
-                               byDecMode = KEY_CTL_CCMP;
-                       pr_debug("group pkt: %d, %d, %p\n",
-                                byKeyIdx, byDecMode, pKey);
-               }
-       }
-       // our WEP only support Default Key
-       if (pKey == NULL) {
-               // use default group key
-               KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, byKeyIdx, &pKey);
-               if (pDevice->pMgmt->byCSSGK == KEY_CTL_TKIP)
-                       byDecMode = KEY_CTL_TKIP;
-               else if (pDevice->pMgmt->byCSSGK == KEY_CTL_CCMP)
-                       byDecMode = KEY_CTL_CCMP;
-       }
-       *pKeyOut = pKey;
+       skb_pull(skb, 4);
+       skb_trim(skb, frame_size);
 
-       pr_debug("AES:%d %d %d\n",
-                pDevice->pMgmt->byCSSPK, pDevice->pMgmt->byCSSGK, byDecMode);
+       rx_status.mactime = le64_to_cpu(*tsf_time);
+       rx_status.band = hw->conf.chandef.chan->band;
+       rx_status.signal = rx_dbm;
+       rx_status.flag = 0;
+       rx_status.freq = hw->conf.chandef.chan->center_freq;
 
-       if (pKey == NULL) {
-               pr_debug("pKey == NULL\n");
+       hdr = (struct ieee80211_hdr *)(skb->data);
+       fc = hdr->frame_control;
 
-               return false;
-       }
-       if (byDecMode != pKey->byCipherSuite) {
+       rx_status.rate_idx = rate_idx;
 
-               *pKeyOut = NULL;
-               return false;
+       if (ieee80211_has_protected(fc)) {
+               if (priv->byLocalID > REV_ID_VT3253_A1)
+                       rx_status.flag = RX_FLAG_DECRYPTED;
        }
-       if (byDecMode == KEY_CTL_WEP) {
-               // handle WEP
-               if ((pDevice->byLocalID <= REV_ID_VT3253_A1) ||
-                   (((PSKeyTable)(pKey->pvKeyTable))->bSoftWEP == true)) {
-                       // Software WEP
-                       // 1. 3253A
-                       // 2. WEP 256
-
-                       PayloadLen -= (WLAN_HDR_ADDR3_LEN + 4 + 4); // 24 is 802.11 header,4 is IV, 4 is crc
-                       memcpy(pDevice->abyPRNG, pbyIV, 3);
-                       memcpy(pDevice->abyPRNG + 3, pKey->abyKey, pKey->uKeyLength);
-                       rc4_init(&pDevice->SBox, pDevice->abyPRNG, pKey->uKeyLength + 3);
-                       rc4_encrypt(&pDevice->SBox, pbyIV+4, pbyIV+4, PayloadLen);
-
-                       if (ETHbIsBufferCrc32Ok(pbyIV+4, PayloadLen))
-                               *pbyNewRsr |= NEWRSR_DECRYPTOK;
-
-               }
-       } else if ((byDecMode == KEY_CTL_TKIP) ||
-                  (byDecMode == KEY_CTL_CCMP)) {
-               // TKIP/AES
-
-               PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); // 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc
-               *pdwRxTSC47_16 = cpu_to_le32(*(unsigned long *)(pbyIV + 4));
-               pr_debug("ExtIV: %lx\n", *pdwRxTSC47_16);
-               if (byDecMode == KEY_CTL_TKIP)
-                       *pwRxTSC15_0 = cpu_to_le16(MAKEWORD(*(pbyIV + 2), *pbyIV));
-               else
-                       *pwRxTSC15_0 = cpu_to_le16(*(unsigned short *)pbyIV);
-
-               pr_debug("TSC0_15: %x\n", *pwRxTSC15_0);
-
-               if ((byDecMode == KEY_CTL_TKIP) &&
-                   (pDevice->byLocalID <= REV_ID_VT3253_A1)) {
-                       // Software TKIP
-                       // 1. 3253 A
-                       PS802_11Header  pMACHeader = (PS802_11Header)(pbyFrame);
-
-                       TKIPvMixKey(pKey->abyKey, pMACHeader->abyAddr2, *pwRxTSC15_0, *pdwRxTSC47_16, pDevice->abyPRNG);
-                       rc4_init(&pDevice->SBox, pDevice->abyPRNG, TKIP_KEY_LEN);
-                       rc4_encrypt(&pDevice->SBox, pbyIV+8, pbyIV+8, PayloadLen);
-                       if (ETHbIsBufferCrc32Ok(pbyIV+8, PayloadLen)) {
-                               *pbyNewRsr |= NEWRSR_DECRYPTOK;
-                               pr_debug("ICV OK!\n");
-                       } else {
-                               pr_debug("ICV FAIL!!!\n");
-                               pr_debug("PayloadLen = %d\n", PayloadLen);
-                       }
-               }
-       }// end of TKIP/AES
-
-       if ((*(pbyIV+3) & 0x20) != 0)
-               *pbExtIV = true;
-       return true;
-}
-
-static bool s_bHostWepRxEncryption(
-       struct vnt_private *pDevice,
-       unsigned char *pbyFrame,
-       unsigned int FrameSize,
-       unsigned char *pbyRsr,
-       bool bOnFly,
-       PSKeyItem    pKey,
-       unsigned char *pbyNewRsr,
-       bool *pbExtIV,
-       unsigned short *pwRxTSC15_0,
-       unsigned long *pdwRxTSC47_16
-)
-{
-       unsigned int PayloadLen = FrameSize;
-       unsigned char *pbyIV;
-       unsigned char byKeyIdx;
-       unsigned char byDecMode = KEY_CTL_WEP;
-       PS802_11Header  pMACHeader;
 
-       *pwRxTSC15_0 = 0;
-       *pdwRxTSC47_16 = 0;
-
-       pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN;
-       if (WLAN_GET_FC_TODS(*(unsigned short *)pbyFrame) &&
-           WLAN_GET_FC_FROMDS(*(unsigned short *)pbyFrame)) {
-               pbyIV += 6;             // 6 is 802.11 address4
-               PayloadLen -= 6;
+       if (priv->vif && priv->bDiversityEnable) {
+               if (ieee80211_is_data(fc) &&
+                   (frame_size > 50) && priv->vif->bss_conf.assoc)
+                       BBvAntennaDiversity(priv, priv->rx_rate, 0);
        }
-       byKeyIdx = (*(pbyIV+3) & 0xc0);
-       byKeyIdx >>= 6;
-       pr_debug("\nKeyIdx: %d\n", byKeyIdx);
-
-       if (pDevice->pMgmt->byCSSGK == KEY_CTL_TKIP)
-               byDecMode = KEY_CTL_TKIP;
-       else if (pDevice->pMgmt->byCSSGK == KEY_CTL_CCMP)
-               byDecMode = KEY_CTL_CCMP;
-
-       pr_debug("AES:%d %d %d\n",
-                pDevice->pMgmt->byCSSPK, pDevice->pMgmt->byCSSGK, byDecMode);
-
-       if (byDecMode != pKey->byCipherSuite)
-               return false;
-
-       if (byDecMode == KEY_CTL_WEP) {
-               // handle WEP
-               pr_debug("byDecMode == KEY_CTL_WEP\n");
-
-               if ((pDevice->byLocalID <= REV_ID_VT3253_A1) ||
-                   (((PSKeyTable)(pKey->pvKeyTable))->bSoftWEP == true) ||
-                   !bOnFly) {
-                       // Software WEP
-                       // 1. 3253A
-                       // 2. WEP 256
-                       // 3. NotOnFly
 
-                       PayloadLen -= (WLAN_HDR_ADDR3_LEN + 4 + 4); // 24 is 802.11 header,4 is IV, 4 is crc
-                       memcpy(pDevice->abyPRNG, pbyIV, 3);
-                       memcpy(pDevice->abyPRNG + 3, pKey->abyKey, pKey->uKeyLength);
-                       rc4_init(&pDevice->SBox, pDevice->abyPRNG, pKey->uKeyLength + 3);
-                       rc4_encrypt(&pDevice->SBox, pbyIV+4, pbyIV+4, PayloadLen);
+       memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status));
 
-                       if (ETHbIsBufferCrc32Ok(pbyIV+4, PayloadLen))
-                               *pbyNewRsr |= NEWRSR_DECRYPTOK;
+       ieee80211_rx_irqsafe(priv->hw, skb);
 
-               }
-       } else if ((byDecMode == KEY_CTL_TKIP) ||
-                  (byDecMode == KEY_CTL_CCMP)) {
-               // TKIP/AES
-
-               PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); // 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc
-               *pdwRxTSC47_16 = cpu_to_le32(*(unsigned long *)(pbyIV + 4));
-               pr_debug("ExtIV: %lx\n", *pdwRxTSC47_16);
-
-               if (byDecMode == KEY_CTL_TKIP)
-                       *pwRxTSC15_0 = cpu_to_le16(MAKEWORD(*(pbyIV+2), *pbyIV));
-               else
-                       *pwRxTSC15_0 = cpu_to_le16(*(unsigned short *)pbyIV);
-
-               pr_debug("TSC0_15: %x\n", *pwRxTSC15_0);
-
-               if (byDecMode == KEY_CTL_TKIP) {
-                       if ((pDevice->byLocalID <= REV_ID_VT3253_A1) || !bOnFly) {
-                               // Software TKIP
-                               // 1. 3253 A
-                               // 2. NotOnFly
-                               pr_debug("soft KEY_CTL_TKIP\n");
-                               pMACHeader = (PS802_11Header)(pbyFrame);
-                               TKIPvMixKey(pKey->abyKey, pMACHeader->abyAddr2, *pwRxTSC15_0, *pdwRxTSC47_16, pDevice->abyPRNG);
-                               rc4_init(&pDevice->SBox, pDevice->abyPRNG, TKIP_KEY_LEN);
-                               rc4_encrypt(&pDevice->SBox, pbyIV+8, pbyIV+8, PayloadLen);
-                               if (ETHbIsBufferCrc32Ok(pbyIV+8, PayloadLen)) {
-                                       *pbyNewRsr |= NEWRSR_DECRYPTOK;
-                                       pr_debug("ICV OK!\n");
-                               } else {
-                                       pr_debug("ICV FAIL!!!\n");
-                                       pr_debug("PayloadLen = %d\n",
-                                                PayloadLen);
-                               }
-                       }
-               }
-
-               if (byDecMode == KEY_CTL_CCMP) {
-                       if (!bOnFly) {
-                               // Software CCMP
-                               // NotOnFly
-                               pr_debug("soft KEY_CTL_CCMP\n");
-                               if (AESbGenCCMP(pKey->abyKey, pbyFrame, FrameSize)) {
-                                       *pbyNewRsr |= NEWRSR_DECRYPTOK;
-                                       pr_debug("CCMP MIC compare OK!\n");
-                               } else {
-                                       pr_debug("CCMP MIC fail!\n");
-                               }
-                       }
-               }
-
-       }// end of TKIP/AES
-
-       if ((*(pbyIV+3) & 0x20) != 0)
-               *pbExtIV = true;
        return true;
 }
 
-static bool s_bAPModeRxData(
-       struct vnt_private *pDevice,
-       struct sk_buff *skb,
-       unsigned int FrameSize,
-       unsigned int cbHeaderOffset,
-       int      iSANodeIndex,
-       int      iDANodeIndex
-)
+bool vnt_receive_frame(struct vnt_private *priv, PSRxDesc curr_rd)
 {
-       PSMgmtObject        pMgmt = pDevice->pMgmt;
-       bool bRelayAndForward = false;
-       bool bRelayOnly = false;
-       unsigned char byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
-       unsigned short wAID;
-
-       struct sk_buff *skbcpy = NULL;
+       PDEVICE_RD_INFO rd_info = curr_rd->pRDInfo;
+       struct sk_buff *skb;
+       u16 frame_size;
 
-       if (FrameSize > CB_MAX_BUF_SIZE)
-               return false;
-       // check DA
-       if (is_multicast_ether_addr((unsigned char *)(skb->data+cbHeaderOffset))) {
-               if (pMgmt->sNodeDBTable[0].bPSEnable) {
-                       skbcpy = dev_alloc_skb((int)pDevice->rx_buf_sz);
+       skb = rd_info->skb;
 
-                       // if any node in PS mode, buffer packet until DTIM.
-                       if (skbcpy == NULL) {
-                               pr_info("relay multicast no skb available\n");
-                       } else {
-                               skbcpy->dev = pDevice->dev;
-                               skbcpy->len = FrameSize;
-                               memcpy(skbcpy->data, skb->data+cbHeaderOffset, FrameSize);
-                               skb_queue_tail(&(pMgmt->sNodeDBTable[0].sTxPSQueue), skbcpy);
+       pci_unmap_single(priv->pcid, rd_info->skb_dma,
+                        priv->rx_buf_sz, PCI_DMA_FROMDEVICE);
 
-                               pMgmt->sNodeDBTable[0].wEnQueueCnt++;
-                               // set tx map
-                               pMgmt->abyPSTxMap[0] |= byMask[0];
-                       }
-               } else {
-                       bRelayAndForward = true;
-               }
-       } else {
-               // check if relay
-               if (BSSDBbIsSTAInNodeDB(pMgmt, (unsigned char *)(skb->data+cbHeaderOffset), &iDANodeIndex)) {
-                       if (pMgmt->sNodeDBTable[iDANodeIndex].eNodeState >= NODE_ASSOC) {
-                               if (pMgmt->sNodeDBTable[iDANodeIndex].bPSEnable) {
-                                       // queue this skb until next PS tx, and then release.
+       frame_size = le16_to_cpu(curr_rd->m_rd1RD1.wReqCount)
+                       - cpu_to_le16(curr_rd->m_rd0RD0.wResCount);
 
-                                       skb->data += cbHeaderOffset;
-                                       skb->tail += cbHeaderOffset;
-                                       skb_put(skb, FrameSize);
-                                       skb_queue_tail(&pMgmt->sNodeDBTable[iDANodeIndex].sTxPSQueue, skb);
-                                       pMgmt->sNodeDBTable[iDANodeIndex].wEnQueueCnt++;
-                                       wAID = pMgmt->sNodeDBTable[iDANodeIndex].wAID;
-                                       pMgmt->abyPSTxMap[wAID >> 3] |=  byMask[wAID & 7];
-                                       pr_debug("relay: index= %d, pMgmt->abyPSTxMap[%d]= %d\n",
-                                                iDANodeIndex, (wAID >> 3),
-                                                pMgmt->abyPSTxMap[wAID >> 3]);
-                                       return true;
-                               } else {
-                                       bRelayOnly = true;
-                               }
-                       }
-               }
+       if ((frame_size > 2364) || (frame_size < 33)) {
+               /* Frame Size error drop this packet.*/
+               dev_dbg(&priv->pcid->dev, "Wrong frame size %d\n", frame_size);
+               dev_kfree_skb_irq(skb);
+               return true;
        }
 
-       if (bRelayOnly || bRelayAndForward) {
-               // relay this packet right now
-               if (bRelayAndForward)
-                       iDANodeIndex = 0;
+       if (vnt_rx_data(priv, skb, frame_size))
+               return true;
 
-               if ((pDevice->uAssocCount > 1) && (iDANodeIndex >= 0))
-                       ROUTEbRelay(pDevice, (unsigned char *)(skb->data + cbHeaderOffset), FrameSize, (unsigned int)iDANodeIndex);
-
-               if (bRelayOnly)
-                       return false;
-       }
-       // none associate, don't forward
-       if (pDevice->uAssocCount == 0)
-               return false;
+       dev_kfree_skb_irq(skb);
 
        return true;
 }
index a068b84..ad49571 100644 (file)
 #ifndef __DPC_H__
 #define __DPC_H__
 
-#include "ttype.h"
 #include "device.h"
-#include "wcmd.h"
 
-bool
-device_receive_frame(
-       struct vnt_private *,
-       PSRxDesc pCurrRD
-);
+bool vnt_receive_frame(struct vnt_private *priv, PSRxDesc curr_rd);
 
-#endif // __RXTX_H__
+#endif /* __RXTX_H__ */
diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
deleted file mode 100644 (file)
index ae0dade..0000000
+++ /dev/null
@@ -1,765 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: hostap.c
- *
- * Purpose: handle hostap deamon ioctl input/out functions
- *
- * Author: Lyndon Chen
- *
- * Date: Oct. 20, 2003
- *
- * Functions:
- *
- * Revision History:
- *
- */
-
-#include "hostap.h"
-#include "iocmd.h"
-#include "mac.h"
-#include "card.h"
-#include "baseband.h"
-#include "wpactl.h"
-#include "key.h"
-
-#define VIAWGET_HOSTAPD_MAX_BUF_SIZE 1024
-#define HOSTAP_CRYPT_FLAG_SET_TX_KEY BIT0
-#define HOSTAP_CRYPT_ERR_UNKNOWN_ADDR 3
-#define HOSTAP_CRYPT_ERR_KEY_SET_FAILED 5
-
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Functions  --------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*
- * Description:
- *      register net_device (AP) for hostap deamon
- *
- * Parameters:
- *  In:
- *      pDevice             -
- *      rtnl_locked         -
- *  Out:
- *
- * Return Value:
- *
- */
-
-static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
-{
-       struct vnt_private *apdev_priv;
-       struct net_device *dev = pDevice->dev;
-       int ret;
-       const struct net_device_ops apdev_netdev_ops = {
-               .ndo_start_xmit         = pDevice->tx_80211,
-       };
-
-       pr_debug("%s: Enabling hostapd mode\n", dev->name);
-
-       pDevice->apdev = alloc_etherdev(sizeof(*apdev_priv));
-       if (pDevice->apdev == NULL)
-               return -ENOMEM;
-
-       apdev_priv = netdev_priv(pDevice->apdev);
-       *apdev_priv = *pDevice;
-       eth_hw_addr_inherit(pDevice->apdev, dev);
-
-       pDevice->apdev->netdev_ops = &apdev_netdev_ops;
-
-       pDevice->apdev->type = ARPHRD_IEEE80211;
-
-       pDevice->apdev->base_addr = dev->base_addr;
-       pDevice->apdev->irq = dev->irq;
-       pDevice->apdev->mem_start = dev->mem_start;
-       pDevice->apdev->mem_end = dev->mem_end;
-       sprintf(pDevice->apdev->name, "%sap", dev->name);
-       if (rtnl_locked)
-               ret = register_netdevice(pDevice->apdev);
-       else
-               ret = register_netdev(pDevice->apdev);
-       if (ret) {
-               pr_debug("%s: register_netdevice(AP) failed!\n",
-                        dev->name);
-               free_netdev(pDevice->apdev);
-               pDevice->apdev = NULL;
-               return -1;
-       }
-
-       pr_debug("%s: Registered netdevice %s for AP management\n",
-                dev->name, pDevice->apdev->name);
-
-       KeyvInitTable(&pDevice->sKey, pDevice->PortOffset);
-
-       return 0;
-}
-
-/*
- * Description:
- *      unregister net_device(AP)
- *
- * Parameters:
- *  In:
- *      pDevice             -
- *      rtnl_locked         -
- *  Out:
- *
- * Return Value:
- *
- */
-
-static int hostap_disable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
-{
-       pr_debug("%s: disabling hostapd mode\n", pDevice->dev->name);
-
-       if (pDevice->apdev && pDevice->apdev->name && pDevice->apdev->name[0]) {
-               if (rtnl_locked)
-                       unregister_netdevice(pDevice->apdev);
-               else
-                       unregister_netdev(pDevice->apdev);
-               pr_debug("%s: Netdevice %s unregistered\n",
-                        pDevice->dev->name, pDevice->apdev->name);
-       }
-       if (pDevice->apdev)
-               free_netdev(pDevice->apdev);
-       pDevice->apdev = NULL;
-       pDevice->bEnable8021x = false;
-       pDevice->bEnableHostWEP = false;
-       pDevice->bEncryptionEnable = false;
-
-/* 4.2007-0118-03,<Add> by EinsnLiu */
-/* execute some clear work */
-       pDevice->pMgmt->byCSSPK = KEY_CTL_NONE;
-       pDevice->pMgmt->byCSSGK = KEY_CTL_NONE;
-       KeyvInitTable(&pDevice->sKey, pDevice->PortOffset);
-
-       return 0;
-}
-
-/*
- * Description:
- *      Set enable/disable hostapd mode
- *
- * Parameters:
- *  In:
- *      pDevice             -
- *      rtnl_locked         -
- *  Out:
- *
- * Return Value:
- *
- */
-
-int vt6655_hostap_set_hostapd(struct vnt_private *pDevice,
-                             int val, int rtnl_locked)
-{
-       if (val < 0 || val > 1)
-               return -EINVAL;
-
-       if (pDevice->bEnableHostapd == val)
-               return 0;
-
-       pDevice->bEnableHostapd = val;
-
-       if (val)
-               return hostap_enable_hostapd(pDevice, rtnl_locked);
-       else
-               return hostap_disable_hostapd(pDevice, rtnl_locked);
-}
-
-/*
- * Description:
- *      remove station function supported for hostap deamon
- *
- * Parameters:
- *  In:
- *      pDevice   -
- *      param     -
- *  Out:
- *
- * Return Value:
- *
- */
-static int hostap_remove_sta(struct vnt_private *pDevice,
-                            struct viawget_hostapd_param *param)
-{
-       unsigned int uNodeIndex;
-
-       if (BSSDBbIsSTAInNodeDB(pDevice->pMgmt, param->sta_addr, &uNodeIndex))
-               BSSvRemoveOneNode(pDevice, uNodeIndex);
-       else
-               return -ENOENT;
-
-       return 0;
-}
-
-/*
- * Description:
- *      add a station from hostap deamon
- *
- * Parameters:
- *  In:
- *      pDevice   -
- *      param     -
- *  Out:
- *
- * Return Value:
- *
- */
-static int hostap_add_sta(struct vnt_private *pDevice,
-                         struct viawget_hostapd_param *param)
-{
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       unsigned int uNodeIndex;
-
-       if (!BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex))
-               BSSvCreateOneNode(pDevice, &uNodeIndex);
-
-       memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, param->sta_addr, WLAN_ADDR_LEN);
-       pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC;
-       pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = param->u.add_sta.capability;
-/* TODO listenInterval */
-       pMgmt->sNodeDBTable[uNodeIndex].bPSEnable = false;
-       pMgmt->sNodeDBTable[uNodeIndex].bySuppRate = param->u.add_sta.tx_supp_rates;
-
-       /* set max tx rate */
-       pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate =
-               pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate;
-       /* set max basic rate */
-       pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate = RATE_2M;
-       /* Todo: check sta preamble, if ap can't support, set status code */
-       pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble =
-               WLAN_GET_CAP_INFO_SHORTPREAMBLE(pMgmt->sNodeDBTable[uNodeIndex].wCapInfo);
-
-       pMgmt->sNodeDBTable[uNodeIndex].wAID = (unsigned short)param->u.add_sta.aid;
-
-       pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer = jiffies;
-
-       pr_debug("Add STA AID= %d\n", pMgmt->sNodeDBTable[uNodeIndex].wAID);
-       pr_debug("MAC=%pM\n", param->sta_addr);
-       pr_debug("Max Support rate = %d\n",
-                pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate);
-
-       return 0;
-}
-
-/*
- * Description:
- *      get station info
- *
- * Parameters:
- *  In:
- *      pDevice   -
- *      param     -
- *  Out:
- *
- * Return Value:
- *
- */
-
-static int hostap_get_info_sta(struct vnt_private *pDevice,
-                              struct viawget_hostapd_param *param)
-{
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       unsigned int uNodeIndex;
-
-       if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) {
-               param->u.get_info_sta.inactive_sec =
-                       (jiffies - pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer) / HZ;
-       } else {
-               return -ENOENT;
-       }
-
-       return 0;
-}
-
-/*
- * Description:
- *      set station flag
- *
- * Parameters:
- *  In:
- *      pDevice   -
- *      param     -
- *  Out:
- *
- * Return Value:
- *
- */
-static int hostap_set_flags_sta(struct vnt_private *pDevice,
-                               struct viawget_hostapd_param *param)
-{
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       unsigned int uNodeIndex;
-
-       if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) {
-               pMgmt->sNodeDBTable[uNodeIndex].dwFlags |= param->u.set_flags_sta.flags_or;
-               pMgmt->sNodeDBTable[uNodeIndex].dwFlags &= param->u.set_flags_sta.flags_and;
-               pr_debug(" dwFlags = %x\n",
-                        (unsigned int)pMgmt->sNodeDBTable[uNodeIndex].dwFlags);
-       } else {
-               return -ENOENT;
-       }
-
-       return 0;
-}
-
-/*
- * Description:
- *      set generic element (wpa ie)
- *
- * Parameters:
- *  In:
- *      pDevice   -
- *      param     -
- *  Out:
- *
- * Return Value:
- *
- */
-static int hostap_set_generic_element(struct vnt_private *pDevice,
-                                     struct viawget_hostapd_param *param)
-{
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-
-       if (param->u.generic_elem.len > sizeof(pMgmt->abyWPAIE))
-               return -EINVAL;
-
-       memcpy(pMgmt->abyWPAIE,
-              param->u.generic_elem.data,
-              param->u.generic_elem.len
-               );
-
-       pMgmt->wWPAIELen = param->u.generic_elem.len;
-
-       pr_debug("pMgmt->wWPAIELen = %d\n", pMgmt->wWPAIELen);
-
-       /* disable wpa */
-       if (pMgmt->wWPAIELen == 0) {
-               pMgmt->eAuthenMode = WMAC_AUTH_OPEN;
-               pr_debug(" No WPAIE, Disable WPA\n");
-       } else  {
-               /* enable wpa */
-               if ((pMgmt->abyWPAIE[0] == WLAN_EID_RSN_WPA) ||
-                   (pMgmt->abyWPAIE[0] == WLAN_EID_RSN)) {
-                       pMgmt->eAuthenMode = WMAC_AUTH_WPANONE;
-                       pr_debug("Set WPAIE enable WPA\n");
-               } else
-                       return -EINVAL;
-       }
-
-       return 0;
-}
-
-/*
- * Description:
- *      flush station nodes table.
- *
- * Parameters:
- *  In:
- *      pDevice   -
- *  Out:
- *
- * Return Value:
- *
- */
-
-static void hostap_flush_sta(struct vnt_private *pDevice)
-{
-       /* reserved node index =0 for multicast node. */
-       BSSvClearNodeDBTable(pDevice, 1);
-       pDevice->uAssocCount = 0;
-}
-
-/*
- * Description:
- *      set each stations encryption key
- *
- * Parameters:
- *  In:
- *      pDevice   -
- *      param     -
- *  Out:
- *
- * Return Value:
- *
- */
-static int hostap_set_encryption(struct vnt_private *pDevice,
-                                struct viawget_hostapd_param *param,
-                                int param_len)
-{
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       unsigned long dwKeyIndex = 0;
-       unsigned char abyKey[MAX_KEY_LEN];
-       unsigned char abySeq[MAX_KEY_LEN];
-       u64 KeyRSC;
-       unsigned char byKeyDecMode = KEY_CTL_WEP;
-       int     iNodeIndex = -1;
-       int     ii;
-       bool bKeyTableFull = false;
-       unsigned short wKeyCtl = 0;
-
-       param->u.crypt.err = 0;
-
-       if (param->u.crypt.alg > WPA_ALG_CCMP)
-               return -EINVAL;
-
-       if ((param->u.crypt.idx > 3) || (param->u.crypt.key_len > MAX_KEY_LEN)) {
-               param->u.crypt.err = HOSTAP_CRYPT_ERR_KEY_SET_FAILED;
-               pr_debug(" HOSTAP_CRYPT_ERR_KEY_SET_FAILED\n");
-               return -EINVAL;
-       }
-
-       if (is_broadcast_ether_addr(param->sta_addr)) {
-               if (param->u.crypt.idx >= MAX_GROUP_KEY)
-                       return -EINVAL;
-               iNodeIndex = 0;
-
-       } else {
-               if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &iNodeIndex) == false) {
-                       param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR;
-                       pr_debug(" HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n");
-                       return -EINVAL;
-               }
-       }
-       pr_debug(" hostap_set_encryption: sta_index %d\n", iNodeIndex);
-       pr_debug(" hostap_set_encryption: alg %d\n", param->u.crypt.alg);
-
-       if (param->u.crypt.alg == WPA_ALG_NONE) {
-               if (pMgmt->sNodeDBTable[iNodeIndex].bOnFly) {
-                       if (!KeybRemoveKey(&(pDevice->sKey),
-                                         param->sta_addr,
-                                         pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex,
-                                         pDevice->PortOffset)) {
-                               pr_debug("KeybRemoveKey fail\n");
-                       }
-                       pMgmt->sNodeDBTable[iNodeIndex].bOnFly = false;
-               }
-               pMgmt->sNodeDBTable[iNodeIndex].byKeyIndex = 0;
-               pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = 0;
-               pMgmt->sNodeDBTable[iNodeIndex].uWepKeyLength = 0;
-               pMgmt->sNodeDBTable[iNodeIndex].KeyRSC = 0;
-               pMgmt->sNodeDBTable[iNodeIndex].dwTSC47_16 = 0;
-               pMgmt->sNodeDBTable[iNodeIndex].wTSC15_0 = 0;
-               pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = 0;
-               memset(&pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[0],
-                      0,
-                      MAX_KEY_LEN
-);
-
-               return 0;
-       }
-
-       memcpy(abyKey, param->u.crypt.key, param->u.crypt.key_len);
-       /* copy to node key tbl */
-       pMgmt->sNodeDBTable[iNodeIndex].byKeyIndex = param->u.crypt.idx;
-       pMgmt->sNodeDBTable[iNodeIndex].uWepKeyLength = param->u.crypt.key_len;
-       memcpy(&pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[0],
-              param->u.crypt.key,
-              param->u.crypt.key_len
-);
-
-       dwKeyIndex = (unsigned long)(param->u.crypt.idx);
-       if (param->u.crypt.flags & HOSTAP_CRYPT_FLAG_SET_TX_KEY) {
-               pDevice->byKeyIndex = (unsigned char)dwKeyIndex;
-               pDevice->bTransmitKey = true;
-               dwKeyIndex |= (1 << 31);
-       }
-
-       if (param->u.crypt.alg == WPA_ALG_WEP) {
-               if ((pDevice->bEnable8021x == false) || (iNodeIndex == 0)) {
-                       KeybSetDefaultKey(&(pDevice->sKey),
-                                         dwKeyIndex & ~(BIT30 | USE_KEYRSC),
-                                         param->u.crypt.key_len,
-                                         NULL,
-                                         abyKey,
-                                         KEY_CTL_WEP,
-                                         pDevice->PortOffset,
-                                         pDevice->byLocalID);
-
-               } else {
-                       /* 8021x enable, individual key */
-                       dwKeyIndex |= (1 << 30); /* set pairwise key */
-                       if (KeybSetKey(&(pDevice->sKey),
-                                      &param->sta_addr[0],
-                                      dwKeyIndex & ~(USE_KEYRSC),
-                                      param->u.crypt.key_len,
-                                      (u64 *) &KeyRSC,
-                                      (unsigned char *)abyKey,
-                                      KEY_CTL_WEP,
-                                      pDevice->PortOffset,
-                                      pDevice->byLocalID)) {
-                               pMgmt->sNodeDBTable[iNodeIndex].bOnFly = true;
-
-                       } else {
-                               /* Key Table Full */
-                               pMgmt->sNodeDBTable[iNodeIndex].bOnFly = false;
-                               bKeyTableFull = true;
-                       }
-               }
-               pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
-               pDevice->bEncryptionEnable = true;
-               pMgmt->byCSSPK = KEY_CTL_WEP;
-               pMgmt->byCSSGK = KEY_CTL_WEP;
-               pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = KEY_CTL_WEP;
-               pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = dwKeyIndex;
-               return 0;
-       }
-
-       if (param->u.crypt.seq) {
-               memcpy(&abySeq, param->u.crypt.seq, 8);
-               for (ii = 0; ii < 8; ii++)
-                       KeyRSC |= (u64)abySeq[ii] << (ii * 8);
-
-               dwKeyIndex |= 1 << 29;
-               pMgmt->sNodeDBTable[iNodeIndex].KeyRSC = KeyRSC;
-       }
-
-       if (param->u.crypt.alg == WPA_ALG_TKIP) {
-               if (param->u.crypt.key_len != MAX_KEY_LEN)
-                       return -EINVAL;
-               pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
-               byKeyDecMode = KEY_CTL_TKIP;
-               pMgmt->byCSSPK = KEY_CTL_TKIP;
-               pMgmt->byCSSGK = KEY_CTL_TKIP;
-       }
-
-       if (param->u.crypt.alg == WPA_ALG_CCMP) {
-               if ((param->u.crypt.key_len != AES_KEY_LEN) ||
-                   (pDevice->byLocalID <= REV_ID_VT3253_A1))
-                       return -EINVAL;
-               pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
-               byKeyDecMode = KEY_CTL_CCMP;
-               pMgmt->byCSSPK = KEY_CTL_CCMP;
-               pMgmt->byCSSGK = KEY_CTL_CCMP;
-       }
-
-       if (iNodeIndex == 0) {
-               KeybSetDefaultKey(&(pDevice->sKey),
-                                 dwKeyIndex,
-                                 param->u.crypt.key_len,
-                                 (u64 *) &KeyRSC,
-                                 abyKey,
-                                 byKeyDecMode,
-                                 pDevice->PortOffset,
-                                 pDevice->byLocalID);
-               pMgmt->sNodeDBTable[iNodeIndex].bOnFly = true;
-
-       } else {
-               dwKeyIndex |= (1 << 30); /* set pairwise key */
-               if (KeybSetKey(&(pDevice->sKey),
-                              &param->sta_addr[0],
-                              dwKeyIndex,
-                              param->u.crypt.key_len,
-                              (u64 *) &KeyRSC,
-                              (unsigned char *)abyKey,
-                              byKeyDecMode,
-                              pDevice->PortOffset,
-                              pDevice->byLocalID)) {
-                       pMgmt->sNodeDBTable[iNodeIndex].bOnFly = true;
-
-               } else {
-                       /* Key Table Full */
-                       pMgmt->sNodeDBTable[iNodeIndex].bOnFly = false;
-                       bKeyTableFull = true;
-                       pr_debug(" Key Table Full\n");
-               }
-
-       }
-
-       if (bKeyTableFull) {
-               wKeyCtl &= 0x7F00;              /* clear all key control filed */
-               wKeyCtl |= (byKeyDecMode << 4);
-               wKeyCtl |= (byKeyDecMode);
-               wKeyCtl |= 0x0044;              /* use group key for all address */
-               wKeyCtl |= 0x4000;              /* disable KeyTable[MAX_KEY_TABLE-1] on-fly to genernate rx int */
-               MACvSetDefaultKeyCtl(pDevice->PortOffset, wKeyCtl, MAX_KEY_TABLE-1, pDevice->byLocalID);
-       }
-
-       pr_debug(" Set key sta_index= %d\n", iNodeIndex);
-       pr_debug(" tx_index=%d len=%d\n",
-                param->u.crypt.idx, param->u.crypt.key_len);
-       pr_debug(" key=%x-%x-%x-%x-%x-xxxxx\n",
-                pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[0],
-                pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[1],
-                pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[2],
-                pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[3],
-                pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[4]);
-
-       /* set wep key */
-       pDevice->bEncryptionEnable = true;
-       pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = byKeyDecMode;
-       pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = dwKeyIndex;
-       pMgmt->sNodeDBTable[iNodeIndex].dwTSC47_16 = 0;
-       pMgmt->sNodeDBTable[iNodeIndex].wTSC15_0 = 0;
-
-       return 0;
-}
-
-/*
- * Description:
- *      get each stations encryption key
- *
- * Parameters:
- *  In:
- *      pDevice   -
- *      param     -
- *  Out:
- *
- * Return Value:
- *
- */
-static int hostap_get_encryption(struct vnt_private *pDevice,
-                                struct viawget_hostapd_param *param,
-                                int param_len)
-{
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       int     ii;
-       int     iNodeIndex = 0;
-
-       param->u.crypt.err = 0;
-
-       if (is_broadcast_ether_addr(param->sta_addr)) {
-               iNodeIndex = 0;
-       } else {
-               if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &iNodeIndex) == false) {
-                       param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR;
-                       pr_debug("hostap_get_encryption: HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n");
-                       return -EINVAL;
-               }
-       }
-       pr_debug("hostap_get_encryption: %d\n", iNodeIndex);
-       memset(param->u.crypt.seq, 0, 8);
-       for (ii = 0; ii < 8; ii++)
-               param->u.crypt.seq[ii] = (unsigned char)pMgmt->sNodeDBTable[iNodeIndex].KeyRSC >> (ii * 8);
-
-       return 0;
-}
-
-/*
- * Description:
- *      vt6655_hostap_ioctl main function supported for hostap deamon.
- *
- * Parameters:
- *  In:
- *      pDevice   -
- *      iw_point  -
- *  Out:
- *
- * Return Value:
- *
- */
-int vt6655_hostap_ioctl(struct vnt_private *pDevice, struct iw_point *p)
-{
-       struct viawget_hostapd_param *param;
-       int ret = 0;
-       int ap_ioctl = 0;
-
-       if (p->length < sizeof(struct viawget_hostapd_param) ||
-           p->length > VIAWGET_HOSTAPD_MAX_BUF_SIZE || !p->pointer)
-               return -EINVAL;
-
-       param = kmalloc((int)p->length, GFP_KERNEL);
-       if (param == NULL)
-               return -ENOMEM;
-
-       if (copy_from_user(param, p->pointer, p->length)) {
-               ret = -EFAULT;
-               goto out;
-       }
-
-       switch (param->cmd) {
-       case VIAWGET_HOSTAPD_SET_ENCRYPTION:
-               pr_debug("VIAWGET_HOSTAPD_SET_ENCRYPTION\n");
-               spin_lock_irq(&pDevice->lock);
-               ret = hostap_set_encryption(pDevice, param, p->length);
-               spin_unlock_irq(&pDevice->lock);
-               break;
-       case VIAWGET_HOSTAPD_GET_ENCRYPTION:
-               pr_debug("VIAWGET_HOSTAPD_GET_ENCRYPTION\n");
-               spin_lock_irq(&pDevice->lock);
-               ret = hostap_get_encryption(pDevice, param, p->length);
-               spin_unlock_irq(&pDevice->lock);
-               break;
-       case VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR:
-               pr_debug("VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR\n");
-               ret = -EOPNOTSUPP;
-               goto out;
-       case VIAWGET_HOSTAPD_FLUSH:
-               pr_debug("VIAWGET_HOSTAPD_FLUSH\n");
-               spin_lock_irq(&pDevice->lock);
-               hostap_flush_sta(pDevice);
-               spin_unlock_irq(&pDevice->lock);
-               break;
-       case VIAWGET_HOSTAPD_ADD_STA:
-               pr_debug("VIAWGET_HOSTAPD_ADD_STA\n");
-               spin_lock_irq(&pDevice->lock);
-               ret = hostap_add_sta(pDevice, param);
-               spin_unlock_irq(&pDevice->lock);
-               break;
-       case VIAWGET_HOSTAPD_REMOVE_STA:
-               pr_debug("VIAWGET_HOSTAPD_REMOVE_STA\n");
-               spin_lock_irq(&pDevice->lock);
-               ret = hostap_remove_sta(pDevice, param);
-               spin_unlock_irq(&pDevice->lock);
-               break;
-       case VIAWGET_HOSTAPD_GET_INFO_STA:
-               pr_debug("VIAWGET_HOSTAPD_GET_INFO_STA\n");
-               ret = hostap_get_info_sta(pDevice, param);
-               ap_ioctl = 1;
-               break;
-       case VIAWGET_HOSTAPD_SET_FLAGS_STA:
-               pr_debug("VIAWGET_HOSTAPD_SET_FLAGS_STA\n");
-               ret = hostap_set_flags_sta(pDevice, param);
-               break;
-       case VIAWGET_HOSTAPD_MLME:
-               pr_debug("VIAWGET_HOSTAPD_MLME\n");
-               ret = -EOPNOTSUPP;
-               goto out;
-       case VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT:
-               pr_debug("VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT\n");
-               ret = hostap_set_generic_element(pDevice, param);
-               break;
-       case VIAWGET_HOSTAPD_SCAN_REQ:
-               pr_debug("VIAWGET_HOSTAPD_SCAN_REQ\n");
-               ret = -EOPNOTSUPP;
-               goto out;
-       case VIAWGET_HOSTAPD_STA_CLEAR_STATS:
-               pr_debug("VIAWGET_HOSTAPD_STA_CLEAR_STATS\n");
-               ret = -EOPNOTSUPP;
-               goto out;
-       default:
-               pr_debug("vt6655_hostap_ioctl: unknown cmd=%d\n",
-                        (int)param->cmd);
-               ret = -EOPNOTSUPP;
-               goto out;
-       }
-
-       if ((ret == 0) && ap_ioctl) {
-               if (copy_to_user(p->pointer, param, p->length))
-                       ret = -EFAULT;
-       }
-
-out:
-       kfree(param);
-       return ret;
-}
diff --git a/drivers/staging/vt6655/hostap.h b/drivers/staging/vt6655/hostap.h
deleted file mode 100644 (file)
index 17df4e4..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: hostap.h
- *
- * Purpose:
- *
- * Author: Lyndon Chen
- *
- * Date: May 21, 2003
- *
- */
-
-#ifndef __HOSTAP_H__
-#define __HOSTAP_H__
-
-#include "device.h"
-
-#define WLAN_RATE_1M    BIT0
-#define WLAN_RATE_2M    BIT1
-#define WLAN_RATE_5M5   BIT2
-#define WLAN_RATE_11M   BIT3
-#define WLAN_RATE_6M    BIT4
-#define WLAN_RATE_9M    BIT5
-#define WLAN_RATE_12M   BIT6
-#define WLAN_RATE_18M   BIT7
-#define WLAN_RATE_24M   BIT8
-#define WLAN_RATE_36M   BIT9
-#define WLAN_RATE_48M   BIT10
-#define WLAN_RATE_54M   BIT11
-
-#ifndef ETH_P_PAE
-#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
-#endif /* ETH_P_PAE */
-
-#ifndef ARPHRD_IEEE80211
-#define ARPHRD_IEEE80211 801
-#endif
-
-int vt6655_hostap_set_hostapd(struct vnt_private *, int val, int rtnl_locked);
-int vt6655_hostap_ioctl(struct vnt_private *, struct iw_point *p);
-
-#endif // __HOSTAP_H__
diff --git a/drivers/staging/vt6655/iocmd.h b/drivers/staging/vt6655/iocmd.h
deleted file mode 100644 (file)
index a665cfd..0000000
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: iocmd.h
- *
- * Purpose: Handles the viawget ioctl private interface functions
- *
- * Author: Lyndon Chen
- *
- * Date: May 8, 2002
- *
- */
-
-#ifndef __IOCMD_H__
-#define __IOCMD_H__
-
-#include "ttype.h"
-
-// ioctl Command code
-#define MAGIC_CODE                      0x3142
-#define IOCTL_CMD_TEST             (SIOCDEVPRIVATE + 0)
-#define IOCTL_CMD_SET                      (SIOCDEVPRIVATE + 1)
-#define IOCTL_CMD_HOSTAPD           (SIOCDEVPRIVATE + 2)
-#define IOCTL_CMD_WPA               (SIOCDEVPRIVATE + 3)
-
-typedef enum tagWMAC_CMD {
-       WLAN_CMD_BSS_SCAN,
-       WLAN_CMD_BSS_JOIN,
-       WLAN_CMD_DISASSOC,
-       WLAN_CMD_SET_WEP,
-       WLAN_CMD_GET_LINK,
-       WLAN_CMD_GET_LISTLEN,
-       WLAN_CMD_GET_LIST,
-       WLAN_CMD_GET_MIB,
-       WLAN_CMD_GET_STAT,
-       WLAN_CMD_STOP_MAC,
-       WLAN_CMD_START_MAC,
-       WLAN_CMD_AP_START,
-       WLAN_CMD_SET_HOSTAPD,
-       WLAN_CMD_SET_HOSTAPD_STA,
-       WLAN_CMD_SET_802_1X,
-       WLAN_CMD_SET_HOST_WEP,
-       WLAN_CMD_SET_WPA,
-       WLAN_CMD_GET_NODE_CNT,
-       WLAN_CMD_ZONETYPE_SET,
-       WLAN_CMD_GET_NODE_LIST
-} WMAC_CMD, *PWMAC_CMD;
-
-typedef enum tagWZONETYPE {
-       ZoneType_USA = 0,
-       ZoneType_Japan = 1,
-       ZoneType_Europe = 2
-} WZONETYPE;
-
-#define ADHOC  0
-#define INFRA  1
-#define BOTH   2
-#define AP         3
-
-#define ADHOC_STARTED     1
-#define ADHOC_JOINTED     2
-
-#define PHY80211a       0
-#define PHY80211b       1
-#define PHY80211g       2
-
-#define SSID_ID                0
-#define SSID_MAXLEN            32
-#define BSSID_LEN              6
-#define WEP_NKEYS              4
-#define WEP_KEYMAXLEN          29
-#define WEP_40BIT_LEN          5
-#define WEP_104BIT_LEN         13
-#define WEP_232BIT_LEN         16
-
-// Ioctl interface structure
-// Command structure
-//
-#pragma pack(1)
-typedef struct tagSCmdRequest {
-       u8          name[16];
-       void __user *data;
-       u16         wResult;
-       u16     wCmdCode;
-} SCmdRequest, *PSCmdRequest;
-
-//
-// Scan
-//
-
-typedef struct tagSCmdScan {
-       u8 ssid[SSID_MAXLEN + 2];
-} SCmdScan, *PSCmdScan;
-
-//
-// BSS Join
-//
-
-typedef struct tagSCmdBSSJoin {
-       u16         wBSSType;
-       u16     wBBPType;
-       u8          ssid[SSID_MAXLEN + 2];
-       u32         uChannel;
-       bool bPSEnable;
-       bool bShareKeyAuth;
-} SCmdBSSJoin, *PSCmdBSSJoin;
-
-//
-// Zonetype Setting
-//
-
-typedef struct tagSCmdZoneTypeSet {
-       bool bWrite;
-       WZONETYPE  ZoneType;
-} SCmdZoneTypeSet, *PSCmdZoneTypeSet;
-
-#ifdef WPA_SM_Transtatus
-typedef struct tagSWPAResult {
-       char    ifname[100];
-       u8 proto;
-       u8 key_mgmt;
-       u8 eap_type;
-       bool authenticated;
-} SWPAResult, *PSWPAResult;
-#endif
-
-typedef struct tagSCmdStartAP {
-       u16         wBSSType;
-       u16     wBBPType;
-       u8          ssid[SSID_MAXLEN + 2];
-       u32         uChannel;
-       u32     uBeaconInt;
-       bool bShareKeyAuth;
-       u8      byBasicRate;
-} SCmdStartAP, *PSCmdStartAP;
-
-typedef struct tagSCmdSetWEP {
-       bool bEnableWep;
-       u8      byKeyIndex;
-       u8      abyWepKey[WEP_NKEYS][WEP_KEYMAXLEN];
-       bool bWepKeyAvailable[WEP_NKEYS];
-       u32     auWepKeyLength[WEP_NKEYS];
-} SCmdSetWEP, *PSCmdSetWEP;
-
-typedef struct tagSBSSIDItem {
-       u32         uChannel;
-       u8      abyBSSID[BSSID_LEN];
-       u8      abySSID[SSID_MAXLEN + 1];
-       u8      byNetType;
-       u16         wBeaconInterval;
-       u16         wCapInfo;        // for address of byNetType at align 4
-
-       bool bWEPOn;
-       u32     uRSSI;
-} SBSSIDItem;
-
-typedef struct tagSBSSIDList {
-       u32                 uItem;
-       SBSSIDItem      sBSSIDList[0];
-} SBSSIDList, *PSBSSIDList;
-
-typedef struct tagSCmdLinkStatus {
-       bool bLink;
-       u16   wBSSType;
-       u8      byState;
-       u8      abyBSSID[BSSID_LEN];
-       u8      abySSID[SSID_MAXLEN + 2];
-       u32     uChannel;
-       u32     uLinkRate;
-} SCmdLinkStatus, *PSCmdLinkStatus;
-
-//
-// 802.11 counter
-//
-typedef struct tagSDot11MIBCount {
-       u32 TransmittedFragmentCount;
-       u32 MulticastTransmittedFrameCount;
-       u32 FailedCount;
-       u32 RetryCount;
-       u32 MultipleRetryCount;
-       u32 RTSSuccessCount;
-       u32 RTSFailureCount;
-       u32 ACKFailureCount;
-       u32 FrameDuplicateCount;
-       u32 ReceivedFragmentCount;
-       u32 MulticastReceivedFrameCount;
-       u32 FCSErrorCount;
-} SDot11MIBCount, *PSDot11MIBCount;
-
-//
-// statistic counter
-//
-typedef struct tagSStatMIBCount {
-       //
-       // ISR status count
-       //
-       u32   dwIsrTx0OK;
-       u32   dwIsrTx1OK;
-       u32   dwIsrBeaconTxOK;
-       u32   dwIsrRxOK;
-       u32   dwIsrTBTTInt;
-       u32   dwIsrSTIMERInt;
-       u32   dwIsrUnrecoverableError;
-       u32   dwIsrSoftInterrupt;
-       u32   dwIsrRxNoBuf;
-
-       u32   dwIsrUnknown;
-
-       // RSR status count
-       //
-       u32   dwRsrFrmAlgnErr;
-       u32   dwRsrErr;
-       u32   dwRsrCRCErr;
-       u32   dwRsrCRCOk;
-       u32   dwRsrBSSIDOk;
-       u32   dwRsrADDROk;
-       u32   dwRsrICVOk;
-       u32   dwNewRsrShortPreamble;
-       u32   dwRsrLong;
-       u32   dwRsrRunt;
-
-       u32   dwRsrRxControl;
-       u32   dwRsrRxData;
-       u32   dwRsrRxManage;
-
-       u32   dwRsrRxPacket;
-       u32   dwRsrRxOctet;
-       u32   dwRsrBroadcast;
-       u32   dwRsrMulticast;
-       u32   dwRsrDirected;
-       // 64-bit OID
-       u32   ullRsrOK;
-
-       // for some optional OIDs (64 bits) and DMI support
-       u32   ullRxBroadcastBytes;
-       u32   ullRxMulticastBytes;
-       u32   ullRxDirectedBytes;
-       u32   ullRxBroadcastFrames;
-       u32   ullRxMulticastFrames;
-       u32   ullRxDirectedFrames;
-
-       u32   dwRsrRxFragment;
-       u32   dwRsrRxFrmLen64;
-       u32   dwRsrRxFrmLen65_127;
-       u32   dwRsrRxFrmLen128_255;
-       u32   dwRsrRxFrmLen256_511;
-       u32   dwRsrRxFrmLen512_1023;
-       u32   dwRsrRxFrmLen1024_1518;
-
-       // TSR0,1 status count
-       //
-       u32   dwTsrTotalRetry[2];        // total collision retry count
-       u32   dwTsrOnceRetry[2];         // this packet only occur one collision
-       u32   dwTsrMoreThanOnceRetry[2]; // this packet occur more than one collision
-       u32   dwTsrRetry[2];             // this packet has ever occur collision,
-       // that is (dwTsrOnceCollision0 + dwTsrMoreThanOnceCollision0)
-       u32   dwTsrACKData[2];
-       u32   dwTsrErr[2];
-       u32   dwAllTsrOK[2];
-       u32   dwTsrRetryTimeout[2];
-       u32   dwTsrTransmitTimeout[2];
-
-       u32   dwTsrTxPacket[2];
-       u32   dwTsrTxOctet[2];
-       u32   dwTsrBroadcast[2];
-       u32   dwTsrMulticast[2];
-       u32   dwTsrDirected[2];
-
-       // RD/TD count
-       u32   dwCntRxFrmLength;
-       u32   dwCntTxBufLength;
-
-       u8    abyCntRxPattern[16];
-       u8    abyCntTxPattern[16];
-
-       // Software check....
-       u32   dwCntRxDataErr;             // rx buffer data software compare CRC err count
-       u32   dwCntDecryptErr;            // rx buffer data software compare CRC err count
-       u32   dwCntRxICVErr;              // rx buffer data software compare CRC err count
-       u32    idxRxErrorDesc;             // index for rx data error RD
-
-       // 64-bit OID
-       u32   ullTsrOK[2];
-
-       // for some optional OIDs (64 bits) and DMI support
-       u32   ullTxBroadcastFrames[2];
-       u32   ullTxMulticastFrames[2];
-       u32   ullTxDirectedFrames[2];
-       u32   ullTxBroadcastBytes[2];
-       u32   ullTxMulticastBytes[2];
-       u32   ullTxDirectedBytes[2];
-} SStatMIBCount, *PSStatMIBCount;
-
-typedef struct tagSNodeItem {
-       // STA info
-       u16            wAID;
-       u8             abyMACAddr[6];
-       u16            wTxDataRate;
-       u16            wInActiveCount;
-       u16            wEnQueueCnt;
-       u16            wFlags;
-       bool bPWBitOn;
-       u8             byKeyIndex;
-       u16            wWepKeyLength;
-       u8            abyWepKey[WEP_KEYMAXLEN];
-       // Auto rate fallback vars
-       bool bIsInFallback;
-       u32            uTxFailures;
-       u32            uTxAttempts;
-       u16            wFailureRatio;
-} SNodeItem;
-
-typedef struct tagSNodeList {
-       u32                 uItem;
-       SNodeItem       sNodeList[0];
-} SNodeList, *PSNodeList;
-
-typedef struct tagSCmdValue {
-       u32 dwValue;
-} SCmdValue,  *PSCmdValue;
-
-//
-// hostapd & viawget ioctl related
-//
-
-enum {
-       VIAWGET_HOSTAPD_FLUSH = 1,
-       VIAWGET_HOSTAPD_ADD_STA = 2,
-       VIAWGET_HOSTAPD_REMOVE_STA = 3,
-       VIAWGET_HOSTAPD_GET_INFO_STA = 4,
-       VIAWGET_HOSTAPD_SET_ENCRYPTION = 5,
-       VIAWGET_HOSTAPD_GET_ENCRYPTION = 6,
-       VIAWGET_HOSTAPD_SET_FLAGS_STA = 7,
-       VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR = 8,
-       VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT = 9,
-       VIAWGET_HOSTAPD_MLME = 10,
-       VIAWGET_HOSTAPD_SCAN_REQ = 11,
-       VIAWGET_HOSTAPD_STA_CLEAR_STATS = 12,
-};
-
-#define VIAWGET_HOSTAPD_GENERIC_ELEMENT_HDR_LEN                                \
-       ((int)(&((struct viawget_hostapd_param *)0)->u.generic_elem.data))
-
-// Maximum length for algorithm names (-1 for nul termination) used in ioctl()
-
-struct viawget_hostapd_param {
-       u32 cmd;
-       u8 sta_addr[6];
-       union {
-               struct {
-                       u16 aid;
-                       u16 capability;
-                       u8 tx_supp_rates;
-               } add_sta;
-               struct {
-                       u32 inactive_sec;
-               } get_info_sta;
-               struct {
-                       u8 alg;
-                       u32 flags;
-                       u32 err;
-                       u8 idx;
-                       u8 seq[8];
-                       u16 key_len;
-                       u8 key[0];
-               } crypt;
-               struct {
-                       u32 flags_and;
-                       u32 flags_or;
-               } set_flags_sta;
-               struct {
-                       u16 rid;
-                       u16 len;
-                       u8 data[0];
-               } rid;
-               struct {
-                       u8 len;
-                       u8 data[0];
-               } generic_elem;
-               struct {
-                       u16 cmd;
-                       u16 reason_code;
-               } mlme;
-               struct {
-                       u8 ssid_len;
-                       u8 ssid[32];
-               } scan_req;
-       } u;
-};
-
-#pragma pack()
-
-#endif //__IOCMD_H__
diff --git a/drivers/staging/vt6655/ioctl.c b/drivers/staging/vt6655/ioctl.c
deleted file mode 100644 (file)
index 970e80d..0000000
+++ /dev/null
@@ -1,658 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: ioctl.c
- *
- * Purpose:  private ioctl functions
- *
- * Author: Lyndon Chen
- *
- * Date: Auguest 20, 2003
- *
- * Functions:
- *
- * Revision History:
- *
- */
-
-#include "ioctl.h"
-#include "iocmd.h"
-#include "mac.h"
-#include "card.h"
-#include "hostap.h"
-#include "wpactl.h"
-#include "rf.h"
-
-#ifdef WPA_SM_Transtatus
-SWPAResult wpa_Result;
-#endif
-
-int private_ioctl(struct vnt_private *pDevice, struct ifreq *rq)
-{
-       PSCmdRequest    pReq = (PSCmdRequest)rq;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       int             result = 0;
-       PWLAN_IE_SSID   pItemSSID;
-       SCmdBSSJoin     sJoinCmd;
-       SCmdZoneTypeSet sZoneTypeCmd;
-       SCmdScan        sScanCmd;
-       SCmdStartAP     sStartAPCmd;
-       SCmdSetWEP      sWEPCmd;
-       SCmdValue       sValue;
-       SBSSIDList      sList;
-       SNodeList       sNodeList;
-       PSBSSIDList     pList;
-       PSNodeList      pNodeList;
-       unsigned int    cbListCount;
-       PKnownBSS       pBSS;
-       PKnownNodeDB    pNode;
-       unsigned int    ii, jj;
-       unsigned char   abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
-       unsigned char   abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-       unsigned long   dwKeyIndex = 0;
-       unsigned char   abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
-       long            ldBm;
-
-       pReq->wResult = 0;
-
-       switch (pReq->wCmdCode) {
-       case WLAN_CMD_BSS_SCAN:
-               pr_debug("WLAN_CMD_BSS_SCAN..begin\n");
-               if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) {
-                       result = -EFAULT;
-                       break;
-               }
-
-               pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid;
-               if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)
-                       return -EINVAL;
-               if (pItemSSID->len != 0) {
-                       memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
-                       memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
-               }
-
-               if (pDevice->bMACSuspend == true) {
-                       if (pDevice->bRadioOff == true)
-                               CARDbRadioPowerOn(pDevice);
-                       vMgrTimerInit(pDevice);
-                       MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
-                       add_timer(&pMgmt->sTimerSecondCallback);
-                       pDevice->bMACSuspend = false;
-               }
-               spin_lock_irq(&pDevice->lock);
-               if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0)
-                       BSSvClearBSSList((void *)pDevice, false);
-               else
-                       BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass);
-
-               if (pItemSSID->len != 0)
-                       bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
-               else
-                       bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL);
-               spin_unlock_irq(&pDevice->lock);
-               break;
-
-       case WLAN_CMD_ZONETYPE_SET:
-               /* mike add :can't support. */
-               result = -EOPNOTSUPP;
-               break;
-
-               if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) {
-                       result = -EFAULT;
-                       break;
-               }
-
-               if (sZoneTypeCmd.bWrite == true) {
-                       /* write zonetype */
-                       if (sZoneTypeCmd.ZoneType == ZoneType_USA) {
-                               /* set to USA */
-                               pr_debug("set_ZoneType:USA\n");
-                       } else if (sZoneTypeCmd.ZoneType == ZoneType_Japan) {
-                               /* set to Japan */
-                               pr_debug("set_ZoneType:Japan\n");
-                       } else if (sZoneTypeCmd.ZoneType == ZoneType_Europe) {
-                               /* set to Europe */
-                               pr_debug("set_ZoneType:Europe\n");
-                       }
-               } else {
-                       /* read zonetype */
-                       unsigned char zonetype = 0;
-
-                       if (zonetype == 0x00) {         /* USA */
-                               sZoneTypeCmd.ZoneType = ZoneType_USA;
-                       } else if (zonetype == 0x01) {  /* Japan */
-                               sZoneTypeCmd.ZoneType = ZoneType_Japan;
-                       } else if (zonetype == 0x02) {  /* Europe */
-                               sZoneTypeCmd.ZoneType = ZoneType_Europe;
-                       } else {                        /* Unknown ZoneType */
-                               pr_err("Error:ZoneType[%x] Unknown ???\n", zonetype);
-                               result = -EFAULT;
-                               break;
-                       }
-                       if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) {
-                               result = -EFAULT;
-                               break;
-                       }
-               }
-               break;
-
-       case WLAN_CMD_BSS_JOIN:
-               if (pDevice->bMACSuspend == true) {
-                       if (pDevice->bRadioOff == true)
-                               CARDbRadioPowerOn(pDevice);
-                       vMgrTimerInit(pDevice);
-                       MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
-                       add_timer(&pMgmt->sTimerSecondCallback);
-                       pDevice->bMACSuspend = false;
-               }
-
-               if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) {
-                       result = -EFAULT;
-                       break;
-               }
-
-               pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid;
-               if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)
-                       return -EINVAL;
-               memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
-               memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
-               if (sJoinCmd.wBSSType == ADHOC) {
-                       pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
-                       pr_debug("ioct set to adhoc mode\n");
-               } else {
-                       pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
-                       pr_debug("ioct set to STA mode\n");
-               }
-               if (sJoinCmd.bPSEnable == true) {
-                       pDevice->ePSMode = WMAC_POWER_FAST;
-                       pMgmt->wListenInterval = 2;
-                       pr_debug("Power Saving On\n");
-               } else {
-                       pDevice->ePSMode = WMAC_POWER_CAM;
-                       pMgmt->wListenInterval = 1;
-                       pr_debug("Power Saving Off\n");
-               }
-
-               if (sJoinCmd.bShareKeyAuth == true) {
-                       pMgmt->bShareKeyAlgorithm = true;
-                       pr_debug("Share Key\n");
-               } else {
-                       pMgmt->bShareKeyAlgorithm = false;
-                       pr_debug("Open System\n");
-               }
-               pDevice->uChannel = sJoinCmd.uChannel;
-               netif_stop_queue(pDevice->dev);
-               spin_lock_irq(&pDevice->lock);
-               pMgmt->eCurrState = WMAC_STATE_IDLE;
-               bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
-               bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL);
-               spin_unlock_irq(&pDevice->lock);
-               break;
-
-       case WLAN_CMD_SET_WEP:
-               pr_debug("WLAN_CMD_SET_WEP Key\n");
-               memset(&sWEPCmd, 0, sizeof(SCmdSetWEP));
-               if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) {
-                       result = -EFAULT;
-                       break;
-               }
-               if (sWEPCmd.bEnableWep != true) {
-                       pDevice->bEncryptionEnable = false;
-                       pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
-                       MACvDisableDefaultKey(pDevice->PortOffset);
-                       pr_debug("WEP function disable\n");
-                       break;
-               }
-
-               for (ii = 0; ii < WLAN_WEP_NKEYS; ii++) {
-                       if (sWEPCmd.bWepKeyAvailable[ii]) {
-                               if (ii == sWEPCmd.byKeyIndex)
-                                       dwKeyIndex = ii | (1 << 31);
-                               else
-                                       dwKeyIndex = ii;
-
-                               KeybSetDefaultKey(&(pDevice->sKey),
-                                                 dwKeyIndex,
-                                                 sWEPCmd.auWepKeyLength[ii],
-                                                 NULL,
-                                                 (unsigned char *)&sWEPCmd.abyWepKey[ii][0],
-                                                 KEY_CTL_WEP,
-                                                 pDevice->PortOffset,
-                                                 pDevice->byLocalID);
-                       }
-               }
-               pDevice->byKeyIndex = sWEPCmd.byKeyIndex;
-               pDevice->bTransmitKey = true;
-               pDevice->bEncryptionEnable = true;
-               pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
-               break;
-
-       case WLAN_CMD_GET_LINK: {
-               SCmdLinkStatus sLinkStatus;
-
-               pr_debug("WLAN_CMD_GET_LINK status\n");
-
-               memset(&sLinkStatus, 0, sizeof(sLinkStatus));
-
-               if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)
-                       sLinkStatus.wBSSType = ADHOC;
-               else
-                       sLinkStatus.wBSSType = INFRA;
-
-               if (pMgmt->eCurrState == WMAC_STATE_JOINTED)
-                       sLinkStatus.byState = ADHOC_JOINTED;
-               else
-                       sLinkStatus.byState = ADHOC_STARTED;
-
-               sLinkStatus.uChannel = pMgmt->uCurrChannel;
-               if (pDevice->bLinkPass == true) {
-                       sLinkStatus.bLink = true;
-                       pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
-                       memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len);
-                       memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
-                       sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate;
-                       pr_debug(" Link Success!\n");
-               } else {
-                       sLinkStatus.bLink = false;
-                       sLinkStatus.uLinkRate = 0;
-               }
-               if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) {
-                       result = -EFAULT;
-                       break;
-               }
-               break;
-       }
-       case WLAN_CMD_GET_LISTLEN:
-               cbListCount = 0;
-               pBSS = &(pMgmt->sBSSList[0]);
-               for (ii = 0; ii < MAX_BSS_NUM; ii++) {
-                       pBSS = &(pMgmt->sBSSList[ii]);
-                       if (!pBSS->bActive)
-                               continue;
-                       cbListCount++;
-               }
-               sList.uItem = cbListCount;
-               if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) {
-                       result = -EFAULT;
-                       break;
-               }
-               pReq->wResult = 0;
-               break;
-
-       case WLAN_CMD_GET_LIST:
-               if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) {
-                       result = -EFAULT;
-                       break;
-               }
-               if (sList.uItem > (ULONG_MAX - sizeof(SBSSIDList)) / sizeof(SBSSIDItem)) {
-                       result = -EINVAL;
-                       break;
-               }
-               pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)),
-                                            GFP_ATOMIC);
-               if (pList == NULL) {
-                       result = -ENOMEM;
-                       break;
-               }
-               pList->uItem = sList.uItem;
-               pBSS = &(pMgmt->sBSSList[0]);
-               for (ii = 0, jj = 0; jj < MAX_BSS_NUM; jj++) {
-                       pBSS = &(pMgmt->sBSSList[jj]);
-                       if (pBSS->bActive) {
-                               pList->sBSSIDList[ii].uChannel = pBSS->uChannel;
-                               pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval;
-                               pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo;
-                               RFvRSSITodBm(pDevice, (unsigned char)(pBSS->uRSSI), &ldBm);
-                               pList->sBSSIDList[ii].uRSSI = (unsigned int)ldBm;
-                               memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN);
-                               pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
-                               memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1);
-                               memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len);
-                               if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo))
-                                       pList->sBSSIDList[ii].byNetType = INFRA;
-                               else
-                                       pList->sBSSIDList[ii].byNetType = ADHOC;
-
-                               if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo))
-                                       pList->sBSSIDList[ii].bWEPOn = true;
-                               else
-                                       pList->sBSSIDList[ii].bWEPOn = false;
-
-                               ii++;
-                               if (ii >= pList->uItem)
-                                       break;
-                       }
-               }
-
-               if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) {
-                       result = -EFAULT;
-                       break;
-               }
-               kfree(pList);
-               pReq->wResult = 0;
-               break;
-
-       case WLAN_CMD_GET_MIB:
-               if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) {
-                       result = -EFAULT;
-                       break;
-               }
-               break;
-
-       case WLAN_CMD_GET_STAT:
-               if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) {
-                       result = -EFAULT;
-                       break;
-               }
-               break;
-
-       case WLAN_CMD_STOP_MAC:
-               pr_debug("WLAN_CMD_STOP_MAC\n");
-               netif_stop_queue(pDevice->dev);
-
-               spin_lock_irq(&pDevice->lock);
-               if (pDevice->bRadioOff == false)
-                       CARDbRadioPowerOff(pDevice);
-
-               pDevice->bLinkPass = false;
-               memset(pMgmt->abyCurrBSSID, 0, 6);
-               pMgmt->eCurrState = WMAC_STATE_IDLE;
-               del_timer(&pDevice->sTimerCommand);
-               del_timer(&pMgmt->sTimerSecondCallback);
-               pDevice->bCmdRunning = false;
-               pDevice->bMACSuspend = true;
-               MACvIntDisable(pDevice->PortOffset);
-               spin_unlock_irq(&pDevice->lock);
-               break;
-
-       case WLAN_CMD_START_MAC:
-               pr_debug("WLAN_CMD_START_MAC\n");
-
-               if (pDevice->bMACSuspend == true) {
-                       if (pDevice->bRadioOff == true)
-                               CARDbRadioPowerOn(pDevice);
-                       vMgrTimerInit(pDevice);
-                       MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
-                       add_timer(&pMgmt->sTimerSecondCallback);
-                       pDevice->bMACSuspend = false;
-               }
-               break;
-
-       case WLAN_CMD_SET_HOSTAPD:
-               pr_debug("WLAN_CMD_SET_HOSTAPD\n");
-
-               if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
-                       result = -EFAULT;
-                       break;
-               }
-               if (sValue.dwValue == 1) {
-                       if (vt6655_hostap_set_hostapd(pDevice, 1, 1) == 0) {
-                               pr_debug("Enable HOSTAP\n");
-                       } else {
-                               result = -EFAULT;
-                               break;
-                       }
-               } else {
-                       vt6655_hostap_set_hostapd(pDevice, 0, 1);
-                       pr_debug("Disable HOSTAP\n");
-               }
-               break;
-
-       case WLAN_CMD_SET_HOSTAPD_STA:
-               pr_debug("WLAN_CMD_SET_HOSTAPD_STA\n");
-               break;
-
-       case WLAN_CMD_SET_802_1X:
-               pr_debug("WLAN_CMD_SET_802_1X\n");
-               if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
-                       result = -EFAULT;
-                       break;
-               }
-
-               if (sValue.dwValue == 1) {
-                       pDevice->bEnable8021x = true;
-                       pr_debug("Enable 802.1x\n");
-               } else {
-                       pDevice->bEnable8021x = false;
-                       pr_debug("Disable 802.1x\n");
-               }
-               break;
-
-       case WLAN_CMD_SET_HOST_WEP:
-               pr_debug("WLAN_CMD_SET_HOST_WEP\n");
-               if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
-                       result = -EFAULT;
-                       break;
-               }
-
-               if (sValue.dwValue == 1) {
-                       pDevice->bEnableHostWEP = true;
-                       pr_debug("Enable HostWEP\n");
-               } else {
-                       pDevice->bEnableHostWEP = false;
-                       pr_debug("Disable HostWEP\n");
-               }
-               break;
-
-       case WLAN_CMD_SET_WPA:
-               pr_debug("WLAN_CMD_SET_WPA\n");
-
-               if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
-                       result = -EFAULT;
-                       break;
-               }
-               if (sValue.dwValue == 1) {
-                       pr_debug("up wpadev\n");
-                       eth_hw_addr_inherit(pDevice->wpadev, pDevice->dev);
-                       pDevice->bWPADEVUp = true;
-               } else {
-                       pr_debug("close wpadev\n");
-                       pDevice->bWPADEVUp = false;
-               }
-               break;
-
-       case WLAN_CMD_AP_START:
-               pr_debug("WLAN_CMD_AP_START\n");
-               if (pDevice->bRadioOff == true) {
-                       CARDbRadioPowerOn(pDevice);
-                       vMgrTimerInit(pDevice);
-                       MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
-                       add_timer(&pMgmt->sTimerSecondCallback);
-               }
-               if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) {
-                       result = -EFAULT;
-                       break;
-               }
-
-               if (sStartAPCmd.wBSSType == AP) {
-                       pMgmt->eConfigMode = WMAC_CONFIG_AP;
-                       pr_debug("ioct set to AP mode\n");
-               } else {
-                       pr_debug("ioct BSS type not set to AP mode\n");
-                       result = -EFAULT;
-                       break;
-               }
-
-               if (sStartAPCmd.wBBPType == PHY80211g)
-                       pMgmt->byAPBBType = PHY_TYPE_11G;
-               else if (sStartAPCmd.wBBPType == PHY80211a)
-                       pMgmt->byAPBBType = PHY_TYPE_11A;
-               else
-                       pMgmt->byAPBBType = PHY_TYPE_11B;
-
-               pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid;
-               if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)
-                       return -EINVAL;
-               memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
-               memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
-
-               if ((sStartAPCmd.uChannel > 0) && (sStartAPCmd.uChannel <= 14))
-                       pDevice->uChannel = sStartAPCmd.uChannel;
-
-               if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000))
-                       pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt;
-               else
-                       pMgmt->wIBSSBeaconPeriod = 100;
-
-               if (sStartAPCmd.bShareKeyAuth == true) {
-                       pMgmt->bShareKeyAlgorithm = true;
-                       pr_debug("Share Key\n");
-               } else {
-                       pMgmt->bShareKeyAlgorithm = false;
-                       pr_debug("Open System\n");
-               }
-               memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6);
-
-               if (sStartAPCmd.byBasicRate & BIT3) {
-                       pMgmt->abyIBSSSuppRates[2] |= BIT7;
-                       pMgmt->abyIBSSSuppRates[3] |= BIT7;
-                       pMgmt->abyIBSSSuppRates[4] |= BIT7;
-                       pMgmt->abyIBSSSuppRates[5] |= BIT7;
-               } else if (sStartAPCmd.byBasicRate & BIT2) {
-                       pMgmt->abyIBSSSuppRates[2] |= BIT7;
-                       pMgmt->abyIBSSSuppRates[3] |= BIT7;
-                       pMgmt->abyIBSSSuppRates[4] |= BIT7;
-               } else if (sStartAPCmd.byBasicRate & BIT1) {
-                       pMgmt->abyIBSSSuppRates[2] |= BIT7;
-                       pMgmt->abyIBSSSuppRates[3] |= BIT7;
-               } else if (sStartAPCmd.byBasicRate & BIT1) {
-                       pMgmt->abyIBSSSuppRates[2] |= BIT7;
-               } else {
-                       /* default 1,2M */
-                       pMgmt->abyIBSSSuppRates[2] |= BIT7;
-                       pMgmt->abyIBSSSuppRates[3] |= BIT7;
-               }
-
-               pr_debug("Support Rate= %*ph\n",
-                        4, pMgmt->abyIBSSSuppRates + 2);
-
-               netif_stop_queue(pDevice->dev);
-               spin_lock_irq(&pDevice->lock);
-               bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL);
-               spin_unlock_irq(&pDevice->lock);
-               break;
-
-       case WLAN_CMD_GET_NODE_CNT:
-               cbListCount = 0;
-               pNode = &(pMgmt->sNodeDBTable[0]);
-               for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
-                       pNode = &(pMgmt->sNodeDBTable[ii]);
-                       if (!pNode->bActive)
-                               continue;
-                       cbListCount++;
-               }
-
-               sNodeList.uItem = cbListCount;
-               if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) {
-                       result = -EFAULT;
-                       break;
-               }
-               pReq->wResult = 0;
-               break;
-
-       case WLAN_CMD_GET_NODE_LIST:
-               if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) {
-                       result = -EFAULT;
-                       break;
-               }
-               if (sNodeList.uItem > (ULONG_MAX - sizeof(SNodeList)) / sizeof(SNodeItem)) {
-                       result = -EINVAL;
-                       break;
-               }
-               pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)),
-                                               GFP_ATOMIC);
-               if (pNodeList == NULL) {
-                       result = -ENOMEM;
-                       break;
-               }
-               pNodeList->uItem = sNodeList.uItem;
-               pNode = &(pMgmt->sNodeDBTable[0]);
-               for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) {
-                       pNode = &(pMgmt->sNodeDBTable[ii]);
-                       if (pNode->bActive) {
-                               pNodeList->sNodeList[jj].wAID = pNode->wAID;
-                               memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN);
-                               pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate;
-                               pNodeList->sNodeList[jj].wInActiveCount = (unsigned short)pNode->uInActiveCount;
-                               pNodeList->sNodeList[jj].wEnQueueCnt = (unsigned short)pNode->wEnQueueCnt;
-                               pNodeList->sNodeList[jj].wFlags = (unsigned short)pNode->dwFlags;
-                               pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable;
-                               pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex;
-                               pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength;
-                               memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN);
-                               pr_debug("key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
-                                        pNodeList->sNodeList[jj].abyWepKey[0],
-                                        pNodeList->sNodeList[jj].abyWepKey[1],
-                                        pNodeList->sNodeList[jj].abyWepKey[2],
-                                        pNodeList->sNodeList[jj].abyWepKey[3],
-                                        pNodeList->sNodeList[jj].abyWepKey[4]);
-                               pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback;
-                               pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures;
-                               pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts;
-                               pNodeList->sNodeList[jj].wFailureRatio = (unsigned short)pNode->uFailureRatio;
-                               jj++;
-                               if (jj >= pNodeList->uItem)
-                                       break;
-                       }
-               }
-               if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) {
-                       result = -EFAULT;
-                       break;
-               }
-               kfree(pNodeList);
-               pReq->wResult = 0;
-               break;
-
-#ifdef WPA_SM_Transtatus
-       case 0xFF:
-               memset(wpa_Result.ifname, 0, sizeof(wpa_Result.ifname));
-               wpa_Result.proto = 0;
-               wpa_Result.key_mgmt = 0;
-               wpa_Result.eap_type = 0;
-               wpa_Result.authenticated = false;
-               pDevice->fWPA_Authened = false;
-               if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) {
-                       result = -EFAULT;
-                       break;
-               }
-
-               if (wpa_Result.authenticated == true) {
-#ifdef SndEvt_ToAPI
-                       {
-                               union iwreq_data wrqu;
-
-                               pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
-
-                               memset(&wrqu, 0, sizeof(wrqu));
-                               wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG;
-                               wrqu.data.length = pItemSSID->len;
-                               wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID);
-                       }
-#endif
-                       pDevice->fWPA_Authened = true; /* is successful peer to wpa_Result.authenticated? */
-               }
-               pReq->wResult = 0;
-               break;
-#endif
-
-       default:
-               pr_debug("Private command not support..\n");
-       }
-
-       return result;
-}
diff --git a/drivers/staging/vt6655/ioctl.h b/drivers/staging/vt6655/ioctl.h
deleted file mode 100644 (file)
index 2dc5a57..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: hostap.h
- *
- * Purpose:
- *
- * Author: Lyndon Chen
- *
- * Date: May 21, 2003
- *
- */
-
-#ifndef __IOCTL_H__
-#define __IOCTL_H__
-
-#include "device.h"
-
-int private_ioctl(struct vnt_private *, struct ifreq *rq);
-
-#endif // __IOCTL_H__
diff --git a/drivers/staging/vt6655/iowpa.h b/drivers/staging/vt6655/iowpa.h
deleted file mode 100644 (file)
index fe4b22e..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: iowpa.h
- *
- * Purpose: Handles wpa supplicant ioctl interface
- *
- * Author: Lyndon Chen
- *
- * Date: May 8, 2002
- *
- */
-
-#ifndef __IOWPA_H__
-#define __IOWPA_H__
-
-#define WPA_IE_LEN 64
-
-//WPA related
-
-enum {
-       VIAWGET_SET_WPA = 1,
-       VIAWGET_SET_KEY = 2,
-       VIAWGET_SET_SCAN = 3,
-       VIAWGET_GET_SCAN = 4,
-       VIAWGET_GET_SSID = 5,
-       VIAWGET_GET_BSSID = 6,
-       VIAWGET_SET_DROP_UNENCRYPT = 7,
-       VIAWGET_SET_DEAUTHENTICATE = 8,
-       VIAWGET_SET_ASSOCIATE = 9,
-       VIAWGET_SET_DISASSOCIATE = 10
-};
-
-enum {
-       VIAWGET_ASSOC_MSG = 1,
-       VIAWGET_DISASSOC_MSG = 2,
-       VIAWGET_PTK_MIC_MSG = 3,
-       VIAWGET_GTK_MIC_MSG = 4,
-       VIAWGET_CCKM_ROAM_MSG = 5,
-       VIAWGET_DEVICECLOSE_MSG = 6
-};
-
-#pragma pack(1)
-typedef struct viawget_wpa_header {
-       u8 type;
-       u16 req_ie_len;
-       u16 resp_ie_len;
-} viawget_wpa_header;
-
-struct viawget_wpa_param {
-       u32 cmd;
-       u8 addr[6];
-       union {
-               struct {
-                       u8 len;
-                       u8 data[0];
-               } generic_elem;
-
-               struct {
-                       u8 bssid[6];
-                       u8 ssid[32];
-                       u8 ssid_len;
-                       u8 __user *wpa_ie;
-                       u16 wpa_ie_len;
-                       int pairwise_suite;
-                       int group_suite;
-                       int key_mgmt_suite;
-                       int auth_alg;
-                       int mode;
-
-               } wpa_associate;
-
-               struct {
-                       int alg_name;
-                       u16 key_index;
-                       u16 set_tx;
-                       u8 *seq;
-                       u16 seq_len;
-                       u8 *key;
-                       u16 key_len;
-               } wpa_key;
-
-               struct {
-                       u8 ssid_len;
-                       u8 ssid[32];
-               } scan_req;
-
-               struct {
-                       u16 scan_count;
-                       u8 __user *buf;
-               } scan_results;
-
-       } u;
-};
-
-#pragma pack(1)
-struct viawget_scan_result {
-       u8 bssid[6];
-       u8 ssid[32];
-       u16 ssid_len;
-       u8 wpa_ie[WPA_IE_LEN];
-       u16 wpa_ie_len;
-       u8 rsn_ie[WPA_IE_LEN];
-       u16 rsn_ie_len;
-       int freq; // MHz
-       int caps; // e.g. privacy
-       int qual; // signal quality
-       int noise;
-       int level;
-       int maxrate;
-};
-
-#pragma pack()
-
-#endif //__IOWPA_H__
diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c
deleted file mode 100644 (file)
index 14a62bd..0000000
+++ /dev/null
@@ -1,1937 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: iwctl.c
- *
- * Purpose:  wireless ext & ioctl functions
- *
- * Author: Lyndon Chen
- *
- * Date: July 5, 2006
- *
- * Functions:
- *
- * Revision History:
- *
- */
-
-#include "device.h"
-#include "ioctl.h"
-#include "iocmd.h"
-#include "iwctl.h"
-#include "mac.h"
-#include "card.h"
-#include "hostap.h"
-#include "power.h"
-#include "rf.h"
-
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-#include "iowpa.h"
-#include "wpactl.h"
-#endif
-
-#include <net/iw_handler.h>
-extern unsigned short TxRate_iwconfig;//2008-5-8 <add> by chester
-
-/*---------------------  Static Definitions -------------------------*/
-
-//2008-0409-07, <Add> by Einsn Liu
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-#define SUPPORTED_WIRELESS_EXT                  18
-#else
-#define SUPPORTED_WIRELESS_EXT                  17
-#endif
-
-static const long frequency_list[] = {
-       2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
-       4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
-       5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
-       5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
-       5700, 5745, 5765, 5785, 5805, 5825
-};
-
-/*---------------------  Static Classes  ----------------------------*/
-/*---------------------  Static Variables  --------------------------*/
-/*---------------------  Static Functions  --------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       long ldBm;
-
-       pDevice->wstats.status = pDevice->op_mode;
-#ifdef Calcu_LinkQual
-       if (pDevice->scStatistic.LinkQuality > 100)
-               pDevice->scStatistic.LinkQuality = 100;
-       pDevice->wstats.qual.qual = (unsigned char)pDevice->scStatistic.LinkQuality;
-#else
-       pDevice->wstats.qual.qual = pDevice->byCurrSQ;
-#endif
-       RFvRSSITodBm(pDevice, (unsigned char)(pDevice->uCurrRSSI), &ldBm);
-       pDevice->wstats.qual.level = ldBm;
-       pDevice->wstats.qual.noise = 0;
-       pDevice->wstats.qual.updated = 1;
-       pDevice->wstats.discard.nwid = 0;
-       pDevice->wstats.discard.code = 0;
-       pDevice->wstats.discard.fragment = 0;
-       pDevice->wstats.discard.retries = (unsigned long)pDevice->scStatistic.dwTsrErr;
-       pDevice->wstats.discard.misc = 0;
-       pDevice->wstats.miss.beacon = 0;
-
-       return &pDevice->wstats;
-}
-
-/*------------------------------------------------------------------*/
-
-static int iwctl_commit(struct net_device *dev,
-                       struct iw_request_info *info,
-                       void *wrq,
-                       char *extra)
-{
-       pr_debug(" SIOCSIWCOMMIT\n");
-
-       return 0;
-}
-/*
- * Wireless Handler : get protocol name
- */
-
-int iwctl_giwname(struct net_device *dev,
-                 struct iw_request_info *info,
-                 char *wrq,
-                 char *extra)
-{
-       strcpy(wrq, "802.11-a/b/g");
-       return 0;
-}
-
-/*
- * Wireless Handler : set scan
- */
-
-static int iwctl_siwscan(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_point *wrq,
-                 char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
-       struct iw_scan_req  *req = (struct iw_scan_req *)extra;
-       unsigned char abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
-       PWLAN_IE_SSID pItemSSID = NULL;
-
-       pr_debug(" SIOCSIWSCAN\n");
-
-       if (pDevice->byReAssocCount > 0) {   //reject scan when re-associating!
-//send scan event to wpa_Supplicant
-               union iwreq_data wrqu;
-
-               PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
-               memset(&wrqu, 0, sizeof(wrqu));
-               wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
-               return 0;
-       }
-
-       spin_lock_irq(&pDevice->lock);
-       BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass);
-
-//mike add: active scan OR passive scan OR desire_ssid scan
-       if (wrq->length == sizeof(struct iw_scan_req)) {
-               if (wrq->flags & IW_SCAN_THIS_ESSID)  {                               //desire_ssid scan
-                       memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
-                       pItemSSID = (PWLAN_IE_SSID)abyScanSSID;
-                       pItemSSID->byElementID = WLAN_EID_SSID;
-                       memcpy(pItemSSID->abySSID, req->essid, (int)req->essid_len);
-                       if (pItemSSID->abySSID[req->essid_len - 1] == '\0') {
-                               if (req->essid_len > 0)
-                                       pItemSSID->len = req->essid_len - 1;
-                       } else
-                               pItemSSID->len = req->essid_len;
-                       pMgmt->eScanType = WMAC_SCAN_PASSIVE;
-                       PRINT_K("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n", ((PWLAN_IE_SSID)abyScanSSID)->abySSID,
-                               ((PWLAN_IE_SSID)abyScanSSID)->len);
-                       bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
-                       spin_unlock_irq(&pDevice->lock);
-
-                       return 0;
-               } else if (req->scan_type == IW_SCAN_TYPE_PASSIVE) {          //passive scan
-                       pMgmt->eScanType = WMAC_SCAN_PASSIVE;
-               }
-       } else {           //active scan
-               pMgmt->eScanType = WMAC_SCAN_ACTIVE;
-       }
-
-       pMgmt->eScanType = WMAC_SCAN_PASSIVE;
-       bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL);
-       spin_unlock_irq(&pDevice->lock);
-
-       return 0;
-}
-
-/*
- * Wireless Handler : get scan results
- */
-
-static int iwctl_giwscan(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_point *wrq,
-                 char *extra)
-{
-       int ii, jj, kk;
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
-       PKnownBSS           pBSS;
-       PWLAN_IE_SSID       pItemSSID;
-       PWLAN_IE_SUPP_RATES pSuppRates, pExtSuppRates;
-       char *current_ev = extra;
-       char *end_buf = extra + IW_SCAN_MAX_DATA;
-       char *current_val = NULL;
-       struct iw_event iwe;
-       long ldBm;
-       char buf[MAX_WPA_IE_LEN * 2 + 30];
-
-       pr_debug(" SIOCGIWSCAN\n");
-
-       if (pMgmt->eScanState ==  WMAC_IS_SCANNING) {
-               // In scanning..
-               return -EAGAIN;
-       }
-       pBSS = &(pMgmt->sBSSList[0]);
-       for (ii = 0, jj = 0; jj < MAX_BSS_NUM; jj++) {
-               if (current_ev >= end_buf)
-                       break;
-               pBSS = &(pMgmt->sBSSList[jj]);
-               if (pBSS->bActive) {
-                       //ADD mac address
-                       memset(&iwe, 0, sizeof(iwe));
-                       iwe.cmd = SIOCGIWAP;
-                       iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
-                       memcpy(iwe.u.ap_addr.sa_data, pBSS->abyBSSID, WLAN_BSSID_LEN);
-                       current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
-                       //ADD ssid
-                       memset(&iwe, 0, sizeof(iwe));
-                       iwe.cmd = SIOCGIWESSID;
-                       pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
-                       iwe.u.data.length = pItemSSID->len;
-                       iwe.u.data.flags = 1;
-                       current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pItemSSID->abySSID);
-                       //ADD mode
-                       memset(&iwe, 0, sizeof(iwe));
-                       iwe.cmd = SIOCGIWMODE;
-                       if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo))
-                               iwe.u.mode = IW_MODE_INFRA;
-                       else
-                               iwe.u.mode = IW_MODE_ADHOC;
-
-                       iwe.len = IW_EV_UINT_LEN;
-                       current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
-                       //ADD frequency
-                       pSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abySuppRates;
-                       pExtSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abyExtSuppRates;
-                       memset(&iwe, 0, sizeof(iwe));
-                       iwe.cmd = SIOCGIWFREQ;
-                       iwe.u.freq.m = pBSS->uChannel;
-                       iwe.u.freq.e = 0;
-                       iwe.u.freq.i = 0;
-                       current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
-                       //2008-0409-04, <Add> by Einsn Liu
-                       {
-                               int f = (int)pBSS->uChannel - 1;
-
-                               if (f < 0)f = 0;
-                               iwe.u.freq.m = frequency_list[f] * 100000;
-                               iwe.u.freq.e = 1;
-                       }
-                       current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
-                       //ADD quality
-                       memset(&iwe, 0, sizeof(iwe));
-                       iwe.cmd = IWEVQUAL;
-                       RFvRSSITodBm(pDevice, (unsigned char)(pBSS->uRSSI), &ldBm);
-                       iwe.u.qual.level = ldBm;
-                       iwe.u.qual.noise = 0;
-//2008-0409-01, <Add> by Einsn Liu
-                       if (-ldBm < 50)
-                               iwe.u.qual.qual = 100;
-                       else if (-ldBm > 90)
-                               iwe.u.qual.qual = 0;
-                       else
-                               iwe.u.qual.qual = (40 - (-ldBm - 50)) * 100 / 40;
-
-                       iwe.u.qual.updated = 7;
-
-                       current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
-
-                       memset(&iwe, 0, sizeof(iwe));
-                       iwe.cmd = SIOCGIWENCODE;
-                       iwe.u.data.length = 0;
-                       if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo))
-                               iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
-                       else
-                               iwe.u.data.flags = IW_ENCODE_DISABLED;
-
-                       current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pItemSSID->abySSID);
-
-                       memset(&iwe, 0, sizeof(iwe));
-                       iwe.cmd = SIOCGIWRATE;
-                       iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
-                       current_val = current_ev + IW_EV_LCP_LEN;
-
-                       for (kk = 0; kk < 12; kk++) {
-                               if (pSuppRates->abyRates[kk] == 0)
-                                       break;
-                               // Bit rate given in 500 kb/s units (+ 0x80)
-                               iwe.u.bitrate.value = ((pSuppRates->abyRates[kk] & 0x7f) * 500000);
-                               current_val = iwe_stream_add_value(info, current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
-                       }
-                       for (kk = 0; kk < 8; kk++) {
-                               if (pExtSuppRates->abyRates[kk] == 0)
-                                       break;
-                               // Bit rate given in 500 kb/s units (+ 0x80)
-                               iwe.u.bitrate.value = ((pExtSuppRates->abyRates[kk] & 0x7f) * 500000);
-                               current_val = iwe_stream_add_value(info, current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
-                       }
-
-                       if ((current_val - current_ev) > IW_EV_LCP_LEN)
-                               current_ev = current_val;
-
-                       memset(&iwe, 0, sizeof(iwe));
-                       iwe.cmd = IWEVCUSTOM;
-                       sprintf(buf, "bcn_int=%d", pBSS->wBeaconInterval);
-                       iwe.u.data.length = strlen(buf);
-                       current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, buf);
-
-                       if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) {
-                               memset(&iwe, 0, sizeof(iwe));
-                               iwe.cmd = IWEVGENIE;
-                               iwe.u.data.length = pBSS->wWPALen;
-                               current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pBSS->byWPAIE);
-                       }
-
-                       if ((pBSS->wRSNLen > 0) && (pBSS->wRSNLen <= MAX_WPA_IE_LEN)) {
-                               memset(&iwe, 0, sizeof(iwe));
-                               iwe.cmd = IWEVGENIE;
-                               iwe.u.data.length = pBSS->wRSNLen;
-                               current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pBSS->byRSNIE);
-                       }
-
-               }
-       }// for
-
-       wrq->length = current_ev - extra;
-       return 0;
-}
-
-/*
- * Wireless Handler : set frequency or channel
- */
-
-int iwctl_siwfreq(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_freq *wrq,
-                 char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       int rc = 0;
-
-       pr_debug(" SIOCSIWFREQ\n");
-
-       // If setting by frequency, convert to a channel
-       if ((wrq->e == 1) &&
-           (wrq->m >= (int) 2.412e8) &&
-           (wrq->m <= (int) 2.487e8)) {
-               int f = wrq->m / 100000;
-               int c = 0;
-
-               while ((c < 14) && (f != frequency_list[c]))
-                       c++;
-               wrq->e = 0;
-               wrq->m = c + 1;
-       }
-       // Setting by channel number
-       if ((wrq->m > 14) || (wrq->e > 0))
-               rc = -EOPNOTSUPP;
-       else {
-               int channel = wrq->m;
-
-               if ((channel < 1) || (channel > 14)) {
-                       pr_debug("%s: New channel value of %d is invalid!\n",
-                                dev->name, wrq->m);
-                       rc = -EINVAL;
-               } else {
-                       // Yes ! We can set it !!!
-                       pr_debug(" Set to channel = %d\n", channel);
-                       pDevice->uChannel = channel;
-                       //2007-0207-04,<Add> by EinsnLiu
-                       //Make change effect at once
-                       pDevice->bCommit = true;
-               }
-       }
-
-       return rc;
-}
-
-/*
- * Wireless Handler : get frequency or channel
- */
-
-int iwctl_giwfreq(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_freq *wrq,
-                 char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
-
-       pr_debug(" SIOCGIWFREQ\n");
-
-#ifdef WEXT_USECHANNELS
-       wrq->m = (int)pMgmt->uCurrChannel;
-       wrq->e = 0;
-#else
-       {
-               int f = (int)pMgmt->uCurrChannel - 1;
-
-               if (f < 0)
-                       f = 0;
-               wrq->m = frequency_list[f] * 100000;
-               wrq->e = 1;
-       }
-#endif
-
-       return 0;
-}
-
-/*
- * Wireless Handler : set operation mode
- */
-
-int iwctl_siwmode(struct net_device *dev,
-                 struct iw_request_info *info,
-                 __u32 *wmode,
-                 char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
-       int rc = 0;
-
-       pr_debug(" SIOCSIWMODE\n");
-
-       if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP && pDevice->bEnableHostapd) {
-               pr_debug("Can't set operation mode, hostapd is running\n");
-               return rc;
-       }
-
-       switch (*wmode) {
-       case IW_MODE_ADHOC:
-               if (pMgmt->eConfigMode != WMAC_CONFIG_IBSS_STA) {
-                       pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
-                       if (pDevice->flags & DEVICE_FLAGS_OPENED)
-                               pDevice->bCommit = true;
-
-               }
-               pr_debug("set mode to ad-hoc\n");
-               break;
-       case IW_MODE_AUTO:
-       case IW_MODE_INFRA:
-               if (pMgmt->eConfigMode != WMAC_CONFIG_ESS_STA) {
-                       pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
-                       if (pDevice->flags & DEVICE_FLAGS_OPENED)
-                               pDevice->bCommit = true;
-
-               }
-               pr_debug("set mode to infrastructure\n");
-               break;
-       case IW_MODE_MASTER:
-
-               pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
-               rc = -EOPNOTSUPP;
-               break;
-
-               if (pMgmt->eConfigMode != WMAC_CONFIG_AP) {
-                       pMgmt->eConfigMode = WMAC_CONFIG_AP;
-                       if (pDevice->flags & DEVICE_FLAGS_OPENED)
-                               pDevice->bCommit = true;
-
-               }
-               pr_debug("set mode to Access Point\n");
-               break;
-
-       case IW_MODE_REPEAT:
-               pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
-               rc = -EOPNOTSUPP;
-               break;
-       default:
-               rc = -EINVAL;
-       }
-
-       return rc;
-}
-
-/*
- * Wireless Handler : get operation mode
- */
-
-int iwctl_giwmode(struct net_device *dev,
-                 struct iw_request_info *info,
-                 __u32 *wmode,
-                 char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
-
-       pr_debug(" SIOCGIWMODE\n");
-       // If not managed, assume it's ad-hoc
-       switch (pMgmt->eConfigMode) {
-       case WMAC_CONFIG_ESS_STA:
-               *wmode = IW_MODE_INFRA;
-               break;
-       case WMAC_CONFIG_IBSS_STA:
-               *wmode = IW_MODE_ADHOC;
-               break;
-       case WMAC_CONFIG_AUTO:
-               *wmode = IW_MODE_INFRA;
-               break;
-       case WMAC_CONFIG_AP:
-               *wmode = IW_MODE_MASTER;
-               break;
-       default:
-               *wmode = IW_MODE_ADHOC;
-       }
-
-       return 0;
-}
-
-/*
- * Wireless Handler : get capability range
- */
-
-int iwctl_giwrange(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_point *wrq,
-                  char *extra)
-{
-       struct iw_range *range = (struct iw_range *)extra;
-       int i, k;
-       unsigned char abySupportedRates[13] = {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
-
-       pr_debug(" SIOCGIWRANGE\n");
-       if (wrq->pointer) {
-               wrq->length = sizeof(struct iw_range);
-               memset(range, 0, sizeof(struct iw_range));
-               range->min_nwid = 0x0000;
-               range->max_nwid = 0x0000;
-               range->num_channels = 14;
-               // Should be based on cap_rid.country to give only
-               //  what the current card support
-               k = 0;
-               for (i = 0; i < 14; i++) {
-                       range->freq[k].i = i + 1; // List index
-                       range->freq[k].m = frequency_list[i] * 100000;
-                       range->freq[k++].e = 1; // Values in table in MHz -> * 10^5 * 10
-               }
-               range->num_frequency = k;
-               // Hum... Should put the right values there
-#ifdef Calcu_LinkQual
-               range->max_qual.qual = 100;
-#else
-               range->max_qual.qual = 255;
-#endif
-               range->max_qual.level = 0;
-               range->max_qual.noise = 0;
-               range->sensitivity = 255;
-
-               for (i = 0; i < 13; i++) {
-                       range->bitrate[i] = abySupportedRates[i] * 500000;
-                       if (range->bitrate[i] == 0)
-                               break;
-               }
-               range->num_bitrates = i;
-
-               // Set an indication of the max TCP throughput
-               // in bit/s that we can expect using this interface.
-               //  May be use for QoS stuff... Jean II
-               if (i > 2)
-                       range->throughput = 5 * 1000 * 1000;
-               else
-                       range->throughput = 1.5 * 1000 * 1000;
-
-               range->min_rts = 0;
-               range->max_rts = 2312;
-               range->min_frag = 256;
-               range->max_frag = 2312;
-
-               // the encoding capabilities
-               range->num_encoding_sizes = 3;
-               // 64(40) bits WEP
-               range->encoding_size[0] = 5;
-               // 128(104) bits WEP
-               range->encoding_size[1] = 13;
-               // 256 bits for WPA-PSK
-               range->encoding_size[2] = 32;
-               // 4 keys are allowed
-               range->max_encoding_tokens = 4;
-
-               range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
-                       IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
-
-               range->min_pmp = 0;
-               range->max_pmp = 1000000;// 1 secs
-               range->min_pmt = 0;
-               range->max_pmt = 1000000;// 1 secs
-               range->pmp_flags = IW_POWER_PERIOD;
-               range->pmt_flags = IW_POWER_TIMEOUT;
-               range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
-
-               // Transmit Power - values are in mW
-
-               range->txpower[0] = 100;
-               range->num_txpower = 1;
-               range->txpower_capa = IW_TXPOW_MWATT;
-               range->we_version_source = SUPPORTED_WIRELESS_EXT;
-               range->we_version_compiled = WIRELESS_EXT;
-               range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
-               range->retry_flags = IW_RETRY_LIMIT;
-               range->r_time_flags = IW_RETRY_LIFETIME;
-               range->min_retry = 1;
-               range->max_retry = 65535;
-               range->min_r_time = 1024;
-               range->max_r_time = 65535 * 1024;
-               // Experimental measurements - boundary 11/5.5 Mb/s
-               // Note : with or without the (local->rssi), results
-               //  are somewhat different. - Jean II
-               range->avg_qual.qual = 6;
-               range->avg_qual.level = 176;    // -80 dBm
-               range->avg_qual.noise = 0;
-       }
-
-       return 0;
-}
-
-/*
- * Wireless Handler : set ap mac address
- */
-
-int iwctl_siwap(struct net_device *dev,
-               struct iw_request_info *info,
-               struct sockaddr *wrq,
-               char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
-       int rc = 0;
-       unsigned char ZeroBSSID[WLAN_BSSID_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
-       pr_debug(" SIOCSIWAP\n");
-       if (pMgmt->eScanState ==  WMAC_IS_SCANNING) {
-               // In scanning..
-               pr_debug("SIOCSIWAP(??)-->In scanning..\n");
-       }
-       if (wrq->sa_family != ARPHRD_ETHER)
-               rc = -EINVAL;
-       else {
-               memcpy(pMgmt->abyDesireBSSID, wrq->sa_data, 6);
-               //2008-0409-05, <Add> by Einsn Liu
-               if ((pDevice->bLinkPass == true) &&
-                   (memcmp(pMgmt->abyDesireBSSID, pMgmt->abyCurrBSSID, 6) == 0)) {
-                       return rc;
-               }
-               //mike :add
-               if ((is_broadcast_ether_addr(pMgmt->abyDesireBSSID)) ||
-                   (memcmp(pMgmt->abyDesireBSSID, ZeroBSSID, 6) == 0)) {
-                       PRINT_K("SIOCSIWAP:invalid desired BSSID return!\n");
-                       return rc;
-               }
-               //mike add: if desired AP is hidden ssid(there are two same BSSID in list),
-               //                  then ignore,because you don't known which one to be connect with??
-               {
-                       unsigned int ii, uSameBssidNum = 0;
-
-                       for (ii = 0; ii < MAX_BSS_NUM; ii++) {
-                               if (pMgmt->sBSSList[ii].bActive &&
-                                   ether_addr_equal(pMgmt->sBSSList[ii].abyBSSID,
-                                                    pMgmt->abyDesireBSSID)) {
-                                       uSameBssidNum++;
-                               }
-                       }
-                       if (uSameBssidNum >= 2) {  //hit: desired AP is in hidden ssid mode!!!
-                               PRINT_K("SIOCSIWAP:ignore for desired AP in hidden mode\n");
-                               return rc;
-                       }
-               }
-
-               if (pDevice->flags & DEVICE_FLAGS_OPENED)
-                       pDevice->bCommit = true;
-
-       }
-       return rc;
-}
-
-/*
- * Wireless Handler : get ap mac address
- */
-
-int iwctl_giwap(struct net_device *dev,
-               struct iw_request_info *info,
-               struct sockaddr *wrq,
-               char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
-
-       pr_debug(" SIOCGIWAP\n");
-
-       memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
-       //2008-0410,<Modify> by Einsn Liu
-       if ((pDevice->bLinkPass == false) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP))
-               memset(wrq->sa_data, 0, 6);
-
-       if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)
-               memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
-
-       wrq->sa_family = ARPHRD_ETHER;
-
-       return 0;
-}
-
-/*
- * Wireless Handler : get ap list
- */
-
-int iwctl_giwaplist(struct net_device *dev,
-                   struct iw_request_info *info,
-                   struct iw_point *wrq,
-                   char *extra)
-{
-       int ii, jj, rc = 0;
-       struct sockaddr *sock   = NULL;
-       struct sockaddr *s      = NULL;
-       struct iw_quality *qual = NULL;
-       struct iw_quality *q    = NULL;
-       PKnownBSS pBSS          = NULL;
-
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
-
-       pr_debug(" SIOCGIWAPLIST\n");
-
-       if (!capable(CAP_NET_ADMIN)) {
-               rc = -EPERM;
-               goto exit;
-       }
-
-       if (!wrq->pointer)
-               goto exit;
-
-       sock = kmalloc_array(IW_MAX_AP, sizeof(struct sockaddr), GFP_KERNEL);
-       if (!sock) {
-               rc = -ENOMEM;
-               goto exit;
-       }
-
-       qual = kmalloc_array(IW_MAX_AP, sizeof(struct iw_quality), GFP_KERNEL);
-       if (!qual) {
-               rc = -ENOMEM;
-               goto exit;
-       }
-
-       for (ii = 0, jj = 0; ii < MAX_BSS_NUM; ii++) {
-               pBSS = &(pMgmt->sBSSList[ii]);
-
-               if (!pBSS->bActive)
-                       continue;
-               if (jj >= IW_MAX_AP)
-                       break;
-
-               s = &sock[jj];
-               q = &qual[jj];
-
-               memcpy(s->sa_data, pBSS->abyBSSID, 6);
-               s->sa_family    = ARPHRD_ETHER;
-               q->level        = pBSS->uRSSI;
-               q->qual         = 0;
-               q->noise        = 0;
-               q->updated      = 2;
-               jj++;
-       }
-
-       wrq->flags = 1; /* Should be define'd */
-       wrq->length = jj;
-       memcpy(extra, sock, sizeof(struct sockaddr) * jj);
-       memcpy(extra + sizeof(struct sockaddr) * jj,
-               qual,
-               sizeof(struct iw_quality) * jj);
-exit:
-       kfree(sock);
-       kfree(qual);
-       return rc;
-}
-
-/*
- * Wireless Handler : set essid
- */
-
-int iwctl_siwessid(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_point *wrq,
-                  char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
-       PWLAN_IE_SSID       pItemSSID;
-       //2008-0409-05, <Add> by Einsn Liu
-       unsigned char len;
-
-       pr_debug(" SIOCSIWESSID\n");
-       pDevice->fWPA_Authened = false;
-       if (pMgmt->eScanState ==  WMAC_IS_SCANNING) {
-               // In scanning..
-               pr_debug("SIOCSIWESSID(??)-->In scanning..\n");
-       }
-       // Check if we asked for `any'
-       if (wrq->flags == 0) {
-               // Just send an empty SSID list
-               memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
-               memset(pMgmt->abyDesireBSSID, 0xFF, 6);
-               PRINT_K("set essid to 'any'\n");
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-               return 0;
-#endif
-       } else {
-               // Set the SSID
-               memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
-               pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
-               pItemSSID->byElementID = WLAN_EID_SSID;
-
-               memcpy(pItemSSID->abySSID, extra, wrq->length);
-               if (pItemSSID->abySSID[wrq->length - 1] == '\0') {
-                       if (wrq->length > 0)
-                               pItemSSID->len = wrq->length - 1;
-               } else
-                       pItemSSID->len = wrq->length;
-               pr_debug("set essid to %s\n", pItemSSID->abySSID);
-               //2008-0409-05, <Add> by Einsn Liu
-               len = (pItemSSID->len > ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) ? pItemSSID->len : ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len;
-               if ((pDevice->bLinkPass == true) &&
-                   (memcmp(pItemSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, len) == 0))
-                       return 0;
-
-               //mike:need clear desiredBSSID
-               if (pItemSSID->len == 0) {
-                       memset(pMgmt->abyDesireBSSID, 0xFF, 6);
-                       return 0;
-               }
-
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-               //Wext wil order another command of siwap to link with desired AP,
-               //so here need not associate??
-               if (pDevice->bWPASuppWextEnabled == true)  {
-                       /*******search if  in hidden ssid mode ****/
-                       {
-                               PKnownBSS       pCurr = NULL;
-                               unsigned char abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
-                               unsigned int ii, uSameBssidNum = 0;
-
-                               memcpy(abyTmpDesireSSID, pMgmt->abyDesireSSID, sizeof(abyTmpDesireSSID));
-                               pCurr = BSSpSearchBSSList(pDevice,
-                                                         NULL,
-                                                         abyTmpDesireSSID,
-                                                         pMgmt->eConfigPHYMode
-);
-
-                               if (pCurr == NULL) {
-                                       PRINT_K("SIOCSIWESSID:hidden ssid site survey before associate.......\n");
-                                       vResetCommandTimer((void *)pDevice);
-                                       pMgmt->eScanType = WMAC_SCAN_ACTIVE;
-                                       bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
-                                       bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID);
-                               } else {  //mike:to find out if that desired SSID is a hidden-ssid AP ,
-                                       //         by means of judging if there are two same BSSID exist in list ?
-                                       for (ii = 0; ii < MAX_BSS_NUM; ii++) {
-                                               if (pMgmt->sBSSList[ii].bActive &&
-                                                   ether_addr_equal(pMgmt->sBSSList[ii].abyBSSID,
-                                                                    pCurr->abyBSSID)) {
-                                                       uSameBssidNum++;
-                                               }
-                                       }
-                                       if (uSameBssidNum >= 2) {  //hit: desired AP is in hidden ssid mode!!!
-                                               pr_debug("SIOCSIWESSID:hidden ssid directly associate.......\n");
-                                               vResetCommandTimer((void *)pDevice);
-                                               pMgmt->eScanType = WMAC_SCAN_PASSIVE;          //this scan type,you'll submit scan result!
-                                               bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
-                                               bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID);
-                                       }
-                               }
-                       }
-                       return 0;
-               }
-#endif
-
-               pr_debug("set essid = %s\n", pItemSSID->abySSID);
-       }
-
-       if (pDevice->flags & DEVICE_FLAGS_OPENED)
-               pDevice->bCommit = true;
-
-       return 0;
-}
-
-/*
- * Wireless Handler : get essid
- */
-
-int iwctl_giwessid(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_point *wrq,
-                  char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
-       PWLAN_IE_SSID       pItemSSID;
-
-       pr_debug(" SIOCGIWESSID\n");
-
-       // Note : if wrq->u.data.flags != 0, we should
-       // get the relevant SSID from the SSID list...
-
-       // Get the current SSID
-       pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
-       memcpy(extra, pItemSSID->abySSID , pItemSSID->len);
-       extra[pItemSSID->len] = '\0';
-       wrq->length = pItemSSID->len + 1;
-       //2008-0409-03, <Add> by Einsn Liu
-       wrq->length = pItemSSID->len;
-       wrq->flags = 1; // active
-
-       return 0;
-}
-
-/*
- * Wireless Handler : set data rate
- */
-
-int iwctl_siwrate(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_param *wrq,
-                 char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       int rc = 0;
-       u8      brate = 0;
-       int     i;
-       unsigned char abySupportedRates[13] = {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
-
-       pr_debug(" SIOCSIWRATE\n");
-       if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
-               rc = -EINVAL;
-               return rc;
-       }
-
-       // First : get a valid bit rate value
-
-       // Which type of value
-       if ((wrq->value < 13) &&
-           (wrq->value >= 0)) {
-               // Setting by rate index
-               // Find value in the magic rate table
-               brate = wrq->value;
-       } else {
-               // Setting by frequency value
-               u8      normvalue = (u8) (wrq->value/500000);
-
-               // Check if rate is valid
-               for (i = 0; i < 13; i++) {
-                       if (normvalue == abySupportedRates[i]) {
-                               brate = i;
-                               break;
-                       }
-               }
-       }
-       // -1 designed the max rate (mostly auto mode)
-       if (wrq->value == -1) {
-               // Get the highest available rate
-               for (i = 0; i < 13; i++) {
-                       if (abySupportedRates[i] == 0)
-                               break;
-               }
-               if (i != 0)
-                       brate = i - 1;
-
-       }
-       // Check that it is valid
-       // brate is index of abySupportedRates[]
-       if (brate > 13) {
-               rc = -EINVAL;
-               return rc;
-       }
-
-       // Now, check if we want a fixed or auto value
-       if (wrq->fixed != 0) {
-               // Fixed mode
-               // One rate, fixed
-               pr_debug("Rate Fix\n");
-               pDevice->bFixRate = true;
-               if ((pDevice->byBBType == BB_TYPE_11B) && (brate > 3)) {
-                       pDevice->uConnectionRate = 3;
-               } else {
-                       pDevice->uConnectionRate = brate;
-                       pr_debug("Fixed to Rate %d\n",
-                                pDevice->uConnectionRate);
-               }
-
-       } else {
-               pDevice->bFixRate = false;
-               pDevice->uConnectionRate = 13;
-               pr_debug("auto rate:connection_rate is 13\n");
-       }
-
-       return rc;
-}
-
-/*
- * Wireless Handler : get data rate
- */
-
-int iwctl_giwrate(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_param *wrq,
-                 char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-//2007-0118-05,<Mark> by EinsnLiu
-//Mark the unnecessary sentences.
-//    PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
-
-       pr_debug(" SIOCGIWRATE\n");
-       {
-               unsigned char abySupportedRates[13] = {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
-               int brate = 0;
-//2008-5-8 <modify> by chester
-               if (pDevice->bLinkPass) {
-                       if (pDevice->bFixRate == true) {
-                               if (pDevice->uConnectionRate < 13) {
-                                       brate = abySupportedRates[pDevice->uConnectionRate];
-                               } else {
-                                       if (pDevice->byBBType == BB_TYPE_11B)
-                                               brate = 0x16;
-                                       if (pDevice->byBBType == BB_TYPE_11G)
-                                               brate = 0x6C;
-                                       if (pDevice->byBBType == BB_TYPE_11A)
-                                               brate = 0x6C;
-                               }
-                       } else {
-                               brate = abySupportedRates[TxRate_iwconfig];
-                       }
-               } else brate = 0;
-
-               wrq->value = brate * 500000;
-               // If more than one rate, set auto
-               if (pDevice->bFixRate == true)
-                       wrq->fixed = true;
-       }
-
-       return 0;
-}
-
-/*
- * Wireless Handler : set rts threshold
- */
-
-int iwctl_siwrts(struct net_device *dev,
-                struct iw_request_info *info,
-                struct iw_param *wrq,
-                char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       int rc = 0;
-
-       pr_debug(" SIOCSIWRTS\n");
-
-       {
-               int rthr = wrq->value;
-
-               if (wrq->disabled)
-                       rthr = 2312;
-
-               if ((rthr < 0) || (rthr > 2312))
-                       rc = -EINVAL;
-               else
-                       pDevice->wRTSThreshold = rthr;
-       }
-
-       return 0;
-}
-
-/*
- * Wireless Handler : get rts
- */
-
-int iwctl_giwrts(struct net_device *dev,
-                struct iw_request_info *info,
-                struct iw_param *wrq,
-                char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-
-       pr_debug(" SIOCGIWRTS\n");
-       wrq->value = pDevice->wRTSThreshold;
-       wrq->disabled = (wrq->value >= 2312);
-       wrq->fixed = 1;
-
-       return 0;
-}
-
-/*
- * Wireless Handler : set fragment threshold
- */
-
-int iwctl_siwfrag(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_param *wrq,
-                 char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       int rc = 0;
-       int fthr = wrq->value;
-
-       pr_debug(" SIOCSIWFRAG\n");
-
-       if (wrq->disabled)
-               fthr = 2312;
-       if ((fthr < 256) || (fthr > 2312)) {
-               rc = -EINVAL;
-       } else {
-               fthr &= ~0x1;   // Get an even value
-               pDevice->wFragmentationThreshold = (u16)fthr;
-       }
-
-       return rc;
-}
-
-/*
- * Wireless Handler : get fragment threshold
- */
-
-int iwctl_giwfrag(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_param *wrq,
-                 char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-
-       pr_debug(" SIOCGIWFRAG\n");
-       wrq->value = pDevice->wFragmentationThreshold;
-       wrq->disabled = (wrq->value >= 2312);
-       wrq->fixed = 1;
-
-       return 0;
-}
-
-/*
- * Wireless Handler : set retry threshold
- */
-int iwctl_siwretry(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_param *wrq,
-                  char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       int rc = 0;
-
-       pr_debug(" SIOCSIWRETRY\n");
-
-       if (wrq->disabled) {
-               rc = -EINVAL;
-               return rc;
-       }
-
-       if (wrq->flags & IW_RETRY_LIMIT) {
-               if (wrq->flags & IW_RETRY_MAX)
-                       pDevice->byLongRetryLimit = wrq->value;
-               else if (wrq->flags & IW_RETRY_MIN)
-                       pDevice->byShortRetryLimit = wrq->value;
-               else {
-                       // No modifier : set both
-                       pDevice->byShortRetryLimit = wrq->value;
-                       pDevice->byLongRetryLimit = wrq->value;
-               }
-       }
-       if (wrq->flags & IW_RETRY_LIFETIME)
-               pDevice->wMaxTransmitMSDULifetime = wrq->value;
-
-       return rc;
-}
-
-/*
- * Wireless Handler : get retry threshold
- */
-int iwctl_giwretry(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_param *wrq,
-                  char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-
-       pr_debug(" SIOCGIWRETRY\n");
-       wrq->disabled = 0;      // Can't be disabled
-
-       // Note : by default, display the min retry number
-       if ((wrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
-               wrq->flags = IW_RETRY_LIFETIME;
-               wrq->value = (int)pDevice->wMaxTransmitMSDULifetime; //ms
-       } else if ((wrq->flags & IW_RETRY_MAX)) {
-               wrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
-               wrq->value = (int)pDevice->byLongRetryLimit;
-       } else {
-               wrq->flags = IW_RETRY_LIMIT;
-               wrq->value = (int)pDevice->byShortRetryLimit;
-               if ((int)pDevice->byShortRetryLimit != (int)pDevice->byLongRetryLimit)
-                       wrq->flags |= IW_RETRY_MIN;
-       }
-
-       return 0;
-}
-
-/*
- * Wireless Handler : set encode mode
- */
-int iwctl_siwencode(struct net_device *dev,
-                   struct iw_request_info *info,
-                   struct iw_point *wrq,
-                   char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
-       unsigned long dwKeyIndex = (unsigned long)(wrq->flags & IW_ENCODE_INDEX);
-       int ii, uu, rc = 0;
-       int index = (wrq->flags & IW_ENCODE_INDEX);
-
-//2007-0207-07,<Modify> by EinsnLiu
-//There are some problems when using iwconfig encode/key command to set the WEP key.
-//I almost rewrite this function.
-//now it support:(assume the wireless interface's name is eth0)
-//iwconfig eth0 key [1] 1122334455 open  /*set key stirng to index 1,and driver using key index is set to 1*/
-//iwconfig eth0 key [3]    /*set driver using  key index to 3,the key string no change */
-//iwconfig eth0 key 1122334455  /*set key string to driver using index*/
-//iwconfig eth0 key restricted  /*enable share key*/
-
-       PSKeyTable pkeytab;
-
-       pr_debug(" SIOCSIWENCODE\n");
-
-       if ((wrq->flags & IW_ENCODE_DISABLED) == 0) {
-               //Not disable encryption
-
-               if (dwKeyIndex > WLAN_WEP_NKEYS) {
-                       rc = -EINVAL;
-                       return rc;
-               }
-
-               if (dwKeyIndex < 1 && ((wrq->flags & IW_ENCODE_NOKEY) == 0)) {//set default key
-                       if (pDevice->byKeyIndex < WLAN_WEP_NKEYS)
-                               dwKeyIndex = pDevice->byKeyIndex;
-                       else
-                               dwKeyIndex = 0;
-               } else {
-                       dwKeyIndex--;
-               }
-
-               // Check the size of the key
-               if (wrq->length > WLAN_WEP232_KEYLEN) {
-                       rc = -EINVAL;
-                       return rc;
-               }
-
-               if (wrq->length > 0) {//have key
-
-                       if (wrq->length ==  WLAN_WEP232_KEYLEN) {
-                               pr_debug("Set 232 bit wep key\n");
-                       } else if (wrq->length ==  WLAN_WEP104_KEYLEN) {
-                               pr_debug("Set 104 bit wep key\n");
-                       } else if (wrq->length == WLAN_WEP40_KEYLEN) {
-                               pr_debug("Set 40 bit wep key, index= %d\n",
-                                        (int)dwKeyIndex);
-                       } else {//no support length
-                               rc = -EINVAL;
-                               return rc;
-                       }
-                       memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
-                       memcpy(pDevice->abyKey, extra, wrq->length);
-
-                       pr_debug("abyKey: ");
-                       for (ii = 0; ii < wrq->length; ii++)
-                               pr_debug("%02x ", pDevice->abyKey[ii]);
-
-                       if (pDevice->flags & DEVICE_FLAGS_OPENED) {
-                               spin_lock_irq(&pDevice->lock);
-                               KeybSetDefaultKey(&(pDevice->sKey),
-                                                 (unsigned long)(dwKeyIndex | (1 << 31)),
-                                                 wrq->length,
-                                                 NULL,
-                                                 pDevice->abyKey,
-                                                 KEY_CTL_WEP,
-                                                 pDevice->PortOffset,
-                                                 pDevice->byLocalID
-);
-                               spin_unlock_irq(&pDevice->lock);
-                       }
-                       pDevice->byKeyIndex = (unsigned char)dwKeyIndex;
-                       pDevice->uKeyLength = wrq->length;
-                       pDevice->bTransmitKey = true;
-                       pDevice->bEncryptionEnable = true;
-                       pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
-
-               } else if (index > 0) {
-                       //when the length is 0 the request only changes the default transmit key index
-                       //check the new key if it has a non zero length
-                       if (pDevice->bEncryptionEnable == false) {
-                               rc = -EINVAL;
-                               return rc;
-                       }
-                       pr_debug("Just set Default key Index:\n");
-                       pkeytab = &(pDevice->sKey.KeyTable[MAX_KEY_TABLE - 1]);
-                       if (pkeytab->GroupKey[(unsigned char)dwKeyIndex].uKeyLength == 0) {
-                               pr_debug("Default key len is 0\n");
-                               rc = -EINVAL;
-                               return rc;
-                       }
-                       pDevice->byKeyIndex = (unsigned char)dwKeyIndex;
-                       pkeytab->dwGTKeyIndex = dwKeyIndex | (1 << 31);
-                       pkeytab->GroupKey[(unsigned char)dwKeyIndex].dwKeyIndex = dwKeyIndex | (1 << 31);
-               }
-
-       } else {//disable the key
-               pr_debug("Disable WEP function\n");
-               if (pDevice->bEncryptionEnable == false)
-                       return 0;
-               pMgmt->bShareKeyAlgorithm = false;
-               pDevice->bEncryptionEnable = false;
-               pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
-               if (pDevice->flags & DEVICE_FLAGS_OPENED) {
-                       spin_lock_irq(&pDevice->lock);
-                       for (uu = 0; uu < MAX_KEY_TABLE; uu++)
-                               MACvDisableKeyEntry(pDevice->PortOffset, uu);
-                       spin_unlock_irq(&pDevice->lock);
-               }
-       }
-//End Modify,Einsn
-
-       if (wrq->flags & IW_ENCODE_RESTRICTED) {
-               pr_debug("Enable WEP & ShareKey System\n");
-               pMgmt->bShareKeyAlgorithm = true;
-       }
-       if (wrq->flags & IW_ENCODE_OPEN) {
-               pr_debug("Enable WEP & Open System\n");
-               pMgmt->bShareKeyAlgorithm = false;
-       }
-       return rc;
-}
-
-int iwctl_giwencode(struct net_device *dev,
-                   struct iw_request_info *info,
-                   struct iw_point *wrq,
-                   char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject            pMgmt = &(pDevice->sMgmtObj);
-       char abyKey[WLAN_WEP232_KEYLEN];
-
-       unsigned int index = (unsigned int)(wrq->flags & IW_ENCODE_INDEX);
-       PSKeyItem       pKey = NULL;
-
-       pr_debug(" SIOCGIWENCODE\n");
-
-       if (index > WLAN_WEP_NKEYS)
-               return  -EINVAL;
-
-       if (index < 1) {//get default key
-               if (pDevice->byKeyIndex < WLAN_WEP_NKEYS)
-                       index = pDevice->byKeyIndex;
-               else
-                       index = 0;
-       } else {
-               index--;
-       }
-
-       memset(abyKey, 0, WLAN_WEP232_KEYLEN);
-       // Check encryption mode
-       wrq->flags = IW_ENCODE_NOKEY;
-       // Is WEP enabled ???
-       if (pDevice->bEncryptionEnable)
-               wrq->flags |=  IW_ENCODE_ENABLED;
-       else
-               wrq->flags |=  IW_ENCODE_DISABLED;
-
-       if (pMgmt->bShareKeyAlgorithm)
-               wrq->flags |=  IW_ENCODE_RESTRICTED;
-       else
-               wrq->flags |=  IW_ENCODE_OPEN;
-       wrq->length = 0;
-
-       if ((index == 0) && (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled ||
-                            pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)) {//get wpa pairwise  key
-               if (KeybGetKey(&(pDevice->sKey), pMgmt->abyCurrBSSID, 0xffffffff, &pKey)) {
-                       wrq->length = pKey->uKeyLength;
-                       memcpy(abyKey, pKey->abyKey,    pKey->uKeyLength);
-                       memcpy(extra,  abyKey, WLAN_WEP232_KEYLEN);
-               }
-       } else if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (unsigned char)index , &pKey)) {
-               wrq->length = pKey->uKeyLength;
-               memcpy(abyKey, pKey->abyKey,  pKey->uKeyLength);
-               memcpy(extra,  abyKey, WLAN_WEP232_KEYLEN);
-       }
-
-       wrq->flags |= index+1;
-
-       return 0;
-}
-
-/*
- * Wireless Handler : set power mode
- */
-int iwctl_siwpower(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_param *wrq,
-                  char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
-       int rc = 0;
-
-       pr_debug(" SIOCSIWPOWER\n");
-
-       if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
-               rc = -EINVAL;
-               return rc;
-       }
-
-       if (wrq->disabled) {
-               pDevice->ePSMode = WMAC_POWER_CAM;
-               PSvDisablePowerSaving(pDevice);
-               return rc;
-       }
-       if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
-               pDevice->ePSMode = WMAC_POWER_FAST;
-               PSvEnablePowerSaving((void *)pDevice, pMgmt->wListenInterval);
-
-       } else if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
-               pDevice->ePSMode = WMAC_POWER_FAST;
-               PSvEnablePowerSaving((void *)pDevice, pMgmt->wListenInterval);
-       }
-       switch (wrq->flags & IW_POWER_MODE) {
-       case IW_POWER_UNICAST_R:
-               pr_debug(" SIOCSIWPOWER: IW_POWER_UNICAST_R\n");
-               rc = -EINVAL;
-               break;
-       case IW_POWER_ALL_R:
-               pr_debug(" SIOCSIWPOWER: IW_POWER_ALL_R\n");
-               rc = -EINVAL;
-       case IW_POWER_ON:
-               pr_debug(" SIOCSIWPOWER: IW_POWER_ON\n");
-               break;
-       default:
-               rc = -EINVAL;
-       }
-
-       return rc;
-}
-
-/*
- * Wireless Handler : get power mode
- */
-int iwctl_giwpower(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_param *wrq,
-                  char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
-       int mode = pDevice->ePSMode;
-
-       pr_debug(" SIOCGIWPOWER\n");
-
-       wrq->disabled = (mode == WMAC_POWER_CAM);
-       if (wrq->disabled)
-               return 0;
-
-       if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
-               wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);
-               wrq->flags = IW_POWER_TIMEOUT;
-       } else {
-               wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);
-               wrq->flags = IW_POWER_PERIOD;
-       }
-       wrq->flags |= IW_POWER_ALL_R;
-
-       return 0;
-}
-
-/*
- * Wireless Handler : get Sensitivity
- */
-int iwctl_giwsens(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_param *wrq,
-                 char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       long ldBm;
-
-       pr_debug(" SIOCGIWSENS\n");
-       if (pDevice->bLinkPass == true) {
-               RFvRSSITodBm(pDevice, (unsigned char)(pDevice->uCurrRSSI), &ldBm);
-               wrq->value = ldBm;
-       } else {
-               wrq->value = 0;
-       }
-       wrq->disabled = (wrq->value == 0);
-       wrq->fixed = 1;
-
-       return 0;
-}
-
-//2008-0409-07, <Add> by Einsn Liu
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-
-int iwctl_siwauth(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_param *wrq,
-                 char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-       int ret = 0;
-       static int wpa_version = 0;  //must be static to save the last value,einsn liu
-       static int pairwise = 0;
-
-       pr_debug(" SIOCSIWAUTH\n");
-       switch (wrq->flags & IW_AUTH_INDEX) {
-       case IW_AUTH_WPA_VERSION:
-               wpa_version = wrq->value;
-               if (wrq->value == IW_AUTH_WPA_VERSION_DISABLED)
-                       PRINT_K("iwctl_siwauth:set WPADEV to disable at 1??????\n");
-               else if (wrq->value == IW_AUTH_WPA_VERSION_WPA)
-                       PRINT_K("iwctl_siwauth:set WPADEV to WPA1******\n");
-               else
-                       PRINT_K("iwctl_siwauth:set WPADEV to WPA2******\n");
-
-               break;
-       case IW_AUTH_CIPHER_PAIRWISE:
-               pairwise = wrq->value;
-               if (pairwise == IW_AUTH_CIPHER_CCMP)
-                       pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
-               else if (pairwise == IW_AUTH_CIPHER_TKIP)
-                       pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
-               else if (pairwise == IW_AUTH_CIPHER_WEP40 || pairwise == IW_AUTH_CIPHER_WEP104)
-                       pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
-               else if (pairwise == IW_AUTH_CIPHER_NONE)
-                       ; /* do nothing,einsn liu */
-               else
-                       pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
-
-               break;
-       case IW_AUTH_CIPHER_GROUP:
-               if (wpa_version == IW_AUTH_WPA_VERSION_DISABLED)
-                       break;
-               if (pairwise == IW_AUTH_CIPHER_NONE) {
-                       if (wrq->value == IW_AUTH_CIPHER_CCMP)
-                               pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
-                       else
-                               pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
-               }
-               break;
-       case IW_AUTH_KEY_MGMT:
-
-               if (wpa_version == IW_AUTH_WPA_VERSION_WPA2) {
-                       if (wrq->value == IW_AUTH_KEY_MGMT_PSK)
-                               pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK;
-                       else
-                               pMgmt->eAuthenMode = WMAC_AUTH_WPA2;
-               } else if (wpa_version == IW_AUTH_WPA_VERSION_WPA) {
-                       if (wrq->value == 0)
-                               pMgmt->eAuthenMode = WMAC_AUTH_WPANONE;
-                       else if (wrq->value == IW_AUTH_KEY_MGMT_PSK)
-                               pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK;
-                       else
-                               pMgmt->eAuthenMode = WMAC_AUTH_WPA;
-               }
-
-               break;
-       case IW_AUTH_TKIP_COUNTERMEASURES:
-               break;          /* FIXME */
-       case IW_AUTH_DROP_UNENCRYPTED:
-               break;
-       case IW_AUTH_80211_AUTH_ALG:
-               if (wrq->value == IW_AUTH_ALG_OPEN_SYSTEM)
-                       pMgmt->bShareKeyAlgorithm = false;
-               else if (wrq->value == IW_AUTH_ALG_SHARED_KEY)
-                       pMgmt->bShareKeyAlgorithm = true;
-
-               break;
-       case IW_AUTH_WPA_ENABLED:
-               break;
-       case IW_AUTH_RX_UNENCRYPTED_EAPOL:
-               break;
-       case IW_AUTH_ROAMING_CONTROL:
-               ret = -EOPNOTSUPP;
-               break;
-       case IW_AUTH_PRIVACY_INVOKED:
-               pDevice->bEncryptionEnable = !!wrq->value;
-               if (pDevice->bEncryptionEnable == false) {
-                       wpa_version = 0;
-                       pairwise = 0;
-                       pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
-                       pMgmt->bShareKeyAlgorithm = false;
-                       pMgmt->eAuthenMode = false;
-               }
-
-               break;
-       default:
-               ret = -EOPNOTSUPP;
-               break;
-       }
-
-       return ret;
-}
-
-int iwctl_giwauth(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_param *wrq,
-                 char *extra)
-{
-       return -EOPNOTSUPP;
-}
-
-int iwctl_siwgenie(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_point *wrq,
-                  char __user *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-       int ret = 0;
-       char length;
-
-       if (wrq->length) {
-               if (wrq->length < 2)
-                       return -EINVAL;
-
-               ret = get_user(length, extra + 1);
-               if (ret)
-                       return ret;
-
-               if (length + 2 != wrq->length)
-                       return -EINVAL;
-
-               if (wrq->length > MAX_WPA_IE_LEN) {
-                       ret = -ENOMEM;
-                       goto out;
-               }
-               memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
-               if (copy_from_user(pMgmt->abyWPAIE, extra, wrq->length)) {
-                       ret = -EFAULT;
-                       goto out;
-               }
-               pMgmt->wWPAIELen = wrq->length;
-       } else {
-               memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
-               pMgmt->wWPAIELen = 0;
-       }
-
-out://not completely ...not necessary in wpa_supplicant 0.5.8
-       return ret;
-}
-
-int iwctl_giwgenie(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_point *wrq,
-                  char __user *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-       int ret = 0;
-       int space = wrq->length;
-
-       wrq->length = 0;
-       if (pMgmt->wWPAIELen > 0) {
-               wrq->length = pMgmt->wWPAIELen;
-               if (pMgmt->wWPAIELen <= space) {
-                       if (copy_to_user(extra, pMgmt->abyWPAIE, pMgmt->wWPAIELen))
-                               ret = -EFAULT;
-
-               } else {
-                       ret = -E2BIG;
-               }
-       }
-
-       return ret;
-}
-
-int iwctl_siwencodeext(struct net_device *dev,
-                      struct iw_request_info *info,
-                      struct iw_point *wrq,
-                      char *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
-       struct viawget_wpa_param *param = NULL;
-//original member
-       enum wpa_alg alg_name;
-       u8  addr[6];
-       int key_idx, set_tx = 0;
-       u8  seq[IW_ENCODE_SEQ_MAX_SIZE];
-       u8 key[64];
-       size_t seq_len = 0, key_len = 0;
-
-       u8 key_array[64];
-       int ret = 0;
-
-       PRINT_K("SIOCSIWENCODEEXT......\n");
-
-       param = kzalloc(sizeof(*param), GFP_KERNEL);
-       if (param == NULL)
-               return -ENOMEM;
-
-//recover alg_name
-       switch (ext->alg) {
-       case IW_ENCODE_ALG_NONE:
-               alg_name = WPA_ALG_NONE;
-               break;
-       case IW_ENCODE_ALG_WEP:
-               alg_name = WPA_ALG_WEP;
-               break;
-       case IW_ENCODE_ALG_TKIP:
-               alg_name = WPA_ALG_TKIP;
-               break;
-       case IW_ENCODE_ALG_CCMP:
-               alg_name = WPA_ALG_CCMP;
-               break;
-       default:
-               PRINT_K("Unknown alg = %d\n", ext->alg);
-               ret = -ENOMEM;
-               goto error;
-       }
-//recover addr
-       memcpy(addr, ext->addr.sa_data, ETH_ALEN);
-//recover key_idx
-       key_idx = (wrq->flags&IW_ENCODE_INDEX) - 1;
-//recover set_tx
-       if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
-               set_tx = 1;
-//recover seq,seq_len
-       if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
-               seq_len = IW_ENCODE_SEQ_MAX_SIZE;
-               memcpy(seq, ext->rx_seq, seq_len);
-       }
-//recover key,key_len
-       if (ext->key_len) {
-               key_len = ext->key_len;
-               memcpy(key, &ext->key[0], key_len);
-       }
-
-       memset(key_array, 0, 64);
-       if (key_len > 0) {
-               memcpy(key_array, key, key_len);
-               if (key_len == 32) {
-                       // notice ! the oder
-                       memcpy(&key_array[16], &key[24], 8);
-                       memcpy(&key_array[24], &key[16], 8);
-               }
-       }
-
-/**************Translate iw_encode_ext to viawget_wpa_param****************/
-       memcpy(param->addr, addr, ETH_ALEN);
-       param->u.wpa_key.alg_name = (int)alg_name;
-       param->u.wpa_key.set_tx = set_tx;
-       param->u.wpa_key.key_index = key_idx;
-       param->u.wpa_key.key_len = key_len;
-       param->u.wpa_key.key = (u8 *)key_array;
-       param->u.wpa_key.seq = (u8 *)seq;
-       param->u.wpa_key.seq_len = seq_len;
-
-//****set if current action is Network Manager count??
-//****this method is so foolish,but there is no other way???
-       if (param->u.wpa_key.alg_name == WPA_ALG_NONE) {
-               if (param->u.wpa_key.key_index == 0)
-                       pDevice->bwextcount++;
-
-               if ((pDevice->bwextcount == 1) && (param->u.wpa_key.key_index == 1))
-                       pDevice->bwextcount++;
-
-               if ((pDevice->bwextcount == 2) && (param->u.wpa_key.key_index == 2))
-                       pDevice->bwextcount++;
-
-               if ((pDevice->bwextcount == 3) && (param->u.wpa_key.key_index == 3))
-                       pDevice->bwextcount++;
-
-       }
-       if (pDevice->bwextcount == 4) {
-               pr_debug("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n");
-               pDevice->bwextcount = 0;
-               pDevice->bWPASuppWextEnabled = true;
-       }
-//******
-
-       spin_lock_irq(&pDevice->lock);
-       ret = wpa_set_keys(pDevice, param, true);
-       spin_unlock_irq(&pDevice->lock);
-
-error:
-       kfree(param);
-       return ret;
-}
-
-int iwctl_giwencodeext(struct net_device *dev,
-                      struct iw_request_info *info,
-                      struct iw_point *wrq,
-                      char *extra)
-{
-       return -EOPNOTSUPP;
-}
-
-int iwctl_siwmlme(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_point *wrq,
-                 char __user *extra)
-{
-       struct vnt_private *pDevice = netdev_priv(dev);
-       PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-       struct iw_mlme mime;
-
-       int ret = 0;
-
-       ret = copy_from_user(&mime, extra, sizeof(mime));
-       if (ret)
-               return -EFAULT;
-
-       if (memcmp(pMgmt->abyCurrBSSID, mime.addr.sa_data, ETH_ALEN)) {
-               ret = -EINVAL;
-               return ret;
-       }
-       switch (mime.cmd) {
-       case IW_MLME_DEAUTH:
-               //this command seems to be not complete,please test it --einsnliu
-               //bScheduleCommand((void *) pDevice, WLAN_CMD_DEAUTH, (unsigned char *)&reason);
-               break;
-       case IW_MLME_DISASSOC:
-               if (pDevice->bLinkPass == true) {
-                       pr_debug("iwctl_siwmlme--->send DISASSOCIATE\n");
-                       //clear related flags
-                       memset(pMgmt->abyDesireBSSID, 0xFF, 6);
-                       KeyvInitTable(&pDevice->sKey, pDevice->PortOffset);
-                       bScheduleCommand((void *)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
-               }
-               break;
-       default:
-               ret = -EOPNOTSUPP;
-       }
-
-       return ret;
-}
-
-#endif
-
-/*------------------------------------------------------------------*/
-/*
- * Structures to export the Wireless Handlers
- */
-
-static const iw_handler                iwctl_handler[] =
-{
-       (iw_handler) iwctl_commit,      // SIOCSIWCOMMIT
-       (iw_handler) NULL,              // SIOCGIWNAME
-       (iw_handler) NULL,              // SIOCSIWNWID
-       (iw_handler) NULL,              // SIOCGIWNWID
-       (iw_handler) NULL,              // SIOCSIWFREQ
-       (iw_handler) NULL,              // SIOCGIWFREQ
-       (iw_handler) NULL,              // SIOCSIWMODE
-       (iw_handler) NULL,              // SIOCGIWMODE
-       (iw_handler) NULL,              // SIOCSIWSENS
-       (iw_handler) NULL,              // SIOCGIWSENS
-       (iw_handler) NULL,              // SIOCSIWRANGE
-       (iw_handler) iwctl_giwrange,    // SIOCGIWRANGE
-       (iw_handler) NULL,              // SIOCSIWPRIV
-       (iw_handler) NULL,              // SIOCGIWPRIV
-       (iw_handler) NULL,              // SIOCSIWSTATS
-       (iw_handler) NULL,              // SIOCGIWSTATS
-       (iw_handler) NULL,              // SIOCSIWSPY
-       (iw_handler) NULL,              // SIOCGIWSPY
-       (iw_handler) NULL,              // -- hole --
-       (iw_handler) NULL,              // -- hole --
-       (iw_handler) NULL,              // SIOCSIWAP
-       (iw_handler) NULL,              // SIOCGIWAP
-       (iw_handler) NULL,              // -- hole -- 0x16
-       (iw_handler) NULL,              // SIOCGIWAPLIST
-       (iw_handler) iwctl_siwscan,     // SIOCSIWSCAN
-       (iw_handler) iwctl_giwscan,     // SIOCGIWSCAN
-       (iw_handler) NULL,              // SIOCSIWESSID
-       (iw_handler) NULL,              // SIOCGIWESSID
-       (iw_handler) NULL,              // SIOCSIWNICKN
-       (iw_handler) NULL,              // SIOCGIWNICKN
-       (iw_handler) NULL,              // -- hole --
-       (iw_handler) NULL,              // -- hole --
-       (iw_handler) NULL,              // SIOCSIWRATE 0x20
-       (iw_handler) NULL,              // SIOCGIWRATE
-       (iw_handler) NULL,              // SIOCSIWRTS
-       (iw_handler) NULL,              // SIOCGIWRTS
-       (iw_handler) NULL,              // SIOCSIWFRAG
-       (iw_handler) NULL,              // SIOCGIWFRAG
-       (iw_handler) NULL,              // SIOCSIWTXPOW
-       (iw_handler) NULL,              // SIOCGIWTXPOW
-       (iw_handler) NULL,              // SIOCSIWRETRY
-       (iw_handler) NULL,              // SIOCGIWRETRY
-       (iw_handler) NULL,              // SIOCSIWENCODE
-       (iw_handler) NULL,              // SIOCGIWENCODE
-       (iw_handler) NULL,              // SIOCSIWPOWER
-       (iw_handler) NULL,              // SIOCGIWPOWER
-
-//2008-0409-07, <Add> by Einsn Liu
-       (iw_handler) NULL,              // -- hole --
-       (iw_handler) NULL,              // -- hole --
-       (iw_handler) NULL,              // SIOCSIWGENIE
-       (iw_handler) NULL,              // SIOCGIWGENIE
-       (iw_handler) NULL,              // SIOCSIWAUTH
-       (iw_handler) NULL,              // SIOCGIWAUTH
-       (iw_handler) NULL,              // SIOCSIWENCODEEXT
-       (iw_handler) NULL,              // SIOCGIWENCODEEXT
-       (iw_handler) NULL,              // SIOCSIWPMKSA
-       (iw_handler) NULL,              // -- hole --
-};
-
-static const iw_handler                iwctl_private_handler[] =
-{
-       NULL,                           // SIOCIWFIRSTPRIV
-};
-
-struct iw_priv_args iwctl_private_args[] = {
-       { IOCTL_CMD_SET,
-         IW_PRIV_TYPE_CHAR | 1024, 0,
-         "set"},
-};
-
-const struct iw_handler_def    iwctl_handler_def =
-{
-       .get_wireless_stats = &iwctl_get_wireless_stats,
-       .num_standard   = sizeof(iwctl_handler)/sizeof(iw_handler),
-       .num_private    = 0,
-       .num_private_args = 0,
-       .standard       = (iw_handler *)iwctl_handler,
-       .private        = NULL,
-       .private_args   = NULL,
-};
diff --git a/drivers/staging/vt6655/iwctl.h b/drivers/staging/vt6655/iwctl.h
deleted file mode 100644 (file)
index 7dd6310..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: iwctl.h
- *
- * Purpose:
- *
- * Author: Lyndon Chen
- *
- * Date: May 21, 2004
- *
- */
-
-#ifndef __IWCTL_H__
-#define __IWCTL_H__
-
-#include "device.h"
-
-/*---------------------  Export Definitions -------------------------*/
-
-/*---------------------  Export Classes  ----------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev);
-
-int iwctl_siwap(struct net_device *dev,
-               struct iw_request_info *info,
-               struct sockaddr *wrq,
-               char *extra);
-
-int iwctl_giwrange(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_point *wrq,
-                  char *extra);
-
-int iwctl_giwmode(struct net_device *dev,
-                 struct iw_request_info *info,
-                 __u32 *wmode,
-                 char *extra);
-
-int iwctl_siwmode(struct net_device *dev,
-                 struct iw_request_info *info,
-                 __u32 *wmode,
-                 char *extra);
-
-int iwctl_giwfreq(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_freq *wrq,
-                 char *extra);
-
-int iwctl_siwfreq(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_freq *wrq,
-                 char *extra);
-
-int iwctl_giwname(struct net_device *dev,
-                 struct iw_request_info *info,
-                 char *wrq,
-                 char *extra);
-
-int iwctl_giwsens(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_param *wrq,
-                 char *extra);
-
-int iwctl_giwap(struct net_device *dev,
-               struct iw_request_info *info,
-               struct sockaddr *wrq,
-               char *extra);
-
-int iwctl_giwaplist(struct net_device *dev,
-                   struct iw_request_info *info,
-                   struct iw_point *wrq,
-                   char *extra);
-
-int iwctl_siwessid(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_point *wrq,
-                  char *extra);
-
-int iwctl_giwessid(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_point *wrq,
-                  char *extra);
-
-int iwctl_siwrate(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_param *wrq,
-                 char *extra);
-
-int iwctl_giwrate(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_param *wrq,
-                 char *extra);
-
-int iwctl_siwrts(struct net_device *dev,
-                struct iw_request_info *info,
-                struct iw_param *wrq,
-                char *extra);
-
-int iwctl_giwrts(struct net_device *dev,
-                struct iw_request_info *info,
-                struct iw_param *wrq,
-                char *extra);
-
-int iwctl_siwfrag(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_param *wrq,
-                 char *extra);
-
-int iwctl_giwfrag(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_param *wrq,
-                 char *extra);
-
-int iwctl_siwretry(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_param *wrq,
-                  char *extra);
-
-int iwctl_giwretry(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_param *wrq,
-                  char *extra);
-
-int iwctl_siwencode(struct net_device *dev,
-                   struct iw_request_info *info,
-                   struct iw_point *wrq,
-                   char *extra);
-
-int iwctl_giwencode(struct net_device *dev,
-                   struct iw_request_info *info,
-                   struct iw_point *wrq,
-                   char *extra);
-
-int iwctl_siwpower(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_param *wrq,
-                  char *extra);
-
-int iwctl_giwpower(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_param *wrq,
-                  char *extra);
-
-//2008-0409-07, <Add> by Einsn Liu
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-int iwctl_siwauth(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_param *wrq,
-                 char *extra);
-
-int iwctl_giwauth(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_param *wrq,
-                 char *extra);
-
-int iwctl_siwgenie(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_point *wrq,
-                  char __user *extra);
-
-int iwctl_giwgenie(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_point *wrq,
-                  char __user *extra);
-
-int iwctl_siwencodeext(struct net_device *dev,
-                      struct iw_request_info *info,
-                      struct iw_point *wrq,
-                      char *extra);
-
-int iwctl_giwencodeext(struct net_device *dev,
-                      struct iw_request_info *info,
-                      struct iw_point *wrq,
-                      char *extra);
-
-int iwctl_siwmlme(struct net_device *dev,
-                 struct iw_request_info *info,
-                 struct iw_point *wrq,
-                 char __user *extra);
-#endif // #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-//End Add -- //2008-0409-07, <Add> by Einsn Liu
-
-extern const struct iw_handler_def     iwctl_handler_def;
-extern struct iw_priv_args       iwctl_private_args[];
-
-#endif // __IWCTL_H__
index 211afae..f2b3fea 100644 (file)
  *
  * Date: May 29, 2003
  *
- * Functions:
- *      KeyvInitTable - Init Key management table
- *      KeybGetKey - Get Key from table
- *      KeybSetKey - Set Key to table
- *      KeybRemoveKey - Remove Key from table
- *      KeybGetTransmitKey - Get Transmit Key from table
- *
- * Revision History:
- *
  */
 
 #include "tmacro.h"
 #include "key.h"
 #include "mac.h"
 
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Functions  --------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Variables  --------------------------*/
-
-/*---------------------  Static Functions  --------------------------*/
-static void
-s_vCheckKeyTableValid(PSKeyManagement pTable, void __iomem *dwIoBase)
-{
-       int i;
-
-       for (i = 0; i < MAX_KEY_TABLE; i++) {
-               if (pTable->KeyTable[i].bInUse &&
-                   !pTable->KeyTable[i].PairwiseKey.bKeyValid &&
-                   !pTable->KeyTable[i].GroupKey[0].bKeyValid &&
-                   !pTable->KeyTable[i].GroupKey[1].bKeyValid &&
-                   !pTable->KeyTable[i].GroupKey[2].bKeyValid &&
-                   !pTable->KeyTable[i].GroupKey[3].bKeyValid) {
-                       pTable->KeyTable[i].bInUse = false;
-                       pTable->KeyTable[i].wKeyCtl = 0;
-                       pTable->KeyTable[i].bSoftWEP = false;
-                       MACvDisableKeyEntry(dwIoBase, i);
-               }
-       }
-}
-
-/*---------------------  Export Functions  --------------------------*/
-
-/*
- * Description: Init Key management table
- *
- * Parameters:
- *  In:
- *      pTable          - Pointer to Key table
- *  Out:
- *      none
- *
- * Return Value: none
- *
- */
-void KeyvInitTable(PSKeyManagement pTable, void __iomem *dwIoBase)
-{
-       int i;
-       int jj;
-
-       for (i = 0; i < MAX_KEY_TABLE; i++) {
-               pTable->KeyTable[i].bInUse = false;
-               pTable->KeyTable[i].PairwiseKey.bKeyValid = false;
-               pTable->KeyTable[i].PairwiseKey.pvKeyTable = (void *)&pTable->KeyTable[i];
-               for (jj = 0; jj < MAX_GROUP_KEY; jj++) {
-                       pTable->KeyTable[i].GroupKey[jj].bKeyValid = false;
-                       pTable->KeyTable[i].GroupKey[jj].pvKeyTable = (void *)&pTable->KeyTable[i];
-               }
-               pTable->KeyTable[i].wKeyCtl = 0;
-               pTable->KeyTable[i].dwGTKeyIndex = 0;
-               pTable->KeyTable[i].bSoftWEP = false;
-               MACvDisableKeyEntry(dwIoBase, i);
-       }
-}
-
-/*
- * Description: Get Key from table
- *
- * Parameters:
- *  In:
- *      pTable          - Pointer to Key table
- *      pbyBSSID        - BSSID of Key
- *      dwKeyIndex      - Key Index (0xFFFFFFFF means pairwise key)
- *  Out:
- *      pKey            - Key return
- *
- * Return Value: true if found otherwise false
- *
- */
-bool KeybGetKey(
-       PSKeyManagement pTable,
-       unsigned char *pbyBSSID,
-       unsigned long dwKeyIndex,
-       PSKeyItem       *pKey
-)
-{
-       int i;
-
-       pr_debug("KeybGetKey()\n");
-
-       *pKey = NULL;
-       for (i = 0; i < MAX_KEY_TABLE; i++) {
-               if (pTable->KeyTable[i].bInUse &&
-                   ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) {
-                       if (dwKeyIndex == 0xFFFFFFFF) {
-                               if (pTable->KeyTable[i].PairwiseKey.bKeyValid) {
-                                       *pKey = &(pTable->KeyTable[i].PairwiseKey);
-                                       return true;
-                               } else {
-                                       return false;
-                               }
-                       } else if (dwKeyIndex < MAX_GROUP_KEY) {
-                               if (pTable->KeyTable[i].GroupKey[dwKeyIndex].bKeyValid) {
-                                       *pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex]);
-                                       return true;
-                               } else {
-                                       return false;
-                               }
-                       } else {
-                               return false;
-                       }
-               }
-       }
-       return false;
-}
-
-/*
- * Description: Set Key to table
- *
- * Parameters:
- *  In:
- *      pTable          - Pointer to Key table
- *      pbyBSSID        - BSSID of Key
- *      dwKeyIndex      - Key index (reference to NDIS DDK)
- *      uKeyLength      - Key length
- *      KeyRSC          - Key RSC
- *      pbyKey          - Pointer to key
- *  Out:
- *      none
- *
- * Return Value: true if success otherwise false
- *
- */
-bool KeybSetKey(
-       PSKeyManagement pTable,
-       unsigned char *pbyBSSID,
-       unsigned long dwKeyIndex,
-       unsigned long uKeyLength,
-       u64 *pKeyRSC,
-       unsigned char *pbyKey,
-       unsigned char byKeyDecMode,
-       void __iomem *dwIoBase,
-       unsigned char byLocalID
-)
-{
-       int i, j;
-       unsigned int ii;
-       PSKeyItem   pKey;
-       unsigned int uKeyIdx;
-
-       pr_debug("Enter KeybSetKey: %lX\n", dwKeyIndex);
-
-       j = (MAX_KEY_TABLE-1);
-       for (i = 0; i < (MAX_KEY_TABLE - 1); i++) {
-               if (!pTable->KeyTable[i].bInUse && (j == (MAX_KEY_TABLE-1))) {
-                       // found empty table
-                       j = i;
-               }
-               if (pTable->KeyTable[i].bInUse &&
-                   ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) {
-                       // found table already exist
-                       if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
-                               // Pairwise key
-                               pKey = &(pTable->KeyTable[i].PairwiseKey);
-                               pTable->KeyTable[i].wKeyCtl &= 0xFFF0;          // clear pairwise key control filed
-                               pTable->KeyTable[i].wKeyCtl |= byKeyDecMode;
-                               uKeyIdx = 4;                                    // use HW key entry 4 for pairwise key
-                       } else {
-                               // Group key
-                               if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY)
-                                       return false;
-                               pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]);
-                               if ((dwKeyIndex & TRANSMIT_KEY) != 0)  {
-                                       // Group transmit key
-                                       pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex;
-                                       pr_debug("Group transmit key(R)[%lX]: %d\n",
-                                                pTable->KeyTable[i].dwGTKeyIndex, i);
-                               }
-                               pTable->KeyTable[i].wKeyCtl &= 0xFF0F;          // clear group key control filed
-                               pTable->KeyTable[i].wKeyCtl |= (byKeyDecMode << 4);
-                               pTable->KeyTable[i].wKeyCtl |= 0x0040;          // use group key for group address
-                               uKeyIdx = (dwKeyIndex & 0x000000FF);
-                       }
-                       pTable->KeyTable[i].wKeyCtl |= 0x8000;              // enable on-fly
-
-                       pKey->bKeyValid = true;
-                       pKey->uKeyLength = uKeyLength;
-                       pKey->dwKeyIndex = dwKeyIndex;
-                       pKey->byCipherSuite = byKeyDecMode;
-                       memcpy(pKey->abyKey, pbyKey, uKeyLength);
-                       if (byKeyDecMode == KEY_CTL_WEP) {
-                               if (uKeyLength == WLAN_WEP40_KEYLEN)
-                                       pKey->abyKey[15] &= 0x7F;
-                               if (uKeyLength == WLAN_WEP104_KEYLEN)
-                                       pKey->abyKey[15] |= 0x80;
-                       }
-                       MACvSetKeyEntry(dwIoBase, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pbyBSSID, (u32 *)pKey->abyKey, byLocalID);
-
-                       if ((dwKeyIndex & USE_KEYRSC) == 0) {
-                               // RSC set by NIC
-                               pKey->KeyRSC = 0;
-                       } else {
-                               pKey->KeyRSC = *pKeyRSC;
-                       }
-                       pKey->dwTSC47_16 = 0;
-                       pKey->wTSC15_0 = 0;
-
-                       pr_debug("KeybSetKey(R):\n");
-                       pr_debug("pKey->bKeyValid: %d\n ", pKey->bKeyValid);
-                       pr_debug("pKey->abyKey: ");
-                       for (ii = 0; ii < pKey->uKeyLength; ii++)
-                               pr_debug("%02x ", pKey->abyKey[ii]);
-
-                       pr_debug("\n");
-
-                       pr_debug("pKey->dwTSC47_16: %lx\n ", pKey->dwTSC47_16);
-                       pr_debug("pKey->wTSC15_0: %x\n ", pKey->wTSC15_0);
-                       pr_debug("pKey->dwKeyIndex: %lx\n ", pKey->dwKeyIndex);
-
-                       return true;
-               }
-       }
-       if (j < (MAX_KEY_TABLE-1)) {
-               memcpy(pTable->KeyTable[j].abyBSSID, pbyBSSID, ETH_ALEN);
-               pTable->KeyTable[j].bInUse = true;
-               if ((dwKeyIndex & PAIRWISE_KEY) != 0)  {
-                       // Pairwise key
-                       pKey = &(pTable->KeyTable[j].PairwiseKey);
-                       pTable->KeyTable[j].wKeyCtl &= 0xFFF0;          // clear pairwise key control filed
-                       pTable->KeyTable[j].wKeyCtl |= byKeyDecMode;
-                       uKeyIdx = 4;                                    // use HW key entry 4 for pairwise key
-               } else {
-                       // Group key
-                       if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY)
-                               return false;
-                       pKey = &(pTable->KeyTable[j].GroupKey[dwKeyIndex & 0x000000FF]);
-                       if ((dwKeyIndex & TRANSMIT_KEY) != 0)  {
-                               // Group transmit key
-                               pTable->KeyTable[j].dwGTKeyIndex = dwKeyIndex;
-                               pr_debug("Group transmit key(N)[%lX]: %d\n",
-                                        pTable->KeyTable[j].dwGTKeyIndex, j);
-                       }
-                       pTable->KeyTable[j].wKeyCtl &= 0xFF0F;          // clear group key control filed
-                       pTable->KeyTable[j].wKeyCtl |= (byKeyDecMode << 4);
-                       pTable->KeyTable[j].wKeyCtl |= 0x0040;          // use group key for group address
-                       uKeyIdx = (dwKeyIndex & 0x000000FF);
-               }
-               pTable->KeyTable[j].wKeyCtl |= 0x8000;              // enable on-fly
-
-               pKey->bKeyValid = true;
-               pKey->uKeyLength = uKeyLength;
-               pKey->dwKeyIndex = dwKeyIndex;
-               pKey->byCipherSuite = byKeyDecMode;
-               memcpy(pKey->abyKey, pbyKey, uKeyLength);
-               if (byKeyDecMode == KEY_CTL_WEP) {
-                       if (uKeyLength == WLAN_WEP40_KEYLEN)
-                               pKey->abyKey[15] &= 0x7F;
-                       if (uKeyLength == WLAN_WEP104_KEYLEN)
-                               pKey->abyKey[15] |= 0x80;
-               }
-               MACvSetKeyEntry(dwIoBase, pTable->KeyTable[j].wKeyCtl, j, uKeyIdx, pbyBSSID, (u32 *)pKey->abyKey, byLocalID);
-
-               if ((dwKeyIndex & USE_KEYRSC) == 0) {
-                       // RSC set by NIC
-                       pKey->KeyRSC = 0;
-               } else {
-                       pKey->KeyRSC = *pKeyRSC;
-               }
-               pKey->dwTSC47_16 = 0;
-               pKey->wTSC15_0 = 0;
-
-               pr_debug("KeybSetKey(N):\n");
-               pr_debug("pKey->bKeyValid: %d\n ", pKey->bKeyValid);
-               pr_debug("pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength);
-               pr_debug("pKey->abyKey: ");
-               for (ii = 0; ii < pKey->uKeyLength; ii++)
-                       pr_debug("%02x ", pKey->abyKey[ii]);
-
-               pr_debug("\n");
-
-               pr_debug("pKey->dwTSC47_16: %lx\n ", pKey->dwTSC47_16);
-               pr_debug("pKey->wTSC15_0: %x\n ", pKey->wTSC15_0);
-               pr_debug("pKey->dwKeyIndex: %lx\n ", pKey->dwKeyIndex);
-
-               return true;
-       }
-       return false;
-}
-
-/*
- * Description: Remove Key from table
- *
- * Parameters:
- *  In:
- *      pTable          - Pointer to Key table
- *      pbyBSSID        - BSSID of Key
- *      dwKeyIndex      - Key Index (reference to NDIS DDK)
- *  Out:
- *      none
- *
- * Return Value: true if success otherwise false
- *
- */
-bool KeybRemoveKey(
-       PSKeyManagement pTable,
-       unsigned char *pbyBSSID,
-       unsigned long dwKeyIndex,
-       void __iomem *dwIoBase
-)
-{
-       int  i;
-
-       if (is_broadcast_ether_addr(pbyBSSID)) {
-               // delete all keys
-               if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
-                       for (i = 0; i < MAX_KEY_TABLE; i++)
-                               pTable->KeyTable[i].PairwiseKey.bKeyValid = false;
-
-                       s_vCheckKeyTableValid(pTable, dwIoBase);
-                       return true;
-               } else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) {
-                       for (i = 0; i < MAX_KEY_TABLE; i++) {
-                               pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false;
-                               if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[i].dwGTKeyIndex & 0x7FFFFFFF)) {
-                                       // remove Group transmit key
-                                       pTable->KeyTable[i].dwGTKeyIndex = 0;
-                               }
-                       }
-                       s_vCheckKeyTableValid(pTable, dwIoBase);
-                       return true;
-               } else {
-                       return false;
-               }
-       }
-
-       for (i = 0; i < MAX_KEY_TABLE; i++) {
-               if (pTable->KeyTable[i].bInUse &&
-                   ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) {
-                       if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
-                               pTable->KeyTable[i].PairwiseKey.bKeyValid = false;
-                               s_vCheckKeyTableValid(pTable, dwIoBase);
-                               return true;
-                       } else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) {
-                               pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false;
-                               if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[i].dwGTKeyIndex & 0x7FFFFFFF)) {
-                                       // remove Group transmit key
-                                       pTable->KeyTable[i].dwGTKeyIndex = 0;
-                               }
-                               s_vCheckKeyTableValid(pTable, dwIoBase);
-                               return true;
-                       } else {
-                               return false;
-                       }
-               }
-       }
-       return false;
-}
-
-/*
- * Description: Remove Key from table
- *
- * Parameters:
- *  In:
- *      pTable          - Pointer to Key table
- *      pbyBSSID        - BSSID of Key
- *  Out:
- *      none
- *
- * Return Value: true if success otherwise false
- *
- */
-bool KeybRemoveAllKey(
-       PSKeyManagement pTable,
-       unsigned char *pbyBSSID,
-       void __iomem *dwIoBase
-)
+int vnt_key_init_table(struct vnt_private *priv)
 {
-       int i, u;
+       u32 i;
 
-       for (i = 0; i < MAX_KEY_TABLE; i++) {
-               if (pTable->KeyTable[i].bInUse &&
-                   ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) {
-                       pTable->KeyTable[i].PairwiseKey.bKeyValid = false;
-                       for (u = 0; u < MAX_GROUP_KEY; u++)
-                               pTable->KeyTable[i].GroupKey[u].bKeyValid = false;
+       for (i = 0; i < MAX_KEY_TABLE; i++)
+               MACvDisableKeyEntry(priv->PortOffset, i);
 
-                       pTable->KeyTable[i].dwGTKeyIndex = 0;
-                       s_vCheckKeyTableValid(pTable, dwIoBase);
-                       return true;
-               }
-       }
-       return false;
+       return 0;
 }
 
-/*
- * Description: Remove WEP Key from table
- *
- * Parameters:
- *  In:
- *      pTable          - Pointer to Key table
- *  Out:
- *      none
- *
- * Return Value: true if success otherwise false
- *
- */
-void KeyvRemoveWEPKey(
-       PSKeyManagement pTable,
-       unsigned long dwKeyIndex,
-       void __iomem *dwIoBase
-)
+static int vnt_set_keymode(struct ieee80211_hw *hw, u8 *mac_addr,
+       struct ieee80211_key_conf *key, u32 key_type, u32 mode,
+       bool onfly_latch)
 {
-       if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) {
-               if (pTable->KeyTable[MAX_KEY_TABLE-1].bInUse) {
-                       if (pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF].byCipherSuite == KEY_CTL_WEP) {
-                               pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false;
-                               if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex & 0x7FFFFFFF)) {
-                                       // remove Group transmit key
-                                       pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex = 0;
-                               }
+       struct vnt_private *priv = hw->priv;
+       u8 broadcast[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+       u16 key_mode = 0;
+       u32 entry = 0;
+       u8 *bssid;
+       u8 key_inx = key->keyidx;
+       u8 i;
+
+       if (mac_addr)
+               bssid = mac_addr;
+       else
+               bssid = &broadcast[0];
+
+       if (key_type != VNT_KEY_DEFAULTKEY) {
+               for (i = 0; i < (MAX_KEY_TABLE - 1); i++) {
+                       if (!test_bit(i, &priv->key_entry_inuse)) {
+                               set_bit(i, &priv->key_entry_inuse);
+
+                               key->hw_key_idx = i;
+                               entry = key->hw_key_idx;
+                               break;
                        }
                }
-               s_vCheckKeyTableValid(pTable, dwIoBase);
        }
-}
 
-void KeyvRemoveAllWEPKey(
-       PSKeyManagement pTable,
-       void __iomem *dwIoBase
-)
-{
-       int i;
-
-       for (i = 0; i < MAX_GROUP_KEY; i++)
-               KeyvRemoveWEPKey(pTable, i, dwIoBase);
+       switch (key_type) {
+       /* fallthrough */
+       case VNT_KEY_DEFAULTKEY:
+               /* default key last entry */
+               entry = MAX_KEY_TABLE - 1;
+               key->hw_key_idx = entry;
+       case VNT_KEY_ALLGROUP:
+               key_mode |= VNT_KEY_ALLGROUP;
+               if (onfly_latch)
+                       key_mode |= VNT_KEY_ONFLY_ALL;
+       case VNT_KEY_GROUP_ADDRESS:
+               key_mode |= mode;
+       case VNT_KEY_GROUP:
+               key_mode |= (mode << 4);
+               key_mode |= VNT_KEY_GROUP;
+               break;
+       case  VNT_KEY_PAIRWISE:
+               key_mode |= mode;
+               key_inx = 4;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       if (onfly_latch)
+               key_mode |= VNT_KEY_ONFLY;
+
+       if (mode == KEY_CTL_WEP) {
+               if (key->keylen == WLAN_KEY_LEN_WEP40)
+                       key->key[15] &= 0x7f;
+               if (key->keylen == WLAN_KEY_LEN_WEP104)
+                       key->key[15] |= 0x80;
+       }
+
+       MACvSetKeyEntry(priv->PortOffset, key_mode, entry, key_inx,
+                       bssid, (u32 *)key->key, priv->byLocalID);
+
+       return 0;
 }
 
-/*
- * Description: Get Transmit Key from table
- *
- * Parameters:
- *  In:
- *      pTable          - Pointer to Key table
- *      pbyBSSID        - BSSID of Key
- *  Out:
- *      pKey            - Key return
- *
- * Return Value: true if found otherwise false
- *
- */
-bool KeybGetTransmitKey(
-       PSKeyManagement pTable,
-       unsigned char *pbyBSSID,
-       unsigned long dwKeyType,
-       PSKeyItem       *pKey
-)
+int vnt_set_keys(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
+                struct ieee80211_vif *vif, struct ieee80211_key_conf *key)
 {
-       int i, ii;
-
-       *pKey = NULL;
-       for (i = 0; i < MAX_KEY_TABLE; i++) {
-               if (pTable->KeyTable[i].bInUse &&
-                   ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) {
-                       if (dwKeyType == PAIRWISE_KEY) {
-                               if (pTable->KeyTable[i].PairwiseKey.bKeyValid) {
-                                       *pKey = &(pTable->KeyTable[i].PairwiseKey);
-
-                                       pr_debug("KeybGetTransmitKey:");
-                                       pr_debug("PAIRWISE_KEY: KeyTable.abyBSSID: ");
-                                       for (ii = 0; ii < 6; ii++)
-                                               pr_debug("%x ",
-                                                        pTable->KeyTable[i].abyBSSID[ii]);
-
-                                       pr_debug("\n");
+       struct ieee80211_bss_conf *conf = &vif->bss_conf;
+       struct vnt_private *priv = hw->priv;
+       u8 *mac_addr = NULL;
+       u8 key_dec_mode = 0;
+       int ret = 0;
+       u32 u;
 
-                                       return true;
-                               } else {
-                                       pr_debug("PairwiseKey.bKeyValid == false\n");
-                                       return false;
-                               }
-                       } // End of Type == PAIRWISE
-                       else {
-                               if (pTable->KeyTable[i].dwGTKeyIndex == 0) {
-                                       pr_debug("ERROR: dwGTKeyIndex == 0 !!!\n");
-                                       return false;
-                               }
-                               if (pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)].bKeyValid) {
-                                       *pKey = &(pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)]);
-
-                                       pr_debug("KeybGetTransmitKey:");
-                                       pr_debug("GROUP_KEY: KeyTable.abyBSSID\n");
-                                       for (ii = 0; ii < 6; ii++)
-                                               pr_debug("%x ",
-                                                        pTable->KeyTable[i].abyBSSID[ii]);
-
-                                       pr_debug("\n");
-                                       pr_debug("dwGTKeyIndex: %lX\n",
-                                                pTable->KeyTable[i].dwGTKeyIndex);
-
-                                       return true;
-                               } else {
-                                       pr_debug("GroupKey.bKeyValid == false\n");
-                                       return false;
-                               }
-                       } // End of Type = GROUP
-               } // BSSID match
-       }
-       pr_debug("ERROR: NO Match BSSID !!! ");
-       for (ii = 0; ii < 6; ii++)
-               pr_debug("%02x ", *(pbyBSSID+ii));
-
-       pr_debug("\n");
-       return false;
-}
-
-/*
- * Description: Check Pairewise Key
- *
- * Parameters:
- *  In:
- *      pTable          - Pointer to Key table
- *  Out:
- *      none
- *
- * Return Value: true if found otherwise false
- *
- */
-bool KeybCheckPairewiseKey(
-       PSKeyManagement pTable,
-       PSKeyItem       *pKey
-)
-{
-       int i;
+       if (sta)
+               mac_addr = &sta->addr[0];
 
-       *pKey = NULL;
-       for (i = 0; i < MAX_KEY_TABLE; i++) {
-               if (pTable->KeyTable[i].bInUse &&
-                   pTable->KeyTable[i].PairwiseKey.bKeyValid) {
-                       *pKey = &(pTable->KeyTable[i].PairwiseKey);
-                       return true;
-               }
-       }
-       return false;
-}
+       switch (key->cipher) {
+       case 0:
+               for (u = 0 ; u < MAX_KEY_TABLE; u++)
+                       MACvDisableKeyEntry(priv->PortOffset, u);
+               return ret;
 
-/*
- * Description: Set Key to table
- *
- * Parameters:
- *  In:
- *      pTable          - Pointer to Key table
- *      dwKeyIndex      - Key index (reference to NDIS DDK)
- *      uKeyLength      - Key length
- *      KeyRSC          - Key RSC
- *      pbyKey          - Pointer to key
- *  Out:
- *      none
- *
- * Return Value: true if success otherwise false
- *
- */
-bool KeybSetDefaultKey(
-       PSKeyManagement pTable,
-       unsigned long dwKeyIndex,
-       unsigned long uKeyLength,
-       u64 *pKeyRSC,
-       unsigned char *pbyKey,
-       unsigned char byKeyDecMode,
-       void __iomem *dwIoBase,
-       unsigned char byLocalID
-)
-{
-       unsigned int ii;
-       PSKeyItem   pKey;
-       unsigned int uKeyIdx;
+       case WLAN_CIPHER_SUITE_WEP40:
+       case WLAN_CIPHER_SUITE_WEP104:
+               for (u = 0; u < MAX_KEY_TABLE; u++)
+                       MACvDisableKeyEntry(priv->PortOffset, u);
 
-       pr_debug("Enter KeybSetDefaultKey: %1x, %d\n",
-                (int)dwKeyIndex, (int)uKeyLength);
+               vnt_set_keymode(hw, mac_addr,
+                               key, VNT_KEY_DEFAULTKEY, KEY_CTL_WEP, true);
 
-       if ((dwKeyIndex & PAIRWISE_KEY) != 0) // Pairwise key
-               return false;
-       else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY)
-               return false;
+               key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
 
-       if (uKeyLength > MAX_KEY_LEN)
-               return false;
+               return ret;
+       case WLAN_CIPHER_SUITE_TKIP:
+               key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
+               key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
 
-       pTable->KeyTable[MAX_KEY_TABLE - 1].bInUse = true;
-       for (ii = 0; ii < ETH_ALEN; ii++)
-               pTable->KeyTable[MAX_KEY_TABLE - 1].abyBSSID[ii] = 0xFF;
+               key_dec_mode = KEY_CTL_TKIP;
 
-       // Group key
-       pKey = &(pTable->KeyTable[MAX_KEY_TABLE - 1].GroupKey[dwKeyIndex & 0x000000FF]);
-       if ((dwKeyIndex & TRANSMIT_KEY) != 0)  {
-               // Group transmit key
-               pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex = dwKeyIndex;
-               pr_debug("Group transmit key(R)[%lX]: %d\n",
-                        pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex,
-                        MAX_KEY_TABLE-1);
+               break;
+       case WLAN_CIPHER_SUITE_CCMP:
+               key_dec_mode = KEY_CTL_CCMP;
 
+               key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
        }
-       pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl &= 0x7F00;          // clear all key control filed
-       pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= (byKeyDecMode << 4);
-       pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= (byKeyDecMode);
-       pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0x0044;          // use group key for all address
-       uKeyIdx = (dwKeyIndex & 0x000000FF);
 
-       if ((uKeyLength == WLAN_WEP232_KEYLEN) &&
-           (byKeyDecMode == KEY_CTL_WEP)) {
-               pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0x4000;              // disable on-fly disable address match
-               pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP = true;
+       if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) {
+               vnt_set_keymode(hw, mac_addr,
+                               key, VNT_KEY_PAIRWISE, key_dec_mode, true);
        } else {
-               if (!pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP)
-                       pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0xC000;          // enable on-fly disable address match
-       }
+               vnt_set_keymode(hw, mac_addr,
+                               key, VNT_KEY_DEFAULTKEY, key_dec_mode, true);
 
-       pKey->bKeyValid = true;
-       pKey->uKeyLength = uKeyLength;
-       pKey->dwKeyIndex = dwKeyIndex;
-       pKey->byCipherSuite = byKeyDecMode;
-       memcpy(pKey->abyKey, pbyKey, uKeyLength);
-       if (byKeyDecMode == KEY_CTL_WEP) {
-               if (uKeyLength == WLAN_WEP40_KEYLEN)
-                       pKey->abyKey[15] &= 0x7F;
-               if (uKeyLength == WLAN_WEP104_KEYLEN)
-                       pKey->abyKey[15] |= 0x80;
-       }
-       MACvSetKeyEntry(dwIoBase, pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl, MAX_KEY_TABLE-1, uKeyIdx, pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID, (u32 *)pKey->abyKey, byLocalID);
-
-       if ((dwKeyIndex & USE_KEYRSC) == 0) {
-               // RSC set by NIC
-               pKey->KeyRSC = 0;
-       } else {
-               pKey->KeyRSC = *pKeyRSC;
+               vnt_set_keymode(hw, (u8 *)conf->bssid,
+                               key, VNT_KEY_GROUP_ADDRESS, key_dec_mode, true);
        }
-       pKey->dwTSC47_16 = 0;
-       pKey->wTSC15_0 = 0;
-
-       pr_debug("KeybSetKey(R):\n");
-       pr_debug("pKey->bKeyValid: %d\n", pKey->bKeyValid);
-       pr_debug("pKey->uKeyLength: %d\n", (int)pKey->uKeyLength);
-       pr_debug("pKey->abyKey:\n");
-       for (ii = 0; ii < pKey->uKeyLength; ii++)
-               pr_debug("%x", pKey->abyKey[ii]);
-
-       pr_debug("\n");
-
-       pr_debug("pKey->dwTSC47_16: %lx\n", pKey->dwTSC47_16);
-       pr_debug("pKey->wTSC15_0: %x\n", pKey->wTSC15_0);
-       pr_debug("pKey->dwKeyIndex: %lx\n", pKey->dwKeyIndex);
-
-       return true;
-}
 
-/*
- * Description: Set Key to table
- *
- * Parameters:
- *  In:
- *      pTable          - Pointer to Key table
- *      dwKeyIndex      - Key index (reference to NDIS DDK)
- *      uKeyLength      - Key length
- *      KeyRSC          - Key RSC
- *      pbyKey          - Pointer to key
- *  Out:
- *      none
- *
- * Return Value: true if success otherwise false
- *
- */
-bool KeybSetAllGroupKey(
-       PSKeyManagement pTable,
-       unsigned long dwKeyIndex,
-       unsigned long uKeyLength,
-       u64 *pKeyRSC,
-       unsigned char *pbyKey,
-       unsigned char byKeyDecMode,
-       void __iomem *dwIoBase,
-       unsigned char byLocalID
-)
-{
-       int         i;
-       unsigned int ii;
-       PSKeyItem   pKey;
-       unsigned int uKeyIdx;
-
-       pr_debug("Enter KeybSetAllGroupKey: %lX\n", dwKeyIndex);
-
-       if ((dwKeyIndex & PAIRWISE_KEY) != 0) // Pairwise key
-               return false;
-       else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY)
-               return false;
-
-       for (i = 0; i < MAX_KEY_TABLE - 1; i++) {
-               if (pTable->KeyTable[i].bInUse) {
-                       // found table already exist
-                       // Group key
-                       pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]);
-                       if ((dwKeyIndex & TRANSMIT_KEY) != 0)  {
-                               // Group transmit key
-                               pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex;
-                               pr_debug("Group transmit key(R)[%lX]: %d\n",
-                                        pTable->KeyTable[i].dwGTKeyIndex, i);
-
-                       }
-                       pTable->KeyTable[i].wKeyCtl &= 0xFF0F;          // clear group key control filed
-                       pTable->KeyTable[i].wKeyCtl |= (byKeyDecMode << 4);
-                       pTable->KeyTable[i].wKeyCtl |= 0x0040;          // use group key for group address
-                       uKeyIdx = (dwKeyIndex & 0x000000FF);
-
-                       pTable->KeyTable[i].wKeyCtl |= 0x8000;              // enable on-fly
-
-                       pKey->bKeyValid = true;
-                       pKey->uKeyLength = uKeyLength;
-                       pKey->dwKeyIndex = dwKeyIndex;
-                       pKey->byCipherSuite = byKeyDecMode;
-                       memcpy(pKey->abyKey, pbyKey, uKeyLength);
-                       if (byKeyDecMode == KEY_CTL_WEP) {
-                               if (uKeyLength == WLAN_WEP40_KEYLEN)
-                                       pKey->abyKey[15] &= 0x7F;
-                               if (uKeyLength == WLAN_WEP104_KEYLEN)
-                                       pKey->abyKey[15] |= 0x80;
-                       }
-                       MACvSetKeyEntry(dwIoBase, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pTable->KeyTable[i].abyBSSID, (u32 *)pKey->abyKey, byLocalID);
-
-                       if ((dwKeyIndex & USE_KEYRSC) == 0) {
-                               // RSC set by NIC
-                               pKey->KeyRSC = 0;
-                       } else {
-                               pKey->KeyRSC = *pKeyRSC;
-                       }
-                       pKey->dwTSC47_16 = 0;
-                       pKey->wTSC15_0 = 0;
-
-                       pr_debug("KeybSetKey(R):\n");
-                       pr_debug("pKey->bKeyValid: %d\n ", pKey->bKeyValid);
-                       pr_debug("pKey->uKeyLength: %d\n ",
-                                (int)pKey->uKeyLength);
-                       pr_debug("pKey->abyKey: ");
-                       for (ii = 0; ii < pKey->uKeyLength; ii++)
-                               pr_debug("%02x ", pKey->abyKey[ii]);
-
-                       pr_debug("\n");
-
-               } // (pTable->KeyTable[i].bInUse == true)
-       }
-       return true;
+       return 0;
 }
index 44efe18..c01d4af 100644 (file)
@@ -30,9 +30,7 @@
 #ifndef __KEY_H__
 #define __KEY_H__
 
-#include "ttype.h"
-#include "tether.h"
-#include "80211mgr.h"
+#include <net/mac80211.h>
 
 /*---------------------  Export Definitions -------------------------*/
 #define MAX_GROUP_KEY       4
 #define KEY_CTL_CCMP        0x03
 #define KEY_CTL_INVALID     0xFF
 
-typedef struct tagSKeyItem {
-       bool bKeyValid;
-       unsigned long uKeyLength;
-       unsigned char abyKey[MAX_KEY_LEN];
-       u64 KeyRSC;
-       unsigned long dwTSC47_16;
-       unsigned short wTSC15_0;
-       unsigned char byCipherSuite;
-       unsigned char byReserved0;
-       unsigned long dwKeyIndex;
-       void *pvKeyTable;
-} SKeyItem, *PSKeyItem; //64
+#define VNT_KEY_DEFAULTKEY     0x1
+#define VNT_KEY_GROUP_ADDRESS  0x2
+#define VNT_KEY_ALLGROUP       0x4
+#define VNT_KEY_GROUP          0x40
+#define VNT_KEY_PAIRWISE       0x00
+#define VNT_KEY_ONFLY          0x8000
+#define VNT_KEY_ONFLY_ALL      0x4000
 
-typedef struct tagSKeyTable {
-       unsigned char abyBSSID[ETH_ALEN];  //6
-       unsigned char byReserved0[2];              //8
-       SKeyItem    PairwiseKey;
-       SKeyItem    GroupKey[MAX_GROUP_KEY]; //64*5 = 320, 320+8=328
-       unsigned long dwGTKeyIndex;            // GroupTransmitKey Index
-       bool bInUse;
-       //2006-1116-01,<Modify> by NomadZhao
-       bool bSoftWEP;
-       unsigned short wKeyCtl;      // for address of wKeyCtl at align 4
+struct vnt_private;
 
-       unsigned char byReserved1[6];
-} SKeyTable, *PSKeyTable; //348
+int vnt_key_init_table(struct vnt_private *);
 
-typedef struct tagSKeyManagement {
-       SKeyTable   KeyTable[MAX_KEY_TABLE];
-} SKeyManagement, *PSKeyManagement;
-
-/*---------------------  Export Types  ------------------------------*/
-
-/*---------------------  Export Macros ------------------------------*/
-
-/*---------------------  Export Classes  ----------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-void KeyvInitTable(PSKeyManagement pTable, void __iomem *dwIoBase);
-
-bool KeybGetKey(
-       PSKeyManagement pTable,
-       unsigned char *pbyBSSID,
-       unsigned long dwKeyIndex,
-       PSKeyItem       *pKey
-);
-
-bool KeybSetKey(
-       PSKeyManagement pTable,
-       unsigned char *pbyBSSID,
-       unsigned long dwKeyIndex,
-       unsigned long uKeyLength,
-       u64 *pKeyRSC,
-       unsigned char *pbyKey,
-       unsigned char byKeyDecMode,
-       void __iomem *dwIoBase,
-       unsigned char byLocalID
-);
-
-bool KeybSetDefaultKey(
-       PSKeyManagement pTable,
-       unsigned long dwKeyIndex,
-       unsigned long uKeyLength,
-       u64 *pKeyRSC,
-       unsigned char *pbyKey,
-       unsigned char byKeyDecMode,
-       void __iomem *dwIoBase,
-       unsigned char byLocalID
-);
-
-bool KeybRemoveKey(
-       PSKeyManagement pTable,
-       unsigned char *pbyBSSID,
-       unsigned long dwKeyIndex,
-       void __iomem *dwIoBase
-);
-
-bool KeybGetTransmitKey(
-       PSKeyManagement pTable,
-       unsigned char *pbyBSSID,
-       unsigned long dwKeyType,
-       PSKeyItem       *pKey
-);
-
-bool KeybCheckPairewiseKey(
-       PSKeyManagement pTable,
-       PSKeyItem       *pKey
-);
-
-bool KeybRemoveAllKey(
-       PSKeyManagement pTable,
-       unsigned char *pbyBSSID,
-       void __iomem *dwIoBase
-);
-
-void KeyvRemoveWEPKey(
-       PSKeyManagement pTable,
-       unsigned long dwKeyIndex,
-       void __iomem *dwIoBase
-);
-
-void KeyvRemoveAllWEPKey(
-       PSKeyManagement pTable,
-       void __iomem *dwIoBase
-);
-
-bool KeybSetAllGroupKey(
-       PSKeyManagement pTable,
-       unsigned long dwKeyIndex,
-       unsigned long uKeyLength,
-       u64 *pKeyRSC,
-       unsigned char *pbyKey,
-       unsigned char byKeyDecMode,
-       void __iomem *dwIoBase,
-       unsigned char byLocalID
-);
+int vnt_set_keys(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
+                struct ieee80211_vif *vif, struct ieee80211_key_conf *key);
 
 #endif // __KEY_H__
index e3b0b7f..955dbfe 100644 (file)
@@ -69,7 +69,6 @@
  */
 
 #include "tmacro.h"
-#include "tether.h"
 #include "mac.h"
 
 unsigned short TxRate_iwconfig;//2008-5-8 <add> by chester
@@ -1526,7 +1525,7 @@ void MACvSetDefaultKeyEntry(void __iomem *dwIoBase, unsigned int uKeyLen,
                VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
        }
        dwData = *pdwKey;
-       if (uKeyLen == WLAN_WEP104_KEYLEN)
+       if (uKeyLen == WLAN_KEY_LEN_WEP40)
                dwData |= 0x80000000;
 
        VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset+3);
index 0bf9375..5391277 100644 (file)
@@ -34,7 +34,6 @@
 #ifndef __MAC_H__
 #define __MAC_H__
 
-#include "ttype.h"
 #include "tmacro.h"
 #include "upc.h"
 
index 111c018..d2f351d 100644 (file)
  * Date: May 21, 1996
  *
  * Functions:
- *      STAvClearAllCounter - Clear All MIB Counter
  *      STAvUpdateIstStatCounter - Update ISR statistic counter
- *      STAvUpdateRDStatCounter - Update Rx statistic counter
- *      STAvUpdateRDStatCounterEx - Update Rx statistic counter and copy rcv data
- *      STAvUpdateTDStatCounter - Update Tx statistic counter
- *      STAvUpdateTDStatCounterEx - Update Tx statistic counter and copy tx data
  *      STAvUpdate802_11Counter - Update 802.11 mib counter
  *
  * Revision History:
  *
  */
 
-#include "upc.h"
 #include "mac.h"
-#include "tether.h"
 #include "mib.h"
-#include "wctl.h"
-#include "baseband.h"
 
 /*---------------------  Static Classes  ----------------------------*/
 
 
 /*---------------------  Export Functions  --------------------------*/
 
-/*
- * Description: Clear All Statistic Counter
- *
- * Parameters:
- *  In:
- *      pStatistic  - Pointer to Statistic Counter Data Structure
- *  Out:
- *      none
- *
- * Return Value: none
- *
- */
-void STAvClearAllCounter(PSStatCounter pStatistic)
-{
-       // set memory to zero
-       memset(pStatistic, 0, sizeof(SStatCounter));
-}
-
 /*
  * Description: Update Isr Statistic Counter
  *
@@ -138,373 +111,6 @@ void STAvUpdateIsrStatCounter(PSStatCounter pStatistic, unsigned long dwIsr)
                pStatistic->ISRStat.dwIsrSTIMER1Int++;
 }
 
-/*
- * Description: Update Rx Statistic Counter
- *
- * Parameters:
- *  In:
- *      pStatistic      - Pointer to Statistic Counter Data Structure
- *      byRSR           - Rx Status
- *      byNewRSR        - Rx Status
- *      pbyBuffer       - Rx Buffer
- *      cbFrameLength   - Rx Length
- *  Out:
- *      none
- *
- * Return Value: none
- *
- */
-void STAvUpdateRDStatCounter(PSStatCounter pStatistic,
-                            unsigned char byRSR, unsigned char byNewRSR, unsigned char byRxRate,
-                            unsigned char *pbyBuffer, unsigned int cbFrameLength)
-{
-       //need change
-       PS802_11Header pHeader = (PS802_11Header)pbyBuffer;
-
-       if (byRSR & RSR_ADDROK)
-               pStatistic->dwRsrADDROk++;
-       if (byRSR & RSR_CRCOK) {
-               pStatistic->dwRsrCRCOk++;
-
-               pStatistic->ullRsrOK++;
-
-               if (cbFrameLength >= ETH_ALEN) {
-                       // update counters in case of successful transmit
-                       if (byRSR & RSR_ADDRBROAD) {
-                               pStatistic->ullRxBroadcastFrames++;
-                               pStatistic->ullRxBroadcastBytes += (unsigned long long) cbFrameLength;
-                       } else if (byRSR & RSR_ADDRMULTI) {
-                               pStatistic->ullRxMulticastFrames++;
-                               pStatistic->ullRxMulticastBytes += (unsigned long long) cbFrameLength;
-                       } else {
-                               pStatistic->ullRxDirectedFrames++;
-                               pStatistic->ullRxDirectedBytes += (unsigned long long) cbFrameLength;
-                       }
-               }
-       }
-
-       if (byRxRate == 22) {
-               pStatistic->CustomStat.ullRsr11M++;
-               if (byRSR & RSR_CRCOK)
-                       pStatistic->CustomStat.ullRsr11MCRCOk++;
-
-               pr_debug("11M: ALL[%d], OK[%d]:[%02x]\n",
-                        (int)pStatistic->CustomStat.ullRsr11M,
-                        (int)pStatistic->CustomStat.ullRsr11MCRCOk, byRSR);
-       } else if (byRxRate == 11) {
-               pStatistic->CustomStat.ullRsr5M++;
-               if (byRSR & RSR_CRCOK)
-                       pStatistic->CustomStat.ullRsr5MCRCOk++;
-
-               pr_debug(" 5M: ALL[%d], OK[%d]:[%02x]\n",
-                        (int)pStatistic->CustomStat.ullRsr5M,
-                        (int)pStatistic->CustomStat.ullRsr5MCRCOk, byRSR);
-       } else if (byRxRate == 4) {
-               pStatistic->CustomStat.ullRsr2M++;
-               if (byRSR & RSR_CRCOK)
-                       pStatistic->CustomStat.ullRsr2MCRCOk++;
-
-               pr_debug(" 2M: ALL[%d], OK[%d]:[%02x]\n",
-                        (int)pStatistic->CustomStat.ullRsr2M,
-                        (int)pStatistic->CustomStat.ullRsr2MCRCOk, byRSR);
-       } else if (byRxRate == 2) {
-               pStatistic->CustomStat.ullRsr1M++;
-               if (byRSR & RSR_CRCOK)
-                       pStatistic->CustomStat.ullRsr1MCRCOk++;
-
-               pr_debug(" 1M: ALL[%d], OK[%d]:[%02x]\n",
-                        (int)pStatistic->CustomStat.ullRsr1M,
-                        (int)pStatistic->CustomStat.ullRsr1MCRCOk, byRSR);
-       } else if (byRxRate == 12) {
-               pStatistic->CustomStat.ullRsr6M++;
-               if (byRSR & RSR_CRCOK)
-                       pStatistic->CustomStat.ullRsr6MCRCOk++;
-
-               pr_debug(" 6M: ALL[%d], OK[%d]\n",
-                        (int)pStatistic->CustomStat.ullRsr6M,
-                        (int)pStatistic->CustomStat.ullRsr6MCRCOk);
-       } else if (byRxRate == 18) {
-               pStatistic->CustomStat.ullRsr9M++;
-               if (byRSR & RSR_CRCOK)
-                       pStatistic->CustomStat.ullRsr9MCRCOk++;
-
-               pr_debug(" 9M: ALL[%d], OK[%d]\n",
-                        (int)pStatistic->CustomStat.ullRsr9M,
-                        (int)pStatistic->CustomStat.ullRsr9MCRCOk);
-       } else if (byRxRate == 24) {
-               pStatistic->CustomStat.ullRsr12M++;
-               if (byRSR & RSR_CRCOK)
-                       pStatistic->CustomStat.ullRsr12MCRCOk++;
-
-               pr_debug("12M: ALL[%d], OK[%d]\n",
-                        (int)pStatistic->CustomStat.ullRsr12M,
-                        (int)pStatistic->CustomStat.ullRsr12MCRCOk);
-       } else if (byRxRate == 36) {
-               pStatistic->CustomStat.ullRsr18M++;
-               if (byRSR & RSR_CRCOK)
-                       pStatistic->CustomStat.ullRsr18MCRCOk++;
-
-               pr_debug("18M: ALL[%d], OK[%d]\n",
-                        (int)pStatistic->CustomStat.ullRsr18M,
-                        (int)pStatistic->CustomStat.ullRsr18MCRCOk);
-       } else if (byRxRate == 48) {
-               pStatistic->CustomStat.ullRsr24M++;
-               if (byRSR & RSR_CRCOK)
-                       pStatistic->CustomStat.ullRsr24MCRCOk++;
-
-               pr_debug("24M: ALL[%d], OK[%d]\n",
-                        (int)pStatistic->CustomStat.ullRsr24M,
-                        (int)pStatistic->CustomStat.ullRsr24MCRCOk);
-       } else if (byRxRate == 72) {
-               pStatistic->CustomStat.ullRsr36M++;
-               if (byRSR & RSR_CRCOK)
-                       pStatistic->CustomStat.ullRsr36MCRCOk++;
-
-               pr_debug("36M: ALL[%d], OK[%d]\n",
-                        (int)pStatistic->CustomStat.ullRsr36M,
-                        (int)pStatistic->CustomStat.ullRsr36MCRCOk);
-       } else if (byRxRate == 96) {
-               pStatistic->CustomStat.ullRsr48M++;
-               if (byRSR & RSR_CRCOK)
-                       pStatistic->CustomStat.ullRsr48MCRCOk++;
-
-               pr_debug("48M: ALL[%d], OK[%d]\n",
-                        (int)pStatistic->CustomStat.ullRsr48M,
-                        (int)pStatistic->CustomStat.ullRsr48MCRCOk);
-       } else if (byRxRate == 108) {
-               pStatistic->CustomStat.ullRsr54M++;
-               if (byRSR & RSR_CRCOK)
-                       pStatistic->CustomStat.ullRsr54MCRCOk++;
-
-               pr_debug("54M: ALL[%d], OK[%d]\n",
-                        (int)pStatistic->CustomStat.ullRsr54M,
-                        (int)pStatistic->CustomStat.ullRsr54MCRCOk);
-       } else {
-               pr_debug("Unknown: Total[%d], CRCOK[%d]\n",
-                        (int)pStatistic->dwRsrRxPacket+1,
-                        (int)pStatistic->dwRsrCRCOk);
-       }
-
-       if (byRSR & RSR_BSSIDOK)
-               pStatistic->dwRsrBSSIDOk++;
-
-       if (byRSR & RSR_BCNSSIDOK)
-               pStatistic->dwRsrBCNSSIDOk++;
-       if (byRSR & RSR_IVLDLEN)  //invalid len (> 2312 byte)
-               pStatistic->dwRsrLENErr++;
-       if (byRSR & RSR_IVLDTYP)  //invalid packet type
-               pStatistic->dwRsrTYPErr++;
-       if (byRSR & (RSR_IVLDTYP | RSR_IVLDLEN))
-               pStatistic->dwRsrErr++;
-
-       if (byNewRSR & NEWRSR_DECRYPTOK)
-               pStatistic->dwNewRsrDECRYPTOK++;
-       if (byNewRSR & NEWRSR_CFPIND)
-               pStatistic->dwNewRsrCFP++;
-       if (byNewRSR & NEWRSR_HWUTSF)
-               pStatistic->dwNewRsrUTSF++;
-       if (byNewRSR & NEWRSR_BCNHITAID)
-               pStatistic->dwNewRsrHITAID++;
-       if (byNewRSR & NEWRSR_BCNHITAID0)
-               pStatistic->dwNewRsrHITAID0++;
-
-       // increase rx packet count
-       pStatistic->dwRsrRxPacket++;
-       pStatistic->dwRsrRxOctet += cbFrameLength;
-
-       if (IS_TYPE_DATA(pbyBuffer))
-               pStatistic->dwRsrRxData++;
-       else if (IS_TYPE_MGMT(pbyBuffer))
-               pStatistic->dwRsrRxManage++;
-       else if (IS_TYPE_CONTROL(pbyBuffer))
-               pStatistic->dwRsrRxControl++;
-
-       if (byRSR & RSR_ADDRBROAD)
-               pStatistic->dwRsrBroadcast++;
-       else if (byRSR & RSR_ADDRMULTI)
-               pStatistic->dwRsrMulticast++;
-       else
-               pStatistic->dwRsrDirected++;
-
-       if (WLAN_GET_FC_MOREFRAG(pHeader->wFrameCtl))
-               pStatistic->dwRsrRxFragment++;
-
-       if (cbFrameLength < ETH_ZLEN + 4)
-               pStatistic->dwRsrRunt++;
-       else if (cbFrameLength == ETH_ZLEN + 4)
-               pStatistic->dwRsrRxFrmLen64++;
-       else if ((65 <= cbFrameLength) && (cbFrameLength <= 127))
-               pStatistic->dwRsrRxFrmLen65_127++;
-       else if ((128 <= cbFrameLength) && (cbFrameLength <= 255))
-               pStatistic->dwRsrRxFrmLen128_255++;
-       else if ((256 <= cbFrameLength) && (cbFrameLength <= 511))
-               pStatistic->dwRsrRxFrmLen256_511++;
-       else if ((512 <= cbFrameLength) && (cbFrameLength <= 1023))
-               pStatistic->dwRsrRxFrmLen512_1023++;
-       else if ((1024 <= cbFrameLength) && (cbFrameLength <= ETH_FRAME_LEN + 4))
-               pStatistic->dwRsrRxFrmLen1024_1518++;
-       else if (cbFrameLength > ETH_FRAME_LEN + 4)
-               pStatistic->dwRsrLong++;
-}
-
-/*
- * Description: Update Rx Statistic Counter and copy Rx buffer
- *
- * Parameters:
- *  In:
- *      pStatistic      - Pointer to Statistic Counter Data Structure
- *      byRSR           - Rx Status
- *      byNewRSR        - Rx Status
- *      pbyBuffer       - Rx Buffer
- *      cbFrameLength   - Rx Length
- *  Out:
- *      none
- *
- * Return Value: none
- *
- */
-
-void
-STAvUpdateRDStatCounterEx(
-       PSStatCounter   pStatistic,
-       unsigned char byRSR,
-       unsigned char byNewRSR,
-       unsigned char byRxRate,
-       unsigned char *pbyBuffer,
-       unsigned int cbFrameLength
-)
-{
-       STAvUpdateRDStatCounter(
-               pStatistic,
-               byRSR,
-               byNewRSR,
-               byRxRate,
-               pbyBuffer,
-               cbFrameLength
-);
-
-       // rx length
-       pStatistic->dwCntRxFrmLength = cbFrameLength;
-       // rx pattern, we just see 10 bytes for sample
-       memcpy(pStatistic->abyCntRxPattern, (unsigned char *)pbyBuffer, 10);
-}
-
-/*
- * Description: Update Tx Statistic Counter
- *
- * Parameters:
- *  In:
- *      pStatistic      - Pointer to Statistic Counter Data Structure
- *      byTSR0          - Tx Status
- *      byTSR1          - Tx Status
- *      pbyBuffer       - Tx Buffer
- *      cbFrameLength   - Tx Length
- *      uIdx            - Index of Tx DMA
- *  Out:
- *      none
- *
- * Return Value: none
- *
- */
-void
-STAvUpdateTDStatCounter(
-       PSStatCounter   pStatistic,
-       unsigned char byTSR0,
-       unsigned char byTSR1,
-       unsigned char *pbyBuffer,
-       unsigned int cbFrameLength,
-       unsigned int uIdx
-)
-{
-       PWLAN_80211HDR_A4   pHeader;
-       unsigned char *pbyDestAddr;
-       unsigned char byTSR0_NCR = byTSR0 & TSR0_NCR;
-
-       pHeader = (PWLAN_80211HDR_A4) pbyBuffer;
-       if (WLAN_GET_FC_TODS(pHeader->wFrameCtl) == 0)
-               pbyDestAddr = &(pHeader->abyAddr1[0]);
-       else
-               pbyDestAddr = &(pHeader->abyAddr3[0]);
-
-       // increase tx packet count
-       pStatistic->dwTsrTxPacket[uIdx]++;
-       pStatistic->dwTsrTxOctet[uIdx] += cbFrameLength;
-
-       if (byTSR0_NCR != 0) {
-               pStatistic->dwTsrRetry[uIdx]++;
-               pStatistic->dwTsrTotalRetry[uIdx] += byTSR0_NCR;
-
-               if (byTSR0_NCR == 1)
-                       pStatistic->dwTsrOnceRetry[uIdx]++;
-               else
-                       pStatistic->dwTsrMoreThanOnceRetry[uIdx]++;
-       }
-
-       if ((byTSR1&(TSR1_TERR|TSR1_RETRYTMO|TSR1_TMO|ACK_DATA)) == 0) {
-               pStatistic->ullTsrOK[uIdx]++;
-               pStatistic->CustomStat.ullTsrAllOK =
-                       (pStatistic->ullTsrOK[TYPE_AC0DMA] + pStatistic->ullTsrOK[TYPE_TXDMA0]);
-               // update counters in case that successful transmit
-               if (is_broadcast_ether_addr(pbyDestAddr)) {
-                       pStatistic->ullTxBroadcastFrames[uIdx]++;
-                       pStatistic->ullTxBroadcastBytes[uIdx] += (unsigned long long) cbFrameLength;
-               } else if (is_multicast_ether_addr(pbyDestAddr)) {
-                       pStatistic->ullTxMulticastFrames[uIdx]++;
-                       pStatistic->ullTxMulticastBytes[uIdx] += (unsigned long long) cbFrameLength;
-               } else {
-                       pStatistic->ullTxDirectedFrames[uIdx]++;
-                       pStatistic->ullTxDirectedBytes[uIdx] += (unsigned long long) cbFrameLength;
-               }
-       } else {
-               if (byTSR1 & TSR1_TERR)
-                       pStatistic->dwTsrErr[uIdx]++;
-               if (byTSR1 & TSR1_RETRYTMO)
-                       pStatistic->dwTsrRetryTimeout[uIdx]++;
-               if (byTSR1 & TSR1_TMO)
-                       pStatistic->dwTsrTransmitTimeout[uIdx]++;
-               if (byTSR1 & ACK_DATA)
-                       pStatistic->dwTsrACKData[uIdx]++;
-       }
-
-       if (is_broadcast_ether_addr(pbyDestAddr))
-               pStatistic->dwTsrBroadcast[uIdx]++;
-       else if (is_multicast_ether_addr(pbyDestAddr))
-               pStatistic->dwTsrMulticast[uIdx]++;
-       else
-               pStatistic->dwTsrDirected[uIdx]++;
-}
-
-/*
- * Description: Update Tx Statistic Counter and copy Tx buffer
- *
- * Parameters:
- *  In:
- *      pStatistic      - Pointer to Statistic Counter Data Structure
- *      pbyBuffer       - Tx Buffer
- *      cbFrameLength   - Tx Length
- *  Out:
- *      none
- *
- * Return Value: none
- *
- */
-void
-STAvUpdateTDStatCounterEx(
-       PSStatCounter   pStatistic,
-       unsigned char *pbyBuffer,
-       unsigned long cbFrameLength
-)
-{
-       unsigned int uPktLength;
-
-       uPktLength = (unsigned int)cbFrameLength;
-
-       // tx length
-       pStatistic->dwCntTxBufLength = uPktLength;
-       // tx pattern, we just see 16 bytes for sample
-       memcpy(pStatistic->abyCntTxPattern, pbyBuffer, 16);
-}
-
 /*
  * Description: Update 802.11 mib counter
  *
@@ -526,37 +132,8 @@ STAvUpdate802_11Counter(
        unsigned long dwCounter
 )
 {
-       p802_11Counter->MulticastTransmittedFrameCount = (unsigned long long) (pStatistic->dwTsrBroadcast[TYPE_AC0DMA] +
-                                                                              pStatistic->dwTsrBroadcast[TYPE_TXDMA0] +
-                                                                              pStatistic->dwTsrMulticast[TYPE_AC0DMA] +
-                                                                              pStatistic->dwTsrMulticast[TYPE_TXDMA0]);
-       p802_11Counter->FailedCount = (unsigned long long) (pStatistic->dwTsrErr[TYPE_AC0DMA] + pStatistic->dwTsrErr[TYPE_TXDMA0]);
-       p802_11Counter->RetryCount = (unsigned long long) (pStatistic->dwTsrRetry[TYPE_AC0DMA] + pStatistic->dwTsrRetry[TYPE_TXDMA0]);
-       p802_11Counter->MultipleRetryCount = (unsigned long long) (pStatistic->dwTsrMoreThanOnceRetry[TYPE_AC0DMA] +
-                                                                  pStatistic->dwTsrMoreThanOnceRetry[TYPE_TXDMA0]);
        p802_11Counter->RTSSuccessCount += (unsigned long long)  (dwCounter & 0x000000ff);
        p802_11Counter->RTSFailureCount += (unsigned long long) ((dwCounter & 0x0000ff00) >> 8);
        p802_11Counter->ACKFailureCount += (unsigned long long) ((dwCounter & 0x00ff0000) >> 16);
        p802_11Counter->FCSErrorCount +=   (unsigned long long) ((dwCounter & 0xff000000) >> 24);
-       p802_11Counter->MulticastReceivedFrameCount = (unsigned long long) (pStatistic->dwRsrBroadcast +
-                                                                           pStatistic->dwRsrMulticast);
-}
-
-/*
- * Description: Clear 802.11 mib counter
- *
- * Parameters:
- *  In:
- *      p802_11Counter  - Pointer to 802.11 mib counter
- *  Out:
- *      none
- *
- * Return Value: none
- *
- */
-void
-STAvClear802_11Counter(PSDot11Counters p802_11Counter)
-{
-       // set memory to zero
-       memset(p802_11Counter, 0, sizeof(SDot11Counters));
 }
index 732bdda..5cb59b8 100644 (file)
@@ -29,8 +29,6 @@
 #ifndef __MIB_H__
 #define __MIB_H__
 
-#include "ttype.h"
-#include "tether.h"
 #include "desc.h"
 
 //
 //
 
 typedef struct tagSDot11Counters {
-       unsigned long Length;
-       unsigned long long   TransmittedFragmentCount;
-       unsigned long long   MulticastTransmittedFrameCount;
-       unsigned long long   FailedCount;
-       unsigned long long   RetryCount;
-       unsigned long long   MultipleRetryCount;
        unsigned long long   RTSSuccessCount;
        unsigned long long   RTSFailureCount;
        unsigned long long   ACKFailureCount;
-       unsigned long long   FrameDuplicateCount;
-       unsigned long long   ReceivedFragmentCount;
-       unsigned long long   MulticastReceivedFrameCount;
        unsigned long long   FCSErrorCount;
-       unsigned long long   TKIPLocalMICFailures;
-       unsigned long long   TKIPRemoteMICFailures;
-       unsigned long long   TKIPICVErrors;
-       unsigned long long   TKIPCounterMeasuresInvoked;
-       unsigned long long   TKIPReplays;
-       unsigned long long   CCMPFormatErrors;
-       unsigned long long   CCMPReplays;
-       unsigned long long   CCMPDecryptErrors;
-       unsigned long long   FourWayHandshakeFailures;
 } SDot11Counters, *PSDot11Counters;
 
-//
-// MIB2 counter
-//
-typedef struct tagSMib2Counter {
-       long    ifIndex;
-       char    ifDescr[256];
-       long    ifType;
-       long    ifMtu;
-       unsigned long ifSpeed;
-       unsigned char ifPhysAddress[ETH_ALEN];
-       long    ifAdminStatus;
-       long    ifOperStatus;
-       unsigned long ifLastChange;
-       unsigned long ifInOctets;
-       unsigned long ifInUcastPkts;
-       unsigned long ifInNUcastPkts;
-       unsigned long ifInDiscards;
-       unsigned long ifInErrors;
-       unsigned long ifInUnknownProtos;
-       unsigned long ifOutOctets;
-       unsigned long ifOutUcastPkts;
-       unsigned long ifOutNUcastPkts;
-       unsigned long ifOutDiscards;
-       unsigned long ifOutErrors;
-       unsigned long ifOutQLen;
-       unsigned long ifSpecific;
-} SMib2Counter, *PSMib2Counter;
-
-// Value in the ifType entry
-#define WIRELESSLANIEEE80211b      6
-
-// Value in the ifAdminStatus/ifOperStatus entry
-#define UP                  1
-#define DOWN                2
-#define TESTING             3
-
-//
-// RMON counter
-//
-typedef struct tagSRmonCounter {
-       long    etherStatsIndex;
-       unsigned long etherStatsDataSource;
-       unsigned long etherStatsDropEvents;
-       unsigned long etherStatsOctets;
-       unsigned long etherStatsPkts;
-       unsigned long etherStatsBroadcastPkts;
-       unsigned long etherStatsMulticastPkts;
-       unsigned long etherStatsCRCAlignErrors;
-       unsigned long etherStatsUndersizePkts;
-       unsigned long etherStatsOversizePkts;
-       unsigned long etherStatsFragments;
-       unsigned long etherStatsJabbers;
-       unsigned long etherStatsCollisions;
-       unsigned long etherStatsPkt64Octets;
-       unsigned long etherStatsPkt65to127Octets;
-       unsigned long etherStatsPkt128to255Octets;
-       unsigned long etherStatsPkt256to511Octets;
-       unsigned long etherStatsPkt512to1023Octets;
-       unsigned long etherStatsPkt1024to1518Octets;
-       unsigned long etherStatsOwners;
-       unsigned long etherStatsStatus;
-} SRmonCounter, *PSRmonCounter;
-
-//
-// Custom counter
-//
-typedef struct tagSCustomCounters {
-       unsigned long Length;
-
-       unsigned long long   ullTsrAllOK;
-
-       unsigned long long   ullRsr11M;
-       unsigned long long   ullRsr5M;
-       unsigned long long   ullRsr2M;
-       unsigned long long   ullRsr1M;
-
-       unsigned long long   ullRsr11MCRCOk;
-       unsigned long long   ullRsr5MCRCOk;
-       unsigned long long   ullRsr2MCRCOk;
-       unsigned long long   ullRsr1MCRCOk;
-
-       unsigned long long   ullRsr54M;
-       unsigned long long   ullRsr48M;
-       unsigned long long   ullRsr36M;
-       unsigned long long   ullRsr24M;
-       unsigned long long   ullRsr18M;
-       unsigned long long   ullRsr12M;
-       unsigned long long   ullRsr9M;
-       unsigned long long   ullRsr6M;
-
-       unsigned long long   ullRsr54MCRCOk;
-       unsigned long long   ullRsr48MCRCOk;
-       unsigned long long   ullRsr36MCRCOk;
-       unsigned long long   ullRsr24MCRCOk;
-       unsigned long long   ullRsr18MCRCOk;
-       unsigned long long   ullRsr12MCRCOk;
-       unsigned long long   ullRsr9MCRCOk;
-       unsigned long long   ullRsr6MCRCOk;
-} SCustomCounters, *PSCustomCounters;
-
 //
 // Custom counter
 //
 typedef struct tagSISRCounters {
-       unsigned long Length;
-
        unsigned long dwIsrTx0OK;
        unsigned long dwIsrAC0TxOK;
        unsigned long dwIsrBeaconTxOK;
@@ -183,161 +61,22 @@ typedef struct tagSISRCounters {
        unsigned long dwIsrUnknown;
 
        unsigned long dwIsrRx1OK;
-       unsigned long dwIsrATIMTxOK;
-       unsigned long dwIsrSYNCTxOK;
-       unsigned long dwIsrCFPEnd;
-       unsigned long dwIsrATIMEnd;
-       unsigned long dwIsrSYNCFlushOK;
        unsigned long dwIsrSTIMER1Int;
 } SISRCounters, *PSISRCounters;
 
-// Value in the etherStatsStatus entry
-#define VALID               1
-#define CREATE_REQUEST      2
-#define UNDER_CREATION      3
-#define INVALID             4
-
 //
 // statistic counter
 //
 typedef struct tagSStatCounter {
-       // RSR status count
-       //
-       unsigned long dwRsrFrmAlgnErr;
-       unsigned long dwRsrErr;
-       unsigned long dwRsrCRCErr;
-       unsigned long dwRsrCRCOk;
-       unsigned long dwRsrBSSIDOk;
-       unsigned long dwRsrADDROk;
-       unsigned long dwRsrBCNSSIDOk;
-       unsigned long dwRsrLENErr;
-       unsigned long dwRsrTYPErr;
-
-       unsigned long dwNewRsrDECRYPTOK;
-       unsigned long dwNewRsrCFP;
-       unsigned long dwNewRsrUTSF;
-       unsigned long dwNewRsrHITAID;
-       unsigned long dwNewRsrHITAID0;
-
-       unsigned long dwRsrLong;
-       unsigned long dwRsrRunt;
-
-       unsigned long dwRsrRxControl;
-       unsigned long dwRsrRxData;
-       unsigned long dwRsrRxManage;
-
-       unsigned long dwRsrRxPacket;
-       unsigned long dwRsrRxOctet;
-       unsigned long dwRsrBroadcast;
-       unsigned long dwRsrMulticast;
-       unsigned long dwRsrDirected;
-       // 64-bit OID
-       unsigned long long   ullRsrOK;
-
-       // for some optional OIDs (64 bits) and DMI support
-       unsigned long long   ullRxBroadcastBytes;
-       unsigned long long   ullRxMulticastBytes;
-       unsigned long long   ullRxDirectedBytes;
-       unsigned long long   ullRxBroadcastFrames;
-       unsigned long long   ullRxMulticastFrames;
-       unsigned long long   ullRxDirectedFrames;
-
-       unsigned long dwRsrRxFragment;
-       unsigned long dwRsrRxFrmLen64;
-       unsigned long dwRsrRxFrmLen65_127;
-       unsigned long dwRsrRxFrmLen128_255;
-       unsigned long dwRsrRxFrmLen256_511;
-       unsigned long dwRsrRxFrmLen512_1023;
-       unsigned long dwRsrRxFrmLen1024_1518;
-
-       // TSR status count
-       //
-       unsigned long dwTsrTotalRetry[TYPE_MAXTD];        // total collision retry count
-       unsigned long dwTsrOnceRetry[TYPE_MAXTD];         // this packet only occur one collision
-       unsigned long dwTsrMoreThanOnceRetry[TYPE_MAXTD]; // this packet occur more than one collision
-       unsigned long dwTsrRetry[TYPE_MAXTD];             // this packet has ever occur collision,
-       // that is (dwTsrOnceCollision0 + dwTsrMoreThanOnceCollision0)
-       unsigned long dwTsrACKData[TYPE_MAXTD];
-       unsigned long dwTsrErr[TYPE_MAXTD];
-       unsigned long dwAllTsrOK[TYPE_MAXTD];
-       unsigned long dwTsrRetryTimeout[TYPE_MAXTD];
-       unsigned long dwTsrTransmitTimeout[TYPE_MAXTD];
-
-       unsigned long dwTsrTxPacket[TYPE_MAXTD];
-       unsigned long dwTsrTxOctet[TYPE_MAXTD];
-       unsigned long dwTsrBroadcast[TYPE_MAXTD];
-       unsigned long dwTsrMulticast[TYPE_MAXTD];
-       unsigned long dwTsrDirected[TYPE_MAXTD];
-
-       // RD/TD count
-       unsigned long dwCntRxFrmLength;
-       unsigned long dwCntTxBufLength;
-
-       unsigned char abyCntRxPattern[16];
-       unsigned char abyCntTxPattern[16];
-
-       // Software check....
-       unsigned long dwCntRxDataErr;             // rx buffer data software compare CRC err count
-       unsigned long dwCntDecryptErr;            // rx buffer data software compare CRC err count
-       unsigned long dwCntRxICVErr;              // rx buffer data software compare CRC err count
-       unsigned int idxRxErrorDesc[TYPE_MAXRD]; // index for rx data error RD
-
-       // 64-bit OID
-       unsigned long long   ullTsrOK[TYPE_MAXTD];
-
-       // for some optional OIDs (64 bits) and DMI support
-       unsigned long long   ullTxBroadcastFrames[TYPE_MAXTD];
-       unsigned long long   ullTxMulticastFrames[TYPE_MAXTD];
-       unsigned long long   ullTxDirectedFrames[TYPE_MAXTD];
-       unsigned long long   ullTxBroadcastBytes[TYPE_MAXTD];
-       unsigned long long   ullTxMulticastBytes[TYPE_MAXTD];
-       unsigned long long   ullTxDirectedBytes[TYPE_MAXTD];
-
        SISRCounters ISRStat;
-
-       SCustomCounters CustomStat;
-
-#ifdef Calcu_LinkQual
-       //Tx count:
-       unsigned long TxNoRetryOkCount;
-       unsigned long TxRetryOkCount;
-       unsigned long TxFailCount;
-       //Rx count:
-       unsigned long RxOkCnt;
-       unsigned long RxFcsErrCnt;
-       //statistic
-       unsigned long SignalStren;
-       unsigned long LinkQuality;
-#endif
 } SStatCounter, *PSStatCounter;
 
-void STAvClearAllCounter(PSStatCounter pStatistic);
-
 void STAvUpdateIsrStatCounter(PSStatCounter pStatistic, unsigned long dwIsr);
 
-void STAvUpdateRDStatCounter(PSStatCounter pStatistic,
-                            unsigned char byRSR, unsigned char byNewRSR, unsigned char byRxRate,
-                            unsigned char *pbyBuffer, unsigned int cbFrameLength);
-
-void STAvUpdateRDStatCounterEx(PSStatCounter pStatistic,
-                              unsigned char byRSR, unsigned char byNewRsr, unsigned char byRxRate,
-                              unsigned char *pbyBuffer, unsigned int cbFrameLength);
-
-void STAvUpdateTDStatCounter(PSStatCounter pStatistic, unsigned char byTSR0, unsigned char byTSR1,
-                            unsigned char *pbyBuffer, unsigned int cbFrameLength, unsigned int uIdx);
-
-void STAvUpdateTDStatCounterEx(
-       PSStatCounter   pStatistic,
-       unsigned char *pbyBuffer,
-       unsigned long cbFrameLength
-);
-
 void STAvUpdate802_11Counter(
        PSDot11Counters p802_11Counter,
        PSStatCounter   pStatistic,
        unsigned long dwCounter
 );
 
-void STAvClear802_11Counter(PSDot11Counters p802_11Counter);
-
 #endif // __MIB_H__
diff --git a/drivers/staging/vt6655/michael.c b/drivers/staging/vt6655/michael.c
deleted file mode 100644 (file)
index edee487..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: michael.cpp
- *
- * Purpose: The implementation of LIST data structure.
- *
- * Author: Kyle Hsu
- *
- * Date: Sep 4, 2002
- *
- * Functions:
- *      s_dwGetUINT32 - Convert from unsigned char [] to unsigned long in a portable way
- *      s_vPutUINT32 - Convert from unsigned long to unsigned char [] in a portable way
- *      s_vClear - Reset the state to the empty message.
- *      s_vSetKey - Set the key.
- *      MIC_vInit - Set the key.
- *      s_vAppendByte - Append the byte to our word-sized buffer.
- *      MIC_vAppend - call s_vAppendByte.
- *      MIC_vGetMIC - Append the minimum padding and call s_vAppendByte.
- *
- * Revision History:
- *
- */
-
-#include "tmacro.h"
-#include "michael.h"
-
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Variables  --------------------------*/
-
-/*---------------------  Static Functions  --------------------------*/
-
-static void s_vClear(void);                       // Clear the internal message,
-// resets the object to the state just after construction.
-static void s_vSetKey(u32  dwK0, u32  dwK1);
-static void s_vAppendByte(unsigned char b);            // Add a single byte to the internal message
-
-/*---------------------  Export Variables  --------------------------*/
-static u32 L, R;       /* Current state */
-
-static u32 K0, K1;     /* Key */
-static u32 M;          /* Message accumulator (single word) */
-static unsigned int nBytesInM;      // # bytes in M
-
-/*---------------------  Export Functions  --------------------------*/
-
-static void s_vClear(void)
-{
-       // Reset the state to the empty message.
-       L = K0;
-       R = K1;
-       nBytesInM = 0;
-       M = 0;
-}
-
-static void s_vSetKey(u32 dwK0, u32 dwK1)
-{
-       // Set the key
-       K0 = dwK0;
-       K1 = dwK1;
-       // and reset the message
-       s_vClear();
-}
-
-static void s_vAppendByte(unsigned char b)
-{
-       // Append the byte to our word-sized buffer
-       M |= b << (8*nBytesInM);
-       nBytesInM++;
-       // Process the word if it is full.
-       if (nBytesInM >= 4) {
-               L ^= M;
-               R ^= ROL32(L, 17);
-               L += R;
-               R ^= ((L & 0xff00ff00) >> 8) | ((L & 0x00ff00ff) << 8);
-               L += R;
-               R ^= ROL32(L, 3);
-               L += R;
-               R ^= ROR32(L, 2);
-               L += R;
-               // Clear the buffer
-               M = 0;
-               nBytesInM = 0;
-       }
-}
-
-void MIC_vInit(u32 dwK0, u32 dwK1)
-{
-       // Set the key
-       s_vSetKey(dwK0, dwK1);
-}
-
-void MIC_vUnInit(void)
-{
-       // Wipe the key material
-       K0 = 0;
-       K1 = 0;
-
-       // And the other fields as well.
-       //Note that this sets (L,R) to (K0,K1) which is just fine.
-       s_vClear();
-}
-
-void MIC_vAppend(unsigned char *src, unsigned int nBytes)
-{
-       // This is simple
-       while (nBytes > 0) {
-               s_vAppendByte(*src++);
-               nBytes--;
-       }
-}
-
-void MIC_vGetMIC(u32 *pdwL, u32 *pdwR)
-{
-       // Append the minimum padding
-       s_vAppendByte(0x5a);
-       s_vAppendByte(0);
-       s_vAppendByte(0);
-       s_vAppendByte(0);
-       s_vAppendByte(0);
-       // and then zeroes until the length is a multiple of 4
-       while (nBytesInM != 0)
-               s_vAppendByte(0);
-
-       // The s_vAppendByte function has already computed the result.
-       *pdwL = L;
-       *pdwR = R;
-       // Reset to the empty message.
-       s_vClear();
-}
diff --git a/drivers/staging/vt6655/michael.h b/drivers/staging/vt6655/michael.h
deleted file mode 100644 (file)
index 86cb140..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: Michael.h
- *
- * Purpose: Reference implementation for Michael
- *          written by Niels Ferguson
- *
- * Author: Kyle Hsu
- *
- * Date: Jan 2, 2003
- *
- */
-
-#ifndef __MICHAEL_H__
-#define __MICHAEL_H__
-
-#include <linux/types.h>
-
-void MIC_vInit(u32 dwK0, u32 dwK1);
-
-void MIC_vUnInit(void);
-
-/* Append bytes to the message to be MICed */
-void MIC_vAppend(unsigned char *src, unsigned int nBytes);
-
-/* Get the MIC result. Destination should accept 8 bytes of result. */
-/* This also resets the message to empty. */
-void MIC_vGetMIC(u32 *pdwL, u32 *pdwR);
-
-/* Rotation functions on 32 bit values */
-#define ROL32(A, n)                                                    \
-       (((A) << (n)) | (((A)>>(32-(n)))  & ((1UL << (n)) - 1)))
-#define ROR32(A, n) ROL32((A), 32-(n))
-
-#endif /*__MICHAEL_H__ */
index 08241b9..e826f07 100644 (file)
  *
  */
 
-#include "ttype.h"
 #include "mac.h"
 #include "device.h"
-#include "wmgr.h"
 #include "power.h"
-#include "wcmd.h"
-#include "rxtx.h"
 #include "card.h"
 
 /*---------------------  Static Definitions -------------------------*/
@@ -73,8 +69,7 @@ PSvEnablePowerSaving(
 )
 {
        struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       unsigned short wAID = pMgmt->wCurrAID | BIT14 | BIT15;
+       u16 wAID = pDevice->current_aid | BIT(14) | BIT(15);
 
        // set period of power up before TBTT
        VNSvOutPortW(pDevice->PortOffset + MAC_REG_PWBT, C_PWBT);
@@ -83,7 +78,9 @@ PSvEnablePowerSaving(
                VNSvOutPortW(pDevice->PortOffset + MAC_REG_AIDATIM, wAID);
        } else {
                // set ATIM Window
+#if 0 /* TODO atim window */
                MACvWriteATIMW(pDevice->PortOffset, pMgmt->wCurrATIMWindow);
+#endif
        }
        // Set AutoSleep
        MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCFG, PSCFG_AUTOSLEEP);
@@ -95,22 +92,15 @@ PSvEnablePowerSaving(
                MACvRegBitsOff(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_ALBCN);
                // first time set listen next beacon
                MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_LNBCN);
-               pMgmt->wCountToWakeUp = wListenInterval;
        } else {
                // always listen beacon
                MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_ALBCN);
-               pMgmt->wCountToWakeUp = 0;
        }
 
        // enable power saving hw function
        MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PSEN);
        pDevice->bEnablePSMode = true;
 
-       /* We don't send null pkt in ad hoc mode since beacon will handle this. */
-       if (pDevice->op_mode != NL80211_IFTYPE_ADHOC &&
-           pDevice->op_mode == NL80211_IFTYPE_STATION)
-               PSbSendNullPacket(pDevice);
-
        pDevice->bPWBitOn = true;
        pr_debug("PS:Power Saving Mode Enable...\n");
 }
@@ -143,182 +133,9 @@ PSvDisablePowerSaving(
 
        pDevice->bEnablePSMode = false;
 
-       if (pDevice->op_mode == NL80211_IFTYPE_STATION)
-               PSbSendNullPacket(pDevice);
-
        pDevice->bPWBitOn = false;
 }
 
-/*+
- *
- * Routine Description:
- * Consider to power down when no more packets to tx or rx.
- *
- * Return Value:
- *    true, if power down success
- *    false, if fail
- -*/
-
-bool
-PSbConsiderPowerDown(
-       void *hDeviceContext,
-       bool bCheckRxDMA,
-       bool bCheckCountToWakeUp
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       unsigned int uIdx;
-
-       // check if already in Doze mode
-       if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS))
-               return true;
-
-       if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) {
-               // check if in TIM wake period
-               if (pMgmt->bInTIMWake)
-                       return false;
-       }
-
-       // check scan state
-       if (pDevice->bCmdRunning)
-               return false;
-
-       // Force PSEN on
-       MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PSEN);
-
-       // check if all TD are empty,
-       for (uIdx = 0; uIdx < TYPE_MAXTD; uIdx++) {
-               if (pDevice->iTDUsed[uIdx] != 0)
-                       return false;
-       }
-
-       // check if rx isr is clear
-       if (bCheckRxDMA &&
-           ((pDevice->dwIsr & ISR_RXDMA0) != 0) &&
-           ((pDevice->dwIsr & ISR_RXDMA1) != 0)) {
-               return false;
-       }
-
-       if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) {
-               if (bCheckCountToWakeUp &&
-                   (pMgmt->wCountToWakeUp == 0 || pMgmt->wCountToWakeUp == 1)) {
-                       return false;
-               }
-       }
-
-       // no Tx, no Rx isr, now go to Doze
-       MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_GO2DOZE);
-       pr_debug("Go to Doze ZZZZZZZZZZZZZZZ\n");
-       return true;
-}
-
-/*+
- *
- * Routine Description:
- * Send PS-POLL packet
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-PSvSendPSPOLL(
-       void *hDeviceContext
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject        pMgmt = pDevice->pMgmt;
-       PSTxMgmtPacket      pTxPacket = NULL;
-
-       memset(pMgmt->pbyPSPacketPool, 0, sizeof(STxMgmtPacket) + WLAN_HDR_ADDR2_LEN);
-       pTxPacket = (PSTxMgmtPacket)pMgmt->pbyPSPacketPool;
-       pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket));
-       pTxPacket->p80211Header->sA2.wFrameCtl = cpu_to_le16(
-               (
-                       WLAN_SET_FC_FTYPE(WLAN_TYPE_CTL) |
-                       WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PSPOLL) |
-                       WLAN_SET_FC_PWRMGT(0)
-));
-       pTxPacket->p80211Header->sA2.wDurationID = pMgmt->wCurrAID | BIT14 | BIT15;
-       memcpy(pTxPacket->p80211Header->sA2.abyAddr1, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN);
-       memcpy(pTxPacket->p80211Header->sA2.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
-       pTxPacket->cbMPDULen = WLAN_HDR_ADDR2_LEN;
-       pTxPacket->cbPayloadLen = 0;
-       // send the frame
-       if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING)
-               pr_debug("Send PS-Poll packet failed..\n");
-}
-
-/*+
- *
- * Routine Description:
- * Send NULL packet to AP for notification power state of STA
- *
- * Return Value:
- *    None.
- *
- -*/
-bool
-PSbSendNullPacket(
-       void *hDeviceContext
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSTxMgmtPacket      pTxPacket = NULL;
-       PSMgmtObject        pMgmt = pDevice->pMgmt;
-       unsigned int uIdx;
-
-       if (!pDevice->bLinkPass)
-               return false;
-
-       if (!pDevice->bEnablePSMode && !pDevice->fTxDataInSleep)
-               return false;
-
-       if (pDevice->bEnablePSMode) {
-               for (uIdx = 0; uIdx < TYPE_MAXTD; uIdx++) {
-                       if (pDevice->iTDUsed[uIdx] != 0)
-                               return false;
-               }
-       }
-
-       memset(pMgmt->pbyPSPacketPool, 0, sizeof(STxMgmtPacket) + WLAN_NULLDATA_FR_MAXLEN);
-       pTxPacket = (PSTxMgmtPacket)pMgmt->pbyPSPacketPool;
-       pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket));
-
-       if (pDevice->bEnablePSMode) {
-               pTxPacket->p80211Header->sA3.wFrameCtl = cpu_to_le16(
-                       (
-                               WLAN_SET_FC_FTYPE(WLAN_TYPE_DATA) |
-                               WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_NULL) |
-                               WLAN_SET_FC_PWRMGT(1)
-));
-       } else {
-               pTxPacket->p80211Header->sA3.wFrameCtl = cpu_to_le16(
-                       (
-                               WLAN_SET_FC_FTYPE(WLAN_TYPE_DATA) |
-                               WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_NULL) |
-                               WLAN_SET_FC_PWRMGT(0)
-));
-       }
-
-       if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA)
-               pTxPacket->p80211Header->sA3.wFrameCtl |= cpu_to_le16((unsigned short)WLAN_SET_FC_TODS(1));
-
-       memcpy(pTxPacket->p80211Header->sA3.abyAddr1, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN);
-       memcpy(pTxPacket->p80211Header->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
-       memcpy(pTxPacket->p80211Header->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
-       pTxPacket->cbMPDULen = WLAN_HDR_ADDR3_LEN;
-       pTxPacket->cbPayloadLen = 0;
-       // send the frame
-       if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
-               pr_debug("Send Null Packet failed !\n");
-               return false;
-       }
-
-       return true;
-}
 
 /*+
  *
@@ -336,21 +153,14 @@ PSbIsNextTBTTWakeUp(
 )
 {
        struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject        pMgmt = pDevice->pMgmt;
+       struct ieee80211_hw *hw = pDevice->hw;
+       struct ieee80211_conf *conf = &hw->conf;
        bool bWakeUp = false;
 
-       if (pMgmt->wListenInterval >= 2) {
-               if (pMgmt->wCountToWakeUp == 0)
-                       pMgmt->wCountToWakeUp = pMgmt->wListenInterval;
-
-               pMgmt->wCountToWakeUp--;
-
-               if (pMgmt->wCountToWakeUp == 1) {
-                       // Turn on wake up to listen next beacon
-                       MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_LNBCN);
-                       bWakeUp = true;
-               }
-
+       if (conf->listen_interval == 1) {
+               /* Turn on wake up to listen next beacon */
+               MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_LNBCN);
+               bWakeUp = true;
        }
 
        return bWakeUp;
index 936f171..1083341 100644 (file)
 #define     PS_FAST_INTERVAL         1         // Fast power saving listen interval
 #define     PS_MAX_INTERVAL          4         // MAX power saving listen interval
 
-bool
-PSbConsiderPowerDown(
-       void *hDeviceContext,
-       bool bCheckRxDMA,
-       bool bCheckCountToWakeUp
-);
-
 void
 PSvDisablePowerSaving(
        void *hDeviceContext
@@ -51,15 +44,6 @@ PSvEnablePowerSaving(
        unsigned short wListenInterval
 );
 
-void
-PSvSendPSPOLL(
-       void *hDeviceContext
-);
-
-bool
-PSbSendNullPacket(
-       void *hDeviceContext
-);
 
 bool
 PSbIsNextTBTTWakeUp(
diff --git a/drivers/staging/vt6655/rc4.c b/drivers/staging/vt6655/rc4.c
deleted file mode 100644 (file)
index b7819bc..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: rc4.c
- *
- * Purpose:
- *
- * Functions:
- *
- * Revision History:
- *
- * Author: Kyle Hsu
- *
- * Date: Sep 4, 2002
- *
- */
-
-#include "rc4.h"
-
-void rc4_init(PRC4Ext pRC4, unsigned char *pbyKey, unsigned int cbKey_len)
-{
-       unsigned int ust1, ust2;
-       unsigned int keyindex;
-       unsigned int stateindex;
-       unsigned char *pbyst;
-       unsigned int idx;
-
-       pbyst = pRC4->abystate;
-       pRC4->ux = 0;
-       pRC4->uy = 0;
-       for (idx = 0; idx < 256; idx++)
-               pbyst[idx] = (unsigned char)idx;
-       keyindex = 0;
-       stateindex = 0;
-       for (idx = 0; idx < 256; idx++) {
-               ust1 = pbyst[idx];
-               stateindex = (stateindex + pbyKey[keyindex] + ust1) & 0xff;
-               ust2 = pbyst[stateindex];
-               pbyst[stateindex] = (unsigned char)ust1;
-               pbyst[idx] = (unsigned char)ust2;
-               if (++keyindex >= cbKey_len)
-                       keyindex = 0;
-       }
-}
-
-unsigned int rc4_byte(PRC4Ext pRC4)
-{
-       unsigned int ux;
-       unsigned int uy;
-       unsigned int ustx, usty;
-       unsigned char *pbyst;
-
-       pbyst = pRC4->abystate;
-       ux = (pRC4->ux + 1) & 0xff;
-       ustx = pbyst[ux];
-       uy = (ustx + pRC4->uy) & 0xff;
-       usty = pbyst[uy];
-       pRC4->ux = ux;
-       pRC4->uy = uy;
-       pbyst[uy] = (unsigned char)ustx;
-       pbyst[ux] = (unsigned char)usty;
-
-       return pbyst[(ustx + usty) & 0xff];
-}
-
-void rc4_encrypt(PRC4Ext pRC4, unsigned char *pbyDest,
-                unsigned char *pbySrc, unsigned int cbData_len)
-{
-       unsigned int ii;
-
-       for (ii = 0; ii < cbData_len; ii++)
-               pbyDest[ii] = (unsigned char)(pbySrc[ii] ^ rc4_byte(pRC4));
-}
diff --git a/drivers/staging/vt6655/rc4.h b/drivers/staging/vt6655/rc4.h
deleted file mode 100644 (file)
index 74b2eed..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * File: rc4.h
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Purpose:
- *
- * Functions:
- *
- * Revision History:
- *
- * Author: Kyle Hsu
- *
- * Date: Sep 4, 2002
- *
- */
-
-#ifndef __RC4_H__
-#define __RC4_H__
-
-#include "ttype.h"
-
-/*---------------------  Export Definitions -------------------------*/
-/*---------------------  Export Types  ------------------------------*/
-typedef struct {
-       unsigned int ux;
-       unsigned int uy;
-       unsigned char abystate[256];
-} RC4Ext, *PRC4Ext;
-
-void rc4_init(PRC4Ext pRC4, unsigned char *pbyKey, unsigned int cbKey_len);
-unsigned int rc4_byte(PRC4Ext pRC4);
-void rc4_encrypt(PRC4Ext pRC4, unsigned char *pbyDest, unsigned char *pbySrc, unsigned int cbData_len);
-
-#endif //__RC4_H__
index be4ef88..e8a7372 100644 (file)
@@ -30,7 +30,6 @@
 #ifndef __RF_H__
 #define __RF_H__
 
-#include "ttype.h"
 #include "device.h"
 
 /*---------------------  Export Definitions -------------------------*/
index 7a183f5..f4da7e7 100644 (file)
 
 #include "device.h"
 #include "rxtx.h"
-#include "tether.h"
 #include "card.h"
-#include "bssdb.h"
 #include "mac.h"
 #include "baseband.h"
-#include "michael.h"
-#include "tkip.h"
-#include "tcrc.h"
-#include "wctl.h"
-#include "wroute.h"
-#include "hostap.h"
 #include "rf.h"
 
 /*---------------------  Static Definitions -------------------------*/
@@ -105,19 +97,6 @@ static const unsigned short wFB_Opt1[2][5] = {
 #define DATADUR_A_F1    13
 
 /*---------------------  Static Functions  --------------------------*/
-
-static
-void
-s_vFillTxKey(
-       struct vnt_private *pDevice,
-       unsigned char *pbyBuf,
-       unsigned char *pbyIVHead,
-       PSKeyItem  pTransmitKey,
-       unsigned char *pbyHdrBuf,
-       unsigned short wPayloadLen,
-       unsigned char *pMICHDR
-);
-
 static
 void
 s_vFillRTSHead(
@@ -127,7 +106,7 @@ s_vFillRTSHead(
        unsigned int    cbFrameLength,
        bool bNeedAck,
        bool bDisCRC,
-       PSEthernetHeader psEthHeader,
+       struct ieee80211_hdr *hdr,
        unsigned short wCurrentRate,
        unsigned char byFBOption
 );
@@ -144,26 +123,16 @@ s_vGenerateTxParameter(
        unsigned int    cbFrameSize,
        bool bNeedACK,
        unsigned int    uDMAIdx,
-       PSEthernetHeader psEthHeader,
+       void *psEthHeader,
        unsigned short wCurrentRate
 );
 
-static void s_vFillFragParameter(
-       struct vnt_private *pDevice,
-       unsigned char *pbyBuffer,
-       unsigned int    uTxType,
-       void *pvtdCurr,
-       unsigned short wFragType,
-       unsigned int    cbReqCount
-);
-
 static unsigned int
 s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType,
                  unsigned char *pbyTxBufferAddr, unsigned int cbFrameBodySize,
                  unsigned int uDMAIdx, PSTxDesc pHeadTD,
-                 PSEthernetHeader psEthHeader, unsigned char *pPacket,
-                 bool bNeedEncrypt, PSKeyItem pTransmitKey,
-                 unsigned int uNodeIndex, unsigned int *puMACfragNum);
+                 unsigned char *pPacket, unsigned int uNodeIndex,
+                 unsigned int *puMACfragNum);
 
 static
 __le16
@@ -178,165 +147,12 @@ s_uFillDataHead(
        unsigned int cbLastFragmentSize,
        unsigned int uMACfragNum,
        unsigned char byFBOption,
-       unsigned short wCurrentRate
+       unsigned short wCurrentRate,
+       bool is_pspoll
 );
 
 /*---------------------  Export Variables  --------------------------*/
 
-static
-void
-s_vFillTxKey(
-       struct vnt_private *pDevice,
-       unsigned char *pbyBuf,
-       unsigned char *pbyIVHead,
-       PSKeyItem  pTransmitKey,
-       unsigned char *pbyHdrBuf,
-       unsigned short wPayloadLen,
-       unsigned char *pMICHDR
-)
-{
-       struct vnt_mic_hdr *mic_hdr = (struct vnt_mic_hdr *)pMICHDR;
-       unsigned long *pdwIV = (unsigned long *)pbyIVHead;
-       unsigned long *pdwExtIV = (unsigned long *)((unsigned char *)pbyIVHead+4);
-       PS802_11Header  pMACHeader = (PS802_11Header)pbyHdrBuf;
-       unsigned long dwRevIVCounter;
-       unsigned char byKeyIndex = 0;
-
-       //Fill TXKEY
-       if (pTransmitKey == NULL)
-               return;
-
-       dwRevIVCounter = cpu_to_le32(pDevice->dwIVCounter);
-       *pdwIV = pDevice->dwIVCounter;
-       byKeyIndex = pTransmitKey->dwKeyIndex & 0xf;
-
-       if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) {
-               if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN) {
-                       memcpy(pDevice->abyPRNG, (unsigned char *)&(dwRevIVCounter), 3);
-                       memcpy(pDevice->abyPRNG+3, pTransmitKey->abyKey, pTransmitKey->uKeyLength);
-               } else {
-                       memcpy(pbyBuf, (unsigned char *)&(dwRevIVCounter), 3);
-                       memcpy(pbyBuf+3, pTransmitKey->abyKey, pTransmitKey->uKeyLength);
-                       if (pTransmitKey->uKeyLength == WLAN_WEP40_KEYLEN) {
-                               memcpy(pbyBuf+8, (unsigned char *)&(dwRevIVCounter), 3);
-                               memcpy(pbyBuf+11, pTransmitKey->abyKey, pTransmitKey->uKeyLength);
-                       }
-                       memcpy(pDevice->abyPRNG, pbyBuf, 16);
-               }
-               // Append IV after Mac Header
-               *pdwIV &= WEP_IV_MASK;//00000000 11111111 11111111 11111111
-               *pdwIV |= (unsigned long)byKeyIndex << 30;
-               *pdwIV = cpu_to_le32(*pdwIV);
-               pDevice->dwIVCounter++;
-               if (pDevice->dwIVCounter > WEP_IV_MASK)
-                       pDevice->dwIVCounter = 0;
-
-       } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) {
-               pTransmitKey->wTSC15_0++;
-               if (pTransmitKey->wTSC15_0 == 0)
-                       pTransmitKey->dwTSC47_16++;
-
-               TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr,
-                           pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG);
-               memcpy(pbyBuf, pDevice->abyPRNG, 16);
-               // Make IV
-               memcpy(pdwIV, pDevice->abyPRNG, 3);
-
-               *(pbyIVHead+3) = (unsigned char)(((byKeyIndex << 6) & 0xc0) | 0x20); // 0x20 is ExtIV
-               // Append IV&ExtIV after Mac Header
-               *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16);
-               pr_debug("vFillTxKey()---- pdwExtIV: %lx\n", *pdwExtIV);
-
-       } else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) {
-               pTransmitKey->wTSC15_0++;
-               if (pTransmitKey->wTSC15_0 == 0)
-                       pTransmitKey->dwTSC47_16++;
-
-               memcpy(pbyBuf, pTransmitKey->abyKey, 16);
-
-               // Make IV
-               *pdwIV = 0;
-               *(pbyIVHead+3) = (unsigned char)(((byKeyIndex << 6) & 0xc0) | 0x20); // 0x20 is ExtIV
-               *pdwIV |= cpu_to_le16((unsigned short)(pTransmitKey->wTSC15_0));
-               //Append IV&ExtIV after Mac Header
-               *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16);
-
-               /* MICHDR0 */
-               mic_hdr->id = 0x59;
-               mic_hdr->tx_priority = 0;
-               memcpy(mic_hdr->mic_addr2, pMACHeader->abyAddr2, ETH_ALEN);
-
-               /* ccmp pn big endian order */
-               mic_hdr->ccmp_pn[0] = (u8)(pTransmitKey->dwTSC47_16 >> 24);
-               mic_hdr->ccmp_pn[1] = (u8)(pTransmitKey->dwTSC47_16 >> 16);
-               mic_hdr->ccmp_pn[2] = (u8)(pTransmitKey->dwTSC47_16 >> 8);
-               mic_hdr->ccmp_pn[3] = (u8)pTransmitKey->dwTSC47_16;
-               mic_hdr->ccmp_pn[4] = (u8)(pTransmitKey->wTSC15_0 >> 8);
-               mic_hdr->ccmp_pn[5] = (u8)pTransmitKey->wTSC15_0;
-
-               /* MICHDR1 */
-               mic_hdr->payload_len = cpu_to_be16(wPayloadLen);
-
-               if (pDevice->bLongHeader)
-                       mic_hdr->hlen = cpu_to_be16(28);
-               else
-                       mic_hdr->hlen = cpu_to_be16(22);
-
-               memcpy(mic_hdr->addr1, pMACHeader->abyAddr1, ETH_ALEN);
-               memcpy(mic_hdr->addr2, pMACHeader->abyAddr2, ETH_ALEN);
-
-               /* MICHDR2 */
-               memcpy(mic_hdr->addr3, pMACHeader->abyAddr3, ETH_ALEN);
-               mic_hdr->frame_control =
-                               cpu_to_le16(pMACHeader->wFrameCtl & 0xc78f);
-               mic_hdr->seq_ctrl = cpu_to_le16(pMACHeader->wSeqCtl & 0xf);
-
-               if (pDevice->bLongHeader)
-                       memcpy(mic_hdr->addr4, pMACHeader->abyAddr4, ETH_ALEN);
-       }
-}
-
-static
-void
-s_vSWencryption(
-       struct vnt_private *pDevice,
-       PSKeyItem           pTransmitKey,
-       unsigned char *pbyPayloadHead,
-       unsigned short wPayloadSize
-)
-{
-       unsigned int cbICVlen = 4;
-       unsigned long dwICV = 0xFFFFFFFFL;
-       unsigned long *pdwICV;
-
-       if (pTransmitKey == NULL)
-               return;
-
-       if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) {
-               //=======================================================================
-               // Append ICV after payload
-               dwICV = CRCdwGetCrc32Ex(pbyPayloadHead, wPayloadSize, dwICV);//ICV(Payload)
-               pdwICV = (unsigned long *)(pbyPayloadHead + wPayloadSize);
-               // finally, we must invert dwCRC to get the correct answer
-               *pdwICV = cpu_to_le32(~dwICV);
-               // RC4 encryption
-               rc4_init(&pDevice->SBox, pDevice->abyPRNG, pTransmitKey->uKeyLength + 3);
-               rc4_encrypt(&pDevice->SBox, pbyPayloadHead, pbyPayloadHead, wPayloadSize+cbICVlen);
-               //=======================================================================
-       } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) {
-               //=======================================================================
-               //Append ICV after payload
-               dwICV = CRCdwGetCrc32Ex(pbyPayloadHead, wPayloadSize, dwICV);//ICV(Payload)
-               pdwICV = (unsigned long *)(pbyPayloadHead + wPayloadSize);
-               // finally, we must invert dwCRC to get the correct answer
-               *pdwICV = cpu_to_le32(~dwICV);
-               // RC4 encryption
-               rc4_init(&pDevice->SBox, pDevice->abyPRNG, TKIP_KEY_LEN);
-               rc4_encrypt(&pDevice->SBox, pbyPayloadHead, pbyPayloadHead, wPayloadSize+cbICVlen);
-               //=======================================================================
-       }
-}
-
 static __le16 vnt_time_stamp_off(struct vnt_private *priv, u16 rate)
 {
        return cpu_to_le16(wTimeStampOff[priv->byPreambleType % 2]
@@ -683,7 +499,8 @@ s_uFillDataHead(
        unsigned int cbLastFragmentSize,
        unsigned int uMACfragNum,
        unsigned char byFBOption,
-       unsigned short wCurrentRate
+       unsigned short wCurrentRate,
+       bool is_pspoll
 )
 {
 
@@ -702,15 +519,24 @@ s_uFillDataHead(
                                          pDevice->byTopCCKBasicRate,
                                          PK_TYPE_11B, &buf->b);
 
-                       /* Get Duration and TimeStamp */
-                       buf->duration_a = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength,
-                                                                             byPktType, wCurrentRate, bNeedAck, uFragIdx,
-                                                                             cbLastFragmentSize, uMACfragNum,
-                                                                             byFBOption));
-                       buf->duration_b = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength,
-                                                                             PK_TYPE_11B, pDevice->byTopCCKBasicRate,
-                                                                             bNeedAck, uFragIdx, cbLastFragmentSize,
-                                                                             uMACfragNum, byFBOption));
+                       if (is_pspoll) {
+                               __le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15));
+
+                               buf->duration_a = dur;
+                               buf->duration_b = dur;
+                       } else {
+                               /* Get Duration and TimeStamp */
+                               buf->duration_a =
+                                       cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength,
+                                                                           byPktType, wCurrentRate, bNeedAck, uFragIdx,
+                                                                           cbLastFragmentSize, uMACfragNum,
+                                                                           byFBOption));
+                               buf->duration_b =
+                                       cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength,
+                                                                           PK_TYPE_11B, pDevice->byTopCCKBasicRate,
+                                                                           bNeedAck, uFragIdx, cbLastFragmentSize,
+                                                                           uMACfragNum, byFBOption));
+                       }
 
                        buf->time_stamp_off_a = vnt_time_stamp_off(pDevice, wCurrentRate);
                        buf->time_stamp_off_b = vnt_time_stamp_off(pDevice, pDevice->byTopCCKBasicRate);
@@ -764,11 +590,18 @@ s_uFillDataHead(
                        vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate,
                                          byPktType, &buf->ab);
 
-                       /* Get Duration and TimeStampOff */
-                       buf->duration = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType,
+                       if (is_pspoll) {
+                               __le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15));
+
+                               buf->duration = dur;
+                       } else {
+                               /* Get Duration and TimeStampOff */
+                               buf->duration =
+                                       cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType,
                                                                            wCurrentRate, bNeedAck, uFragIdx,
                                                                            cbLastFragmentSize, uMACfragNum,
                                                                            byFBOption));
+                       }
 
                        buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate);
                        return buf->duration;
@@ -778,17 +611,27 @@ s_uFillDataHead(
                /* Get SignalField, ServiceField & Length */
                vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate,
                                  byPktType, &buf->ab);
-               /* Get Duration and TimeStampOff */
-               buf->duration = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, byPktType,
+
+               if (is_pspoll) {
+                       __le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15));
+
+                       buf->duration = dur;
+               } else {
+                       /* Get Duration and TimeStampOff */
+                       buf->duration =
+                               cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, byPktType,
                                                                    wCurrentRate, bNeedAck, uFragIdx,
                                                                    cbLastFragmentSize, uMACfragNum,
                                                                    byFBOption));
+               }
+
                buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate);
                return buf->duration;
        }
        return 0;
 }
 
+
 static
 void
 s_vFillRTSHead(
@@ -798,7 +641,7 @@ s_vFillRTSHead(
        unsigned int cbFrameLength,
        bool bNeedAck,
        bool bDisCRC,
-       PSEthernetHeader psEthHeader,
+       struct ieee80211_hdr *hdr,
        unsigned short wCurrentRate,
        unsigned char byFBOption
 )
@@ -850,18 +693,8 @@ s_vFillRTSHead(
                                        cpu_to_le16(IEEE80211_FTYPE_CTL |
                                                    IEEE80211_STYPE_RTS);
 
-
-                       if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) ||
-                           (pDevice->op_mode == NL80211_IFTYPE_AP)) {
-                               memcpy(&buf->data.ra, psEthHeader->abyDstAddr, ETH_ALEN);
-                       } else {
-                               memcpy(&buf->data.ra, pDevice->abyBSSID, ETH_ALEN);
-                       }
-                       if (pDevice->op_mode == NL80211_IFTYPE_AP)
-                               memcpy(&buf->data.ta, pDevice->abyBSSID, ETH_ALEN);
-                       else
-                               memcpy(&buf->data.ta, psEthHeader->abySrcAddr, ETH_ALEN);
-
+                       ether_addr_copy(buf->data.ra, hdr->addr1);
+                       ether_addr_copy(buf->data.ta, hdr->addr2);
                } else {
                        struct vnt_rts_g_fb *buf = pvRTS;
                        /* Get SignalField, ServiceField & Length */
@@ -914,19 +747,8 @@ s_vFillRTSHead(
                                        cpu_to_le16(IEEE80211_FTYPE_CTL |
                                                    IEEE80211_STYPE_RTS);
 
-
-                       if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) ||
-                           (pDevice->op_mode == NL80211_IFTYPE_AP)) {
-                               memcpy(&buf->data.ra, psEthHeader->abyDstAddr, ETH_ALEN);
-                       } else {
-                               memcpy(&buf->data.ra, pDevice->abyBSSID, ETH_ALEN);
-                       }
-
-                       if (pDevice->op_mode == NL80211_IFTYPE_AP)
-                               memcpy(&buf->data.ta, pDevice->abyBSSID, ETH_ALEN);
-                       else
-                               memcpy(&buf->data.ta, psEthHeader->abySrcAddr, ETH_ALEN);
-
+                       ether_addr_copy(buf->data.ra, hdr->addr1);
+                       ether_addr_copy(buf->data.ta, hdr->addr2);
                } // if (byFBOption == AUTO_FB_NONE)
        } else if (byPktType == PK_TYPE_11A) {
                if (byFBOption == AUTO_FB_NONE) {
@@ -947,19 +769,8 @@ s_vFillRTSHead(
                                        cpu_to_le16(IEEE80211_FTYPE_CTL |
                                                    IEEE80211_STYPE_RTS);
 
-
-                       if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) ||
-                           (pDevice->op_mode == NL80211_IFTYPE_AP)) {
-                               memcpy(&buf->data.ra, psEthHeader->abyDstAddr, ETH_ALEN);
-                       } else {
-                               memcpy(&buf->data.ra, pDevice->abyBSSID, ETH_ALEN);
-                       }
-
-                       if (pDevice->op_mode == NL80211_IFTYPE_AP)
-                               memcpy(&buf->data.ta, pDevice->abyBSSID, ETH_ALEN);
-                       else
-                               memcpy(&buf->data.ta, psEthHeader->abySrcAddr, ETH_ALEN);
-
+                       ether_addr_copy(buf->data.ra, hdr->addr1);
+                       ether_addr_copy(buf->data.ta, hdr->addr2);
                } else {
                        struct vnt_rts_a_fb *buf = pvRTS;
                        /* Get SignalField, ServiceField & Length */
@@ -988,16 +799,8 @@ s_vFillRTSHead(
                                        cpu_to_le16(IEEE80211_FTYPE_CTL |
                                                    IEEE80211_STYPE_RTS);
 
-                       if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) ||
-                           (pDevice->op_mode == NL80211_IFTYPE_AP)) {
-                               memcpy(&buf->data.ra, psEthHeader->abyDstAddr, ETH_ALEN);
-                       } else {
-                               memcpy(&buf->data.ra, pDevice->abyBSSID, ETH_ALEN);
-                       }
-                       if (pDevice->op_mode == NL80211_IFTYPE_AP)
-                               memcpy(&buf->data.ta, pDevice->abyBSSID, ETH_ALEN);
-                       else
-                               memcpy(&buf->data.ta, psEthHeader->abySrcAddr, ETH_ALEN);
+                       ether_addr_copy(buf->data.ra, hdr->addr1);
+                       ether_addr_copy(buf->data.ta, hdr->addr2);
                }
        } else if (byPktType == PK_TYPE_11B) {
                struct vnt_rts_ab *buf = pvRTS;
@@ -1016,17 +819,8 @@ s_vFillRTSHead(
                buf->data.frame_control =
                        cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
 
-               if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) ||
-                   (pDevice->op_mode == NL80211_IFTYPE_AP)) {
-                       memcpy(&buf->data.ra, psEthHeader->abyDstAddr, ETH_ALEN);
-               } else {
-                       memcpy(&buf->data.ra, pDevice->abyBSSID, ETH_ALEN);
-               }
-
-               if (pDevice->op_mode == NL80211_IFTYPE_AP)
-                       memcpy(&buf->data.ta, pDevice->abyBSSID, ETH_ALEN);
-               else
-                       memcpy(&buf->data.ta, psEthHeader->abySrcAddr, ETH_ALEN);
+               ether_addr_copy(buf->data.ra, hdr->addr1);
+               ether_addr_copy(buf->data.ta, hdr->addr2);
        }
 }
 
@@ -1093,7 +887,8 @@ s_vFillCTSHead(
 
                        buf->reserved2 = 0x0;
 
-                       memcpy(&buf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN);
+                       ether_addr_copy(buf->data.ra,
+                                       pDevice->abyCurrentNetAddr);
                } else { //if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA)
                        struct vnt_cts *buf = pvCTS;
                        /* Get SignalField, ServiceField & Length */
@@ -1116,7 +911,8 @@ s_vFillCTSHead(
                                            IEEE80211_STYPE_CTS);
 
                        buf->reserved2 = 0x0;
-                       memcpy(&buf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN);
+                       ether_addr_copy(buf->data.ra,
+                                       pDevice->abyCurrentNetAddr);
                }
        }
 }
@@ -1156,11 +952,10 @@ s_vGenerateTxParameter(
        unsigned int cbFrameSize,
        bool bNeedACK,
        unsigned int uDMAIdx,
-       PSEthernetHeader psEthHeader,
+       void *psEthHeader,
        unsigned short wCurrentRate
 )
 {
-       unsigned int cbMACHdLen = WLAN_HDR_ADDR3_LEN; //24
        unsigned short wFifoCtl;
        bool bDisCRC = false;
        unsigned char byFBOption = AUTO_FB_NONE;
@@ -1178,9 +973,6 @@ s_vGenerateTxParameter(
        else if (wFifoCtl & FIFOCTL_AUTO_FB_1)
                byFBOption = AUTO_FB_1;
 
-       if (pDevice->bLongHeader)
-               cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6;
-
        if (!pvRrvTime)
                return;
 
@@ -1237,90 +1029,31 @@ s_vGenerateTxParameter(
        }
 }
 
-static
-void
-s_vFillFragParameter(
-       struct vnt_private *pDevice,
-       unsigned char *pbyBuffer,
-       unsigned int uTxType,
-       void *pvtdCurr,
-       unsigned short wFragType,
-       unsigned int cbReqCount
-)
-{
-       PSTxBufHead pTxBufHead = (PSTxBufHead) pbyBuffer;
-
-       if (uTxType == TYPE_SYNCDMA) {
-               PSTxSyncDesc ptdCurr = (PSTxSyncDesc)pvtdCurr;
-
-               //Set FIFOCtl & TimeStamp in TxSyncDesc
-               ptdCurr->m_wFIFOCtl = pTxBufHead->wFIFOCtl;
-               ptdCurr->m_wTimeStamp = pTxBufHead->wTimeStamp;
-               //Set TSR1 & ReqCount in TxDescHead
-               ptdCurr->m_td1TD1.wReqCount = cpu_to_le16((unsigned short)(cbReqCount));
-               if (wFragType == FRAGCTL_ENDFRAG) //Last Fragmentation
-                       ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP | EDMSDU);
-               else
-                       ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP);
-       } else {
-               PSTxDesc ptdCurr = (PSTxDesc)pvtdCurr;
-               //Set TSR1 & ReqCount in TxDescHead
-               ptdCurr->m_td1TD1.wReqCount = cpu_to_le16((unsigned short)(cbReqCount));
-               if (wFragType == FRAGCTL_ENDFRAG) //Last Fragmentation
-                       ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP | EDMSDU);
-               else
-                       ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP);
-       }
-
-       pTxBufHead->wFragCtl |= (unsigned short)wFragType;//0x0001; //0000 0000 0000 0001
-}
-
 static unsigned int
 s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType,
                  unsigned char *pbyTxBufferAddr, unsigned int cbFrameBodySize,
                  unsigned int uDMAIdx, PSTxDesc pHeadTD,
-                 PSEthernetHeader psEthHeader, unsigned char *pPacket,
-                 bool bNeedEncrypt, PSKeyItem pTransmitKey,
-                 unsigned int uNodeIndex, unsigned int *puMACfragNum)
+                 unsigned char *pPacket, unsigned int is_pspoll,
+                 unsigned int *puMACfragNum)
 {
-       unsigned int cbMACHdLen;
+       PDEVICE_TD_INFO td_info = pHeadTD->pTDInfo;
+       struct sk_buff *skb = td_info->skb;
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+       struct vnt_tx_fifo_head *tx_buffer_head =
+                       (struct vnt_tx_fifo_head *)td_info->buf;
+       u16 fifo_ctl = le16_to_cpu(tx_buffer_head->fifo_ctl);
        unsigned int cbFrameSize;
-       unsigned int cbFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS
-       unsigned int cbFragPayloadSize;
-       unsigned int cbLastFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS
-       unsigned int cbLastFragPayloadSize;
-       unsigned int uFragIdx;
-       unsigned char *pbyPayloadHead;
-       unsigned char *pbyIVHead;
-       unsigned char *pbyMacHdr;
-       unsigned short wFragType; //00:Non-Frag, 01:Start, 10:Mid, 11:Last
        __le16 uDuration;
        unsigned char *pbyBuffer;
-       unsigned int cbIVlen = 0;
-       unsigned int cbICVlen = 0;
-       unsigned int cbMIClen = 0;
-       unsigned int cbFCSlen = 4;
-       unsigned int cb802_1_H_len = 0;
        unsigned int uLength = 0;
-       unsigned int uTmpLen = 0;
        unsigned int cbMICHDR = 0;
-       u32 dwMICKey0, dwMICKey1;
-       u32 dwMIC_Priority;
-       u32 *pdwMIC_L;
-       u32 *pdwMIC_R;
-       u32 dwSafeMIC_L, dwSafeMIC_R; /* Fix "Last Frag Size" < "MIC length". */
-       bool bMIC2Frag = false;
-       unsigned int uMICFragLen = 0;
        unsigned int uMACfragNum = 1;
        unsigned int uPadding = 0;
        unsigned int cbReqCount = 0;
-
-       bool bNeedACK;
-       bool bRTS;
-       bool bIsAdhoc;
-       unsigned char *pbyType;
+       bool bNeedACK = (bool)(fifo_ctl & FIFOCTL_NEEDACK);
+       bool bRTS = (bool)(fifo_ctl & FIFOCTL_RTS);
        PSTxDesc       ptdCurr;
-       PSTxBufHead    psTxBufHd = (PSTxBufHead) pbyTxBufferAddr;
        unsigned int cbHeaderLength = 0;
        void *pvRrvTime;
        struct vnt_mic_hdr *pMICHDR;
@@ -1328,72 +1061,35 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType,
        void *pvCTS;
        void *pvTxDataHd;
        unsigned short wTxBufSize;   // FFinfo size
-       unsigned int uTotalCopyLength = 0;
        unsigned char byFBOption = AUTO_FB_NONE;
-       bool bIsWEP256 = false;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
 
        pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL;
 
-       if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) ||
-           (pDevice->op_mode == NL80211_IFTYPE_AP)) {
-               if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0])))
-                       bNeedACK = false;
-               else
-                       bNeedACK = true;
-               bIsAdhoc = true;
-       } else {
-               // MSDUs in Infra mode always need ACK
-               bNeedACK = true;
-               bIsAdhoc = false;
-       }
+       cbFrameSize = skb->len + 4;
 
-       if (pDevice->bLongHeader)
-               cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6;
-       else
-               cbMACHdLen = WLAN_HDR_ADDR3_LEN;
-
-       if ((bNeedEncrypt == true) && (pTransmitKey != NULL)) {
-               if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) {
-                       cbIVlen = 4;
-                       cbICVlen = 4;
-                       if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN)
-                               bIsWEP256 = true;
-               }
-               if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) {
-                       cbIVlen = 8;//IV+ExtIV
-                       cbMIClen = 8;
-                       cbICVlen = 4;
-               }
-               if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) {
-                       cbIVlen = 8;//RSN Header
-                       cbICVlen = 8;//MIC
+       if (info->control.hw_key) {
+               switch (info->control.hw_key->cipher) {
+               case WLAN_CIPHER_SUITE_CCMP:
                        cbMICHDR = sizeof(struct vnt_mic_hdr);
+               default:
+                       break;
                }
+
+               cbFrameSize += info->control.hw_key->icv_len;
+
                if (pDevice->byLocalID > REV_ID_VT3253_A1) {
                        //MAC Header should be padding 0 to DW alignment.
-                       uPadding = 4 - (cbMACHdLen%4);
+                       uPadding = 4 - (ieee80211_get_hdrlen_from_skb(skb) % 4);
                        uPadding %= 4;
                }
        }
 
-       cbFrameSize = cbMACHdLen + cbIVlen + (cbFrameBodySize + cbMIClen) + cbICVlen + cbFCSlen;
-
-       if ((bNeedACK == false) ||
-           (cbFrameSize < pDevice->wRTSThreshold) ||
-           ((cbFrameSize >= pDevice->wFragmentationThreshold) && (pDevice->wFragmentationThreshold <= pDevice->wRTSThreshold))
-) {
-               bRTS = false;
-       } else {
-               bRTS = true;
-               psTxBufHd->wFIFOCtl |= (FIFOCTL_RTS | FIFOCTL_LRETRY);
-       }
        //
        // Use for AUTO FALL BACK
        //
-       if (psTxBufHd->wFIFOCtl & FIFOCTL_AUTO_FB_0)
+       if (fifo_ctl & FIFOCTL_AUTO_FB_0)
                byFBOption = AUTO_FB_0;
-       else if (psTxBufHd->wFIFOCtl & FIFOCTL_AUTO_FB_1)
+       else if (fifo_ctl & FIFOCTL_AUTO_FB_1)
                byFBOption = AUTO_FB_1;
 
        //////////////////////////////////////////////////////
@@ -1487,1477 +1183,349 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType,
                        }
                } // Auto Fall Back
        }
-       memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderLength - wTxBufSize));
-
-//////////////////////////////////////////////////////////////////
-       if ((bNeedEncrypt == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) {
-               if (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
-                       dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[16]);
-                       dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[20]);
-               } else if ((pTransmitKey->dwKeyIndex & AUTHENTICATOR_KEY) != 0) {
-                       dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[16]);
-                       dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[20]);
-               } else {
-                       dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[24]);
-                       dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[28]);
-               }
-               // DO Software Michael
-               MIC_vInit(dwMICKey0, dwMICKey1);
-               MIC_vAppend((unsigned char *)&(psEthHeader->abyDstAddr[0]), 12);
-               dwMIC_Priority = 0;
-               MIC_vAppend((unsigned char *)&dwMIC_Priority, 4);
-               pr_debug("MIC KEY: %X, %X\n", dwMICKey0, dwMICKey1);
-       }
-
-///////////////////////////////////////////////////////////////////
-
-       pbyMacHdr = (unsigned char *)(pbyTxBufferAddr + cbHeaderLength);
-       pbyPayloadHead = (unsigned char *)(pbyMacHdr + cbMACHdLen + uPadding + cbIVlen);
-       pbyIVHead = (unsigned char *)(pbyMacHdr + cbMACHdLen + uPadding);
-
-       if ((cbFrameSize > pDevice->wFragmentationThreshold) && (bNeedACK == true) && (bIsWEP256 == false)) {
-               // Fragmentation
-               // FragThreshold = Fragment size(Hdr+(IV)+fragment payload+(MIC)+(ICV)+FCS)
-               cbFragmentSize = pDevice->wFragmentationThreshold;
-               cbFragPayloadSize = cbFragmentSize - cbMACHdLen - cbIVlen - cbICVlen - cbFCSlen;
-               //FragNum = (FrameSize-(Hdr+FCS))/(Fragment Size -(Hrd+FCS)))
-               uMACfragNum = (unsigned short) ((cbFrameBodySize + cbMIClen) / cbFragPayloadSize);
-               cbLastFragPayloadSize = (cbFrameBodySize + cbMIClen) % cbFragPayloadSize;
-               if (cbLastFragPayloadSize == 0)
-                       cbLastFragPayloadSize = cbFragPayloadSize;
-               else
-                       uMACfragNum++;
-
-               //[Hdr+(IV)+last fragment payload+(MIC)+(ICV)+FCS]
-               cbLastFragmentSize = cbMACHdLen + cbLastFragPayloadSize + cbIVlen + cbICVlen + cbFCSlen;
-
-               for (uFragIdx = 0; uFragIdx < uMACfragNum; uFragIdx++) {
-                       if (uFragIdx == 0) {
-                               //=========================
-                               //    Start Fragmentation
-                               //=========================
-                               pr_debug("Start Fragmentation...\n");
-                               wFragType = FRAGCTL_STAFRAG;
-
-                               //Fill FIFO,RrvTime,RTS,and CTS
-                               s_vGenerateTxParameter(pDevice, byPktType, (void *)psTxBufHd, pvRrvTime, pvRTS, pvCTS,
-                                                      cbFragmentSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate);
-                               //Fill DataHead
-                               uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFragmentSize, uDMAIdx, bNeedACK,
-                                                           uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption, pDevice->wCurrentRate);
-                               // Generate TX MAC Header
-                               vGenerateMACHeader(pDevice, pbyMacHdr, uDuration, psEthHeader, bNeedEncrypt,
-                                                  wFragType, uDMAIdx, uFragIdx);
-
-                               if (bNeedEncrypt == true) {
-                                       //Fill TXKEY
-                                       s_vFillTxKey(pDevice, (unsigned char *)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey,
-                                                    pbyMacHdr, (unsigned short)cbFragPayloadSize, (unsigned char *)pMICHDR);
-                                       //Fill IV(ExtIV,RSNHDR)
-                                       if (pDevice->bEnableHostWEP) {
-                                               pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16;
-                                               pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0;
-                                       }
-                               }
-
-                               // 802.1H
-                               if (ntohs(psEthHeader->wType) > ETH_DATA_LEN) {
-                                       if ((psEthHeader->wType == TYPE_PKT_IPX) ||
-                                           (psEthHeader->wType == cpu_to_le16(0xF380))) {
-                                               memcpy((unsigned char *)(pbyPayloadHead), &pDevice->abySNAP_Bridgetunnel[0], 6);
-                                       } else {
-                                               memcpy((unsigned char *)(pbyPayloadHead), &pDevice->abySNAP_RFC1042[0], 6);
-                                       }
-                                       pbyType = (unsigned char *)(pbyPayloadHead + 6);
-                                       memcpy(pbyType, &(psEthHeader->wType), sizeof(unsigned short));
-                                       cb802_1_H_len = 8;
-                               }
-
-                               cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cbFragPayloadSize;
-                               //---------------------------
-                               // S/W or H/W Encryption
-                               //---------------------------
-                               pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf;
-
-                               uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cb802_1_H_len;
-                               //copy TxBufferHeader + MacHeader to desc
-                               memcpy(pbyBuffer, (void *)psTxBufHd, uLength);
-
-                               // Copy the Packet into a tx Buffer
-                               memcpy((pbyBuffer + uLength), (pPacket + 14), (cbFragPayloadSize - cb802_1_H_len));
-
-                               uTotalCopyLength += cbFragPayloadSize - cb802_1_H_len;
-
-                               if ((bNeedEncrypt == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) {
-                                       pr_debug("Start MIC: %d\n",
-                                                cbFragPayloadSize);
-                                       MIC_vAppend((pbyBuffer + uLength - cb802_1_H_len), cbFragPayloadSize);
-
-                               }
-
-                               //---------------------------
-                               // S/W Encryption
-                               //---------------------------
-                               if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) {
-                                       if (bNeedEncrypt) {
-                                               s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength - cb802_1_H_len), (unsigned short)cbFragPayloadSize);
-                                               cbReqCount += cbICVlen;
-                                       }
-                               }
-
-                               ptdCurr = (PSTxDesc)pHeadTD;
-                               //--------------------
-                               //1.Set TSR1 & ReqCount in TxDescHead
-                               //2.Set FragCtl in TxBufferHead
-                               //3.Set Frame Control
-                               //4.Set Sequence Control
-                               //5.Get S/W generate FCS
-                               //--------------------
-                               s_vFillFragParameter(pDevice, pbyBuffer, uDMAIdx, (void *)ptdCurr, wFragType, cbReqCount);
-
-                               ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding;
-                               ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength;
-                               ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma;
-                               ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma);
-                               pDevice->iTDUsed[uDMAIdx]++;
-                               pHeadTD = ptdCurr->next;
-                       } else if (uFragIdx == (uMACfragNum-1)) {
-                               //=========================
-                               //    Last Fragmentation
-                               //=========================
-                               pr_debug("Last Fragmentation...\n");
-
-                               wFragType = FRAGCTL_ENDFRAG;
-
-                               //Fill FIFO,RrvTime,RTS,and CTS
-                               s_vGenerateTxParameter(pDevice, byPktType, (void *)psTxBufHd, pvRrvTime, pvRTS, pvCTS,
-                                                      cbLastFragmentSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate);
-                               //Fill DataHead
-                               uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbLastFragmentSize, uDMAIdx, bNeedACK,
-                                                           uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption, pDevice->wCurrentRate);
-
-                               // Generate TX MAC Header
-                               vGenerateMACHeader(pDevice, pbyMacHdr, uDuration, psEthHeader, bNeedEncrypt,
-                                                  wFragType, uDMAIdx, uFragIdx);
-
-                               if (bNeedEncrypt == true) {
-                                       //Fill TXKEY
-                                       s_vFillTxKey(pDevice, (unsigned char *)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey,
-                                                    pbyMacHdr, (unsigned short)cbLastFragPayloadSize, (unsigned char *)pMICHDR);
-
-                                       if (pDevice->bEnableHostWEP) {
-                                               pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16;
-                                               pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0;
-                                       }
-
-                               }
-
-                               cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cbLastFragPayloadSize;
-                               //---------------------------
-                               // S/W or H/W Encryption
-                               //---------------------------
-
-                               pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf;
-
-                               uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen;
-
-                               //copy TxBufferHeader + MacHeader to desc
-                               memcpy(pbyBuffer, (void *)psTxBufHd, uLength);
-
-                               // Copy the Packet into a tx Buffer
-                               if (bMIC2Frag == false) {
-                                       memcpy((pbyBuffer + uLength),
-                                              (pPacket + 14 + uTotalCopyLength),
-                                              (cbLastFragPayloadSize - cbMIClen)
-);
-                                       //TODO check uTmpLen !
-                                       uTmpLen = cbLastFragPayloadSize - cbMIClen;
-
-                               }
-                               if ((bNeedEncrypt == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) {
-                                       pr_debug("LAST: uMICFragLen:%d, cbLastFragPayloadSize:%d, uTmpLen:%d\n",
-                                                uMICFragLen,
-                                                cbLastFragPayloadSize,
-                                                uTmpLen);
-
-                                       if (bMIC2Frag == false) {
-                                               if (uTmpLen != 0)
-                                                       MIC_vAppend((pbyBuffer + uLength), uTmpLen);
-                                               pdwMIC_L = (u32 *)(pbyBuffer + uLength + uTmpLen);
-                                               pdwMIC_R = (u32 *)(pbyBuffer + uLength + uTmpLen + 4);
-                                               MIC_vGetMIC(pdwMIC_L, pdwMIC_R);
-                                               pr_debug("Last MIC:%X, %X\n",
-                                                        *pdwMIC_L, *pdwMIC_R);
-                                       } else {
-                                               if (uMICFragLen >= 4) {
-                                                       memcpy((pbyBuffer + uLength), ((unsigned char *)&dwSafeMIC_R + (uMICFragLen - 4)),
-                                                              (cbMIClen - uMICFragLen));
-                                                       pr_debug("LAST: uMICFragLen >= 4: %X, %d\n",
-                                                                *(unsigned char *)((unsigned char *)&dwSafeMIC_R + (uMICFragLen - 4)),
-                                                                (cbMIClen - uMICFragLen));
-
-                                               } else {
-                                                       memcpy((pbyBuffer + uLength), ((unsigned char *)&dwSafeMIC_L + uMICFragLen),
-                                                              (4 - uMICFragLen));
-                                                       memcpy((pbyBuffer + uLength + (4 - uMICFragLen)), &dwSafeMIC_R, 4);
-                                                       pr_debug("LAST: uMICFragLen < 4: %X, %d\n",
-                                                                *(unsigned char *)((unsigned char *)&dwSafeMIC_R + uMICFragLen - 4),
-                                                                (cbMIClen - uMICFragLen));
-                                               }
-                                       }
-                                       MIC_vUnInit();
-                               } else {
-                                       ASSERT(uTmpLen == (cbLastFragPayloadSize - cbMIClen));
-                               }
-
-                               //---------------------------
-                               // S/W Encryption
-                               //---------------------------
-                               if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) {
-                                       if (bNeedEncrypt) {
-                                               s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength), (unsigned short)cbLastFragPayloadSize);
-                                               cbReqCount += cbICVlen;
-                                       }
-                               }
-
-                               ptdCurr = (PSTxDesc)pHeadTD;
-
-                               //--------------------
-                               //1.Set TSR1 & ReqCount in TxDescHead
-                               //2.Set FragCtl in TxBufferHead
-                               //3.Set Frame Control
-                               //4.Set Sequence Control
-                               //5.Get S/W generate FCS
-                               //--------------------
-
-                               s_vFillFragParameter(pDevice, pbyBuffer, uDMAIdx, (void *)ptdCurr, wFragType, cbReqCount);
-
-                               ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding;
-                               ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength;
-                               ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma;
-                               ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma);
-                               pDevice->iTDUsed[uDMAIdx]++;
-                               pHeadTD = ptdCurr->next;
-
-                       } else {
-                               //=========================
-                               //    Middle Fragmentation
-                               //=========================
-                               pr_debug("Middle Fragmentation...\n");
-
-                               wFragType = FRAGCTL_MIDFRAG;
-
-                               //Fill FIFO,RrvTime,RTS,and CTS
-                               s_vGenerateTxParameter(pDevice, byPktType, (void *)psTxBufHd, pvRrvTime, pvRTS, pvCTS,
-                                                      cbFragmentSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate);
-                               //Fill DataHead
-                               uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFragmentSize, uDMAIdx, bNeedACK,
-                                                           uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption, pDevice->wCurrentRate);
-
-                               // Generate TX MAC Header
-                               vGenerateMACHeader(pDevice, pbyMacHdr, uDuration, psEthHeader, bNeedEncrypt,
-                                                  wFragType, uDMAIdx, uFragIdx);
-
-                               if (bNeedEncrypt == true) {
-                                       //Fill TXKEY
-                                       s_vFillTxKey(pDevice, (unsigned char *)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey,
-                                                    pbyMacHdr, (unsigned short)cbFragPayloadSize, (unsigned char *)pMICHDR);
-
-                                       if (pDevice->bEnableHostWEP) {
-                                               pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16;
-                                               pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0;
-                                       }
-                               }
-
-                               cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cbFragPayloadSize;
-                               //---------------------------
-                               // S/W or H/W Encryption
-                               //---------------------------
-
-                               pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf;
-                               uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen;
-
-                               //copy TxBufferHeader + MacHeader to desc
-                               memcpy(pbyBuffer, (void *)psTxBufHd, uLength);
-
-                               // Copy the Packet into a tx Buffer
-                               memcpy((pbyBuffer + uLength),
-                                      (pPacket + 14 + uTotalCopyLength),
-                                      cbFragPayloadSize
-);
-                               uTmpLen = cbFragPayloadSize;
-
-                               uTotalCopyLength += uTmpLen;
-
-                               if ((bNeedEncrypt == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) {
-                                       MIC_vAppend((pbyBuffer + uLength), uTmpLen);
-
-                                       if (uTmpLen < cbFragPayloadSize) {
-                                               bMIC2Frag = true;
-                                               uMICFragLen = cbFragPayloadSize - uTmpLen;
-                                               ASSERT(uMICFragLen < cbMIClen);
-
-                                               pdwMIC_L = (u32 *)(pbyBuffer + uLength + uTmpLen);
-                                               pdwMIC_R = (u32 *)(pbyBuffer + uLength + uTmpLen + 4);
-                                               MIC_vGetMIC(pdwMIC_L, pdwMIC_R);
-                                               dwSafeMIC_L = *pdwMIC_L;
-                                               dwSafeMIC_R = *pdwMIC_R;
-
-                                               pr_debug("MIDDLE: uMICFragLen:%d, cbFragPayloadSize:%d, uTmpLen:%d\n",
-                                                        uMICFragLen,
-                                                        cbFragPayloadSize,
-                                                        uTmpLen);
-                                               pr_debug("Fill MIC in Middle frag [%d]\n",
-                                                        uMICFragLen);
-                                               pr_debug("Get MIC:%X, %X\n",
-                                                        *pdwMIC_L, *pdwMIC_R);
-                                       }
-                                       pr_debug("Middle frag len: %d\n",
-                                                uTmpLen);
-
-                               } else {
-                                       ASSERT(uTmpLen == (cbFragPayloadSize));
-                               }
-
-                               if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) {
-                                       if (bNeedEncrypt) {
-                                               s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength), (unsigned short)cbFragPayloadSize);
-                                               cbReqCount += cbICVlen;
-                                       }
-                               }
-
-                               ptdCurr = (PSTxDesc)pHeadTD;
-
-                               //--------------------
-                               //1.Set TSR1 & ReqCount in TxDescHead
-                               //2.Set FragCtl in TxBufferHead
-                               //3.Set Frame Control
-                               //4.Set Sequence Control
-                               //5.Get S/W generate FCS
-                               //--------------------
-
-                               s_vFillFragParameter(pDevice, pbyBuffer, uDMAIdx, (void *)ptdCurr, wFragType, cbReqCount);
-
-                               ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding;
-                               ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength;
-                               ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma;
-                               ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma);
-                               pDevice->iTDUsed[uDMAIdx]++;
-                               pHeadTD = ptdCurr->next;
-                       }
-               }  // for (uMACfragNum)
-       } else {
-               //=========================
-               //    No Fragmentation
-               //=========================
-               wFragType = FRAGCTL_NONFRAG;
-
-               //Set FragCtl in TxBufferHead
-               psTxBufHd->wFragCtl |= (unsigned short)wFragType;
-
-               //Fill FIFO,RrvTime,RTS,and CTS
-               s_vGenerateTxParameter(pDevice, byPktType, (void *)psTxBufHd, pvRrvTime, pvRTS, pvCTS,
-                                      cbFrameSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate);
-               //Fill DataHead
-               uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFrameSize, uDMAIdx, bNeedACK,
-                                           0, 0, uMACfragNum, byFBOption, pDevice->wCurrentRate);
-
-               // Generate TX MAC Header
-               vGenerateMACHeader(pDevice, pbyMacHdr, uDuration, psEthHeader, bNeedEncrypt,
-                                  wFragType, uDMAIdx, 0);
-
-               if (bNeedEncrypt == true) {
-                       //Fill TXKEY
-                       s_vFillTxKey(pDevice, (unsigned char *)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey,
-                                    pbyMacHdr, (unsigned short)cbFrameBodySize, (unsigned char *)pMICHDR);
-
-                       if (pDevice->bEnableHostWEP) {
-                               pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16;
-                               pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0;
-                       }
-               }
-
-               // 802.1H
-               if (ntohs(psEthHeader->wType) > ETH_DATA_LEN) {
-                       if ((psEthHeader->wType == TYPE_PKT_IPX) ||
-                           (psEthHeader->wType == cpu_to_le16(0xF380))) {
-                               memcpy((unsigned char *)(pbyPayloadHead), &pDevice->abySNAP_Bridgetunnel[0], 6);
-                       } else {
-                               memcpy((unsigned char *)(pbyPayloadHead), &pDevice->abySNAP_RFC1042[0], 6);
-                       }
-                       pbyType = (unsigned char *)(pbyPayloadHead + 6);
-                       memcpy(pbyType, &(psEthHeader->wType), sizeof(unsigned short));
-                       cb802_1_H_len = 8;
-               }
-
-               cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + (cbFrameBodySize + cbMIClen);
-               //---------------------------
-               // S/W or H/W Encryption
-               //---------------------------
-               pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf;
-               uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cb802_1_H_len;
 
-               //copy TxBufferHeader + MacHeader to desc
-               memcpy(pbyBuffer, (void *)psTxBufHd, uLength);
+       td_info->mic_hdr = pMICHDR;
 
-               // Copy the Packet into a tx Buffer
-               memcpy((pbyBuffer + uLength),
-                      (pPacket + 14),
-                      cbFrameBodySize - cb802_1_H_len
-);
-
-               if ((bNeedEncrypt == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) {
-                       pr_debug("Length:%d, %d\n",
-                                cbFrameBodySize - cb802_1_H_len, uLength);
-
-                       MIC_vAppend((pbyBuffer + uLength - cb802_1_H_len), cbFrameBodySize);
-
-                       pdwMIC_L = (u32 *)(pbyBuffer + uLength - cb802_1_H_len + cbFrameBodySize);
-                       pdwMIC_R = (u32 *)(pbyBuffer + uLength - cb802_1_H_len + cbFrameBodySize + 4);
-
-                       MIC_vGetMIC(pdwMIC_L, pdwMIC_R);
-                       MIC_vUnInit();
-
-                       if (pDevice->bTxMICFail == true) {
-                               *pdwMIC_L = 0;
-                               *pdwMIC_R = 0;
-                               pDevice->bTxMICFail = false;
-                       }
+       memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderLength - wTxBufSize));
 
-                       pr_debug("uLength: %d, %d\n", uLength, cbFrameBodySize);
-                       pr_debug("cbReqCount:%d, %d, %d, %d\n",
-                                cbReqCount, cbHeaderLength, uPadding, cbIVlen);
-                       pr_debug("MIC:%x, %x\n", *pdwMIC_L, *pdwMIC_R);
+       /* Fill FIFO,RrvTime,RTS,and CTS */
+       s_vGenerateTxParameter(pDevice, byPktType, tx_buffer_head, pvRrvTime, pvRTS, pvCTS,
+                              cbFrameSize, bNeedACK, uDMAIdx, hdr, pDevice->wCurrentRate);
+       /* Fill DataHead */
+       uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFrameSize, uDMAIdx, bNeedACK,
+                                   0, 0, uMACfragNum, byFBOption, pDevice->wCurrentRate, is_pspoll);
 
-               }
+       hdr->duration_id = uDuration;
 
-               if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) {
-                       if (bNeedEncrypt) {
-                               s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength - cb802_1_H_len),
-                                               (unsigned short)(cbFrameBodySize + cbMIClen));
-                               cbReqCount += cbICVlen;
-                       }
-               }
+       cbReqCount = cbHeaderLength + uPadding + cbFrameBodySize;
+       pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf;
+       uLength = cbHeaderLength + uPadding;
 
-               ptdCurr = (PSTxDesc)pHeadTD;
+       /* Copy the Packet into a tx Buffer */
+       memcpy((pbyBuffer + uLength), pPacket, cbFrameBodySize);
 
-               ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding;
-               ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength;
-               ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma;
-               ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma);
-               //Set TSR1 & ReqCount in TxDescHead
-               ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP | EDMSDU);
-               ptdCurr->m_td1TD1.wReqCount = cpu_to_le16((unsigned short)(cbReqCount));
+       ptdCurr = (PSTxDesc)pHeadTD;
 
-               pDevice->iTDUsed[uDMAIdx]++;
+       ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding;
+       ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength;
+       ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma;
+       ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma);
+       /* Set TSR1 & ReqCount in TxDescHead */
+       ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP | EDMSDU);
+       ptdCurr->m_td1TD1.wReqCount = cpu_to_le16((unsigned short)(cbReqCount));
 
-       }
        *puMACfragNum = uMACfragNum;
 
        return cbHeaderLength;
 }
 
-void
-vGenerateFIFOHeader(struct vnt_private *pDevice, unsigned char byPktType,
-                   unsigned char *pbyTxBufferAddr, bool bNeedEncrypt,
-                   unsigned int cbPayloadSize, unsigned int uDMAIdx,
-                   PSTxDesc pHeadTD, PSEthernetHeader psEthHeader, unsigned char *pPacket,
-                   PSKeyItem pTransmitKey, unsigned int uNodeIndex, unsigned int *puMACfragNum,
-                   unsigned int *pcbHeaderSize)
+static void vnt_fill_txkey(struct ieee80211_hdr *hdr, u8 *key_buffer,
+                          struct ieee80211_key_conf *tx_key,
+                          struct sk_buff *skb, u16 payload_len,
+                          struct vnt_mic_hdr *mic_hdr)
 {
-       unsigned int wTxBufSize;       // FFinfo size
-       bool bNeedACK;
-       bool bIsAdhoc;
-       unsigned short cbMacHdLen;
-       PSTxBufHead     pTxBufHead = (PSTxBufHead) pbyTxBufferAddr;
-
-       wTxBufSize = sizeof(STxBufHead);
-
-       memset(pTxBufHead, 0, wTxBufSize);
-       //Set FIFOCTL_NEEDACK
-
-       if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) ||
-           (pDevice->op_mode == NL80211_IFTYPE_AP)) {
-               if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0]))) {
-                       bNeedACK = false;
-                       pTxBufHead->wFIFOCtl = pTxBufHead->wFIFOCtl & (~FIFOCTL_NEEDACK);
-               } else {
-                       bNeedACK = true;
-                       pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK;
+       struct ieee80211_key_seq seq;
+       u8 *iv = ((u8 *)hdr + ieee80211_get_hdrlen_from_skb(skb));
+
+       /* strip header and icv len from payload */
+       payload_len -= ieee80211_get_hdrlen_from_skb(skb);
+       payload_len -= tx_key->icv_len;
+
+       switch (tx_key->cipher) {
+       case WLAN_CIPHER_SUITE_WEP40:
+       case WLAN_CIPHER_SUITE_WEP104:
+               memcpy(key_buffer, iv, 3);
+               memcpy(key_buffer + 3, tx_key->key, tx_key->keylen);
+
+               if (tx_key->keylen == WLAN_KEY_LEN_WEP40) {
+                       memcpy(key_buffer + 8, iv, 3);
+                       memcpy(key_buffer + 11,
+                              tx_key->key, WLAN_KEY_LEN_WEP40);
                }
-               bIsAdhoc = true;
-       } else {
-               // MSDUs in Infra mode always need ACK
-               bNeedACK = true;
-               pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK;
-               bIsAdhoc = false;
-       }
-
-       pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN;
-       pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MSDU_LIFETIME_RES_64us);
-
-       //Set FIFOCTL_LHEAD
-       if (pDevice->bLongHeader)
-               pTxBufHead->wFIFOCtl |= FIFOCTL_LHEAD;
-
-       //Set FIFOCTL_GENINT
 
-       pTxBufHead->wFIFOCtl |= FIFOCTL_GENINT;
-
-       //Set FIFOCTL_ISDMA0
-       if (TYPE_TXDMA0 == uDMAIdx)
-               pTxBufHead->wFIFOCtl |= FIFOCTL_ISDMA0;
-
-       //Set FRAGCTL_MACHDCNT
-       if (pDevice->bLongHeader)
-               cbMacHdLen = WLAN_HDR_ADDR3_LEN + 6;
-       else
-               cbMacHdLen = WLAN_HDR_ADDR3_LEN;
-
-       pTxBufHead->wFragCtl |= cpu_to_le16((unsigned short)(cbMacHdLen << 10));
-
-       //Set packet type
-       if (byPktType == PK_TYPE_11A) //0000 0000 0000 0000
-               ;
-       else if (byPktType == PK_TYPE_11B) //0000 0001 0000 0000
-               pTxBufHead->wFIFOCtl |= FIFOCTL_11B;
-       else if (byPktType == PK_TYPE_11GB) //0000 0010 0000 0000
-               pTxBufHead->wFIFOCtl |= FIFOCTL_11GB;
-       else if (byPktType == PK_TYPE_11GA) //0000 0011 0000 0000
-               pTxBufHead->wFIFOCtl |= FIFOCTL_11GA;
-
-       //Set FIFOCTL_GrpAckPolicy
-       if (pDevice->bGrpAckPolicy == true) //0000 0100 0000 0000
-               pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK;
-
-       //Set Auto Fallback Ctl
-       if (pDevice->wCurrentRate >= RATE_18M) {
-               if (pDevice->byAutoFBCtrl == AUTO_FB_0)
-                       pTxBufHead->wFIFOCtl |= FIFOCTL_AUTO_FB_0;
-               else if (pDevice->byAutoFBCtrl == AUTO_FB_1)
-                       pTxBufHead->wFIFOCtl |= FIFOCTL_AUTO_FB_1;
-       }
-
-       //Set FRAGCTL_WEPTYP
-       pDevice->bAES = false;
-
-       //Set FRAGCTL_WEPTYP
-       if (pDevice->byLocalID > REV_ID_VT3253_A1) {
-               if ((bNeedEncrypt) && (pTransmitKey != NULL))  { //WEP enabled
-                       if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) {
-                               pTxBufHead->wFragCtl |= FRAGCTL_TKIP;
-                       } else if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { //WEP40 or WEP104
-                               if (pTransmitKey->uKeyLength != WLAN_WEP232_KEYLEN)
-                                       pTxBufHead->wFragCtl |= FRAGCTL_LEGACY;
-                       } else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { //CCMP
-                               pTxBufHead->wFragCtl |= FRAGCTL_AES;
-                       }
-               }
-       }
-
-       RFbSetPower(pDevice, pDevice->wCurrentRate, pDevice->byCurrentCh);
-
-       pTxBufHead->byTxPower = pDevice->byCurPwr;
-
-       *pcbHeaderSize = s_cbFillTxBufHead(pDevice, byPktType, pbyTxBufferAddr, cbPayloadSize,
-                                          uDMAIdx, pHeadTD, psEthHeader, pPacket, bNeedEncrypt,
-                                          pTransmitKey, uNodeIndex, puMACfragNum);
-}
+               break;
+       case WLAN_CIPHER_SUITE_TKIP:
+               ieee80211_get_tkip_p2k(tx_key, skb, key_buffer);
 
-/*+
- *
- * Description:
- *      Translate 802.3 to 802.11 header
- *
- * Parameters:
- *  In:
- *      pDevice         - Pointer to adapter
- *      dwTxBufferAddr  - Transmit Buffer
- *      pPacket         - Packet from upper layer
- *      cbPacketSize    - Transmit Data Length
- *  Out:
- *      pcbHeadSize         - Header size of MAC&Baseband control and 802.11 Header
- *      pcbAppendPayload    - size of append payload for 802.1H translation
- *
- * Return Value: none
- *
- -*/
+               break;
+       case WLAN_CIPHER_SUITE_CCMP:
 
-void
-vGenerateMACHeader(
-       struct vnt_private *pDevice,
-       unsigned char *pbyBufferAddr,
-       __le16 wDuration,
-       PSEthernetHeader psEthHeader,
-       bool bNeedEncrypt,
-       unsigned short wFragType,
-       unsigned int uDMAIdx,
-       unsigned int uFragIdx
-)
-{
-       PS802_11Header  pMACHeader = (PS802_11Header)pbyBufferAddr;
+               if (!mic_hdr)
+                       return;
 
-       memset(pMACHeader, 0, (sizeof(S802_11Header)));
+               mic_hdr->id = 0x59;
+               mic_hdr->payload_len = cpu_to_be16(payload_len);
+               ether_addr_copy(mic_hdr->mic_addr2, hdr->addr2);
 
-       if (uDMAIdx == TYPE_ATIMDMA)
-               pMACHeader->wFrameCtl = TYPE_802_11_ATIM;
-       else
-               pMACHeader->wFrameCtl = TYPE_802_11_DATA;
+               ieee80211_get_key_tx_seq(tx_key, &seq);
 
-       if (pDevice->op_mode == NL80211_IFTYPE_AP) {
-               memcpy(&(pMACHeader->abyAddr1[0]), &(psEthHeader->abyDstAddr[0]), ETH_ALEN);
-               memcpy(&(pMACHeader->abyAddr2[0]), &(pDevice->abyBSSID[0]), ETH_ALEN);
-               memcpy(&(pMACHeader->abyAddr3[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN);
-               pMACHeader->wFrameCtl |= FC_FROMDS;
-       } else {
-               if (pDevice->op_mode == NL80211_IFTYPE_ADHOC) {
-                       memcpy(&(pMACHeader->abyAddr1[0]), &(psEthHeader->abyDstAddr[0]), ETH_ALEN);
-                       memcpy(&(pMACHeader->abyAddr2[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN);
-                       memcpy(&(pMACHeader->abyAddr3[0]), &(pDevice->abyBSSID[0]), ETH_ALEN);
-               } else {
-                       memcpy(&(pMACHeader->abyAddr3[0]), &(psEthHeader->abyDstAddr[0]), ETH_ALEN);
-                       memcpy(&(pMACHeader->abyAddr2[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN);
-                       memcpy(&(pMACHeader->abyAddr1[0]), &(pDevice->abyBSSID[0]), ETH_ALEN);
-                       pMACHeader->wFrameCtl |= FC_TODS;
-               }
-       }
+               memcpy(mic_hdr->ccmp_pn, seq.ccmp.pn, IEEE80211_CCMP_PN_LEN);
 
-       if (bNeedEncrypt)
-               pMACHeader->wFrameCtl |= cpu_to_le16((unsigned short)WLAN_SET_FC_ISWEP(1));
+               if (ieee80211_has_a4(hdr->frame_control))
+                       mic_hdr->hlen = cpu_to_be16(28);
+               else
+                       mic_hdr->hlen = cpu_to_be16(22);
 
-       pMACHeader->wDurationID = le16_to_cpu(wDuration);
+               ether_addr_copy(mic_hdr->addr1, hdr->addr1);
+               ether_addr_copy(mic_hdr->addr2, hdr->addr2);
+               ether_addr_copy(mic_hdr->addr3, hdr->addr3);
 
-       if (pDevice->bLongHeader) {
-               PWLAN_80211HDR_A4 pMACA4Header  = (PWLAN_80211HDR_A4) pbyBufferAddr;
+               mic_hdr->frame_control = cpu_to_le16(
+                       le16_to_cpu(hdr->frame_control) & 0xc78f);
+               mic_hdr->seq_ctrl = cpu_to_le16(
+                               le16_to_cpu(hdr->seq_ctrl) & 0xf);
 
-               pMACHeader->wFrameCtl |= (FC_TODS | FC_FROMDS);
-               memcpy(pMACA4Header->abyAddr4, pDevice->abyBSSID, WLAN_ADDR_LEN);
-       }
-       pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4);
+               if (ieee80211_has_a4(hdr->frame_control))
+                       ether_addr_copy(mic_hdr->addr4, hdr->addr4);
 
-       //Set FragNumber in Sequence Control
-       pMACHeader->wSeqCtl |= cpu_to_le16((unsigned short)uFragIdx);
+               memcpy(key_buffer, tx_key->key, WLAN_KEY_LEN_CCMP);
 
-       if ((wFragType == FRAGCTL_ENDFRAG) || (wFragType == FRAGCTL_NONFRAG)) {
-               pDevice->wSeqCounter++;
-               if (pDevice->wSeqCounter > 0x0fff)
-                       pDevice->wSeqCounter = 0;
+               break;
+       default:
+               break;
        }
-
-       if ((wFragType == FRAGCTL_STAFRAG) || (wFragType == FRAGCTL_MIDFRAG)) //StartFrag or MidFrag
-               pMACHeader->wFrameCtl |= FC_MOREFRAG;
 }
 
-CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, PSTxMgmtPacket pPacket)
+int vnt_generate_fifo_header(struct vnt_private *priv, u32 dma_idx,
+                            PSTxDesc head_td, struct sk_buff *skb)
 {
-       PSTxDesc        pFrstTD;
-       unsigned char byPktType;
-       unsigned char *pbyTxBufferAddr;
-       void *pvRTS;
-       struct vnt_cts *pCTS;
-       void *pvTxDataHd;
-       unsigned int uDuration;
-       unsigned int cbReqCount;
-       PS802_11Header  pMACHeader;
-       unsigned int cbHeaderSize;
-       unsigned int cbFrameBodySize;
-       bool bNeedACK;
-       bool bIsPSPOLL = false;
-       PSTxBufHead     pTxBufHead;
-       unsigned int cbFrameSize;
-       unsigned int cbIVlen = 0;
-       unsigned int cbICVlen = 0;
-       unsigned int cbMIClen = 0;
-       unsigned int cbFCSlen = 4;
-       unsigned int uPadding = 0;
-       unsigned short wTxBufSize;
-       unsigned int cbMacHdLen;
-       SEthernetHeader sEthHeader;
-       void *pvRrvTime;
-       void *pMICHDR;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       unsigned short wCurrentRate = RATE_1M;
-
-       if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 0)
-               return CMD_STATUS_RESOURCES;
-
-       pFrstTD = pDevice->apCurrTD[TYPE_TXDMA0];
-       pbyTxBufferAddr = (unsigned char *)pFrstTD->pTDInfo->buf;
-       cbFrameBodySize = pPacket->cbPayloadLen;
-       pTxBufHead = (PSTxBufHead) pbyTxBufferAddr;
-       wTxBufSize = sizeof(STxBufHead);
-       memset(pTxBufHead, 0, wTxBufSize);
-
-       if (pDevice->eCurrentPHYType == PHY_TYPE_11A) {
-               wCurrentRate = RATE_6M;
-               byPktType = PK_TYPE_11A;
-       } else {
-               wCurrentRate = RATE_1M;
-               byPktType = PK_TYPE_11B;
+       PDEVICE_TD_INFO td_info = head_td->pTDInfo;
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+       struct ieee80211_tx_rate *tx_rate = &info->control.rates[0];
+       struct ieee80211_rate *rate;
+       struct ieee80211_key_conf *tx_key;
+       struct ieee80211_hdr *hdr;
+       struct vnt_tx_fifo_head *tx_buffer_head =
+                       (struct vnt_tx_fifo_head *)td_info->buf;
+       u32 frag;
+       u16 tx_body_size = skb->len, current_rate;
+       u8 pkt_type;
+       bool is_pspoll = false;
+
+       memset(tx_buffer_head, 0, sizeof(*tx_buffer_head));
+
+       hdr = (struct ieee80211_hdr *)(skb->data);
+
+       rate = ieee80211_get_tx_rate(priv->hw, info);
+
+       current_rate = rate->hw_value;
+       if (priv->wCurrentRate != current_rate &&
+                       !(priv->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) {
+               priv->wCurrentRate = current_rate;
+
+               RFbSetPower(priv, priv->wCurrentRate,
+                           priv->hw->conf.chandef.chan->hw_value);
        }
 
-       // SetPower will cause error power TX state for OFDM Date packet in TX buffer.
-       // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability.
-       //                    And cmd timer will wait data pkt TX finish before scanning so it's OK
-       //                    to set power here.
-       if (pDevice->pMgmt->eScanState != WMAC_NO_SCANNING)
-               RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh);
+       if (current_rate > RATE_11M)
+               pkt_type = (u8)priv->byPacketType;
        else
-               RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel);
-
-       pTxBufHead->byTxPower = pDevice->byCurPwr;
-       //+++++++++++++++++++++ Patch VT3253 A1 performance +++++++++++++++++++++++++++
-       if (pDevice->byFOETuning) {
-               if ((pPacket->p80211Header->sA3.wFrameCtl & TYPE_DATE_NULL) == TYPE_DATE_NULL) {
-                       wCurrentRate = RATE_24M;
-                       byPktType = PK_TYPE_11GA;
-               }
-       }
-
-       //Set packet type
-       if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000
-               pTxBufHead->wFIFOCtl = 0;
-       } else if (byPktType == PK_TYPE_11B) {//0000 0001 0000 0000
-               pTxBufHead->wFIFOCtl |= FIFOCTL_11B;
-       } else if (byPktType == PK_TYPE_11GB) {//0000 0010 0000 0000
-               pTxBufHead->wFIFOCtl |= FIFOCTL_11GB;
-       } else if (byPktType == PK_TYPE_11GA) {//0000 0011 0000 0000
-               pTxBufHead->wFIFOCtl |= FIFOCTL_11GA;
+               pkt_type = PK_TYPE_11B;
+
+       /*Set fifo controls */
+       if (pkt_type == PK_TYPE_11A)
+               tx_buffer_head->fifo_ctl = 0;
+       else if (pkt_type == PK_TYPE_11B)
+               tx_buffer_head->fifo_ctl = cpu_to_le16(FIFOCTL_11B);
+       else if (pkt_type == PK_TYPE_11GB)
+               tx_buffer_head->fifo_ctl = cpu_to_le16(FIFOCTL_11GB);
+       else if (pkt_type == PK_TYPE_11GA)
+               tx_buffer_head->fifo_ctl = cpu_to_le16(FIFOCTL_11GA);
+
+       /* generate interrupt */
+       tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_GENINT);
+
+       if (!ieee80211_is_data(hdr->frame_control)) {
+               tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_TMOEN);
+               tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_ISDMA0);
+               tx_buffer_head->time_stamp =
+                       cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us);
+       } else {
+               tx_buffer_head->time_stamp =
+                       cpu_to_le16(DEFAULT_MSDU_LIFETIME_RES_64us);
        }
 
-       pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN;
-       pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us);
+       if (!(info->flags & IEEE80211_TX_CTL_NO_ACK))
+               tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_NEEDACK);
 
-       if (is_multicast_ether_addr(&(pPacket->p80211Header->sA3.abyAddr1[0])))
-               bNeedACK = false;
-       else {
-               bNeedACK = true;
-               pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK;
-       }
+       if (ieee80211_has_retry(hdr->frame_control))
+               tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_LRETRY);
 
-       if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) ||
-           (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) {
-               pTxBufHead->wFIFOCtl |= FIFOCTL_LRETRY;
-       }
+       if (tx_rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
+               priv->byPreambleType = PREAMBLE_SHORT;
+       else
+               priv->byPreambleType = PREAMBLE_LONG;
 
-       pTxBufHead->wFIFOCtl |= (FIFOCTL_GENINT | FIFOCTL_ISDMA0);
+       if (tx_rate->flags & IEEE80211_TX_RC_USE_RTS_CTS)
+               tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_RTS);
 
-       if ((pPacket->p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL) {
-               bIsPSPOLL = true;
-               cbMacHdLen = WLAN_HDR_ADDR2_LEN;
-       } else {
-               cbMacHdLen = WLAN_HDR_ADDR3_LEN;
+       if (ieee80211_has_a4(hdr->frame_control)) {
+               tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_LHEAD);
+               priv->bLongHeader = true;
        }
 
-       //Set FRAGCTL_MACHDCNT
-       pTxBufHead->wFragCtl |= cpu_to_le16((unsigned short)(cbMacHdLen << 10));
-
-       // Notes:
-       // Although spec says MMPDU can be fragmented; In most cases,
-       // no one will send a MMPDU under fragmentation. With RTS may occur.
-       pDevice->bAES = false;  //Set FRAGCTL_WEPTYP
-
-       if (WLAN_GET_FC_ISWEP(pPacket->p80211Header->sA4.wFrameCtl) != 0) {
-               if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) {
-                       cbIVlen = 4;
-                       cbICVlen = 4;
-                       pTxBufHead->wFragCtl |= FRAGCTL_LEGACY;
-               } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
-                       cbIVlen = 8;//IV+ExtIV
-                       cbMIClen = 8;
-                       cbICVlen = 4;
-                       pTxBufHead->wFragCtl |= FRAGCTL_TKIP;
-                       //We need to get seed here for filling TxKey entry.
-               } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
-                       cbIVlen = 8;//RSN Header
-                       cbICVlen = 8;//MIC
-                       pTxBufHead->wFragCtl |= FRAGCTL_AES;
-                       pDevice->bAES = true;
+       if (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER)
+               is_pspoll = true;
+
+       tx_buffer_head->frag_ctl =
+                       cpu_to_le16(ieee80211_get_hdrlen_from_skb(skb) << 10);
+
+       if (info->control.hw_key) {
+               tx_key = info->control.hw_key;
+
+               switch (info->control.hw_key->cipher) {
+               case WLAN_CIPHER_SUITE_WEP40:
+               case WLAN_CIPHER_SUITE_WEP104:
+                       tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_LEGACY);
+                       break;
+               case WLAN_CIPHER_SUITE_TKIP:
+                       tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_TKIP);
+                       break;
+               case WLAN_CIPHER_SUITE_CCMP:
+                       tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_AES);
+               default:
+                       break;
                }
-               //MAC Header should be padding 0 to DW alignment.
-               uPadding = 4 - (cbMacHdLen%4);
-               uPadding %= 4;
        }
 
-       cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen;
+       tx_buffer_head->current_rate = cpu_to_le16(current_rate);
 
-       //Set FIFOCTL_GrpAckPolicy
-       if (pDevice->bGrpAckPolicy == true) //0000 0100 0000 0000
-               pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK;
+       /* legacy rates TODO use ieee80211_tx_rate */
+       if (current_rate >= RATE_18M && ieee80211_is_data(hdr->frame_control)) {
+               if (priv->byAutoFBCtrl == AUTO_FB_0)
+                       tx_buffer_head->fifo_ctl |=
+                                               cpu_to_le16(FIFOCTL_AUTO_FB_0);
+               else if (priv->byAutoFBCtrl == AUTO_FB_1)
+                       tx_buffer_head->fifo_ctl |=
+                                               cpu_to_le16(FIFOCTL_AUTO_FB_1);
 
-       //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter()
-
-       //Set RrvTime/RTS/CTS Buffer
-       if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet
-               pvRrvTime = (void *) (pbyTxBufferAddr + wTxBufSize);
-               pMICHDR = NULL;
-               pvRTS = NULL;
-               pCTS = (struct vnt_cts *)(pbyTxBufferAddr + wTxBufSize +
-                                       sizeof(struct vnt_rrv_time_cts));
-               pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize +
-                               sizeof(struct vnt_rrv_time_cts) + sizeof(struct vnt_cts));
-               cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_cts) +
-                               sizeof(struct vnt_cts) + sizeof(struct vnt_tx_datahead_g);
-       } else { // 802.11a/b packet
-               pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize);
-               pMICHDR = NULL;
-               pvRTS = NULL;
-               pCTS = NULL;
-               pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize +
-                       sizeof(struct vnt_rrv_time_ab));
-               cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_ab) +
-                       sizeof(struct vnt_tx_datahead_ab);
        }
 
-       memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderSize - wTxBufSize));
-
-       memcpy(&(sEthHeader.abyDstAddr[0]), &(pPacket->p80211Header->sA3.abyAddr1[0]), ETH_ALEN);
-       memcpy(&(sEthHeader.abySrcAddr[0]), &(pPacket->p80211Header->sA3.abyAddr2[0]), ETH_ALEN);
-       //=========================
-       //    No Fragmentation
-       //=========================
-       pTxBufHead->wFragCtl |= (unsigned short)FRAGCTL_NONFRAG;
-
-       //Fill FIFO,RrvTime,RTS,and CTS
-       s_vGenerateTxParameter(pDevice, byPktType, pbyTxBufferAddr, pvRrvTime, pvRTS, pCTS,
-                              cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader, wCurrentRate);
-
-       //Fill DataHead
-       uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK,
-                                   0, 0, 1, AUTO_FB_NONE, wCurrentRate);
-
-       pMACHeader = (PS802_11Header) (pbyTxBufferAddr + cbHeaderSize);
-
-       cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + cbFrameBodySize;
-
-       if (WLAN_GET_FC_ISWEP(pPacket->p80211Header->sA4.wFrameCtl) != 0) {
-               unsigned char *pbyIVHead;
-               unsigned char *pbyPayloadHead;
-               unsigned char *pbyBSSID;
-               PSKeyItem       pTransmitKey = NULL;
-
-               pbyIVHead = (unsigned char *)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding);
-               pbyPayloadHead = (unsigned char *)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding + cbIVlen);
-
-               //Fill TXKEY
-               //Kyle: Need fix: TKIP and AES did't encrypt Mnt Packet.
-               //s_vFillTxKey(pDevice, (unsigned char *)pTxBufHead->adwTxKey, NULL);
-
-               //Fill IV(ExtIV,RSNHDR)
-               //s_vFillPrePayload(pDevice, pbyIVHead, NULL);
-               //---------------------------
-               // S/W or H/W Encryption
-               //---------------------------
-               do {
-                       if ((pDevice->op_mode == NL80211_IFTYPE_STATION) &&
-                           (pDevice->bLinkPass == true)) {
-                               pbyBSSID = pDevice->abyBSSID;
-                               // get pairwise key
-                               if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == false) {
-                                       // get group key
-                                       if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == true) {
-                                               pr_debug("Get GTK\n");
-                                               break;
-                                       }
-                               } else {
-                                       pr_debug("Get PTK\n");
-                                       break;
-                               }
-                       }
-                       // get group key
-                       pbyBSSID = pDevice->abyBroadcastAddr;
-                       if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == false) {
-                               pTransmitKey = NULL;
-                               pr_debug("KEY is NULL. OP Mode[%d]\n",
-                                        pDevice->op_mode);
-                       } else {
-                               pr_debug("Get GTK\n");
-                       }
-               } while (false);
-               //Fill TXKEY
-               s_vFillTxKey(pDevice, (unsigned char *)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey,
-                            (unsigned char *)pMACHeader, (unsigned short)cbFrameBodySize, NULL);
-
-               memcpy(pMACHeader, pPacket->p80211Header, cbMacHdLen);
-               memcpy(pbyPayloadHead, ((unsigned char *)(pPacket->p80211Header) + cbMacHdLen),
-                      cbFrameBodySize);
-       } else {
-               // Copy the Packet into a tx Buffer
-               memcpy(pMACHeader, pPacket->p80211Header, pPacket->cbMPDULen);
-       }
+       tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_NONFRAG);
 
-       pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4);
-       pDevice->wSeqCounter++;
-       if (pDevice->wSeqCounter > 0x0fff)
-               pDevice->wSeqCounter = 0;
-
-       if (bIsPSPOLL) {
-               // The MAC will automatically replace the Duration-field of MAC header by Duration-field
-               // of  FIFO control header.
-               // This will cause AID-field of PS-POLL packet to be incorrect (Because PS-POLL's AID field is
-               // in the same place of other packet's Duration-field).
-               // And it will cause Cisco-AP to issue Disassociation-packet
-               if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {
-                       ((struct vnt_tx_datahead_g *)pvTxDataHd)->duration_a = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID);
-                       ((struct vnt_tx_datahead_g *)pvTxDataHd)->duration_b = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID);
-               } else {
-                       ((struct vnt_tx_datahead_ab *)pvTxDataHd)->duration = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID);
-               }
-       }
+       s_cbFillTxBufHead(priv, pkt_type, (u8 *)tx_buffer_head, skb->len,
+                         dma_idx, head_td, (u8 *)skb->data,
+                         is_pspoll, &frag);
 
-       // first TD is the only TD
-       //Set TSR1 & ReqCount in TxDescHead
-       pFrstTD->m_td1TD1.byTCR = (TCR_STP | TCR_EDP | EDMSDU);
-       pFrstTD->pTDInfo->skb_dma = pFrstTD->pTDInfo->buf_dma;
-       pFrstTD->m_td1TD1.wReqCount = cpu_to_le16((unsigned short)(cbReqCount));
-       pFrstTD->buff_addr = cpu_to_le32(pFrstTD->pTDInfo->skb_dma);
-       pFrstTD->pTDInfo->byFlags = 0;
-
-       if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) {
-               // Disable PS
-               MACbPSWakeup(pDevice->PortOffset);
+       if (info->control.hw_key) {
+               tx_key = info->control.hw_key;
+               if (tx_key->keylen > 0)
+                       vnt_fill_txkey(hdr, tx_buffer_head->tx_key,
+                               tx_key, skb, tx_body_size, td_info->mic_hdr);
        }
-       pDevice->bPWBitOn = false;
-
-       wmb();
-       pFrstTD->m_td0TD0.f1Owner = OWNED_BY_NIC;
-       wmb();
-
-       pDevice->iTDUsed[TYPE_TXDMA0]++;
-
-       if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 1)
-               pr_debug(" available td0 <= 1\n");
-
-       pDevice->apCurrTD[TYPE_TXDMA0] = pFrstTD->next;
-
-       pDevice->nTxDataTimeCout = 0; //2008-8-21 chester <add> for send null packet
-
-       // Poll Transmit the adapter
-       MACvTransmit0(pDevice->PortOffset);
 
-       return CMD_STATUS_PENDING;
+       return 0;
 }
 
-CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, PSTxMgmtPacket pPacket)
+static int vnt_beacon_xmit(struct vnt_private *priv,
+                          struct sk_buff *skb)
 {
-       unsigned char byPktType;
-       unsigned char *pbyBuffer = (unsigned char *)pDevice->tx_beacon_bufs;
-       unsigned int cbFrameSize = pPacket->cbMPDULen + WLAN_FCS_LEN;
-       unsigned int cbHeaderSize = 0;
        struct vnt_tx_short_buf_head *short_head =
-                               (struct vnt_tx_short_buf_head *)pbyBuffer;
-       PS802_11Header   pMACHeader;
-       unsigned short wCurrentRate;
-
-       memset(short_head, 0, sizeof(*short_head));
+               (struct vnt_tx_short_buf_head *)priv->tx_beacon_bufs;
+       struct ieee80211_mgmt *mgmt_hdr = (struct ieee80211_mgmt *)
+                               (priv->tx_beacon_bufs + sizeof(*short_head));
+       struct ieee80211_tx_info *info;
+       u32 frame_size = skb->len + 4;
+       u16 current_rate;
 
-       if (pDevice->eCurrentPHYType == PHY_TYPE_11A) {
-               wCurrentRate = RATE_6M;
-               byPktType = PK_TYPE_11A;
-       } else {
-               wCurrentRate = RATE_2M;
-               byPktType = PK_TYPE_11B;
-       }
+       memset(priv->tx_beacon_bufs, 0, sizeof(*short_head));
 
-       //Set Preamble type always long
-       pDevice->byPreambleType = PREAMBLE_LONG;
+       if (priv->byBBType == BB_TYPE_11A) {
+               current_rate = RATE_6M;
 
-       /* Set FIFOCTL_GENINT */
-       short_head->fifo_ctl |= cpu_to_le16(FIFOCTL_GENINT);
-
-       /* Set packet type & Get Duration */
-       if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000
-               short_head->duration =
-                       cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A,
-                                   cbFrameSize, byPktType, wCurrentRate, false,
-                                   0, 0, 1, AUTO_FB_NONE));
-       } else if (byPktType == PK_TYPE_11B) {//0000 0001 0000 0000
-               short_head->fifo_ctl |= cpu_to_le16(FIFOCTL_11B);
+               /* Get SignalField,ServiceField,Length */
+               vnt_get_phy_field(priv, frame_size, current_rate,
+                                 PK_TYPE_11A, &short_head->ab);
 
+               /* Get Duration and TimeStampOff */
                short_head->duration =
-                       cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B,
-                                   cbFrameSize, byPktType, wCurrentRate, false,
-                                   0, 0, 1, AUTO_FB_NONE));
-       }
-
-       vnt_get_phy_field(pDevice, cbFrameSize,
-                         wCurrentRate, byPktType, &short_head->ab);
+                       cpu_to_le16((u16)s_uGetDataDuration(priv, DATADUR_B,
+                                   frame_size, PK_TYPE_11A, current_rate,
+                                   false, 0, 0, 1, AUTO_FB_NONE));
 
-       /* Get TimeStampOff */
-       short_head->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate);
-       cbHeaderSize = sizeof(struct vnt_tx_short_buf_head);
-
-       //Generate Beacon Header
-       pMACHeader = (PS802_11Header)(pbyBuffer + cbHeaderSize);
-       memcpy(pMACHeader, pPacket->p80211Header, pPacket->cbMPDULen);
-
-       pMACHeader->wDurationID = 0;
-       pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4);
-       pDevice->wSeqCounter++;
-       if (pDevice->wSeqCounter > 0x0fff)
-               pDevice->wSeqCounter = 0;
-
-       // Set Beacon buffer length
-       pDevice->wBCNBufLen = pPacket->cbMPDULen + cbHeaderSize;
-
-       MACvSetCurrBCNTxDescAddr(pDevice->PortOffset, (pDevice->tx_beacon_dma));
-
-       MACvSetCurrBCNLength(pDevice->PortOffset, pDevice->wBCNBufLen);
-       // Set auto Transmit on
-       MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
-       // Poll Transmit the adapter
-       MACvTransmitBCN(pDevice->PortOffset);
-
-       return CMD_STATUS_PENDING;
-}
-
-unsigned int
-cbGetFragCount(
-       struct vnt_private *pDevice,
-       PSKeyItem        pTransmitKey,
-       unsigned int cbFrameBodySize,
-       PSEthernetHeader psEthHeader
-)
-{
-       unsigned int cbMACHdLen;
-       unsigned int cbFrameSize;
-       unsigned int cbFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS
-       unsigned int cbFragPayloadSize;
-       unsigned int cbLastFragPayloadSize;
-       unsigned int cbIVlen = 0;
-       unsigned int cbICVlen = 0;
-       unsigned int cbMIClen = 0;
-       unsigned int cbFCSlen = 4;
-       unsigned int uMACfragNum = 1;
-       bool bNeedACK;
-
-       if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) ||
-           (pDevice->op_mode == NL80211_IFTYPE_AP)) {
-               if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0])))
-                       bNeedACK = false;
-               else
-                       bNeedACK = true;
+               short_head->time_stamp_off =
+                               vnt_time_stamp_off(priv, current_rate);
        } else {
-               // MSDUs in Infra mode always need ACK
-               bNeedACK = true;
-       }
-
-       if (pDevice->bLongHeader)
-               cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6;
-       else
-               cbMACHdLen = WLAN_HDR_ADDR3_LEN;
-
-       if (pDevice->bEncryptionEnable == true) {
-               if (pTransmitKey == NULL) {
-                       if ((pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) ||
-                           (pDevice->pMgmt->eAuthenMode < WMAC_AUTH_WPA)) {
-                               cbIVlen = 4;
-                               cbICVlen = 4;
-                       } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
-                               cbIVlen = 8;//IV+ExtIV
-                               cbMIClen = 8;
-                               cbICVlen = 4;
-                       } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
-                               cbIVlen = 8;//RSN Header
-                               cbICVlen = 8;//MIC
-                       }
-               } else if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) {
-                       cbIVlen = 4;
-                       cbICVlen = 4;
-               } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) {
-                       cbIVlen = 8;//IV+ExtIV
-                       cbMIClen = 8;
-                       cbICVlen = 4;
-               } else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) {
-                       cbIVlen = 8;//RSN Header
-                       cbICVlen = 8;//MIC
-               }
-       }
-
-       cbFrameSize = cbMACHdLen + cbIVlen + (cbFrameBodySize + cbMIClen) + cbICVlen + cbFCSlen;
-
-       if ((cbFrameSize > pDevice->wFragmentationThreshold) && (bNeedACK == true)) {
-               // Fragmentation
-               cbFragmentSize = pDevice->wFragmentationThreshold;
-               cbFragPayloadSize = cbFragmentSize - cbMACHdLen - cbIVlen - cbICVlen - cbFCSlen;
-               uMACfragNum = (unsigned short) ((cbFrameBodySize + cbMIClen) / cbFragPayloadSize);
-               cbLastFragPayloadSize = (cbFrameBodySize + cbMIClen) % cbFragPayloadSize;
-               if (cbLastFragPayloadSize == 0)
-                       cbLastFragPayloadSize = cbFragPayloadSize;
-               else
-                       uMACfragNum++;
-       }
-       return uMACfragNum;
-}
-
-void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb,
-                   unsigned char *pbMPDU, unsigned int cbMPDULen)
-{
-       PSTxDesc        pFrstTD;
-       unsigned char byPktType;
-       unsigned char *pbyTxBufferAddr;
-       void *pvRTS;
-       void *pvCTS;
-       void *pvTxDataHd;
-       unsigned int uDuration;
-       unsigned int cbReqCount;
-       PS802_11Header  pMACHeader;
-       unsigned int cbHeaderSize;
-       unsigned int cbFrameBodySize;
-       bool bNeedACK;
-       bool bIsPSPOLL = false;
-       PSTxBufHead     pTxBufHead;
-       unsigned int cbFrameSize;
-       unsigned int cbIVlen = 0;
-       unsigned int cbICVlen = 0;
-       unsigned int cbMIClen = 0;
-       unsigned int cbFCSlen = 4;
-       unsigned int uPadding = 0;
-       unsigned int cbMICHDR = 0;
-       unsigned int uLength = 0;
-       u32 dwMICKey0, dwMICKey1;
-       u32 dwMIC_Priority;
-       u32 *pdwMIC_L;
-       u32 *pdwMIC_R;
-       unsigned short wTxBufSize;
-       unsigned int cbMacHdLen;
-       SEthernetHeader sEthHeader;
-       void *pvRrvTime;
-       void *pMICHDR;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       unsigned short wCurrentRate = RATE_1M;
-       PUWLAN_80211HDR  p80211Header;
-       unsigned int uNodeIndex = 0;
-       bool bNodeExist = false;
-       SKeyItem        STempKey;
-       PSKeyItem       pTransmitKey = NULL;
-       unsigned char *pbyIVHead;
-       unsigned char *pbyPayloadHead;
-       unsigned char *pbyMacHdr;
-
-       unsigned int cbExtSuppRate = 0;
-
-       pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL;
-
-       if (cbMPDULen <= WLAN_HDR_ADDR3_LEN)
-               cbFrameBodySize = 0;
-       else
-               cbFrameBodySize = cbMPDULen - WLAN_HDR_ADDR3_LEN;
-
-       p80211Header = (PUWLAN_80211HDR)pbMPDU;
-
-       pFrstTD = pDevice->apCurrTD[TYPE_TXDMA0];
-       pbyTxBufferAddr = (unsigned char *)pFrstTD->pTDInfo->buf;
-       pTxBufHead = (PSTxBufHead) pbyTxBufferAddr;
-       wTxBufSize = sizeof(STxBufHead);
-       memset(pTxBufHead, 0, wTxBufSize);
-
-       if (pDevice->eCurrentPHYType == PHY_TYPE_11A) {
-               wCurrentRate = RATE_6M;
-               byPktType = PK_TYPE_11A;
-       } else {
-               wCurrentRate = RATE_1M;
-               byPktType = PK_TYPE_11B;
-       }
-
-       // SetPower will cause error power TX state for OFDM Date packet in TX buffer.
-       // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability.
-       //                    And cmd timer will wait data pkt TX to finish before scanning so it's OK
-       //                    to set power here.
-       if (pDevice->pMgmt->eScanState != WMAC_NO_SCANNING)
-               RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh);
-       else
-               RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel);
-
-       pTxBufHead->byTxPower = pDevice->byCurPwr;
-
-       //+++++++++++++++++++++ Patch VT3253 A1 performance +++++++++++++++++++++++++++
-       if (pDevice->byFOETuning) {
-               if ((p80211Header->sA3.wFrameCtl & TYPE_DATE_NULL) == TYPE_DATE_NULL) {
-                       wCurrentRate = RATE_24M;
-                       byPktType = PK_TYPE_11GA;
-               }
-       }
-
-       pr_debug("vDMA0_tx_80211: p80211Header->sA3.wFrameCtl = %x\n",
-                p80211Header->sA3.wFrameCtl);
-
-       //Set packet type
-       if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000
-               pTxBufHead->wFIFOCtl = 0;
-       } else if (byPktType == PK_TYPE_11B) {//0000 0001 0000 0000
-               pTxBufHead->wFIFOCtl |= FIFOCTL_11B;
-       } else if (byPktType == PK_TYPE_11GB) {//0000 0010 0000 0000
-               pTxBufHead->wFIFOCtl |= FIFOCTL_11GB;
-       } else if (byPktType == PK_TYPE_11GA) {//0000 0011 0000 0000
-               pTxBufHead->wFIFOCtl |= FIFOCTL_11GA;
-       }
-
-       pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN;
-       pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us);
-
-       if (is_multicast_ether_addr(&(p80211Header->sA3.abyAddr1[0]))) {
-               bNeedACK = false;
-               if (pDevice->bEnableHostWEP) {
-                       uNodeIndex = 0;
-                       bNodeExist = true;
-               }
-       } else {
-               if (pDevice->bEnableHostWEP) {
-                       if (BSSDBbIsSTAInNodeDB(pDevice->pMgmt, (unsigned char *)(p80211Header->sA3.abyAddr1), &uNodeIndex))
-                               bNodeExist = true;
-               }
-               bNeedACK = true;
-               pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK;
-       }
-
-       if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) ||
-           (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) {
-               pTxBufHead->wFIFOCtl |= FIFOCTL_LRETRY;
-       }
-
-       pTxBufHead->wFIFOCtl |= (FIFOCTL_GENINT | FIFOCTL_ISDMA0);
-
-       if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL) {
-               bIsPSPOLL = true;
-               cbMacHdLen = WLAN_HDR_ADDR2_LEN;
-       } else {
-               cbMacHdLen = WLAN_HDR_ADDR3_LEN;
-       }
-
-       // hostapd deamon ext support rate patch
-       if (WLAN_GET_FC_FSTYPE(p80211Header->sA4.wFrameCtl) == WLAN_FSTYPE_ASSOCRESP) {
-               if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len != 0)
-                       cbExtSuppRate += ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN;
+               current_rate = RATE_1M;
+               short_head->fifo_ctl |= cpu_to_le16(FIFOCTL_11B);
 
-               if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len != 0)
-                       cbExtSuppRate += ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len + WLAN_IEHDR_LEN;
+               /* Get SignalField,ServiceField,Length */
+               vnt_get_phy_field(priv, frame_size, current_rate,
+                                 PK_TYPE_11B, &short_head->ab);
 
-               if (cbExtSuppRate > 0)
-                       cbFrameBodySize = WLAN_ASSOCRESP_OFF_SUPP_RATES;
-       }
+               /* Get Duration and TimeStampOff */
+               short_head->duration =
+                       cpu_to_le16((u16)s_uGetDataDuration(priv, DATADUR_B,
+                                   frame_size, PK_TYPE_11B, current_rate,
+                                   false, 0, 0, 1, AUTO_FB_NONE));
 
-       //Set FRAGCTL_MACHDCNT
-       pTxBufHead->wFragCtl |= cpu_to_le16((unsigned short)cbMacHdLen << 10);
-
-       // Notes:
-       // Although spec says MMPDU can be fragmented; In most cases,
-       // no one will send a MMPDU under fragmentation. With RTS may occur.
-       pDevice->bAES = false;  //Set FRAGCTL_WEPTYP
-
-       if (WLAN_GET_FC_ISWEP(p80211Header->sA4.wFrameCtl) != 0) {
-               if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) {
-                       cbIVlen = 4;
-                       cbICVlen = 4;
-                       pTxBufHead->wFragCtl |= FRAGCTL_LEGACY;
-               } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
-                       cbIVlen = 8;//IV+ExtIV
-                       cbMIClen = 8;
-                       cbICVlen = 4;
-                       pTxBufHead->wFragCtl |= FRAGCTL_TKIP;
-                       //We need to get seed here for filling TxKey entry.
-               } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
-                       cbIVlen = 8;//RSN Header
-                       cbICVlen = 8;//MIC
-                       cbMICHDR = sizeof(struct vnt_mic_hdr);
-                       pTxBufHead->wFragCtl |= FRAGCTL_AES;
-                       pDevice->bAES = true;
-               }
-               //MAC Header should be padding 0 to DW alignment.
-               uPadding = 4 - (cbMacHdLen%4);
-               uPadding %= 4;
+               short_head->time_stamp_off =
+                       vnt_time_stamp_off(priv, current_rate);
        }
 
-       cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen + cbExtSuppRate;
-
-       //Set FIFOCTL_GrpAckPolicy
-       if (pDevice->bGrpAckPolicy == true) //0000 0100 0000 0000
-               pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK;
-
-       //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter()
+       short_head->fifo_ctl |= cpu_to_le16(FIFOCTL_GENINT);
 
-       if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet
+       /* Copy Beacon */
+       memcpy(mgmt_hdr, skb->data, skb->len);
 
-               pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize);
-               pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize +
-                                       sizeof(struct vnt_rrv_time_cts));
-               pvRTS = NULL;
-               pvCTS = (struct vnt_cts *)(pbyTxBufferAddr + wTxBufSize +
-                               sizeof(struct vnt_rrv_time_cts) + cbMICHDR);
-               pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize +
-                       sizeof(struct vnt_rrv_time_cts) + cbMICHDR + sizeof(struct vnt_cts));
-               cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_cts) +
-                               cbMICHDR + sizeof(struct vnt_cts) + sizeof(struct vnt_tx_datahead_g);
+       /* time stamp always 0 */
+       mgmt_hdr->u.beacon.timestamp = 0;
 
-       } else {//802.11a/b packet
-
-               pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize);
-               pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr +
-                               wTxBufSize + sizeof(struct vnt_rrv_time_ab));
-               pvRTS = NULL;
-               pvCTS = NULL;
-               pvTxDataHd = (void *)(pbyTxBufferAddr +
-                       wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR);
-               cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_ab) +
-                               cbMICHDR + sizeof(struct vnt_tx_datahead_ab);
+       info = IEEE80211_SKB_CB(skb);
+       if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
+               struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)mgmt_hdr;
 
+               hdr->duration_id = 0;
+               hdr->seq_ctrl = cpu_to_le16(priv->wSeqCounter << 4);
        }
 
-       memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderSize - wTxBufSize));
-       memcpy(&(sEthHeader.abyDstAddr[0]), &(p80211Header->sA3.abyAddr1[0]), ETH_ALEN);
-       memcpy(&(sEthHeader.abySrcAddr[0]), &(p80211Header->sA3.abyAddr2[0]), ETH_ALEN);
-       //=========================
-       //    No Fragmentation
-       //=========================
-       pTxBufHead->wFragCtl |= (unsigned short)FRAGCTL_NONFRAG;
-
-       //Fill FIFO,RrvTime,RTS,and CTS
-       s_vGenerateTxParameter(pDevice, byPktType, pbyTxBufferAddr, pvRrvTime, pvRTS, pvCTS,
-                              cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader, wCurrentRate);
+       priv->wSeqCounter++;
+       if (priv->wSeqCounter > 0x0fff)
+               priv->wSeqCounter = 0;
 
-       //Fill DataHead
-       uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK,
-                                   0, 0, 1, AUTO_FB_NONE, wCurrentRate);
+       priv->wBCNBufLen = sizeof(*short_head) + skb->len;
 
-       pMACHeader = (PS802_11Header) (pbyTxBufferAddr + cbHeaderSize);
+       MACvSetCurrBCNTxDescAddr(priv->PortOffset, priv->tx_beacon_dma);
 
-       cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + (cbFrameBodySize + cbMIClen) + cbExtSuppRate;
+       MACvSetCurrBCNLength(priv->PortOffset, priv->wBCNBufLen);
+       /* Set auto Transmit on */
+       MACvRegBitsOn(priv->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
+       /* Poll Transmit the adapter */
+       MACvTransmitBCN(priv->PortOffset);
 
-       pbyMacHdr = (unsigned char *)(pbyTxBufferAddr + cbHeaderSize);
-       pbyPayloadHead = (unsigned char *)(pbyMacHdr + cbMacHdLen + uPadding + cbIVlen);
-       pbyIVHead = (unsigned char *)(pbyMacHdr + cbMacHdLen + uPadding);
+       return 0;
+}
 
-       // Copy the Packet into a tx Buffer
-       memcpy(pbyMacHdr, pbMPDU, cbMacHdLen);
+int vnt_beacon_make(struct vnt_private *priv, struct ieee80211_vif *vif)
+{
+       struct sk_buff *beacon;
 
-       // version set to 0, patch for hostapd deamon
-       pMACHeader->wFrameCtl &= cpu_to_le16(0xfffc);
-       memcpy(pbyPayloadHead, (pbMPDU + cbMacHdLen), cbFrameBodySize);
+       beacon = ieee80211_beacon_get(priv->hw, vif);
+       if (!beacon)
+               return -ENOMEM;
 
-       // replace support rate, patch for hostapd deamon(only support 11M)
-       if (WLAN_GET_FC_FSTYPE(p80211Header->sA4.wFrameCtl) == WLAN_FSTYPE_ASSOCRESP) {
-               if (cbExtSuppRate != 0) {
-                       if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len != 0)
-                               memcpy((pbyPayloadHead + cbFrameBodySize),
-                                      pMgmt->abyCurrSuppRates,
-                                      ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN
-);
-                       if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len != 0)
-                               memcpy((pbyPayloadHead + cbFrameBodySize) + ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN,
-                                      pMgmt->abyCurrExtSuppRates,
-                                      ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len + WLAN_IEHDR_LEN
-);
-               }
+       if (vnt_beacon_xmit(priv, beacon)) {
+               ieee80211_free_txskb(priv->hw, beacon);
+               return -ENODEV;
        }
 
-       // Set wep
-       if (WLAN_GET_FC_ISWEP(p80211Header->sA4.wFrameCtl) != 0) {
-               if (pDevice->bEnableHostWEP) {
-                       pTransmitKey = &STempKey;
-                       pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite;
-                       pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex;
-                       pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength;
-                       pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16;
-                       pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0;
-                       memcpy(pTransmitKey->abyKey,
-                              &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0],
-                              pTransmitKey->uKeyLength
-);
-               }
-
-               if ((pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) {
-                       dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[16]);
-                       dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[20]);
-
-                       // DO Software Michael
-                       MIC_vInit(dwMICKey0, dwMICKey1);
-                       MIC_vAppend((unsigned char *)&(sEthHeader.abyDstAddr[0]), 12);
-                       dwMIC_Priority = 0;
-                       MIC_vAppend((unsigned char *)&dwMIC_Priority, 4);
-                       pr_debug("DMA0_tx_8021:MIC KEY: %X, %X\n",
-                                dwMICKey0, dwMICKey1);
-
-                       uLength = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen;
-
-                       MIC_vAppend((pbyTxBufferAddr + uLength), cbFrameBodySize);
-
-                       pdwMIC_L = (u32 *)(pbyTxBufferAddr + uLength + cbFrameBodySize);
-                       pdwMIC_R = (u32 *)(pbyTxBufferAddr + uLength + cbFrameBodySize + 4);
-
-                       MIC_vGetMIC(pdwMIC_L, pdwMIC_R);
-                       MIC_vUnInit();
-
-                       if (pDevice->bTxMICFail == true) {
-                               *pdwMIC_L = 0;
-                               *pdwMIC_R = 0;
-                               pDevice->bTxMICFail = false;
-                       }
-
-                       pr_debug("uLength: %d, %d\n", uLength, cbFrameBodySize);
-                       pr_debug("cbReqCount:%d, %d, %d, %d\n",
-                                cbReqCount, cbHeaderSize, uPadding, cbIVlen);
-                       pr_debug("MIC:%x, %x\n", *pdwMIC_L, *pdwMIC_R);
-
-               }
-
-               s_vFillTxKey(pDevice, (unsigned char *)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey,
-                            pbyMacHdr, (unsigned short)cbFrameBodySize, (unsigned char *)pMICHDR);
-
-               if (pDevice->bEnableHostWEP) {
-                       pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16;
-                       pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0;
-               }
-
-               if ((pDevice->byLocalID <= REV_ID_VT3253_A1))
-                       s_vSWencryption(pDevice, pTransmitKey, pbyPayloadHead, (unsigned short)(cbFrameBodySize + cbMIClen));
-       }
+       return 0;
+}
 
-       pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4);
-       pDevice->wSeqCounter++;
-       if (pDevice->wSeqCounter > 0x0fff)
-               pDevice->wSeqCounter = 0;
-
-       if (bIsPSPOLL) {
-               // The MAC will automatically replace the Duration-field of MAC header by Duration-field
-               // of  FIFO control header.
-               // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is
-               // in the same place of other packet's Duration-field).
-               // And it will cause Cisco-AP to issue Disassociation-packet
-               if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {
-                       ((struct vnt_tx_datahead_g *)pvTxDataHd)->duration_a = cpu_to_le16(p80211Header->sA2.wDurationID);
-                       ((struct vnt_tx_datahead_g *)pvTxDataHd)->duration_b = cpu_to_le16(p80211Header->sA2.wDurationID);
-               } else {
-                       ((struct vnt_tx_datahead_ab *)pvTxDataHd)->duration = cpu_to_le16(p80211Header->sA2.wDurationID);
-               }
-       }
+int vnt_beacon_enable(struct vnt_private *priv, struct ieee80211_vif *vif,
+                     struct ieee80211_bss_conf *conf)
+{
+       int ret;
 
-       // first TD is the only TD
-       //Set TSR1 & ReqCount in TxDescHead
-       pFrstTD->pTDInfo->skb = skb;
-       pFrstTD->m_td1TD1.byTCR = (TCR_STP | TCR_EDP | EDMSDU);
-       pFrstTD->pTDInfo->skb_dma = pFrstTD->pTDInfo->buf_dma;
-       pFrstTD->m_td1TD1.wReqCount = cpu_to_le16(cbReqCount);
-       pFrstTD->buff_addr = cpu_to_le32(pFrstTD->pTDInfo->skb_dma);
-       pFrstTD->pTDInfo->byFlags = 0;
-       pFrstTD->pTDInfo->byFlags |= TD_FLAGS_PRIV_SKB;
-
-       if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) {
-               // Disable PS
-               MACbPSWakeup(pDevice->PortOffset);
-       }
-       pDevice->bPWBitOn = false;
+       VNSvOutPortB(priv->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTRST);
 
-       wmb();
-       pFrstTD->m_td0TD0.f1Owner = OWNED_BY_NIC;
-       wmb();
+       VNSvOutPortB(priv->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTREN);
 
-       pDevice->iTDUsed[TYPE_TXDMA0]++;
+       CARDvSetFirstNextTBTT(priv->PortOffset, conf->beacon_int);
 
-       if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 1)
-               pr_debug(" available td0 <= 1\n");
+       CARDbSetBeaconPeriod(priv, conf->beacon_int);
 
-       pDevice->apCurrTD[TYPE_TXDMA0] = pFrstTD->next;
+       ret = vnt_beacon_make(priv, vif);
 
-       // Poll Transmit the adapter
-       MACvTransmit0(pDevice->PortOffset);
+       return ret;
 }
index 8ee6288..b9bd163 100644 (file)
 #ifndef __RXTX_H__
 #define __RXTX_H__
 
-#include "ttype.h"
 #include "device.h"
-#include "wcmd.h"
+
+#define DEFAULT_MSDU_LIFETIME_RES_64us 8000 /* 64us */
+#define DEFAULT_MGN_LIFETIME_RES_64us  125  /* 64us */
+
 
 /*---------------------  Export Definitions -------------------------*/
 
@@ -173,6 +175,14 @@ struct vnt_cts_fb {
        u16 reserved2;
 } __packed;
 
+struct vnt_tx_fifo_head {
+       u8 tx_key[WLAN_KEY_LEN_CCMP];
+       __le16 fifo_ctl;
+       __le16 time_stamp;
+       __le16 frag_ctl;
+       __le16 current_rate;
+} __packed;
+
 struct vnt_tx_short_buf_head {
        __le16 fifo_ctl;
        u16 time_stamp;
@@ -181,38 +191,10 @@ struct vnt_tx_short_buf_head {
        __le16 time_stamp_off;
 } __packed;
 
-void
-vGenerateMACHeader(
-       struct vnt_private *,
-       unsigned char *pbyBufferAddr,
-       unsigned short wDuration,
-       PSEthernetHeader psEthHeader,
-       bool bNeedEncrypt,
-       unsigned short wFragType,
-       unsigned int uDMAIdx,
-       unsigned int uFragIdx
-);
-
-unsigned int
-cbGetFragCount(
-       struct vnt_private *,
-       PSKeyItem        pTransmitKey,
-       unsigned int    cbFrameBodySize,
-       PSEthernetHeader psEthHeader
-);
-
-void
-vGenerateFIFOHeader(struct vnt_private *, unsigned char byPktTyp,
-                   unsigned char *pbyTxBufferAddr, bool bNeedEncrypt,
-                   unsigned int cbPayloadSize, unsigned int uDMAIdx,
-                   PSTxDesc pHeadTD, PSEthernetHeader psEthHeader,
-                   unsigned char *pPacket, PSKeyItem pTransmitKey,
-                   unsigned int uNodeIndex, unsigned int *puMACfragNum,
-                   unsigned int *pcbHeaderSize);
-
-void vDMA0_tx_80211(struct vnt_private *, struct sk_buff *skb,
-                   unsigned char *pbMPDU, unsigned int cbMPDULen);
-CMD_STATUS csMgmt_xmit(struct vnt_private *, PSTxMgmtPacket pPacket);
-CMD_STATUS csBeacon_xmit(struct vnt_private *, PSTxMgmtPacket pPacket);
+int vnt_generate_fifo_header(struct vnt_private *, u32,
+                            PSTxDesc head_td, struct sk_buff *);
+int vnt_beacon_make(struct vnt_private *, struct ieee80211_vif *);
+int vnt_beacon_enable(struct vnt_private *, struct ieee80211_vif *,
+                     struct ieee80211_bss_conf *);
 
 #endif // __RXTX_H__
index 5396e58..1ac60fb 100644 (file)
@@ -44,7 +44,6 @@
 
 #include "upc.h"
 #include "tmacro.h"
-#include "tether.h"
 #include "mac.h"
 #include "srom.h"
 
index 3128e53..9f309c4 100644 (file)
@@ -30,8 +30,6 @@
 #ifndef __SROM_H__
 #define __SROM_H__
 
-#include "ttype.h"
-
 /*---------------------  Export Definitions -------------------------*/
 
 #define EEP_MAX_CONTEXT_SIZE    256
diff --git a/drivers/staging/vt6655/tcrc.c b/drivers/staging/vt6655/tcrc.c
deleted file mode 100644 (file)
index ddc5efd..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (c) 2003 VIA Networking, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: tcrc.c
- *
- * Purpose: Implement functions to calculate CRC
- *
- * Author: Tevin Chen
- *
- * Date: May 21, 1996
- *
- * Functions:
- *      CRCdwCrc32 -
- *      CRCdwGetCrc32 -
- *      CRCdwGetCrc32Ex -
- *
- * Revision History:
- *
- */
-
-#include "tcrc.h"
-
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Variables  --------------------------*/
-
-/* 32-bit CRC table */
-static const unsigned long s_adwCrc32Table[256] = {
-       0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL,
-       0x076DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L,
-       0x0EDB8832L, 0x79DCB8A4L, 0xE0D5E91EL, 0x97D2D988L,
-       0x09B64C2BL, 0x7EB17CBDL, 0xE7B82D07L, 0x90BF1D91L,
-       0x1DB71064L, 0x6AB020F2L, 0xF3B97148L, 0x84BE41DEL,
-       0x1ADAD47DL, 0x6DDDE4EBL, 0xF4D4B551L, 0x83D385C7L,
-       0x136C9856L, 0x646BA8C0L, 0xFD62F97AL, 0x8A65C9ECL,
-       0x14015C4FL, 0x63066CD9L, 0xFA0F3D63L, 0x8D080DF5L,
-       0x3B6E20C8L, 0x4C69105EL, 0xD56041E4L, 0xA2677172L,
-       0x3C03E4D1L, 0x4B04D447L, 0xD20D85FDL, 0xA50AB56BL,
-       0x35B5A8FAL, 0x42B2986CL, 0xDBBBC9D6L, 0xACBCF940L,
-       0x32D86CE3L, 0x45DF5C75L, 0xDCD60DCFL, 0xABD13D59L,
-       0x26D930ACL, 0x51DE003AL, 0xC8D75180L, 0xBFD06116L,
-       0x21B4F4B5L, 0x56B3C423L, 0xCFBA9599L, 0xB8BDA50FL,
-       0x2802B89EL, 0x5F058808L, 0xC60CD9B2L, 0xB10BE924L,
-       0x2F6F7C87L, 0x58684C11L, 0xC1611DABL, 0xB6662D3DL,
-       0x76DC4190L, 0x01DB7106L, 0x98D220BCL, 0xEFD5102AL,
-       0x71B18589L, 0x06B6B51FL, 0x9FBFE4A5L, 0xE8B8D433L,
-       0x7807C9A2L, 0x0F00F934L, 0x9609A88EL, 0xE10E9818L,
-       0x7F6A0DBBL, 0x086D3D2DL, 0x91646C97L, 0xE6635C01L,
-       0x6B6B51F4L, 0x1C6C6162L, 0x856530D8L, 0xF262004EL,
-       0x6C0695EDL, 0x1B01A57BL, 0x8208F4C1L, 0xF50FC457L,
-       0x65B0D9C6L, 0x12B7E950L, 0x8BBEB8EAL, 0xFCB9887CL,
-       0x62DD1DDFL, 0x15DA2D49L, 0x8CD37CF3L, 0xFBD44C65L,
-       0x4DB26158L, 0x3AB551CEL, 0xA3BC0074L, 0xD4BB30E2L,
-       0x4ADFA541L, 0x3DD895D7L, 0xA4D1C46DL, 0xD3D6F4FBL,
-       0x4369E96AL, 0x346ED9FCL, 0xAD678846L, 0xDA60B8D0L,
-       0x44042D73L, 0x33031DE5L, 0xAA0A4C5FL, 0xDD0D7CC9L,
-       0x5005713CL, 0x270241AAL, 0xBE0B1010L, 0xC90C2086L,
-       0x5768B525L, 0x206F85B3L, 0xB966D409L, 0xCE61E49FL,
-       0x5EDEF90EL, 0x29D9C998L, 0xB0D09822L, 0xC7D7A8B4L,
-       0x59B33D17L, 0x2EB40D81L, 0xB7BD5C3BL, 0xC0BA6CADL,
-       0xEDB88320L, 0x9ABFB3B6L, 0x03B6E20CL, 0x74B1D29AL,
-       0xEAD54739L, 0x9DD277AFL, 0x04DB2615L, 0x73DC1683L,
-       0xE3630B12L, 0x94643B84L, 0x0D6D6A3EL, 0x7A6A5AA8L,
-       0xE40ECF0BL, 0x9309FF9DL, 0x0A00AE27L, 0x7D079EB1L,
-       0xF00F9344L, 0x8708A3D2L, 0x1E01F268L, 0x6906C2FEL,
-       0xF762575DL, 0x806567CBL, 0x196C3671L, 0x6E6B06E7L,
-       0xFED41B76L, 0x89D32BE0L, 0x10DA7A5AL, 0x67DD4ACCL,
-       0xF9B9DF6FL, 0x8EBEEFF9L, 0x17B7BE43L, 0x60B08ED5L,
-       0xD6D6A3E8L, 0xA1D1937EL, 0x38D8C2C4L, 0x4FDFF252L,
-       0xD1BB67F1L, 0xA6BC5767L, 0x3FB506DDL, 0x48B2364BL,
-       0xD80D2BDAL, 0xAF0A1B4CL, 0x36034AF6L, 0x41047A60L,
-       0xDF60EFC3L, 0xA867DF55L, 0x316E8EEFL, 0x4669BE79L,
-       0xCB61B38CL, 0xBC66831AL, 0x256FD2A0L, 0x5268E236L,
-       0xCC0C7795L, 0xBB0B4703L, 0x220216B9L, 0x5505262FL,
-       0xC5BA3BBEL, 0xB2BD0B28L, 0x2BB45A92L, 0x5CB36A04L,
-       0xC2D7FFA7L, 0xB5D0CF31L, 0x2CD99E8BL, 0x5BDEAE1DL,
-       0x9B64C2B0L, 0xEC63F226L, 0x756AA39CL, 0x026D930AL,
-       0x9C0906A9L, 0xEB0E363FL, 0x72076785L, 0x05005713L,
-       0x95BF4A82L, 0xE2B87A14L, 0x7BB12BAEL, 0x0CB61B38L,
-       0x92D28E9BL, 0xE5D5BE0DL, 0x7CDCEFB7L, 0x0BDBDF21L,
-       0x86D3D2D4L, 0xF1D4E242L, 0x68DDB3F8L, 0x1FDA836EL,
-       0x81BE16CDL, 0xF6B9265BL, 0x6FB077E1L, 0x18B74777L,
-       0x88085AE6L, 0xFF0F6A70L, 0x66063BCAL, 0x11010B5CL,
-       0x8F659EFFL, 0xF862AE69L, 0x616BFFD3L, 0x166CCF45L,
-       0xA00AE278L, 0xD70DD2EEL, 0x4E048354L, 0x3903B3C2L,
-       0xA7672661L, 0xD06016F7L, 0x4969474DL, 0x3E6E77DBL,
-       0xAED16A4AL, 0xD9D65ADCL, 0x40DF0B66L, 0x37D83BF0L,
-       0xA9BCAE53L, 0xDEBB9EC5L, 0x47B2CF7FL, 0x30B5FFE9L,
-       0xBDBDF21CL, 0xCABAC28AL, 0x53B39330L, 0x24B4A3A6L,
-       0xBAD03605L, 0xCDD70693L, 0x54DE5729L, 0x23D967BFL,
-       0xB3667A2EL, 0xC4614AB8L, 0x5D681B02L, 0x2A6F2B94L,
-       0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL
-};
-
-/*---------------------  Static Functions  --------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*+
- *
- * Description:
- *    Generate a CRC-32 from the data stream
- *
- * Parameters:
- *  In:
- *      pbyData     - the data stream
- *      cbByte      - the length of the stream
- *      dwCrcSeed   - Seed for CRC32
- *  Out:
- *      none
- *
- * Return Value: CRC-32
- *
- -*/
-unsigned long CRCdwCrc32(unsigned char *pbyData, unsigned int cbByte, unsigned long dwCrcSeed)
-{
-       unsigned long dwCrc;
-
-       dwCrc = dwCrcSeed;
-       while (cbByte--) {
-               dwCrc = s_adwCrc32Table[(unsigned char)((dwCrc ^ (*pbyData)) & 0xFF)] ^ (dwCrc >> 8);
-               pbyData++;
-       }
-
-       return dwCrc;
-}
-
-/*+
- *
- * Description:
- * To test CRC generator, input 8 bytes packet
- *      -- 0xff 0xff 0xff 0xff 0x00 0x00 0x00 0x00
- * the generated CRC should be
- *      -- 0xff 0xff 0xff 0xff
- *
- * Parameters:
- *  In:
- *      pbyData     - the data stream
- *      cbByte      - the length of the stream
- *  Out:
- *      none
- *
- * Return Value: CRC-32
- *
- -*/
-unsigned long CRCdwGetCrc32(unsigned char *pbyData, unsigned int cbByte)
-{
-       return ~CRCdwCrc32(pbyData, cbByte, 0xFFFFFFFFL);
-}
-
-/*+
- *
- * Description:
- *
- * NOTE.... Because CRCdwGetCrc32Ex() is an iteration function,
- *          this means we will use the output of CRCdwGetCrc32Ex()
- *          to be a new argument to do next CRCdwGetCrc32Ex() calculation.
- *          Thus, the final result must be inverted to be the
- *          correct answer.
- *
- * Parameters:
- *  In:
- *      pbyData     - the data stream
- *      cbByte      - the length of the stream
- *  Out:
- *      none
- *
- * Return Value: CRC-32
- *
- -*/
-unsigned long CRCdwGetCrc32Ex(unsigned char *pbyData, unsigned int cbByte, unsigned long dwPreCRC)
-{
-       return CRCdwCrc32(pbyData, cbByte, dwPreCRC);
-}
diff --git a/drivers/staging/vt6655/tcrc.h b/drivers/staging/vt6655/tcrc.h
deleted file mode 100644 (file)
index 82b5dda..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2003 VIA Networking, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: tcrc.h
- *
- * Purpose: Implement functions to calculate CRC
- *
- * Author: Tevin Chen
- *
- * Date: Jan. 28, 1997
- *
- */
-
-#ifndef __TCRC_H__
-#define __TCRC_H__
-
-#include "ttype.h"
-
-/*---------------------  Export Definitions -------------------------*/
-
-/*---------------------  Export Types  ------------------------------*/
-
-/*---------------------  Export Macros ------------------------------*/
-
-/*---------------------  Export Classes  ----------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-unsigned long CRCdwCrc32(unsigned char *pbyData, unsigned int cbByte, unsigned long dwCrcSeed);
-unsigned long CRCdwGetCrc32(unsigned char *pbyData, unsigned int cbByte);
-unsigned long CRCdwGetCrc32Ex(unsigned char *pbyData, unsigned int cbByte, unsigned long dwPreCRC);
-
-#endif // __TCRC_H__
diff --git a/drivers/staging/vt6655/tether.c b/drivers/staging/vt6655/tether.c
deleted file mode 100644 (file)
index 1e7d3e2..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2003 VIA Networking, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: tether.c
- *
- * Purpose:
- *
- * Author: Tevin Chen
- *
- * Date: May 21, 1996
- *
- * Functions:
- *      ETHbyGetHashIndexByCrc32 - Calculate multicast hash value by CRC32
- *      ETHbIsBufferCrc32Ok - Check CRC value of the buffer if Ok or not
- *
- * Revision History:
- *
- */
-
-#include "device.h"
-#include "tmacro.h"
-#include "tcrc.h"
-#include "tether.h"
-
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Variables  --------------------------*/
-
-/*---------------------  Static Functions  --------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*
- * Description: Calculate multicast hash value by CRC32
- *
- * Parameters:
- *  In:
- *             pbyMultiAddr    - Multicast Address
- *  Out:
- *      none
- *
- * Return Value: Hash value
- *
- */
-unsigned char ETHbyGetHashIndexByCrc32(unsigned char *pbyMultiAddr)
-{
-       int     ii;
-       unsigned char byTmpHash;
-       unsigned char byHash = 0;
-
-       // get the least 6-bits from CRC generator
-       byTmpHash = (unsigned char)(CRCdwCrc32(pbyMultiAddr, ETH_ALEN,
-                                              0xFFFFFFFFL) & 0x3F);
-       // reverse most bit to least bit
-       for (ii = 0; ii < (sizeof(byTmpHash) * 8); ii++) {
-               byHash <<= 1;
-               if (byTmpHash & 0x01)
-                       byHash |= 1;
-               byTmpHash >>= 1;
-       }
-
-       // adjust 6-bits to the right most
-       return byHash >> 2;
-}
-
-/*
- * Description: Check CRC value of the buffer if Ok or not
- *
- * Parameters:
- *  In:
- *             pbyBuffer           - pointer of buffer (normally is rx buffer)
- *             cbFrameLength   - length of buffer, including CRC portion
- *  Out:
- *      none
- *
- * Return Value: true if ok; false if error.
- *
- */
-bool ETHbIsBufferCrc32Ok(unsigned char *pbyBuffer, unsigned int cbFrameLength)
-{
-       unsigned long dwCRC;
-
-       dwCRC = CRCdwGetCrc32(pbyBuffer, cbFrameLength - 4);
-       if (cpu_to_le32(*((unsigned long *)(pbyBuffer + cbFrameLength - 4))) != dwCRC)
-               return false;
-
-       return true;
-}
diff --git a/drivers/staging/vt6655/tether.h b/drivers/staging/vt6655/tether.h
deleted file mode 100644 (file)
index 94cc883..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: tether.h
- *
- * Purpose:
- *
- * Author: Tevin Chen
- *
- * Date: Jan. 28, 1997
- *
- */
-
-#ifndef __TETHER_H__
-#define __TETHER_H__
-
-#include <linux/etherdevice.h>
-#include "ttype.h"
-
-/*---------------------  Export Definitions -------------------------*/
-//
-// constants
-//
-#define U_ETHER_ADDR_STR_LEN (ETH_ALEN * 2 + 1)
-// Ethernet address string length
-
-#define MAX_LOOKAHEAD_SIZE  ETH_FRAME_LEN
-
-#define U_MULTI_ADDR_LEN    8           // multicast address length
-
-#ifdef __BIG_ENDIAN
-
-#define TYPE_PKT_IP         0x0800      //
-#define TYPE_PKT_ARP        0x0806      //
-#define TYPE_PKT_RARP       0x8035      //
-#define TYPE_PKT_IPX       0x8137          //
-#define TYPE_PKT_802_1x     0x888e
-#define TYPE_PKT_PreAuth    0x88C7
-
-#define TYPE_PKT_PING_M_REQ 0x8011      // master reguest
-#define TYPE_PKT_PING_S_GNT 0x8022      // slave grant
-#define TYPE_PKT_PING_M     0x8077      // pingpong master packet
-#define TYPE_PKT_PING_S     0x8088      // pingpong slave packet
-#define TYPE_PKT_WOL_M_REQ  0x8033      // WOL waker request
-#define TYPE_PKT_WOL_S_GNT  0x8044      // WOL sleeper grant
-#define TYPE_MGMT_PROBE_RSP 0x5000
-#define TYPE_PKT_VNT_DIAG   0x8011      // Diag Pkt
-#define TYPE_PKT_VNT_PER    0x8888      // Diag PER Pkt
-//
-// wFrameCtl field in the S802_11Header
-//
-// NOTE....
-//   in network byte order, high byte is going first
-#define FC_TODS             0x0001
-#define FC_FROMDS           0x0002
-#define FC_MOREFRAG         0x0004
-#define FC_RETRY            0x0008
-#define FC_POWERMGT         0x0010
-#define FC_MOREDATA         0x0020
-#define FC_WEP              0x0040
-#define TYPE_802_11_ATIM    0x9000
-
-#define TYPE_802_11_DATA    0x0800
-#define TYPE_802_11_CTL     0x0400
-#define TYPE_802_11_MGMT    0x0000
-#define TYPE_802_11_MASK    0x0C00
-#define TYPE_SUBTYPE_MASK   0xFC00
-#define TYPE_802_11_NODATA  0x4000
-#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
-//
-// wType field in the SEthernetHeader
-//
-// NOTE....
-//   in network byte order, high byte is going first
-#define TYPE_PKT_IP         0x0008      //
-#define TYPE_PKT_ARP        0x0608      //
-#define TYPE_PKT_RARP       0x3580      //
-#define TYPE_PKT_IPX       0x3781          //
-
-#define TYPE_PKT_802_1x     0x8e88
-#define TYPE_PKT_PreAuth    0xC788
-
-#define TYPE_PKT_PING_M_REQ 0x1180      // master reguest
-#define TYPE_PKT_PING_S_GNT 0x2280      // slave grant
-#define TYPE_PKT_PING_M     0x7780      // pingpong master packet
-#define TYPE_PKT_PING_S     0x8880      // pingpong slave packet
-#define TYPE_PKT_WOL_M_REQ  0x3380      // WOL waker request
-#define TYPE_PKT_WOL_S_GNT  0x4480      // WOL sleeper grant
-#define TYPE_MGMT_PROBE_RSP 0x0050
-#define TYPE_PKT_VNT_DIAG   0x1180      // Diag Pkt
-#define TYPE_PKT_VNT_PER    0x8888      // Diag PER Pkt
-//
-// wFrameCtl field in the S802_11Header
-//
-// NOTE....
-//   in network byte order, high byte is going first
-#define FC_TODS             0x0100
-#define FC_FROMDS           0x0200
-#define FC_MOREFRAG         0x0400
-#define FC_RETRY            0x0800
-#define FC_POWERMGT         0x1000
-#define FC_MOREDATA         0x2000
-#define FC_WEP              0x4000
-#define TYPE_802_11_ATIM    0x0090
-
-#define TYPE_802_11_DATA    0x0008
-#define TYPE_802_11_CTL     0x0004
-#define TYPE_802_11_MGMT    0x0000
-#define TYPE_802_11_MASK    0x000C
-#define TYPE_SUBTYPE_MASK   0x00FC
-#define TYPE_802_11_NODATA  0x0040
-#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
-
-#define WEP_IV_MASK         0x00FFFFFF
-
-/*---------------------  Export Types  ------------------------------*/
-//
-// Ethernet packet
-//
-typedef struct tagSEthernetHeader {
-       unsigned char abyDstAddr[ETH_ALEN];
-       unsigned char abySrcAddr[ETH_ALEN];
-       unsigned short wType;
-} __attribute__ ((__packed__))
-SEthernetHeader, *PSEthernetHeader;
-
-//
-// 802_3 packet
-//
-typedef struct tagS802_3Header {
-       unsigned char abyDstAddr[ETH_ALEN];
-       unsigned char abySrcAddr[ETH_ALEN];
-       unsigned short wLen;
-} __attribute__ ((__packed__))
-S802_3Header, *PS802_3Header;
-
-//
-// 802_11 packet
-//
-typedef struct tagS802_11Header {
-       unsigned short wFrameCtl;
-       unsigned short wDurationID;
-       unsigned char abyAddr1[ETH_ALEN];
-       unsigned char abyAddr2[ETH_ALEN];
-       unsigned char abyAddr3[ETH_ALEN];
-       unsigned short wSeqCtl;
-       unsigned char abyAddr4[ETH_ALEN];
-} __attribute__ ((__packed__))
-S802_11Header, *PS802_11Header;
-
-/*---------------------  Export Macros ------------------------------*/
-
-/*---------------------  Export Classes  ----------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-unsigned char ETHbyGetHashIndexByCrc32(unsigned char *pbyMultiAddr);
-//unsigned char ETHbyGetHashIndexByCrc(unsigned char *pbyMultiAddr);
-bool ETHbIsBufferCrc32Ok(unsigned char *pbyBuffer, unsigned int cbFrameLength);
-
-#endif // __TETHER_H__
diff --git a/drivers/staging/vt6655/tkip.c b/drivers/staging/vt6655/tkip.c
deleted file mode 100644 (file)
index f758d02..0000000
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: tkip.c
- *
- * Purpose: Implement functions for 802.11i TKIP
- *
- * Author: Jerry Chen
- *
- * Date: Mar. 11, 2003
- *
- * Functions:
- *      TKIPvMixKey - Get TKIP RC4 Key from TK,TA, and TSC
- *
- * Revision History:
- *
- */
-
-#include "tmacro.h"
-#include "tkip.h"
-
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Variables  --------------------------*/
-
-/*---------------------  Static Functions  --------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Variables  --------------------------*/
-
-/* The Sbox is reduced to 2 16-bit wide tables, each with 256 entries. */
-/* The 2nd table is the same as the 1st but with the upper and lower   */
-/* bytes swapped. To allow an endian tolerant implementation, the byte */
-/* halves have been expressed independently here.                      */
-static const unsigned char TKIP_Sbox_Lower[256] = {
-       0xA5, 0x84, 0x99, 0x8D, 0x0D, 0xBD, 0xB1, 0x54,
-       0x50, 0x03, 0xA9, 0x7D, 0x19, 0x62, 0xE6, 0x9A,
-       0x45, 0x9D, 0x40, 0x87, 0x15, 0xEB, 0xC9, 0x0B,
-       0xEC, 0x67, 0xFD, 0xEA, 0xBF, 0xF7, 0x96, 0x5B,
-       0xC2, 0x1C, 0xAE, 0x6A, 0x5A, 0x41, 0x02, 0x4F,
-       0x5C, 0xF4, 0x34, 0x08, 0x93, 0x73, 0x53, 0x3F,
-       0x0C, 0x52, 0x65, 0x5E, 0x28, 0xA1, 0x0F, 0xB5,
-       0x09, 0x36, 0x9B, 0x3D, 0x26, 0x69, 0xCD, 0x9F,
-       0x1B, 0x9E, 0x74, 0x2E, 0x2D, 0xB2, 0xEE, 0xFB,
-       0xF6, 0x4D, 0x61, 0xCE, 0x7B, 0x3E, 0x71, 0x97,
-       0xF5, 0x68, 0x00, 0x2C, 0x60, 0x1F, 0xC8, 0xED,
-       0xBE, 0x46, 0xD9, 0x4B, 0xDE, 0xD4, 0xE8, 0x4A,
-       0x6B, 0x2A, 0xE5, 0x16, 0xC5, 0xD7, 0x55, 0x94,
-       0xCF, 0x10, 0x06, 0x81, 0xF0, 0x44, 0xBA, 0xE3,
-       0xF3, 0xFE, 0xC0, 0x8A, 0xAD, 0xBC, 0x48, 0x04,
-       0xDF, 0xC1, 0x75, 0x63, 0x30, 0x1A, 0x0E, 0x6D,
-       0x4C, 0x14, 0x35, 0x2F, 0xE1, 0xA2, 0xCC, 0x39,
-       0x57, 0xF2, 0x82, 0x47, 0xAC, 0xE7, 0x2B, 0x95,
-       0xA0, 0x98, 0xD1, 0x7F, 0x66, 0x7E, 0xAB, 0x83,
-       0xCA, 0x29, 0xD3, 0x3C, 0x79, 0xE2, 0x1D, 0x76,
-       0x3B, 0x56, 0x4E, 0x1E, 0xDB, 0x0A, 0x6C, 0xE4,
-       0x5D, 0x6E, 0xEF, 0xA6, 0xA8, 0xA4, 0x37, 0x8B,
-       0x32, 0x43, 0x59, 0xB7, 0x8C, 0x64, 0xD2, 0xE0,
-       0xB4, 0xFA, 0x07, 0x25, 0xAF, 0x8E, 0xE9, 0x18,
-       0xD5, 0x88, 0x6F, 0x72, 0x24, 0xF1, 0xC7, 0x51,
-       0x23, 0x7C, 0x9C, 0x21, 0xDD, 0xDC, 0x86, 0x85,
-       0x90, 0x42, 0xC4, 0xAA, 0xD8, 0x05, 0x01, 0x12,
-       0xA3, 0x5F, 0xF9, 0xD0, 0x91, 0x58, 0x27, 0xB9,
-       0x38, 0x13, 0xB3, 0x33, 0xBB, 0x70, 0x89, 0xA7,
-       0xB6, 0x22, 0x92, 0x20, 0x49, 0xFF, 0x78, 0x7A,
-       0x8F, 0xF8, 0x80, 0x17, 0xDA, 0x31, 0xC6, 0xB8,
-       0xC3, 0xB0, 0x77, 0x11, 0xCB, 0xFC, 0xD6, 0x3A
-};
-
-static const unsigned char TKIP_Sbox_Upper[256] = {
-       0xC6, 0xF8, 0xEE, 0xF6, 0xFF, 0xD6, 0xDE, 0x91,
-       0x60, 0x02, 0xCE, 0x56, 0xE7, 0xB5, 0x4D, 0xEC,
-       0x8F, 0x1F, 0x89, 0xFA, 0xEF, 0xB2, 0x8E, 0xFB,
-       0x41, 0xB3, 0x5F, 0x45, 0x23, 0x53, 0xE4, 0x9B,
-       0x75, 0xE1, 0x3D, 0x4C, 0x6C, 0x7E, 0xF5, 0x83,
-       0x68, 0x51, 0xD1, 0xF9, 0xE2, 0xAB, 0x62, 0x2A,
-       0x08, 0x95, 0x46, 0x9D, 0x30, 0x37, 0x0A, 0x2F,
-       0x0E, 0x24, 0x1B, 0xDF, 0xCD, 0x4E, 0x7F, 0xEA,
-       0x12, 0x1D, 0x58, 0x34, 0x36, 0xDC, 0xB4, 0x5B,
-       0xA4, 0x76, 0xB7, 0x7D, 0x52, 0xDD, 0x5E, 0x13,
-       0xA6, 0xB9, 0x00, 0xC1, 0x40, 0xE3, 0x79, 0xB6,
-       0xD4, 0x8D, 0x67, 0x72, 0x94, 0x98, 0xB0, 0x85,
-       0xBB, 0xC5, 0x4F, 0xED, 0x86, 0x9A, 0x66, 0x11,
-       0x8A, 0xE9, 0x04, 0xFE, 0xA0, 0x78, 0x25, 0x4B,
-       0xA2, 0x5D, 0x80, 0x05, 0x3F, 0x21, 0x70, 0xF1,
-       0x63, 0x77, 0xAF, 0x42, 0x20, 0xE5, 0xFD, 0xBF,
-       0x81, 0x18, 0x26, 0xC3, 0xBE, 0x35, 0x88, 0x2E,
-       0x93, 0x55, 0xFC, 0x7A, 0xC8, 0xBA, 0x32, 0xE6,
-       0xC0, 0x19, 0x9E, 0xA3, 0x44, 0x54, 0x3B, 0x0B,
-       0x8C, 0xC7, 0x6B, 0x28, 0xA7, 0xBC, 0x16, 0xAD,
-       0xDB, 0x64, 0x74, 0x14, 0x92, 0x0C, 0x48, 0xB8,
-       0x9F, 0xBD, 0x43, 0xC4, 0x39, 0x31, 0xD3, 0xF2,
-       0xD5, 0x8B, 0x6E, 0xDA, 0x01, 0xB1, 0x9C, 0x49,
-       0xD8, 0xAC, 0xF3, 0xCF, 0xCA, 0xF4, 0x47, 0x10,
-       0x6F, 0xF0, 0x4A, 0x5C, 0x38, 0x57, 0x73, 0x97,
-       0xCB, 0xA1, 0xE8, 0x3E, 0x96, 0x61, 0x0D, 0x0F,
-       0xE0, 0x7C, 0x71, 0xCC, 0x90, 0x06, 0xF7, 0x1C,
-       0xC2, 0x6A, 0xAE, 0x69, 0x17, 0x99, 0x3A, 0x27,
-       0xD9, 0xEB, 0x2B, 0x22, 0xD2, 0xA9, 0x07, 0x33,
-       0x2D, 0x3C, 0x15, 0xC9, 0x87, 0xAA, 0x50, 0xA5,
-       0x03, 0x59, 0x09, 0x1A, 0x65, 0xD7, 0x84, 0xD0,
-       0x82, 0x29, 0x5A, 0x1E, 0x7B, 0xA8, 0x6D, 0x2C
-};
-
-//STKIPKeyManagement  sTKIPKeyTable[MAX_TKIP_KEY];
-
-/*---------------------  Static Functions  --------------------------*/
-unsigned int tkip_sbox(unsigned int index);
-unsigned int rotr1(unsigned int a);
-
-/*---------------------  Export Variables  --------------------------*/
-
-/************************************************************/
-/* tkip_sbox()                                              */
-/* Returns a 16 bit value from a 64K entry table. The Table */
-/* is synthesized from two 256 entry byte wide tables.      */
-/************************************************************/
-unsigned int tkip_sbox(unsigned int index)
-{
-       unsigned int index_low;
-       unsigned int index_high;
-       unsigned int left, right;
-
-       index_low = (index % 256);
-       index_high = ((index >> 8) % 256);
-
-       left = TKIP_Sbox_Lower[index_low] + (TKIP_Sbox_Upper[index_low] * 256);
-       right = TKIP_Sbox_Upper[index_high] + (TKIP_Sbox_Lower[index_high] * 256);
-
-       return left ^ right;
-};
-
-unsigned int rotr1(unsigned int a)
-{
-       unsigned int b;
-
-       if ((a & 0x01) == 0x01)
-               b = (a >> 1) | 0x8000;
-       else
-               b = (a >> 1) & 0x7fff;
-
-       b = b % 65536;
-       return b;
-}
-
-/*
- * Description: Calculate RC4Key fom TK, TA, and TSC
- *
- * Parameters:
- *  In:
- *      pbyTKey         - TKey
- *      pbyTA           - TA
- *      dwTSC           - TSC
- *  Out:
- *      pbyRC4Key       - RC4Key
- *
- * Return Value: none
- *
- */
-void TKIPvMixKey(
-       unsigned char *pbyTKey,
-       unsigned char *pbyTA,
-       unsigned short wTSC15_0,
-       unsigned long dwTSC47_16,
-       unsigned char *pbyRC4Key
-)
-{
-       unsigned int p1k[5];
-       unsigned int tsc0, tsc1, tsc2;
-       unsigned int ppk0, ppk1, ppk2, ppk3, ppk4, ppk5;
-       unsigned long int pnl, pnh;
-
-       int i, j;
-
-       pnl = wTSC15_0;
-       pnh = dwTSC47_16;
-
-       tsc0 = (unsigned int)((pnh >> 16) % 65536); /* msb */
-       tsc1 = (unsigned int)(pnh % 65536);
-       tsc2 = (unsigned int)(pnl % 65536); /* lsb */
-
-       /* Phase 1, step 1 */
-       p1k[0] = tsc1;
-       p1k[1] = tsc0;
-       p1k[2] = (unsigned int)(pbyTA[0] + (pbyTA[1]*256));
-       p1k[3] = (unsigned int)(pbyTA[2] + (pbyTA[3]*256));
-       p1k[4] = (unsigned int)(pbyTA[4] + (pbyTA[5]*256));
-
-       /* Phase 1, step 2 */
-       for (i = 0; i < 8; i++) {
-               j = 2 * (i & 1);
-               p1k[0] = (p1k[0] + tkip_sbox((p1k[4] ^ ((256*pbyTKey[1+j]) + pbyTKey[j])) % 65536)) % 65536;
-               p1k[1] = (p1k[1] + tkip_sbox((p1k[0] ^ ((256*pbyTKey[5+j]) + pbyTKey[4+j])) % 65536)) % 65536;
-               p1k[2] = (p1k[2] + tkip_sbox((p1k[1] ^ ((256*pbyTKey[9+j]) + pbyTKey[8+j])) % 65536)) % 65536;
-               p1k[3] = (p1k[3] + tkip_sbox((p1k[2] ^ ((256*pbyTKey[13+j]) + pbyTKey[12+j])) % 65536)) % 65536;
-               p1k[4] = (p1k[4] + tkip_sbox((p1k[3] ^ (((256*pbyTKey[1+j]) + pbyTKey[j]))) % 65536)) % 65536;
-               p1k[4] = (p1k[4] + i) % 65536;
-       }
-       /* Phase 2, Step 1 */
-       ppk0 = p1k[0];
-       ppk1 = p1k[1];
-       ppk2 = p1k[2];
-       ppk3 = p1k[3];
-       ppk4 = p1k[4];
-       ppk5 = (p1k[4] + tsc2) % 65536;
-
-       /* Phase2, Step 2 */
-       ppk0 = ppk0 + tkip_sbox((ppk5 ^ ((256*pbyTKey[1]) + pbyTKey[0])) % 65536);
-       ppk1 = ppk1 + tkip_sbox((ppk0 ^ ((256*pbyTKey[3]) + pbyTKey[2])) % 65536);
-       ppk2 = ppk2 + tkip_sbox((ppk1 ^ ((256*pbyTKey[5]) + pbyTKey[4])) % 65536);
-       ppk3 = ppk3 + tkip_sbox((ppk2 ^ ((256*pbyTKey[7]) + pbyTKey[6])) % 65536);
-       ppk4 = ppk4 + tkip_sbox((ppk3 ^ ((256*pbyTKey[9]) + pbyTKey[8])) % 65536);
-       ppk5 = ppk5 + tkip_sbox((ppk4 ^ ((256*pbyTKey[11]) + pbyTKey[10])) % 65536);
-
-       ppk0 = ppk0 + rotr1(ppk5 ^ ((256*pbyTKey[13]) + pbyTKey[12]));
-       ppk1 = ppk1 + rotr1(ppk0 ^ ((256*pbyTKey[15]) + pbyTKey[14]));
-       ppk2 = ppk2 + rotr1(ppk1);
-       ppk3 = ppk3 + rotr1(ppk2);
-       ppk4 = ppk4 + rotr1(ppk3);
-       ppk5 = ppk5 + rotr1(ppk4);
-
-       /* Phase 2, Step 3 */
-       pbyRC4Key[0] = (tsc2 >> 8) % 256;
-       pbyRC4Key[1] = (((tsc2 >> 8) % 256) | 0x20) & 0x7f;
-       pbyRC4Key[2] = tsc2 % 256;
-       pbyRC4Key[3] = ((ppk5 ^ ((256*pbyTKey[1]) + pbyTKey[0])) >> 1) % 256;
-
-       pbyRC4Key[4] = ppk0 % 256;
-       pbyRC4Key[5] = (ppk0 >> 8) % 256;
-
-       pbyRC4Key[6] = ppk1 % 256;
-       pbyRC4Key[7] = (ppk1 >> 8) % 256;
-
-       pbyRC4Key[8] = ppk2 % 256;
-       pbyRC4Key[9] = (ppk2 >> 8) % 256;
-
-       pbyRC4Key[10] = ppk3 % 256;
-       pbyRC4Key[11] = (ppk3 >> 8) % 256;
-
-       pbyRC4Key[12] = ppk4 % 256;
-       pbyRC4Key[13] = (ppk4 >> 8) % 256;
-
-       pbyRC4Key[14] = ppk5 % 256;
-       pbyRC4Key[15] = (ppk5 >> 8) % 256;
-}
diff --git a/drivers/staging/vt6655/tkip.h b/drivers/staging/vt6655/tkip.h
deleted file mode 100644 (file)
index 3b6357a..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: tkip.h
- *
- * Purpose: Implement functions for 802.11i TKIP
- *
- * Author: Jerry Chen
- *
- * Date: Mar. 11, 2003
- *
- */
-
-#ifndef __TKIP_H__
-#define __TKIP_H__
-
-#include "ttype.h"
-#include "tether.h"
-
-/*---------------------  Export Definitions -------------------------*/
-#define TKIP_KEY_LEN        16
-
-/*---------------------  Export Types  ------------------------------*/
-
-/*---------------------  Export Macros ------------------------------*/
-
-/*---------------------  Export Classes  ----------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-void TKIPvMixKey(
-       unsigned char *pbyTKey,
-       unsigned char *pbyTA,
-       unsigned short wTSC15_0,
-       unsigned long dwTSC47_16,
-       unsigned char *pbyRC4Key
-);
-
-#endif // __TKIP_H__
index 59c6e72..607b78f 100644 (file)
@@ -29,8 +29,6 @@
 #ifndef __TMACRO_H__
 #define __TMACRO_H__
 
-#include "ttype.h"
-
 /****** Common helper macros ***********************************************/
 
 #if !defined(LOBYTE)
diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h
deleted file mode 100644 (file)
index 747ef62..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: ttype.h
- *
- * Purpose: define basic common types and macros
- *
- * Author: Tevin Chen
- *
- * Date: May 21, 1996
- *
- */
-
-#ifndef __TTYPE_H__
-#define __TTYPE_H__
-
-/******* Common definitions and typedefs ***********************************/
-
-#ifndef WPA_SM_Transtatus
-#define WPA_SM_Transtatus
-#endif
-
-#ifndef Calcu_LinkQual
-#define Calcu_LinkQual
-#endif
-
-#endif // __TTYPE_H__
index c5c889c..c53703a 100644 (file)
@@ -30,7 +30,6 @@
 #define __UPC_H__
 
 #include "device.h"
-#include "ttype.h"
 
 /*---------------------  Export Definitions -------------------------*/
 
diff --git a/drivers/staging/vt6655/vntconfiguration.dat b/drivers/staging/vt6655/vntconfiguration.dat
deleted file mode 100644 (file)
index 0064ddc..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ZONETYPE=EUROPE
\ No newline at end of file
diff --git a/drivers/staging/vt6655/vntwifi.c b/drivers/staging/vt6655/vntwifi.c
deleted file mode 100644 (file)
index 59f66fe..0000000
+++ /dev/null
@@ -1,700 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: vntwifi.c
- *
- * Purpose: export functions for vntwifi lib
- *
- * Functions:
- *
- * Revision History:
- *
- * Author: Yiching Chen
- *
- * Date: feb. 2, 2005
- *
- */
-
-#include "vntwifi.h"
-#include "IEEE11h.h"
-#include "country.h"
-#include "device.h"
-#include "wmgr.h"
-#include "datarate.h"
-
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Variables  --------------------------*/
-
-/*---------------------  Static Functions  --------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-/*+
- *
- * Description:
- *    Set Operation Mode
- *
- * Parameters:
- *  In:
- *      pMgmtHandle - pointer to management object
- *      eOPMode     - Operation Mode
- *  Out:
- *      none
- *
- * Return Value: none
- *
- -*/
-void
-VNTWIFIvSetOPMode(
-       void *pMgmtHandle,
-       WMAC_CONFIG_MODE eOPMode
-)
-{
-       PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
-
-       pMgmt->eConfigMode = eOPMode;
-}
-
-/*+
- *
- * Description:
- *    Set Operation Mode
- *
- * Parameters:
- *  In:
- *      pMgmtHandle - pointer to management object
- *      wBeaconPeriod - Beacon Period
- *      wATIMWindow - ATIM window
- *      uChannel - channel number
- *  Out:
- *      none
- *
- * Return Value: none
- *
- -*/
-void
-VNTWIFIvSetIBSSParameter(
-       void *pMgmtHandle,
-       unsigned short wBeaconPeriod,
-       unsigned short wATIMWindow,
-       unsigned int uChannel
-)
-{
-       PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
-
-       pMgmt->wIBSSBeaconPeriod = wBeaconPeriod;
-       pMgmt->wIBSSATIMWindow = wATIMWindow;
-       pMgmt->uIBSSChannel = uChannel;
-}
-
-/*+
- *
- * Description:
- *    Get current SSID
- *
- * Parameters:
- *  In:
- *      pMgmtHandle - pointer to management object
- *  Out:
- *      none
- *
- * Return Value: current SSID pointer.
- *
- -*/
-PWLAN_IE_SSID
-VNTWIFIpGetCurrentSSID(
-       void *pMgmtHandle
-)
-{
-       PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
-
-       return (PWLAN_IE_SSID) pMgmt->abyCurrSSID;
-}
-
-/*+
- *
- * Description:
- *    Get current link channel
- *
- * Parameters:
- *  In:
- *      pMgmtHandle - pointer to management object
- *  Out:
- *      none
- *
- * Return Value: current Channel.
- *
- -*/
-unsigned int
-VNTWIFIpGetCurrentChannel(
-       void *pMgmtHandle
-)
-{
-       PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
-
-       if (pMgmtHandle != NULL)
-               return pMgmt->uCurrChannel;
-
-       return 0;
-}
-
-/*+
- *
- * Description:
- *    Get current Assoc ID
- *
- * Parameters:
- *  In:
- *      pMgmtHandle - pointer to management object
- *  Out:
- *      none
- *
- * Return Value: current Assoc ID
- *
- -*/
-unsigned short
-VNTWIFIwGetAssocID(
-       void *pMgmtHandle
-)
-{
-       PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
-
-       return pMgmt->wCurrAID;
-}
-
-/*+
- *
- * Description:
- *    This routine return max support rate of IES
- *
- * Parameters:
- *  In:
- *      pSupportRateIEs
- *      pExtSupportRateIEs
- *
- *  Out:
- *
- * Return Value: max support rate
- *
- -*/
-unsigned char
-VNTWIFIbyGetMaxSupportRate(
-       PWLAN_IE_SUPP_RATES pSupportRateIEs,
-       PWLAN_IE_SUPP_RATES pExtSupportRateIEs
-)
-{
-       unsigned char byMaxSupportRate = RATE_1M;
-       unsigned char bySupportRate = RATE_1M;
-       unsigned int ii = 0;
-
-       if (pSupportRateIEs) {
-               for (ii = 0; ii < pSupportRateIEs->len; ii++) {
-                       bySupportRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]);
-                       if (bySupportRate > byMaxSupportRate)
-                               byMaxSupportRate = bySupportRate;
-
-               }
-       }
-       if (pExtSupportRateIEs) {
-               for (ii = 0; ii < pExtSupportRateIEs->len; ii++) {
-                       bySupportRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]);
-                       if (bySupportRate > byMaxSupportRate)
-                               byMaxSupportRate = bySupportRate;
-
-               }
-       }
-
-       return byMaxSupportRate;
-}
-
-/*+
- *
- * Description:
- *    This routine return data rate of ACK packtet
- *
- * Parameters:
- *  In:
- *      byRxDataRate
- *      pSupportRateIEs
- *      pExtSupportRateIEs
- *
- *  Out:
- *
- * Return Value: max support rate
- *
- -*/
-unsigned char
-VNTWIFIbyGetACKTxRate(
-       unsigned char byRxDataRate,
-       PWLAN_IE_SUPP_RATES pSupportRateIEs,
-       PWLAN_IE_SUPP_RATES pExtSupportRateIEs
-)
-{
-       unsigned char byMaxAckRate;
-       unsigned char byBasicRate;
-       unsigned int ii;
-
-       if (byRxDataRate <= RATE_11M) {
-               byMaxAckRate = RATE_1M;
-       } else  {
-               /* 24M is mandatory for 802.11a and 802.11g */
-               byMaxAckRate = RATE_24M;
-       }
-       if (pSupportRateIEs) {
-               for (ii = 0; ii < pSupportRateIEs->len; ii++) {
-                       if (pSupportRateIEs->abyRates[ii] & 0x80) {
-                               byBasicRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]);
-                               if ((byBasicRate <= byRxDataRate) &&
-                                   (byBasicRate > byMaxAckRate))  {
-                                       byMaxAckRate = byBasicRate;
-                               }
-                       }
-               }
-       }
-       if (pExtSupportRateIEs) {
-               for (ii = 0; ii < pExtSupportRateIEs->len; ii++) {
-                       if (pExtSupportRateIEs->abyRates[ii] & 0x80) {
-                               byBasicRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]);
-                               if ((byBasicRate <= byRxDataRate) &&
-                                   (byBasicRate > byMaxAckRate))  {
-                                       byMaxAckRate = byBasicRate;
-                               }
-                       }
-               }
-       }
-
-       return byMaxAckRate;
-}
-
-/*+
- *
- * Description:
- *    Set Authentication Mode
- *
- * Parameters:
- *  In:
- *      pMgmtHandle - pointer to management object
- *      eAuthMode   - Authentication mode
- *  Out:
- *      none
- *
- * Return Value: none
- *
- -*/
-void
-VNTWIFIvSetAuthenticationMode(
-       void *pMgmtHandle,
-       WMAC_AUTHENTICATION_MODE eAuthMode
-)
-{
-       PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
-
-       pMgmt->eAuthenMode = eAuthMode;
-       if ((eAuthMode == WMAC_AUTH_SHAREKEY) ||
-           (eAuthMode == WMAC_AUTH_AUTO)) {
-               pMgmt->bShareKeyAlgorithm = true;
-       } else {
-               pMgmt->bShareKeyAlgorithm = false;
-       }
-}
-
-/*+
- *
- * Description:
- *    Set Encryption Mode
- *
- * Parameters:
- *  In:
- *      pMgmtHandle - pointer to management object
- *      eAuthMode   - Authentication mode
- *  Out:
- *      none
- *
- * Return Value: none
- *
- -*/
-void
-VNTWIFIvSetEncryptionMode(
-       void *pMgmtHandle,
-       WMAC_ENCRYPTION_MODE eEncryptionMode
-)
-{
-       PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
-
-       pMgmt->eEncryptionMode = eEncryptionMode;
-       if ((eEncryptionMode == WMAC_ENCRYPTION_WEPEnabled) ||
-           (eEncryptionMode == WMAC_ENCRYPTION_TKIPEnabled) ||
-           (eEncryptionMode == WMAC_ENCRYPTION_AESEnabled)) {
-               pMgmt->bPrivacyInvoked = true;
-       } else {
-               pMgmt->bPrivacyInvoked = false;
-       }
-}
-
-bool
-VNTWIFIbConfigPhyMode(
-       void *pMgmtHandle,
-       CARD_PHY_TYPE ePhyType
-)
-{
-       PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
-
-       if ((ePhyType != PHY_TYPE_AUTO) &&
-           (ePhyType != pMgmt->eCurrentPHYMode)) {
-               if (CARDbSetPhyParameter(pMgmt->pAdapter, ePhyType, 0, 0, NULL, NULL) == true)
-                       pMgmt->eCurrentPHYMode = ePhyType;
-               else
-                       return false;
-       }
-       pMgmt->eConfigPHYMode = ePhyType;
-       return true;
-}
-
-void
-VNTWIFIbGetConfigPhyMode(
-       void *pMgmtHandle,
-       void *pePhyType
-)
-{
-       PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
-
-       if ((pMgmt != NULL) && (pePhyType != NULL))
-               *(PCARD_PHY_TYPE)pePhyType = pMgmt->eConfigPHYMode;
-}
-
-/*+
- *
- * Description:
- *      Clear BSS List Database except current assoc BSS
- *
- * Parameters:
- *  In:
- *      pMgmtHandle     - Management Object structure
- *      bLinkPass       - Current Link status
- *  Out:
- *
- * Return Value: None.
- *
- -*/
-
-/*+
- *
- * Description:
- *      Query BSS List in management database
- *
- * Parameters:
- *  In:
- *      pMgmtHandle     - Management Object structure
- *  Out:
- *      puBSSCount      - BSS count
- *      pvFirstBSS      - pointer to first BSS
- *
- * Return Value: None.
- *
- -*/
-
-void
-VNTWIFIvQueryBSSList(void *pMgmtHandle, unsigned int *puBSSCount, void **pvFirstBSS)
-{
-       unsigned int ii = 0;
-       PSMgmtObject    pMgmt = (PSMgmtObject)pMgmtHandle;
-       PKnownBSS       pBSS = NULL;
-       unsigned int uCount = 0;
-
-       *pvFirstBSS = NULL;
-
-       for (ii = 0; ii < MAX_BSS_NUM; ii++) {
-               pBSS = &(pMgmt->sBSSList[ii]);
-               if (!pBSS->bActive)
-                       continue;
-
-               if (*pvFirstBSS == NULL)
-                       *pvFirstBSS = &(pMgmt->sBSSList[ii]);
-
-               uCount++;
-       }
-       *puBSSCount = uCount;
-}
-
-void
-VNTWIFIvGetNextBSS(
-       void *pMgmtHandle,
-       void *pvCurrentBSS,
-       void **pvNextBSS
-)
-{
-       PKnownBSS       pBSS = (PKnownBSS) pvCurrentBSS;
-       PSMgmtObject    pMgmt = (PSMgmtObject)pMgmtHandle;
-
-       *pvNextBSS = NULL;
-
-       while (*pvNextBSS == NULL) {
-               pBSS++;
-               if (pBSS > &(pMgmt->sBSSList[MAX_BSS_NUM]))
-                       return;
-
-               if (pBSS->bActive == true) {
-                       *pvNextBSS = pBSS;
-                       return;
-               }
-       }
-}
-
-/*+
- *
- * Description:
- *      Update Tx attemps, Tx failure counter in Node DB
- *
- *  In:
- *  Out:
- *      none
- *
- * Return Value: none
- *
- -*/
-void
-VNTWIFIvUpdateNodeTxCounter(
-       void *pMgmtHandle,
-       unsigned char *pbyDestAddress,
-       bool bTxOk,
-       unsigned short wRate,
-       unsigned char *pbyTxFailCount
-)
-{
-       PSMgmtObject    pMgmt = (PSMgmtObject)pMgmtHandle;
-       unsigned int uNodeIndex = 0;
-       unsigned int ii;
-
-       if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
-           (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
-               if (BSSDBbIsSTAInNodeDB(pMgmt, pbyDestAddress, &uNodeIndex) == false)
-                       return;
-       }
-
-       pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts++;
-       if (bTxOk) {
-               /* transmit success, TxAttempts at least plus one */
-               pMgmt->sNodeDBTable[uNodeIndex].uTxOk[MAX_RATE]++;
-               pMgmt->sNodeDBTable[uNodeIndex].uTxOk[wRate]++;
-       } else {
-               pMgmt->sNodeDBTable[uNodeIndex].uTxFailures++;
-       }
-       pMgmt->sNodeDBTable[uNodeIndex].uTxRetry += pbyTxFailCount[MAX_RATE];
-       for (ii = 0; ii < MAX_RATE; ii++)
-               pMgmt->sNodeDBTable[uNodeIndex].uTxFail[ii] += pbyTxFailCount[ii];
-}
-
-void
-VNTWIFIvGetTxRate(
-       void *pMgmtHandle,
-       unsigned char *pbyDestAddress,
-       unsigned short *pwTxDataRate,
-       unsigned char *pbyACKRate,
-       unsigned char *pbyCCKBasicRate,
-       unsigned char *pbyOFDMBasicRate
-)
-{
-       PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
-       unsigned int uNodeIndex = 0;
-       unsigned short wTxDataRate = RATE_1M;
-       unsigned char byACKRate = RATE_1M;
-       unsigned char byCCKBasicRate = RATE_1M;
-       unsigned char byOFDMBasicRate = RATE_24M;
-       PWLAN_IE_SUPP_RATES pSupportRateIEs = NULL;
-       PWLAN_IE_SUPP_RATES pExtSupportRateIEs = NULL;
-
-       if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
-           (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
-               /* Adhoc Tx rate decided from node DB */
-               if (BSSDBbIsSTAInNodeDB(pMgmt, pbyDestAddress, &uNodeIndex)) {
-                       wTxDataRate = (pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate);
-                       pSupportRateIEs = (PWLAN_IE_SUPP_RATES) (pMgmt->sNodeDBTable[uNodeIndex].abyCurrSuppRates);
-                       pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) (pMgmt->sNodeDBTable[uNodeIndex].abyCurrExtSuppRates);
-               } else {
-                       if (pMgmt->eCurrentPHYMode != PHY_TYPE_11A)
-                               wTxDataRate = RATE_2M;
-                       else
-                               wTxDataRate = RATE_24M;
-
-                       pSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrSuppRates;
-                       pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrExtSuppRates;
-               }
-       } else { /* Infrastructure: rate decided from AP Node, index = 0 */
-
-               wTxDataRate = (pMgmt->sNodeDBTable[0].wTxDataRate);
-
-               pSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrSuppRates;
-               pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrExtSuppRates;
-       }
-       byACKRate = VNTWIFIbyGetACKTxRate((unsigned char) wTxDataRate,
-                                           pSupportRateIEs,
-                                           pExtSupportRateIEs
-);
-       if (byACKRate > (unsigned char) wTxDataRate)
-               byACKRate = (unsigned char) wTxDataRate;
-
-       byCCKBasicRate = VNTWIFIbyGetACKTxRate(RATE_11M,
-                                               pSupportRateIEs,
-                                               pExtSupportRateIEs
-);
-       byOFDMBasicRate = VNTWIFIbyGetACKTxRate(RATE_54M,
-                                               pSupportRateIEs,
-                                               pExtSupportRateIEs
-);
-       *pwTxDataRate = wTxDataRate;
-       *pbyACKRate = byACKRate;
-       *pbyCCKBasicRate = byCCKBasicRate;
-       *pbyOFDMBasicRate = byOFDMBasicRate;
-}
-
-unsigned char
-VNTWIFIbyGetKeyCypher(
-       void *pMgmtHandle,
-       bool bGroupKey
-)
-{
-       PSMgmtObject    pMgmt = (PSMgmtObject)pMgmtHandle;
-
-       if (bGroupKey)
-               return pMgmt->byCSSGK;
-       else
-               return pMgmt->byCSSPK;
-}
-
-bool
-VNTWIFIbSetPMKIDCache(
-       void *pMgmtObject,
-       unsigned long ulCount,
-       void *pPMKIDInfo
-)
-{
-       PSMgmtObject    pMgmt = (PSMgmtObject) pMgmtObject;
-
-       if (ulCount > MAX_PMKID_CACHE)
-               return false;
-
-       pMgmt->gsPMKIDCache.BSSIDInfoCount = ulCount;
-       memcpy(pMgmt->gsPMKIDCache.BSSIDInfo, pPMKIDInfo, (ulCount*sizeof(PMKIDInfo)));
-       return true;
-}
-
-unsigned short
-VNTWIFIwGetMaxSupportRate(
-       void *pMgmtObject
-)
-{
-       unsigned short wRate = RATE_54M;
-       PSMgmtObject    pMgmt = (PSMgmtObject) pMgmtObject;
-
-       for (wRate = RATE_54M; wRate > RATE_1M; wRate--) {
-               if (pMgmt->sNodeDBTable[0].wSuppRate & (1<<wRate))
-                       return wRate;
-       }
-
-       if (pMgmt->eCurrentPHYMode == PHY_TYPE_11A)
-               return RATE_6M;
-       else
-               return RATE_1M;
-}
-
-void
-VNTWIFIvSet11h(
-       void *pMgmtObject,
-       bool b11hEnable
-)
-{
-       PSMgmtObject    pMgmt = (PSMgmtObject) pMgmtObject;
-
-       pMgmt->b11hEnable = b11hEnable;
-}
-
-bool
-VNTWIFIbMeasureReport(
-       void *pMgmtObject,
-       bool bEndOfReport,
-       void *pvMeasureEID,
-       unsigned char byReportMode,
-       unsigned char byBasicMap,
-       unsigned char byCCAFraction,
-       unsigned char *pbyRPIs
-)
-{
-       PSMgmtObject    pMgmt = (PSMgmtObject) pMgmtObject;
-       unsigned char *pbyCurrentEID = (unsigned char *)(pMgmt->pCurrMeasureEIDRep);
-
-       if ((pvMeasureEID != NULL) &&
-           (pMgmt->uLengthOfRepEIDs < (WLAN_A3FR_MAXLEN - sizeof(MEASEURE_REP) - sizeof(WLAN_80211HDR_A3) - 3))
-) {
-               pMgmt->pCurrMeasureEIDRep->byElementID = WLAN_EID_MEASURE_REP;
-               pMgmt->pCurrMeasureEIDRep->len = 3;
-               pMgmt->pCurrMeasureEIDRep->byToken = ((PWLAN_IE_MEASURE_REQ)pvMeasureEID)->byToken;
-               pMgmt->pCurrMeasureEIDRep->byMode = byReportMode;
-               pMgmt->pCurrMeasureEIDRep->byType = ((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->byType;
-               switch (pMgmt->pCurrMeasureEIDRep->byType) {
-               case MEASURE_TYPE_BASIC:
-                       pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_BASIC);
-                       memcpy(&(pMgmt->pCurrMeasureEIDRep->sRep.sBasic),
-                              &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
-                              sizeof(MEASEURE_REQ));
-                       pMgmt->pCurrMeasureEIDRep->sRep.sBasic.byMap = byBasicMap;
-                       break;
-               case MEASURE_TYPE_CCA:
-                       pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_CCA);
-                       memcpy(&(pMgmt->pCurrMeasureEIDRep->sRep.sCCA),
-                              &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
-                              sizeof(MEASEURE_REQ));
-                       pMgmt->pCurrMeasureEIDRep->sRep.sCCA.byCCABusyFraction = byCCAFraction;
-                       break;
-               case MEASURE_TYPE_RPI:
-                       pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_RPI);
-                       memcpy(&(pMgmt->pCurrMeasureEIDRep->sRep.sRPI),
-                              &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
-                              sizeof(MEASEURE_REQ));
-                       memcpy(pMgmt->pCurrMeasureEIDRep->sRep.sRPI.abyRPIdensity, pbyRPIs, 8);
-                       break;
-               default:
-                       break;
-               }
-               pbyCurrentEID += (2 + pMgmt->pCurrMeasureEIDRep->len);
-               pMgmt->uLengthOfRepEIDs += (2 + pMgmt->pCurrMeasureEIDRep->len);
-               pMgmt->pCurrMeasureEIDRep = (PWLAN_IE_MEASURE_REP) pbyCurrentEID;
-       }
-       if (bEndOfReport)
-               IEEE11hbMSRRepTx(pMgmt);
-
-       return true;
-}
-
-bool
-VNTWIFIbChannelSwitch(
-       void *pMgmtObject,
-       unsigned char byNewChannel
-)
-{
-       PSMgmtObject    pMgmt = (PSMgmtObject) pMgmtObject;
-
-       pMgmt->uCurrChannel = byNewChannel;
-       pMgmt->bSwitchChannel = false;
-       return true;
-}
diff --git a/drivers/staging/vt6655/vntwifi.h b/drivers/staging/vt6655/vntwifi.h
deleted file mode 100644 (file)
index 880b8ab..0000000
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: vntwifi.h
- *
- * Purpose: export VNT Host WiFi library function
- *
- * Author: Yiching Chen
- *
- * Date: Jan 7, 2004
- *
- */
-
-#ifndef __VNTWIFI_H__
-#define __VNTWIFI_H__
-
-#include "ttype.h"
-#include "80211mgr.h"
-#include "card.h"
-#include "wpa2.h"
-
-/*---------------------  Export Definitions -------------------------*/
-#define RATE_1M         0
-#define RATE_2M         1
-#define RATE_5M         2
-#define RATE_11M        3
-#define RATE_6M         4
-#define RATE_9M         5
-#define RATE_12M        6
-#define RATE_18M        7
-#define RATE_24M        8
-#define RATE_36M        9
-#define RATE_48M       10
-#define RATE_54M       11
-#define RATE_AUTO      12
-#define MAX_RATE       12
-
-// key CipherSuite
-#define KEY_CTL_WEP         0x00
-#define KEY_CTL_NONE        0x01
-#define KEY_CTL_TKIP        0x02
-#define KEY_CTL_CCMP        0x03
-#define KEY_CTL_INVALID     0xFF
-
-#define CHANNEL_MAX_24G         14
-
-#define MAX_BSS_NUM             42
-
-// Pre-configured Authenticaiton Mode (from XP)
-typedef enum tagWMAC_AUTHENTICATION_MODE {
-       WMAC_AUTH_OPEN,
-       WMAC_AUTH_SHAREKEY,
-       WMAC_AUTH_AUTO,
-       WMAC_AUTH_WPA,
-       WMAC_AUTH_WPAPSK,
-       WMAC_AUTH_WPANONE,
-       WMAC_AUTH_WPA2,
-       WMAC_AUTH_WPA2PSK,
-       WMAC_AUTH_MAX       // Not a real mode, defined as upper bound
-} WMAC_AUTHENTICATION_MODE, *PWMAC_AUTHENTICATION_MODE;
-
-typedef enum tagWMAC_ENCRYPTION_MODE {
-       WMAC_ENCRYPTION_WEPEnabled,
-       WMAC_ENCRYPTION_WEPDisabled,
-       WMAC_ENCRYPTION_WEPKeyAbsent,
-       WMAC_ENCRYPTION_WEPNotSupported,
-       WMAC_ENCRYPTION_TKIPEnabled,
-       WMAC_ENCRYPTION_TKIPKeyAbsent,
-       WMAC_ENCRYPTION_AESEnabled,
-       WMAC_ENCRYPTION_AESKeyAbsent
-} WMAC_ENCRYPTION_MODE, *PWMAC_ENCRYPTION_MODE;
-
-// Pre-configured Mode (from XP)
-
-typedef enum tagWMAC_CONFIG_MODE {
-       WMAC_CONFIG_ESS_STA = 0,
-       WMAC_CONFIG_IBSS_STA,
-       WMAC_CONFIG_AUTO,
-       WMAC_CONFIG_AP
-} WMAC_CONFIG_MODE, *PWMAC_CONFIG_MODE;
-
-typedef enum tagWMAC_POWER_MODE {
-       WMAC_POWER_CAM,
-       WMAC_POWER_FAST,
-       WMAC_POWER_MAX
-} WMAC_POWER_MODE, *PWMAC_POWER_MODE;
-
-#define VNTWIFIbIsShortSlotTime(wCapInfo)               \
-       WLAN_GET_CAP_INFO_SHORTSLOTTIME(wCapInfo)       \
-
-#define VNTWIFIbIsProtectMode(byERP)                    \
-       ((byERP & WLAN_EID_ERP_USE_PROTECTION) != 0)    \
-
-#define VNTWIFIbIsBarkerMode(byERP)                     \
-       ((byERP & WLAN_EID_ERP_BARKER_MODE) != 0)       \
-
-#define VNTWIFIbIsShortPreamble(wCapInfo)               \
-       WLAN_GET_CAP_INFO_SHORTPREAMBLE(wCapInfo)       \
-
-#define VNTWIFIbIsEncryption(wCapInfo)         \
-       WLAN_GET_CAP_INFO_PRIVACY(wCapInfo)     \
-
-#define VNTWIFIbIsESS(wCapInfo)                        \
-       WLAN_GET_CAP_INFO_ESS(wCapInfo)         \
-
-/*---------------------  Export Classes  ----------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Types  ------------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-void
-VNTWIFIvSetIBSSParameter(
-       void *pMgmtHandle,
-       unsigned short wBeaconPeriod,
-       unsigned short wATIMWindow,
-       unsigned int uChannel
-);
-
-void
-VNTWIFIvSetOPMode(
-       void *pMgmtHandle,
-       WMAC_CONFIG_MODE eOPMode
-);
-
-PWLAN_IE_SSID
-VNTWIFIpGetCurrentSSID(
-       void *pMgmtHandle
-);
-
-unsigned int
-VNTWIFIpGetCurrentChannel(
-       void *pMgmtHandle
-);
-
-unsigned short
-VNTWIFIwGetAssocID(
-       void *pMgmtHandle
-);
-
-unsigned char
-VNTWIFIbyGetMaxSupportRate(
-       PWLAN_IE_SUPP_RATES pSupportRateIEs,
-       PWLAN_IE_SUPP_RATES pExtSupportRateIEs
-);
-
-unsigned char
-VNTWIFIbyGetACKTxRate(
-       unsigned char byRxDataRate,
-       PWLAN_IE_SUPP_RATES pSupportRateIEs,
-       PWLAN_IE_SUPP_RATES pExtSupportRateIEs
-);
-
-void
-VNTWIFIvSetAuthenticationMode(
-       void *pMgmtHandle,
-       WMAC_AUTHENTICATION_MODE eAuthMode
-);
-
-void
-VNTWIFIvSetEncryptionMode(
-       void *pMgmtHandle,
-       WMAC_ENCRYPTION_MODE eEncryptionMode
-);
-
-bool
-VNTWIFIbConfigPhyMode(
-       void *pMgmtHandle,
-       CARD_PHY_TYPE ePhyType
-);
-
-void
-VNTWIFIbGetConfigPhyMode(
-       void *pMgmtHandle,
-       void *pePhyType
-);
-
-void
-VNTWIFIvQueryBSSList(void *pMgmtHandle, unsigned int *puBSSCount,
-                    void **pvFirstBSS);
-
-void
-VNTWIFIvGetNextBSS(
-       void *pMgmtHandle,
-       void *pvCurrentBSS,
-       void **pvNextBSS
-);
-
-void
-VNTWIFIvUpdateNodeTxCounter(
-       void *pMgmtHandle,
-       unsigned char *pbyDestAddress,
-       bool bTxOk,
-       unsigned short wRate,
-       unsigned char *pbyTxFailCount
-);
-
-void
-VNTWIFIvGetTxRate(
-       void *pMgmtHandle,
-       unsigned char *pbyDestAddress,
-       unsigned short *pwTxDataRate,
-       unsigned char *pbyACKRate,
-       unsigned char *pbyCCKBasicRate,
-       unsigned char *pbyOFDMBasicRate
-);
-
-unsigned char
-VNTWIFIbyGetKeyCypher(
-       void *pMgmtHandle,
-       bool bGroupKey
-);
-
-bool
-VNTWIFIbSetPMKIDCache(
-       void *pMgmtObject,
-       unsigned long ulCount,
-       void *pPMKIDInfo
-);
-
-bool
-VNTWIFIbCommandRunning(
-       void *pMgmtObject
-);
-
-unsigned short
-VNTWIFIwGetMaxSupportRate(
-       void *pMgmtObject
-);
-
-// for 802.11h
-void
-VNTWIFIvSet11h(
-       void *pMgmtObject,
-       bool b11hEnable
-);
-
-bool
-VNTWIFIbMeasureReport(
-       void *pMgmtObject,
-       bool bEndOfReport,
-       void *pvMeasureEID,
-       unsigned char byReportMode,
-       unsigned char byBasicMap,
-       unsigned char byCCAFraction,
-       unsigned char *pbyRPIs
-);
-
-bool
-VNTWIFIbChannelSwitch(
-       void *pMgmtObject,
-       unsigned char byNewChannel
-);
-
-#endif //__VNTWIFI_H__
diff --git a/drivers/staging/vt6655/wcmd.c b/drivers/staging/vt6655/wcmd.c
deleted file mode 100644 (file)
index 985e1b9..0000000
+++ /dev/null
@@ -1,1023 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: wcmd.c
- *
- * Purpose: Handles the management command interface functions
- *
- * Author: Lyndon Chen
- *
- * Date: May 8, 2003
- *
- * Functions:
- *      s_vProbeChannel - Active scan channel
- *      s_MgrMakeProbeRequest - Make ProbeRequest packet
- *      CommandTimer - Timer function to handle command
- *      s_bCommandComplete - Command Complete function
- *      bScheduleCommand - Push Command and wait Command Scheduler to do
- *      vCommandTimer- Command call back functions
- *      vCommandTimerWait- Call back timer
- *      bClearBSSID_SCAN- Clear BSSID_SCAN cmd in CMD Queue
- *
- * Revision History:
- *
- */
-
-#include "ttype.h"
-#include "tmacro.h"
-#include "device.h"
-#include "mac.h"
-#include "card.h"
-#include "80211hdr.h"
-#include "wcmd.h"
-#include "wmgr.h"
-#include "power.h"
-#include "wctl.h"
-#include "baseband.h"
-#include "rxtx.h"
-#include "rf.h"
-#include "iowpa.h"
-#include "channel.h"
-
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Functions  --------------------------*/
-
-static
-void
-s_vProbeChannel(
-       struct vnt_private *pDevice
-);
-
-static
-PSTxMgmtPacket
-s_MgrMakeProbeRequest(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       unsigned char *pScanBSSID,
-       PWLAN_IE_SSID pSSID,
-       PWLAN_IE_SUPP_RATES pCurrRates,
-       PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-);
-
-static
-bool
-s_bCommandComplete(
-       struct vnt_private *pDevice
-);
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-/*
- * Description:
- *      Stop AdHoc beacon during scan process
- *
- * Parameters:
- *  In:
- *      pDevice     - Pointer to the adapter
- *  Out:
- *      none
- *
- * Return Value: none
- *
- */
-static
-void
-vAdHocBeaconStop(struct vnt_private *pDevice)
-{
-       PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-       bool bStop;
-
-       /*
-        * temporarily stop Beacon packet for AdHoc Server
-        * if all of the following conditions are met:
-        *  (1) STA is in AdHoc mode
-        *  (2) VT3253 is programmed as automatic Beacon Transmitting
-        *  (3) One of the following conditions is met
-        *      (3.1) AdHoc channel is in B/G band and the
-        *      current scan channel is in A band
-        *      or
-        *      (3.2) AdHoc channel is in A mode
-        */
-       bStop = false;
-       if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
-           (pMgmt->eCurrState >= WMAC_STATE_STARTED)) {
-               if ((pMgmt->uIBSSChannel <=  CB_MAX_CHANNEL_24G) &&
-                   (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G)) {
-                       bStop = true;
-               }
-               if (pMgmt->uIBSSChannel >  CB_MAX_CHANNEL_24G)
-                       bStop = true;
-
-       }
-
-       if (bStop)
-               MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
-} /* vAdHocBeaconStop */
-
-/*
- * Description:
- *      Restart AdHoc beacon after scan process complete
- *
- * Parameters:
- *  In:
- *      pDevice     - Pointer to the adapter
- *  Out:
- *      none
- *
- * Return Value: none
- *
- */
-static
-void
-vAdHocBeaconRestart(struct vnt_private *pDevice)
-{
-       PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-
-       /*
-        * Restart Beacon packet for AdHoc Server
-        * if all of the following coditions are met:
-        *  (1) STA is in AdHoc mode
-        *  (2) VT3253 is programmed as automatic Beacon Transmitting
-        */
-       if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
-           (pMgmt->eCurrState >= WMAC_STATE_STARTED)) {
-               MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
-       }
-}
-
-/*+
- *
- * Routine Description:
- *   Prepare and send probe request management frames.
- *
- *
- * Return Value:
- *    none.
- *
- -*/
-
-static
-void
-s_vProbeChannel(
-       struct vnt_private *pDevice
-)
-{
-       //1M,   2M,   5M,   11M,  18M,  24M,  36M,  54M
-       unsigned char abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
-       unsigned char abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60};
-       //6M,   9M,   12M,  48M
-       unsigned char abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
-       unsigned char abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
-       unsigned char *pbyRate;
-       PSTxMgmtPacket  pTxPacket;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       unsigned int ii;
-
-       if (pDevice->eCurrentPHYType == PHY_TYPE_11A)
-               pbyRate = &abyCurrSuppRatesA[0];
-       else if (pDevice->eCurrentPHYType == PHY_TYPE_11B)
-               pbyRate = &abyCurrSuppRatesB[0];
-       else
-               pbyRate = &abyCurrSuppRatesG[0];
-
-       // build an assocreq frame and send it
-       pTxPacket = s_MgrMakeProbeRequest
-               (
-                       pDevice,
-                       pMgmt,
-                       pMgmt->abyScanBSSID,
-                       (PWLAN_IE_SSID)pMgmt->abyScanSSID,
-                       (PWLAN_IE_SUPP_RATES)pbyRate,
-                       (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRatesG
-                       );
-
-       if (pTxPacket != NULL) {
-               for (ii = 0; ii < 2; ii++) {
-                       if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING)
-                               pr_debug("Probe request sending fail..\n");
-                       else
-                               pr_debug("Probe request is sending..\n");
-               }
-       }
-}
-
-/*+
- *
- * Routine Description:
- *  Constructs an probe request frame
- *
- *
- * Return Value:
- *    A ptr to Tx frame or NULL on allocation failure
- *
- -*/
-
-static PSTxMgmtPacket
-s_MgrMakeProbeRequest(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       unsigned char *pScanBSSID,
-       PWLAN_IE_SSID pSSID,
-       PWLAN_IE_SUPP_RATES pCurrRates,
-       PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-
-)
-{
-       PSTxMgmtPacket      pTxPacket = NULL;
-       WLAN_FR_PROBEREQ    sFrame;
-
-       pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-       memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_PROBEREQ_FR_MAXLEN);
-       pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket));
-       sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header;
-       sFrame.len = WLAN_PROBEREQ_FR_MAXLEN;
-       vMgrEncodeProbeRequest(&sFrame);
-       sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
-               (
-                       WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
-                       WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBEREQ)
-));
-       memcpy(sFrame.pHdr->sA3.abyAddr1, pScanBSSID, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr3, pScanBSSID, WLAN_BSSID_LEN);
-       // Copy the SSID, pSSID->len=0 indicate broadcast SSID
-       sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
-       sFrame.len += pSSID->len + WLAN_IEHDR_LEN;
-       memcpy(sFrame.pSSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
-       sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
-       sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN;
-       memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
-       // Copy the extension rate set
-       if (pDevice->eCurrentPHYType == PHY_TYPE_11G) {
-               sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
-               sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN;
-               memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN);
-       }
-       pTxPacket->cbMPDULen = sFrame.len;
-       pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
-
-       return pTxPacket;
-}
-
-void
-vCommandTimerWait(
-       void *hDeviceContext,
-       unsigned int MSecond
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-
-       init_timer(&pDevice->sTimerCommand);
-       pDevice->sTimerCommand.data = (unsigned long) pDevice;
-       pDevice->sTimerCommand.function = (TimerFunction)vCommandTimer;
-       // RUN_AT :1 msec ~= (HZ/1024)
-       pDevice->sTimerCommand.expires = (unsigned int)RUN_AT((MSecond * HZ) >> 10);
-       add_timer(&pDevice->sTimerCommand);
-}
-
-void
-vCommandTimer(
-       void *hDeviceContext
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       PWLAN_IE_SSID   pItemSSID;
-       PWLAN_IE_SSID   pItemSSIDCurr;
-       CMD_STATUS      Status;
-       unsigned int ii;
-       unsigned char byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
-       struct sk_buff  *skb;
-
-       if (pDevice->dwDiagRefCount != 0)
-               return;
-       if (!pDevice->bCmdRunning)
-               return;
-
-       spin_lock_irq(&pDevice->lock);
-
-       switch (pDevice->eCommandState) {
-       case WLAN_CMD_SCAN_START:
-
-               pDevice->byReAssocCount = 0;
-               if (pDevice->bRadioOff) {
-                       s_bCommandComplete(pDevice);
-                       spin_unlock_irq(&pDevice->lock);
-                       return;
-               }
-
-               if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
-                       s_bCommandComplete(pDevice);
-                       CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, NL80211_IFTYPE_AP);
-                       spin_unlock_irq(&pDevice->lock);
-                       return;
-               }
-
-               pr_debug("eCommandState= WLAN_CMD_SCAN_START\n");
-               pItemSSID = (PWLAN_IE_SSID)pMgmt->abyScanSSID;
-               // wait all Data TD complete
-               if (pDevice->iTDUsed[TYPE_AC0DMA] != 0) {
-                       spin_unlock_irq(&pDevice->lock);
-                       vCommandTimerWait((void *)pDevice, 10);
-                       return;
-               }
-
-               if (pMgmt->uScanChannel == 0) {
-                       pMgmt->uScanChannel = pDevice->byMinChannel;
-                       // Set Baseband to be more sensitive.
-
-               }
-               if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
-                       pMgmt->eScanState = WMAC_NO_SCANNING;
-
-                       // Set Baseband's sensitivity back.
-                       // Set channel back
-                       set_channel(pMgmt->pAdapter, pMgmt->uCurrChannel);
-                       pr_debug("Scanning, set back to channel: [%d]\n",
-                                pMgmt->uCurrChannel);
-                       if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)
-                               CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, NL80211_IFTYPE_ADHOC);
-                       else
-                               CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, NL80211_IFTYPE_STATION);
-
-                       vAdHocBeaconRestart(pDevice);
-                       s_bCommandComplete(pDevice);
-
-               } else {
-//2008-8-4 <add> by chester
-                       if (!is_channel_valid(pMgmt->uScanChannel)) {
-                               pr_debug("Invalid channel pMgmt->uScanChannel = %d\n",
-                                        pMgmt->uScanChannel);
-                               s_bCommandComplete(pDevice);
-                               spin_unlock_irq(&pDevice->lock);
-                               return;
-                       }
-                       if (pMgmt->uScanChannel == pDevice->byMinChannel) {
-                               pMgmt->abyScanBSSID[0] = 0xFF;
-                               pMgmt->abyScanBSSID[1] = 0xFF;
-                               pMgmt->abyScanBSSID[2] = 0xFF;
-                               pMgmt->abyScanBSSID[3] = 0xFF;
-                               pMgmt->abyScanBSSID[4] = 0xFF;
-                               pMgmt->abyScanBSSID[5] = 0xFF;
-                               pItemSSID->byElementID = WLAN_EID_SSID;
-                               pMgmt->eScanState = WMAC_IS_SCANNING;
-
-                       }
-
-                       vAdHocBeaconStop(pDevice);
-
-                       if (set_channel(pMgmt->pAdapter, pMgmt->uScanChannel))
-                               pr_debug("SCAN Channel: %d\n",
-                                        pMgmt->uScanChannel);
-                       else
-                               pr_debug("SET SCAN Channel Fail: %d\n",
-                                        pMgmt->uScanChannel);
-
-                       CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, NL80211_IFTYPE_UNSPECIFIED);
-                       pMgmt->uScanChannel++;
-//2008-8-4 <modify> by chester
-                       if (!is_channel_valid(pMgmt->uScanChannel) &&
-                           pMgmt->uScanChannel <= pDevice->byMaxChannel) {
-                               pMgmt->uScanChannel = pDevice->byMaxChannel + 1;
-                               pMgmt->eCommandState = WLAN_CMD_SCAN_END;
-
-                       }
-
-                       if (!pMgmt->b11hEnable ||
-                           (pMgmt->uScanChannel < CB_MAX_CHANNEL_24G)) {
-                               s_vProbeChannel(pDevice);
-                               spin_unlock_irq(&pDevice->lock);
-                               vCommandTimerWait((void *)pDevice, WCMD_ACTIVE_SCAN_TIME);
-                               return;
-                       } else {
-                               spin_unlock_irq(&pDevice->lock);
-                               vCommandTimerWait((void *)pDevice, WCMD_PASSIVE_SCAN_TIME);
-                               return;
-                       }
-
-               }
-
-               break;
-
-       case WLAN_CMD_SCAN_END:
-
-               // Set Baseband's sensitivity back.
-               // Set channel back
-               set_channel(pMgmt->pAdapter, pMgmt->uCurrChannel);
-               pr_debug("Scanning, set back to channel: [%d]\n",
-                        pMgmt->uCurrChannel);
-               if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)
-                       CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, NL80211_IFTYPE_ADHOC);
-               else
-                       CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, NL80211_IFTYPE_STATION);
-
-               pMgmt->eScanState = WMAC_NO_SCANNING;
-               vAdHocBeaconRestart(pDevice);
-//2008-0409-07, <Add> by Einsn Liu
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-               if (pMgmt->eScanType == WMAC_SCAN_PASSIVE) {
-                       //send scan event to wpa_Supplicant
-                       union iwreq_data wrqu;
-
-                       memset(&wrqu, 0, sizeof(wrqu));
-                       wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
-               }
-#endif
-               s_bCommandComplete(pDevice);
-               break;
-
-       case WLAN_CMD_DISASSOCIATE_START:
-               pDevice->byReAssocCount = 0;
-               if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
-                   (pMgmt->eCurrState != WMAC_STATE_ASSOC)) {
-                       s_bCommandComplete(pDevice);
-                       spin_unlock_irq(&pDevice->lock);
-                       return;
-               } else {
-                       pr_debug("Send Disassociation Packet..\n");
-                       // reason = 8 : disassoc because sta has left
-                       vMgrDisassocBeginSta((void *)pDevice, pMgmt, pMgmt->abyCurrBSSID, (8), &Status);
-                       pDevice->bLinkPass = false;
-                       // unlock command busy
-                       pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
-                       pItemSSID->len = 0;
-                       memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
-                       pMgmt->eCurrState = WMAC_STATE_IDLE;
-                       pMgmt->sNodeDBTable[0].bActive = false;
-               }
-               netif_stop_queue(pDevice->dev);
-               pDevice->eCommandState = WLAN_DISASSOCIATE_WAIT;
-               // wait all Control TD complete
-               if (pDevice->iTDUsed[TYPE_TXDMA0] != 0) {
-                       vCommandTimerWait((void *)pDevice, 10);
-                       spin_unlock_irq(&pDevice->lock);
-                       return;
-               }
-               pr_debug(" CARDbRadioPowerOff\n");
-               //2008-09-02  <mark>    by chester
-               s_bCommandComplete(pDevice);
-               break;
-
-       case WLAN_DISASSOCIATE_WAIT:
-               // wait all Control TD complete
-               if (pDevice->iTDUsed[TYPE_TXDMA0] != 0) {
-                       vCommandTimerWait((void *)pDevice, 10);
-                       spin_unlock_irq(&pDevice->lock);
-                       return;
-               }
-//2008-09-02  <mark> by chester
-               s_bCommandComplete(pDevice);
-               break;
-
-       case WLAN_CMD_SSID_START:
-               pDevice->byReAssocCount = 0;
-               if (pDevice->bRadioOff) {
-                       s_bCommandComplete(pDevice);
-                       spin_unlock_irq(&pDevice->lock);
-                       return;
-               }
-               pr_debug("chester-abyDesireSSID=%s\n", ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySSID);
-               pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
-               pItemSSIDCurr = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
-               pr_debug(" cmd: desire ssid = %s\n", pItemSSID->abySSID);
-               pr_debug(" cmd: curr ssid = %s\n", pItemSSIDCurr->abySSID);
-
-               if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
-                       pr_debug(" Cmd pMgmt->eCurrState == WMAC_STATE_ASSOC\n");
-                       pr_debug(" pItemSSID->len =%d\n", pItemSSID->len);
-                       pr_debug(" pItemSSIDCurr->len = %d\n",
-                                pItemSSIDCurr->len);
-                       pr_debug(" desire ssid = %s\n", pItemSSID->abySSID);
-                       pr_debug(" curr ssid = %s\n", pItemSSIDCurr->abySSID);
-               }
-
-               if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
-                   ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
-                       if (pItemSSID->len == pItemSSIDCurr->len) {
-                               if (memcmp(pItemSSID->abySSID, pItemSSIDCurr->abySSID, pItemSSID->len) == 0) {
-                                       s_bCommandComplete(pDevice);
-                                       spin_unlock_irq(&pDevice->lock);
-                                       return;
-                               }
-                       }
-
-                       netif_stop_queue(pDevice->dev);
-                       pDevice->bLinkPass = false;
-               }
-               // set initial state
-               pMgmt->eCurrState = WMAC_STATE_IDLE;
-               pMgmt->eCurrMode = WMAC_MODE_STANDBY;
-               PSvDisablePowerSaving((void *)pDevice);
-               BSSvClearNodeDBTable(pDevice, 0);
-
-               vMgrJoinBSSBegin((void *)pDevice, &Status);
-               // if Infra mode
-               if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED)) {
-                       // Call mgr to begin the deauthentication
-                       // reason = (3) because sta has left ESS
-                       if (pMgmt->eCurrState >= WMAC_STATE_AUTH)
-                               vMgrDeAuthenBeginSta((void *)pDevice, pMgmt, pMgmt->abyCurrBSSID, (3), &Status);
-
-                       // Call mgr to begin the authentication
-                       vMgrAuthenBeginSta((void *)pDevice, pMgmt, &Status);
-                       if (Status == CMD_STATUS_SUCCESS) {
-                               pDevice->byLinkWaitCount = 0;
-                               pDevice->eCommandState = WLAN_AUTHENTICATE_WAIT;
-                               vCommandTimerWait((void *)pDevice, AUTHENTICATE_TIMEOUT);
-                               spin_unlock_irq(&pDevice->lock);
-                               pr_debug(" Set eCommandState = WLAN_AUTHENTICATE_WAIT\n");
-                               return;
-                       }
-               }
-               // if Adhoc mode
-               else if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
-                       if (pMgmt->eCurrState == WMAC_STATE_JOINTED) {
-                               if (netif_queue_stopped(pDevice->dev))
-                                       netif_wake_queue(pDevice->dev);
-
-                               pDevice->bLinkPass = true;
-
-                               pMgmt->sNodeDBTable[0].bActive = true;
-                               pMgmt->sNodeDBTable[0].uInActiveCount = 0;
-                               bClearBSSID_SCAN(pDevice);
-                       } else {
-                               // start own IBSS
-                               vMgrCreateOwnIBSS((void *)pDevice, &Status);
-                               if (Status != CMD_STATUS_SUCCESS)
-                                       pr_debug(" WLAN_CMD_IBSS_CREATE fail !\n");
-
-                               BSSvAddMulticastNode(pDevice);
-                       }
-               }
-               // if SSID not found
-               else if (pMgmt->eCurrMode == WMAC_MODE_STANDBY) {
-                       if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA ||
-                           pMgmt->eConfigMode == WMAC_CONFIG_AUTO) {
-                               // start own IBSS
-                               vMgrCreateOwnIBSS((void *)pDevice, &Status);
-                               if (Status != CMD_STATUS_SUCCESS)
-                                       pr_debug(" WLAN_CMD_IBSS_CREATE fail !\n");
-
-                               BSSvAddMulticastNode(pDevice);
-                               if (netif_queue_stopped(pDevice->dev))
-                                       netif_wake_queue(pDevice->dev);
-
-                               pDevice->bLinkPass = true;
-                       } else {
-                               pr_debug("Disconnect SSID none\n");
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-                               {
-                                       union iwreq_data  wrqu;
-
-                                       memset(&wrqu, 0, sizeof(wrqu));
-                                       wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-                                       pr_debug("wireless_send_event--->SIOCGIWAP(disassociated:vMgrJoinBSSBegin Fail !!)\n");
-                                       wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
-                               }
-#endif
-
-                       }
-               }
-               s_bCommandComplete(pDevice);
-               break;
-
-       case WLAN_AUTHENTICATE_WAIT:
-               pr_debug("eCommandState == WLAN_AUTHENTICATE_WAIT\n");
-               if (pMgmt->eCurrState == WMAC_STATE_AUTH) {
-                       // Call mgr to begin the association
-                       pDevice->byLinkWaitCount = 0;
-                       pr_debug("eCurrState == WMAC_STATE_AUTH\n");
-                       vMgrAssocBeginSta((void *)pDevice, pMgmt, &Status);
-                       if (Status == CMD_STATUS_SUCCESS) {
-                               pDevice->byLinkWaitCount = 0;
-                               pr_debug("eCommandState = WLAN_ASSOCIATE_WAIT\n");
-                               pDevice->eCommandState = WLAN_ASSOCIATE_WAIT;
-                               vCommandTimerWait((void *)pDevice, ASSOCIATE_TIMEOUT);
-                               spin_unlock_irq(&pDevice->lock);
-                               return;
-                       }
-               }
-
-               else if (pMgmt->eCurrState < WMAC_STATE_AUTHPENDING) {
-                       pr_debug("WLAN_AUTHENTICATE_WAIT:Authen Fail???\n");
-               } else if (pDevice->byLinkWaitCount <= 4) {    //mike add:wait another 2 sec if authenticated_frame delay!
-                       pDevice->byLinkWaitCount++;
-                       pr_debug("WLAN_AUTHENTICATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount);
-                       spin_unlock_irq(&pDevice->lock);
-                       vCommandTimerWait((void *)pDevice, AUTHENTICATE_TIMEOUT/2);
-                       return;
-               }
-               pDevice->byLinkWaitCount = 0;
-               s_bCommandComplete(pDevice);
-               break;
-
-       case WLAN_ASSOCIATE_WAIT:
-               if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
-                       pr_debug("eCurrState == WMAC_STATE_ASSOC\n");
-                       if (pDevice->ePSMode != WMAC_POWER_CAM)
-                               PSvEnablePowerSaving((void *)pDevice, pMgmt->wListenInterval);
-
-                       if (pMgmt->eAuthenMode >= WMAC_AUTH_WPA)
-                               KeybRemoveAllKey(&(pDevice->sKey), pDevice->abyBSSID, pDevice->PortOffset);
-
-                       pDevice->bLinkPass = true;
-                       pDevice->byLinkWaitCount = 0;
-                       pDevice->byReAssocCount = 0;
-                       bClearBSSID_SCAN(pDevice);
-                       if (pDevice->byFOETuning) {
-                               BBvSetFOE(pDevice->PortOffset);
-                               PSbSendNullPacket(pDevice);
-                       }
-                       if (netif_queue_stopped(pDevice->dev))
-                               netif_wake_queue(pDevice->dev);
-
-                       if (pDevice->IsTxDataTrigger) {    //TxDataTimer is not triggered at the first time
-                               del_timer(&pDevice->sTimerTxData);
-                               init_timer(&pDevice->sTimerTxData);
-                               pDevice->sTimerTxData.data = (unsigned long) pDevice;
-                               pDevice->sTimerTxData.function = (TimerFunction)BSSvSecondTxData;
-                               pDevice->sTimerTxData.expires = RUN_AT(10*HZ);      //10s callback
-                               pDevice->fTxDataInSleep = false;
-                               pDevice->nTxDataTimeCout = 0;
-                       }
-
-                       pDevice->IsTxDataTrigger = true;
-                       add_timer(&pDevice->sTimerTxData);
-
-               } else if (pMgmt->eCurrState < WMAC_STATE_ASSOCPENDING) {
-                       printk("WLAN_ASSOCIATE_WAIT:Association Fail???\n");
-               } else if (pDevice->byLinkWaitCount <= 4) {    //mike add:wait another 2 sec if associated_frame delay!
-                       pDevice->byLinkWaitCount++;
-                       pr_debug("WLAN_ASSOCIATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount);
-                       spin_unlock_irq(&pDevice->lock);
-                       vCommandTimerWait((void *)pDevice, ASSOCIATE_TIMEOUT/2);
-                       return;
-               }
-               pDevice->byLinkWaitCount = 0;
-
-               s_bCommandComplete(pDevice);
-               break;
-
-       case WLAN_CMD_AP_MODE_START:
-               pr_debug("eCommandState == WLAN_CMD_AP_MODE_START\n");
-
-               if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
-                       del_timer(&pMgmt->sTimerSecondCallback);
-                       pMgmt->eCurrState = WMAC_STATE_IDLE;
-                       pMgmt->eCurrMode = WMAC_MODE_STANDBY;
-                       pDevice->bLinkPass = false;
-                       if (pDevice->bEnableHostWEP)
-                               BSSvClearNodeDBTable(pDevice, 1);
-                       else
-                               BSSvClearNodeDBTable(pDevice, 0);
-                       pDevice->uAssocCount = 0;
-                       pMgmt->eCurrState = WMAC_STATE_IDLE;
-                       pDevice->bFixRate = false;
-
-                       vMgrCreateOwnIBSS((void *)pDevice, &Status);
-                       if (Status != CMD_STATUS_SUCCESS)
-                               pr_debug(" vMgrCreateOwnIBSS fail !\n");
-
-                       // alway turn off unicast bit
-                       MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_UNICAST);
-                       pDevice->byRxMode &= ~RCR_UNICAST;
-                       pr_debug("wcmd: rx_mode = %x\n", pDevice->byRxMode);
-                       BSSvAddMulticastNode(pDevice);
-                       if (netif_queue_stopped(pDevice->dev))
-                               netif_wake_queue(pDevice->dev);
-
-                       pDevice->bLinkPass = true;
-                       add_timer(&pMgmt->sTimerSecondCallback);
-               }
-               s_bCommandComplete(pDevice);
-               break;
-
-       case WLAN_CMD_TX_PSPACKET_START:
-               // DTIM Multicast tx
-               if (pMgmt->sNodeDBTable[0].bRxPSPoll) {
-                       while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[0].sTxPSQueue)) != NULL) {
-                               if (skb_queue_empty(&pMgmt->sNodeDBTable[0].sTxPSQueue)) {
-                                       pMgmt->abyPSTxMap[0] &= ~byMask[0];
-                                       pDevice->bMoreData = false;
-                               } else {
-                                       pDevice->bMoreData = true;
-                               }
-                               if (!device_dma0_xmit(pDevice, skb, 0))
-                                       pr_debug("Multicast ps tx fail\n");
-
-                               pMgmt->sNodeDBTable[0].wEnQueueCnt--;
-                       }
-               }
-
-               // PS nodes tx
-               for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
-                       if (pMgmt->sNodeDBTable[ii].bActive &&
-                           pMgmt->sNodeDBTable[ii].bRxPSPoll) {
-                               pr_debug("Index=%d Enqueu Cnt= %d\n",
-                                        ii,
-                                        pMgmt->sNodeDBTable[ii].wEnQueueCnt);
-                               while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL) {
-                                       if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
-                                               // clear tx map
-                                               pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
-                                                       ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
-                                               pDevice->bMoreData = false;
-                                       } else {
-                                               pDevice->bMoreData = true;
-                                       }
-                                       if (!device_dma0_xmit(pDevice, skb, ii))
-                                               pr_debug("sta ps tx fail\n");
-
-                                       pMgmt->sNodeDBTable[ii].wEnQueueCnt--;
-                                       // check if sta ps enabled, and wait next pspoll.
-                                       // if sta ps disable, then send all pending buffers.
-                                       if (pMgmt->sNodeDBTable[ii].bPSEnable)
-                                               break;
-                               }
-                               if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
-                                       // clear tx map
-                                       pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
-                                               ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
-                                       pr_debug("Index=%d PS queue clear\n",
-                                                ii);
-                               }
-                               pMgmt->sNodeDBTable[ii].bRxPSPoll = false;
-                       }
-               }
-
-               s_bCommandComplete(pDevice);
-               break;
-
-       case WLAN_CMD_RADIO_START:
-               pr_debug("eCommandState == WLAN_CMD_RADIO_START\n");
-               if (pDevice->bRadioCmd)
-                       CARDbRadioPowerOn(pDevice);
-               else
-                       CARDbRadioPowerOff(pDevice);
-
-               s_bCommandComplete(pDevice);
-               break;
-
-       case WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE:
-               // wait all TD complete
-               if (pDevice->iTDUsed[TYPE_AC0DMA] != 0) {
-                       vCommandTimerWait((void *)pDevice, 10);
-                       spin_unlock_irq(&pDevice->lock);
-                       return;
-               }
-               if (pDevice->iTDUsed[TYPE_TXDMA0] != 0) {
-                       vCommandTimerWait((void *)pDevice, 10);
-                       spin_unlock_irq(&pDevice->lock);
-                       return;
-               }
-               pDevice->byBBVGACurrent = pDevice->byBBVGANew;
-               BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
-               pr_debug("SetVGAGainOffset %02X\n", pDevice->byBBVGACurrent);
-               s_bCommandComplete(pDevice);
-               break;
-
-       default:
-               s_bCommandComplete(pDevice);
-               break;
-
-       } //switch
-       spin_unlock_irq(&pDevice->lock);
-}
-
-static
-bool
-s_bCommandComplete(
-       struct vnt_private *pDevice
-)
-{
-       PWLAN_IE_SSID pSSID;
-       bool bRadioCmd = false;
-       bool bForceSCAN = true;
-       PSMgmtObject  pMgmt = pDevice->pMgmt;
-
-       pDevice->eCommandState = WLAN_CMD_IDLE;
-       if (pDevice->cbFreeCmdQueue == CMD_Q_SIZE) {
-               //Command Queue Empty
-               pDevice->bCmdRunning = false;
-               return true;
-       } else {
-               pDevice->eCommand = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].eCmd;
-               pSSID = (PWLAN_IE_SSID)pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].abyCmdDesireSSID;
-               bRadioCmd = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bRadioCmd;
-               bForceSCAN = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bForceSCAN;
-               ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdDequeueIdx, CMD_Q_SIZE);
-               pDevice->cbFreeCmdQueue++;
-               pDevice->bCmdRunning = true;
-               switch (pDevice->eCommand) {
-               case WLAN_CMD_BSSID_SCAN:
-                       pr_debug("eCommandState= WLAN_CMD_BSSID_SCAN\n");
-                       pDevice->eCommandState = WLAN_CMD_SCAN_START;
-                       pMgmt->uScanChannel = 0;
-                       if (pSSID->len != 0)
-                               memcpy(pMgmt->abyScanSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
-                       else
-                               memset(pMgmt->abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
-
-                       break;
-               case WLAN_CMD_SSID:
-                       pDevice->eCommandState = WLAN_CMD_SSID_START;
-                       if (pSSID->len > WLAN_SSID_MAXLEN)
-                               pSSID->len = WLAN_SSID_MAXLEN;
-                       if (pSSID->len != 0)
-                               memcpy(pDevice->pMgmt->abyDesireSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
-                       pr_debug("eCommandState= WLAN_CMD_SSID_START\n");
-                       break;
-               case WLAN_CMD_DISASSOCIATE:
-                       pDevice->eCommandState = WLAN_CMD_DISASSOCIATE_START;
-                       break;
-               case WLAN_CMD_RX_PSPOLL:
-                       pDevice->eCommandState = WLAN_CMD_TX_PSPACKET_START;
-                       break;
-               case WLAN_CMD_RUN_AP:
-                       pDevice->eCommandState = WLAN_CMD_AP_MODE_START;
-                       break;
-               case WLAN_CMD_RADIO:
-                       pDevice->eCommandState = WLAN_CMD_RADIO_START;
-                       pDevice->bRadioCmd = bRadioCmd;
-                       break;
-               case WLAN_CMD_CHANGE_BBSENSITIVITY:
-                       pDevice->eCommandState = WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE;
-                       break;
-
-               default:
-                       break;
-
-               }
-
-               vCommandTimerWait((void *)pDevice, 0);
-       }
-
-       return true;
-}
-
-bool bScheduleCommand(
-       void *hDeviceContext,
-       CMD_CODE    eCommand,
-       unsigned char *pbyItem0
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-
-       if (pDevice->cbFreeCmdQueue == 0)
-               return false;
-
-       pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].eCmd = eCommand;
-       pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = true;
-       memset(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID, 0 , WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
-
-       if (pbyItem0 != NULL) {
-               switch (eCommand) {
-               case WLAN_CMD_BSSID_SCAN:
-                       memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
-                              pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
-                       pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = false;
-                       break;
-
-               case WLAN_CMD_SSID:
-                       memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
-                              pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
-                       break;
-
-               case WLAN_CMD_DISASSOCIATE:
-                       pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bNeedRadioOFF = *((int *)pbyItem0);
-                       break;
-
-               case WLAN_CMD_RX_PSPOLL:
-                       break;
-
-               case WLAN_CMD_RADIO:
-                       pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bRadioCmd = *((int *)pbyItem0);
-                       break;
-
-               case WLAN_CMD_CHANGE_BBSENSITIVITY:
-                       pDevice->eCommandState = WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE;
-                       break;
-
-               default:
-                       break;
-               }
-       }
-
-       ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdEnqueueIdx, CMD_Q_SIZE);
-       pDevice->cbFreeCmdQueue--;
-
-       if (!pDevice->bCmdRunning)
-               s_bCommandComplete(pDevice);
-
-       return true;
-}
-
-/*
- * Description:
- *      Clear BSSID_SCAN cmd in CMD Queue
- *
- * Parameters:
- *  In:
- *      hDeviceContext  - Pointer to the adapter
- *      eCommand        - Command
- *  Out:
- *      none
- *
- * Return Value: true if success; otherwise false
- *
- */
-bool bClearBSSID_SCAN(
-       void *hDeviceContext
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       unsigned int uCmdDequeueIdx = pDevice->uCmdDequeueIdx;
-       unsigned int ii;
-
-       if ((pDevice->cbFreeCmdQueue < CMD_Q_SIZE) && (uCmdDequeueIdx != pDevice->uCmdEnqueueIdx)) {
-               for (ii = 0; ii < (CMD_Q_SIZE - pDevice->cbFreeCmdQueue); ii++) {
-                       if (pDevice->eCmdQueue[uCmdDequeueIdx].eCmd == WLAN_CMD_BSSID_SCAN)
-                               pDevice->eCmdQueue[uCmdDequeueIdx].eCmd = WLAN_CMD_IDLE;
-                       ADD_ONE_WITH_WRAP_AROUND(uCmdDequeueIdx, CMD_Q_SIZE);
-                       if (uCmdDequeueIdx == pDevice->uCmdEnqueueIdx)
-                               break;
-               }
-       }
-       return true;
-}
-
-//mike add:reset command timer
-void
-vResetCommandTimer(
-       void *hDeviceContext
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-
-       //delete timer
-       del_timer(&pDevice->sTimerCommand);
-       //init timer
-       init_timer(&pDevice->sTimerCommand);
-       pDevice->sTimerCommand.data = (unsigned long) pDevice;
-       pDevice->sTimerCommand.function = (TimerFunction)vCommandTimer;
-       pDevice->sTimerCommand.expires = RUN_AT(HZ);
-       pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
-       pDevice->uCmdDequeueIdx = 0;
-       pDevice->uCmdEnqueueIdx = 0;
-       pDevice->eCommandState = WLAN_CMD_IDLE;
-       pDevice->bCmdRunning = false;
-       pDevice->bCmdClear = false;
-}
-
-void
-BSSvSecondTxData(
-       void *hDeviceContext
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject  pMgmt = &(pDevice->sMgmtObj);
-
-       pDevice->nTxDataTimeCout++;
-
-       if (pDevice->nTxDataTimeCout < 4)     //don't tx data if timer less than 40s
-       {
-               pDevice->sTimerTxData.expires = RUN_AT(10*HZ);      //10s callback
-               add_timer(&pDevice->sTimerTxData);
-               return;
-       }
-
-       spin_lock_irq(&pDevice->lock);
-
-       /* open && sharekey linking */
-       if ((pDevice->bLinkPass && (pMgmt->eAuthenMode < WMAC_AUTH_WPA)) ||
-           pDevice->fWPA_Authened) {   /* wpa linking */
-               pDevice->fTxDataInSleep = true;
-               PSbSendNullPacket(pDevice);     /* send null packet */
-               pDevice->fTxDataInSleep = false;
-       }
-
-       spin_unlock_irq(&pDevice->lock);
-
-       pDevice->sTimerTxData.expires = RUN_AT(10*HZ); /* 10s callback */
-       add_timer(&pDevice->sTimerTxData);
-}
diff --git a/drivers/staging/vt6655/wcmd.h b/drivers/staging/vt6655/wcmd.h
deleted file mode 100644 (file)
index 6ef04de..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: wcmd.h
- *
- * Purpose: Handles the management command interface functions
- *
- * Author: Lyndon Chen
- *
- * Date: May 8, 2002
- *
- */
-
-#ifndef __WCMD_H__
-#define __WCMD_H__
-
-#include "ttype.h"
-#include "80211hdr.h"
-#include "80211mgr.h"
-
-#define AUTHENTICATE_TIMEOUT   1000
-#define ASSOCIATE_TIMEOUT      1000
-
-typedef enum tagCMD_CODE {
-       WLAN_CMD_BSSID_SCAN,
-       WLAN_CMD_SSID,
-       WLAN_CMD_DISASSOCIATE,
-       WLAN_CMD_DEAUTH,
-       WLAN_CMD_RX_PSPOLL,
-       WLAN_CMD_RADIO,
-       WLAN_CMD_CHANGE_BBSENSITIVITY,
-       WLAN_CMD_SETPOWER,
-       WLAN_CMD_TBTT_WAKEUP,
-       WLAN_CMD_BECON_SEND,
-       WLAN_CMD_CHANGE_ANTENNA,
-       WLAN_CMD_REMOVE_ALLKEY,
-       WLAN_CMD_MAC_DISPOWERSAVING,
-       WLAN_CMD_11H_CHSW,
-       WLAN_CMD_RUN_AP
-} CMD_CODE, *PCMD_CODE;
-
-#define CMD_Q_SIZE              32
-
-typedef enum tagCMD_STATUS {
-       CMD_STATUS_SUCCESS = 0,
-       CMD_STATUS_FAILURE,
-       CMD_STATUS_RESOURCES,
-       CMD_STATUS_TIMEOUT,
-       CMD_STATUS_PENDING
-} CMD_STATUS, *PCMD_STATUS;
-
-typedef struct tagCMD_ITEM {
-       CMD_CODE eCmd;
-       unsigned char abyCmdDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
-       bool bNeedRadioOFF;
-       unsigned short wDeAuthenReason;
-       bool bRadioCmd;
-       bool bForceSCAN;
-} CMD_ITEM, *PCMD_ITEM;
-
-typedef enum tagCMD_STATE {
-       WLAN_CMD_SCAN_START,
-       WLAN_CMD_SCAN_END,
-       WLAN_CMD_DISASSOCIATE_START,
-       WLAN_CMD_SSID_START,
-       WLAN_AUTHENTICATE_WAIT,
-       WLAN_ASSOCIATE_WAIT,
-       WLAN_DISASSOCIATE_WAIT,
-       WLAN_CMD_TX_PSPACKET_START,
-       WLAN_CMD_AP_MODE_START,
-       WLAN_CMD_RADIO_START,
-       WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE,
-       WLAN_CMD_IDLE
-} CMD_STATE, *PCMD_STATE;
-
-void
-vResetCommandTimer(
-       void *hDeviceContext
-);
-
-void
-vCommandTimer(
-       void *hDeviceContext
-);
-
-bool bClearBSSID_SCAN(
-       void *hDeviceContext
-);
-
-bool
-bScheduleCommand(
-       void *hDeviceContext,
-       CMD_CODE    eCommand,
-       unsigned char *pbyItem0
-);
-
-void
-vCommandTimerWait(
-       void *hDeviceContext,
-       unsigned int MSecond
-);
-
-void
-BSSvSecondTxData(
-       void *hDeviceContext
-);
-
-#endif //__WCMD_H__
diff --git a/drivers/staging/vt6655/wctl.c b/drivers/staging/vt6655/wctl.c
deleted file mode 100644 (file)
index 5a54d98..0000000
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: wctl.c
- *
- * Purpose: handle WMAC duplicate filter & defragment
- *
- * Author: Jerry Chen
- *
- * Date: Jun. 27, 2002
- *
- * Functions:
- *      WCTLbIsDuplicate - Test if duplicate packet
- *      WCTLuSearchDFCB - Search DeFragment Control Database
- *      WCTLuInsertDFCB - Insert DeFragment Control Database
- *      WCTLbHandleFragment - Handle received fragment packet
- *
- * Revision History:
- *
- */
-
-#include "wctl.h"
-#include "device.h"
-#include "card.h"
-
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Variables  --------------------------*/
-
-/*---------------------  Static Functions  --------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*
- * Description:
- *      Scan Rx cache.  Return true if packet is duplicate, else
- *      inserts in receive cache and returns false.
- *
- * Parameters:
- *  In:
- *      pCache      - Receive packets history
- *      pMACHeader  - 802.11 MAC Header of received packet
- *  Out:
- *      none
- *
- * Return Value: true if packet duplicate; otherwise false
- *
- */
-
-bool WCTLbIsDuplicate(PSCache pCache, PS802_11Header pMACHeader)
-{
-       unsigned int uIndex;
-       unsigned int ii;
-       PSCacheEntry    pCacheEntry;
-
-       if (IS_FC_RETRY(pMACHeader)) {
-               uIndex = pCache->uInPtr;
-               for (ii = 0; ii < DUPLICATE_RX_CACHE_LENGTH; ii++) {
-                       pCacheEntry = &(pCache->asCacheEntry[uIndex]);
-                       if ((pCacheEntry->wFmSequence == pMACHeader->wSeqCtl) &&
-                           ether_addr_equal(pCacheEntry->abyAddr2,
-                                            pMACHeader->abyAddr2)) {
-                               /* Duplicate match */
-                               return true;
-                       }
-                       ADD_ONE_WITH_WRAP_AROUND(uIndex, DUPLICATE_RX_CACHE_LENGTH);
-               }
-       }
-       /* Not fount in cache - insert */
-       pCacheEntry = &pCache->asCacheEntry[pCache->uInPtr];
-       pCacheEntry->wFmSequence = pMACHeader->wSeqCtl;
-       memcpy(&(pCacheEntry->abyAddr2[0]), &(pMACHeader->abyAddr2[0]), ETH_ALEN);
-       ADD_ONE_WITH_WRAP_AROUND(pCache->uInPtr, DUPLICATE_RX_CACHE_LENGTH);
-       return false;
-}
-
-/*
- * Description:
- *      Found if sequence number of received fragment packet in Defragment Database
- *
- * Parameters:
- *  In:
- *      pDevice     - Pointer to adapter
- *      pMACHeader  - 802.11 MAC Header of received packet
- *  Out:
- *      none
- *
- * Return Value: index number in Defragment Database
- *
- */
-unsigned int WCTLuSearchDFCB(struct vnt_private *pDevice,
-                            PS802_11Header pMACHeader)
-{
-       unsigned int ii;
-
-       for (ii = 0; ii < pDevice->cbDFCB; ii++) {
-               if (pDevice->sRxDFCB[ii].bInUse &&
-                   ether_addr_equal(pDevice->sRxDFCB[ii].abyAddr2,
-                                    pMACHeader->abyAddr2)) {
-                       return ii;
-               }
-       }
-       return pDevice->cbDFCB;
-}
-
-/*
- * Description:
- *      Insert received fragment packet in Defragment Database
- *
- * Parameters:
- *  In:
- *      pDevice     - Pointer to adapter
- *      pMACHeader  - 802.11 MAC Header of received packet
- *  Out:
- *      none
- *
- * Return Value: index number in Defragment Database
- *
- */
-unsigned int WCTLuInsertDFCB(struct vnt_private *pDevice, PS802_11Header pMACHeader)
-{
-       unsigned int ii;
-
-       if (pDevice->cbFreeDFCB == 0)
-               return pDevice->cbDFCB;
-       for (ii = 0; ii < pDevice->cbDFCB; ii++) {
-               if (!pDevice->sRxDFCB[ii].bInUse) {
-                       pDevice->cbFreeDFCB--;
-                       pDevice->sRxDFCB[ii].uLifetime = pDevice->dwMaxReceiveLifetime;
-                       pDevice->sRxDFCB[ii].bInUse = true;
-                       pDevice->sRxDFCB[ii].wSequence = (pMACHeader->wSeqCtl >> 4);
-                       pDevice->sRxDFCB[ii].wFragNum = (pMACHeader->wSeqCtl & 0x000F);
-                       memcpy(&(pDevice->sRxDFCB[ii].abyAddr2[0]), &(pMACHeader->abyAddr2[0]), ETH_ALEN);
-                       return ii;
-               }
-       }
-       return pDevice->cbDFCB;
-}
-
-/*
- * Description:
- *      Handle received fragment packet
- *
- * Parameters:
- *  In:
- *      pDevice         - Pointer to adapter
- *      pMACHeader      - 802.11 MAC Header of received packet
- *      cbFrameLength   - Frame length
- *      bWEP            - is WEP packet
- *  Out:
- *      none
- *
- * Return Value: true if it is valid fragment packet and we have resource to defragment; otherwise false
- *
- */
-bool WCTLbHandleFragment(struct vnt_private *pDevice, PS802_11Header pMACHeader,
-                        unsigned int cbFrameLength, bool bWEP, bool bExtIV)
-{
-       unsigned int uHeaderSize;
-
-       if (bWEP) {
-               uHeaderSize = 28;
-               if (bExtIV)
-                       // ExtIV
-                       uHeaderSize += 4;
-       } else {
-               uHeaderSize = 24;
-       }
-
-       if (IS_FIRST_FRAGMENT_PKT(pMACHeader)) {
-               pDevice->uCurrentDFCBIdx = WCTLuSearchDFCB(pDevice, pMACHeader);
-               if (pDevice->uCurrentDFCBIdx < pDevice->cbDFCB) {
-                       // duplicate, we must flush previous DCB
-                       pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].uLifetime = pDevice->dwMaxReceiveLifetime;
-                       pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wSequence = (pMACHeader->wSeqCtl >> 4);
-                       pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum = (pMACHeader->wSeqCtl & 0x000F);
-               } else {
-                       pDevice->uCurrentDFCBIdx = WCTLuInsertDFCB(pDevice, pMACHeader);
-                       if (pDevice->uCurrentDFCBIdx == pDevice->cbDFCB)
-                               return false;
-               }
-               // reserve 4 byte to match MAC RX Buffer
-               pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer = (unsigned char *)(pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].skb->data + 4);
-               memcpy(pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer, pMACHeader, cbFrameLength);
-               pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength = cbFrameLength;
-               pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer += cbFrameLength;
-               pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum++;
-               return false;
-       } else {
-               pDevice->uCurrentDFCBIdx = WCTLuSearchDFCB(pDevice, pMACHeader);
-               if (pDevice->uCurrentDFCBIdx != pDevice->cbDFCB) {
-                       if ((pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wSequence == (pMACHeader->wSeqCtl >> 4)) &&
-                           (pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum == (pMACHeader->wSeqCtl & 0x000F)) &&
-                           ((pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength + cbFrameLength - uHeaderSize) < 2346)) {
-                               memcpy(pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer, ((unsigned char *)(pMACHeader) + uHeaderSize), (cbFrameLength - uHeaderSize));
-                               pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength += (cbFrameLength - uHeaderSize);
-                               pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer += (cbFrameLength - uHeaderSize);
-                               pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum++;
-                       } else {
-                               // seq error or frag # error flush DFCB
-                               pDevice->cbFreeDFCB++;
-                               pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].bInUse = false;
-                               return false;
-                       }
-               } else {
-                       return false;
-               }
-               if (IS_LAST_FRAGMENT_PKT(pMACHeader)) {
-                       //enq defragcontrolblock
-                       pDevice->cbFreeDFCB++;
-                       pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].bInUse = false;
-                       return true;
-               }
-               return false;
-       }
-}
diff --git a/drivers/staging/vt6655/wctl.h b/drivers/staging/vt6655/wctl.h
deleted file mode 100644 (file)
index f0995d8..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: wctl.h
- *
- * Purpose:
- *
- * Author: Jerry Chen
- *
- * Date: Jun. 27, 2002
- *
- */
-
-#ifndef __WCTL_H__
-#define __WCTL_H__
-
-#include "ttype.h"
-#include "tether.h"
-#include "device.h"
-
-/*---------------------  Export Definitions -------------------------*/
-
-#define IS_TYPE_DATA(pMACHeader)                                       \
-       ((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_802_11_MASK) == TYPE_802_11_DATA)
-
-#define IS_TYPE_MGMT(pMACHeader)                                       \
-       ((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_802_11_MASK) == TYPE_802_11_MGMT)
-
-#define IS_TYPE_CONTROL(pMACHeader)                                    \
-       ((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_802_11_MASK) == TYPE_802_11_CTL)
-
-#define IS_FC_MOREDATA(pMACHeader)                                     \
-       ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREDATA) == FC_MOREDATA)
-
-#define IS_FC_POWERMGT(pMACHeader)                                     \
-       ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_POWERMGT) == FC_POWERMGT)
-
-#define IS_FC_RETRY(pMACHeader)                                                \
-       ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_RETRY) == FC_RETRY)
-
-#define IS_FC_WEP(pMACHeader)                                          \
-       ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_WEP) == FC_WEP)
-
-#ifdef __BIG_ENDIAN
-
-#define IS_FRAGMENT_PKT(pMACHeader)                                    \
-       (((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREFRAG) != 0) | \
-        ((((PS802_11Header) pMACHeader)->wSeqCtl & 0x0F00) != 0))
-
-#define IS_FIRST_FRAGMENT_PKT(pMACHeader)                              \
-       ((((PS802_11Header) pMACHeader)->wSeqCtl & 0x0F00) == 0)
-
-#else
-
-#define IS_FRAGMENT_PKT(pMACHeader)                                    \
-       (((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREFRAG) != 0) | \
-        ((((PS802_11Header) pMACHeader)->wSeqCtl & 0x000F) != 0))
-
-#define IS_FIRST_FRAGMENT_PKT(pMACHeader)                              \
-       ((((PS802_11Header) pMACHeader)->wSeqCtl & 0x000F) == 0)
-
-#endif//#ifdef __BIG_ENDIAN
-
-#define IS_LAST_FRAGMENT_PKT(pMACHeader)                               \
-       ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREFRAG) == 0)
-
-#define IS_CTL_PSPOLL(pMACHeader)                                      \
-       ((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL)
-
-#define ADD_ONE_WITH_WRAP_AROUND(uVar, uModulo)                \
-do {                                                   \
-       if ((uVar) >= ((uModulo) - 1))                  \
-               (uVar) = 0;                             \
-       else                                            \
-               (uVar)++;                               \
-} while (0)
-
-/*---------------------  Export Classes  ----------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-bool WCTLbIsDuplicate(PSCache pCache, PS802_11Header pMACHeader);
-bool WCTLbHandleFragment(struct vnt_private *, PS802_11Header pMACHeader,
-                        unsigned int cbFrameLength, bool bWEP, bool bExtIV);
-unsigned int WCTLuSearchDFCB(struct vnt_private *, PS802_11Header pMACHeader);
-unsigned int WCTLuInsertDFCB(struct vnt_private *, PS802_11Header pMACHeader);
-
-#endif // __WCTL_H__
diff --git a/drivers/staging/vt6655/wmgr.c b/drivers/staging/vt6655/wmgr.c
deleted file mode 100644 (file)
index c73c39d..0000000
+++ /dev/null
@@ -1,4602 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: wmgr.c
- *
- * Purpose: Handles the 802.11 management functions
- *
- * Author: Lyndon Chen
- *
- * Date: May 8, 2002
- *
- * Functions:
- *      nsMgrObjectInitial - Initialize Management Object data structure
- *      vMgrObjectReset - Reset Management Object data structure
- *      vMgrAssocBeginSta - Start associate function
- *      vMgrReAssocBeginSta - Start reassociate function
- *      vMgrDisassocBeginSta - Start disassociate function
- *      s_vMgrRxAssocRequest - Handle Rcv associate_request
- *      s_vMgrRxAssocResponse - Handle Rcv associate_response
- *      vMrgAuthenBeginSta - Start authentication function
- *      vMgrDeAuthenDeginSta - Start deauthentication function
- *      s_vMgrRxAuthentication - Handle Rcv authentication
- *      s_vMgrRxAuthenSequence_1 - Handle Rcv authentication sequence 1
- *      s_vMgrRxAuthenSequence_2 - Handle Rcv authentication sequence 2
- *      s_vMgrRxAuthenSequence_3 - Handle Rcv authentication sequence 3
- *      s_vMgrRxAuthenSequence_4 - Handle Rcv authentication sequence 4
- *      s_vMgrRxDisassociation - Handle Rcv disassociation
- *      s_vMgrRxBeacon - Handle Rcv Beacon
- *      vMgrCreateOwnIBSS - Create ad_hoc IBSS or AP BSS
- *      vMgrJoinBSSBegin - Join BSS function
- *      s_vMgrSynchBSS - Synch & adopt BSS parameters
- *      s_MgrMakeBeacon - Create Baecon frame
- *      s_MgrMakeProbeResponse - Create Probe Response frame
- *      s_MgrMakeAssocRequest - Create Associate Request frame
- *      s_MgrMakeReAssocRequest - Create ReAssociate Request frame
- *      s_vMgrRxProbeResponse - Handle Rcv probe_response
- *      s_vMrgRxProbeRequest - Handle Rcv probe_request
- *      bMgrPrepareBeaconToSend - Prepare Beacon frame
- *      s_vMgrLogStatus - Log 802.11 Status
- *      vMgrRxManagePacket - Rcv management frame dispatch function
- *      s_vMgrFormatTIM- Assembler TIM field of beacon
- *      vMgrTimerInit- Initial 1-sec and command call back funtions
- *
- * Revision History:
- *
- */
-
-#include "tmacro.h"
-#include "desc.h"
-#include "device.h"
-#include "card.h"
-#include "channel.h"
-#include "80211hdr.h"
-#include "80211mgr.h"
-#include "wmgr.h"
-#include "wcmd.h"
-#include "mac.h"
-#include "bssdb.h"
-#include "power.h"
-#include "datarate.h"
-#include "baseband.h"
-#include "rxtx.h"
-#include "wpa.h"
-#include "rf.h"
-#include "iowpa.h"
-
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Functions  --------------------------*/
-//2008-8-4 <add> by chester
-static bool ChannelExceedZoneType(
-       struct vnt_private *pDevice,
-       unsigned char byCurrChannel
-);
-
-// Association/diassociation functions
-static
-PSTxMgmtPacket
-s_MgrMakeAssocRequest(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       unsigned char *pDAddr,
-       unsigned short wCurrCapInfo,
-       unsigned short wListenInterval,
-       PWLAN_IE_SSID pCurrSSID,
-       PWLAN_IE_SUPP_RATES pCurrRates,
-       PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-);
-
-static
-void
-s_vMgrRxAssocRequest(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket,
-       unsigned int uNodeIndex
-);
-
-static
-PSTxMgmtPacket
-s_MgrMakeReAssocRequest(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       unsigned char *pDAddr,
-       unsigned short wCurrCapInfo,
-       unsigned short wListenInterval,
-       PWLAN_IE_SSID pCurrSSID,
-       PWLAN_IE_SUPP_RATES pCurrRates,
-       PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-);
-
-static
-void
-s_vMgrRxAssocResponse(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket,
-       bool bReAssocType
-);
-
-static
-void
-s_vMgrRxDisassociation(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket
-);
-
-// Authentication/deauthen functions
-static
-void
-s_vMgrRxAuthenSequence_1(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PWLAN_FR_AUTHEN pFrame
-);
-
-static
-void
-s_vMgrRxAuthenSequence_2(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PWLAN_FR_AUTHEN pFrame
-);
-
-static
-void
-s_vMgrRxAuthenSequence_3(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PWLAN_FR_AUTHEN pFrame
-);
-
-static
-void
-s_vMgrRxAuthenSequence_4(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PWLAN_FR_AUTHEN pFrame
-);
-
-static
-void
-s_vMgrRxAuthentication(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket
-);
-
-static
-void
-s_vMgrRxDeauthentication(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket
-);
-
-// Scan functions
-// probe request/response functions
-static
-void
-s_vMgrRxProbeRequest(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket
-);
-
-static
-void
-s_vMgrRxProbeResponse(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket
-);
-
-// beacon functions
-static
-void
-s_vMgrRxBeacon(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket,
-       bool bInScan
-);
-
-static
-void
-s_vMgrFormatTIM(
-       PSMgmtObject pMgmt,
-       PWLAN_IE_TIM pTIM
-);
-
-static
-PSTxMgmtPacket
-s_MgrMakeBeacon(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       unsigned short wCurrCapInfo,
-       unsigned short wCurrBeaconPeriod,
-       unsigned int uCurrChannel,
-       unsigned short wCurrATIMWinodw,
-       PWLAN_IE_SSID pCurrSSID,
-       unsigned char *pCurrBSSID,
-       PWLAN_IE_SUPP_RATES pCurrSuppRates,
-       PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-);
-
-// Association response
-static
-PSTxMgmtPacket
-s_MgrMakeAssocResponse(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       unsigned short wCurrCapInfo,
-       unsigned short wAssocStatus,
-       unsigned short wAssocAID,
-       unsigned char *pDstAddr,
-       PWLAN_IE_SUPP_RATES pCurrSuppRates,
-       PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-);
-
-// ReAssociation response
-static
-PSTxMgmtPacket
-s_MgrMakeReAssocResponse(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       unsigned short wCurrCapInfo,
-       unsigned short wAssocStatus,
-       unsigned short wAssocAID,
-       unsigned char *pDstAddr,
-       PWLAN_IE_SUPP_RATES pCurrSuppRates,
-       PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-);
-
-// Probe response
-static
-PSTxMgmtPacket
-s_MgrMakeProbeResponse(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       unsigned short wCurrCapInfo,
-       unsigned short wCurrBeaconPeriod,
-       unsigned int uCurrChannel,
-       unsigned short wCurrATIMWinodw,
-       unsigned char *pDstAddr,
-       PWLAN_IE_SSID pCurrSSID,
-       unsigned char *pCurrBSSID,
-       PWLAN_IE_SUPP_RATES pCurrSuppRates,
-       PWLAN_IE_SUPP_RATES pCurrExtSuppRates,
-       unsigned char byPHYType
-);
-
-// received status
-static
-void
-s_vMgrLogStatus(
-       PSMgmtObject pMgmt,
-       unsigned short wStatus
-);
-
-static
-void
-s_vMgrSynchBSS(
-       struct vnt_private *pDevice,
-       unsigned int uBSSMode,
-       PKnownBSS     pCurr,
-       PCMD_STATUS  pStatus
-);
-
-static bool
-s_bCipherMatch(
-       PKnownBSS                        pBSSNode,
-       NDIS_802_11_ENCRYPTION_STATUS    EncStatus,
-       unsigned char *pbyCCSPK,
-       unsigned char *pbyCCSGK
-);
-
-static void  Encyption_Rebuild(
-       struct vnt_private *pDevice,
-       PKnownBSS pCurr
-);
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-/*+
- *
- * Routine Description:
- *    Allocates and initializes the Management object.
- *
- * Return Value:
- *    Ndis_staus.
- *
- -*/
-
-void
-vMgrObjectInit(
-       void *hDeviceContext
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       int ii;
-
-       pMgmt->pbyPSPacketPool = &pMgmt->byPSPacketPool[0];
-       pMgmt->pbyMgmtPacketPool = &pMgmt->byMgmtPacketPool[0];
-       pMgmt->uCurrChannel = pDevice->uChannel;
-       for (ii = 0; ii < WLAN_BSSID_LEN; ii++)
-               pMgmt->abyDesireBSSID[ii] = 0xFF;
-
-       pMgmt->sAssocInfo.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
-       pMgmt->byCSSPK = KEY_CTL_NONE;
-       pMgmt->byCSSGK = KEY_CTL_NONE;
-       pMgmt->wIBSSBeaconPeriod = DEFAULT_IBSS_BI;
-       BSSvClearBSSList((void *)pDevice, false);
-}
-
-/*+
- *
- * Routine Description:
- *    Initializes timer object
- *
- * Return Value:
- *    Ndis_staus.
- *
- -*/
-
-void
-vMgrTimerInit(
-       void *hDeviceContext
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-
-       init_timer(&pMgmt->sTimerSecondCallback);
-       pMgmt->sTimerSecondCallback.data = (unsigned long) pDevice;
-       pMgmt->sTimerSecondCallback.function = (TimerFunction)BSSvSecondCallBack;
-       pMgmt->sTimerSecondCallback.expires = RUN_AT(HZ);
-
-       init_timer(&pDevice->sTimerCommand);
-       pDevice->sTimerCommand.data = (unsigned long) pDevice;
-       pDevice->sTimerCommand.function = (TimerFunction)vCommandTimer;
-       pDevice->sTimerCommand.expires = RUN_AT(HZ);
-
-       init_timer(&pDevice->sTimerTxData);
-       pDevice->sTimerTxData.data = (unsigned long) pDevice;
-       pDevice->sTimerTxData.function = (TimerFunction)BSSvSecondTxData;
-       pDevice->sTimerTxData.expires = RUN_AT(10*HZ);      //10s callback
-       pDevice->fTxDataInSleep = false;
-       pDevice->IsTxDataTrigger = false;
-       pDevice->nTxDataTimeCout = 0;
-
-       pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
-       pDevice->uCmdDequeueIdx = 0;
-       pDevice->uCmdEnqueueIdx = 0;
-}
-
-/*+
- *
- * Routine Description:
- *    Reset the management object structure.
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrObjectReset(
-       void *hDeviceContext
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject        pMgmt = pDevice->pMgmt;
-
-       pMgmt->eCurrMode = WMAC_MODE_STANDBY;
-       pMgmt->eCurrState = WMAC_STATE_IDLE;
-       pDevice->bEnablePSMode = false;
-       // TODO: timer
-}
-
-/*+
- *
- * Routine Description:
- *    Start the station association procedure.  Namely, send an
- *    association request frame to the AP.
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrAssocBeginSta(
-       void *hDeviceContext,
-       PSMgmtObject pMgmt,
-       PCMD_STATUS pStatus
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSTxMgmtPacket          pTxPacket;
-
-       pMgmt->wCurrCapInfo = 0;
-       pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1);
-       if (pDevice->bEncryptionEnable)
-               pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1);
-
-       pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
-       if (pMgmt->wListenInterval == 0)
-               pMgmt->wListenInterval = 1;    // at least one.
-
-       // ERP Phy (802.11g) should support short preamble.
-       if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) {
-               pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
-               if (CARDbIsShorSlotTime(pMgmt->pAdapter))
-                       pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);
-       } else if (pMgmt->eCurrentPHYMode == PHY_TYPE_11B) {
-               if (CARDbIsShortPreamble(pMgmt->pAdapter))
-                       pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
-       }
-       if (pMgmt->b11hEnable)
-               pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);
-
-       /* build an assocreq frame and send it */
-       pTxPacket = s_MgrMakeAssocRequest
-               (
-                       pDevice,
-                       pMgmt,
-                       pMgmt->abyCurrBSSID,
-                       pMgmt->wCurrCapInfo,
-                       pMgmt->wListenInterval,
-                       (PWLAN_IE_SSID)pMgmt->abyCurrSSID,
-                       (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                       (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates
-);
-
-       if (pTxPacket != NULL) {
-               /* send the frame */
-               *pStatus = csMgmt_xmit(pDevice, pTxPacket);
-               if (*pStatus == CMD_STATUS_PENDING) {
-                       pMgmt->eCurrState = WMAC_STATE_ASSOCPENDING;
-                       *pStatus = CMD_STATUS_SUCCESS;
-               }
-       } else {
-               *pStatus = CMD_STATUS_RESOURCES;
-       }
-}
-
-/*+
- *
- * Routine Description:
- *    Start the station re-association procedure.
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrReAssocBeginSta(
-       void *hDeviceContext,
-       PSMgmtObject pMgmt,
-       PCMD_STATUS pStatus
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSTxMgmtPacket          pTxPacket;
-
-       pMgmt->wCurrCapInfo = 0;
-       pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1);
-       if (pDevice->bEncryptionEnable)
-               pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1);
-
-       pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
-
-       if (pMgmt->wListenInterval == 0)
-               pMgmt->wListenInterval = 1;    // at least one.
-
-       // ERP Phy (802.11g) should support short preamble.
-       if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) {
-               pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
-               if (CARDbIsShorSlotTime(pMgmt->pAdapter))
-                       pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);
-       } else if (pMgmt->eCurrentPHYMode == PHY_TYPE_11B) {
-               if (CARDbIsShortPreamble(pMgmt->pAdapter))
-                       pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
-       }
-
-       if (pMgmt->b11hEnable)
-               pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);
-
-       pTxPacket = s_MgrMakeReAssocRequest
-               (
-                       pDevice,
-                       pMgmt,
-                       pMgmt->abyCurrBSSID,
-                       pMgmt->wCurrCapInfo,
-                       pMgmt->wListenInterval,
-                       (PWLAN_IE_SSID)pMgmt->abyCurrSSID,
-                       (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                       (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates
-);
-
-       if (pTxPacket != NULL) {
-               /* send the frame */
-               *pStatus = csMgmt_xmit(pDevice, pTxPacket);
-               if (*pStatus != CMD_STATUS_PENDING)
-                       pr_debug("Mgt:Reassociation tx failed\n");
-               else
-                       pr_debug("Mgt:Reassociation tx sending\n");
-       }
-}
-
-/*+
- *
- * Routine Description:
- *    Send an dis-association request frame to the AP.
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrDisassocBeginSta(
-       void *hDeviceContext,
-       PSMgmtObject pMgmt,
-       unsigned char *abyDestAddress,
-       unsigned short wReason,
-       PCMD_STATUS pStatus
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSTxMgmtPacket      pTxPacket = NULL;
-       WLAN_FR_DISASSOC    sFrame;
-
-       pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-       memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_DISASSOC_FR_MAXLEN);
-       pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket));
-
-       // Setup the sFrame structure
-       sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header;
-       sFrame.len = WLAN_DISASSOC_FR_MAXLEN;
-
-       // format fixed field frame structure
-       vMgrEncodeDisassociation(&sFrame);
-
-       // Setup the header
-       sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
-               (
-                       WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
-                       WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DISASSOC)
-));
-
-       memcpy(sFrame.pHdr->sA3.abyAddr1, abyDestAddress, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
-
-       // Set reason code
-       *(sFrame.pwReason) = cpu_to_le16(wReason);
-       pTxPacket->cbMPDULen = sFrame.len;
-       pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
-
-       // send the frame
-       *pStatus = csMgmt_xmit(pDevice, pTxPacket);
-       if (*pStatus == CMD_STATUS_PENDING) {
-               pMgmt->eCurrState = WMAC_STATE_IDLE;
-               *pStatus = CMD_STATUS_SUCCESS;
-       }
-}
-
-/*+
- *
- * Routine Description:(AP function)
- *    Handle incoming station association request frames.
- *
- * Return Value:
- *    None.
- *
- -*/
-
-static
-void
-s_vMgrRxAssocRequest(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket,
-       unsigned int uNodeIndex
-)
-{
-       WLAN_FR_ASSOCREQ    sFrame;
-       CMD_STATUS          Status;
-       PSTxMgmtPacket      pTxPacket;
-       unsigned short wAssocStatus = 0;
-       unsigned short wAssocAID = 0;
-       unsigned int uRateLen = WLAN_RATES_MAXLEN;
-       unsigned char abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
-       unsigned char abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
-
-       if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP)
-               return;
-       //  node index not found
-       if (!uNodeIndex)
-               return;
-
-       //check if node is authenticated
-       //decode the frame
-       memset(&sFrame, 0, sizeof(WLAN_FR_ASSOCREQ));
-       memset(abyCurrSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
-       memset(abyCurrExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
-       sFrame.len = pRxPacket->cbMPDULen;
-       sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header;
-
-       vMgrDecodeAssocRequest(&sFrame);
-
-       if (pMgmt->sNodeDBTable[uNodeIndex].eNodeState >= NODE_AUTH) {
-               pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC;
-               pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = cpu_to_le16(*sFrame.pwCapInfo);
-               pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = cpu_to_le16(*sFrame.pwListenInterval);
-               pMgmt->sNodeDBTable[uNodeIndex].bPSEnable =
-                       WLAN_GET_FC_PWRMGT(sFrame.pHdr->sA3.wFrameCtl) ? true : false;
-               // Todo: check sta basic rate, if ap can't support, set status code
-               if (pDevice->eCurrentPHYType == PHY_TYPE_11B)
-                       uRateLen = WLAN_RATES_MAXLEN_11B;
-
-               abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES;
-               abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates,
-                                                (PWLAN_IE_SUPP_RATES)abyCurrSuppRates,
-                                                uRateLen);
-               abyCurrExtSuppRates[0] = WLAN_EID_EXTSUPP_RATES;
-               if (pDevice->eCurrentPHYType == PHY_TYPE_11G)
-                       abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pExtSuppRates,
-                                                           (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates,
-                                                           uRateLen);
-               else
-                       abyCurrExtSuppRates[1] = 0;
-
-               RATEvParseMaxRate((void *)pDevice,
-                                 (PWLAN_IE_SUPP_RATES)abyCurrSuppRates,
-                                 (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates,
-                                 false, // do not change our basic rate
-                                 &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate),
-                                 &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate),
-                                 &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate),
-                                 &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate),
-                                 &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate)
-);
-
-               // set max tx rate
-               pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate =
-                       pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate;
-
-               pr_debug("RxAssocRequest:wTxDataRate is %d\n", pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate);
-
-               // Todo: check sta preamble, if ap can't support, set status code
-               pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble =
-                       WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo);
-               pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime =
-                       WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo);
-               pMgmt->sNodeDBTable[uNodeIndex].wAID = (unsigned short)uNodeIndex;
-               wAssocStatus = WLAN_MGMT_STATUS_SUCCESS;
-               wAssocAID = (unsigned short)uNodeIndex;
-               // check if ERP support
-               if (pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M)
-                       pMgmt->sNodeDBTable[uNodeIndex].bERPExist = true;
-
-               if (pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate <= RATE_11M) {
-                       // B only STA join
-                       pDevice->bProtectMode = true;
-                       pDevice->bNonERPPresent = true;
-               }
-               if (!pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble)
-                       pDevice->bBarkerPreambleMd = true;
-
-               pr_info("Associate AID= %d\n", wAssocAID);
-               pr_info("MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
-                       sFrame.pHdr->sA3.abyAddr2[0],
-                       sFrame.pHdr->sA3.abyAddr2[1],
-                       sFrame.pHdr->sA3.abyAddr2[2],
-                       sFrame.pHdr->sA3.abyAddr2[3],
-                       sFrame.pHdr->sA3.abyAddr2[4],
-                       sFrame.pHdr->sA3.abyAddr2[5]
-                       );
-               pr_info("Max Support rate = %d\n",
-                       pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate);
-       } else {
-               /* TODO: received STA under state1 handle */
-               return;
-       }
-
-       // assoc response reply..
-       pTxPacket = s_MgrMakeAssocResponse
-               (
-                       pDevice,
-                       pMgmt,
-                       pMgmt->wCurrCapInfo,
-                       wAssocStatus,
-                       wAssocAID,
-                       sFrame.pHdr->sA3.abyAddr2,
-                       (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                       (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates
-);
-       if (pTxPacket != NULL) {
-               if (pDevice->bEnableHostapd)
-                       return;
-
-               /* send the frame */
-               Status = csMgmt_xmit(pDevice, pTxPacket);
-               if (Status != CMD_STATUS_PENDING)
-                       pr_debug("Mgt:Assoc response tx failed\n");
-               else
-                       pr_debug("Mgt:Assoc response tx sending..\n");
-       }
-}
-
-/*+
- *
- * Description:(AP function)
- *      Handle incoming station re-association request frames.
- *
- * Parameters:
- *  In:
- *      pMgmt           - Management Object structure
- *      pRxPacket       - Received Packet
- *  Out:
- *      none
- *
- * Return Value: None.
- *
- -*/
-
-static
-void
-s_vMgrRxReAssocRequest(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket,
-       unsigned int uNodeIndex
-)
-{
-       WLAN_FR_REASSOCREQ    sFrame;
-       CMD_STATUS          Status;
-       PSTxMgmtPacket      pTxPacket;
-       unsigned short wAssocStatus = 0;
-       unsigned short wAssocAID = 0;
-       unsigned int    uRateLen = WLAN_RATES_MAXLEN;
-       unsigned char abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
-       unsigned char abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
-
-       if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP)
-               return;
-       //  node index not found
-       if (!uNodeIndex)
-               return;
-       //check if node is authenticated
-       //decode the frame
-       memset(&sFrame, 0, sizeof(WLAN_FR_REASSOCREQ));
-       sFrame.len = pRxPacket->cbMPDULen;
-       sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header;
-       vMgrDecodeReassocRequest(&sFrame);
-
-       if (pMgmt->sNodeDBTable[uNodeIndex].eNodeState >= NODE_AUTH) {
-               pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC;
-               pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = cpu_to_le16(*sFrame.pwCapInfo);
-               pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = cpu_to_le16(*sFrame.pwListenInterval);
-               pMgmt->sNodeDBTable[uNodeIndex].bPSEnable =
-                       WLAN_GET_FC_PWRMGT(sFrame.pHdr->sA3.wFrameCtl) ? true : false;
-               // Todo: check sta basic rate, if ap can't support, set status code
-
-               if (pDevice->eCurrentPHYType == PHY_TYPE_11B)
-                       uRateLen = WLAN_RATES_MAXLEN_11B;
-
-               abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES;
-               abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates,
-                                                (PWLAN_IE_SUPP_RATES)abyCurrSuppRates,
-                                                uRateLen);
-               abyCurrExtSuppRates[0] = WLAN_EID_EXTSUPP_RATES;
-               if (pDevice->eCurrentPHYType == PHY_TYPE_11G) {
-                       abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pExtSuppRates,
-                                                           (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates,
-                                                           uRateLen);
-               } else {
-                       abyCurrExtSuppRates[1] = 0;
-               }
-
-               RATEvParseMaxRate((void *)pDevice,
-                                 (PWLAN_IE_SUPP_RATES)abyCurrSuppRates,
-                                 (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates,
-                                 false, // do not change our basic rate
-                                 &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate),
-                                 &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate),
-                                 &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate),
-                                 &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate),
-                                 &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate)
-);
-
-               // set max tx rate
-               pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate =
-                       pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate;
-
-               pr_debug("RxReAssocRequest:TxDataRate is %d\n", pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate);
-
-               // Todo: check sta preamble, if ap can't support, set status code
-               pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble =
-                       WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo);
-               pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime =
-                       WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo);
-               pMgmt->sNodeDBTable[uNodeIndex].wAID = (unsigned short)uNodeIndex;
-               wAssocStatus = WLAN_MGMT_STATUS_SUCCESS;
-               wAssocAID = (unsigned short)uNodeIndex;
-
-               // if suppurt ERP
-               if (pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M)
-                       pMgmt->sNodeDBTable[uNodeIndex].bERPExist = true;
-
-               if (pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate <= RATE_11M) {
-                       // B only STA join
-                       pDevice->bProtectMode = true;
-                       pDevice->bNonERPPresent = true;
-               }
-               if (!pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble)
-                       pDevice->bBarkerPreambleMd = true;
-
-               pr_info("Rx ReAssociate AID= %d\n", wAssocAID);
-               pr_info("MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
-                       sFrame.pHdr->sA3.abyAddr2[0],
-                       sFrame.pHdr->sA3.abyAddr2[1],
-                       sFrame.pHdr->sA3.abyAddr2[2],
-                       sFrame.pHdr->sA3.abyAddr2[3],
-                       sFrame.pHdr->sA3.abyAddr2[4],
-                       sFrame.pHdr->sA3.abyAddr2[5]
-                       );
-               pr_info("Max Support rate = %d\n",
-                       pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate);
-
-       }
-
-       // assoc response reply..
-       pTxPacket = s_MgrMakeReAssocResponse
-               (
-                       pDevice,
-                       pMgmt,
-                       pMgmt->wCurrCapInfo,
-                       wAssocStatus,
-                       wAssocAID,
-                       sFrame.pHdr->sA3.abyAddr2,
-                       (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                       (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates
-                       );
-
-       if (pTxPacket != NULL) {
-               /* send the frame */
-               if (pDevice->bEnableHostapd)
-                       return;
-
-               Status = csMgmt_xmit(pDevice, pTxPacket);
-               if (Status != CMD_STATUS_PENDING)
-                       pr_debug("Mgt:ReAssoc response tx failed\n");
-               else
-                       pr_debug("Mgt:ReAssoc response tx sending..\n");
-       }
-}
-
-/*+
- *
- * Routine Description:
- *    Handle incoming association response frames.
- *
- * Return Value:
- *    None.
- *
- -*/
-
-static
-void
-s_vMgrRxAssocResponse(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket,
-       bool bReAssocType
-)
-{
-       WLAN_FR_ASSOCRESP   sFrame;
-       PWLAN_IE_SSID   pItemSSID;
-       unsigned char *pbyIEs;
-       viawget_wpa_header *wpahdr;
-
-       if (pMgmt->eCurrState == WMAC_STATE_ASSOCPENDING ||
-           pMgmt->eCurrState == WMAC_STATE_ASSOC) {
-               sFrame.len = pRxPacket->cbMPDULen;
-               sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header;
-               // decode the frame
-               vMgrDecodeAssocResponse(&sFrame);
-               if ((sFrame.pwCapInfo == NULL) ||
-                   (sFrame.pwStatus == NULL) ||
-                   (sFrame.pwAid == NULL) ||
-                   (sFrame.pSuppRates == NULL)) {
-                       DBG_PORT80(0xCC);
-                       return;
-               }
-
-               pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.Capabilities = *(sFrame.pwCapInfo);
-               pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.StatusCode = *(sFrame.pwStatus);
-               pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.AssociationId = *(sFrame.pwAid);
-               pMgmt->sAssocInfo.AssocInfo.AvailableResponseFixedIEs |= 0x07;
-
-               pMgmt->sAssocInfo.AssocInfo.ResponseIELength = sFrame.len - 24 - 6;
-               pMgmt->sAssocInfo.AssocInfo.OffsetResponseIEs = pMgmt->sAssocInfo.AssocInfo.OffsetRequestIEs + pMgmt->sAssocInfo.AssocInfo.RequestIELength;
-               pbyIEs = pMgmt->sAssocInfo.abyIEs;
-               pbyIEs += pMgmt->sAssocInfo.AssocInfo.RequestIELength;
-               memcpy(pbyIEs, (sFrame.pBuf + 24 + 6), pMgmt->sAssocInfo.AssocInfo.ResponseIELength);
-
-               // save values and set current BSS state
-               if (cpu_to_le16((*(sFrame.pwStatus))) == WLAN_MGMT_STATUS_SUCCESS) {
-                       // set AID
-                       pMgmt->wCurrAID = cpu_to_le16((*(sFrame.pwAid)));
-                       if ((pMgmt->wCurrAID >> 14) != (BIT0 | BIT1))
-                               pr_debug("AID from AP, has two msb clear\n");
-
-                       pr_info("Association Successful, AID=%d\n",
-                               pMgmt->wCurrAID & ~(BIT14 | BIT15));
-                       pMgmt->eCurrState = WMAC_STATE_ASSOC;
-                       BSSvUpdateAPNode((void *)pDevice, sFrame.pwCapInfo, sFrame.pSuppRates, sFrame.pExtSuppRates);
-                       pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
-                       pr_info("Link with AP(SSID): %s\n", pItemSSID->abySSID);
-                       pDevice->bLinkPass = true;
-                       pDevice->uBBVGADiffCount = 0;
-                       if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
-                               if (skb_tailroom(pDevice->skb) < (sizeof(viawget_wpa_header) + pMgmt->sAssocInfo.AssocInfo.ResponseIELength +
-                                                                 pMgmt->sAssocInfo.AssocInfo.RequestIELength)) {    //data room not enough
-                                       dev_kfree_skb(pDevice->skb);
-                                       pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
-                               }
-                               wpahdr = (viawget_wpa_header *)pDevice->skb->data;
-                               wpahdr->type = VIAWGET_ASSOC_MSG;
-                               wpahdr->resp_ie_len = pMgmt->sAssocInfo.AssocInfo.ResponseIELength;
-                               wpahdr->req_ie_len = pMgmt->sAssocInfo.AssocInfo.RequestIELength;
-                               memcpy(pDevice->skb->data + sizeof(viawget_wpa_header), pMgmt->sAssocInfo.abyIEs, wpahdr->req_ie_len);
-                               memcpy(pDevice->skb->data + sizeof(viawget_wpa_header) + wpahdr->req_ie_len,
-                                      pbyIEs,
-                                      wpahdr->resp_ie_len
-);
-                               skb_put(pDevice->skb, sizeof(viawget_wpa_header) + wpahdr->resp_ie_len + wpahdr->req_ie_len);
-                               pDevice->skb->dev = pDevice->wpadev;
-                               skb_reset_mac_header(pDevice->skb);
-                               pDevice->skb->pkt_type = PACKET_HOST;
-                               pDevice->skb->protocol = htons(ETH_P_802_2);
-                               memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
-                               netif_rx(pDevice->skb);
-                               pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
-                       }
-
-//2008-0409-07, <Add> by Einsn Liu
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-                       {
-                               unsigned char buf[512];
-                               size_t len;
-                               union iwreq_data  wrqu;
-                               int we_event;
-
-                               memset(buf, 0, 512);
-
-                               len = pMgmt->sAssocInfo.AssocInfo.RequestIELength;
-                               if (len)        {
-                                       memcpy(buf, pMgmt->sAssocInfo.abyIEs, len);
-                                       memset(&wrqu, 0, sizeof(wrqu));
-                                       wrqu.data.length = len;
-                                       we_event = IWEVASSOCREQIE;
-                                       wireless_send_event(pDevice->dev, we_event, &wrqu, buf);
-                               }
-
-                               memset(buf, 0, 512);
-                               len = pMgmt->sAssocInfo.AssocInfo.ResponseIELength;
-
-                               if (len)        {
-                                       memcpy(buf, pbyIEs, len);
-                                       memset(&wrqu, 0, sizeof(wrqu));
-                                       wrqu.data.length = len;
-                                       we_event = IWEVASSOCRESPIE;
-                                       wireless_send_event(pDevice->dev, we_event, &wrqu, buf);
-                               }
-
-                               memset(&wrqu, 0, sizeof(wrqu));
-                               memcpy(wrqu.ap_addr.sa_data, &pMgmt->abyCurrBSSID[0], ETH_ALEN);
-                               wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-                               wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
-                       }
-#endif //#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-//End Add -- //2008-0409-07, <Add> by Einsn Liu
-               } else {
-                       if (bReAssocType) {
-                               pMgmt->eCurrState = WMAC_STATE_IDLE;
-                       } else {
-                               // jump back to the auth state and indicate the error
-                               pMgmt->eCurrState = WMAC_STATE_AUTH;
-                       }
-                       s_vMgrLogStatus(pMgmt, cpu_to_le16((*(sFrame.pwStatus))));
-               }
-
-       }
-
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-//need clear flags related to Networkmanager
-
-       pDevice->bwextcount = 0;
-       pDevice->bWPASuppWextEnabled = false;
-#endif
-
-       if (pMgmt->eCurrState == WMAC_STATE_ASSOC)
-               timer_expire(pDevice->sTimerCommand, 0);
-}
-
-/*+
- *
- * Routine Description:
- *    Start the station authentication procedure.  Namely, send an
- *    authentication frame to the AP.
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrAuthenBeginSta(
-       void *hDeviceContext,
-       PSMgmtObject  pMgmt,
-       PCMD_STATUS pStatus
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       WLAN_FR_AUTHEN  sFrame;
-       PSTxMgmtPacket  pTxPacket = NULL;
-
-       pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-       memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN);
-       pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket));
-       sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header;
-       sFrame.len = WLAN_AUTHEN_FR_MAXLEN;
-       vMgrEncodeAuthen(&sFrame);
-       /* insert values */
-       sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
-               (
-                       WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
-                       WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN)
-));
-       memcpy(sFrame.pHdr->sA3.abyAddr1, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
-       if (pMgmt->bShareKeyAlgorithm)
-               *(sFrame.pwAuthAlgorithm) = cpu_to_le16(WLAN_AUTH_ALG_SHAREDKEY);
-       else
-               *(sFrame.pwAuthAlgorithm) = cpu_to_le16(WLAN_AUTH_ALG_OPENSYSTEM);
-
-       *(sFrame.pwAuthSequence) = cpu_to_le16(1);
-       /* Adjust the length fields */
-       pTxPacket->cbMPDULen = sFrame.len;
-       pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
-
-       *pStatus = csMgmt_xmit(pDevice, pTxPacket);
-       if (*pStatus == CMD_STATUS_PENDING) {
-               pMgmt->eCurrState = WMAC_STATE_AUTHPENDING;
-               *pStatus = CMD_STATUS_SUCCESS;
-       }
-}
-
-/*+
- *
- * Routine Description:
- *    Start the station(AP) deauthentication procedure.  Namely, send an
- *    deauthentication frame to the AP or Sta.
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrDeAuthenBeginSta(
-       void *hDeviceContext,
-       PSMgmtObject  pMgmt,
-       unsigned char *abyDestAddress,
-       unsigned short wReason,
-       PCMD_STATUS pStatus
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       WLAN_FR_DEAUTHEN    sFrame;
-       PSTxMgmtPacket      pTxPacket = NULL;
-
-       pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-       memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_DEAUTHEN_FR_MAXLEN);
-       pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket));
-       sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header;
-       sFrame.len = WLAN_DEAUTHEN_FR_MAXLEN;
-       vMgrEncodeDeauthen(&sFrame);
-       /* insert values */
-       sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
-               (
-                       WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
-                       WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DEAUTHEN)
-));
-
-       memcpy(sFrame.pHdr->sA3.abyAddr1, abyDestAddress, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
-
-       *(sFrame.pwReason) = cpu_to_le16(wReason);       // deauthen. bcs left BSS
-       /* Adjust the length fields */
-       pTxPacket->cbMPDULen = sFrame.len;
-       pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
-
-       *pStatus = csMgmt_xmit(pDevice, pTxPacket);
-       if (*pStatus == CMD_STATUS_PENDING)
-               *pStatus = CMD_STATUS_SUCCESS;
-}
-
-/*+
- *
- * Routine Description:
- *    Handle incoming authentication frames.
- *
- * Return Value:
- *    None.
- *
- -*/
-
-static
-void
-s_vMgrRxAuthentication(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket
-)
-{
-       WLAN_FR_AUTHEN  sFrame;
-
-       // we better be an AP or a STA in AUTHPENDING otherwise ignore
-       if (!(pMgmt->eCurrMode == WMAC_MODE_ESS_AP ||
-             pMgmt->eCurrState == WMAC_STATE_AUTHPENDING)) {
-               return;
-       }
-
-       // decode the frame
-       sFrame.len = pRxPacket->cbMPDULen;
-       sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header;
-       vMgrDecodeAuthen(&sFrame);
-       switch (cpu_to_le16((*(sFrame.pwAuthSequence)))) {
-       case 1:
-               //AP function
-               s_vMgrRxAuthenSequence_1(pDevice, pMgmt, &sFrame);
-               break;
-       case 2:
-               s_vMgrRxAuthenSequence_2(pDevice, pMgmt, &sFrame);
-               break;
-       case 3:
-               //AP function
-               s_vMgrRxAuthenSequence_3(pDevice, pMgmt, &sFrame);
-               break;
-       case 4:
-               s_vMgrRxAuthenSequence_4(pDevice, pMgmt, &sFrame);
-               break;
-       default:
-               pr_debug("Auth Sequence error, seq = %d\n",
-                        cpu_to_le16((*(sFrame.pwAuthSequence))));
-               break;
-       }
-}
-
-/*+
- *
- * Routine Description:
- *   Handles incoming authen frames with sequence 1.  Currently
- *   assumes we're an AP.  So far, no one appears to use authentication
- *   in Ad-Hoc mode.
- *
- * Return Value:
- *    None.
- *
- -*/
-
-static
-void
-s_vMgrRxAuthenSequence_1(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PWLAN_FR_AUTHEN pFrame
-)
-{
-       PSTxMgmtPacket      pTxPacket = NULL;
-       unsigned int    uNodeIndex;
-       WLAN_FR_AUTHEN      sFrame;
-       PSKeyItem           pTransmitKey;
-
-       // Insert a Node entry
-       if (!BSSDBbIsSTAInNodeDB(pMgmt, pFrame->pHdr->sA3.abyAddr2, &uNodeIndex)) {
-               BSSvCreateOneNode(pDevice, &uNodeIndex);
-               memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, pFrame->pHdr->sA3.abyAddr2,
-                      WLAN_ADDR_LEN);
-       }
-
-       if (pMgmt->bShareKeyAlgorithm) {
-               pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_KNOWN;
-               pMgmt->sNodeDBTable[uNodeIndex].byAuthSequence = 1;
-       } else {
-               pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_AUTH;
-       }
-
-       // send auth reply
-       pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-       memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN);
-       pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket));
-       sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header;
-       sFrame.len = WLAN_AUTHEN_FR_MAXLEN;
-       // format buffer structure
-       vMgrEncodeAuthen(&sFrame);
-       // insert values
-       sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
-               (
-                       WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
-                       WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN)|
-                       WLAN_SET_FC_ISWEP(0)
-));
-       memcpy(sFrame.pHdr->sA3.abyAddr1, pFrame->pHdr->sA3.abyAddr2, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
-       *(sFrame.pwAuthAlgorithm) = *(pFrame->pwAuthAlgorithm);
-       *(sFrame.pwAuthSequence) = cpu_to_le16(2);
-
-       if (cpu_to_le16(*(pFrame->pwAuthAlgorithm)) == WLAN_AUTH_ALG_SHAREDKEY) {
-               if (pMgmt->bShareKeyAlgorithm)
-                       *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS);
-               else
-                       *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG);
-       } else {
-               if (pMgmt->bShareKeyAlgorithm)
-                       *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG);
-               else
-                       *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS);
-       }
-
-       if (pMgmt->bShareKeyAlgorithm &&
-           (cpu_to_le16(*(sFrame.pwStatus)) == WLAN_MGMT_STATUS_SUCCESS)) {
-               sFrame.pChallenge = (PWLAN_IE_CHALLENGE)(sFrame.pBuf + sFrame.len);
-               sFrame.len += WLAN_CHALLENGE_IE_LEN;
-               sFrame.pChallenge->byElementID = WLAN_EID_CHALLENGE;
-               sFrame.pChallenge->len = WLAN_CHALLENGE_LEN;
-               memset(pMgmt->abyChallenge, 0, WLAN_CHALLENGE_LEN);
-               // get group key
-               if (KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, GROUP_KEY, &pTransmitKey) == true) {
-                       rc4_init(&pDevice->SBox, pDevice->abyPRNG, pTransmitKey->uKeyLength+3);
-                       rc4_encrypt(&pDevice->SBox, pMgmt->abyChallenge, pMgmt->abyChallenge, WLAN_CHALLENGE_LEN);
-               }
-               memcpy(sFrame.pChallenge->abyChallenge, pMgmt->abyChallenge , WLAN_CHALLENGE_LEN);
-       }
-
-       /* Adjust the length fields */
-       pTxPacket->cbMPDULen = sFrame.len;
-       pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
-       // send the frame
-       if (pDevice->bEnableHostapd)
-               return;
-
-       pr_debug("Mgt:Authreq_reply sequence_1 tx..\n");
-       if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING)
-               pr_debug("Mgt:Authreq_reply sequence_1 tx failed\n");
-}
-
-/*+
- *
- * Routine Description:
- *   Handles incoming auth frames with sequence number 2.  Currently
- *   assumes we're a station.
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-static
-void
-s_vMgrRxAuthenSequence_2(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PWLAN_FR_AUTHEN pFrame
-)
-{
-       WLAN_FR_AUTHEN      sFrame;
-       PSTxMgmtPacket      pTxPacket = NULL;
-
-       switch (cpu_to_le16((*(pFrame->pwAuthAlgorithm)))) {
-       case WLAN_AUTH_ALG_OPENSYSTEM:
-               if (cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS) {
-                       pr_info("802.11 Authen (OPEN) Successful\n");
-                       pMgmt->eCurrState = WMAC_STATE_AUTH;
-                       timer_expire(pDevice->sTimerCommand, 0);
-               } else {
-                       pr_info("802.11 Authen (OPEN) Failed\n");
-                       s_vMgrLogStatus(pMgmt, cpu_to_le16((*(pFrame->pwStatus))));
-                       pMgmt->eCurrState = WMAC_STATE_IDLE;
-               }
-
-               break;
-
-       case WLAN_AUTH_ALG_SHAREDKEY:
-
-               if (cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS) {
-                       pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-                       memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN);
-                       pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket));
-                       sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header;
-                       sFrame.len = WLAN_AUTHEN_FR_MAXLEN;
-                       // format buffer structure
-                       vMgrEncodeAuthen(&sFrame);
-                       // insert values
-                       sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
-                               (
-                                       WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
-                                       WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN)|
-                                       WLAN_SET_FC_ISWEP(1)
-));
-                       memcpy(sFrame.pHdr->sA3.abyAddr1, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
-                       memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
-                       memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
-                       *(sFrame.pwAuthAlgorithm) = *(pFrame->pwAuthAlgorithm);
-                       *(sFrame.pwAuthSequence) = cpu_to_le16(3);
-                       *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS);
-                       sFrame.pChallenge = (PWLAN_IE_CHALLENGE)(sFrame.pBuf + sFrame.len);
-                       sFrame.len += WLAN_CHALLENGE_IE_LEN;
-                       sFrame.pChallenge->byElementID = WLAN_EID_CHALLENGE;
-                       sFrame.pChallenge->len = WLAN_CHALLENGE_LEN;
-                       memcpy(sFrame.pChallenge->abyChallenge, pFrame->pChallenge->abyChallenge, WLAN_CHALLENGE_LEN);
-                       // Adjust the length fields
-                       pTxPacket->cbMPDULen = sFrame.len;
-                       pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
-                       // send the frame
-                       if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING)
-                               pr_debug("Mgt:Auth_reply sequence_2 tx failed\n");
-
-                       pr_debug("Mgt:Auth_reply sequence_2 tx ...\n");
-               } else {
-                       pr_debug("Mgt:rx Auth_reply sequence_2 status error ...\n");
-                       s_vMgrLogStatus(pMgmt, cpu_to_le16((*(pFrame->pwStatus))));
-               }
-               break;
-       default:
-               pr_debug("Mgt: rx auth.seq = 2 unknown AuthAlgorithm=%d\n",
-                        cpu_to_le16((*(pFrame->pwAuthAlgorithm))));
-               break;
-       }
-}
-
-/*+
- *
- * Routine Description:
- *   Handles incoming authen frames with sequence 3.  Currently
- *   assumes we're an AP.  This function assumes the frame has
- *   already been successfully decrypted.
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-static
-void
-s_vMgrRxAuthenSequence_3(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PWLAN_FR_AUTHEN pFrame
-)
-{
-       PSTxMgmtPacket      pTxPacket = NULL;
-       unsigned int uStatusCode = 0;
-       unsigned int uNodeIndex = 0;
-       WLAN_FR_AUTHEN      sFrame;
-
-       if (!WLAN_GET_FC_ISWEP(pFrame->pHdr->sA3.wFrameCtl)) {
-               uStatusCode = WLAN_MGMT_STATUS_CHALLENGE_FAIL;
-               goto reply;
-       }
-       if (BSSDBbIsSTAInNodeDB(pMgmt, pFrame->pHdr->sA3.abyAddr2, &uNodeIndex)) {
-               if (pMgmt->sNodeDBTable[uNodeIndex].byAuthSequence != 1) {
-                       uStatusCode = WLAN_MGMT_STATUS_RX_AUTH_NOSEQ;
-                       goto reply;
-               }
-               if (memcmp(pMgmt->abyChallenge, pFrame->pChallenge->abyChallenge, WLAN_CHALLENGE_LEN) != 0) {
-                       uStatusCode = WLAN_MGMT_STATUS_CHALLENGE_FAIL;
-                       goto reply;
-               }
-       } else {
-               uStatusCode = WLAN_MGMT_STATUS_UNSPEC_FAILURE;
-               goto reply;
-       }
-
-       if (uNodeIndex) {
-               pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_AUTH;
-               pMgmt->sNodeDBTable[uNodeIndex].byAuthSequence = 0;
-       }
-       uStatusCode = WLAN_MGMT_STATUS_SUCCESS;
-       pr_debug("Challenge text check ok..\n");
-
-reply:
-       // send auth reply
-       pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-       memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN);
-       pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket));
-       sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header;
-       sFrame.len = WLAN_AUTHEN_FR_MAXLEN;
-       // format buffer structure
-       vMgrEncodeAuthen(&sFrame);
-       /* insert values */
-       sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
-               (
-                       WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
-                       WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN)|
-                       WLAN_SET_FC_ISWEP(0)
-));
-       memcpy(sFrame.pHdr->sA3.abyAddr1, pFrame->pHdr->sA3.abyAddr2, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
-       *(sFrame.pwAuthAlgorithm) = *(pFrame->pwAuthAlgorithm);
-       *(sFrame.pwAuthSequence) = cpu_to_le16(4);
-       *(sFrame.pwStatus) = cpu_to_le16(uStatusCode);
-
-       /* Adjust the length fields */
-       pTxPacket->cbMPDULen = sFrame.len;
-       pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
-       // send the frame
-       if (pDevice->bEnableHostapd)
-               return;
-
-       if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING)
-               pr_debug("Mgt:Authreq_reply sequence_4 tx failed\n");
-}
-
-/*+
- *
- * Routine Description:
- *   Handles incoming authen frames with sequence 4
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-static
-void
-s_vMgrRxAuthenSequence_4(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PWLAN_FR_AUTHEN pFrame
-)
-{
-       if (cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS) {
-               pr_info("802.11 Authen (SHAREDKEY) Successful\n");
-               pMgmt->eCurrState = WMAC_STATE_AUTH;
-               timer_expire(pDevice->sTimerCommand, 0);
-       } else{
-               pr_info("802.11 Authen (SHAREDKEY) Failed\n");
-               s_vMgrLogStatus(pMgmt, cpu_to_le16((*(pFrame->pwStatus))));
-               pMgmt->eCurrState = WMAC_STATE_IDLE;
-       }
-}
-
-/*+
- *
- * Routine Description:
- *   Handles incoming disassociation frames
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-static
-void
-s_vMgrRxDisassociation(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket
-)
-{
-       WLAN_FR_DISASSOC    sFrame;
-       unsigned int uNodeIndex = 0;
-       viawget_wpa_header *wpahdr;
-
-       if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
-               // if is acting an AP..
-               // a STA is leaving this BSS..
-               sFrame.len = pRxPacket->cbMPDULen;
-               sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header;
-               if (BSSDBbIsSTAInNodeDB(pMgmt, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex))
-                       BSSvRemoveOneNode(pDevice, uNodeIndex);
-               else
-                       pr_debug("Rx disassoc, sta not found\n");
-
-       } else if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) {
-               sFrame.len = pRxPacket->cbMPDULen;
-               sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header;
-               vMgrDecodeDisassociation(&sFrame);
-               pr_info("AP disassociated me, reason=%d\n",
-                       cpu_to_le16(*(sFrame.pwReason)));
-               //TODO: do something let upper layer know or
-               //try to send associate packet again because of inactivity timeout
-               if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
-                       wpahdr = (viawget_wpa_header *)pDevice->skb->data;
-                       wpahdr->type = VIAWGET_DISASSOC_MSG;
-                       wpahdr->resp_ie_len = 0;
-                       wpahdr->req_ie_len = 0;
-                       skb_put(pDevice->skb, sizeof(viawget_wpa_header));
-                       pDevice->skb->dev = pDevice->wpadev;
-                       skb_reset_mac_header(pDevice->skb);
-
-                       pDevice->skb->pkt_type = PACKET_HOST;
-                       pDevice->skb->protocol = htons(ETH_P_802_2);
-                       memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
-                       netif_rx(pDevice->skb);
-                       pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
-               }
-
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-               {
-                       union iwreq_data  wrqu;
-
-                       memset(&wrqu, 0, sizeof(wrqu));
-                       wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-                       pr_debug("wireless_send_event--->SIOCGIWAP(disassociated)\n");
-                       wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
-               }
-#endif
-       }
-       /* else, ignore it */
-}
-
-/*+
- *
- * Routine Description:
- *   Handles incoming deauthentication frames
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-static
-void
-s_vMgrRxDeauthentication(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket
-)
-{
-       WLAN_FR_DEAUTHEN    sFrame;
-       unsigned int uNodeIndex = 0;
-       viawget_wpa_header *wpahdr;
-
-       if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
-               //Todo:
-               // if is acting an AP..
-               // a STA is leaving this BSS..
-               sFrame.len = pRxPacket->cbMPDULen;
-               sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header;
-               if (BSSDBbIsSTAInNodeDB(pMgmt, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex))
-                       BSSvRemoveOneNode(pDevice, uNodeIndex);
-               else
-                       pr_info("Rx deauth, sta not found\n");
-       } else {
-               if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) {
-                       sFrame.len = pRxPacket->cbMPDULen;
-                       sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header;
-                       vMgrDecodeDeauthen(&sFrame);
-                       pr_info("AP deauthed me, reason=%d\n",
-                               cpu_to_le16((*(sFrame.pwReason))));
-                       // TODO: update BSS list for specific BSSID if pre-authentication case
-                       if (ether_addr_equal(sFrame.pHdr->sA3.abyAddr3,
-                                            pMgmt->abyCurrBSSID)) {
-                               if (pMgmt->eCurrState >= WMAC_STATE_AUTHPENDING) {
-                                       pMgmt->sNodeDBTable[0].bActive = false;
-                                       pMgmt->eCurrMode = WMAC_MODE_STANDBY;
-                                       pMgmt->eCurrState = WMAC_STATE_IDLE;
-                                       netif_stop_queue(pDevice->dev);
-                                       pDevice->bLinkPass = false;
-                               }
-                       }
-
-                       if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
-                               wpahdr = (viawget_wpa_header *)pDevice->skb->data;
-                               wpahdr->type = VIAWGET_DISASSOC_MSG;
-                               wpahdr->resp_ie_len = 0;
-                               wpahdr->req_ie_len = 0;
-                               skb_put(pDevice->skb, sizeof(viawget_wpa_header));
-                               pDevice->skb->dev = pDevice->wpadev;
-                               skb_reset_mac_header(pDevice->skb);
-                               pDevice->skb->pkt_type = PACKET_HOST;
-                               pDevice->skb->protocol = htons(ETH_P_802_2);
-                               memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
-                               netif_rx(pDevice->skb);
-                               pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
-                       }
-
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-                       {
-                               union iwreq_data  wrqu;
-
-                               memset(&wrqu, 0, sizeof(wrqu));
-                               wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-                               PRINT_K("wireless_send_event--->SIOCGIWAP(disauthen)\n");
-                               wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
-                       }
-#endif
-
-               }
-               /* else, ignore it.  TODO: IBSS authentication service
-                  would be implemented here */
-       }
-}
-
-//2008-8-4 <add> by chester
-/*+
- *
- * Routine Description:
- * check if current channel is match ZoneType.
- *for USA:1~11;
- *      Japan:1~13;
- *      Europe:1~13
- * Return Value:
- *               True:exceed;
- *                False:normal case
- -*/
-static bool
-ChannelExceedZoneType(
-       struct vnt_private *pDevice,
-       unsigned char byCurrChannel
-)
-{
-       bool exceed = false;
-
-       switch (pDevice->byZoneType) {
-       case 0x00:                  //USA:1~11
-               if ((byCurrChannel < 1) || (byCurrChannel > 11))
-                       exceed = true;
-               break;
-       case 0x01:                  //Japan:1~13
-       case 0x02:                  //Europe:1~13
-               if ((byCurrChannel < 1) || (byCurrChannel > 13))
-                       exceed = true;
-               break;
-       default:                    //reserve for other zonetype
-               break;
-       }
-
-       return exceed;
-}
-
-/*+
- *
- * Routine Description:
- *   Handles and analysis incoming beacon frames.
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-static
-void
-s_vMgrRxBeacon(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket,
-       bool bInScan
-)
-{
-       PKnownBSS           pBSSList;
-       WLAN_FR_BEACON      sFrame;
-       u64 qwTSFOffset;
-       bool bIsBSSIDEqual = false;
-       bool bIsSSIDEqual = false;
-       bool bTSFLargeDiff = false;
-       bool bTSFOffsetPostive = false;
-       bool bUpdateTSF = false;
-       bool bIsAPBeacon = false;
-       bool bIsChannelEqual = false;
-       unsigned int uLocateByteIndex;
-       unsigned char byTIMBitOn = 0;
-       unsigned short wAIDNumber = 0;
-       unsigned int uNodeIndex;
-       u64 qwTimestamp, qwLocalTSF;
-       u64 qwCurrTSF;
-       unsigned short wStartIndex = 0;
-       unsigned short wAIDIndex = 0;
-       unsigned char byCurrChannel = pRxPacket->byRxChannel;
-       ERPObject           sERP;
-       unsigned int uRateLen = WLAN_RATES_MAXLEN;
-       bool bChannelHit = false;
-       bool bUpdatePhyParameter = false;
-       unsigned char byIEChannel = 0;
-
-       memset(&sFrame, 0, sizeof(WLAN_FR_BEACON));
-       sFrame.len = pRxPacket->cbMPDULen;
-       sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header;
-
-       // decode the beacon frame
-       vMgrDecodeBeacon(&sFrame);
-
-       if ((sFrame.pwBeaconInterval == NULL) ||
-           (sFrame.pwCapInfo == NULL) ||
-           (sFrame.pSSID == NULL) ||
-           (sFrame.pSuppRates == NULL)) {
-               pr_debug("Rx beacon frame error\n");
-               return;
-       }
-
-       if (sFrame.pDSParms != NULL) {
-               if (byCurrChannel > CB_MAX_CHANNEL_24G) {
-                       // channel remapping to
-                       byIEChannel = get_channel_mapping(pDevice, sFrame.pDSParms->byCurrChannel, PHY_TYPE_11A);
-               } else {
-                       byIEChannel = sFrame.pDSParms->byCurrChannel;
-               }
-               if (byCurrChannel != byIEChannel) {
-                       // adjust channel info. bcs we rcv adjacent channel packets
-                       bChannelHit = false;
-                       byCurrChannel = byIEChannel;
-               }
-       } else {
-               // no DS channel info
-               bChannelHit = true;
-       }
-//2008-0730-01<Add>by MikeLiu
-       if (ChannelExceedZoneType(pDevice, byCurrChannel))
-               return;
-
-       if (sFrame.pERP != NULL) {
-               sERP.byERP = sFrame.pERP->byContext;
-               sERP.bERPExist = true;
-
-       } else {
-               sERP.bERPExist = false;
-               sERP.byERP = 0;
-       }
-
-       pBSSList = BSSpAddrIsInBSSList((void *)pDevice, sFrame.pHdr->sA3.abyAddr3, sFrame.pSSID);
-       if (pBSSList == NULL) {
-               pr_debug("Beacon/insert: RxChannel = : %d\n", byCurrChannel);
-               BSSbInsertToBSSList((void *)pDevice,
-                                   sFrame.pHdr->sA3.abyAddr3,
-                                   *sFrame.pqwTimestamp,
-                                   *sFrame.pwBeaconInterval,
-                                   *sFrame.pwCapInfo,
-                                   byCurrChannel,
-                                   sFrame.pSSID,
-                                   sFrame.pSuppRates,
-                                   sFrame.pExtSuppRates,
-                                   &sERP,
-                                   sFrame.pRSN,
-                                   sFrame.pRSNWPA,
-                                   sFrame.pIE_Country,
-                                   sFrame.pIE_Quiet,
-                                   sFrame.len - WLAN_HDR_ADDR3_LEN,
-                                   sFrame.pHdr->sA4.abyAddr4,   // payload of beacon
-                                   (void *)pRxPacket
-);
-       } else {
-               BSSbUpdateToBSSList((void *)pDevice,
-                                   *sFrame.pqwTimestamp,
-                                   *sFrame.pwBeaconInterval,
-                                   *sFrame.pwCapInfo,
-                                   byCurrChannel,
-                                   bChannelHit,
-                                   sFrame.pSSID,
-                                   sFrame.pSuppRates,
-                                   sFrame.pExtSuppRates,
-                                   &sERP,
-                                   sFrame.pRSN,
-                                   sFrame.pRSNWPA,
-                                   sFrame.pIE_Country,
-                                   sFrame.pIE_Quiet,
-                                   pBSSList,
-                                   sFrame.len - WLAN_HDR_ADDR3_LEN,
-                                   sFrame.pHdr->sA4.abyAddr4,   // payload of probresponse
-                                   (void *)pRxPacket
-);
-
-       }
-
-       if (bInScan)
-               return;
-
-       if (byCurrChannel == (unsigned char)pMgmt->uCurrChannel)
-               bIsChannelEqual = true;
-
-       if (bIsChannelEqual && (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
-               // if rx beacon without ERP field
-               if (sERP.bERPExist) {
-                       if (WLAN_GET_ERP_USE_PROTECTION(sERP.byERP)) {
-                               pDevice->byERPFlag |= WLAN_SET_ERP_USE_PROTECTION(1);
-                               pDevice->wUseProtectCntDown = USE_PROTECT_PERIOD;
-                       }
-               } else {
-                       pDevice->byERPFlag |= WLAN_SET_ERP_USE_PROTECTION(1);
-                       pDevice->wUseProtectCntDown = USE_PROTECT_PERIOD;
-               }
-
-               if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
-                       if (!WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo))
-                               pDevice->byERPFlag |= WLAN_SET_ERP_BARKER_MODE(1);
-                       if (!sERP.bERPExist)
-                               pDevice->byERPFlag |= WLAN_SET_ERP_NONERP_PRESENT(1);
-               }
-
-               // set to MAC&BBP
-               if (WLAN_GET_ERP_USE_PROTECTION(pDevice->byERPFlag)) {
-                       if (!pDevice->bProtectMode) {
-                               MACvEnableProtectMD(pDevice->PortOffset);
-                               pDevice->bProtectMode = true;
-                       }
-               }
-       }
-
-       if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)
-               return;
-
-       // check if BSSID the same
-       if (memcmp(sFrame.pHdr->sA3.abyAddr3,
-                  pMgmt->abyCurrBSSID,
-                  WLAN_BSSID_LEN) == 0) {
-               bIsBSSIDEqual = true;
-
-// 2008-05-21 <add> by Richardtai
-               pDevice->uCurrRSSI = pRxPacket->uRSSI;
-               pDevice->byCurrSQ = pRxPacket->bySQ;
-
-               if (pMgmt->sNodeDBTable[0].uInActiveCount != 0)
-                       pMgmt->sNodeDBTable[0].uInActiveCount = 0;
-       }
-       // check if SSID the same
-       if (sFrame.pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) {
-               if (memcmp(sFrame.pSSID->abySSID,
-                          ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID,
-                          sFrame.pSSID->len
-) == 0) {
-                       bIsSSIDEqual = true;
-               }
-       }
-
-       if (WLAN_GET_CAP_INFO_ESS(*sFrame.pwCapInfo) &&
-           bIsBSSIDEqual &&
-           bIsSSIDEqual &&
-           (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
-           (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
-               // add state check to prevent reconnect fail since we'll receive Beacon
-
-               bIsAPBeacon = true;
-
-               if (pBSSList != NULL) {
-                       // Compare PHY parameter setting
-                       if (pMgmt->wCurrCapInfo != pBSSList->wCapInfo) {
-                               bUpdatePhyParameter = true;
-                               pMgmt->wCurrCapInfo = pBSSList->wCapInfo;
-                       }
-                       if (sFrame.pERP != NULL) {
-                               if ((sFrame.pERP->byElementID == WLAN_EID_ERP) &&
-                                   (pMgmt->byERPContext != sFrame.pERP->byContext)) {
-                                       bUpdatePhyParameter = true;
-                                       pMgmt->byERPContext = sFrame.pERP->byContext;
-                               }
-                       }
-                       //
-                       // Basic Rate Set may change dynamically
-                       //
-                       if (pBSSList->eNetworkTypeInUse == PHY_TYPE_11B)
-                               uRateLen = WLAN_RATES_MAXLEN_11B;
-
-                       pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pBSSList->abySuppRates,
-                                                               (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                                                               uRateLen);
-                       pMgmt->abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pBSSList->abyExtSuppRates,
-                                                                  (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
-                                                                  uRateLen);
-                       RATEvParseMaxRate((void *)pDevice,
-                                         (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                                         (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
-                                         true,
-                                         &(pMgmt->sNodeDBTable[0].wMaxBasicRate),
-                                         &(pMgmt->sNodeDBTable[0].wMaxSuppRate),
-                                         &(pMgmt->sNodeDBTable[0].wSuppRate),
-                                         &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate),
-                                         &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate)
-                               );
-                       if (bUpdatePhyParameter) {
-                               CARDbSetPhyParameter(pMgmt->pAdapter,
-                                                    pMgmt->eCurrentPHYMode,
-                                                    pMgmt->wCurrCapInfo,
-                                                    pMgmt->byERPContext,
-                                                    pMgmt->abyCurrSuppRates,
-                                                    pMgmt->abyCurrExtSuppRates
-                                       );
-                       }
-                       if (sFrame.pIE_PowerConstraint != NULL) {
-                               CARDvSetPowerConstraint(pMgmt->pAdapter,
-                                                       (unsigned char) pBSSList->uChannel,
-                                                       sFrame.pIE_PowerConstraint->byPower
-);
-                       }
-                       if (sFrame.pIE_CHSW != NULL) {
-                               CARDbChannelSwitch(pMgmt->pAdapter,
-                                                  sFrame.pIE_CHSW->byMode,
-                                                  get_channel_mapping(pMgmt->pAdapter, sFrame.pIE_CHSW->byMode, pMgmt->eCurrentPHYMode),
-                                                  sFrame.pIE_CHSW->byCount
-                                       );
-
-                       } else if (!bIsChannelEqual) {
-                               set_channel(pMgmt->pAdapter, pBSSList->uChannel);
-                       }
-               }
-       }
-
-//    pr_debug("Beacon 2\n");
-       // check if CF field exists
-       if (WLAN_GET_CAP_INFO_ESS(*sFrame.pwCapInfo)) {
-               if (sFrame.pCFParms->wCFPDurRemaining > 0) {
-                       // TODO: deal with CFP period to set NAV
-               }
-       }
-
-       qwTimestamp = le64_to_cpu(*sFrame.pqwTimestamp);
-       qwLocalTSF = pRxPacket->qwLocalTSF;
-
-       // check if beacon TSF larger or small than our local TSF
-       if (qwTimestamp >= qwLocalTSF)
-               bTSFOffsetPostive = true;
-       else
-               bTSFOffsetPostive = false;
-
-       if (bTSFOffsetPostive)
-               qwTSFOffset = CARDqGetTSFOffset(pRxPacket->byRxRate, (qwTimestamp), (qwLocalTSF));
-       else
-               qwTSFOffset = CARDqGetTSFOffset(pRxPacket->byRxRate, (qwLocalTSF), (qwTimestamp));
-
-       if (qwTSFOffset > TRIVIAL_SYNC_DIFFERENCE)
-               bTSFLargeDiff = true;
-
-       // if infra mode
-       if (bIsAPBeacon) {
-               // Infra mode: Local TSF always follow AP's TSF if Difference huge.
-               if (bTSFLargeDiff)
-                       bUpdateTSF = true;
-
-               if (pDevice->bEnablePSMode && (sFrame.pTIM != NULL)) {
-                       // deal with DTIM, analysis TIM
-                       pMgmt->bMulticastTIM = WLAN_MGMT_IS_MULTICAST_TIM(sFrame.pTIM->byBitMapCtl) ? true : false;
-                       pMgmt->byDTIMCount = sFrame.pTIM->byDTIMCount;
-                       pMgmt->byDTIMPeriod = sFrame.pTIM->byDTIMPeriod;
-                       wAIDNumber = pMgmt->wCurrAID & ~(BIT14|BIT15);
-
-                       // check if AID in TIM field bit on
-                       // wStartIndex = N1
-                       wStartIndex = WLAN_MGMT_GET_TIM_OFFSET(sFrame.pTIM->byBitMapCtl) << 1;
-                       // AIDIndex = N2
-                       wAIDIndex = (wAIDNumber >> 3);
-                       if ((wAIDNumber > 0) && (wAIDIndex >= wStartIndex)) {
-                               uLocateByteIndex = wAIDIndex - wStartIndex;
-                               // len = byDTIMCount + byDTIMPeriod + byDTIMPeriod + byVirtBitMap[0~250]
-                               if (sFrame.pTIM->len >= (uLocateByteIndex + 4)) {
-                                       byTIMBitOn  = (0x01) << ((wAIDNumber) % 8);
-                                       pMgmt->bInTIM = sFrame.pTIM->byVirtBitMap[uLocateByteIndex] & byTIMBitOn ? true : false;
-                               } else {
-                                       pMgmt->bInTIM = false;
-                               }
-                       } else {
-                               pMgmt->bInTIM = false;
-                       }
-
-                       if (pMgmt->bInTIM ||
-                           (pMgmt->bMulticastTIM && (pMgmt->byDTIMCount == 0))) {
-                               pMgmt->bInTIMWake = true;
-                               // send out ps-poll packet
-
-                               if (pMgmt->bInTIM)
-                                       PSvSendPSPOLL(pDevice);
-
-                       } else {
-                               pMgmt->bInTIMWake = false;
-                               pr_debug("BCN: Not In TIM..\n");
-                               if (!pDevice->bPWBitOn) {
-                                       pr_debug("BCN: Send Null Packet\n");
-                                       if (PSbSendNullPacket(pDevice))
-                                               pDevice->bPWBitOn = true;
-                               }
-                               if (PSbConsiderPowerDown(pDevice, false, false))
-                                       pr_debug("BCN: Power down now...\n");
-                       }
-
-               }
-
-       }
-       // if adhoc mode
-       if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && !bIsAPBeacon && bIsChannelEqual) {
-               if (bIsBSSIDEqual) {
-                       // Use sNodeDBTable[0].uInActiveCount as IBSS beacons received count.
-                       if (pMgmt->sNodeDBTable[0].uInActiveCount != 0)
-                               pMgmt->sNodeDBTable[0].uInActiveCount = 0;
-
-                       // adhoc mode:TSF updated only when beacon larger than local TSF
-                       if (bTSFLargeDiff && bTSFOffsetPostive &&
-                           (pMgmt->eCurrState == WMAC_STATE_JOINTED))
-                               bUpdateTSF = true;
-
-                       // During dpc, already in spinlocked.
-                       if (BSSDBbIsSTAInNodeDB(pMgmt, sFrame.pHdr->sA3.abyAddr2, &uNodeIndex)) {
-                               // Update the STA, (Technically the Beacons of all the IBSS nodes
-                               // should be identical, but that's not happening in practice.
-                               pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates,
-                                                                       (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                                                                       WLAN_RATES_MAXLEN_11B);
-                               RATEvParseMaxRate((void *)pDevice,
-                                                 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                                                 NULL,
-                                                 true,
-                                                 &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate),
-                                                 &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate),
-                                                 &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate),
-                                                 &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate),
-                                                 &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate)
-                                       );
-                               pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble = WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo);
-                               pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo);
-                               pMgmt->sNodeDBTable[uNodeIndex].uInActiveCount = 0;
-                       } else {
-                               // Todo, initial Node content
-                               BSSvCreateOneNode(pDevice, &uNodeIndex);
-
-                               pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates,
-                                                                       (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                                                                       WLAN_RATES_MAXLEN_11B);
-                               RATEvParseMaxRate((void *)pDevice,
-                                                 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                                                 NULL,
-                                                 true,
-                                                 &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate),
-                                                 &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate),
-                                                 &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate),
-                                                 &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate),
-                                                 &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate)
-                                       );
-
-                               memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, sFrame.pHdr->sA3.abyAddr2, WLAN_ADDR_LEN);
-                               pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble = WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo);
-                               pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate = pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate;
-                               {
-                                       pr_debug("s_vMgrRxBeacon:TxDataRate is %d,Index is %d\n", pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate, uNodeIndex);
-                               }
-                       }
-
-                       // if other stations joined, indicate connection to upper layer..
-                       if (pMgmt->eCurrState == WMAC_STATE_STARTED) {
-                               pr_debug("Current IBSS State: [Started]........to: [Jointed]\n");
-                               pMgmt->eCurrState = WMAC_STATE_JOINTED;
-                               pDevice->bLinkPass = true;
-                               if (netif_queue_stopped(pDevice->dev))
-                                       netif_wake_queue(pDevice->dev);
-
-                               pMgmt->sNodeDBTable[0].bActive = true;
-                               pMgmt->sNodeDBTable[0].uInActiveCount = 0;
-
-                       }
-               } else if (bIsSSIDEqual) {
-                       // See other adhoc sta with the same SSID but BSSID is different.
-                       // adpot this vars only when TSF larger then us.
-                       if (bTSFLargeDiff && bTSFOffsetPostive) {
-                               // we don't support ATIM under adhoc mode
-                               // if (sFrame.pIBSSParms->wATIMWindow == 0) {
-                               // adpot this vars
-                               // TODO: check sFrame cap if privacy on, and support rate syn
-                               memcpy(pMgmt->abyCurrBSSID, sFrame.pHdr->sA3.abyAddr3, WLAN_BSSID_LEN);
-                               memcpy(pDevice->abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
-                               pMgmt->wCurrATIMWindow = cpu_to_le16(sFrame.pIBSSParms->wATIMWindow);
-                               pMgmt->wCurrBeaconPeriod = cpu_to_le16(*sFrame.pwBeaconInterval);
-                               pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates,
-                                                                       (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                                                                       WLAN_RATES_MAXLEN_11B);
-                               // set HW beacon interval and re-synchronizing....
-                               pr_debug("Rejoining to Other Adhoc group with same SSID........\n");
-                               VNSvOutPortW(pDevice->PortOffset + MAC_REG_BI, pMgmt->wCurrBeaconPeriod);
-                               CARDbUpdateTSF(pDevice, pRxPacket->byRxRate, qwTimestamp, qwLocalTSF);
-                               CARDvUpdateNextTBTT(pDevice->PortOffset, qwTimestamp, pMgmt->wCurrBeaconPeriod);
-                               // Turn off bssid filter to avoid filter others adhoc station which bssid is different.
-                               MACvWriteBSSIDAddress(pDevice->PortOffset, pMgmt->abyCurrBSSID);
-
-                               CARDbSetPhyParameter(pMgmt->pAdapter,
-                                                    pMgmt->eCurrentPHYMode,
-                                                    pMgmt->wCurrCapInfo,
-                                                    pMgmt->byERPContext,
-                                                    pMgmt->abyCurrSuppRates,
-                                                    pMgmt->abyCurrExtSuppRates);
-
-                               // Prepare beacon frame
-                               bMgrPrepareBeaconToSend((void *)pDevice, pMgmt);
-                       }
-               }
-       }
-       // endian issue ???
-       // Update TSF
-if (bUpdateTSF) {
-               CARDbGetCurrentTSF(pDevice->PortOffset, &qwCurrTSF);
-               CARDbUpdateTSF(pDevice, pRxPacket->byRxRate, qwTimestamp, pRxPacket->qwLocalTSF);
-               CARDbGetCurrentTSF(pDevice->PortOffset, &qwCurrTSF);
-               CARDvUpdateNextTBTT(pDevice->PortOffset, qwTimestamp, pMgmt->wCurrBeaconPeriod);
-       }
-}
-
-/*+
- *
- * Routine Description:
- *   Instructs the hw to create a bss using the supplied
- *   attributes. Note that this implementation only supports Ad-Hoc
- *   BSS creation.
- *
- *
- * Return Value:
- *    CMD_STATUS
- *
- -*/
-void
-vMgrCreateOwnIBSS(
-       void *hDeviceContext,
-       PCMD_STATUS pStatus
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject        pMgmt = pDevice->pMgmt;
-       unsigned short wMaxBasicRate;
-       unsigned short wMaxSuppRate;
-       unsigned char byTopCCKBasicRate;
-       unsigned char byTopOFDMBasicRate;
-       u64 qwCurrTSF;
-       unsigned int ii;
-       unsigned char abyRATE[] = {0x82, 0x84, 0x8B, 0x96, 0x24, 0x30, 0x48, 0x6C, 0x0C, 0x12, 0x18, 0x60};
-       unsigned char abyCCK_RATE[] = {0x82, 0x84, 0x8B, 0x96};
-       unsigned char abyOFDM_RATE[] = {0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
-       unsigned short wSuppRate;
-
-       pr_debug("Create Basic Service Set .......\n");
-
-       if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) {
-               if ((pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) &&
-                   (pDevice->eEncryptionStatus != Ndis802_11Encryption2Enabled) &&
-                   (pDevice->eEncryptionStatus != Ndis802_11Encryption3Enabled)) {
-                       // encryption mode error
-                       *pStatus = CMD_STATUS_FAILURE;
-                       return;
-               }
-       }
-
-       pMgmt->abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES;
-       pMgmt->abyCurrExtSuppRates[0] = WLAN_EID_EXTSUPP_RATES;
-
-       if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
-               pMgmt->eCurrentPHYMode = pMgmt->byAPBBType;
-       } else {
-               if (pDevice->byBBType == BB_TYPE_11G)
-                       pMgmt->eCurrentPHYMode = PHY_TYPE_11G;
-               if (pDevice->byBBType == BB_TYPE_11B)
-                       pMgmt->eCurrentPHYMode = PHY_TYPE_11B;
-               if (pDevice->byBBType == BB_TYPE_11A)
-                       pMgmt->eCurrentPHYMode = PHY_TYPE_11A;
-       }
-
-       if (pMgmt->eCurrentPHYMode != PHY_TYPE_11A) {
-               pMgmt->abyCurrSuppRates[1] = WLAN_RATES_MAXLEN_11B;
-               pMgmt->abyCurrExtSuppRates[1] = 0;
-               for (ii = 0; ii < 4; ii++)
-                       pMgmt->abyCurrSuppRates[2+ii] = abyRATE[ii];
-       } else {
-               pMgmt->abyCurrSuppRates[1] = 8;
-               pMgmt->abyCurrExtSuppRates[1] = 0;
-               for (ii = 0; ii < 8; ii++)
-                       pMgmt->abyCurrSuppRates[2+ii] = abyRATE[ii];
-       }
-
-       if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) {
-               pMgmt->abyCurrSuppRates[1] = 8;
-               pMgmt->abyCurrExtSuppRates[1] = 4;
-               for (ii = 0; ii < 4; ii++)
-                       pMgmt->abyCurrSuppRates[2+ii] =  abyCCK_RATE[ii];
-               for (ii = 4; ii < 8; ii++)
-                       pMgmt->abyCurrSuppRates[2+ii] =  abyOFDM_RATE[ii-4];
-               for (ii = 0; ii < 4; ii++)
-                       pMgmt->abyCurrExtSuppRates[2+ii] =  abyOFDM_RATE[ii+4];
-       }
-
-       // Disable Protect Mode
-       pDevice->bProtectMode = false;
-       MACvDisableProtectMD(pDevice->PortOffset);
-
-       pDevice->bBarkerPreambleMd = false;
-       MACvDisableBarkerPreambleMd(pDevice->PortOffset);
-
-       // Kyle Test 2003.11.04
-
-       // set HW beacon interval
-       if (pMgmt->wIBSSBeaconPeriod == 0)
-               pMgmt->wIBSSBeaconPeriod = DEFAULT_IBSS_BI;
-
-       CARDbGetCurrentTSF(pDevice->PortOffset, &qwCurrTSF);
-       // clear TSF counter
-       VNSvOutPortB(pDevice->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTRST);
-       // enable TSF counter
-       VNSvOutPortB(pDevice->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTREN);
-
-       // set Next TBTT
-       CARDvSetFirstNextTBTT(pDevice->PortOffset, pMgmt->wIBSSBeaconPeriod);
-
-       pMgmt->uIBSSChannel = pDevice->uChannel;
-
-       if (pMgmt->uIBSSChannel == 0)
-               pMgmt->uIBSSChannel = DEFAULT_IBSS_CHANNEL;
-
-       // set basic rate
-
-       RATEvParseMaxRate((void *)pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                         (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, true,
-                         &wMaxBasicRate, &wMaxSuppRate, &wSuppRate,
-                         &byTopCCKBasicRate, &byTopOFDMBasicRate);
-
-       if (pMgmt->eConfigMode == WMAC_CONFIG_AP)
-               pMgmt->eCurrMode = WMAC_MODE_ESS_AP;
-
-       if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) {
-               memcpy(pMgmt->abyIBSSDFSOwner, pDevice->abyCurrentNetAddr, 6);
-               pMgmt->byIBSSDFSRecovery = 10;
-               pMgmt->eCurrMode = WMAC_MODE_IBSS_STA;
-       }
-
-       // Adopt pre-configured IBSS vars to current vars
-       pMgmt->eCurrState = WMAC_STATE_STARTED;
-       pMgmt->wCurrBeaconPeriod = pMgmt->wIBSSBeaconPeriod;
-       pMgmt->uCurrChannel = pMgmt->uIBSSChannel;
-       pMgmt->wCurrATIMWindow = pMgmt->wIBSSATIMWindow;
-       MACvWriteATIMW(pDevice->PortOffset, pMgmt->wCurrATIMWindow);
-       pDevice->uCurrRSSI = 0;
-       pDevice->byCurrSQ = 0;
-       memset(pMgmt->abyCurrSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
-       memcpy(pMgmt->abyCurrSSID,
-              pMgmt->abyDesireSSID,
-              ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len + WLAN_IEHDR_LEN
-);
-
-       if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
-               // AP mode BSSID = MAC addr
-               memcpy(pMgmt->abyCurrBSSID, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
-               pr_info("AP beacon created BSSID:%pM\n",
-                       pMgmt->abyCurrBSSID);
-       }
-
-       if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
-               // BSSID selected must be randomized as spec 11.1.3
-               pMgmt->abyCurrBSSID[5] = (u8) (qwCurrTSF & 0x000000ff);
-               pMgmt->abyCurrBSSID[4] = (u8) ((qwCurrTSF & 0x0000ff00) >> 8);
-               pMgmt->abyCurrBSSID[3] = (u8) ((qwCurrTSF & 0x00ff0000) >> 16);
-               pMgmt->abyCurrBSSID[2] = (u8) ((qwCurrTSF & 0x00000ff0) >> 4);
-               pMgmt->abyCurrBSSID[1] = (u8) ((qwCurrTSF & 0x000ff000) >> 12);
-               pMgmt->abyCurrBSSID[0] = (u8) ((qwCurrTSF & 0x0ff00000) >> 20);
-               pMgmt->abyCurrBSSID[5] ^= pMgmt->abyMACAddr[0];
-               pMgmt->abyCurrBSSID[4] ^= pMgmt->abyMACAddr[1];
-               pMgmt->abyCurrBSSID[3] ^= pMgmt->abyMACAddr[2];
-               pMgmt->abyCurrBSSID[2] ^= pMgmt->abyMACAddr[3];
-               pMgmt->abyCurrBSSID[1] ^= pMgmt->abyMACAddr[4];
-               pMgmt->abyCurrBSSID[0] ^= pMgmt->abyMACAddr[5];
-               pMgmt->abyCurrBSSID[0] &= ~IEEE_ADDR_GROUP;
-               pMgmt->abyCurrBSSID[0] |= IEEE_ADDR_UNIVERSAL;
-
-               pr_info("Adhoc beacon created bssid:%pM\n",
-                       pMgmt->abyCurrBSSID);
-       }
-
-       // Set Capability Info
-       pMgmt->wCurrCapInfo = 0;
-
-       if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
-               pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1);
-               pMgmt->byDTIMPeriod = DEFAULT_DTIM_PERIOD;
-               pMgmt->byDTIMCount = pMgmt->byDTIMPeriod - 1;
-       }
-
-       if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)
-               pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_IBSS(1);
-
-       if (pDevice->bEncryptionEnable) {
-               pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1);
-               if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
-                       if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
-                               pMgmt->byCSSPK = KEY_CTL_CCMP;
-                               pMgmt->byCSSGK = KEY_CTL_CCMP;
-                       } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
-                               pMgmt->byCSSPK = KEY_CTL_TKIP;
-                               pMgmt->byCSSGK = KEY_CTL_TKIP;
-                       } else {
-                               pMgmt->byCSSPK = KEY_CTL_NONE;
-                               pMgmt->byCSSGK = KEY_CTL_WEP;
-                       }
-               } else {
-                       pMgmt->byCSSPK = KEY_CTL_WEP;
-                       pMgmt->byCSSGK = KEY_CTL_WEP;
-               }
-       }
-
-       pMgmt->byERPContext = 0;
-
-       if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
-               CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, NL80211_IFTYPE_AP);
-       } else {
-               CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, NL80211_IFTYPE_ADHOC);
-       }
-
-       CARDbSetPhyParameter(pMgmt->pAdapter,
-                            pMgmt->eCurrentPHYMode,
-                            pMgmt->wCurrCapInfo,
-                            pMgmt->byERPContext,
-                            pMgmt->abyCurrSuppRates,
-                            pMgmt->abyCurrExtSuppRates
-               );
-
-       CARDbSetBeaconPeriod(pMgmt->pAdapter, pMgmt->wIBSSBeaconPeriod);
-       // set channel and clear NAV
-       set_channel(pMgmt->pAdapter, pMgmt->uIBSSChannel);
-       pMgmt->uCurrChannel = pMgmt->uIBSSChannel;
-
-       if (CARDbIsShortPreamble(pMgmt->pAdapter))
-               pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
-       else
-               pMgmt->wCurrCapInfo &= (~WLAN_SET_CAP_INFO_SHORTPREAMBLE(1));
-
-       if (pMgmt->b11hEnable &&
-           (pMgmt->eCurrentPHYMode == PHY_TYPE_11A)) {
-               pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);
-       } else {
-               pMgmt->wCurrCapInfo &= (~WLAN_SET_CAP_INFO_SPECTRUMMNG(1));
-       }
-
-       pMgmt->eCurrState = WMAC_STATE_STARTED;
-       // Prepare beacon to send
-       if (bMgrPrepareBeaconToSend((void *)pDevice, pMgmt))
-               *pStatus = CMD_STATUS_SUCCESS;
-}
-
-/*+
- *
- * Routine Description:
- *   Instructs wmac to join a bss using the supplied attributes.
- *   The arguments may the BSSID or SSID and the rest of the
- *   attributes are obtained from the scan result of known bss list.
- *
- *
- * Return Value:
- *    None.
- *
- -*/
-
-void
-vMgrJoinBSSBegin(
-       void *hDeviceContext,
-       PCMD_STATUS pStatus
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       PKnownBSS       pCurr = NULL;
-       unsigned int ii, uu;
-       PWLAN_IE_SUPP_RATES pItemRates = NULL;
-       PWLAN_IE_SUPP_RATES pItemExtRates = NULL;
-       PWLAN_IE_SSID   pItemSSID;
-       unsigned int uRateLen = WLAN_RATES_MAXLEN;
-       unsigned short wMaxBasicRate = RATE_1M;
-       unsigned short wMaxSuppRate = RATE_1M;
-       unsigned short wSuppRate;
-       unsigned char byTopCCKBasicRate = RATE_1M;
-       unsigned char byTopOFDMBasicRate = RATE_1M;
-
-       for (ii = 0; ii < MAX_BSS_NUM; ii++) {
-               if (pMgmt->sBSSList[ii].bActive)
-                       break;
-       }
-
-       if (ii == MAX_BSS_NUM) {
-               *pStatus = CMD_STATUS_RESOURCES;
-               pr_info("BSS finding:BSS list is empty\n");
-               return;
-       }
-
-       // Search known BSS list for prefer BSSID or SSID
-
-       pCurr = BSSpSearchBSSList(pDevice,
-                                 pMgmt->abyDesireBSSID,
-                                 pMgmt->abyDesireSSID,
-                                 pMgmt->eConfigPHYMode
-);
-
-       if (pCurr == NULL) {
-               *pStatus = CMD_STATUS_RESOURCES;
-               pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
-               pr_info("Scanning [%s] not found, disconnected !\n",
-                       pItemSSID->abySSID);
-               return;
-       }
-
-       pr_info("AP(BSS) finding:Found a AP(BSS)..\n");
-       if (WLAN_GET_CAP_INFO_ESS(cpu_to_le16(pCurr->wCapInfo))) {
-               if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA) || (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK)) {
-                       // patch for CISCO migration mode
-               }
-
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-               Encyption_Rebuild(pDevice, pCurr);
-#endif
-               // Infrastructure BSS
-               s_vMgrSynchBSS(pDevice,
-                              WMAC_MODE_ESS_STA,
-                              pCurr,
-                              pStatus
-);
-
-               if (*pStatus == CMD_STATUS_SUCCESS) {
-                       // Adopt this BSS state vars in Mgmt Object
-                       pMgmt->uCurrChannel = pCurr->uChannel;
-
-                       memset(pMgmt->abyCurrSuppRates, 0 , WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
-                       memset(pMgmt->abyCurrExtSuppRates, 0 , WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
-
-                       if (pCurr->eNetworkTypeInUse == PHY_TYPE_11B)
-                               uRateLen = WLAN_RATES_MAXLEN_11B;
-
-                       pItemRates = (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates;
-                       pItemExtRates = (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates;
-
-                       // Parse Support Rate IE
-                       pItemRates->byElementID = WLAN_EID_SUPP_RATES;
-                       pItemRates->len = RATEuSetIE((PWLAN_IE_SUPP_RATES)pCurr->abySuppRates,
-                                                    pItemRates,
-                                                    uRateLen);
-
-                       // Parse Extension Support Rate IE
-                       pItemExtRates->byElementID = WLAN_EID_EXTSUPP_RATES;
-                       pItemExtRates->len = RATEuSetIE((PWLAN_IE_SUPP_RATES)pCurr->abyExtSuppRates,
-                                                       pItemExtRates,
-                                                       uRateLen);
-                       // Stuffing Rate IE
-                       if ((pItemExtRates->len > 0) && (pItemRates->len < 8)) {
-                               for (ii = 0; ii < (unsigned int)(8 - pItemRates->len);) {
-                                       pItemRates->abyRates[pItemRates->len + ii] = pItemExtRates->abyRates[ii];
-                                       ii++;
-                                       if (pItemExtRates->len <= ii)
-                                               break;
-                               }
-                               pItemRates->len += (unsigned char)ii;
-                               if (pItemExtRates->len - ii > 0) {
-                                       pItemExtRates->len -= (unsigned char)ii;
-                                       for (uu = 0; uu < pItemExtRates->len; uu++)
-                                               pItemExtRates->abyRates[uu] = pItemExtRates->abyRates[uu + ii];
-                               } else {
-                                       pItemExtRates->len = 0;
-                               }
-                       }
-
-                       RATEvParseMaxRate((void *)pDevice, pItemRates, pItemExtRates, true,
-                                         &wMaxBasicRate, &wMaxSuppRate, &wSuppRate,
-                                         &byTopCCKBasicRate, &byTopOFDMBasicRate);
-
-                       // TODO: deal with if wCapInfo the privacy is on, but station WEP is off
-                       // TODO: deal with if wCapInfo the PS-Pollable is on.
-                       pMgmt->wCurrBeaconPeriod = pCurr->wBeaconInterval;
-                       memset(pMgmt->abyCurrSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
-                       memcpy(pMgmt->abyCurrBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN);
-                       memcpy(pMgmt->abyCurrSSID, pCurr->abySSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
-
-                       pMgmt->eCurrMode = WMAC_MODE_ESS_STA;
-
-                       pMgmt->eCurrState = WMAC_STATE_JOINTED;
-
-                       // Add current BSS to Candidate list
-                       // This should only works for WPA2 BSS, and WPA2 BSS check must be done before.
-                       if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) {
-                               bool bResult = bAdd_PMKID_Candidate((void *)pDevice, pMgmt->abyCurrBSSID, &pCurr->sRSNCapObj);
-
-                               pr_debug("bAdd_PMKID_Candidate: 1(%d)\n",
-                                        bResult);
-                               if (!bResult) {
-                                       vFlush_PMKID_Candidate((void *)pDevice);
-                                       pr_debug("vFlush_PMKID_Candidate: 4\n");
-                                       bAdd_PMKID_Candidate((void *)pDevice, pMgmt->abyCurrBSSID, &pCurr->sRSNCapObj);
-                               }
-                       }
-
-                       // Preamble type auto-switch: if AP can receive short-preamble cap,
-                       // we can turn on too.
-
-                       pr_debug("Join ESS\n");
-
-                       pr_debug("End of Join AP -- A/B/G Action\n");
-               } else {
-                       pMgmt->eCurrState = WMAC_STATE_IDLE;
-               }
-
-       } else {
-               // ad-hoc mode BSS
-               if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
-                       if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
-                               if (!WPA_SearchRSN(0, WPA_TKIP, pCurr)) {
-                                       // encryption mode error
-                                       pMgmt->eCurrState = WMAC_STATE_IDLE;
-                                       return;
-                               }
-                       } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
-                               if (!WPA_SearchRSN(0, WPA_AESCCMP, pCurr)) {
-                                       // encryption mode error
-                                       pMgmt->eCurrState = WMAC_STATE_IDLE;
-                                       return;
-                               }
-                       } else {
-                               // encryption mode error
-                               pMgmt->eCurrState = WMAC_STATE_IDLE;
-                               return;
-                       }
-               }
-
-               s_vMgrSynchBSS(pDevice,
-                              WMAC_MODE_IBSS_STA,
-                              pCurr,
-                              pStatus
-);
-
-               if (*pStatus == CMD_STATUS_SUCCESS) {
-                       // Adopt this BSS state vars in Mgmt Object
-                       // TODO: check if CapInfo privacy on, but we don't..
-                       pMgmt->uCurrChannel = pCurr->uChannel;
-
-                       // Parse Support Rate IE
-                       pMgmt->abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES;
-                       pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pCurr->abySuppRates,
-                                                               (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                                                               WLAN_RATES_MAXLEN_11B);
-                       // set basic rate
-                       RATEvParseMaxRate((void *)pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                                         NULL, true, &wMaxBasicRate, &wMaxSuppRate, &wSuppRate,
-                                         &byTopCCKBasicRate, &byTopOFDMBasicRate);
-
-                       pMgmt->wCurrCapInfo = pCurr->wCapInfo;
-                       pMgmt->wCurrBeaconPeriod = pCurr->wBeaconInterval;
-                       memset(pMgmt->abyCurrSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN);
-                       memcpy(pMgmt->abyCurrBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN);
-                       memcpy(pMgmt->abyCurrSSID, pCurr->abySSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN);
-                       MACvWriteATIMW(pDevice->PortOffset, pMgmt->wCurrATIMWindow);
-                       pMgmt->eCurrMode = WMAC_MODE_IBSS_STA;
-
-                       pMgmt->eCurrState = WMAC_STATE_STARTED;
-
-                       pr_debug("Join IBSS ok:%pM\n",
-                                pMgmt->abyCurrBSSID);
-                       // Preamble type auto-switch: if AP can receive short-preamble cap,
-                       // and if registry setting is short preamble we can turn on too.
-
-                       // Prepare beacon
-                       bMgrPrepareBeaconToSend((void *)pDevice, pMgmt);
-               } else {
-                       pMgmt->eCurrState = WMAC_STATE_IDLE;
-               }
-       }
-}
-
-/*+
- *
- * Routine Description:
- * Set HW to synchronize a specific BSS from known BSS list.
- *
- *
- * Return Value:
- *    PCM_STATUS
- *
- -*/
-static
-void
-s_vMgrSynchBSS(
-       struct vnt_private *pDevice,
-       unsigned int uBSSMode,
-       PKnownBSS     pCurr,
-       PCMD_STATUS  pStatus
-)
-{
-       CARD_PHY_TYPE   ePhyType = PHY_TYPE_11B;
-       PSMgmtObject  pMgmt = pDevice->pMgmt;
-
-       //1M,   2M,   5M,   11M,  18M,  24M,  36M,  54M
-       unsigned char abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
-       unsigned char abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60};
-       //6M,   9M,   12M,  48M
-       unsigned char abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
-       unsigned char abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
-
-       *pStatus = CMD_STATUS_FAILURE;
-
-       if (!s_bCipherMatch(pCurr,
-                          pDevice->eEncryptionStatus,
-                          &(pMgmt->byCSSPK),
-                          &(pMgmt->byCSSGK))) {
-               pr_debug("s_bCipherMatch Fail .......\n");
-               return;
-       }
-
-       pMgmt->pCurrBSS = pCurr;
-
-       // if previous mode is IBSS.
-       if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
-               MACvRegBitsOff(pDevice->PortOffset, MAC_REG_BCNDMACTL, BEACON_READY);
-               MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
-       }
-
-       // Init the BSS informations
-       pDevice->bProtectMode = false;
-       MACvDisableProtectMD(pDevice->PortOffset);
-       pDevice->bBarkerPreambleMd = false;
-       MACvDisableBarkerPreambleMd(pDevice->PortOffset);
-       pDevice->bNonERPPresent = false;
-       pDevice->byPreambleType = 0;
-       pDevice->wBasicRate = 0;
-       // Set Basic Rate
-       CARDbAddBasicRate((void *)pDevice, RATE_1M);
-       // calculate TSF offset
-       // TSF Offset = Received Timestamp TSF - Marked Local's TSF
-       CARDbUpdateTSF(pDevice, pCurr->byRxRate, pCurr->qwBSSTimestamp, pCurr->qwLocalTSF);
-
-       CARDbSetBeaconPeriod(pDevice, pCurr->wBeaconInterval);
-
-       // set Next TBTT
-       // Next TBTT = ((local_current_TSF / beacon_interval) + 1) * beacon_interval
-       CARDvSetFirstNextTBTT(pDevice->PortOffset, pCurr->wBeaconInterval);
-
-       // set BSSID
-       MACvWriteBSSIDAddress(pDevice->PortOffset, pCurr->abyBSSID);
-
-       MACvReadBSSIDAddress(pDevice->PortOffset, pMgmt->abyCurrBSSID);
-
-       pr_debug("Sync:set CurrBSSID address = %pM\n", pMgmt->abyCurrBSSID);
-
-       if (pCurr->eNetworkTypeInUse == PHY_TYPE_11A) {
-               if ((pMgmt->eConfigPHYMode == PHY_TYPE_11A) ||
-                   (pMgmt->eConfigPHYMode == PHY_TYPE_AUTO)) {
-                       ePhyType = PHY_TYPE_11A;
-               } else {
-                       return;
-               }
-       } else if (pCurr->eNetworkTypeInUse == PHY_TYPE_11B) {
-               if ((pMgmt->eConfigPHYMode == PHY_TYPE_11B) ||
-                   (pMgmt->eConfigPHYMode == PHY_TYPE_11G) ||
-                   (pMgmt->eConfigPHYMode == PHY_TYPE_AUTO)) {
-                       ePhyType = PHY_TYPE_11B;
-               } else {
-                       return;
-               }
-       } else {
-               if ((pMgmt->eConfigPHYMode == PHY_TYPE_11G) ||
-                   (pMgmt->eConfigPHYMode == PHY_TYPE_AUTO)) {
-                       ePhyType = PHY_TYPE_11G;
-               } else if (pMgmt->eConfigPHYMode == PHY_TYPE_11B) {
-                       ePhyType = PHY_TYPE_11B;
-               } else {
-                       return;
-               }
-       }
-
-       if (ePhyType == PHY_TYPE_11A) {
-               memcpy(pMgmt->abyCurrSuppRates, &abyCurrSuppRatesA[0], sizeof(abyCurrSuppRatesA));
-               pMgmt->abyCurrExtSuppRates[1] = 0;
-       } else if (ePhyType == PHY_TYPE_11B) {
-               memcpy(pMgmt->abyCurrSuppRates, &abyCurrSuppRatesB[0], sizeof(abyCurrSuppRatesB));
-               pMgmt->abyCurrExtSuppRates[1] = 0;
-       } else {
-               memcpy(pMgmt->abyCurrSuppRates, &abyCurrSuppRatesG[0], sizeof(abyCurrSuppRatesG));
-               memcpy(pMgmt->abyCurrExtSuppRates, &abyCurrExtSuppRatesG[0], sizeof(abyCurrExtSuppRatesG));
-       }
-
-       if (WLAN_GET_CAP_INFO_ESS(pCurr->wCapInfo)) {
-               CARDbSetBSSID(pMgmt->pAdapter, pCurr->abyBSSID, NL80211_IFTYPE_STATION);
-               // Add current BSS to Candidate list
-               // This should only works for WPA2 BSS, and WPA2 BSS check must be done before.
-               if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)
-                       CARDbAdd_PMKID_Candidate(pMgmt->pAdapter, pMgmt->abyCurrBSSID, pCurr->sRSNCapObj.bRSNCapExist, pCurr->sRSNCapObj.wRSNCap);
-       } else {
-               CARDbSetBSSID(pMgmt->pAdapter, pCurr->abyBSSID, NL80211_IFTYPE_ADHOC);
-       }
-
-       if (!CARDbSetPhyParameter(pMgmt->pAdapter,
-                                ePhyType,
-                                pCurr->wCapInfo,
-                                pCurr->sERP.byERP,
-                                pMgmt->abyCurrSuppRates,
-                                pMgmt->abyCurrExtSuppRates)) {
-               pr_debug("<----s_bSynchBSS Set Phy Mode Fail [%d]\n", ePhyType);
-               return;
-       }
-       // set channel and clear NAV
-       if (!set_channel(pMgmt->pAdapter, pCurr->uChannel)) {
-               pr_debug("<----s_bSynchBSS Set Channel [%d]\n",
-                        pCurr->uChannel);
-               return;
-       }
-
-       pMgmt->uCurrChannel = pCurr->uChannel;
-       pMgmt->eCurrentPHYMode = ePhyType;
-       pMgmt->byERPContext = pCurr->sERP.byERP;
-       pr_debug("Sync:Set to channel = [%d]\n", (int)pCurr->uChannel);
-
-       *pStatus = CMD_STATUS_SUCCESS;
-
-       return;
-};
-
-//mike add: fix NetworkManager 0.7.0 hidden ssid mode in WPA encryption
-//                   ,need reset eAuthenMode and eEncryptionStatus
-static void  Encyption_Rebuild(
-       struct vnt_private *pDevice,
-       PKnownBSS pCurr
-)
-{
-       PSMgmtObject  pMgmt = &(pDevice->sMgmtObj);
-
-       if ((pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) ||           //networkmanager 0.7.0 does not give the pairwise-key selection,
-           (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) {         // so we need re-select it according to real pairwise-key info.
-               if (pCurr->bWPAValid)  {   //WPA-PSK
-                       pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK;
-                       if (pCurr->abyPKType[0] == WPA_TKIP) {
-                               pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;    //TKIP
-                               PRINT_K("Encyption_Rebuild--->ssid reset config to [WPAPSK-TKIP]\n");
-                       } else if (pCurr->abyPKType[0] == WPA_AESCCMP) {
-                               pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;    //AES
-                               PRINT_K("Encyption_Rebuild--->ssid reset config to [WPAPSK-AES]\n");
-                       }
-               } else if (pCurr->bWPA2Valid) {  //WPA2-PSK
-                       pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK;
-                       if (pCurr->abyCSSPK[0] == WLAN_11i_CSS_TKIP) {
-                               pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;     //TKIP
-                               PRINT_K("Encyption_Rebuild--->ssid reset config to [WPA2PSK-TKIP]\n");
-                       } else if (pCurr->abyCSSPK[0] == WLAN_11i_CSS_CCMP) {
-                               pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;    //AES
-                               PRINT_K("Encyption_Rebuild--->ssid reset config to [WPA2PSK-AES]\n");
-                       }
-               }
-       }
-}
-
-/*+
- *
- * Routine Description:
- *  Format TIM field
- *
- *
- * Return Value:
- *    void
- *
- -*/
-
-static
-void
-s_vMgrFormatTIM(
-       PSMgmtObject pMgmt,
-       PWLAN_IE_TIM pTIM
-)
-{
-       unsigned char byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
-       unsigned char byMap;
-       unsigned int ii, jj;
-       bool bStartFound = false;
-       bool bMulticast = false;
-       unsigned short wStartIndex = 0;
-       unsigned short wEndIndex = 0;
-
-       // Find size of partial virtual bitmap
-       for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
-               byMap = pMgmt->abyPSTxMap[ii];
-               if (!ii) {
-                       // Mask out the broadcast bit which is indicated separately.
-                       bMulticast = (byMap & byMask[0]) != 0;
-                       if (bMulticast)
-                               pMgmt->sNodeDBTable[0].bRxPSPoll = true;
-
-                       byMap = 0;
-               }
-               if (byMap) {
-                       if (!bStartFound) {
-                               bStartFound = true;
-                               wStartIndex = ii;
-                       }
-                       wEndIndex = ii;
-               }
-       }
-
-       // Round start index down to nearest even number
-       wStartIndex &=  ~BIT0;
-
-       // Round end index up to nearest even number
-       wEndIndex = ((wEndIndex + 1) & ~BIT0);
-
-       // Size of element payload
-
-       pTIM->len =  3 + (wEndIndex - wStartIndex) + 1;
-
-       // Fill in the Fixed parts of the TIM
-       pTIM->byDTIMCount = pMgmt->byDTIMCount;
-       pTIM->byDTIMPeriod = pMgmt->byDTIMPeriod;
-       pTIM->byBitMapCtl = (bMulticast ? TIM_MULTICAST_MASK : 0) |
-               (((wStartIndex >> 1) << 1) & TIM_BITMAPOFFSET_MASK);
-
-       // Append variable part of TIM
-
-       for (ii = wStartIndex, jj = 0; ii <= wEndIndex; ii++, jj++)
-               pTIM->byVirtBitMap[jj] = pMgmt->abyPSTxMap[ii];
-
-       // Aid = 0 don't used.
-       pTIM->byVirtBitMap[0]  &= ~BIT0;
-}
-
-/*+
- *
- * Routine Description:
- *  Constructs an Beacon frame(Ad-hoc mode)
- *
- *
- * Return Value:
- *    PTR to frame; or NULL on allocation failure
- *
- -*/
-
-static
-PSTxMgmtPacket
-s_MgrMakeBeacon(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       unsigned short wCurrCapInfo,
-       unsigned short wCurrBeaconPeriod,
-       unsigned int uCurrChannel,
-       unsigned short wCurrATIMWinodw,
-       PWLAN_IE_SSID pCurrSSID,
-       unsigned char *pCurrBSSID,
-       PWLAN_IE_SUPP_RATES pCurrSuppRates,
-       PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-)
-{
-       PSTxMgmtPacket      pTxPacket = NULL;
-       WLAN_FR_BEACON      sFrame;
-       unsigned char abyBroadcastAddr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-       unsigned char *pbyBuffer;
-       unsigned int uLength = 0;
-       PWLAN_IE_IBSS_DFS   pIBSSDFS = NULL;
-       unsigned int ii;
-
-       // prepare beacon frame
-       pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-       memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_BEACON_FR_MAXLEN);
-       pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket));
-       // Setup the sFrame structure.
-       sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header;
-       sFrame.len = WLAN_BEACON_FR_MAXLEN;
-       vMgrEncodeBeacon(&sFrame);
-       // Setup the header
-       sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
-               (
-                       WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
-                       WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_BEACON)
-));
-
-       if (pDevice->bEnablePSMode)
-               sFrame.pHdr->sA3.wFrameCtl |= cpu_to_le16((unsigned short)WLAN_SET_FC_PWRMGT(1));
-
-       memcpy(sFrame.pHdr->sA3.abyAddr1, abyBroadcastAddr, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr3, pCurrBSSID, WLAN_BSSID_LEN);
-       *sFrame.pwBeaconInterval = cpu_to_le16(wCurrBeaconPeriod);
-       *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo);
-       // Copy SSID
-       sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
-       sFrame.len += ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len + WLAN_IEHDR_LEN;
-       memcpy(sFrame.pSSID,
-              pCurrSSID,
-              ((PWLAN_IE_SSID)pCurrSSID)->len + WLAN_IEHDR_LEN
-);
-       // Copy the rate set
-       sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
-       sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN;
-       memcpy(sFrame.pSuppRates,
-              pCurrSuppRates,
-              ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN
-);
-       // DS parameter
-       if (pDevice->eCurrentPHYType != PHY_TYPE_11A) {
-               sFrame.pDSParms = (PWLAN_IE_DS_PARMS)(sFrame.pBuf + sFrame.len);
-               sFrame.len += (1) + WLAN_IEHDR_LEN;
-               sFrame.pDSParms->byElementID = WLAN_EID_DS_PARMS;
-               sFrame.pDSParms->len = 1;
-               sFrame.pDSParms->byCurrChannel = (unsigned char)uCurrChannel;
-       }
-       // TIM field
-       if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
-               sFrame.pTIM = (PWLAN_IE_TIM)(sFrame.pBuf + sFrame.len);
-               sFrame.pTIM->byElementID = WLAN_EID_TIM;
-               s_vMgrFormatTIM(pMgmt, sFrame.pTIM);
-               sFrame.len += (WLAN_IEHDR_LEN + sFrame.pTIM->len);
-       }
-
-       if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
-               // IBSS parameter
-               sFrame.pIBSSParms = (PWLAN_IE_IBSS_PARMS)(sFrame.pBuf + sFrame.len);
-               sFrame.len += (2) + WLAN_IEHDR_LEN;
-               sFrame.pIBSSParms->byElementID = WLAN_EID_IBSS_PARMS;
-               sFrame.pIBSSParms->len = 2;
-               sFrame.pIBSSParms->wATIMWindow = wCurrATIMWinodw;
-               if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
-                       /* RSN parameter */
-                       sFrame.pRSNWPA = (PWLAN_IE_RSN_EXT)(sFrame.pBuf + sFrame.len);
-                       sFrame.pRSNWPA->byElementID = WLAN_EID_RSN_WPA;
-                       sFrame.pRSNWPA->len = 12;
-                       sFrame.pRSNWPA->abyOUI[0] = 0x00;
-                       sFrame.pRSNWPA->abyOUI[1] = 0x50;
-                       sFrame.pRSNWPA->abyOUI[2] = 0xf2;
-                       sFrame.pRSNWPA->abyOUI[3] = 0x01;
-                       sFrame.pRSNWPA->wVersion = 1;
-                       sFrame.pRSNWPA->abyMulticast[0] = 0x00;
-                       sFrame.pRSNWPA->abyMulticast[1] = 0x50;
-                       sFrame.pRSNWPA->abyMulticast[2] = 0xf2;
-                       if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)
-                               sFrame.pRSNWPA->abyMulticast[3] = 0x04;//AES
-                       else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled)
-                               sFrame.pRSNWPA->abyMulticast[3] = 0x02;//TKIP
-                       else if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled)
-                               sFrame.pRSNWPA->abyMulticast[3] = 0x01;//WEP40
-                       else
-                               sFrame.pRSNWPA->abyMulticast[3] = 0x00;//NONE
-
-                       // Pairwise Key Cipher Suite
-                       sFrame.pRSNWPA->wPKCount = 0;
-                       // Auth Key Management Suite
-                       *((unsigned short *)(sFrame.pBuf + sFrame.len + sFrame.pRSNWPA->len)) = 0;
-                       sFrame.pRSNWPA->len += 2;
-
-                       // RSN Capabilities
-                       *((unsigned short *)(sFrame.pBuf + sFrame.len + sFrame.pRSNWPA->len)) = 0;
-                       sFrame.pRSNWPA->len += 2;
-                       sFrame.len += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
-               }
-       }
-
-       if (pMgmt->b11hEnable && (pMgmt->eCurrentPHYMode == PHY_TYPE_11A)) {
-               // Country IE
-               pbyBuffer = (unsigned char *)(sFrame.pBuf + sFrame.len);
-               set_country_IE(pMgmt->pAdapter, pbyBuffer);
-               set_country_info(pMgmt->pAdapter, PHY_TYPE_11A, pbyBuffer);
-               uLength += ((PWLAN_IE_COUNTRY) pbyBuffer)->len + WLAN_IEHDR_LEN;
-               pbyBuffer += (((PWLAN_IE_COUNTRY) pbyBuffer)->len + WLAN_IEHDR_LEN);
-               // Power Constrain IE
-               ((PWLAN_IE_PW_CONST) pbyBuffer)->byElementID = WLAN_EID_PWR_CONSTRAINT;
-               ((PWLAN_IE_PW_CONST) pbyBuffer)->len = 1;
-               ((PWLAN_IE_PW_CONST) pbyBuffer)->byPower = 0;
-               pbyBuffer += (1) + WLAN_IEHDR_LEN;
-               uLength += (1) + WLAN_IEHDR_LEN;
-               if (pMgmt->bSwitchChannel) {
-                       // Channel Switch IE
-                       ((PWLAN_IE_CH_SW) pbyBuffer)->byElementID = WLAN_EID_CH_SWITCH;
-                       ((PWLAN_IE_CH_SW) pbyBuffer)->len = 3;
-                       ((PWLAN_IE_CH_SW) pbyBuffer)->byMode = 1;
-                       ((PWLAN_IE_CH_SW) pbyBuffer)->byChannel = get_channel_number(pMgmt->pAdapter, pMgmt->byNewChannel);
-                       ((PWLAN_IE_CH_SW) pbyBuffer)->byCount = 0;
-                       pbyBuffer += (3) + WLAN_IEHDR_LEN;
-                       uLength += (3) + WLAN_IEHDR_LEN;
-               }
-               // TPC report
-               ((PWLAN_IE_TPC_REP) pbyBuffer)->byElementID = WLAN_EID_TPC_REP;
-               ((PWLAN_IE_TPC_REP) pbyBuffer)->len = 2;
-               ((PWLAN_IE_TPC_REP) pbyBuffer)->byTxPower = CARDbyGetTransmitPower(pMgmt->pAdapter);
-               ((PWLAN_IE_TPC_REP) pbyBuffer)->byLinkMargin = 0;
-               pbyBuffer += (2) + WLAN_IEHDR_LEN;
-               uLength += (2) + WLAN_IEHDR_LEN;
-               // IBSS DFS
-               if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP) {
-                       pIBSSDFS = (PWLAN_IE_IBSS_DFS) pbyBuffer;
-                       pIBSSDFS->byElementID = WLAN_EID_IBSS_DFS;
-                       pIBSSDFS->len = 7;
-                       memcpy(pIBSSDFS->abyDFSOwner,
-                              pMgmt->abyIBSSDFSOwner,
-                              6);
-                       pIBSSDFS->byDFSRecovery = pMgmt->byIBSSDFSRecovery;
-                       pbyBuffer += (7) + WLAN_IEHDR_LEN;
-                       uLength += (7) + WLAN_IEHDR_LEN;
-                       for (ii = CB_MAX_CHANNEL_24G+1; ii <= CB_MAX_CHANNEL; ii++) {
-                               if (get_channel_map_info(pMgmt->pAdapter, ii, pbyBuffer, pbyBuffer+1)) {
-                                       pbyBuffer += 2;
-                                       uLength += 2;
-                                       pIBSSDFS->len += 2;
-                               }
-                       }
-               }
-               sFrame.len += uLength;
-       }
-
-       if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) {
-               sFrame.pERP = (PWLAN_IE_ERP)(sFrame.pBuf + sFrame.len);
-               sFrame.len += 1 + WLAN_IEHDR_LEN;
-               sFrame.pERP->byElementID = WLAN_EID_ERP;
-               sFrame.pERP->len = 1;
-               sFrame.pERP->byContext = 0;
-               if (pDevice->bProtectMode)
-                       sFrame.pERP->byContext |= WLAN_EID_ERP_USE_PROTECTION;
-               if (pDevice->bNonERPPresent)
-                       sFrame.pERP->byContext |= WLAN_EID_ERP_NONERP_PRESENT;
-               if (pDevice->bBarkerPreambleMd)
-                       sFrame.pERP->byContext |= WLAN_EID_ERP_BARKER_MODE;
-       }
-       if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) {
-               sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
-               sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN;
-               memcpy(sFrame.pExtSuppRates,
-                      pCurrExtSuppRates,
-                      ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN
-);
-       }
-       // hostapd wpa/wpa2 IE
-       if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && pDevice->bEnableHostapd) {
-               if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
-                       if (pMgmt->wWPAIELen != 0) {
-                               sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len);
-                               memcpy(sFrame.pRSN, pMgmt->abyWPAIE, pMgmt->wWPAIELen);
-                               sFrame.len += pMgmt->wWPAIELen;
-                       }
-               }
-       }
-
-       /* Adjust the length fields */
-       pTxPacket->cbMPDULen = sFrame.len;
-       pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
-
-       return pTxPacket;
-}
-
-/*+
- *
- * Routine Description:
- *  Constructs an Prob-response frame
- *
- *
- * Return Value:
- *    PTR to frame; or NULL on allocation failure
- *
- -*/
-
-static PSTxMgmtPacket
-s_MgrMakeProbeResponse(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       unsigned short wCurrCapInfo,
-       unsigned short wCurrBeaconPeriod,
-       unsigned int uCurrChannel,
-       unsigned short wCurrATIMWinodw,
-       unsigned char *pDstAddr,
-       PWLAN_IE_SSID pCurrSSID,
-       unsigned char *pCurrBSSID,
-       PWLAN_IE_SUPP_RATES pCurrSuppRates,
-       PWLAN_IE_SUPP_RATES pCurrExtSuppRates,
-       unsigned char byPHYType
-)
-{
-       PSTxMgmtPacket      pTxPacket = NULL;
-       WLAN_FR_PROBERESP   sFrame;
-       unsigned char *pbyBuffer;
-       unsigned int uLength = 0;
-       PWLAN_IE_IBSS_DFS   pIBSSDFS = NULL;
-       unsigned int ii;
-
-       pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-       memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_PROBERESP_FR_MAXLEN);
-       pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket));
-       // Setup the sFrame structure.
-       sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header;
-       sFrame.len = WLAN_PROBERESP_FR_MAXLEN;
-       vMgrEncodeProbeResponse(&sFrame);
-       // Setup the header
-       sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
-               (
-                       WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
-                       WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBERESP)
-));
-       memcpy(sFrame.pHdr->sA3.abyAddr1, pDstAddr, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr3, pCurrBSSID, WLAN_BSSID_LEN);
-       *sFrame.pwBeaconInterval = cpu_to_le16(wCurrBeaconPeriod);
-       *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo);
-
-       if (byPHYType == BB_TYPE_11B)
-               *sFrame.pwCapInfo &= cpu_to_le16((unsigned short)~(WLAN_SET_CAP_INFO_SHORTSLOTTIME(1)));
-
-       // Copy SSID
-       sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
-       sFrame.len += ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len + WLAN_IEHDR_LEN;
-       memcpy(sFrame.pSSID,
-              pCurrSSID,
-              ((PWLAN_IE_SSID)pCurrSSID)->len + WLAN_IEHDR_LEN
-);
-       // Copy the rate set
-       sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
-
-       sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN;
-       memcpy(sFrame.pSuppRates,
-              pCurrSuppRates,
-              ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN
-);
-
-       // DS parameter
-       if (pDevice->eCurrentPHYType != PHY_TYPE_11A) {
-               sFrame.pDSParms = (PWLAN_IE_DS_PARMS)(sFrame.pBuf + sFrame.len);
-               sFrame.len += (1) + WLAN_IEHDR_LEN;
-               sFrame.pDSParms->byElementID = WLAN_EID_DS_PARMS;
-               sFrame.pDSParms->len = 1;
-               sFrame.pDSParms->byCurrChannel = (unsigned char)uCurrChannel;
-       }
-
-       if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP) {
-               // IBSS parameter
-               sFrame.pIBSSParms = (PWLAN_IE_IBSS_PARMS)(sFrame.pBuf + sFrame.len);
-               sFrame.len += (2) + WLAN_IEHDR_LEN;
-               sFrame.pIBSSParms->byElementID = WLAN_EID_IBSS_PARMS;
-               sFrame.pIBSSParms->len = 2;
-               sFrame.pIBSSParms->wATIMWindow = 0;
-       }
-       if (pDevice->eCurrentPHYType == PHY_TYPE_11G) {
-               sFrame.pERP = (PWLAN_IE_ERP)(sFrame.pBuf + sFrame.len);
-               sFrame.len += 1 + WLAN_IEHDR_LEN;
-               sFrame.pERP->byElementID = WLAN_EID_ERP;
-               sFrame.pERP->len = 1;
-               sFrame.pERP->byContext = 0;
-               if (pDevice->bProtectMode)
-                       sFrame.pERP->byContext |= WLAN_EID_ERP_USE_PROTECTION;
-               if (pDevice->bNonERPPresent)
-                       sFrame.pERP->byContext |= WLAN_EID_ERP_NONERP_PRESENT;
-               if (pDevice->bBarkerPreambleMd)
-                       sFrame.pERP->byContext |= WLAN_EID_ERP_BARKER_MODE;
-       }
-
-       if (pMgmt->b11hEnable && (pMgmt->eCurrentPHYMode == PHY_TYPE_11A)) {
-               // Country IE
-               pbyBuffer = (unsigned char *)(sFrame.pBuf + sFrame.len);
-               set_country_IE(pMgmt->pAdapter, pbyBuffer);
-               set_country_info(pMgmt->pAdapter, PHY_TYPE_11A, pbyBuffer);
-               uLength += ((PWLAN_IE_COUNTRY) pbyBuffer)->len + WLAN_IEHDR_LEN;
-               pbyBuffer += (((PWLAN_IE_COUNTRY) pbyBuffer)->len + WLAN_IEHDR_LEN);
-               // Power Constrain IE
-               ((PWLAN_IE_PW_CONST) pbyBuffer)->byElementID = WLAN_EID_PWR_CONSTRAINT;
-               ((PWLAN_IE_PW_CONST) pbyBuffer)->len = 1;
-               ((PWLAN_IE_PW_CONST) pbyBuffer)->byPower = 0;
-               pbyBuffer += (1) + WLAN_IEHDR_LEN;
-               uLength += (1) + WLAN_IEHDR_LEN;
-               if (pMgmt->bSwitchChannel) {
-                       // Channel Switch IE
-                       ((PWLAN_IE_CH_SW) pbyBuffer)->byElementID = WLAN_EID_CH_SWITCH;
-                       ((PWLAN_IE_CH_SW) pbyBuffer)->len = 3;
-                       ((PWLAN_IE_CH_SW) pbyBuffer)->byMode = 1;
-                       ((PWLAN_IE_CH_SW) pbyBuffer)->byChannel = get_channel_number(pMgmt->pAdapter, pMgmt->byNewChannel);
-                       ((PWLAN_IE_CH_SW) pbyBuffer)->byCount = 0;
-                       pbyBuffer += (3) + WLAN_IEHDR_LEN;
-                       uLength += (3) + WLAN_IEHDR_LEN;
-               }
-               // TPC report
-               ((PWLAN_IE_TPC_REP) pbyBuffer)->byElementID = WLAN_EID_TPC_REP;
-               ((PWLAN_IE_TPC_REP) pbyBuffer)->len = 2;
-               ((PWLAN_IE_TPC_REP) pbyBuffer)->byTxPower = CARDbyGetTransmitPower(pMgmt->pAdapter);
-               ((PWLAN_IE_TPC_REP) pbyBuffer)->byLinkMargin = 0;
-               pbyBuffer += (2) + WLAN_IEHDR_LEN;
-               uLength += (2) + WLAN_IEHDR_LEN;
-               // IBSS DFS
-               if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP) {
-                       pIBSSDFS = (PWLAN_IE_IBSS_DFS) pbyBuffer;
-                       pIBSSDFS->byElementID = WLAN_EID_IBSS_DFS;
-                       pIBSSDFS->len = 7;
-                       memcpy(pIBSSDFS->abyDFSOwner,
-                              pMgmt->abyIBSSDFSOwner,
-                              6);
-                       pIBSSDFS->byDFSRecovery = pMgmt->byIBSSDFSRecovery;
-                       pbyBuffer += (7) + WLAN_IEHDR_LEN;
-                       uLength += (7) + WLAN_IEHDR_LEN;
-                       for (ii = CB_MAX_CHANNEL_24G + 1; ii <= CB_MAX_CHANNEL; ii++) {
-                               if (get_channel_map_info(pMgmt->pAdapter, ii, pbyBuffer, pbyBuffer+1)) {
-                                       pbyBuffer += 2;
-                                       uLength += 2;
-                                       pIBSSDFS->len += 2;
-                               }
-                       }
-               }
-               sFrame.len += uLength;
-       }
-
-       if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) {
-               sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
-               sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN;
-               memcpy(sFrame.pExtSuppRates,
-                      pCurrExtSuppRates,
-                      ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN
-);
-       }
-
-       // hostapd wpa/wpa2 IE
-       if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && pDevice->bEnableHostapd) {
-               if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
-                       if (pMgmt->wWPAIELen != 0) {
-                               sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len);
-                               memcpy(sFrame.pRSN, pMgmt->abyWPAIE, pMgmt->wWPAIELen);
-                               sFrame.len += pMgmt->wWPAIELen;
-                       }
-               }
-       }
-
-       // Adjust the length fields
-       pTxPacket->cbMPDULen = sFrame.len;
-       pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
-
-       return pTxPacket;
-}
-
-/*+
- *
- * Routine Description:
- *  Constructs an association request frame
- *
- *
- * Return Value:
- *    A ptr to frame or NULL on allocation failure
- *
- -*/
-
-static PSTxMgmtPacket
-s_MgrMakeAssocRequest(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       unsigned char *pDAddr,
-       unsigned short wCurrCapInfo,
-       unsigned short wListenInterval,
-       PWLAN_IE_SSID pCurrSSID,
-       PWLAN_IE_SUPP_RATES pCurrRates,
-       PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-)
-{
-       PSTxMgmtPacket      pTxPacket = NULL;
-       WLAN_FR_ASSOCREQ    sFrame;
-       unsigned char *pbyIEs;
-       unsigned char *pbyRSN;
-
-       pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-       memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_ASSOCREQ_FR_MAXLEN);
-       pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket));
-       // Setup the sFrame structure.
-       sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header;
-       sFrame.len = WLAN_ASSOCREQ_FR_MAXLEN;
-       // format fixed field frame structure
-       vMgrEncodeAssocRequest(&sFrame);
-       // Setup the header
-       sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
-               (
-                       WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
-                       WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ASSOCREQ)
-));
-       memcpy(sFrame.pHdr->sA3.abyAddr1, pDAddr, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
-
-       // Set the capability and listen interval
-       *(sFrame.pwCapInfo) = cpu_to_le16(wCurrCapInfo);
-       *(sFrame.pwListenInterval) = cpu_to_le16(wListenInterval);
-
-       // sFrame.len point to end of fixed field
-       sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
-       sFrame.len += pCurrSSID->len + WLAN_IEHDR_LEN;
-       memcpy(sFrame.pSSID, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN);
-
-       pMgmt->sAssocInfo.AssocInfo.RequestIELength = pCurrSSID->len + WLAN_IEHDR_LEN;
-       pMgmt->sAssocInfo.AssocInfo.OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
-       pbyIEs = pMgmt->sAssocInfo.abyIEs;
-       memcpy(pbyIEs, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN);
-       pbyIEs += pCurrSSID->len + WLAN_IEHDR_LEN;
-
-       // Copy the rate set
-       sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
-       if ((pDevice->eCurrentPHYType == PHY_TYPE_11B) && (pCurrRates->len > 4))
-               sFrame.len += 4 + WLAN_IEHDR_LEN;
-       else
-               sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN;
-       memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
-
-       // Copy the extension rate set
-       if ((pDevice->eCurrentPHYType == PHY_TYPE_11G) && (pCurrExtSuppRates->len > 0)) {
-               sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
-               sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN;
-               memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN);
-       }
-
-       pMgmt->sAssocInfo.AssocInfo.RequestIELength += pCurrRates->len + WLAN_IEHDR_LEN;
-       memcpy(pbyIEs, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
-       pbyIEs += pCurrRates->len + WLAN_IEHDR_LEN;
-
-       // for 802.11h
-       if (pMgmt->b11hEnable) {
-               if (sFrame.pCurrPowerCap == NULL) {
-                       sFrame.pCurrPowerCap = (PWLAN_IE_PW_CAP)(sFrame.pBuf + sFrame.len);
-                       sFrame.len += (2 + WLAN_IEHDR_LEN);
-                       sFrame.pCurrPowerCap->byElementID = WLAN_EID_PWR_CAPABILITY;
-                       sFrame.pCurrPowerCap->len = 2;
-                       CARDvGetPowerCapability(pMgmt->pAdapter,
-                                               &(sFrame.pCurrPowerCap->byMinPower),
-                                               &(sFrame.pCurrPowerCap->byMaxPower)
-);
-               }
-               if (sFrame.pCurrSuppCh == NULL) {
-                       sFrame.pCurrSuppCh = (PWLAN_IE_SUPP_CH)(sFrame.pBuf + sFrame.len);
-                       sFrame.len += set_support_channels(pMgmt->pAdapter, (unsigned char *)sFrame.pCurrSuppCh);
-               }
-       }
-
-       if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA) ||
-            (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) ||
-            (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE)) &&
-           (pMgmt->pCurrBSS != NULL)) {
-               /* WPA IE */
-               sFrame.pRSNWPA = (PWLAN_IE_RSN_EXT)(sFrame.pBuf + sFrame.len);
-               sFrame.pRSNWPA->byElementID = WLAN_EID_RSN_WPA;
-               sFrame.pRSNWPA->len = 16;
-               sFrame.pRSNWPA->abyOUI[0] = 0x00;
-               sFrame.pRSNWPA->abyOUI[1] = 0x50;
-               sFrame.pRSNWPA->abyOUI[2] = 0xf2;
-               sFrame.pRSNWPA->abyOUI[3] = 0x01;
-               sFrame.pRSNWPA->wVersion = 1;
-               //Group Key Cipher Suite
-               sFrame.pRSNWPA->abyMulticast[0] = 0x00;
-               sFrame.pRSNWPA->abyMulticast[1] = 0x50;
-               sFrame.pRSNWPA->abyMulticast[2] = 0xf2;
-               if (pMgmt->byCSSGK == KEY_CTL_WEP)
-                       sFrame.pRSNWPA->abyMulticast[3] = pMgmt->pCurrBSS->byGKType;
-               else if (pMgmt->byCSSGK == KEY_CTL_TKIP)
-                       sFrame.pRSNWPA->abyMulticast[3] = WPA_TKIP;
-               else if (pMgmt->byCSSGK == KEY_CTL_CCMP)
-                       sFrame.pRSNWPA->abyMulticast[3] = WPA_AESCCMP;
-               else
-                       sFrame.pRSNWPA->abyMulticast[3] = WPA_NONE;
-
-               // Pairwise Key Cipher Suite
-               sFrame.pRSNWPA->wPKCount = 1;
-               sFrame.pRSNWPA->PKSList[0].abyOUI[0] = 0x00;
-               sFrame.pRSNWPA->PKSList[0].abyOUI[1] = 0x50;
-               sFrame.pRSNWPA->PKSList[0].abyOUI[2] = 0xf2;
-               if (pMgmt->byCSSPK == KEY_CTL_TKIP)
-                       sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_TKIP;
-               else if (pMgmt->byCSSPK == KEY_CTL_CCMP)
-                       sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_AESCCMP;
-               else
-                       sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_NONE;
-
-               // Auth Key Management Suite
-               pbyRSN = (unsigned char *)(sFrame.pBuf + sFrame.len + 2 + sFrame.pRSNWPA->len);
-               *pbyRSN++ = 0x01;
-               *pbyRSN++ = 0x00;
-               *pbyRSN++ = 0x00;
-
-               *pbyRSN++ = 0x50;
-               *pbyRSN++ = 0xf2;
-               if (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK)
-                       *pbyRSN++ = WPA_AUTH_PSK;
-               else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA)
-                       *pbyRSN++ = WPA_AUTH_IEEE802_1X;
-               else
-                       *pbyRSN++ = WPA_NONE;
-
-               sFrame.pRSNWPA->len += 6;
-
-               // RSN Capabilities
-
-               *pbyRSN++ = 0x00;
-               *pbyRSN++ = 0x00;
-               sFrame.pRSNWPA->len += 2;
-
-               sFrame.len += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
-               // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
-               pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
-               memcpy(pbyIEs, sFrame.pRSNWPA, sFrame.pRSNWPA->len + WLAN_IEHDR_LEN);
-               pbyIEs += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
-
-       } else if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
-                   (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) &&
-                  (pMgmt->pCurrBSS != NULL)) {
-               unsigned int ii;
-               unsigned short *pwPMKID;
-
-               // WPA IE
-               sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len);
-               sFrame.pRSN->byElementID = WLAN_EID_RSN;
-               sFrame.pRSN->len = 6; //Version(2)+GK(4)
-               sFrame.pRSN->wVersion = 1;
-               //Group Key Cipher Suite
-               sFrame.pRSN->abyRSN[0] = 0x00;
-               sFrame.pRSN->abyRSN[1] = 0x0F;
-               sFrame.pRSN->abyRSN[2] = 0xAC;
-               if (pMgmt->byCSSGK == KEY_CTL_WEP)
-                       sFrame.pRSN->abyRSN[3] = pMgmt->pCurrBSS->byCSSGK;
-               else if (pMgmt->byCSSGK == KEY_CTL_TKIP)
-                       sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_TKIP;
-               else if (pMgmt->byCSSGK == KEY_CTL_CCMP)
-                       sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_CCMP;
-               else
-                       sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_UNKNOWN;
-
-               // Pairwise Key Cipher Suite
-               sFrame.pRSN->abyRSN[4] = 1;
-               sFrame.pRSN->abyRSN[5] = 0;
-               sFrame.pRSN->abyRSN[6] = 0x00;
-               sFrame.pRSN->abyRSN[7] = 0x0F;
-               sFrame.pRSN->abyRSN[8] = 0xAC;
-               if (pMgmt->byCSSPK == KEY_CTL_TKIP)
-                       sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_TKIP;
-               else if (pMgmt->byCSSPK == KEY_CTL_CCMP)
-                       sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_CCMP;
-               else if (pMgmt->byCSSPK == KEY_CTL_NONE)
-                       sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_USE_GROUP;
-               else
-                       sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_UNKNOWN;
-
-               sFrame.pRSN->len += 6;
-
-               // Auth Key Management Suite
-               sFrame.pRSN->abyRSN[10] = 1;
-               sFrame.pRSN->abyRSN[11] = 0;
-               sFrame.pRSN->abyRSN[12] = 0x00;
-               sFrame.pRSN->abyRSN[13] = 0x0F;
-               sFrame.pRSN->abyRSN[14] = 0xAC;
-               if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)
-                       sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_PSK;
-               else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)
-                       sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_802_1X;
-               else
-                       sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_UNKNOWN;
-
-               sFrame.pRSN->len += 6;
-
-               // RSN Capabilities
-               if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist) {
-                       memcpy(&sFrame.pRSN->abyRSN[16], &pMgmt->pCurrBSS->sRSNCapObj.wRSNCap, 2);
-               } else {
-                       sFrame.pRSN->abyRSN[16] = 0;
-                       sFrame.pRSN->abyRSN[17] = 0;
-               }
-               sFrame.pRSN->len += 2;
-
-               if ((pDevice->gsPMKID.BSSIDInfoCount > 0) && pDevice->bRoaming && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) {
-                       // RSN PMKID
-                       pbyRSN = &sFrame.pRSN->abyRSN[18];
-                       pwPMKID = (unsigned short *)pbyRSN; // Point to PMKID count
-                       *pwPMKID = 0;            // Initialize PMKID count
-                       pbyRSN += 2;             // Point to PMKID list
-                       for (ii = 0; ii < pDevice->gsPMKID.BSSIDInfoCount; ii++) {
-                               if (!memcmp(&pDevice->gsPMKID.BSSIDInfo[ii].BSSID[0], pMgmt->abyCurrBSSID, ETH_ALEN)) {
-                                       (*pwPMKID)++;
-                                       memcpy(pbyRSN, pDevice->gsPMKID.BSSIDInfo[ii].PMKID, 16);
-                                       pbyRSN += 16;
-                               }
-                       }
-                       if (*pwPMKID != 0)
-                               sFrame.pRSN->len += (2 + (*pwPMKID)*16);
-               }
-
-               sFrame.len += sFrame.pRSN->len + WLAN_IEHDR_LEN;
-               // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
-               pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSN->len + WLAN_IEHDR_LEN;
-               memcpy(pbyIEs, sFrame.pRSN, sFrame.pRSN->len + WLAN_IEHDR_LEN);
-               pbyIEs += sFrame.pRSN->len + WLAN_IEHDR_LEN;
-       }
-
-       // Adjust the length fields
-       pTxPacket->cbMPDULen = sFrame.len;
-       pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
-       return pTxPacket;
-}
-
-/*+
- *
- * Routine Description:
- *  Constructs an re-association request frame
- *
- *
- * Return Value:
- *    A ptr to frame or NULL on allocation failure
- *
- -*/
-
-static PSTxMgmtPacket
-s_MgrMakeReAssocRequest(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       unsigned char *pDAddr,
-       unsigned short wCurrCapInfo,
-       unsigned short wListenInterval,
-       PWLAN_IE_SSID pCurrSSID,
-       PWLAN_IE_SUPP_RATES pCurrRates,
-       PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-)
-{
-       PSTxMgmtPacket      pTxPacket = NULL;
-       WLAN_FR_REASSOCREQ  sFrame;
-       unsigned char *pbyIEs;
-       unsigned char *pbyRSN;
-
-       pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-       memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_REASSOCREQ_FR_MAXLEN);
-       pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket));
-       /* Setup the sFrame structure. */
-       sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header;
-       sFrame.len = WLAN_REASSOCREQ_FR_MAXLEN;
-
-       // format fixed field frame structure
-       vMgrEncodeReassocRequest(&sFrame);
-
-       /* Setup the header */
-       sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
-               (
-                       WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
-                       WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_REASSOCREQ)
-));
-       memcpy(sFrame.pHdr->sA3.abyAddr1, pDAddr, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
-
-       /* Set the capability and listen interval */
-       *(sFrame.pwCapInfo) = cpu_to_le16(wCurrCapInfo);
-       *(sFrame.pwListenInterval) = cpu_to_le16(wListenInterval);
-
-       memcpy(sFrame.pAddrCurrAP, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
-       /* Copy the SSID */
-       /* sFrame.len point to end of fixed field */
-       sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
-       sFrame.len += pCurrSSID->len + WLAN_IEHDR_LEN;
-       memcpy(sFrame.pSSID, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN);
-
-       pMgmt->sAssocInfo.AssocInfo.RequestIELength = pCurrSSID->len + WLAN_IEHDR_LEN;
-       pMgmt->sAssocInfo.AssocInfo.OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
-       pbyIEs = pMgmt->sAssocInfo.abyIEs;
-       memcpy(pbyIEs, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN);
-       pbyIEs += pCurrSSID->len + WLAN_IEHDR_LEN;
-
-       /* Copy the rate set */
-       /* sFrame.len point to end of SSID */
-       sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
-       sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN;
-       memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
-
-       // Copy the extension rate set
-       if ((pMgmt->eCurrentPHYMode == PHY_TYPE_11G) && (pCurrExtSuppRates->len > 0)) {
-               sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
-               sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN;
-               memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN);
-       }
-
-       pMgmt->sAssocInfo.AssocInfo.RequestIELength += pCurrRates->len + WLAN_IEHDR_LEN;
-       memcpy(pbyIEs, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
-       pbyIEs += pCurrRates->len + WLAN_IEHDR_LEN;
-
-       if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA) ||
-            (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) ||
-            (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE)) &&
-           (pMgmt->pCurrBSS != NULL)) {
-               /* WPA IE */
-               sFrame.pRSNWPA = (PWLAN_IE_RSN_EXT)(sFrame.pBuf + sFrame.len);
-               sFrame.pRSNWPA->byElementID = WLAN_EID_RSN_WPA;
-               sFrame.pRSNWPA->len = 16;
-               sFrame.pRSNWPA->abyOUI[0] = 0x00;
-               sFrame.pRSNWPA->abyOUI[1] = 0x50;
-               sFrame.pRSNWPA->abyOUI[2] = 0xf2;
-               sFrame.pRSNWPA->abyOUI[3] = 0x01;
-               sFrame.pRSNWPA->wVersion = 1;
-               //Group Key Cipher Suite
-               sFrame.pRSNWPA->abyMulticast[0] = 0x00;
-               sFrame.pRSNWPA->abyMulticast[1] = 0x50;
-               sFrame.pRSNWPA->abyMulticast[2] = 0xf2;
-               if (pMgmt->byCSSGK == KEY_CTL_WEP)
-                       sFrame.pRSNWPA->abyMulticast[3] = pMgmt->pCurrBSS->byGKType;
-               else if (pMgmt->byCSSGK == KEY_CTL_TKIP)
-                       sFrame.pRSNWPA->abyMulticast[3] = WPA_TKIP;
-               else if (pMgmt->byCSSGK == KEY_CTL_CCMP)
-                       sFrame.pRSNWPA->abyMulticast[3] = WPA_AESCCMP;
-               else
-                       sFrame.pRSNWPA->abyMulticast[3] = WPA_NONE;
-
-               // Pairwise Key Cipher Suite
-               sFrame.pRSNWPA->wPKCount = 1;
-               sFrame.pRSNWPA->PKSList[0].abyOUI[0] = 0x00;
-               sFrame.pRSNWPA->PKSList[0].abyOUI[1] = 0x50;
-               sFrame.pRSNWPA->PKSList[0].abyOUI[2] = 0xf2;
-               if (pMgmt->byCSSPK == KEY_CTL_TKIP)
-                       sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_TKIP;
-               else if (pMgmt->byCSSPK == KEY_CTL_CCMP)
-                       sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_AESCCMP;
-               else
-                       sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_NONE;
-
-               // Auth Key Management Suite
-               pbyRSN = (unsigned char *)(sFrame.pBuf + sFrame.len + 2 + sFrame.pRSNWPA->len);
-               *pbyRSN++ = 0x01;
-               *pbyRSN++ = 0x00;
-               *pbyRSN++ = 0x00;
-
-               *pbyRSN++ = 0x50;
-               *pbyRSN++ = 0xf2;
-               if (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK)
-                       *pbyRSN++ = WPA_AUTH_PSK;
-               else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA)
-                       *pbyRSN++ = WPA_AUTH_IEEE802_1X;
-               else
-                       *pbyRSN++ = WPA_NONE;
-
-               sFrame.pRSNWPA->len += 6;
-
-               // RSN Capabilities
-               *pbyRSN++ = 0x00;
-               *pbyRSN++ = 0x00;
-               sFrame.pRSNWPA->len += 2;
-
-               sFrame.len += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
-               // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
-               pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
-               memcpy(pbyIEs, sFrame.pRSNWPA, sFrame.pRSNWPA->len + WLAN_IEHDR_LEN);
-               pbyIEs += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
-
-       } else if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
-                   (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) &&
-                  (pMgmt->pCurrBSS != NULL)) {
-               unsigned int ii;
-               unsigned short *pwPMKID;
-
-               /* WPA IE */
-               sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len);
-               sFrame.pRSN->byElementID = WLAN_EID_RSN;
-               sFrame.pRSN->len = 6; //Version(2)+GK(4)
-               sFrame.pRSN->wVersion = 1;
-               //Group Key Cipher Suite
-               sFrame.pRSN->abyRSN[0] = 0x00;
-               sFrame.pRSN->abyRSN[1] = 0x0F;
-               sFrame.pRSN->abyRSN[2] = 0xAC;
-               if (pMgmt->byCSSGK == KEY_CTL_WEP)
-                       sFrame.pRSN->abyRSN[3] = pMgmt->pCurrBSS->byCSSGK;
-               else if (pMgmt->byCSSGK == KEY_CTL_TKIP)
-                       sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_TKIP;
-               else if (pMgmt->byCSSGK == KEY_CTL_CCMP)
-                       sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_CCMP;
-               else
-                       sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_UNKNOWN;
-
-               // Pairwise Key Cipher Suite
-               sFrame.pRSN->abyRSN[4] = 1;
-               sFrame.pRSN->abyRSN[5] = 0;
-               sFrame.pRSN->abyRSN[6] = 0x00;
-               sFrame.pRSN->abyRSN[7] = 0x0F;
-               sFrame.pRSN->abyRSN[8] = 0xAC;
-               if (pMgmt->byCSSPK == KEY_CTL_TKIP)
-                       sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_TKIP;
-               else if (pMgmt->byCSSPK == KEY_CTL_CCMP)
-                       sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_CCMP;
-               else if (pMgmt->byCSSPK == KEY_CTL_NONE)
-                       sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_USE_GROUP;
-               else
-                       sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_UNKNOWN;
-
-               sFrame.pRSN->len += 6;
-
-               // Auth Key Management Suite
-               sFrame.pRSN->abyRSN[10] = 1;
-               sFrame.pRSN->abyRSN[11] = 0;
-               sFrame.pRSN->abyRSN[12] = 0x00;
-               sFrame.pRSN->abyRSN[13] = 0x0F;
-               sFrame.pRSN->abyRSN[14] = 0xAC;
-               if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)
-                       sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_PSK;
-               else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)
-                       sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_802_1X;
-               else
-                       sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_UNKNOWN;
-
-               sFrame.pRSN->len += 6;
-
-               // RSN Capabilities
-               if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist) {
-                       memcpy(&sFrame.pRSN->abyRSN[16], &pMgmt->pCurrBSS->sRSNCapObj.wRSNCap, 2);
-               } else {
-                       sFrame.pRSN->abyRSN[16] = 0;
-                       sFrame.pRSN->abyRSN[17] = 0;
-               }
-               sFrame.pRSN->len += 2;
-
-               if ((pDevice->gsPMKID.BSSIDInfoCount > 0) && pDevice->bRoaming && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) {
-                       // RSN PMKID
-                       pbyRSN = &sFrame.pRSN->abyRSN[18];
-                       pwPMKID = (unsigned short *)pbyRSN; // Point to PMKID count
-                       *pwPMKID = 0;            // Initialize PMKID count
-                       pbyRSN += 2;             // Point to PMKID list
-                       for (ii = 0; ii < pDevice->gsPMKID.BSSIDInfoCount; ii++) {
-                               if (!memcmp(&pDevice->gsPMKID.BSSIDInfo[ii].BSSID[0], pMgmt->abyCurrBSSID, ETH_ALEN)) {
-                                       (*pwPMKID)++;
-                                       memcpy(pbyRSN, pDevice->gsPMKID.BSSIDInfo[ii].PMKID, 16);
-                                       pbyRSN += 16;
-                               }
-                       }
-
-                       if (*pwPMKID != 0)
-                               sFrame.pRSN->len += (2 + (*pwPMKID) * 16);
-               }
-
-               sFrame.len += sFrame.pRSN->len + WLAN_IEHDR_LEN;
-               // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
-               pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSN->len + WLAN_IEHDR_LEN;
-               memcpy(pbyIEs, sFrame.pRSN, sFrame.pRSN->len + WLAN_IEHDR_LEN);
-               pbyIEs += sFrame.pRSN->len + WLAN_IEHDR_LEN;
-       }
-
-       /* Adjust the length fields */
-       pTxPacket->cbMPDULen = sFrame.len;
-       pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
-
-       return pTxPacket;
-}
-
-/*+
- *
- * Routine Description:
- *  Constructs an assoc-response frame
- *
- *
- * Return Value:
- *    PTR to frame; or NULL on allocation failure
- *
- -*/
-
-static PSTxMgmtPacket
-s_MgrMakeAssocResponse(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       unsigned short wCurrCapInfo,
-       unsigned short wAssocStatus,
-       unsigned short wAssocAID,
-       unsigned char *pDstAddr,
-       PWLAN_IE_SUPP_RATES pCurrSuppRates,
-       PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-)
-{
-       PSTxMgmtPacket      pTxPacket = NULL;
-       WLAN_FR_ASSOCRESP   sFrame;
-
-       pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-       memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_ASSOCREQ_FR_MAXLEN);
-       pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket));
-       // Setup the sFrame structure
-       sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header;
-       sFrame.len = WLAN_REASSOCRESP_FR_MAXLEN;
-       vMgrEncodeAssocResponse(&sFrame);
-       // Setup the header
-       sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
-               (
-                       WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
-                       WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ASSOCRESP)
-));
-       memcpy(sFrame.pHdr->sA3.abyAddr1, pDstAddr, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
-
-       *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo);
-       *sFrame.pwStatus = cpu_to_le16(wAssocStatus);
-       *sFrame.pwAid = cpu_to_le16((unsigned short)(wAssocAID | BIT14 | BIT15));
-
-       // Copy the rate set
-       sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
-       sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN;
-       memcpy(sFrame.pSuppRates,
-              pCurrSuppRates,
-              ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN
-);
-
-       if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) {
-               sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
-               sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN;
-               memcpy(sFrame.pExtSuppRates,
-                      pCurrExtSuppRates,
-                      ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN
-);
-       }
-
-       // Adjust the length fields
-       pTxPacket->cbMPDULen = sFrame.len;
-       pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
-
-       return pTxPacket;
-}
-
-/*+
- *
- * Routine Description:
- *  Constructs an reassoc-response frame
- *
- *
- * Return Value:
- *    PTR to frame; or NULL on allocation failure
- *
- -*/
-
-static PSTxMgmtPacket
-s_MgrMakeReAssocResponse(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       unsigned short wCurrCapInfo,
-       unsigned short wAssocStatus,
-       unsigned short wAssocAID,
-       unsigned char *pDstAddr,
-       PWLAN_IE_SUPP_RATES pCurrSuppRates,
-       PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-)
-{
-       PSTxMgmtPacket      pTxPacket = NULL;
-       WLAN_FR_REASSOCRESP   sFrame;
-
-       pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-       memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_ASSOCREQ_FR_MAXLEN);
-       pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket));
-       // Setup the sFrame structure
-       sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header;
-       sFrame.len = WLAN_REASSOCRESP_FR_MAXLEN;
-       vMgrEncodeReassocResponse(&sFrame);
-       // Setup the header
-       sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
-               (
-                       WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
-                       WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_REASSOCRESP)
-));
-       memcpy(sFrame.pHdr->sA3.abyAddr1, pDstAddr, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
-       memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
-
-       *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo);
-       *sFrame.pwStatus = cpu_to_le16(wAssocStatus);
-       *sFrame.pwAid = cpu_to_le16((unsigned short)(wAssocAID | BIT14 | BIT15));
-
-       // Copy the rate set
-       sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
-       sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN;
-       memcpy(sFrame.pSuppRates,
-              pCurrSuppRates,
-              ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN
-);
-
-       if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) {
-               sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
-               sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN;
-               memcpy(sFrame.pExtSuppRates,
-                      pCurrExtSuppRates,
-                      ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN
-);
-       }
-
-       // Adjust the length fields
-       pTxPacket->cbMPDULen = sFrame.len;
-       pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
-
-       return pTxPacket;
-}
-
-/*+
- *
- * Routine Description:
- *  Handles probe response management frames.
- *
- *
- * Return Value:
- *    none.
- *
- -*/
-
-static
-void
-s_vMgrRxProbeResponse(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket
-)
-{
-       PKnownBSS           pBSSList = NULL;
-       WLAN_FR_PROBERESP   sFrame;
-       unsigned char byCurrChannel = pRxPacket->byRxChannel;
-       ERPObject           sERP;
-       unsigned char byIEChannel = 0;
-       bool bChannelHit = true;
-
-       memset(&sFrame, 0, sizeof(WLAN_FR_PROBERESP));
-       // decode the frame
-       sFrame.len = pRxPacket->cbMPDULen;
-       sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header;
-       vMgrDecodeProbeResponse(&sFrame);
-
-       if ((sFrame.pqwTimestamp == NULL) ||
-           (sFrame.pwBeaconInterval == NULL) ||
-           (sFrame.pwCapInfo == NULL) ||
-           (sFrame.pSSID == NULL) ||
-           (sFrame.pSuppRates == NULL)) {
-               pr_debug("Probe resp:Fail addr:[%p]\n",
-                        pRxPacket->p80211Header);
-               DBG_PORT80(0xCC);
-               return;
-       }
-
-       if (sFrame.pSSID->len == 0)
-               pr_debug("Rx Probe resp: SSID len = 0\n");
-
-       if (sFrame.pDSParms != NULL) {
-               if (byCurrChannel > CB_MAX_CHANNEL_24G) {
-                       // channel remapping to
-                       byIEChannel = get_channel_mapping(pMgmt->pAdapter, sFrame.pDSParms->byCurrChannel, PHY_TYPE_11A);
-               } else {
-                       byIEChannel = sFrame.pDSParms->byCurrChannel;
-               }
-               if (byCurrChannel != byIEChannel) {
-                       // adjust channel info. bcs we rcv adjacent channel packets
-                       bChannelHit = false;
-                       byCurrChannel = byIEChannel;
-               }
-       } else {
-               // no DS channel info
-               bChannelHit = true;
-       }
-
-//2008-0730-01<Add>by MikeLiu
-       if (ChannelExceedZoneType(pDevice, byCurrChannel))
-               return;
-
-       if (sFrame.pERP != NULL) {
-               sERP.byERP = sFrame.pERP->byContext;
-               sERP.bERPExist = true;
-       } else {
-               sERP.bERPExist = false;
-               sERP.byERP = 0;
-       }
-
-       // update or insert the bss
-       pBSSList = BSSpAddrIsInBSSList((void *)pDevice, sFrame.pHdr->sA3.abyAddr3, sFrame.pSSID);
-       if (pBSSList) {
-               BSSbUpdateToBSSList((void *)pDevice,
-                                   *sFrame.pqwTimestamp,
-                                   *sFrame.pwBeaconInterval,
-                                   *sFrame.pwCapInfo,
-                                   byCurrChannel,
-                                   bChannelHit,
-                                   sFrame.pSSID,
-                                   sFrame.pSuppRates,
-                                   sFrame.pExtSuppRates,
-                                   &sERP,
-                                   sFrame.pRSN,
-                                   sFrame.pRSNWPA,
-                                   sFrame.pIE_Country,
-                                   sFrame.pIE_Quiet,
-                                   pBSSList,
-                                   sFrame.len - WLAN_HDR_ADDR3_LEN,
-                                   sFrame.pHdr->sA4.abyAddr4,   // payload of probresponse
-                                   (void *)pRxPacket
-);
-       } else {
-               pr_debug("Probe resp/insert: RxChannel = : %d\n",
-                        byCurrChannel);
-               BSSbInsertToBSSList((void *)pDevice,
-                                   sFrame.pHdr->sA3.abyAddr3,
-                                   *sFrame.pqwTimestamp,
-                                   *sFrame.pwBeaconInterval,
-                                   *sFrame.pwCapInfo,
-                                   byCurrChannel,
-                                   sFrame.pSSID,
-                                   sFrame.pSuppRates,
-                                   sFrame.pExtSuppRates,
-                                   &sERP,
-                                   sFrame.pRSN,
-                                   sFrame.pRSNWPA,
-                                   sFrame.pIE_Country,
-                                   sFrame.pIE_Quiet,
-                                   sFrame.len - WLAN_HDR_ADDR3_LEN,
-                                   sFrame.pHdr->sA4.abyAddr4,   // payload of beacon
-                                   (void *)pRxPacket
-);
-       }
-}
-
-/*+
- *
- * Routine Description:(AP)or(Ad-hoc STA)
- *  Handles probe request management frames.
- *
- *
- * Return Value:
- *    none.
- *
- -*/
-
-static
-void
-s_vMgrRxProbeRequest(
-       struct vnt_private *pDevice,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket
-)
-{
-       WLAN_FR_PROBEREQ    sFrame;
-       CMD_STATUS          Status;
-       PSTxMgmtPacket      pTxPacket;
-       unsigned char byPHYType = BB_TYPE_11B;
-
-       // STA in Ad-hoc mode: when latest TBTT beacon transmit success,
-       // STA have to response this request.
-       if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) ||
-           ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && pDevice->bBeaconSent)) {
-               memset(&sFrame, 0, sizeof(WLAN_FR_PROBEREQ));
-               // decode the frame
-               sFrame.len = pRxPacket->cbMPDULen;
-               sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header;
-               vMgrDecodeProbeRequest(&sFrame);
-
-               if (sFrame.pSSID->len != 0) {
-                       if (sFrame.pSSID->len != ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len)
-                               return;
-                       if (memcmp(sFrame.pSSID->abySSID,
-                                  ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID,
-                                  ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) != 0) {
-                               return;
-                       }
-               }
-
-               if ((sFrame.pSuppRates->len > 4) || (sFrame.pExtSuppRates != NULL))
-                       byPHYType = BB_TYPE_11G;
-
-               // Probe response reply..
-               pTxPacket = s_MgrMakeProbeResponse
-                       (
-                               pDevice,
-                               pMgmt,
-                               pMgmt->wCurrCapInfo,
-                               pMgmt->wCurrBeaconPeriod,
-                               pMgmt->uCurrChannel,
-                               0,
-                               sFrame.pHdr->sA3.abyAddr2,
-                               (PWLAN_IE_SSID)pMgmt->abyCurrSSID,
-                               (unsigned char *)pMgmt->abyCurrBSSID,
-                               (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                               (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
-                               byPHYType
-);
-               if (pTxPacket != NULL) {
-                       /* send the frame */
-                       Status = csMgmt_xmit(pDevice, pTxPacket);
-                       if (Status != CMD_STATUS_PENDING)
-                               pr_debug("Mgt:Probe response tx failed\n");
-               }
-       }
-}
-
-/*+
- *
- * Routine Description:
- *
- *  Entry point for the reception and handling of 802.11 management
- *  frames. Makes a determination of the frame type and then calls
- *  the appropriate function.
- *
- *
- * Return Value:
- *    none.
- *
- -*/
-
-void
-vMgrRxManagePacket(
-       void *hDeviceContext,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       bool bInScan = false;
-       unsigned int uNodeIndex = 0;
-       NODE_STATE  eNodeState = 0;
-       CMD_STATUS  Status;
-
-       if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
-               if (BSSDBbIsSTAInNodeDB(pMgmt, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex))
-                       eNodeState = pMgmt->sNodeDBTable[uNodeIndex].eNodeState;
-       }
-
-       switch (WLAN_GET_FC_FSTYPE((pRxPacket->p80211Header->sA3.wFrameCtl))) {
-       case WLAN_FSTYPE_ASSOCREQ:
-               // Frame Clase = 2
-               pr_debug("rx assocreq\n");
-               if (eNodeState < NODE_AUTH) {
-                       // send deauth notification
-                       // reason = (6) class 2 received from nonauth sta
-                       vMgrDeAuthenBeginSta(pDevice,
-                                            pMgmt,
-                                            pRxPacket->p80211Header->sA3.abyAddr2,
-                                            (6),
-                                            &Status
-);
-                       pr_debug("wmgr: send vMgrDeAuthenBeginSta 1\n");
-               } else {
-                       s_vMgrRxAssocRequest(pDevice, pMgmt, pRxPacket, uNodeIndex);
-               }
-               break;
-
-       case WLAN_FSTYPE_ASSOCRESP:
-               // Frame Clase = 2
-               pr_debug("rx assocresp1\n");
-               s_vMgrRxAssocResponse(pDevice, pMgmt, pRxPacket, false);
-               pr_debug("rx assocresp2\n");
-               break;
-
-       case WLAN_FSTYPE_REASSOCREQ:
-               // Frame Clase = 2
-               pr_debug("rx reassocreq\n");
-               // Todo: reassoc
-               if (eNodeState < NODE_AUTH) {
-                       // send deauth notification
-                       // reason = (6) class 2 received from nonauth sta
-                       vMgrDeAuthenBeginSta(pDevice,
-                                            pMgmt,
-                                            pRxPacket->p80211Header->sA3.abyAddr2,
-                                            (6),
-                                            &Status
-);
-                       pr_debug("wmgr: send vMgrDeAuthenBeginSta 2\n");
-
-               }
-               s_vMgrRxReAssocRequest(pDevice, pMgmt, pRxPacket, uNodeIndex);
-               break;
-
-       case WLAN_FSTYPE_REASSOCRESP:
-               // Frame Clase = 2
-               pr_debug("rx reassocresp\n");
-               s_vMgrRxAssocResponse(pDevice, pMgmt, pRxPacket, true);
-               break;
-
-       case WLAN_FSTYPE_PROBEREQ:
-               // Frame Clase = 0
-               s_vMgrRxProbeRequest(pDevice, pMgmt, pRxPacket);
-               break;
-
-       case WLAN_FSTYPE_PROBERESP:
-               // Frame Clase = 0
-               pr_debug("rx proberesp\n");
-
-               s_vMgrRxProbeResponse(pDevice, pMgmt, pRxPacket);
-               break;
-
-       case WLAN_FSTYPE_BEACON:
-               // Frame Clase = 0
-               if (pMgmt->eScanState != WMAC_NO_SCANNING)
-                       bInScan = true;
-
-               s_vMgrRxBeacon(pDevice, pMgmt, pRxPacket, bInScan);
-               break;
-
-       case WLAN_FSTYPE_ATIM:
-               // Frame Clase = 1
-               pr_debug("rx atim\n");
-               break;
-
-       case WLAN_FSTYPE_DISASSOC:
-               // Frame Clase = 2
-               pr_debug("rx disassoc\n");
-               if (eNodeState < NODE_AUTH) {
-                       // send deauth notification
-                       // reason = (6) class 2 received from nonauth sta
-                       vMgrDeAuthenBeginSta(pDevice,
-                                            pMgmt,
-                                            pRxPacket->p80211Header->sA3.abyAddr2,
-                                            (6),
-                                            &Status
-);
-                       pr_debug("wmgr: send vMgrDeAuthenBeginSta 3\n");
-               }
-               s_vMgrRxDisassociation(pDevice, pMgmt, pRxPacket);
-               break;
-
-       case WLAN_FSTYPE_AUTHEN:
-               // Frame Clase = 1
-               pr_debug("rx authen\n");
-               s_vMgrRxAuthentication(pDevice, pMgmt, pRxPacket);
-               break;
-
-       case WLAN_FSTYPE_DEAUTHEN:
-               // Frame Clase = 1
-               pr_debug("rx deauthen\n");
-               s_vMgrRxDeauthentication(pDevice, pMgmt, pRxPacket);
-               break;
-
-       default:
-               pr_debug("rx unknown mgmt\n");
-       }
-}
-
-/*+
- *
- * Routine Description:
- *
- *
- *  Prepare beacon to send
- *
- * Return Value:
- *    true if success; false if failed.
- *
- -*/
-bool
-bMgrPrepareBeaconToSend(
-       void *hDeviceContext,
-       PSMgmtObject pMgmt
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       PSTxMgmtPacket      pTxPacket;
-
-       if (pDevice->bEncryptionEnable || pDevice->bEnable8021x)
-               pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1);
-       else
-               pMgmt->wCurrCapInfo &= ~WLAN_SET_CAP_INFO_PRIVACY(1);
-
-       pTxPacket = s_MgrMakeBeacon
-               (
-                       pDevice,
-                       pMgmt,
-                       pMgmt->wCurrCapInfo,
-                       pMgmt->wCurrBeaconPeriod,
-                       pMgmt->uCurrChannel,
-                       pMgmt->wCurrATIMWindow,
-                       (PWLAN_IE_SSID)pMgmt->abyCurrSSID,
-                       (unsigned char *)pMgmt->abyCurrBSSID,
-                       (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
-                       (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates
-);
-
-       if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
-           (pMgmt->abyCurrBSSID[0] == 0))
-               return false;
-
-       csBeacon_xmit(pDevice, pTxPacket);
-
-       return true;
-}
-
-/*+
- *
- * Routine Description:
- *
- *  Log a warning message based on the contents of the Status
- *  Code field of an 802.11 management frame.  Defines are
- *  derived from 802.11-1997 SPEC.
- *
- * Return Value:
- *    none.
- *
- -*/
-static
-void
-s_vMgrLogStatus(
-       PSMgmtObject pMgmt,
-       unsigned short wStatus
-)
-{
-       switch (wStatus) {
-       case WLAN_MGMT_STATUS_UNSPEC_FAILURE:
-               pr_info("Status code == Unspecified error\n");
-               break;
-       case WLAN_MGMT_STATUS_CAPS_UNSUPPORTED:
-               pr_info("Status code == Can't support all requested capabilities\n");
-               break;
-       case WLAN_MGMT_STATUS_REASSOC_NO_ASSOC:
-               pr_info("Status code == Reassoc denied, can't confirm original Association\n");
-               break;
-       case WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC:
-               pr_info("Status code == Assoc denied, undefine in spec\n");
-               break;
-       case WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG:
-               pr_info("Status code == Peer doesn't support authen algorithm\n");
-               break;
-       case WLAN_MGMT_STATUS_RX_AUTH_NOSEQ:
-               pr_info("Status code == Authen frame received out of sequence\n");
-               break;
-       case WLAN_MGMT_STATUS_CHALLENGE_FAIL:
-               pr_info("Status code == Authen rejected, challenge  failure\n");
-               break;
-       case WLAN_MGMT_STATUS_AUTH_TIMEOUT:
-               pr_info("Status code == Authen rejected, timeout waiting for next frame\n");
-               break;
-       case WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY:
-               pr_info("Status code == Assoc denied, AP too busy\n");
-               break;
-       case WLAN_MGMT_STATUS_ASSOC_DENIED_RATES:
-               pr_info("Status code == Assoc denied, we haven't enough basic rates\n");
-               break;
-       case WLAN_MGMT_STATUS_ASSOC_DENIED_SHORTPREAMBLE:
-               pr_info("Status code == Assoc denied, we do not support short preamble\n");
-               break;
-       case WLAN_MGMT_STATUS_ASSOC_DENIED_PBCC:
-               pr_info("Status code == Assoc denied, we do not support PBCC\n");
-               break;
-       case WLAN_MGMT_STATUS_ASSOC_DENIED_AGILITY:
-               pr_info("Status code == Assoc denied, we do not support channel agility\n");
-               break;
-       default:
-               pr_info("Unknown status code %d\n", wStatus);
-               break;
-       }
-}
-
-/*
- *
- * Description:
- *    Add BSSID in PMKID Candidate list.
- *
- * Parameters:
- *  In:
- *      hDeviceContext - device structure point
- *      pbyBSSID - BSSID address for adding
- *      wRSNCap - BSS's RSN capability
- *  Out:
- *      none
- *
- * Return Value: none.
- *
- -*/
-bool
-bAdd_PMKID_Candidate(
-       void *hDeviceContext,
-       unsigned char *pbyBSSID,
-       PSRSNCapObject psRSNCapObj
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-       struct pmkid_candidate *pCandidateList;
-       unsigned int ii = 0;
-
-       pr_debug("bAdd_PMKID_Candidate START: (%d)\n",
-                (int)pDevice->gsPMKIDCandidate.NumCandidates);
-
-       if ((pDevice == NULL) || (pbyBSSID == NULL) || (psRSNCapObj == NULL))
-               return false;
-
-       if (pDevice->gsPMKIDCandidate.NumCandidates >= MAX_PMKIDLIST)
-               return false;
-
-       // Update Old Candidate
-       for (ii = 0; ii < pDevice->gsPMKIDCandidate.NumCandidates; ii++) {
-               pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[ii];
-               if (!memcmp(pCandidateList->BSSID, pbyBSSID, ETH_ALEN)) {
-                       if (psRSNCapObj->bRSNCapExist && (psRSNCapObj->wRSNCap & BIT0))
-                               pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED;
-                       else
-                               pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED);
-
-                       return true;
-               }
-       }
-
-       // New Candidate
-       pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[pDevice->gsPMKIDCandidate.NumCandidates];
-       if (psRSNCapObj->bRSNCapExist && (psRSNCapObj->wRSNCap & BIT0))
-               pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED;
-       else
-               pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED);
-
-       memcpy(pCandidateList->BSSID, pbyBSSID, ETH_ALEN);
-       pDevice->gsPMKIDCandidate.NumCandidates++;
-       pr_debug("NumCandidates:%d\n",
-                (int)pDevice->gsPMKIDCandidate.NumCandidates);
-       return true;
-}
-
-/*
- *
- * Description:
- *    Flush PMKID Candidate list.
- *
- * Parameters:
- *  In:
- *      hDeviceContext - device structure point
- *  Out:
- *      none
- *
- * Return Value: none.
- *
- -*/
-void
-vFlush_PMKID_Candidate(
-       void *hDeviceContext
-)
-{
-       struct vnt_private *pDevice = hDeviceContext;
-
-       if (pDevice == NULL)
-               return;
-
-       memset(&pDevice->gsPMKIDCandidate, 0, sizeof(SPMKIDCandidateEvent));
-}
-
-static bool
-s_bCipherMatch(
-       PKnownBSS                        pBSSNode,
-       NDIS_802_11_ENCRYPTION_STATUS    EncStatus,
-       unsigned char *pbyCCSPK,
-       unsigned char *pbyCCSGK
-)
-{
-       unsigned char byMulticastCipher = KEY_CTL_INVALID;
-       unsigned char byCipherMask = 0x00;
-       int i;
-
-       if (pBSSNode == NULL)
-               return false;
-
-       // check cap. of BSS
-       if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) &&
-           (EncStatus == Ndis802_11Encryption1Enabled)) {
-               // default is WEP only
-               byMulticastCipher = KEY_CTL_WEP;
-       }
-
-       if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) &&
-           pBSSNode->bWPA2Valid &&
-           //20080123-01,<Add> by Einsn Liu
-           ((EncStatus == Ndis802_11Encryption3Enabled) || (EncStatus == Ndis802_11Encryption2Enabled))) {
-               //WPA2
-               // check Group Key Cipher
-               if ((pBSSNode->byCSSGK == WLAN_11i_CSS_WEP40) ||
-                   (pBSSNode->byCSSGK == WLAN_11i_CSS_WEP104)) {
-                       byMulticastCipher = KEY_CTL_WEP;
-               } else if (pBSSNode->byCSSGK == WLAN_11i_CSS_TKIP) {
-                       byMulticastCipher = KEY_CTL_TKIP;
-               } else if (pBSSNode->byCSSGK == WLAN_11i_CSS_CCMP) {
-                       byMulticastCipher = KEY_CTL_CCMP;
-               } else {
-                       byMulticastCipher = KEY_CTL_INVALID;
-               }
-
-               // check Pairwise Key Cipher
-               for (i = 0; i < pBSSNode->wCSSPKCount; i++) {
-                       if ((pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_WEP40) ||
-                           (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_WEP104)) {
-                               // this should not happen as defined 802.11i
-                               byCipherMask |= 0x01;
-                       } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_TKIP) {
-                               byCipherMask |= 0x02;
-                       } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_CCMP) {
-                               byCipherMask |= 0x04;
-                       } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_USE_GROUP) {
-                               // use group key only ignore all others
-                               byCipherMask = 0;
-                               i = pBSSNode->wCSSPKCount;
-                       }
-               }
-
-       } else if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) &&
-                  pBSSNode->bWPAValid &&
-                  ((EncStatus == Ndis802_11Encryption3Enabled) || (EncStatus == Ndis802_11Encryption2Enabled))) {
-               //WPA
-               // check Group Key Cipher
-               if ((pBSSNode->byGKType == WPA_WEP40) ||
-                   (pBSSNode->byGKType == WPA_WEP104)) {
-                       byMulticastCipher = KEY_CTL_WEP;
-               } else if (pBSSNode->byGKType == WPA_TKIP) {
-                       byMulticastCipher = KEY_CTL_TKIP;
-               } else if (pBSSNode->byGKType == WPA_AESCCMP) {
-                       byMulticastCipher = KEY_CTL_CCMP;
-               } else {
-                       byMulticastCipher = KEY_CTL_INVALID;
-               }
-
-               // check Pairwise Key Cipher
-               for (i = 0; i < pBSSNode->wPKCount; i++) {
-                       if (pBSSNode->abyPKType[i] == WPA_TKIP) {
-                               byCipherMask |= 0x02;
-                       } else if (pBSSNode->abyPKType[i] == WPA_AESCCMP) {
-                               byCipherMask |= 0x04;
-                       } else if (pBSSNode->abyPKType[i] == WPA_NONE) {
-                               // use group key only ignore all others
-                               byCipherMask = 0;
-                               i = pBSSNode->wPKCount;
-                       }
-               }
-       }
-
-       pr_debug("%d, %d, %d, %d, EncStatus:%d\n",
-                byMulticastCipher, byCipherMask,
-                pBSSNode->bWPAValid, pBSSNode->bWPA2Valid, EncStatus);
-
-       // mask our cap. with BSS
-       if (EncStatus == Ndis802_11Encryption1Enabled) {
-               // For supporting Cisco migration mode, don't care pairwise key cipher
-               if ((byMulticastCipher == KEY_CTL_WEP) &&
-                   (byCipherMask == 0)) {
-                       *pbyCCSGK = KEY_CTL_WEP;
-                       *pbyCCSPK = KEY_CTL_NONE;
-                       return true;
-               } else {
-                       return false;
-               }
-
-       } else if (EncStatus == Ndis802_11Encryption2Enabled) {
-               if ((byMulticastCipher == KEY_CTL_TKIP) &&
-                   (byCipherMask == 0)) {
-                       *pbyCCSGK = KEY_CTL_TKIP;
-                       *pbyCCSPK = KEY_CTL_NONE;
-                       return true;
-               } else if ((byMulticastCipher == KEY_CTL_WEP) &&
-                          ((byCipherMask & 0x02) != 0)) {
-                       *pbyCCSGK = KEY_CTL_WEP;
-                       *pbyCCSPK = KEY_CTL_TKIP;
-                       return true;
-               } else if ((byMulticastCipher == KEY_CTL_TKIP) &&
-                          ((byCipherMask & 0x02) != 0)) {
-                       *pbyCCSGK = KEY_CTL_TKIP;
-                       *pbyCCSPK = KEY_CTL_TKIP;
-                       return true;
-               } else {
-                       return false;
-               }
-       } else if (EncStatus == Ndis802_11Encryption3Enabled) {
-               if ((byMulticastCipher == KEY_CTL_CCMP) &&
-                   (byCipherMask == 0)) {
-                       // When CCMP is enable, "Use group cipher suite" shall not be a valid option.
-                       return false;
-               } else if ((byMulticastCipher == KEY_CTL_WEP) &&
-                          ((byCipherMask & 0x04) != 0)) {
-                       *pbyCCSGK = KEY_CTL_WEP;
-                       *pbyCCSPK = KEY_CTL_CCMP;
-                       return true;
-               } else if ((byMulticastCipher == KEY_CTL_TKIP) &&
-                          ((byCipherMask & 0x04) != 0)) {
-                       *pbyCCSGK = KEY_CTL_TKIP;
-                       *pbyCCSPK = KEY_CTL_CCMP;
-                       return true;
-               } else if ((byMulticastCipher == KEY_CTL_CCMP) &&
-                          ((byCipherMask & 0x04) != 0)) {
-                       *pbyCCSGK = KEY_CTL_CCMP;
-                       *pbyCCSPK = KEY_CTL_CCMP;
-                       return true;
-               } else {
-                       return false;
-               }
-       }
-       return true;
-}
diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h
deleted file mode 100644 (file)
index ce939b3..0000000
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: wmgr.h
- *
- * Purpose:
- *
- * Author: lyndon chen
- *
- * Date: Jan 2, 2003
- *
- * Functions:
- *
- * Revision History:
- *
- */
-
-#ifndef __WMGR_H__
-#define __WMGR_H__
-
-#include "ttype.h"
-#include "80211mgr.h"
-#include "80211hdr.h"
-#include "wcmd.h"
-#include "bssdb.h"
-#include "wpa2.h"
-#include "vntwifi.h"
-#include "card.h"
-
-/*---------------------  Export Definitions -------------------------*/
-
-// Scan time
-#define PROBE_DELAY                  100  // (us)
-#define SWITCH_CHANNEL_DELAY         200 // (us)
-#define WLAN_SCAN_MINITIME           25   // (ms)
-#define WLAN_SCAN_MAXTIME            100  // (ms)
-#define TRIVIAL_SYNC_DIFFERENCE      0    // (us)
-#define DEFAULT_IBSS_BI              100  // (ms)
-
-#define WCMD_ACTIVE_SCAN_TIME   50 //(ms)
-#define WCMD_PASSIVE_SCAN_TIME  100 //(ms)
-
-#define DEFAULT_MSDU_LIFETIME           512  // ms
-#define DEFAULT_MSDU_LIFETIME_RES_64us  8000 // 64us
-
-#define DEFAULT_MGN_LIFETIME            8    // ms
-#define DEFAULT_MGN_LIFETIME_RES_64us   125  // 64us
-
-#define MAKE_BEACON_RESERVED            10  //(us)
-
-#define TIM_MULTICAST_MASK           0x01
-#define TIM_BITMAPOFFSET_MASK        0xFE
-#define DEFAULT_DTIM_PERIOD             1
-
-#define AP_LONG_RETRY_LIMIT             4
-
-#define DEFAULT_IBSS_CHANNEL            6  //2.4G
-
-/*---------------------  Export Classes  ----------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Types  ------------------------------*/
-#define timer_expire(timer, next_tick)   mod_timer(&timer, RUN_AT(next_tick))
-typedef void (*TimerFunction)(unsigned long);
-
-//+++ NDIS related
-
-typedef unsigned char NDIS_802_11_MAC_ADDRESS[6];
-typedef struct _NDIS_802_11_AI_REQFI {
-       unsigned short Capabilities;
-       unsigned short ListenInterval;
-       NDIS_802_11_MAC_ADDRESS  CurrentAPAddress;
-} NDIS_802_11_AI_REQFI, *PNDIS_802_11_AI_REQFI;
-
-typedef struct _NDIS_802_11_AI_RESFI {
-       unsigned short Capabilities;
-       unsigned short StatusCode;
-       unsigned short AssociationId;
-} NDIS_802_11_AI_RESFI, *PNDIS_802_11_AI_RESFI;
-
-typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION {
-       unsigned long Length;
-       unsigned short          AvailableRequestFixedIEs;
-       NDIS_802_11_AI_REQFI    RequestFixedIEs;
-       unsigned long RequestIELength;
-       unsigned long OffsetRequestIEs;
-       unsigned short          AvailableResponseFixedIEs;
-       NDIS_802_11_AI_RESFI    ResponseFixedIEs;
-       unsigned long ResponseIELength;
-       unsigned long OffsetResponseIEs;
-} NDIS_802_11_ASSOCIATION_INFORMATION, *PNDIS_802_11_ASSOCIATION_INFORMATION;
-
-typedef struct tagSAssocInfo {
-       NDIS_802_11_ASSOCIATION_INFORMATION     AssocInfo;
-       unsigned char abyIEs[WLAN_BEACON_FR_MAXLEN+WLAN_BEACON_FR_MAXLEN];
-       // store ReqIEs set by OID_802_11_ASSOCIATION_INFORMATION
-       unsigned long RequestIELength;
-       unsigned char abyReqIEs[WLAN_BEACON_FR_MAXLEN];
-} SAssocInfo, *PSAssocInfo;
-//---
-
-typedef enum tagWMAC_SCAN_TYPE {
-       WMAC_SCAN_ACTIVE,
-       WMAC_SCAN_PASSIVE,
-       WMAC_SCAN_HYBRID
-} WMAC_SCAN_TYPE, *PWMAC_SCAN_TYPE;
-
-typedef enum tagWMAC_SCAN_STATE {
-       WMAC_NO_SCANNING,
-       WMAC_IS_SCANNING,
-       WMAC_IS_PROBEPENDING
-} WMAC_SCAN_STATE, *PWMAC_SCAN_STATE;
-
-// Notes:
-// Basic Service Set state explained as following:
-// WMAC_STATE_IDLE          : no BSS is selected (Adhoc or Infra)
-// WMAC_STATE_STARTED       : no BSS is selected, start own IBSS (Adhoc only)
-// WMAC_STATE_JOINTED       : BSS is selected and synchronized (Adhoc or Infra)
-// WMAC_STATE_AUTHPENDING   : Authentication pending (Infra)
-// WMAC_STATE_AUTH          : Authenticated (Infra)
-// WMAC_STATE_ASSOCPENDING  : Association pending (Infra)
-// WMAC_STATE_ASSOC         : Associated (Infra)
-
-typedef enum tagWMAC_BSS_STATE {
-       WMAC_STATE_IDLE,
-       WMAC_STATE_STARTED,
-       WMAC_STATE_JOINTED,
-       WMAC_STATE_AUTHPENDING,
-       WMAC_STATE_AUTH,
-       WMAC_STATE_ASSOCPENDING,
-       WMAC_STATE_ASSOC
-} WMAC_BSS_STATE, *PWMAC_BSS_STATE;
-
-// WMAC selected running mode
-typedef enum tagWMAC_CURRENT_MODE {
-       WMAC_MODE_STANDBY,
-       WMAC_MODE_ESS_STA,
-       WMAC_MODE_IBSS_STA,
-       WMAC_MODE_ESS_AP
-} WMAC_CURRENT_MODE, *PWMAC_CURRENT_MODE;
-
-/*
-  typedef enum tagWMAC_POWER_MODE {
-  WMAC_POWER_CAM,
-  WMAC_POWER_FAST,
-  WMAC_POWER_MAX
-
-  } WMAC_POWER_MODE, *PWMAC_POWER_MODE;
-*/
-
-// Tx Management Packet descriptor
-typedef struct tagSTxMgmtPacket {
-       PUWLAN_80211HDR     p80211Header;
-       unsigned int cbMPDULen;
-       unsigned int cbPayloadLen;
-} STxMgmtPacket, *PSTxMgmtPacket;
-
-// Rx Management Packet descriptor
-typedef struct tagSRxMgmtPacket {
-       PUWLAN_80211HDR     p80211Header;
-       u64 qwLocalTSF;
-       unsigned int cbMPDULen;
-       unsigned int cbPayloadLen;
-       unsigned int uRSSI;
-       unsigned char bySQ;
-       unsigned char byRxRate;
-       unsigned char byRxChannel;
-} SRxMgmtPacket, *PSRxMgmtPacket;
-
-typedef struct tagSMgmtObject {
-       void *pAdapter;
-       // MAC address
-       unsigned char abyMACAddr[WLAN_ADDR_LEN];
-
-       // Configuration Mode
-       WMAC_CONFIG_MODE        eConfigMode; // MAC pre-configed mode
-       CARD_PHY_TYPE           eCurrentPHYMode;
-       CARD_PHY_TYPE           eConfigPHYMode;
-
-       // Operation state variables
-       WMAC_CURRENT_MODE       eCurrMode;   // MAC current connection mode
-       WMAC_BSS_STATE          eCurrState;  // MAC current BSS state
-
-       PKnownBSS               pCurrBSS;
-       unsigned char byCSSGK;
-       unsigned char byCSSPK;
-
-       // Current state vars
-       unsigned int    uCurrChannel;
-       unsigned char abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
-       unsigned char abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
-       unsigned char abyCurrSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
-       unsigned char abyCurrBSSID[WLAN_BSSID_LEN];
-       unsigned short wCurrCapInfo;
-       unsigned short wCurrAID;
-       unsigned short wCurrATIMWindow;
-       unsigned short wCurrBeaconPeriod;
-       bool bIsDS;
-       unsigned char byERPContext;
-
-       CMD_STATE               eCommandState;
-       unsigned int    uScanChannel;
-
-       // Desire joining BSS vars
-       unsigned char abyDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
-       unsigned char abyDesireBSSID[WLAN_BSSID_LEN];
-
-       // Adhoc or AP configuration vars
-       unsigned short wIBSSBeaconPeriod;
-       unsigned short wIBSSATIMWindow;
-       unsigned int    uIBSSChannel;
-       unsigned char abyIBSSSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
-       unsigned char byAPBBType;
-       unsigned char abyWPAIE[MAX_WPA_IE_LEN];
-       unsigned short wWPAIELen;
-
-       unsigned int    uAssocCount;
-       bool bMoreData;
-
-       // Scan state vars
-       WMAC_SCAN_STATE         eScanState;
-       WMAC_SCAN_TYPE          eScanType;
-       unsigned int    uScanStartCh;
-       unsigned int    uScanEndCh;
-       unsigned short wScanSteps;
-       unsigned int    uScanBSSType;
-       // Desire scanning vars
-       unsigned char abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
-       unsigned char abyScanBSSID[WLAN_BSSID_LEN];
-
-       // Privacy
-       WMAC_AUTHENTICATION_MODE eAuthenMode;
-       WMAC_ENCRYPTION_MODE    eEncryptionMode;
-       bool bShareKeyAlgorithm;
-       unsigned char abyChallenge[WLAN_CHALLENGE_LEN];
-       bool bPrivacyInvoked;
-
-       // Received beacon state vars
-       bool bInTIM;
-       bool bMulticastTIM;
-       unsigned char byDTIMCount;
-       unsigned char byDTIMPeriod;
-
-       // Power saving state vars
-       WMAC_POWER_MODE         ePSMode;
-       unsigned short wListenInterval;
-       unsigned short wCountToWakeUp;
-       bool bInTIMWake;
-       unsigned char *pbyPSPacketPool;
-       unsigned char byPSPacketPool[sizeof(STxMgmtPacket) + WLAN_NULLDATA_FR_MAXLEN];
-       bool bRxBeaconInTBTTWake;
-       unsigned char abyPSTxMap[MAX_NODE_NUM + 1];
-
-       // management command related
-       unsigned int    uCmdBusy;
-       unsigned int    uCmdHostAPBusy;
-
-       // management packet pool
-       unsigned char *pbyMgmtPacketPool;
-       unsigned char byMgmtPacketPool[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN];
-
-       // One second callback timer
-       struct timer_list           sTimerSecondCallback;
-
-       // Temporarily Rx Mgmt Packet Descriptor
-       SRxMgmtPacket           sRxPacket;
-
-       // link list of known bss's (scan results)
-       KnownBSS                sBSSList[MAX_BSS_NUM];
-
-       // table list of known node
-       // sNodeDBList[0] is reserved for AP under Infra mode
-       // sNodeDBList[0] is reserved for Multicast under adhoc/AP mode
-       KnownNodeDB             sNodeDBTable[MAX_NODE_NUM + 1];
-
-       // WPA2 PMKID Cache
-       SPMKIDCache             gsPMKIDCache;
-       bool bRoaming;
-
-       // rate fall back vars
-
-       // associate info
-       SAssocInfo              sAssocInfo;
-
-       // for 802.11h
-       bool b11hEnable;
-       bool bSwitchChannel;
-       unsigned char byNewChannel;
-       PWLAN_IE_MEASURE_REP    pCurrMeasureEIDRep;
-       unsigned int    uLengthOfRepEIDs;
-       unsigned char abyCurrentMSRReq[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN];
-       unsigned char abyCurrentMSRRep[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN];
-       unsigned char abyIECountry[WLAN_A3FR_MAXLEN];
-       unsigned char abyIBSSDFSOwner[6];
-       unsigned char byIBSSDFSRecovery;
-
-       struct sk_buff  skb;
-} SMgmtObject, *PSMgmtObject;
-
-/*---------------------  Export Macros ------------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-void
-vMgrObjectInit(
-       void *hDeviceContext
-);
-
-void
-vMgrTimerInit(
-       void *hDeviceContext
-);
-
-void
-vMgrObjectReset(
-       void *hDeviceContext
-);
-
-void
-vMgrAssocBeginSta(
-       void *hDeviceContext,
-       PSMgmtObject pMgmt,
-       PCMD_STATUS pStatus
-);
-
-void
-vMgrReAssocBeginSta(
-       void *hDeviceContext,
-       PSMgmtObject pMgmt,
-       PCMD_STATUS pStatus
-);
-
-void
-vMgrDisassocBeginSta(
-       void *hDeviceContext,
-       PSMgmtObject pMgmt,
-       unsigned char *abyDestAddress,
-       unsigned short wReason,
-       PCMD_STATUS pStatus
-);
-
-void
-vMgrAuthenBeginSta(
-       void *hDeviceContext,
-       PSMgmtObject pMgmt,
-       PCMD_STATUS pStatus
-);
-
-void
-vMgrCreateOwnIBSS(
-       void *hDeviceContext,
-       PCMD_STATUS pStatus
-);
-
-void
-vMgrJoinBSSBegin(
-       void *hDeviceContext,
-       PCMD_STATUS pStatus
-);
-
-void
-vMgrRxManagePacket(
-       void *hDeviceContext,
-       PSMgmtObject pMgmt,
-       PSRxMgmtPacket pRxPacket
-);
-
-/*
-  void
-  vMgrScanBegin(
-  void *hDeviceContext,
-  PCMD_STATUS pStatus
-);
-*/
-
-void
-vMgrDeAuthenBeginSta(
-       void *hDeviceContext,
-       PSMgmtObject  pMgmt,
-       unsigned char *abyDestAddress,
-       unsigned short wReason,
-       PCMD_STATUS pStatus
-);
-
-bool
-bMgrPrepareBeaconToSend(
-       void *hDeviceContext,
-       PSMgmtObject pMgmt
-);
-
-bool
-bAdd_PMKID_Candidate(
-       void *hDeviceContext,
-       unsigned char *pbyBSSID,
-       PSRSNCapObject psRSNCapObj
-);
-
-void
-vFlush_PMKID_Candidate(
-       void *hDeviceContext
-);
-
-#endif // __WMGR_H__
diff --git a/drivers/staging/vt6655/wpa.c b/drivers/staging/vt6655/wpa.c
deleted file mode 100644 (file)
index 5d4eca8..0000000
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: wpa.c
- *
- * Purpose: Handles the Basic Service Set & Node Database functions
- *
- * Functions:
- *      WPA_ParseRSN - Parse RSN IE.
- *
- * Revision History:
- *
- * Author: Kyle Hsu
- *
- * Date: July 14, 2003
- *
- */
-
-#include "ttype.h"
-#include "tmacro.h"
-#include "tether.h"
-#include "device.h"
-#include "80211hdr.h"
-#include "bssdb.h"
-#include "wmgr.h"
-#include "wpa.h"
-#include "80211mgr.h"
-
-/*---------------------  Static Variables  --------------------------*/
-static const unsigned char abyOUI00[4] = { 0x00, 0x50, 0xf2, 0x00 };
-static const unsigned char abyOUI01[4] = { 0x00, 0x50, 0xf2, 0x01 };
-static const unsigned char abyOUI02[4] = { 0x00, 0x50, 0xf2, 0x02 };
-static const unsigned char abyOUI03[4] = { 0x00, 0x50, 0xf2, 0x03 };
-static const unsigned char abyOUI04[4] = { 0x00, 0x50, 0xf2, 0x04 };
-static const unsigned char abyOUI05[4] = { 0x00, 0x50, 0xf2, 0x05 };
-
-/*+
- *
- * Description:
- *    Clear RSN information in BSSList.
- *
- * Parameters:
- *  In:
- *      pBSSList - BSS list.
- *  Out:
- *      none
- *
- * Return Value: none.
- *
- -*/
-
-void
-WPA_ClearRSN(
-       PKnownBSS        pBSSList
-)
-{
-       int ii;
-
-       pBSSList->byGKType = WPA_TKIP;
-       for (ii = 0; ii < 4; ii++)
-               pBSSList->abyPKType[ii] = WPA_TKIP;
-       pBSSList->wPKCount = 0;
-       for (ii = 0; ii < 4; ii++)
-               pBSSList->abyAuthType[ii] = WPA_AUTH_IEEE802_1X;
-       pBSSList->wAuthCount = 0;
-       pBSSList->byDefaultK_as_PK = 0;
-       pBSSList->byReplayIdx = 0;
-       pBSSList->sRSNCapObj.bRSNCapExist = false;
-       pBSSList->sRSNCapObj.wRSNCap = 0;
-       pBSSList->bWPAValid = false;
-}
-
-/*+
- *
- * Description:
- *    Parse RSN IE.
- *
- * Parameters:
- *  In:
- *      pBSSList - BSS list.
- *      pRSN - Pointer to the RSN IE.
- *  Out:
- *      none
- *
- * Return Value: none.
- *
- -*/
-void
-WPA_ParseRSN(
-       PKnownBSS        pBSSList,
-       PWLAN_IE_RSN_EXT pRSN
-)
-{
-       PWLAN_IE_RSN_AUTH  pIE_RSN_Auth = NULL;
-       int                i, j, m, n = 0;
-       unsigned char *pbyCaps;
-
-       WPA_ClearRSN(pBSSList);
-
-       pr_debug("WPA_ParseRSN: [%d]\n", pRSN->len);
-
-       // information element header makes sense
-       if ((pRSN->len >= 6) // oui1(4)+ver(2)
-           && (pRSN->byElementID == WLAN_EID_RSN_WPA) && !memcmp(pRSN->abyOUI, abyOUI01, 4)
-           && (pRSN->wVersion == 1)) {
-               pr_debug("Legal RSN\n");
-               // update each variable if pRSN is long enough to contain the variable
-               if (pRSN->len >= 10) {
-                       //OUI1(4)+ver(2)+GKSuite(4)
-                       if (!memcmp(pRSN->abyMulticast, abyOUI01, 4))
-                               pBSSList->byGKType = WPA_WEP40;
-                       else if (!memcmp(pRSN->abyMulticast, abyOUI02, 4))
-                               pBSSList->byGKType = WPA_TKIP;
-                       else if (!memcmp(pRSN->abyMulticast, abyOUI03, 4))
-                               pBSSList->byGKType = WPA_AESWRAP;
-                       else if (!memcmp(pRSN->abyMulticast, abyOUI04, 4))
-                               pBSSList->byGKType = WPA_AESCCMP;
-                       else if (!memcmp(pRSN->abyMulticast, abyOUI05, 4))
-                               pBSSList->byGKType = WPA_WEP104;
-                       else
-                               // any vendor checks here
-                               pBSSList->byGKType = WPA_NONE;
-
-                       pr_debug("byGKType: %x\n", pBSSList->byGKType);
-               }
-
-               if (pRSN->len >= 12) {
-                       //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)
-                       j = 0;
-                       pr_debug("wPKCount: %d, sizeof(pBSSList->abyPKType): %zu\n",
-                                pRSN->wPKCount, sizeof(pBSSList->abyPKType));
-                       for (i = 0; (i < pRSN->wPKCount) && (j < ARRAY_SIZE(pBSSList->abyPKType)); i++) {
-                               if (pRSN->len >= 12+i*4+4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*i)
-                                       if (!memcmp(pRSN->PKSList[i].abyOUI, abyOUI00, 4))
-                                               pBSSList->abyPKType[j++] = WPA_NONE;
-                                       else if (!memcmp(pRSN->PKSList[i].abyOUI, abyOUI02, 4))
-                                               pBSSList->abyPKType[j++] = WPA_TKIP;
-                                       else if (!memcmp(pRSN->PKSList[i].abyOUI, abyOUI03, 4))
-                                               pBSSList->abyPKType[j++] = WPA_AESWRAP;
-                                       else if (!memcmp(pRSN->PKSList[i].abyOUI, abyOUI04, 4))
-                                               pBSSList->abyPKType[j++] = WPA_AESCCMP;
-                                       else
-                                               // any vendor checks here
-                                               ;
-                               } else
-                                       break;
-                       }
-                       pBSSList->wPKCount = (unsigned short)j;
-                       pr_debug("wPKCount: %d\n", pBSSList->wPKCount);
-               }
-
-               m = pRSN->wPKCount;
-               pr_debug("m: %d\n", m);
-               pr_debug("14+m*4: %d\n", 14+m*4);
-
-               if (pRSN->len >= 14+m*4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*m)+AKC(2)
-                       // overlay IE_RSN_Auth structure into correct place
-                       pIE_RSN_Auth = (PWLAN_IE_RSN_AUTH) pRSN->PKSList[m].abyOUI;
-                       j = 0;
-                       pr_debug("wAuthCount: %d, sizeof(pBSSList->abyAuthType): %zu\n",
-                                pIE_RSN_Auth->wAuthCount,
-                                sizeof(pBSSList->abyAuthType));
-                       for (i = 0; (i < pIE_RSN_Auth->wAuthCount) && (j < ARRAY_SIZE(pBSSList->abyAuthType)); i++) {
-                               if (pRSN->len >= 14+4+(m+i)*4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*m)+AKC(2)+AKS(4*i)
-                                       if (!memcmp(pIE_RSN_Auth->AuthKSList[i].abyOUI, abyOUI01, 4))
-                                               pBSSList->abyAuthType[j++] = WPA_AUTH_IEEE802_1X;
-                                       else if (!memcmp(pIE_RSN_Auth->AuthKSList[i].abyOUI, abyOUI02, 4))
-                                               pBSSList->abyAuthType[j++] = WPA_AUTH_PSK;
-                                       else
-                                               // any vendor checks here
-                                               ;
-                               } else
-                                       break;
-
-                       }
-                       if (j > 0)
-                               pBSSList->wAuthCount = (unsigned short)j;
-                       pr_debug("wAuthCount: %d\n", pBSSList->wAuthCount);
-               }
-
-               if (pIE_RSN_Auth != NULL) {
-                       n = pIE_RSN_Auth->wAuthCount;
-
-                       pr_debug("n: %d\n", n);
-                       pr_debug("14+4+(m+n)*4: %d\n", 14+4+(m+n)*4);
-
-                       if (pRSN->len+2 >= 14+4+(m+n)*4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*m)+AKC(2)+AKS(4*n)+Cap(2)
-                               pbyCaps = (unsigned char *)pIE_RSN_Auth->AuthKSList[n].abyOUI;
-                               pBSSList->byDefaultK_as_PK = (*pbyCaps) & WPA_GROUPFLAG;
-                               pBSSList->byReplayIdx = 2 << ((*pbyCaps >> WPA_REPLAYBITSSHIFT) & WPA_REPLAYBITS);
-                               pBSSList->sRSNCapObj.bRSNCapExist = true;
-                               pBSSList->sRSNCapObj.wRSNCap = *(unsigned short *)pbyCaps;
-                       }
-               }
-               pBSSList->bWPAValid = true;
-       }
-}
-
-/*+
- *
- * Description:
- *    Search RSN information in BSSList.
- *
- * Parameters:
- *  In:
- *      byCmd    - Search type
- *      byEncrypt- Encrypt Type
- *      pBSSList - BSS list
- *  Out:
- *      none
- *
- * Return Value: none.
- *
- -*/
-bool
-WPA_SearchRSN(
-       unsigned char byCmd,
-       unsigned char byEncrypt,
-       PKnownBSS        pBSSList
-)
-{
-       int ii;
-       unsigned char byPKType = WPA_NONE;
-
-       if (!pBSSList->bWPAValid)
-               return false;
-
-       switch (byCmd) {
-       case 0:
-
-               if (byEncrypt != pBSSList->byGKType)
-                       return false;
-
-               if (pBSSList->wPKCount > 0) {
-                       for (ii = 0; ii < pBSSList->wPKCount; ii++) {
-                               if (pBSSList->abyPKType[ii] == WPA_AESCCMP)
-                                       byPKType = WPA_AESCCMP;
-                               else if ((pBSSList->abyPKType[ii] == WPA_TKIP) && (byPKType != WPA_AESCCMP))
-                                       byPKType = WPA_TKIP;
-                               else if ((pBSSList->abyPKType[ii] == WPA_WEP40) && (byPKType != WPA_AESCCMP) && (byPKType != WPA_TKIP))
-                                       byPKType = WPA_WEP40;
-                               else if ((pBSSList->abyPKType[ii] == WPA_WEP104) && (byPKType != WPA_AESCCMP) && (byPKType != WPA_TKIP))
-                                       byPKType = WPA_WEP104;
-                       }
-                       if (byEncrypt != byPKType)
-                               return false;
-               }
-               return true;
-
-       default:
-               break;
-       }
-       return false;
-}
-
-/*+
- *
- * Description:
- *    Check if RSN IE makes sense.
- *
- * Parameters:
- *  In:
- *      pRSN - Pointer to the RSN IE.
- *  Out:
- *      none
- *
- * Return Value: none.
- *
- -*/
-bool
-WPAb_Is_RSN(
-       PWLAN_IE_RSN_EXT pRSN
-)
-{
-       if (pRSN == NULL)
-               return false;
-
-       if ((pRSN->len >= 6) && // oui1(4)+ver(2)
-           (pRSN->byElementID == WLAN_EID_RSN_WPA) &&  !memcmp(pRSN->abyOUI, abyOUI01, 4) &&
-           (pRSN->wVersion == 1)) {
-               return true;
-       } else
-               return false;
-}
diff --git a/drivers/staging/vt6655/wpa.h b/drivers/staging/vt6655/wpa.h
deleted file mode 100644 (file)
index 1d1918a..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: wpa.h
- *
- * Purpose: Defines the macros, types, and functions for dealing
- *          with WPA informations.
- *
- * Author: Kyle Hsu
- *
- * Date: Jul 14, 2003
- *
- */
-
-#ifndef __WPA_H__
-#define __WPA_H__
-
-#include "ttype.h"
-#include "80211hdr.h"
-
-/*---------------------  Export Definitions -------------------------*/
-
-#define WPA_NONE            0
-#define WPA_WEP40           1
-#define WPA_TKIP            2
-#define WPA_AESWRAP         3
-#define WPA_AESCCMP         4
-#define WPA_WEP104          5
-#define WPA_AUTH_IEEE802_1X 1
-#define WPA_AUTH_PSK        2
-
-#define WPA_GROUPFLAG       0x02
-#define WPA_REPLAYBITSSHIFT 2
-#define WPA_REPLAYBITS      0x03
-
-/*---------------------  Export Classes  ----------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Types  ------------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-void
-WPA_ClearRSN(
-       PKnownBSS        pBSSList
-);
-
-void
-WPA_ParseRSN(
-       PKnownBSS        pBSSList,
-       PWLAN_IE_RSN_EXT pRSN
-);
-
-bool
-WPA_SearchRSN(
-       unsigned char byCmd,
-       unsigned char byEncrypt,
-       PKnownBSS        pBSSList
-);
-
-bool
-WPAb_Is_RSN(
-       PWLAN_IE_RSN_EXT pRSN
-);
-
-#endif // __WPA_H__
diff --git a/drivers/staging/vt6655/wpa2.c b/drivers/staging/vt6655/wpa2.c
deleted file mode 100644 (file)
index bb335ef..0000000
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: wpa2.c
- *
- * Purpose: Handles the Basic Service Set & Node Database functions
- *
- * Functions:
- *
- * Revision History:
- *
- * Author: Yiching Chen
- *
- * Date: Oct. 4, 2004
- *
- */
-
-#include "wpa2.h"
-#include "device.h"
-#include "wmgr.h"
-
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Variables  --------------------------*/
-
-static const unsigned char abyOUIGK[4]      = { 0x00, 0x0F, 0xAC, 0x00 };
-static const unsigned char abyOUIWEP40[4]   = { 0x00, 0x0F, 0xAC, 0x01 };
-static const unsigned char abyOUIWEP104[4]  = { 0x00, 0x0F, 0xAC, 0x05 };
-static const unsigned char abyOUITKIP[4]    = { 0x00, 0x0F, 0xAC, 0x02 };
-static const unsigned char abyOUICCMP[4]    = { 0x00, 0x0F, 0xAC, 0x04 };
-
-static const unsigned char abyOUI8021X[4]   = { 0x00, 0x0F, 0xAC, 0x01 };
-static const unsigned char abyOUIPSK[4]     = { 0x00, 0x0F, 0xAC, 0x02 };
-
-/*---------------------  Static Functions  --------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-/*+
- *
- * Description:
- *    Clear RSN information in BSSList.
- *
- * Parameters:
- *  In:
- *      pBSSNode - BSS list.
- *  Out:
- *      none
- *
- * Return Value: none.
- *
- -*/
-void
-WPA2_ClearRSN(
-       PKnownBSS        pBSSNode
-)
-{
-       int ii;
-
-       pBSSNode->bWPA2Valid = false;
-
-       pBSSNode->byCSSGK = WLAN_11i_CSS_CCMP;
-       for (ii = 0; ii < 4; ii++)
-               pBSSNode->abyCSSPK[ii] = WLAN_11i_CSS_CCMP;
-       pBSSNode->wCSSPKCount = 1;
-       for (ii = 0; ii < 4; ii++)
-               pBSSNode->abyAKMSSAuthType[ii] = WLAN_11i_AKMSS_802_1X;
-       pBSSNode->wAKMSSAuthCount = 1;
-       pBSSNode->sRSNCapObj.bRSNCapExist = false;
-       pBSSNode->sRSNCapObj.wRSNCap = 0;
-}
-
-/*+
- *
- * Description:
- *    Parse RSN IE.
- *
- * Parameters:
- *  In:
- *      pBSSNode - BSS list.
- *      pRSN - Pointer to the RSN IE.
- *  Out:
- *      none
- *
- * Return Value: none.
- *
- -*/
-void
-WPA2vParseRSN(
-       PKnownBSS        pBSSNode,
-       PWLAN_IE_RSN     pRSN
-)
-{
-       int                 i, j;
-       unsigned short m = 0, n = 0;
-       unsigned char *pbyOUI;
-       bool bUseGK = false;
-
-       pr_debug("WPA2_ParseRSN: [%d]\n", pRSN->len);
-
-       WPA2_ClearRSN(pBSSNode);
-
-       if (pRSN->len == 2) { // ver(2)
-               if ((pRSN->byElementID == WLAN_EID_RSN) && (pRSN->wVersion == 1))
-                       pBSSNode->bWPA2Valid = true;
-
-               return;
-       }
-
-       if (pRSN->len < 6) { // ver(2) + GK(4)
-               // invalid CSS, P802.11i/D10.0, p31
-               return;
-       }
-
-       // information element header makes sense
-       if ((pRSN->byElementID == WLAN_EID_RSN) &&
-           (pRSN->wVersion == 1)) {
-               pr_debug("Legal 802.11i RSN\n");
-
-               pbyOUI = &(pRSN->abyRSN[0]);
-               if (!memcmp(pbyOUI, abyOUIWEP40, 4))
-                       pBSSNode->byCSSGK = WLAN_11i_CSS_WEP40;
-               else if (!memcmp(pbyOUI, abyOUITKIP, 4))
-                       pBSSNode->byCSSGK = WLAN_11i_CSS_TKIP;
-               else if (!memcmp(pbyOUI, abyOUICCMP, 4))
-                       pBSSNode->byCSSGK = WLAN_11i_CSS_CCMP;
-               else if (!memcmp(pbyOUI, abyOUIWEP104, 4))
-                       pBSSNode->byCSSGK = WLAN_11i_CSS_WEP104;
-               else if (!memcmp(pbyOUI, abyOUIGK, 4)) {
-                       // invalid CSS, P802.11i/D10.0, p32
-                       return;
-               } else
-                       // any vendor checks here
-                       pBSSNode->byCSSGK = WLAN_11i_CSS_UNKNOWN;
-
-               pr_debug("802.11i CSS: %X\n", pBSSNode->byCSSGK);
-
-               if (pRSN->len == 6) {
-                       pBSSNode->bWPA2Valid = true;
-                       return;
-               }
-
-               if (pRSN->len >= 8) { // ver(2) + GK(4) + PK count(2)
-                       pBSSNode->wCSSPKCount = *((unsigned short *)&(pRSN->abyRSN[4]));
-                       j = 0;
-                       pbyOUI = &(pRSN->abyRSN[6]);
-
-                       for (i = 0; (i < pBSSNode->wCSSPKCount) && (j < sizeof(pBSSNode->abyCSSPK)/sizeof(unsigned char)); i++) {
-                               if (pRSN->len >= 8+i*4+4) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*i)
-                                       if (!memcmp(pbyOUI, abyOUIGK, 4)) {
-                                               pBSSNode->abyCSSPK[j++] = WLAN_11i_CSS_USE_GROUP;
-                                               bUseGK = true;
-                                       } else if (!memcmp(pbyOUI, abyOUIWEP40, 4)) {
-                                               // Invalid CSS, continue to parsing
-                                       } else if (!memcmp(pbyOUI, abyOUITKIP, 4)) {
-                                               if (pBSSNode->byCSSGK != WLAN_11i_CSS_CCMP)
-                                                       pBSSNode->abyCSSPK[j++] = WLAN_11i_CSS_TKIP;
-                                               else
-                                                       ; // Invalid CSS, continue to parsing
-                                       } else if (!memcmp(pbyOUI, abyOUICCMP, 4)) {
-                                               pBSSNode->abyCSSPK[j++] = WLAN_11i_CSS_CCMP;
-                                       } else if (!memcmp(pbyOUI, abyOUIWEP104, 4)) {
-                                               // Invalid CSS, continue to parsing
-                                       } else {
-                                               // any vendor checks here
-                                               pBSSNode->abyCSSPK[j++] = WLAN_11i_CSS_UNKNOWN;
-                                       }
-                                       pbyOUI += 4;
-                                       pr_debug("abyCSSPK[%d]: %X\n",
-                                                j-1, pBSSNode->abyCSSPK[j-1]);
-                               } else
-                                       break;
-                       } //for
-
-                       if (bUseGK) {
-                               if (j != 1) {
-                                       // invalid CSS, This should be only PK CSS.
-                                       return;
-                               }
-                               if (pBSSNode->byCSSGK == WLAN_11i_CSS_CCMP) {
-                                       // invalid CSS, If CCMP is enable , PK can't be CSSGK.
-                                       return;
-                               }
-                       }
-                       if ((pBSSNode->wCSSPKCount != 0) && (j == 0)) {
-                               // invalid CSS, No valid PK.
-                               return;
-                       }
-                       pBSSNode->wCSSPKCount = (unsigned short)j;
-                       pr_debug("wCSSPKCount: %d\n", pBSSNode->wCSSPKCount);
-               }
-
-               m = *((unsigned short *)&(pRSN->abyRSN[4]));
-
-               if (pRSN->len >= 10+m*4) { // ver(2) + GK(4) + PK count(2) + PKS(4*m) + AKMSS count(2)
-                       pBSSNode->wAKMSSAuthCount = *((unsigned short *)&(pRSN->abyRSN[6+4*m]));
-                       j = 0;
-                       pbyOUI = &(pRSN->abyRSN[8+4*m]);
-                       for (i = 0; (i < pBSSNode->wAKMSSAuthCount) && (j < sizeof(pBSSNode->abyAKMSSAuthType)/sizeof(unsigned char)); i++) {
-                               if (pRSN->len >= 10+(m+i)*4+4) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*m)+AKMSS(2)+AKS(4*i)
-                                       if (!memcmp(pbyOUI, abyOUI8021X, 4))
-                                               pBSSNode->abyAKMSSAuthType[j++] = WLAN_11i_AKMSS_802_1X;
-                                       else if (!memcmp(pbyOUI, abyOUIPSK, 4))
-                                               pBSSNode->abyAKMSSAuthType[j++] = WLAN_11i_AKMSS_PSK;
-                                       else
-                                               // any vendor checks here
-                                               pBSSNode->abyAKMSSAuthType[j++] = WLAN_11i_AKMSS_UNKNOWN;
-                                       pr_debug("abyAKMSSAuthType[%d]: %X\n",
-                                                j-1,
-                                                pBSSNode->abyAKMSSAuthType[j-1]);
-                               } else
-                                       break;
-                       }
-                       pBSSNode->wAKMSSAuthCount = (unsigned short)j;
-                       pr_debug("wAKMSSAuthCount: %d\n",
-                                pBSSNode->wAKMSSAuthCount);
-
-                       n = *((unsigned short *)&(pRSN->abyRSN[6+4*m]));
-                       if (pRSN->len >= 12 + 4 * m + 4 * n) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*m)+AKMSSCnt(2)+AKMSS(4*n)+Cap(2)
-                               pBSSNode->sRSNCapObj.bRSNCapExist = true;
-                               pBSSNode->sRSNCapObj.wRSNCap = *((unsigned short *)&(pRSN->abyRSN[8+4*m+4*n]));
-                       }
-               }
-               //ignore PMKID lists bcs only (Re)Assocrequest has this field
-               pBSSNode->bWPA2Valid = true;
-       }
-}
-
-/*+
- *
- * Description:
- *    Set WPA IEs
- *
- * Parameters:
- *  In:
- *      pMgmtHandle - Pointer to management object
- *  Out:
- *      pRSNIEs     - Pointer to the RSN IE to set.
- *
- * Return Value: length of IEs.
- *
- -*/
-unsigned int
-WPA2uSetIEs(
-       void *pMgmtHandle,
-       PWLAN_IE_RSN pRSNIEs
-)
-{
-       PSMgmtObject    pMgmt = (PSMgmtObject) pMgmtHandle;
-       unsigned char *pbyBuffer = NULL;
-       unsigned int ii = 0;
-       unsigned short *pwPMKID = NULL;
-
-       if (pRSNIEs == NULL)
-               return 0;
-
-       if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
-            (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) &&
-           (pMgmt->pCurrBSS != NULL)) {
-               /* WPA2 IE */
-               pbyBuffer = (unsigned char *)pRSNIEs;
-               pRSNIEs->byElementID = WLAN_EID_RSN;
-               pRSNIEs->len = 6; //Version(2)+GK(4)
-               pRSNIEs->wVersion = 1;
-               //Group Key Cipher Suite
-               pRSNIEs->abyRSN[0] = 0x00;
-               pRSNIEs->abyRSN[1] = 0x0F;
-               pRSNIEs->abyRSN[2] = 0xAC;
-               if (pMgmt->byCSSGK == KEY_CTL_WEP)
-                       pRSNIEs->abyRSN[3] = pMgmt->pCurrBSS->byCSSGK;
-               else if (pMgmt->byCSSGK == KEY_CTL_TKIP)
-                       pRSNIEs->abyRSN[3] = WLAN_11i_CSS_TKIP;
-               else if (pMgmt->byCSSGK == KEY_CTL_CCMP)
-                       pRSNIEs->abyRSN[3] = WLAN_11i_CSS_CCMP;
-               else
-                       pRSNIEs->abyRSN[3] = WLAN_11i_CSS_UNKNOWN;
-
-               // Pairwise Key Cipher Suite
-               pRSNIEs->abyRSN[4] = 1;
-               pRSNIEs->abyRSN[5] = 0;
-               pRSNIEs->abyRSN[6] = 0x00;
-               pRSNIEs->abyRSN[7] = 0x0F;
-               pRSNIEs->abyRSN[8] = 0xAC;
-               if (pMgmt->byCSSPK == KEY_CTL_TKIP)
-                       pRSNIEs->abyRSN[9] = WLAN_11i_CSS_TKIP;
-               else if (pMgmt->byCSSPK == KEY_CTL_CCMP)
-                       pRSNIEs->abyRSN[9] = WLAN_11i_CSS_CCMP;
-               else if (pMgmt->byCSSPK == KEY_CTL_NONE)
-                       pRSNIEs->abyRSN[9] = WLAN_11i_CSS_USE_GROUP;
-               else
-                       pRSNIEs->abyRSN[9] = WLAN_11i_CSS_UNKNOWN;
-
-               pRSNIEs->len += 6;
-
-               // Auth Key Management Suite
-               pRSNIEs->abyRSN[10] = 1;
-               pRSNIEs->abyRSN[11] = 0;
-               pRSNIEs->abyRSN[12] = 0x00;
-               pRSNIEs->abyRSN[13] = 0x0F;
-               pRSNIEs->abyRSN[14] = 0xAC;
-               if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)
-                       pRSNIEs->abyRSN[15] = WLAN_11i_AKMSS_PSK;
-               else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)
-                       pRSNIEs->abyRSN[15] = WLAN_11i_AKMSS_802_1X;
-               else
-                       pRSNIEs->abyRSN[15] = WLAN_11i_AKMSS_UNKNOWN;
-
-               pRSNIEs->len += 6;
-
-               // RSN Capabilities
-               if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist == true) {
-                       memcpy(&pRSNIEs->abyRSN[16], &pMgmt->pCurrBSS->sRSNCapObj.wRSNCap, 2);
-               } else {
-                       pRSNIEs->abyRSN[16] = 0;
-                       pRSNIEs->abyRSN[17] = 0;
-               }
-               pRSNIEs->len += 2;
-
-               if ((pMgmt->gsPMKIDCache.BSSIDInfoCount > 0) &&
-                   pMgmt->bRoaming &&
-                   (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) {
-                       // RSN PMKID
-                       pwPMKID = (unsigned short *)(&pRSNIEs->abyRSN[18]);  // Point to PMKID count
-                       *pwPMKID = 0;                               // Initialize PMKID count
-                       pbyBuffer = &pRSNIEs->abyRSN[20];           // Point to PMKID list
-                       for (ii = 0; ii < pMgmt->gsPMKIDCache.BSSIDInfoCount; ii++) {
-                               if (!memcmp(&pMgmt->gsPMKIDCache.BSSIDInfo[ii].abyBSSID[0], pMgmt->abyCurrBSSID, ETH_ALEN)) {
-                                       (*pwPMKID)++;
-                                       memcpy(pbyBuffer, pMgmt->gsPMKIDCache.BSSIDInfo[ii].abyPMKID, 16);
-                                       pbyBuffer += 16;
-                               }
-                       }
-                       if (*pwPMKID != 0)
-                               pRSNIEs->len += (2 + (*pwPMKID)*16);
-                       else
-                               pbyBuffer = &pRSNIEs->abyRSN[18];
-               }
-               return pRSNIEs->len + WLAN_IEHDR_LEN;
-       }
-       return 0;
-}
diff --git a/drivers/staging/vt6655/wpa2.h b/drivers/staging/vt6655/wpa2.h
deleted file mode 100644 (file)
index 2d0bd2e..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: wpa2.h
- *
- * Purpose: Defines the macros, types, and functions for dealing
- *          with WPA2 informations.
- *
- * Author: Yiching Chen
- *
- * Date: Oct. 4, 2004
- *
- */
-
-#ifndef __WPA2_H__
-#define __WPA2_H__
-
-#include "ttype.h"
-#include "80211mgr.h"
-#include "80211hdr.h"
-#include "bssdb.h"
-
-/*---------------------  Export Definitions -------------------------*/
-#define MAX_PMKID_CACHE         16
-
-typedef struct tagsPMKIDInfo {
-       unsigned char abyBSSID[6];
-       unsigned char abyPMKID[16];
-} PMKIDInfo, *PPMKIDInfo;
-
-typedef struct tagSPMKIDCache {
-       unsigned long BSSIDInfoCount;
-       PMKIDInfo   BSSIDInfo[MAX_PMKID_CACHE];
-} SPMKIDCache, *PSPMKIDCache;
-
-/*---------------------  Export Classes  ----------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Types  ------------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-void
-WPA2_ClearRSN(
-       PKnownBSS        pBSSNode
-);
-
-void
-WPA2vParseRSN(
-       PKnownBSS        pBSSNode,
-       PWLAN_IE_RSN     pRSN
-);
-
-unsigned int
-WPA2uSetIEs(
-       void *pMgmtHandle,
-       PWLAN_IE_RSN pRSNIEs
-);
-
-#endif // __WPA2_H__
diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c
deleted file mode 100644 (file)
index dab1e80..0000000
+++ /dev/null
@@ -1,896 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * File: wpactl.c
- *
- * Purpose: handle wpa supplicant ioctl input/out functions
- *
- * Author: Lyndon Chen
- *
- * Date: Oct. 20, 2003
- *
- * Functions:
- *
- * Revision History:
- *
- */
-
-#include "wpactl.h"
-#include "key.h"
-#include "mac.h"
-#include "device.h"
-#include "wmgr.h"
-#include "iocmd.h"
-#include "iowpa.h"
-#include "rf.h"
-
-/*---------------------  Static Definitions -------------------------*/
-
-#define VIAWGET_WPA_MAX_BUF_SIZE 1024
-
-static const int frequency_list[] = {
-       2412, 2417, 2422, 2427, 2432, 2437, 2442,
-       2447, 2452, 2457, 2462, 2467, 2472, 2484
-};
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Functions  --------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-static void wpadev_setup(struct net_device *dev)
-{
-       dev->type               = ARPHRD_IEEE80211;
-       dev->hard_header_len    = ETH_HLEN;
-       dev->mtu                = 2048;
-       dev->addr_len           = ETH_ALEN;
-       dev->tx_queue_len       = 1000;
-
-       memset(dev->broadcast, 0xFF, ETH_ALEN);
-
-       dev->flags              = IFF_BROADCAST|IFF_MULTICAST;
-}
-
-/*
- * Description:
- *      register netdev for wpa supplicant daemon
- *
- * Parameters:
- *  In:
- *      pDevice             -
- *      enable              -
- *  Out:
- *
- * Return Value:
- *
- */
-
-static int wpa_init_wpadev(struct vnt_private *pDevice)
-{
-       struct vnt_private *wpadev_priv;
-       struct net_device *dev = pDevice->dev;
-       int ret = 0;
-
-       pDevice->wpadev = alloc_netdev(sizeof(*wpadev_priv), "vntwpa",
-                                      NET_NAME_UNKNOWN, wpadev_setup);
-       if (pDevice->wpadev == NULL)
-               return -ENOMEM;
-
-       wpadev_priv = netdev_priv(pDevice->wpadev);
-       *wpadev_priv = *pDevice;
-       eth_hw_addr_inherit(pDevice->wpadev, dev);
-       pDevice->wpadev->base_addr = dev->base_addr;
-       pDevice->wpadev->irq = dev->irq;
-       pDevice->wpadev->mem_start = dev->mem_start;
-       pDevice->wpadev->mem_end = dev->mem_end;
-       ret = register_netdev(pDevice->wpadev);
-       if (ret) {
-               pr_debug("%s: register_netdev(WPA) failed!\n", dev->name);
-               free_netdev(pDevice->wpadev);
-               return -1;
-       }
-
-       if (pDevice->skb == NULL) {
-               pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
-               if (pDevice->skb == NULL)
-                       return -ENOMEM;
-       }
-
-       pr_debug("%s: Registered netdev %s for WPA management\n",
-                dev->name, pDevice->wpadev->name);
-
-       return 0;
-}
-
-/*
- * Description:
- *      unregister net_device (wpadev)
- *
- * Parameters:
- *  In:
- *      pDevice             -
- *  Out:
- *
- * Return Value:
- *
- */
-
-static int wpa_release_wpadev(struct vnt_private *pDevice)
-{
-       if (pDevice->skb) {
-               dev_kfree_skb(pDevice->skb);
-               pDevice->skb = NULL;
-       }
-
-       if (pDevice->wpadev) {
-               pr_debug("%s: Netdevice %s unregistered\n",
-                        pDevice->dev->name, pDevice->wpadev->name);
-               unregister_netdev(pDevice->wpadev);
-               free_netdev(pDevice->wpadev);
-               pDevice->wpadev = NULL;
-       }
-
-       return 0;
-}
-
-/*
- * Description:
- *      Set enable/disable dev for wpa supplicant daemon
- *
- * Parameters:
- *  In:
- *      pDevice             -
- *      val                 -
- *  Out:
- *
- * Return Value:
- *
- */
-
-int wpa_set_wpadev(struct vnt_private *pDevice, int val)
-{
-       if (val)
-               return wpa_init_wpadev(pDevice);
-       else
-               return wpa_release_wpadev(pDevice);
-}
-
-/*
- * Description:
- *      Set WPA algorithm & keys
- *
- * Parameters:
- *  In:
- *      pDevice -
- *      param -
- *  Out:
- *
- * Return Value:
- *
- */
-
-int wpa_set_keys(struct vnt_private *pDevice, void *ctx,
-                bool fcpfkernel) __must_hold(&pDevice->lock)
-{
-       struct viawget_wpa_param *param = ctx;
-       PSMgmtObject pMgmt = pDevice->pMgmt;
-       unsigned long dwKeyIndex = 0;
-       unsigned char abyKey[MAX_KEY_LEN];
-       unsigned char abySeq[MAX_KEY_LEN];
-       u64 KeyRSC;
-       unsigned char byKeyDecMode = KEY_CTL_WEP;
-       int ret = 0;
-       int uu, ii;
-
-       if (param->u.wpa_key.alg_name > WPA_ALG_CCMP ||
-           param->u.wpa_key.key_len > MAX_KEY_LEN ||
-           param->u.wpa_key.seq_len > MAX_KEY_LEN)
-               return -EINVAL;
-
-       pr_debug("param->u.wpa_key.alg_name = %d\n", param->u.wpa_key.alg_name);
-       if (param->u.wpa_key.alg_name == WPA_ALG_NONE) {
-               pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
-               pDevice->bEncryptionEnable = false;
-               pDevice->byKeyIndex = 0;
-               pDevice->bTransmitKey = false;
-               KeyvRemoveAllWEPKey(&(pDevice->sKey), pDevice->PortOffset);
-               for (uu = 0; uu < MAX_KEY_TABLE; uu++)
-                       MACvDisableKeyEntry(pDevice->PortOffset, uu);
-
-               return ret;
-       }
-
-       if (param->u.wpa_key.key && fcpfkernel) {
-               memcpy(&abyKey[0], param->u.wpa_key.key, param->u.wpa_key.key_len);
-       } else {
-               spin_unlock_irq(&pDevice->lock);
-               if (param->u.wpa_key.key &&
-                   copy_from_user(&abyKey[0],
-                                  (void __user *)param->u.wpa_key.key,
-                                  param->u.wpa_key.key_len)) {
-                       spin_lock_irq(&pDevice->lock);
-                       return -EINVAL;
-               }
-               spin_lock_irq(&pDevice->lock);
-       }
-
-       dwKeyIndex = (unsigned long)(param->u.wpa_key.key_index);
-
-       if (param->u.wpa_key.alg_name == WPA_ALG_WEP) {
-               if (dwKeyIndex > 3) {
-                       return -EINVAL;
-               } else {
-                       if (param->u.wpa_key.set_tx) {
-                               pDevice->byKeyIndex = (unsigned char)dwKeyIndex;
-                               pDevice->bTransmitKey = true;
-                               dwKeyIndex |= (1 << 31);
-                       }
-                       KeybSetDefaultKey(&(pDevice->sKey),
-                                         dwKeyIndex & ~(BIT30 | USE_KEYRSC),
-                                         param->u.wpa_key.key_len,
-                                         NULL,
-                                         abyKey,
-                                         KEY_CTL_WEP,
-                                         pDevice->PortOffset,
-                                         pDevice->byLocalID);
-
-               }
-               pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
-               pDevice->bEncryptionEnable = true;
-               return ret;
-       }
-
-       if (param->u.wpa_key.seq && fcpfkernel) {
-               memcpy(&abySeq[0], param->u.wpa_key.seq, param->u.wpa_key.seq_len);
-       } else {
-               spin_unlock_irq(&pDevice->lock);
-               if (param->u.wpa_key.seq &&
-                   copy_from_user(&abySeq[0],
-                                  (void __user *)param->u.wpa_key.seq,
-                                  param->u.wpa_key.seq_len)) {
-                       spin_lock_irq(&pDevice->lock);
-                       return -EINVAL;
-               }
-               spin_lock_irq(&pDevice->lock);
-       }
-
-       if (param->u.wpa_key.seq_len > 0) {
-               for (ii = 0; ii < param->u.wpa_key.seq_len; ii++) {
-                       if (ii < 4)
-                               KeyRSC |= (u64)(abySeq[ii] << (ii * 8));
-                       else
-                               KeyRSC |= (u64)(abySeq[ii] << ((ii-4) * 8));
-               }
-               dwKeyIndex |= 1 << 29;
-       }
-
-       if (param->u.wpa_key.key_index >= MAX_GROUP_KEY) {
-               pr_debug("return  dwKeyIndex > 3\n");
-               return -EINVAL;
-       }
-
-       if (param->u.wpa_key.alg_name == WPA_ALG_TKIP)
-               pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
-
-       if (param->u.wpa_key.alg_name == WPA_ALG_CCMP)
-               pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
-
-       if (param->u.wpa_key.set_tx)
-               dwKeyIndex |= (1 << 31);
-
-       if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)
-               byKeyDecMode = KEY_CTL_CCMP;
-       else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled)
-               byKeyDecMode = KEY_CTL_TKIP;
-       else
-               byKeyDecMode = KEY_CTL_WEP;
-
-       /* Fix HCT test that set 256 bits KEY and Ndis802_11Encryption3Enabled */
-       if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
-               if (param->u.wpa_key.key_len == MAX_KEY_LEN)
-                       byKeyDecMode = KEY_CTL_TKIP;
-               else if (param->u.wpa_key.key_len == WLAN_WEP40_KEYLEN)
-                       byKeyDecMode = KEY_CTL_WEP;
-               else if (param->u.wpa_key.key_len == WLAN_WEP104_KEYLEN)
-                       byKeyDecMode = KEY_CTL_WEP;
-       } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
-               if (param->u.wpa_key.key_len == WLAN_WEP40_KEYLEN)
-                       byKeyDecMode = KEY_CTL_WEP;
-               else if (param->u.wpa_key.key_len == WLAN_WEP104_KEYLEN)
-                       byKeyDecMode = KEY_CTL_WEP;
-       }
-
-       /* Check TKIP key length */
-       if ((byKeyDecMode == KEY_CTL_TKIP) &&
-           (param->u.wpa_key.key_len != MAX_KEY_LEN)) {
-               /* TKIP Key must be 256 bits */
-               pr_debug("return- TKIP Key must be 256 bits!\n");
-               return -EINVAL;
-       }
-       /* Check AES key length */
-       if ((byKeyDecMode == KEY_CTL_CCMP) &&
-           (param->u.wpa_key.key_len != AES_KEY_LEN)) {
-               /* AES Key must be 128 bits */
-               return -EINVAL;
-       }
-
-       /* spin_lock_irq(&pDevice->lock); */
-       if (is_broadcast_ether_addr(&param->addr[0]) || (param->addr == NULL)) {
-               /* If is_broadcast_ether_addr, set the key as every key entry's group key. */
-               pr_debug("Groupe Key Assign\n");
-
-               if (KeybSetAllGroupKey(&(pDevice->sKey),
-                                       dwKeyIndex,
-                                       param->u.wpa_key.key_len,
-                                       (u64 *) &KeyRSC,
-                                       (unsigned char *)abyKey,
-                                       byKeyDecMode,
-                                       pDevice->PortOffset,
-                                       pDevice->byLocalID) &&
-                   KeybSetDefaultKey(&(pDevice->sKey),
-                                      dwKeyIndex,
-                                      param->u.wpa_key.key_len,
-                                      (u64 *) &KeyRSC,
-                                      (unsigned char *)abyKey,
-                                      byKeyDecMode,
-                                      pDevice->PortOffset,
-                                      pDevice->byLocalID)) {
-                       pr_debug("GROUP Key Assign\n");
-
-               } else {
-                       return -EINVAL;
-               }
-
-       } else {
-               pr_debug("Pairwise Key Assign\n");
-               /* BSSID not 0xffffffffffff */
-               /* Pairwise Key can't be WEP */
-               if (byKeyDecMode == KEY_CTL_WEP) {
-                       pr_debug("Pairwise Key can't be WEP\n");
-                       return -EINVAL;
-               }
-
-               dwKeyIndex |= (1 << 30); /* set pairwise key */
-               if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA)
-                       return -EINVAL;
-
-               if (KeybSetKey(&(pDevice->sKey),
-                              &param->addr[0],
-                              dwKeyIndex,
-                              param->u.wpa_key.key_len,
-                              (u64 *) &KeyRSC,
-                              (unsigned char *)abyKey,
-                              byKeyDecMode,
-                              pDevice->PortOffset,
-                              pDevice->byLocalID)) {
-                       pr_debug("Pairwise Key Set\n");
-
-               } else {
-                       /* Key Table Full */
-                       return -EINVAL;
-               }
-       } /* BSSID not 0xffffffffffff */
-       if ((ret == 0) && ((param->u.wpa_key.set_tx) != 0)) {
-               pDevice->byKeyIndex = (unsigned char)param->u.wpa_key.key_index;
-               pDevice->bTransmitKey = true;
-       }
-       pDevice->bEncryptionEnable = true;
-
-       return ret;
-}
-
-/*
- * Description:
- *      enable wpa auth & mode
- *
- * Parameters:
- *  In:
- *      pDevice   -
- *      param     -
- *  Out:
- *
- * Return Value:
- *
- */
-
-static int wpa_set_wpa(struct vnt_private *pDevice,
-                      struct viawget_wpa_param *param)
-{
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-
-       pMgmt->eAuthenMode = WMAC_AUTH_OPEN;
-       pMgmt->bShareKeyAlgorithm = false;
-
-       return 0;
-}
-
-/*
- * Description:
- *      set disassociate
- *
- * Parameters:
- *  In:
- *      pDevice   -
- *      param     -
- *  Out:
- *
- * Return Value:
- *
- */
-
-static int wpa_set_disassociate(struct vnt_private *pDevice,
-                               struct viawget_wpa_param *param)
-{
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-
-       spin_lock_irq(&pDevice->lock);
-       if (pDevice->bLinkPass) {
-               if (!memcmp(param->addr, pMgmt->abyCurrBSSID, 6))
-                       bScheduleCommand((void *)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
-       }
-       spin_unlock_irq(&pDevice->lock);
-
-       return 0;
-}
-
-/*
- * Description:
- *      enable scan process
- *
- * Parameters:
- *  In:
- *      pDevice   -
- *      param     -
- *  Out:
- *
- * Return Value:
- *
- */
-
-static int wpa_set_scan(struct vnt_private *pDevice,
-                       struct viawget_wpa_param *param)
-{
-       spin_lock_irq(&pDevice->lock);
-       BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass);
-       bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL);
-       spin_unlock_irq(&pDevice->lock);
-
-       return 0;
-}
-
-/*
- * Description:
- *      get bssid
- *
- * Parameters:
- *  In:
- *      pDevice   -
- *      param     -
- *  Out:
- *
- * Return Value:
- *
- */
-
-static int wpa_get_bssid(struct vnt_private *pDevice,
-                        struct viawget_wpa_param *param)
-{
-       PSMgmtObject        pMgmt = pDevice->pMgmt;
-
-       memcpy(param->u.wpa_associate.bssid, pMgmt->abyCurrBSSID , 6);
-
-       return 0;
-}
-
-/*
- * Description:
- *      get bssid
- *
- * Parameters:
- *  In:
- *      pDevice   -
- *      param     -
- *  Out:
- *
- * Return Value:
- *
- */
-
-static int wpa_get_ssid(struct vnt_private *pDevice,
-                       struct viawget_wpa_param *param)
-{
-       PSMgmtObject        pMgmt = pDevice->pMgmt;
-       PWLAN_IE_SSID       pItemSSID;
-
-       pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
-
-       memcpy(param->u.wpa_associate.ssid, pItemSSID->abySSID , pItemSSID->len);
-       param->u.wpa_associate.ssid_len = pItemSSID->len;
-
-       return 0;
-}
-
-/*
- * Description:
- *      get scan results
- *
- * Parameters:
- *  In:
- *      pDevice   -
- *      param     -
- *  Out:
- *
- * Return Value:
- *
- */
-
-static int wpa_get_scan(struct vnt_private *pDevice,
-                       struct viawget_wpa_param *param)
-{
-       struct viawget_scan_result *scan_buf;
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       PWLAN_IE_SSID   pItemSSID;
-       PKnownBSS pBSS;
-       unsigned char *pBuf;
-       int ret = 0;
-       u16 count = 0;
-       u16 ii, jj;
-#if 1
-
-       unsigned char *ptempBSS;
-
-       ptempBSS = kmalloc(sizeof(KnownBSS), GFP_ATOMIC);
-
-       if (ptempBSS == NULL) {
-               pr_err("bubble sort kmalloc memory fail@@@\n");
-
-               ret = -ENOMEM;
-
-               return ret;
-
-       }
-
-       for (ii = 0; ii < MAX_BSS_NUM; ii++) {
-               for (jj = 0; jj < MAX_BSS_NUM - ii - 1; jj++) {
-                       if ((pMgmt->sBSSList[jj].bActive != true) ||
-
-                           ((pMgmt->sBSSList[jj].uRSSI > pMgmt->sBSSList[jj + 1].uRSSI) && (pMgmt->sBSSList[jj + 1].bActive != false))) {
-                               memcpy(ptempBSS, &pMgmt->sBSSList[jj], sizeof(KnownBSS));
-
-                               memcpy(&pMgmt->sBSSList[jj], &pMgmt->sBSSList[jj + 1], sizeof(KnownBSS));
-
-                               memcpy(&pMgmt->sBSSList[jj + 1], ptempBSS, sizeof(KnownBSS));
-
-                       }
-
-               }
-
-       }
-
-       kfree(ptempBSS);
-#endif
-
-//******mike:bubble sort by stronger RSSI*****//
-
-       count = 0;
-       pBSS = &(pMgmt->sBSSList[0]);
-       for (ii = 0; ii < MAX_BSS_NUM; ii++) {
-               pBSS = &(pMgmt->sBSSList[ii]);
-               if (!pBSS->bActive)
-                       continue;
-               count++;
-       }
-
-       pBuf = kcalloc(count, sizeof(struct viawget_scan_result), GFP_ATOMIC);
-
-       if (pBuf == NULL) {
-               ret = -ENOMEM;
-               return ret;
-       }
-       scan_buf = (struct viawget_scan_result *)pBuf;
-       pBSS = &(pMgmt->sBSSList[0]);
-       for (ii = 0, jj = 0; ii < MAX_BSS_NUM; ii++) {
-               pBSS = &(pMgmt->sBSSList[ii]);
-               if (pBSS->bActive) {
-                       if (jj >= count)
-                               break;
-                       memcpy(scan_buf->bssid, pBSS->abyBSSID, WLAN_BSSID_LEN);
-                       pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
-                       memcpy(scan_buf->ssid, pItemSSID->abySSID, pItemSSID->len);
-                       scan_buf->ssid_len = pItemSSID->len;
-                       scan_buf->freq = frequency_list[pBSS->uChannel-1];
-                       scan_buf->caps = pBSS->wCapInfo;
-
-                       if (pBSS->wWPALen != 0) {
-                               scan_buf->wpa_ie_len = pBSS->wWPALen;
-                               memcpy(scan_buf->wpa_ie, pBSS->byWPAIE, pBSS->wWPALen);
-                       }
-                       if (pBSS->wRSNLen != 0) {
-                               scan_buf->rsn_ie_len = pBSS->wRSNLen;
-                               memcpy(scan_buf->rsn_ie, pBSS->byRSNIE, pBSS->wRSNLen);
-                       }
-                       scan_buf = (struct viawget_scan_result *)((unsigned char *)scan_buf + sizeof(struct viawget_scan_result));
-                       jj++;
-               }
-       }
-
-       if (jj < count)
-               count = jj;
-
-       if (copy_to_user(param->u.scan_results.buf, pBuf, sizeof(struct viawget_scan_result) * count))
-               ret = -EFAULT;
-
-       param->u.scan_results.scan_count = count;
-       pr_debug(" param->u.scan_results.scan_count = %d\n", count);
-
-               kfree(pBuf);
-       return ret;
-}
-
-/*
- * Description:
- *      set associate with AP
- *
- * Parameters:
- *  In:
- *      pDevice   -
- *      param     -
- *  Out:
- *
- * Return Value:
- *
- */
-
-static int wpa_set_associate(struct vnt_private *pDevice,
-                            struct viawget_wpa_param *param)
-{
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       PWLAN_IE_SSID   pItemSSID;
-       unsigned char abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-       unsigned char abyWPAIE[64];
-       bool bWepEnabled = false;
-
-       /* set key type & algorithm */
-       pr_debug("pairwise_suite = %d\n",
-                param->u.wpa_associate.pairwise_suite);
-       pr_debug("group_suite = %d\n", param->u.wpa_associate.group_suite);
-       pr_debug("key_mgmt_suite = %d\n",
-                param->u.wpa_associate.key_mgmt_suite);
-       pr_debug("auth_alg = %d\n", param->u.wpa_associate.auth_alg);
-       pr_debug("mode = %d\n", param->u.wpa_associate.mode);
-       pr_debug("wpa_ie_len = %d\n", param->u.wpa_associate.wpa_ie_len);
-
-       if (param->u.wpa_associate.wpa_ie_len) {
-               if (!param->u.wpa_associate.wpa_ie)
-                       return -EINVAL;
-               if (param->u.wpa_associate.wpa_ie_len > sizeof(abyWPAIE))
-                       return -EINVAL;
-               if (copy_from_user(&abyWPAIE[0], param->u.wpa_associate.wpa_ie, param->u.wpa_associate.wpa_ie_len))
-                       return -EFAULT;
-       }
-
-       if (param->u.wpa_associate.mode == 1)
-               pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
-       else
-               pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
-       /* set ssid */
-       memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
-       pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
-       pItemSSID->byElementID = WLAN_EID_SSID;
-       pItemSSID->len = param->u.wpa_associate.ssid_len;
-       memcpy(pItemSSID->abySSID, param->u.wpa_associate.ssid, pItemSSID->len);
-       /* set bssid */
-       if (memcmp(param->u.wpa_associate.bssid, &abyNullAddr[0], 6) != 0)
-               memcpy(pMgmt->abyDesireBSSID, param->u.wpa_associate.bssid, 6);
-       else
-               bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pItemSSID->abySSID);
-
-       if (param->u.wpa_associate.wpa_ie_len == 0) {
-               if (param->u.wpa_associate.auth_alg & AUTH_ALG_SHARED_KEY)
-                       pMgmt->eAuthenMode = WMAC_AUTH_SHAREKEY;
-               else
-                       pMgmt->eAuthenMode = WMAC_AUTH_OPEN;
-       } else if (abyWPAIE[0] == RSN_INFO_ELEM) {
-               if (param->u.wpa_associate.key_mgmt_suite == KEY_MGMT_PSK)
-                       pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK;
-               else
-                       pMgmt->eAuthenMode = WMAC_AUTH_WPA2;
-       } else {
-               if (param->u.wpa_associate.key_mgmt_suite == KEY_MGMT_WPA_NONE)
-                       pMgmt->eAuthenMode = WMAC_AUTH_WPANONE;
-               else if (param->u.wpa_associate.key_mgmt_suite == KEY_MGMT_PSK)
-                       pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK;
-               else
-                       pMgmt->eAuthenMode = WMAC_AUTH_WPA;
-       }
-
-       switch (param->u.wpa_associate.pairwise_suite) {
-       case CIPHER_CCMP:
-               pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
-               break;
-       case CIPHER_TKIP:
-               pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
-               break;
-       case CIPHER_WEP40:
-       case CIPHER_WEP104:
-               pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
-               bWepEnabled = true;
-               break;
-       case CIPHER_NONE:
-               if (param->u.wpa_associate.group_suite == CIPHER_CCMP)
-                       pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
-               else
-                       pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
-               break;
-       default:
-               pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
-       }
-
-//DavidWang add for WPA_supplicant support open/share mode
-
-       if (pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) {
-               pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
-               pMgmt->bShareKeyAlgorithm = true;
-       } else if (pMgmt->eAuthenMode == WMAC_AUTH_OPEN) {
-               if (!bWepEnabled)  pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
-               else pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
-       }
-//mike save old encryption status
-       pDevice->eOldEncryptionStatus = pDevice->eEncryptionStatus;
-
-       if (pDevice->eEncryptionStatus !=  Ndis802_11EncryptionDisabled)
-               pDevice->bEncryptionEnable = true;
-       else
-               pDevice->bEncryptionEnable = false;
-       if (!((pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) ||
-             ((pMgmt->eAuthenMode == WMAC_AUTH_OPEN) && bWepEnabled)))  //DavidWang  //20080717-06,<Modify> by chester//Not to initial WEP
-               KeyvInitTable(&pDevice->sKey, pDevice->PortOffset);
-       spin_lock_irq(&pDevice->lock);
-       pDevice->bLinkPass = false;
-       memset(pMgmt->abyCurrBSSID, 0, 6);
-       pMgmt->eCurrState = WMAC_STATE_IDLE;
-       netif_stop_queue(pDevice->dev);
-       //20080701-02,<Add> by Mike Liu
-/*******search if ap_scan=2 ,which is associating request in hidden ssid mode ****/
-       {
-               PKnownBSS       pCurr = NULL;
-
-               pCurr = BSSpSearchBSSList(pDevice,
-                                         pMgmt->abyDesireBSSID,
-                                         pMgmt->abyDesireSSID,
-                                         pMgmt->eConfigPHYMode
-);
-
-               if (pCurr == NULL) {
-                       pr_debug("wpa_set_associate---->hidden mode site survey before associate.......\n");
-                       bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
-               }
-       }
-/****************************************************************/
-       bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL);
-       spin_unlock_irq(&pDevice->lock);
-
-       return 0;
-}
-
-/*
- * Description:
- *      wpa_ioctl main function supported for wpa supplicant
- *
- * Parameters:
- *  In:
- *      pDevice   -
- *      iw_point  -
- *  Out:
- *
- * Return Value:
- *
- */
-
-int wpa_ioctl(struct vnt_private *pDevice, struct iw_point *p)
-{
-       struct viawget_wpa_param *param;
-       int ret = 0;
-       int wpa_ioctl = 0;
-
-       if (p->length < sizeof(struct viawget_wpa_param) ||
-           p->length > VIAWGET_WPA_MAX_BUF_SIZE || !p->pointer)
-               return -EINVAL;
-
-       param = kmalloc((int)p->length, GFP_KERNEL);
-       if (param == NULL)
-               return -ENOMEM;
-
-       if (copy_from_user(param, p->pointer, p->length)) {
-               ret = -EFAULT;
-               goto out;
-       }
-
-       switch (param->cmd) {
-       case VIAWGET_SET_WPA:
-               ret = wpa_set_wpa(pDevice, param);
-               pr_debug("VIAWGET_SET_WPA\n");
-               break;
-
-       case VIAWGET_SET_KEY:
-               pr_debug("VIAWGET_SET_KEY\n");
-               spin_lock_irq(&pDevice->lock);
-               ret = wpa_set_keys(pDevice, param, false);
-               spin_unlock_irq(&pDevice->lock);
-               break;
-
-       case VIAWGET_SET_SCAN:
-               pr_debug("VIAWGET_SET_SCAN\n");
-               ret = wpa_set_scan(pDevice, param);
-               break;
-
-       case VIAWGET_GET_SCAN:
-               pr_debug("VIAWGET_GET_SCAN\n");
-               ret = wpa_get_scan(pDevice, param);
-               wpa_ioctl = 1;
-               break;
-
-       case VIAWGET_GET_SSID:
-               pr_debug("VIAWGET_GET_SSID\n");
-               ret = wpa_get_ssid(pDevice, param);
-               wpa_ioctl = 1;
-               break;
-
-       case VIAWGET_GET_BSSID:
-               pr_debug("VIAWGET_GET_BSSID\n");
-               ret = wpa_get_bssid(pDevice, param);
-               wpa_ioctl = 1;
-               break;
-
-       case VIAWGET_SET_ASSOCIATE:
-               pr_debug("VIAWGET_SET_ASSOCIATE\n");
-               ret = wpa_set_associate(pDevice, param);
-               break;
-
-       case VIAWGET_SET_DISASSOCIATE:
-               pr_debug("VIAWGET_SET_DISASSOCIATE\n");
-               ret = wpa_set_disassociate(pDevice, param);
-               break;
-
-       case VIAWGET_SET_DROP_UNENCRYPT:
-               pr_debug("VIAWGET_SET_DROP_UNENCRYPT\n");
-               break;
-
-       case VIAWGET_SET_DEAUTHENTICATE:
-               pr_debug("VIAWGET_SET_DEAUTHENTICATE\n");
-               break;
-
-       default:
-               pr_debug("wpa_ioctl: unknown cmd=%d\n",
-                        param->cmd);
-               ret = -EOPNOTSUPP;
-               goto out;
-       }
-
-       if ((ret == 0) && wpa_ioctl) {
-               if (copy_to_user(p->pointer, param, p->length)) {
-                       ret = -EFAULT;
-                       goto out;
-               }
-       }
-
-out:
-       kfree(param);
-
-       return ret;
-}
diff --git a/drivers/staging/vt6655/wpactl.h b/drivers/staging/vt6655/wpactl.h
deleted file mode 100644 (file)
index c1b4a72..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: wpactl.h
- *
- * Purpose:
- *
- * Author: Lyndon Chen
- *
- * Date: March 1, 2005
- *
- */
-
-#ifndef __WPACTL_H__
-#define __WPACTL_H__
-
-#include "device.h"
-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-#include "iowpa.h"
-#endif
-
-/*---------------------  Export Definitions -------------------------*/
-
-//WPA related
-
-enum wpa_alg { WPA_ALG_NONE, WPA_ALG_WEP, WPA_ALG_TKIP, WPA_ALG_CCMP };
-enum wpa_cipher { CIPHER_NONE, CIPHER_WEP40, CIPHER_TKIP, CIPHER_CCMP,
-                 CIPHER_WEP104 };
-enum wpa_key_mgmt { KEY_MGMT_802_1X, KEY_MGMT_CCKM, KEY_MGMT_PSK, KEY_MGMT_NONE,
-                   KEY_MGMT_802_1X_NO_WPA, KEY_MGMT_WPA_NONE };
-
-#define AUTH_ALG_OPEN_SYSTEM   0x01
-#define AUTH_ALG_SHARED_KEY    0x02
-#define AUTH_ALG_LEAP          0x04
-
-#define GENERIC_INFO_ELEM 0xdd
-#define RSN_INFO_ELEM 0x30
-
-/*---------------------  Export Classes  ----------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-int wpa_set_wpadev(struct vnt_private *, int val);
-int wpa_ioctl(struct vnt_private *, struct iw_point *p);
-int wpa_set_keys(struct vnt_private *, void *ctx, bool fcpfkernel);
-
-#endif // __WPACL_H__
diff --git a/drivers/staging/vt6655/wroute.c b/drivers/staging/vt6655/wroute.c
deleted file mode 100644 (file)
index d1171fa..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: wroute.c
- *
- * Purpose: handle WMAC frame relay & filtering
- *
- * Author: Lyndon Chen
- *
- * Date: May 20, 2003
- *
- * Functions:
- *      ROUTEbRelay - Relay packet
- *
- * Revision History:
- *
- */
-
-#include "mac.h"
-#include "tcrc.h"
-#include "rxtx.h"
-#include "wroute.h"
-#include "card.h"
-#include "baseband.h"
-
-/*---------------------  Static Definitions -------------------------*/
-
-/*---------------------  Static Classes  ----------------------------*/
-
-/*---------------------  Static Functions  --------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*
- * Description:
- *      Relay packet.  Return true if packet is copy to DMA1
- *
- * Parameters:
- *  In:
- *      pDevice             -
- *      pbySkbData          - rx packet skb data
- *  Out:
- *      true, false
- *
- * Return Value: true if packet duplicate; otherwise false
- *
- */
-bool ROUTEbRelay(struct vnt_private *pDevice, unsigned char *pbySkbData,
-                unsigned int uDataLen, unsigned int uNodeIndex)
-{
-       PSMgmtObject    pMgmt = pDevice->pMgmt;
-       PSTxDesc        pHeadTD, pLastTD;
-       unsigned int cbFrameBodySize;
-       unsigned int uMACfragNum;
-       unsigned char byPktType;
-       bool bNeedEncryption = false;
-       SKeyItem        STempKey;
-       PSKeyItem       pTransmitKey = NULL;
-       unsigned int cbHeaderSize;
-       unsigned int ii;
-       unsigned char *pbyBSSID;
-
-       if (AVAIL_TD(pDevice, TYPE_AC0DMA) <= 0) {
-               pr_debug("Relay can't allocate TD1..\n");
-               return false;
-       }
-
-       pHeadTD = pDevice->apCurrTD[TYPE_AC0DMA];
-
-       pHeadTD->m_td1TD1.byTCR = (TCR_EDP | TCR_STP);
-
-       memcpy(pDevice->sTxEthHeader.abyDstAddr, pbySkbData, ETH_HLEN);
-
-       cbFrameBodySize = uDataLen - ETH_HLEN;
-
-       if (ntohs(pDevice->sTxEthHeader.wType) > ETH_DATA_LEN)
-               cbFrameBodySize += 8;
-
-       if (pDevice->bEncryptionEnable == true) {
-               bNeedEncryption = true;
-
-               // get group key
-               pbyBSSID = pDevice->abyBroadcastAddr;
-               if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID,
-                   GROUP_KEY, &pTransmitKey) == false) {
-                       pTransmitKey = NULL;
-                       pr_debug("KEY is NULL. [%d]\n",
-                                pDevice->pMgmt->eCurrMode);
-               } else {
-                       pr_debug("Get GTK\n");
-               }
-       }
-
-       if (pDevice->bEnableHostWEP) {
-               if (uNodeIndex < MAX_NODE_NUM + 1) {
-                       pTransmitKey = &STempKey;
-                       pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite;
-                       pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex;
-                       pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength;
-                       pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16;
-                       pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0;
-                       memcpy(pTransmitKey->abyKey,
-                              &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0],
-                              pTransmitKey->uKeyLength);
-               }
-       }
-
-       uMACfragNum = cbGetFragCount(pDevice, pTransmitKey,
-                                    cbFrameBodySize, &pDevice->sTxEthHeader);
-
-       if (uMACfragNum > AVAIL_TD(pDevice, TYPE_AC0DMA))
-               return false;
-
-       byPktType = pDevice->byPacketType;
-
-       if (pDevice->bFixRate) {
-               if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
-                       if (pDevice->uConnectionRate >= RATE_11M)
-                               pDevice->wCurrentRate = RATE_11M;
-                       else
-                               pDevice->wCurrentRate = pDevice->uConnectionRate;
-               } else {
-                       if ((pDevice->eCurrentPHYType == PHY_TYPE_11A) &&
-                           (pDevice->uConnectionRate <= RATE_6M)) {
-                               pDevice->wCurrentRate = RATE_6M;
-                       } else {
-                               if (pDevice->uConnectionRate >= RATE_54M)
-                                       pDevice->wCurrentRate = RATE_54M;
-                               else
-                                       pDevice->wCurrentRate = pDevice->uConnectionRate;
-                       }
-               }
-       } else {
-               pDevice->wCurrentRate = pDevice->pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate;
-       }
-
-       if (pDevice->wCurrentRate <= RATE_11M)
-               byPktType = PK_TYPE_11B;
-
-       vGenerateFIFOHeader(pDevice, byPktType, pDevice->pbyTmpBuff,
-                           bNeedEncryption, cbFrameBodySize, TYPE_AC0DMA,
-                           pHeadTD, &pDevice->sTxEthHeader, pbySkbData,
-                           pTransmitKey, uNodeIndex, &uMACfragNum,
-                           &cbHeaderSize);
-
-       if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) {
-               // Disable PS
-               MACbPSWakeup(pDevice->PortOffset);
-       }
-
-       pDevice->bPWBitOn = false;
-
-       pLastTD = pHeadTD;
-       for (ii = 0; ii < uMACfragNum; ii++) {
-               // Poll Transmit the adapter
-               wmb();
-               pHeadTD->m_td0TD0.f1Owner = OWNED_BY_NIC;
-               wmb();
-               if (ii == (uMACfragNum - 1))
-                       pLastTD = pHeadTD;
-               pHeadTD = pHeadTD->next;
-       }
-
-       pLastTD->pTDInfo->skb = NULL;
-       pLastTD->pTDInfo->byFlags = 0;
-
-       pDevice->apCurrTD[TYPE_AC0DMA] = pHeadTD;
-
-       MACvTransmitAC0(pDevice->PortOffset);
-
-       return true;
-}
diff --git a/drivers/staging/vt6655/wroute.h b/drivers/staging/vt6655/wroute.h
deleted file mode 100644 (file)
index e59eec9..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: wroute.h
- *
- * Purpose:
- *
- * Author: Lyndon Chen
- *
- * Date: May 21, 2003
- *
- */
-
-#ifndef __WROUTE_H__
-#define __WROUTE_H__
-
-#include "device.h"
-
-/*---------------------  Export Definitions -------------------------*/
-
-/*---------------------  Export Classes  ----------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
-bool ROUTEbRelay(struct vnt_private *pDevice, unsigned char *pbySkbData,
-                unsigned int uDataLen, unsigned int uNodeIndex);
-
-#endif /* __WROUTE_H__ */
index 2fbff90..04ae6a2 100644 (file)
@@ -431,11 +431,8 @@ static bool vnt_alloc_bufs(struct vnt_private *priv)
        for (ii = 0; ii < priv->num_tx_context; ii++) {
                tx_context = kmalloc(sizeof(struct vnt_usb_send_context),
                                                                GFP_KERNEL);
-               if (tx_context == NULL) {
-                       dev_err(&priv->usb->dev,
-                                       "allocate tx usb context failed\n");
+               if (tx_context == NULL)
                        goto free_tx;
-               }
 
                priv->tx_context[ii] = tx_context;
                tx_context->priv = priv;
@@ -471,10 +468,8 @@ static bool vnt_alloc_bufs(struct vnt_private *priv)
                }
 
                rcb->skb = dev_alloc_skb(priv->rx_buf_sz);
-               if (rcb->skb == NULL) {
-                       dev_err(&priv->usb->dev, "Failed to alloc rx skb\n");
+               if (rcb->skb == NULL)
                        goto free_rx_tx;
-               }
 
                rcb->in_use = false;
 
@@ -491,7 +486,6 @@ static bool vnt_alloc_bufs(struct vnt_private *priv)
 
        priv->int_buf.data_buf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL);
        if (priv->int_buf.data_buf == NULL) {
-               dev_err(&priv->usb->dev, "Failed to alloc int buf\n");
                usb_free_urb(priv->interrupt_urb);
                goto free_rx_tx;
        }
index 1f2c78c..20d146b 100644 (file)
@@ -1376,6 +1376,7 @@ int hfa384x_drvr_setconfig(hfa384x_t *hw, u16 rid, void *buf, u16 len);
 static inline int hfa384x_drvr_getconfig16(hfa384x_t *hw, u16 rid, void *val)
 {
        int result = 0;
+
        result = hfa384x_drvr_getconfig(hw, rid, val, sizeof(u16));
        if (result == 0)
                *((u16 *) val) = le16_to_cpu(*((u16 *) val));
@@ -1385,6 +1386,7 @@ static inline int hfa384x_drvr_getconfig16(hfa384x_t *hw, u16 rid, void *val)
 static inline int hfa384x_drvr_setconfig16(hfa384x_t *hw, u16 rid, u16 val)
 {
        u16 value = cpu_to_le16(val);
+
        return hfa384x_drvr_setconfig(hw, rid, &value, sizeof(value));
 }
 
@@ -1402,6 +1404,7 @@ static inline int
 hfa384x_drvr_setconfig16_async(hfa384x_t *hw, u16 rid, u16 val)
 {
        u16 value = cpu_to_le16(val);
+
        return hfa384x_drvr_setconfig_async(hw, rid, &value, sizeof(value),
                                            NULL, NULL);
 }
index 898bde7..55d2f56 100644 (file)
@@ -3583,12 +3583,8 @@ static void hfa384x_int_rxmonitor(wlandevice_t *wlandev,
        }
 
        skb = dev_alloc_skb(skblen);
-       if (skb == NULL) {
-               netdev_err(hw->wlandev->netdev,
-                          "alloc_skb failed trying to allocate %d bytes\n",
-                          skblen);
+       if (skb == NULL)
                return;
-       }
 
        /* only prepend the prism header if in the right mode */
        if ((wlandev->netdev->type == ARPHRD_IEEE80211_PRISM) &&
index 3b5468c..7eaaf9a 100644 (file)
@@ -107,7 +107,7 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
                        struct p80211_metawep *p80211_wep)
 {
 
-       u16 fc;
+       __le16 fc;
        u16 proto;
        struct wlan_ethhdr e_hdr;
        struct wlan_llc *e_llc;
index 66b5e20..79d9b20 100644 (file)
 /* Generic 802.11 Header types */
 
 struct p80211_hdr_a3 {
-       u16 fc;
+       __le16 fc;
        u16 dur;
        u8 a1[ETH_ALEN];
        u8 a2[ETH_ALEN];
index 2dd9bf8..a9c1e0b 100644 (file)
@@ -358,7 +358,7 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb,
                 * and return success .
                 * TODO: we need a saner way to handle this
                 */
-               if (skb->protocol != ETH_P_80211_RAW) {
+               if (be16_to_cpu(skb->protocol) != ETH_P_80211_RAW) {
                        netif_start_queue(wlandev->netdev);
                        netdev_notice(netdev, "Tx attempt prior to association, frame dropped.\n");
                        netdev->stats.tx_dropped++;
@@ -369,7 +369,7 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb,
        }
 
        /* Check for raw transmits */
-       if (skb->protocol == ETH_P_80211_RAW) {
+       if (be16_to_cpu(skb->protocol) == ETH_P_80211_RAW) {
                if (!capable(CAP_NET_ADMIN)) {
                        result = 1;
                        goto failed;
index 6c38f79..e907380 100644 (file)
@@ -986,8 +986,8 @@ static int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk,
        u32 currlen;
        u32 currdaddr;
 
-       rstmsg = kmalloc(sizeof(*rstmsg), GFP_KERNEL);
-       rwrmsg = kmalloc(sizeof(*rwrmsg), GFP_KERNEL);
+       rstmsg = kzalloc(sizeof(*rstmsg), GFP_KERNEL);
+       rwrmsg = kzalloc(sizeof(*rwrmsg), GFP_KERNEL);
        if (!rstmsg || !rwrmsg) {
                kfree(rstmsg);
                kfree(rwrmsg);
@@ -997,7 +997,6 @@ static int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk,
        }
 
        /* Initialize the messages */
-       memset(rstmsg, 0, sizeof(*rstmsg));
        strcpy(rstmsg->devname, wlandev->name);
        rstmsg->msgcode = DIDmsg_p2req_ramdl_state;
        rstmsg->msglen = sizeof(*rstmsg);
@@ -1011,7 +1010,6 @@ static int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk,
        rstmsg->exeaddr.len = sizeof(u32);
        rstmsg->resultcode.len = sizeof(u32);
 
-       memset(rwrmsg, 0, sizeof(*rwrmsg));
        strcpy(rwrmsg->devname, wlandev->name);
        rwrmsg->msgcode = DIDmsg_p2req_ramdl_write;
        rwrmsg->msglen = sizeof(*rwrmsg);
index be7778b..709d49e 100644 (file)
@@ -2012,7 +2012,7 @@ static int xgifb_probe(struct pci_dev *pdev,
        XGIfb_get_fix(&fb_info->fix, -1, fb_info);
        fb_info->pseudo_palette = xgifb_info->pseudo_palette;
 
-       fb_alloc_cmap(&fb_info->cmap, 256 , 0);
+       fb_alloc_cmap(&fb_info->cmap, 256, 0);
 
 #ifdef CONFIG_MTRR
        xgifb_info->mtrr = mtrr_add(xgifb_info->video_base,
index d5f49d2..1f6f699 100644 (file)
@@ -4135,7 +4135,7 @@ static void XGI_SetGroup4(unsigned short ModeIdIndex,
                tempax -= 1;
 
                temp = (tempax & 0xFF00) >> 8;
-               temp = ((temp & 0x0003) << 4);
+               temp = (temp & 0x0003) << 4;
                xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp);
                temp = (tempax & 0x00FF);
                xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp);
index 1b452f8..be3437c 100644 (file)
@@ -9,11 +9,8 @@ void xgifb_reg_set(unsigned long port, u8 index, u8 data)
 
 u8 xgifb_reg_get(unsigned long port, u8 index)
 {
-       u8 data;
-
        outb(index, port);
-       data = inb(port + 1);
-       return data;
+       return inb(port + 1);
 }
 
 void xgifb_reg_and_or(unsigned long port, u8 index,
index b70237e..d0df456 100644 (file)
@@ -1,4 +1,5 @@
 # UAPI Header export list
+header-y += android/
 header-y += byteorder/
 header-y += can/
 header-y += caif/
diff --git a/include/uapi/linux/android/Kbuild b/include/uapi/linux/android/Kbuild
new file mode 100644 (file)
index 0000000..ca011ee
--- /dev/null
@@ -0,0 +1,2 @@
+# UAPI Header export list
+header-y += binder.h
diff --git a/include/uapi/linux/android/binder.h b/include/uapi/linux/android/binder.h
new file mode 100644 (file)
index 0000000..41420e3
--- /dev/null
@@ -0,0 +1,352 @@
+/*
+ * Copyright (C) 2008 Google, Inc.
+ *
+ * Based on, but no longer compatible with, the original
+ * OpenBinder.org binder driver interface, which is:
+ *
+ * Copyright (c) 2005 Palmsource, 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 _UAPI_LINUX_BINDER_H
+#define _UAPI_LINUX_BINDER_H
+
+#include <linux/types.h>
+#include <linux/ioctl.h>
+
+#define B_PACK_CHARS(c1, c2, c3, c4) \
+       ((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4))
+#define B_TYPE_LARGE 0x85
+
+enum {
+       BINDER_TYPE_BINDER      = B_PACK_CHARS('s', 'b', '*', B_TYPE_LARGE),
+       BINDER_TYPE_WEAK_BINDER = B_PACK_CHARS('w', 'b', '*', B_TYPE_LARGE),
+       BINDER_TYPE_HANDLE      = B_PACK_CHARS('s', 'h', '*', B_TYPE_LARGE),
+       BINDER_TYPE_WEAK_HANDLE = B_PACK_CHARS('w', 'h', '*', B_TYPE_LARGE),
+       BINDER_TYPE_FD          = B_PACK_CHARS('f', 'd', '*', B_TYPE_LARGE),
+};
+
+enum {
+       FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff,
+       FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100,
+};
+
+#ifdef BINDER_IPC_32BIT
+typedef __u32 binder_size_t;
+typedef __u32 binder_uintptr_t;
+#else
+typedef __u64 binder_size_t;
+typedef __u64 binder_uintptr_t;
+#endif
+
+/*
+ * This is the flattened representation of a Binder object for transfer
+ * between processes.  The 'offsets' supplied as part of a binder transaction
+ * contains offsets into the data where these structures occur.  The Binder
+ * driver takes care of re-writing the structure type and data as it moves
+ * between processes.
+ */
+struct flat_binder_object {
+       /* 8 bytes for large_flat_header. */
+       __u32           type;
+       __u32           flags;
+
+       /* 8 bytes of data. */
+       union {
+               binder_uintptr_t        binder; /* local object */
+               __u32                   handle; /* remote object */
+       };
+
+       /* extra data associated with local object */
+       binder_uintptr_t        cookie;
+};
+
+/*
+ * On 64-bit platforms where user code may run in 32-bits the driver must
+ * translate the buffer (and local binder) addresses appropriately.
+ */
+
+struct binder_write_read {
+       binder_size_t           write_size;     /* bytes to write */
+       binder_size_t           write_consumed; /* bytes consumed by driver */
+       binder_uintptr_t        write_buffer;
+       binder_size_t           read_size;      /* bytes to read */
+       binder_size_t           read_consumed;  /* bytes consumed by driver */
+       binder_uintptr_t        read_buffer;
+};
+
+/* Use with BINDER_VERSION, driver fills in fields. */
+struct binder_version {
+       /* driver protocol version -- increment with incompatible change */
+       __s32       protocol_version;
+};
+
+/* This is the current protocol version. */
+#ifdef BINDER_IPC_32BIT
+#define BINDER_CURRENT_PROTOCOL_VERSION 7
+#else
+#define BINDER_CURRENT_PROTOCOL_VERSION 8
+#endif
+
+#define BINDER_WRITE_READ              _IOWR('b', 1, struct binder_write_read)
+#define BINDER_SET_IDLE_TIMEOUT                _IOW('b', 3, __s64)
+#define BINDER_SET_MAX_THREADS         _IOW('b', 5, __u32)
+#define BINDER_SET_IDLE_PRIORITY       _IOW('b', 6, __s32)
+#define BINDER_SET_CONTEXT_MGR         _IOW('b', 7, __s32)
+#define BINDER_THREAD_EXIT             _IOW('b', 8, __s32)
+#define BINDER_VERSION                 _IOWR('b', 9, struct binder_version)
+
+/*
+ * NOTE: Two special error codes you should check for when calling
+ * in to the driver are:
+ *
+ * EINTR -- The operation has been interupted.  This should be
+ * handled by retrying the ioctl() until a different error code
+ * is returned.
+ *
+ * ECONNREFUSED -- The driver is no longer accepting operations
+ * from your process.  That is, the process is being destroyed.
+ * You should handle this by exiting from your process.  Note
+ * that once this error code is returned, all further calls to
+ * the driver from any thread will return this same code.
+ */
+
+enum transaction_flags {
+       TF_ONE_WAY      = 0x01, /* this is a one-way call: async, no return */
+       TF_ROOT_OBJECT  = 0x04, /* contents are the component's root object */
+       TF_STATUS_CODE  = 0x08, /* contents are a 32-bit status code */
+       TF_ACCEPT_FDS   = 0x10, /* allow replies with file descriptors */
+};
+
+struct binder_transaction_data {
+       /* The first two are only used for bcTRANSACTION and brTRANSACTION,
+        * identifying the target and contents of the transaction.
+        */
+       union {
+               /* target descriptor of command transaction */
+               __u32   handle;
+               /* target descriptor of return transaction */
+               binder_uintptr_t ptr;
+       } target;
+       binder_uintptr_t        cookie; /* target object cookie */
+       __u32           code;           /* transaction command */
+
+       /* General information about the transaction. */
+       __u32           flags;
+       pid_t           sender_pid;
+       uid_t           sender_euid;
+       binder_size_t   data_size;      /* number of bytes of data */
+       binder_size_t   offsets_size;   /* number of bytes of offsets */
+
+       /* If this transaction is inline, the data immediately
+        * follows here; otherwise, it ends with a pointer to
+        * the data buffer.
+        */
+       union {
+               struct {
+                       /* transaction data */
+                       binder_uintptr_t        buffer;
+                       /* offsets from buffer to flat_binder_object structs */
+                       binder_uintptr_t        offsets;
+               } ptr;
+               __u8    buf[8];
+       } data;
+};
+
+struct binder_ptr_cookie {
+       binder_uintptr_t ptr;
+       binder_uintptr_t cookie;
+};
+
+struct binder_handle_cookie {
+       __u32 handle;
+       binder_uintptr_t cookie;
+} __packed;
+
+struct binder_pri_desc {
+       __s32 priority;
+       __u32 desc;
+};
+
+struct binder_pri_ptr_cookie {
+       __s32 priority;
+       binder_uintptr_t ptr;
+       binder_uintptr_t cookie;
+};
+
+enum binder_driver_return_protocol {
+       BR_ERROR = _IOR('r', 0, __s32),
+       /*
+        * int: error code
+        */
+
+       BR_OK = _IO('r', 1),
+       /* No parameters! */
+
+       BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data),
+       BR_REPLY = _IOR('r', 3, struct binder_transaction_data),
+       /*
+        * binder_transaction_data: the received command.
+        */
+
+       BR_ACQUIRE_RESULT = _IOR('r', 4, __s32),
+       /*
+        * not currently supported
+        * int: 0 if the last bcATTEMPT_ACQUIRE was not successful.
+        * Else the remote object has acquired a primary reference.
+        */
+
+       BR_DEAD_REPLY = _IO('r', 5),
+       /*
+        * The target of the last transaction (either a bcTRANSACTION or
+        * a bcATTEMPT_ACQUIRE) is no longer with us.  No parameters.
+        */
+
+       BR_TRANSACTION_COMPLETE = _IO('r', 6),
+       /*
+        * No parameters... always refers to the last transaction requested
+        * (including replies).  Note that this will be sent even for
+        * asynchronous transactions.
+        */
+
+       BR_INCREFS = _IOR('r', 7, struct binder_ptr_cookie),
+       BR_ACQUIRE = _IOR('r', 8, struct binder_ptr_cookie),
+       BR_RELEASE = _IOR('r', 9, struct binder_ptr_cookie),
+       BR_DECREFS = _IOR('r', 10, struct binder_ptr_cookie),
+       /*
+        * void *:      ptr to binder
+        * void *: cookie for binder
+        */
+
+       BR_ATTEMPT_ACQUIRE = _IOR('r', 11, struct binder_pri_ptr_cookie),
+       /*
+        * not currently supported
+        * int: priority
+        * void *: ptr to binder
+        * void *: cookie for binder
+        */
+
+       BR_NOOP = _IO('r', 12),
+       /*
+        * No parameters.  Do nothing and examine the next command.  It exists
+        * primarily so that we can replace it with a BR_SPAWN_LOOPER command.
+        */
+
+       BR_SPAWN_LOOPER = _IO('r', 13),
+       /*
+        * No parameters.  The driver has determined that a process has no
+        * threads waiting to service incoming transactions.  When a process
+        * receives this command, it must spawn a new service thread and
+        * register it via bcENTER_LOOPER.
+        */
+
+       BR_FINISHED = _IO('r', 14),
+       /*
+        * not currently supported
+        * stop threadpool thread
+        */
+
+       BR_DEAD_BINDER = _IOR('r', 15, binder_uintptr_t),
+       /*
+        * void *: cookie
+        */
+       BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, binder_uintptr_t),
+       /*
+        * void *: cookie
+        */
+
+       BR_FAILED_REPLY = _IO('r', 17),
+       /*
+        * The the last transaction (either a bcTRANSACTION or
+        * a bcATTEMPT_ACQUIRE) failed (e.g. out of memory).  No parameters.
+        */
+};
+
+enum binder_driver_command_protocol {
+       BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data),
+       BC_REPLY = _IOW('c', 1, struct binder_transaction_data),
+       /*
+        * binder_transaction_data: the sent command.
+        */
+
+       BC_ACQUIRE_RESULT = _IOW('c', 2, __s32),
+       /*
+        * not currently supported
+        * int:  0 if the last BR_ATTEMPT_ACQUIRE was not successful.
+        * Else you have acquired a primary reference on the object.
+        */
+
+       BC_FREE_BUFFER = _IOW('c', 3, binder_uintptr_t),
+       /*
+        * void *: ptr to transaction data received on a read
+        */
+
+       BC_INCREFS = _IOW('c', 4, __u32),
+       BC_ACQUIRE = _IOW('c', 5, __u32),
+       BC_RELEASE = _IOW('c', 6, __u32),
+       BC_DECREFS = _IOW('c', 7, __u32),
+       /*
+        * int: descriptor
+        */
+
+       BC_INCREFS_DONE = _IOW('c', 8, struct binder_ptr_cookie),
+       BC_ACQUIRE_DONE = _IOW('c', 9, struct binder_ptr_cookie),
+       /*
+        * void *: ptr to binder
+        * void *: cookie for binder
+        */
+
+       BC_ATTEMPT_ACQUIRE = _IOW('c', 10, struct binder_pri_desc),
+       /*
+        * not currently supported
+        * int: priority
+        * int: descriptor
+        */
+
+       BC_REGISTER_LOOPER = _IO('c', 11),
+       /*
+        * No parameters.
+        * Register a spawned looper thread with the device.
+        */
+
+       BC_ENTER_LOOPER = _IO('c', 12),
+       BC_EXIT_LOOPER = _IO('c', 13),
+       /*
+        * No parameters.
+        * These two commands are sent as an application-level thread
+        * enters and exits the binder loop, respectively.  They are
+        * used so the binder can have an accurate count of the number
+        * of looping threads it has available.
+        */
+
+       BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14,
+                                               struct binder_handle_cookie),
+       /*
+        * int: handle
+        * void *: cookie
+        */
+
+       BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15,
+                                               struct binder_handle_cookie),
+       /*
+        * int: handle
+        * void *: cookie
+        */
+
+       BC_DEAD_BINDER_DONE = _IOW('c', 16, binder_uintptr_t),
+       /*
+        * void *: cookie
+        */
+};
+
+#endif /* _UAPI_LINUX_BINDER_H */
+